diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..f93ffb19d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,231 @@ +# Remove the line below if you want to inherit .editorconfig settings from higher directories +root = true + +# C# files +[*.cs] + +#### Core EditorConfig Options #### + +# Indentation and spacing +indent_size = 4 +indent_style = Space +tab_width = 4 + +# New line preferences +end_of_line = crlf +insert_final_newline = true + +#### .NET Coding Conventions #### + +# Organize usings +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = false +file_header_template = unset + +# this. and Me. preferences +dotnet_style_qualification_for_event = false +dotnet_style_qualification_for_field = false +dotnet_style_qualification_for_method = false +dotnet_style_qualification_for_property = false + +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true +dotnet_style_predefined_type_for_member_access = true + +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_operators = never_if_unnecessary +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity + +# Modifier preferences +dotnet_style_require_accessibility_modifiers = for_non_interface_members + +# Expression-level preferences +dotnet_style_coalesce_expression = true +dotnet_style_collection_initializer = true +dotnet_style_explicit_tuple_names = true +dotnet_style_namespace_match_folder = true +dotnet_style_null_propagation = true +dotnet_style_object_initializer = true +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_auto_properties = true +dotnet_style_prefer_collection_expression = when_types_loosely_match +dotnet_style_prefer_compound_assignment = true +dotnet_style_prefer_conditional_expression_over_assignment = true +dotnet_style_prefer_conditional_expression_over_return = true +dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed +dotnet_style_prefer_inferred_anonymous_type_member_names = true +dotnet_style_prefer_inferred_tuple_names = true +dotnet_style_prefer_is_null_check_over_reference_equality_method = true +dotnet_style_prefer_simplified_boolean_expressions = true +dotnet_style_prefer_simplified_interpolation = true + +# Field preferences +dotnet_style_readonly_field = true + +# Parameter preferences +dotnet_code_quality_unused_parameters = all + +# Suppression preferences +dotnet_remove_unnecessary_suppression_exclusions = none + +# New line preferences +dotnet_style_allow_multiple_blank_lines_experimental = true +dotnet_style_allow_statement_immediately_after_block_experimental = true + +#### C# Coding Conventions #### + +# var preferences +csharp_style_var_elsewhere = false +csharp_style_var_for_built_in_types = false +csharp_style_var_when_type_is_apparent = false + +# Expression-bodied members +csharp_style_expression_bodied_accessors = true +csharp_style_expression_bodied_constructors = false +csharp_style_expression_bodied_indexers = true +csharp_style_expression_bodied_lambdas = true +csharp_style_expression_bodied_local_functions = false +csharp_style_expression_bodied_methods = false +csharp_style_expression_bodied_operators = false +csharp_style_expression_bodied_properties = true + +# Pattern matching preferences +csharp_style_pattern_matching_over_as_with_null_check = true +csharp_style_pattern_matching_over_is_with_cast_check = true +csharp_style_prefer_extended_property_pattern = true +csharp_style_prefer_not_pattern = true +csharp_style_prefer_pattern_matching = true +csharp_style_prefer_switch_expression = true + +# Null-checking preferences +csharp_style_conditional_delegate_call = true + +# Modifier preferences +csharp_prefer_static_local_function = true +csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async +csharp_style_prefer_readonly_struct = true +csharp_style_prefer_readonly_struct_member = true + +# Code-block preferences +csharp_prefer_braces = true +csharp_prefer_simple_using_statement = true +csharp_style_namespace_declarations = block_scoped +csharp_style_prefer_method_group_conversion = true +csharp_style_prefer_primary_constructors = true +csharp_style_prefer_top_level_statements = true + +# Expression-level preferences +csharp_prefer_simple_default_expression = true +csharp_style_deconstructed_variable_declaration = true +csharp_style_implicit_object_creation_when_type_is_apparent = true +csharp_style_inlined_variable_declaration = true +csharp_style_prefer_index_operator = true +csharp_style_prefer_local_over_anonymous_function = true +csharp_style_prefer_null_check_over_type_check = true +csharp_style_prefer_range_operator = true +csharp_style_prefer_tuple_swap = true +csharp_style_prefer_utf8_string_literals = true +csharp_style_throw_expression = true +csharp_style_unused_value_assignment_preference = discard_variable +csharp_style_unused_value_expression_statement_preference = discard_variable + +# 'using' directive preferences +csharp_using_directive_placement = outside_namespace + +# New line preferences +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true +csharp_style_allow_embedded_statements_on_same_line_experimental = true + +#### C# Formatting Rules #### + +# New line preferences +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = false +csharp_indent_labels = one_less_than_current +csharp_indent_switch_labels = true + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Wrapping preferences +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Naming styles #### + +# Naming rules + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# Symbol specifications + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Naming styles + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case diff --git a/Assembly-CSharp/Assembly-CSharp.csproj b/Assembly-CSharp/Assembly-CSharp.csproj index e2fa85001..6a84b925f 100644 --- a/Assembly-CSharp/Assembly-CSharp.csproj +++ b/Assembly-CSharp/Assembly-CSharp.csproj @@ -333,6 +333,11 @@ + + + + + @@ -1372,6 +1377,14 @@ + + + PreserveNewest + + + PreserveNewest + + diff --git a/Assembly-CSharp/Assets/Sources/Graphics/Movie/MovieMaterial.cs b/Assembly-CSharp/Assets/Sources/Graphics/Movie/MovieMaterial.cs index c3ca68951..ec2a6e735 100644 --- a/Assembly-CSharp/Assets/Sources/Graphics/Movie/MovieMaterial.cs +++ b/Assembly-CSharp/Assets/Sources/Graphics/Movie/MovieMaterial.cs @@ -165,11 +165,17 @@ public void Update() { if (this.advance) { - double elapsedTime = this.m_elapsedTime; - float num = Mathf.Max(this.playSpeed, 0f); - bool flag = false; - flag |= this.isFMV; - if (flag) + int soundID = SoundLib.MovieAudioPlayer.GetActiveSoundID(); + double elapsedTime = ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_GetElapsedPlaybackTime(soundID) / 1000.0; + + // We allow +/- 66ms of delay + if (elapsedTime > 0 && Math.Abs(elapsedTime - m_elapsedTime) > 0.066) + { + // Forces sync with audio + this.m_elapsedTime = elapsedTime; + } + + if (this.isFMV) { if (this.preciseTimeCycleCounter == 0) { @@ -190,9 +196,9 @@ public void Update() } else { - this.m_elapsedTime += (double)(Mathf.Min(Time.deltaTime, 0.067f) * num); + this.m_elapsedTime += (double)(Mathf.Min(Time.deltaTime, 0.067f) * Mathf.Max(this.playSpeed, 0f)); } - if (this.shouldSync) + /*if (this.shouldSync) { SoundLib.SeekMovieAudio(this.movieKey, this.PlayPosition); this.shouldSync = false; @@ -205,7 +211,7 @@ public void Update() SoundLib.SeekMovieAudio(this.movieKey, this.PlayPosition); this.syncElapsed = 0f; } - } + }*/ } } else @@ -591,7 +597,7 @@ public void Destroy() public Action OnFinished; - private String movieKey; + public String movieKey; private Boolean advance; diff --git a/Assembly-CSharp/Assets/Sources/Scripts/UI/Common/FF9UIDataTool.cs b/Assembly-CSharp/Assets/Sources/Scripts/UI/Common/FF9UIDataTool.cs index f589521ea..37dc246ba 100644 --- a/Assembly-CSharp/Assets/Sources/Scripts/UI/Common/FF9UIDataTool.cs +++ b/Assembly-CSharp/Assets/Sources/Scripts/UI/Common/FF9UIDataTool.cs @@ -971,1554 +971,493 @@ public static Sprite LoadWorldTitle(SByte titleId, Boolean isShadow) public static readonly Dictionary IconSpriteName = new Dictionary { - { - 1, - "cursor_hand_choice" - }, - { - 19, - "arrow_up" - }, - { - 20, - "arrow_down" - }, - { - 27, - "help_mog_dialog" - }, - { - 28, - "help_mog_hand_1" - }, - { - 29, - "help_mog_hand_2" - }, - { - 92, - "item00_00" - }, - { - 93, - "item01_00" - }, - { - 94, - "item02_00" - }, - { - 95, - "item03_00" - }, - { - 96, - "item04_00" - }, - { - 97, - "item05_00" - }, - { - 98, - "item06_00" - }, - { - 99, - "item07_00" - }, - { - 100, - "item08_00" - }, - { - 101, - "item09_00" - }, - { - 102, - "item10_00" - }, - { - 103, - "item11_00" - }, - { - 104, - "item12_00" - }, - { - 105, - "item13_01" - }, - { - 106, - "item14_02" - }, - { - 107, - "item15_01" - }, - { - 108, - "item16_01" - }, - { - 109, - "item17_01" - }, - { - 110, - "item18_00" - }, - { - 111, - "item19_02" - }, - { - 112, - "item20_01" - }, - { - 113, - "item21_00" - }, - { - 114, - "item22_02" - }, - { - 115, - "item23_00" - }, - { - 116, - "item24_00" - }, - { - 117, - "item25_03" - }, - { - 118, - "item26_09" - }, - { - 119, - "item27_01" - }, - { - 120, - "item28_03" - }, - { - 121, - "item29_01" - }, - { - 122, - "item30_00" - }, - { - 123, - "item31_08" - }, - { - 124, - "item32_02" - }, - { - 125, - "item33_01" - }, - { - 126, - "item34_02" - }, - { - 127, - "item35_03" - }, - { - 131, - "icon_status_22" - }, - { - 132, - "icon_status_23" - }, - { - 133, - "icon_status_11" - }, - { - 134, - "icon_status_00" - }, - { - 135, - "icon_status_01" - }, - { - 136, - "icon_status_02" - }, - { - 137, - "icon_status_03" - }, - { - 138, - "icon_status_04" - }, - { - 139, - "icon_status_05" - }, - { - 140, - "icon_status_06" - }, - { - 141, - "icon_status_07" - }, - { - 142, - "icon_status_08" - }, - { - 143, - "icon_status_09" - }, - { - 144, - "icon_status_10" - }, - { - 145, - "icon_status_12" - }, - { - 146, - "icon_status_13" - }, - { - 147, - "icon_status_14" - }, - { - 148, - "icon_status_15" - }, - { - 149, - "icon_status_16" - }, - { - 150, - "icon_status_17" - }, - { - 151, - "icon_status_18" - }, - { - 152, - "icon_status_19" - }, - { - 153, - "icon_status_20" - }, - { - 154, - "icon_status_21" - }, - { - 180, - "text_lv_us_uk_jp_gr_it" - }, - { - 188, - "ability_stone" - }, - { - 189, - "skill_stone_on" - }, - { - 190, - "ability_stone_null" - }, - { - 191, - "skill_stone_null" - }, - { - 192, - "ap_bar_complete_star" - }, - { - 193, - "skill_stone_gem" - }, - { - 244, - "skill_stone_off" - }, - { - 254, - "ap_bar_full" - }, - { - 255, - "ap_bar_half" - }, - { - 257, - "balloon_exclamation" - }, - { - 258, - "balloon_question" - }, - { - 259, - "balloon_card" - }, - { - 260, - "icon_action" - }, - { - 261, - "icon_back" - }, - { - 262, - "icon_analog" - }, - { - 263, - "virtual_up" - }, - { - 264, - "virtual_down" - }, - { - 265, - "virtual_left" - }, - { - 266, - "virtual_right" - }, - { - 267, - "icon_left" - }, - { - 268, - "icon_up" - }, - { - 269, - "icon_right" - }, - { - 270, - "icon_down" - }, - { - 271, - "icon_x" - }, - { - 272, - "icon_y" - }, - { - 273, - "icon_b" - }, - { - 274, - "icon_a" - }, - { - 275, - "icon_minus" - }, - { - 276, - "icon_plus" - }, - { - 277, - "icon_racing_01" - }, - { - 278, - "icon_racing_02" - }, - { - 279, - "icon_help" - }, - { - 280, - "virtual_aside" - }, - { - 281, - "icon_world_map" - }, - { - 282, - "icon_world_mog" - }, - { - 283, - "icon_world_map" - }, - { - 284, - "icon_cam_rotate" - }, - { - 285, - "icon_cam_perspective" - }, - { - 286, - "icon_world_dismount" - }, - { - 287, - "icon_cam_align" - }, - { - 288, - "icon_menu_jp" - }, - { - 289, - "icon_menu_us" - }, - { - 290, - "icon_menu_fr" - }, - { - 291, - "icon_menu_es" - }, - { - 292, - "icon_menu_gr" - }, - { - 293, - "icon_menu_it" - }, - { - 294, - "icon_menu_uk" - }, - { - 295, - "icon_deck_jp" - }, - { - 296, - "icon_deck_us" - }, - { - 297, - "icon_deck_fr" - }, - { - 298, - "icon_deck_es" - }, - { - 299, - "icon_deck_gr" - }, - { - 300, - "icon_deck_it" - }, - { - 301, - "icon_deck_uk" - }, - { - 302, - "icon_battle_run" - }, - { - 303, - "icon_battle_all" - }, - { - 304, - "icon_pause" - }, - { - 305, - "icon_bubble_question" - }, - { - 306, - "text_touch_us_uk_fr_gr_it_es" - }, - { - 307, - "text_touchconfirm_us_uk_fr_gr_it_es" - }, - { - 308, - "text_touchscreen_us_uk_fr_gr_it_es" - }, - { - 309, - "text_characterpanel_us_uk_fr_gr_it_es" - }, - { - 310, - "icon_bubble_card" - }, - { - 311, - "icon_chocobo_dig" - }, - { - 312, - "icon_bubble_question" - }, - { - 313, - "icon_ate_us_uk_jp" - }, - { - 314, - "icon_ate_es_fr" - }, - { - 315, - "icon_ate_gr_it" - }, - { - 316, - "text_touch_jp" - }, - { - 317, - "text_touch_us_uk" - }, - { - 318, - "text_touch_fr" - }, - { - 319, - "text_touch_es" - }, - { - 320, - "text_touch_gr" - }, - { - 321, - "text_touch_it" - }, - { - 322, - "text_touchconfirm_jp" - }, - { - 323, - "text_touchconfirm_us_uk" - }, - { - 324, - "text_touchconfirm_fr" - }, - { - 325, - "text_touchconfirm_es" - }, - { - 326, - "text_touchconfirm_gr" - }, - { - 327, - "text_touchconfirm_it" - }, - { - 328, - "text_touchscreen_jp" - }, - { - 329, - "text_touchscreen_us_uk" - }, - { - 330, - "text_touchscreen_fr" - }, - { - 331, - "text_touchscreen_es" - }, - { - 332, - "text_touchscreen_gr" - }, - { - 333, - "text_touchscreen_it" - }, - { - 334, - "text_characterpanel_jp" - }, - { - 335, - "text_characterpanel_us_uk" - }, - { - 336, - "text_characterpanel_fr" - }, - { - 337, - "text_characterpanel_es" - }, - { - 338, - "text_characterpanel_gr" - }, - { - 339, - "text_characterpanel_it" - }, - { - 340, - "icon_ate_us_uk_jp" - }, - { - 341, - "icon_ate_es_fr" - }, - { - 342, - "icon_ate_gr_it" - }, - { - 343, - "icon_beach" - }, - { - 512, - "item01_06" - }, - { - 513, - "item01_12" - }, - { - 514, - "item03_03" - }, - { - 515, - "item03_05" - }, - { - 516, - "item03_09" - }, - { - 517, - "item03_11" - }, - { - 518, - "item03_13" - }, - { - 519, - "item04_03" - }, - { - 520, - "item05_03" - }, - { - 521, - "item05_05" - }, - { - 522, - "item05_06" - }, - { - 523, - "item05_12" - }, - { - 524, - "item06_03" - }, - { - 525, - "item06_06" - }, - { - 526, - "item06_13" - }, - { - 527, - "item08_03" - }, - { - 528, - "item08_04" - }, - { - 529, - "item08_12" - }, - { - 530, - "item09_02" - }, - { - 531, - "item09_03" - }, - { - 532, - "item09_07" - }, - { - 533, - "item10_02" - }, - { - 534, - "item10_05" - }, - { - 535, - "item10_09" - }, - { - 536, - "item10_11" - }, - { - 537, - "item11_02" - }, - { - 538, - "item11_04" - }, - { - 539, - "item13_02" - }, - { - 540, - "item13_03" - }, - { - 541, - "item13_07" - }, - { - 542, - "item13_14" - }, - { - 543, - "item14_08" - }, - { - 544, - "item14_09" - }, - { - 545, - "item14_11" - }, - { - 546, - "item15_02" - }, - { - 547, - "item15_04" - }, - { - 548, - "item15_07" - }, - { - 549, - "item15_08" - }, - { - 550, - "item15_09" - }, - { - 551, - "item15_12" - }, - { - 552, - "item16_03" - }, - { - 553, - "item16_08" - }, - { - 554, - "item16_09" - }, - { - 555, - "item16_12" - }, - { - 556, - "item17_02" - }, - { - 557, - "item17_03" - }, - { - 558, - "item17_08" - }, - { - 559, - "item17_14" - }, - { - 560, - "item18_06" - }, - { - 561, - "item18_08" - }, - { - 562, - "item18_09" - }, - { - 563, - "item18_10" - }, - { - 564, - "item18_11" - }, - { - 565, - "item18_14" - }, - { - 566, - "item19_03" - }, - { - 567, - "item19_06" - }, - { - 568, - "item19_08" - }, - { - 569, - "item19_11" - }, - { - 570, - "item19_12" - }, - { - 571, - "item20_02" - }, - { - 572, - "item20_03" - }, - { - 573, - "item20_06" - }, - { - 574, - "item20_10" - }, - { - 575, - "item20_11" - }, - { - 576, - "item20_14" - }, - { - 577, - "item21_01" - }, - { - 578, - "item21_02" - }, - { - 579, - "item21_03" - }, - { - 580, - "item21_04" - }, - { - 581, - "item21_05" - }, - { - 582, - "item21_06" - }, - { - 583, - "item21_07" - }, - { - 584, - "item21_08" - }, - { - 585, - "item21_10" - }, - { - 586, - "item21_12" - }, - { - 587, - "item21_13" - }, - { - 588, - "item21_14" - }, - { - 589, - "item22_06" - }, - { - 590, - "item22_08" - }, - { - 591, - "item22_09" - }, - { - 592, - "item23_03" - }, - { - 593, - "item23_05" - }, - { - 594, - "item23_06" - }, - { - 595, - "item23_07" - }, - { - 596, - "item23_09" - }, - { - 597, - "item23_10" - }, - { - 598, - "item24_02" - }, - { - 599, - "item24_03" - }, - { - 600, - "item24_04" - }, - { - 601, - "item24_06" - }, - { - 602, - "item24_08" - }, - { - 603, - "item24_10" - }, - { - 604, - "item24_11" - }, - { - 605, - "item25_09" - }, - { - 606, - "item27_09" - }, - { - 607, - "item28_08" - }, - { - 608, - "item29_02" - }, - { - 609, - "item29_03" - }, - { - 610, - "item29_04" - }, - { - 611, - "item29_08" - }, - { - 612, - "item29_10" - }, - { - 613, - "item29_12" - }, - { - 614, - "item29_14" - }, - { - 615, - "item31_09" - }, - { - 616, - "item31_14" - }, - { - 617, - "item32_03" - }, - { - 618, - "item33_02" - }, - { - 619, - "item33_03" - }, - { - 620, - "item33_04" - }, - { - 621, - "item33_05" - }, - { - 622, - "item33_11" - }, - { - 623, - "item33_14" - }, - { - 624, - "item35_12" - }, - { - 625, - "icon_equip_0" - }, - { - 626, - "icon_equip_1" - }, - { - 627, - "icon_equip_2" - }, - { - 628, - "icon_equip_3" - }, - { - 629, - "icon_equip_4" - }, - { - 630, - "keyboard_button_enter" - }, - { - 631, - "keyboard_button_esc" - }, - { - 632, - "keyboard_button_arrow_up" - }, - { - 633, - "keyboard_button_arrow_left" - }, - { - 634, - "keyboard_button_arrow_right" - }, - { - 635, - "keyboard_button_arrow_down" - }, - { - 636, - "text_lv_es" - }, - { - 637, - "text_lv_fr" - }, - { - 638, - "joystick_start" - }, - { - 639, - "joystick_l2" - }, - { - 640, - "joystick_r2" - }, - { - 641, - "joystick_button_y" - } + { 1, "cursor_hand_choice" }, + { 2, "cursor_hand_here" }, + { 17, "arrow_left" }, + { 18, "arrow_right" }, + { 19, "arrow_up" }, + { 20, "arrow_down" }, + { 27, "help_mog_dialog" }, + { 28, "help_mog_hand_1" }, + { 29, "help_mog_hand_2" }, + { 92, "item00_00" }, + { 93, "item01_00" }, + { 94, "item02_00" }, + { 95, "item03_00" }, + { 96, "item04_00" }, + { 97, "item05_00" }, + { 98, "item06_00" }, + { 99, "item07_00" }, + { 100, "item08_00" }, + { 101, "item09_00" }, + { 102, "item10_00" }, + { 103, "item11_00" }, + { 104, "item12_00" }, + { 105, "item13_01" }, + { 106, "item14_02" }, + { 107, "item15_01" }, + { 108, "item16_01" }, + { 109, "item17_01" }, + { 110, "item18_00" }, + { 111, "item19_02" }, + { 112, "item20_01" }, + { 113, "item21_00" }, + { 114, "item22_02" }, + { 115, "item23_00" }, + { 116, "item24_00" }, + { 117, "item25_03" }, + { 118, "item26_09" }, + { 119, "item27_01" }, + { 120, "item28_03" }, + { 121, "item29_01" }, + { 122, "item30_00" }, + { 123, "item31_08" }, + { 124, "item32_02" }, + { 125, "item33_01" }, + { 126, "item34_02" }, + { 127, "item35_03" }, + { 131, "icon_status_22" }, + { 132, "icon_status_23" }, + { 133, "icon_status_11" }, + { 134, "icon_status_00" }, + { 135, "icon_status_01" }, + { 136, "icon_status_02" }, + { 137, "icon_status_03" }, + { 138, "icon_status_04" }, + { 139, "icon_status_05" }, + { 140, "icon_status_06" }, + { 141, "icon_status_07" }, + { 142, "icon_status_08" }, + { 143, "icon_status_09" }, + { 144, "icon_status_10" }, + { 145, "icon_status_12" }, + { 146, "icon_status_13" }, + { 147, "icon_status_14" }, + { 148, "icon_status_15" }, + { 149, "icon_status_16" }, + { 150, "icon_status_17" }, + { 151, "icon_status_18" }, + { 152, "icon_status_19" }, + { 153, "icon_status_20" }, + { 154, "icon_status_21" }, + { 155, "icon_status_04_es" }, + { 180, "text_lv_us_uk_jp_gr_it" }, + { 188, "ability_stone" }, + { 189, "skill_stone_on" }, + { 190, "ability_stone_null" }, + { 191, "skill_stone_null" }, + { 192, "ap_bar_complete_star" }, + { 193, "skill_stone_gem" }, + { 194, "skill_stone_gem_00" }, + { 195, "skill_stone_gem_01" }, + { 196, "skill_stone_gem_02" }, + { 197, "skill_stone_gem_03" }, + { 198, "skill_stone_gem_04" }, + { 199, "skill_stone_gem_05" }, + { 200, "skill_stone_gem_06" }, + { 244, "skill_stone_off" }, + { 245, "config_arrow" }, + { 246, "balloon_beach_act" }, + { 247, "balloon_exclamation_act" }, + { 248, "balloon_question_act" }, + { 249, "balloon_card_act" }, + { 250, "virtual_map" }, + { 254, "ap_bar_full" }, + { 255, "ap_bar_half" }, + { 256, "balloon_beach" }, + { 257, "balloon_exclamation" }, + { 258, "balloon_question" }, + { 259, "balloon_card" }, + { 260, "icon_action" }, + { 261, "icon_back" }, + { 262, "icon_analog" }, + { 263, "virtual_up" }, + { 264, "virtual_down" }, + { 265, "virtual_left" }, + { 266, "virtual_right" }, + { 267, "icon_left" }, + { 268, "icon_up" }, + { 269, "icon_right" }, + { 270, "icon_down" }, + { 271, "icon_x" }, + { 272, "icon_y" }, + { 273, "icon_b" }, + { 274, "icon_a" }, + { 275, "icon_minus" }, + { 276, "icon_plus" }, + { 277, "icon_racing_01" }, + { 278, "icon_racing_02" }, + { 279, "icon_help" }, + { 280, "virtual_aside" }, + { 281, "icon_world_map" }, + { 282, "icon_world_mog" }, + { 283, "icon_world_map" }, + { 284, "icon_cam_rotate" }, + { 285, "icon_cam_perspective" }, + { 286, "icon_world_dismount" }, + { 287, "icon_cam_align" }, + { 288, "icon_menu_jp" }, + { 289, "icon_menu_us" }, + { 290, "icon_menu_fr" }, + { 291, "icon_menu_es" }, + { 292, "icon_menu_gr" }, + { 293, "icon_menu_it" }, + { 294, "icon_menu_uk" }, + { 295, "icon_deck_jp" }, + { 296, "icon_deck_us" }, + { 297, "icon_deck_fr" }, + { 298, "icon_deck_es" }, + { 299, "icon_deck_gr" }, + { 300, "icon_deck_it" }, + { 301, "icon_deck_uk" }, + { 302, "icon_battle_run" }, + { 303, "icon_battle_all" }, + { 304, "icon_pause" }, + { 305, "icon_bubble_question" }, + { 306, "text_touch_us_uk_fr_gr_it_es" }, + { 307, "text_touchconfirm_us_uk_fr_gr_it_es" }, + { 308, "text_touchscreen_us_uk_fr_gr_it_es" }, + { 309, "text_characterpanel_us_uk_fr_gr_it_es" }, + { 310, "icon_bubble_card" }, + { 311, "icon_chocobo_dig" }, + { 312, "icon_bubble_question" }, + { 313, "icon_ate_us_uk_jp" }, + { 314, "icon_ate_es_fr" }, + { 315, "icon_ate_gr_it" }, + { 316, "text_touch_jp" }, + { 317, "text_touch_us_uk" }, + { 318, "text_touch_fr" }, + { 319, "text_touch_es" }, + { 320, "text_touch_gr" }, + { 321, "text_touch_it" }, + { 322, "text_touchconfirm_jp" }, + { 323, "text_touchconfirm_us_uk" }, + { 324, "text_touchconfirm_fr" }, + { 325, "text_touchconfirm_es" }, + { 326, "text_touchconfirm_gr" }, + { 327, "text_touchconfirm_it" }, + { 328, "text_touchscreen_jp" }, + { 329, "text_touchscreen_us_uk" }, + { 330, "text_touchscreen_fr" }, + { 331, "text_touchscreen_es" }, + { 332, "text_touchscreen_gr" }, + { 333, "text_touchscreen_it" }, + { 334, "text_characterpanel_jp" }, + { 335, "text_characterpanel_us_uk" }, + { 336, "text_characterpanel_fr" }, + { 337, "text_characterpanel_es" }, + { 338, "text_characterpanel_gr" }, + { 339, "text_characterpanel_it" }, + { 340, "icon_ate_us_uk_jp" }, + { 341, "icon_ate_es_fr" }, + { 342, "icon_ate_gr_it" }, + { 343, "icon_beach" }, + { 350, "icon_ff" }, + { 351, "icon_battle" }, + { 352, "icon_9999" }, + { 353, "icon_encounter" }, + { 354, "icon_gil" }, + { 355, "icon_masterskill" }, + { 360, "icon_bubble" }, + { 361, "icon_card" }, + { 362, "icon_new_exclamation" }, + { 363, "icon_new_text" }, + { 364, "icon_time" }, + { 450, "item00_15" }, + { 451, "item01_15" }, + { 452, "item02_15" }, + { 453, "item03_15" }, + { 454, "item04_15" }, + { 455, "item05_15" }, + { 456, "item06_15" }, + { 457, "item07_15" }, + { 458, "item08_15" }, + { 459, "item09_15" }, + { 460, "item10_15" }, + { 461, "item11_15" }, + { 462, "item12_15" }, + { 463, "item13_15" }, + { 464, "item14_15" }, + { 465, "item15_15" }, + { 466, "item16_15" }, + { 467, "item17_15" }, + { 468, "item18_15" }, + { 469, "item19_15" }, + { 470, "item20_15" }, + { 471, "item21_15" }, + { 472, "item22_15" }, + { 473, "item23_15" }, + { 474, "item24_15" }, + { 475, "item25_15" }, + { 476, "item26_15" }, + { 477, "item27_15" }, + { 478, "item28_15" }, + { 479, "item29_15" }, + { 480, "item30_15" }, + { 481, "item31_15" }, + { 482, "item32_15" }, + { 483, "item33_15" }, + { 484, "item34_15" }, + { 485, "item35_15" }, + { 512, "item01_06" }, + { 513, "item01_12" }, + { 514, "item03_03" }, + { 515, "item03_05" }, + { 516, "item03_09" }, + { 517, "item03_11" }, + { 518, "item03_13" }, + { 519, "item04_03" }, + { 520, "item05_03" }, + { 521, "item05_05" }, + { 522, "item05_06" }, + { 523, "item05_12" }, + { 524, "item06_03" }, + { 525, "item06_06" }, + { 526, "item06_13" }, + { 527, "item08_03" }, + { 528, "item08_04" }, + { 529, "item08_12" }, + { 530, "item09_02" }, + { 531, "item09_03" }, + { 532, "item09_07" }, + { 533, "item10_02" }, + { 534, "item10_05" }, + { 535, "item10_09" }, + { 536, "item10_11" }, + { 537, "item11_02" }, + { 538, "item11_04" }, + { 539, "item13_02" }, + { 540, "item13_03" }, + { 541, "item13_07" }, + { 542, "item13_14" }, + { 543, "item14_08" }, + { 544, "item14_09" }, + { 545, "item14_11" }, + { 546, "item15_02" }, + { 547, "item15_04" }, + { 548, "item15_07" }, + { 549, "item15_08" }, + { 550, "item15_09" }, + { 551, "item15_12" }, + { 552, "item16_03" }, + { 553, "item16_08" }, + { 554, "item16_09" }, + { 555, "item16_12" }, + { 556, "item17_02" }, + { 557, "item17_03" }, + { 558, "item17_08" }, + { 559, "item17_14" }, + { 560, "item18_06" }, + { 561, "item18_08" }, + { 562, "item18_09" }, + { 563, "item18_10" }, + { 564, "item18_11" }, + { 565, "item18_14" }, + { 566, "item19_03" }, + { 567, "item19_06" }, + { 568, "item19_08" }, + { 569, "item19_11" }, + { 570, "item19_12" }, + { 571, "item20_02" }, + { 572, "item20_03" }, + { 573, "item20_06" }, + { 574, "item20_10" }, + { 575, "item20_11" }, + { 576, "item20_14" }, + { 577, "item21_01" }, + { 578, "item21_02" }, + { 579, "item21_03" }, + { 580, "item21_04" }, + { 581, "item21_05" }, + { 582, "item21_06" }, + { 583, "item21_07" }, + { 584, "item21_08" }, + { 585, "item21_10" }, + { 586, "item21_12" }, + { 587, "item21_13" }, + { 588, "item21_14" }, + { 589, "item22_06" }, + { 590, "item22_08" }, + { 591, "item22_09" }, + { 592, "item23_03" }, + { 593, "item23_05" }, + { 594, "item23_06" }, + { 595, "item23_07" }, + { 596, "item23_09" }, + { 597, "item23_10" }, + { 598, "item24_02" }, + { 599, "item24_03" }, + { 600, "item24_04" }, + { 601, "item24_06" }, + { 602, "item24_08" }, + { 603, "item24_10" }, + { 604, "item24_11" }, + { 605, "item25_09" }, + { 606, "item27_09" }, + { 607, "item28_08" }, + { 608, "item29_02" }, + { 609, "item29_03" }, + { 610, "item29_04" }, + { 611, "item29_08" }, + { 612, "item29_10" }, + { 613, "item29_12" }, + { 614, "item29_14" }, + { 615, "item31_09" }, + { 616, "item31_14" }, + { 617, "item32_03" }, + { 618, "item33_02" }, + { 619, "item33_03" }, + { 620, "item33_04" }, + { 621, "item33_05" }, + { 622, "item33_11" }, + { 623, "item33_14" }, + { 624, "item35_12" }, + { 625, "icon_equip_0" }, + { 626, "icon_equip_1" }, + { 627, "icon_equip_2" }, + { 628, "icon_equip_3" }, + { 629, "icon_equip_4" }, + { 630, "keyboard_button_enter" }, + { 631, "keyboard_button_esc" }, + { 632, "keyboard_button_arrow_up" }, + { 633, "keyboard_button_arrow_left" }, + { 634, "keyboard_button_arrow_right" }, + { 635, "keyboard_button_arrow_down" }, + { 636, "text_lv_es" }, + { 637, "text_lv_fr" }, + { 638, "joystick_start" }, + { 639, "joystick_l2" }, + { 640, "joystick_r2" }, + { 641, "joystick_button_y" }, + { 642, "joystick_button_x" }, + { 643, "joystick_button_a" }, + { 644, "joystick_button_b" }, + { 645, "joystick_analog_r" }, + { 646, "joystick_select" }, + { 647, "joystick_l1" }, + { 648, "joystick_r1" }, + { 649, "keyboard_button" }, + { 650, "keyboard_button_backspace" }, + { 651, "keyboard_button_backspace_fr_gr_it" }, + { 652, "keyboard_button_enter_fr_gr" }, + { 653, "keyboard_button_enter_it" }, + { 654, "keyboard_button_num" }, + { 655, "ps_dpad" }, + { 656, "ps_dpad_down" }, + { 657, "ps_dpad_left" }, + { 658, "ps_dpad_right" }, + { 659, "ps_dpad_up" }, + { 700, "shop_icon_part_0" }, + { 701, "shop_icon_part_1" }, + { 702, "shop_icon_part_2" }, + { 703, "shop_icon_part_3" }, + { 704, "shop_icon_part_4" }, + { 710, "status_arrow" }, + { 720, "text_hp_es" }, + { 721, "text_hp_us_uk_jp_fr_gr_it" }, + { 722, "text_mp_es" }, + { 723, "text_mp_us_uk_jp_fr_gr_it" }, + { 724, "text_sp_us_uk_jp_es_fr_gr_it" }, }; public static readonly Dictionary TutorialIconSpriteName = new Dictionary { - { - 769, - "tutorial_quadmist_2" - }, - { - 770, - "tutorial_quadmist_3" - } + { 769, "tutorial_quadmist_2" }, + { 770, "tutorial_quadmist_3" } }; public static readonly Dictionary KeyboardIconLabel = new Dictionary { - { - KeyCode.Exclaim, - "!" - }, - { - KeyCode.DoubleQuote, - "\"" - }, - { - KeyCode.Hash, - "#" - }, - { - KeyCode.Dollar, - "$" - }, - { - KeyCode.Ampersand, - "&" - }, - { - KeyCode.Quote, - "'" - }, - { - KeyCode.LeftParen, - "(" - }, - { - KeyCode.RightParen, - ")" - }, - { - KeyCode.Asterisk, - "*" - }, - { - KeyCode.Plus, - "+" - }, - { - KeyCode.Comma, - "," - }, - { - KeyCode.Minus, - "-" - }, - { - KeyCode.Period, - "." - }, - { - KeyCode.Slash, - "/" - }, - { - KeyCode.Alpha0, - "0" - }, - { - KeyCode.Alpha1, - "1" - }, - { - KeyCode.Alpha2, - "2" - }, - { - KeyCode.Alpha3, - "3" - }, - { - KeyCode.Alpha4, - "4" - }, - { - KeyCode.Alpha5, - "5" - }, - { - KeyCode.Alpha6, - "6" - }, - { - KeyCode.Alpha7, - "7" - }, - { - KeyCode.Alpha8, - "8" - }, - { - KeyCode.Alpha9, - "9" - }, - { - KeyCode.Colon, - ":" - }, - { - KeyCode.Semicolon, - ";" - }, - { - KeyCode.Less, - "<" - }, - { - KeyCode.Equals, - "=" - }, - { - KeyCode.Greater, - ">" - }, - { - KeyCode.Question, - "?" - }, - { - KeyCode.At, - "@" - }, - { - KeyCode.LeftBracket, - "[" - }, - { - KeyCode.Backslash, - "\\" - }, - { - KeyCode.RightBracket, - "]" - }, - { - KeyCode.Caret, - "^" - }, - { - KeyCode.Underscore, - "_" - }, - { - KeyCode.BackQuote, - "`" - }, - { - KeyCode.A, - "A" - }, - { - KeyCode.B, - "B" - }, - { - KeyCode.C, - "C" - }, - { - KeyCode.D, - "D" - }, - { - KeyCode.E, - "E" - }, - { - KeyCode.F, - "F" - }, - { - KeyCode.G, - "G" - }, - { - KeyCode.H, - "H" - }, - { - KeyCode.I, - "I" - }, - { - KeyCode.J, - "J" - }, - { - KeyCode.K, - "K" - }, - { - KeyCode.L, - "L" - }, - { - KeyCode.M, - "M" - }, - { - KeyCode.N, - "N" - }, - { - KeyCode.O, - "O" - }, - { - KeyCode.P, - "P" - }, - { - KeyCode.Q, - "Q" - }, - { - KeyCode.R, - "R" - }, - { - KeyCode.S, - "S" - }, - { - KeyCode.T, - "T" - }, - { - KeyCode.U, - "U" - }, - { - KeyCode.V, - "V" - }, - { - KeyCode.W, - "W" - }, - { - KeyCode.X, - "X" - }, - { - KeyCode.Y, - "Y" - }, - { - KeyCode.Z, - "Z" - }, - { - KeyCode.Keypad0, - "0" - }, - { - KeyCode.Keypad1, - "1" - }, - { - KeyCode.Keypad2, - "2" - }, - { - KeyCode.Keypad3, - "3" - }, - { - KeyCode.Keypad4, - "4" - }, - { - KeyCode.Keypad5, - "5" - }, - { - KeyCode.Keypad6, - "6" - }, - { - KeyCode.Keypad7, - "7" - }, - { - KeyCode.Keypad8, - "8" - }, - { - KeyCode.Keypad9, - "9" - }, - { - KeyCode.KeypadDivide, - "/" - }, - { - KeyCode.KeypadPeriod, - "." - }, - { - KeyCode.KeypadMultiply, - "*" - }, - { - KeyCode.KeypadPlus, - "+" - }, - { - KeyCode.KeypadMinus, - "-" - }, - { - KeyCode.F1, - "F1" - }, - { - KeyCode.F2, - "F2" - }, - { - KeyCode.F3, - "F3" - }, - { - KeyCode.F4, - "F4" - }, - { - KeyCode.F5, - "F5" - }, - { - KeyCode.F6, - "F6" - }, - { - KeyCode.F7, - "F7" - }, - { - KeyCode.F8, - "F8" - }, - { - KeyCode.F9, - "F9" - }, - { - KeyCode.F10, - "F10" - }, - { - KeyCode.F11, - "F11" - }, - { - KeyCode.F12, - "F12" - } + { KeyCode.Exclaim, "!" }, + { KeyCode.DoubleQuote, "\"" }, + { KeyCode.Hash, "#" }, + { KeyCode.Dollar, "$" }, + { KeyCode.Ampersand, "&" }, + { KeyCode.Quote, "'" }, + { KeyCode.LeftParen, "(" }, + { KeyCode.RightParen, ")" }, + { KeyCode.Asterisk, "*" }, + { KeyCode.Plus, "+" }, + { KeyCode.Comma, "," }, + { KeyCode.Minus, "-" }, + { KeyCode.Period, "." }, + { KeyCode.Slash, "/" }, + { KeyCode.Alpha0, "0" }, + { KeyCode.Alpha1, "1" }, + { KeyCode.Alpha2, "2" }, + { KeyCode.Alpha3, "3" }, + { KeyCode.Alpha4, "4" }, + { KeyCode.Alpha5, "5" }, + { KeyCode.Alpha6, "6" }, + { KeyCode.Alpha7, "7" }, + { KeyCode.Alpha8, "8" }, + { KeyCode.Alpha9, "9" }, + { KeyCode.Colon, ":" }, + { KeyCode.Semicolon, ";" }, + { KeyCode.Less, "<" }, + { KeyCode.Equals, "=" }, + { KeyCode.Greater, ">" }, + { KeyCode.Question, "?" }, + { KeyCode.At, "@" }, + { KeyCode.LeftBracket, "[" }, + { KeyCode.Backslash, "\\" }, + { KeyCode.RightBracket, "]" }, + { KeyCode.Caret, "^" }, + { KeyCode.Underscore, "_" }, + { KeyCode.BackQuote, "`" }, + { KeyCode.A, "A" }, + { KeyCode.B, "B" }, + { KeyCode.C, "C" }, + { KeyCode.D, "D" }, + { KeyCode.E, "E" }, + { KeyCode.F, "F" }, + { KeyCode.G, "G" }, + { KeyCode.H, "H" }, + { KeyCode.I, "I" }, + { KeyCode.J, "J" }, + { KeyCode.K, "K" }, + { KeyCode.L, "L" }, + { KeyCode.M, "M" }, + { KeyCode.N, "N" }, + { KeyCode.O, "O" }, + { KeyCode.P, "P" }, + { KeyCode.Q, "Q" }, + { KeyCode.R, "R" }, + { KeyCode.S, "S" }, + { KeyCode.T, "T" }, + { KeyCode.U, "U" }, + { KeyCode.V, "V" }, + { KeyCode.W, "W" }, + { KeyCode.X, "X" }, + { KeyCode.Y, "Y" }, + { KeyCode.Z, "Z" }, + { KeyCode.Keypad0, "0" }, + { KeyCode.Keypad1, "1" }, + { KeyCode.Keypad2, "2" }, + { KeyCode.Keypad3, "3" }, + { KeyCode.Keypad4, "4" }, + { KeyCode.Keypad5, "5" }, + { KeyCode.Keypad6, "6" }, + { KeyCode.Keypad7, "7" }, + { KeyCode.Keypad8, "8" }, + { KeyCode.Keypad9, "9" }, + { KeyCode.KeypadDivide, "/" }, + { KeyCode.KeypadPeriod, "." }, + { KeyCode.KeypadMultiply, "*" }, + { KeyCode.KeypadPlus, "+" }, + { KeyCode.KeypadMinus, "-" }, + { KeyCode.F1, "F1" }, + { KeyCode.F2, "F2" }, + { KeyCode.F3, "F3" }, + { KeyCode.F4, "F4" }, + { KeyCode.F5, "F5" }, + { KeyCode.F6, "F6" }, + { KeyCode.F7, "F7" }, + { KeyCode.F8, "F8" }, + { KeyCode.F9, "F9" }, + { KeyCode.F10, "F10" }, + { KeyCode.F11, "F11" }, + { KeyCode.F12, "F12" } }; private static readonly SByte WorldTitleMistContinent = 0; diff --git a/Assembly-CSharp/Global/AbilityUI.cs b/Assembly-CSharp/Global/AbilityUI.cs index eb242e532..0857c23d2 100644 --- a/Assembly-CSharp/Global/AbilityUI.cs +++ b/Assembly-CSharp/Global/AbilityUI.cs @@ -230,10 +230,12 @@ public override Boolean OnKeyConfirm(GameObject go) Character player = FF9StateSystem.Common.FF9.party.GetCharacter(this.currentPartyIndex); this.currentAbilityIndex = go.GetComponent().ItemDataIndex; Int32 abilId = this.aaIdList[this.currentAbilityIndex]; - this.canMultiTarget = this.IsMulti(abilId); - if (abilId != 0 && ff9abil.IsAbilityActive(abilId)) - { - if (this.CheckAAType(abilId, player) == AbilityType.Enable) + if (abilId != 0 && ff9abil.IsAbilityActive(abilId)) + { + BattleAbilityId battleAbilId = ff9abil.GetActiveAbilityFromAbilityId(abilId); + BattleAbilityId patchedId = this.PatchAbility(battleAbilId); + this.canMultiTarget = this.IsMulti(patchedId); + if (this.CheckAAType(abilId, player) == AbilityType.Enable) { if (this.canMultiTarget) { @@ -259,7 +261,7 @@ public override Boolean OnKeyConfirm(GameObject go) { this.targetTransition.animatedInStartPosition = new Vector3(-1543f, 0.0f, 0.0f); this.targetTransition.animatedOutEndPosition = new Vector3(-1543f, 0.0f, 0.0f); - this.TargetListPanel.transform.localPosition = new Vector3((Single)(-TargetPositionXOffset - 60.0), 0.0f, 0.0f); + this.TargetListPanel.transform.localPosition = new Vector3(-TargetPositionXOffset - 60f, 0.0f, 0.0f); } this.targetTransition.DestinationPosition = new Vector3[1] { @@ -373,7 +375,8 @@ public override Boolean OnKeyConfirm(GameObject go) Int32 memberIndex = go.transform.GetSiblingIndex(); PLAYER caster = FF9StateSystem.Common.FF9.party.member[this.currentPartyIndex]; BattleAbilityId abilId = ff9abil.GetActiveAbilityFromAbilityId(this.aaIdList[this.currentAbilityIndex]); - AA_DATA aaData = FF9StateSystem.Battle.FF9Battle.aa_data[abilId]; + BattleAbilityId patchedId = this.PatchAbility(abilId); + AA_DATA aaData = FF9StateSystem.Battle.FF9Battle.aa_data[patchedId]; if (!this.multiTarget) { canUseAbility = SFieldCalculator.FieldCalcMain(caster, FF9StateSystem.Common.FF9.party.member[memberIndex], aaData, aaData.Ref.ScriptId, 0U); @@ -397,7 +400,7 @@ public override Boolean OnKeyConfirm(GameObject go) this.TargetListPanel.SetActive(false); ButtonGroupState.ActiveGroup = ActionAbilityGroupButton; } - FF9StateSystem.EventState.IncreaseAAUsageCounter(abilId); + FF9StateSystem.EventState.IncreaseAAUsageCounter(patchedId); BattleAchievement.IncreaseNumber(ref FF9StateSystem.Achievement.whtMag_no, 1); AchievementManager.ReportAchievement(AcheivementKey.WhtMag200, FF9StateSystem.Achievement.whtMag_no); this.DisplayTarget(); @@ -905,8 +908,8 @@ private void DisplayAADetail(Transform item, ListDataTypeBase data, Int32 index, BattleAbilityId battleAbilId = ff9abil.GetActiveAbilityFromAbilityId(abilityListData.Id); itemListDetailHud.Content.SetActive(true); ButtonGroupState.SetButtonAnimation(itemListDetailHud.Self, abilityListData.Type == AbilityType.Enable); - Int32 mp = GetMp(FF9StateSystem.Battle.FF9Battle.aa_data[battleAbilId]); - BattleAbilityId patchedId = this.PatchAbility(battleAbilId); + BattleAbilityId patchedId = this.PatchAbility(battleAbilId); + Int32 mp = GetMp(FF9StateSystem.Battle.FF9Battle.aa_data[patchedId]); itemListDetailHud.NameLabel.text = FF9TextTool.ActionAbilityName(patchedId); itemListDetailHud.NumberLabel.text = mp != 0 ? mp.ToString() : String.Empty; if (abilityListData.Type == AbilityType.CantSpell) @@ -1046,7 +1049,8 @@ private void DisplayTarget() charHud.Content.SetActive(true); FF9UIDataTool.DisplayCharacterDetail(player, charHud); FF9UIDataTool.DisplayCharacterAvatar(player, new Vector2(), new Vector2(), charHud.AvatarSprite, false); - switch (ff9abil.GetActionAbility(this.aaIdList[this.currentAbilityIndex]).Info.DisplayStats) + AA_DATA patchedAbil = FF9StateSystem.Battle.FF9Battle.aa_data[this.PatchAbility(ff9abil.GetActiveAbilityFromAbilityId(this.aaIdList[this.currentAbilityIndex]))]; + switch (patchedAbil.Info.DisplayStats) { case TargetDisplay.None: case TargetDisplay.Hp: @@ -1071,9 +1075,8 @@ private void DisplayTarget() this.SetAvailableCharacter(); } - private Boolean IsMulti(Int32 abil_id) + private Boolean IsMulti(BattleAbilityId battleAbilityId) { - BattleAbilityId battleAbilityId = ff9abil.GetActiveAbilityFromAbilityId(abil_id); switch (FF9BattleDB.CharacterActions[battleAbilityId].Info.Target) { case TargetType.ManyAny: @@ -1095,8 +1098,8 @@ private Boolean IsMulti(Int32 abil_id) private AbilityType CheckAAType(Int32 abilityId, Character player) { - BattleAbilityId battleAbilId = ff9abil.GetActiveAbilityFromAbilityId(abilityId); - AA_DATA aa_data = FF9BattleDB.CharacterActions[battleAbilId]; + BattleAbilityId patchedId = this.PatchAbility(ff9abil.GetActiveAbilityFromAbilityId(abilityId)); + AA_DATA patchedAbil = FF9BattleDB.CharacterActions[patchedId]; if (!this.equipmentPartInAbilityDict.ContainsKey(abilityId)) { @@ -1115,7 +1118,7 @@ private AbilityType CheckAAType(Int32 abilityId, Character player) } } - return (player.Data.status & BattleStatusConst.CannotUseAbilityInMenu) != 0 || (aa_data.Type & 1) == 0 || GetMp(aa_data) > player.Data.cur.mp ? AbilityType.CantSpell : AbilityType.Enable; + return (player.Data.status & BattleStatusConst.CannotUseAbilityInMenu) != 0 || (patchedAbil.Type & 1) == 0 || GetMp(patchedAbil) > player.Data.cur.mp ? AbilityType.CantSpell : AbilityType.Enable; } private AbilityType CheckSAType(Int32 abilityId, Character player) @@ -1167,7 +1170,7 @@ private static BattleCommandId GetCommand(Int32 abil_id, Character play) BattleCommandId cmdId = CharacterCommands.CommandSets[play.PresetId].GetRegular(commandNumber); CharacterCommand ff9Command = CharacterCommands.Commands[cmdId]; foreach (BattleAbilityId abilId in ff9Command.EnumerateAbilities()) - if (BattleAbilityHelper.Patch(abilId, play.Data) == battleAbilId) + if (abilId == battleAbilId) return cmdId; } return BattleCommandId.None; diff --git a/Assembly-CSharp/Global/AllSoundDispatchPlayer.cs b/Assembly-CSharp/Global/AllSoundDispatchPlayer.cs index f850e68e4..0d47f24f1 100644 --- a/Assembly-CSharp/Global/AllSoundDispatchPlayer.cs +++ b/Assembly-CSharp/Global/AllSoundDispatchPlayer.cs @@ -8,7 +8,7 @@ public class AllSoundDispatchPlayer : SoundPlayer { public static Single NormalizeVolume(Int32 originalVolume) { - return (Single)originalVolume / 127f; + return Mathf.Clamp01((Single)originalVolume / 127f); } public static Int32 ReverseNormalizeVolume(Single normalizedVolume) @@ -34,6 +34,10 @@ public void UpdatePlayingMusicVolume() ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * SoundLib.MusicPlayer.Volume, 0); } }); + } + + public void UpdatePlayingSoundEffectVolume() + { AllSoundDispatchPlayer.PlayingSfx[] array = this.sfxResSlot; for (Int32 i = 0; i < (Int32)array.Length; i++) { @@ -42,39 +46,19 @@ public void UpdatePlayingMusicVolume() { if (ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_IsExist(playingSfx.SoundID) != 0) { - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(playingSfx.SndEffectVol) * SoundLib.MusicPlayer.Volume, 0); - } - } - } - foreach (AllSoundDispatchPlayer.PlayingSfx playingSfx2 in this.sfxChanels) - { - if (playingSfx2 != null) - { - if (FF9Snd.GetIsExtEnvObjNo(playingSfx2.ObjNo)) - { - if (ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_IsExist(playingSfx2.SoundID) != 0) - { - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx2.SoundID, AllSoundDispatchPlayer.NormalizeVolume(playingSfx2.SndEffectVol) * SoundLib.MusicPlayer.Volume, 0); - } + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(playingSfx.SndEffectVol) * SoundLib.SoundEffectPlayer.Volume, 0); } } } - } - - public void UpdatePlayingSoundEffectVolume() - { foreach (AllSoundDispatchPlayer.PlayingSfx playingSfx in this.sfxChanels) { if (playingSfx != null) { - if (!FF9Snd.GetIsExtEnvObjNo(playingSfx.ObjNo)) + if (ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_IsExist(playingSfx.SoundID) != 0) { - if (ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_IsExist(playingSfx.SoundID) != 0) + if (playingSfx.ObjNo != 1261 && playingSfx.ObjNo != 3096) // Why? - SamsamTS { - if (playingSfx.ObjNo != 1261 && playingSfx.ObjNo != 3096) - { - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(playingSfx.SndEffectVol) * SoundLib.SoundEffectPlayer.Volume, 0); - } + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(playingSfx.SndEffectVol) * SoundLib.SoundEffectPlayer.Volume, 0); } } } @@ -134,16 +118,17 @@ public void FF9SOUND_SONG_LOAD(Int32 ObjNo) { this.CreateSound(soundProfile); soundProfile.SoundVolume = 1f; - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, SoundLib.MusicPlayer.Volume, 0); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPause(soundProfile.SoundID, 1, 0); Int16 fldMapNo = FF9StateSystem.Common.FF9.fldMapNo; if (fldMapNo == 503 && PersistenSingleton.Instance.eBin.getVarManually(EBin.SC_COUNTER_SVR) == 2970 && PersistenSingleton.Instance.eBin.getVarManually(EBin.MAP_INDEX_SVR) == 11 && ObjNo == 35) { + // What is this for ? - SamsamTS // Cargo Ship/Bridge soundProfile.SoundVolume = 0f; - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, 0f, 0); } + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); this.currentMusicID = ObjNo; this.StopAndClearSuspendBGM(ObjNo, true); }); @@ -156,7 +141,7 @@ public void FF9SOUND_SONG_LOAD(Int32 ObjNo) }); } } - + public void StopAndClearSuspendBGM(int ObjNo, Boolean SetCurrentMusic = false) { if (this.suspendBgmNo != -1 && ObjNo != this.suspendBgmNo) @@ -192,7 +177,8 @@ public void FF9SOUND_SONG_PLAY(Int32 ObjNo, Int32 vol = 127, int time = 0) { if (soundProfile != null) { - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Stop(soundProfile.SoundID, 0); + if (time < MINIMUM_SONG_FADE_MS) time = MINIMUM_SONG_FADE_MS; // Add a fadeout for smoother transition + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Stop(soundProfile.SoundID, time); } this.currentMusicID = -1; }); @@ -201,8 +187,8 @@ public void FF9SOUND_SONG_PLAY(Int32 ObjNo, Int32 vol = 127, int time = 0) { this.CreateSound(soundProfile); soundProfile.SoundVolume = AllSoundDispatchPlayer.NormalizeVolume(vol); - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, time * 1000); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * SoundLib.MusicPlayer.Volume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, time); this.currentMusicID = ObjNo; this.StopAndClearSuspendBGM(ObjNo, true); }); @@ -213,7 +199,7 @@ public void FF9SOUND_SONG_PLAY(Int32 ObjNo, Int32 vol = 127, int time = 0) { if (soundProfile != null) { - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPause(soundProfile.SoundID, 0, time * 1000); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPause(soundProfile.SoundID, 0, time); soundProfile.SoundVolume = AllSoundDispatchPlayer.NormalizeVolume(vol); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * SoundLib.MusicPlayer.Volume, 0); this.StopAndClearSuspendBGM(ObjNo, true); @@ -270,7 +256,7 @@ public void FF9SOUND_SONG_STOP(int ObjNo) { if (soundProfile != null) { - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Stop(soundProfile.SoundID, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Stop(soundProfile.SoundID, MINIMUM_SONG_FADE_MS); } if (ObjNo == this.suspendBgmNo) { @@ -304,7 +290,7 @@ public void FF9SOUND_SONG_STOPCURRENT() { if (soundProfile != null) { - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Stop(soundProfile.SoundID, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Stop(soundProfile.SoundID, MINIMUM_SONG_FADE_MS); } this.currentMusicID = -1; }); @@ -348,7 +334,7 @@ public void FF9SOUND_SONG_VOL_FADE(Int32 ObjNo, Int32 ticks, Int32 from, Int32 t if (soundProfile != null) { ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPause(soundProfile.SoundID, 0, 0); - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, AllSoundDispatchPlayer.NormalizeVolume(from), 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, AllSoundDispatchPlayer.NormalizeVolume(from) * SoundLib.MusicPlayer.Volume, 0); soundProfile.SoundVolume = AllSoundDispatchPlayer.NormalizeVolume(to); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * SoundLib.MusicPlayer.Volume, AllSoundDispatchPlayer.ConvertTickToMillisec(ticks)); } @@ -459,10 +445,19 @@ public void FF9SOUND_SONG_SKIPPHRASE_MILLISEC(Int32 ObjNo, Int32 offsetTimeMSec) { if (soundProfile != null) { - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Stop(soundProfile.SoundID, 0); - soundProfile.SoundID = ISdLibAPIProxy.Instance.SdSoundSystem_CreateSound(soundProfile.BankID); - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, offsetTimeMSec); - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, SoundLib.MusicPlayer.Volume, 0); + if (Configuration.Audio.Backend == 0) + { + Single volume = ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_GetVolume(soundProfile.SoundID); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Stop(soundProfile.SoundID, 0); + soundProfile.SoundID = ISdLibAPIProxy.Instance.SdSoundSystem_CreateSound(soundProfile.BankID); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, volume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, offsetTimeMSec); + } + else + { + // This will seek with Soloud + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, offsetTimeMSec); + } } }); } @@ -477,9 +472,9 @@ public void FF9SOUND_SNDEFFECT_PLAY(Int32 ObjNo, Int32 attr, Int32 pos, Int32 vo soundProfile.Pitch = 1f; if (this.TuneUpSoundEffectByObjNo(ObjNo, soundProfile) == 0) { - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, AllSoundDispatchPlayer.NormalizeVolume(vol) * SoundLib.SoundEffectPlayer.Volume, 0); this.ShiftPitchIfFastForward(soundProfile); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); } AllSoundDispatchPlayer.PlayingSfx playingSfx = new AllSoundDispatchPlayer.PlayingSfx(); playingSfx.ObjNo = ObjNo; @@ -524,10 +519,10 @@ private Int32 TuneUpSoundEffectByObjNo(Int32 ObjNo, SoundProfile soundProfile) { if (ObjNo == 1748) { - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, 0.6f * SoundLib.SoundEffectPlayer.Volume, 0); soundProfile.Pitch *= 0.6f; ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPitch(soundProfile.SoundID, soundProfile.Pitch, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); return 1; } // TODO: This special way to handle this sound (Fire effect) seems to crash the game when the INI option "[Import] Audio" is used @@ -541,6 +536,15 @@ private Int32 TuneUpSoundEffectByObjNo(Int32 ObjNo, SoundProfile soundProfile) // ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPitch(soundProfile.SoundID, soundProfile.Pitch, 0); // return 1; //} + if (ObjNo == 58 && Configuration.Audio.Backend > 0) + { + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, 0f, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, SoundLib.SoundEffectPlayer.Volume, 300); + soundProfile.Pitch *= 0.8f; + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPitch(soundProfile.SoundID, soundProfile.Pitch, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 900); + return 1; + } return 0; } @@ -706,8 +710,8 @@ public void FF9SOUND_SNDEFFECTRES_PLAY(Int32 slot, Int32 ObjNo, Int32 attr, Int3 this.CreateSoundProfileIfNotExist(ObjNo, SoundProfileType.SoundEffect, delegate(SoundProfile soundProfile) { this.CreateSound(soundProfile); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, AllSoundDispatchPlayer.NormalizeVolume(vol) * SoundLib.SoundEffectPlayer.Volume, 0); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, AllSoundDispatchPlayer.NormalizeVolume(vol) * SoundLib.MusicPlayer.Volume, 0); AllSoundDispatchPlayer.PlayingSfx playingSfx = new AllSoundDispatchPlayer.PlayingSfx(); playingSfx.ObjNo = ObjNo; playingSfx.SoundID = soundProfile.SoundID; @@ -788,7 +792,7 @@ public void FF9SOUND_SNDEFFECTRES_RESTORE(Int32 slot) } else if (playingSfx.PrevSndEffectMapID == (Int32)FF9StateSystem.Common.FF9.fldMapNo) { - this.FF9SOUND_SNDEFFECTRES_PLAY(slot, playingSfx.ObjNo, 0, 0, AllSoundDispatchPlayer.ReverseNormalizeVolume((Single)playingSfx.SndEffectVol)); + this.FF9SOUND_SNDEFFECTRES_PLAY(slot, playingSfx.ObjNo, 0, 0, playingSfx.SndEffectVol); } } @@ -806,7 +810,7 @@ public void FF9SOUND_SNDEFFECTRES_VOL(Int32 slot, Int32 ObjNo, Int32 attr, Int32 if (playingSfx.ObjNo == ObjNo) { playingSfx.SndEffectVol = vol; - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(vol) * SoundLib.MusicPlayer.Volume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(vol) * SoundLib.SoundEffectPlayer.Volume, 0); } } } @@ -826,7 +830,7 @@ public void FF9SOUND_SNDEFFECTRES_VOL_INTPL(Int32 slot, Int32 ObjNo, Int32 attr, if (playingSfx.ObjNo == ObjNo) { playingSfx.SndEffectVol = to; - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(to) * SoundLib.MusicPlayer.Volume, AllSoundDispatchPlayer.ConvertTickToMillisec(ticks)); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(to) * SoundLib.SoundEffectPlayer.Volume, AllSoundDispatchPlayer.ConvertTickToMillisec(ticks)); } } } @@ -844,7 +848,7 @@ public void FF9SOUND_SNDEFFECTRES_VOL_ALL(Int32 vol) if (playingSfx != null) { playingSfx.SndEffectVol = vol; - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(vol) * SoundLib.MusicPlayer.Volume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(vol) * SoundLib.SoundEffectPlayer.Volume, 0); } } } @@ -861,7 +865,7 @@ public void FF9SOUND_SNDEFFECTRES_VOL_INTPLALL(Int32 ticks, Int32 to) if (playingSfx != null) { playingSfx.SndEffectVol = to; - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(to) * SoundLib.MusicPlayer.Volume, AllSoundDispatchPlayer.ConvertTickToMillisec(ticks)); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(to) * SoundLib.SoundEffectPlayer.Volume, AllSoundDispatchPlayer.ConvertTickToMillisec(ticks)); } } } @@ -881,8 +885,8 @@ public void FF9SOUND_STREAM_PLAY(Int32 streamid, Int32 pos, Int32 reverb) this.CreateSoundProfileIfNotExist(streamid, SoundProfileType.Song, delegate(SoundProfile soundProfile) { base.CreateSound(soundProfile); - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, SoundLib.SoundEffectPlayer.Volume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); this.currentSongID = soundProfile.SoundIndex; }); } @@ -1397,12 +1401,14 @@ public void UpdatePlayingSoundEffectPitchFollowingGameSpeed() } } - public override Single Volume => throw new NotImplementedException(); + public override Single Volume => throw new NotImplementedException(); - public const Int32 VOLUME_MAX = 127; + public const Int32 VOLUME_MAX = 127; public const Int32 SNDEFFECTRES_SLOT_MAX = 2; + public const Int32 MINIMUM_SONG_FADE_MS = 500; + private Int32 currentMusicID = -1; private Int32 suspendBgmNo = -1; diff --git a/Assembly-CSharp/Global/Asset/AssetManager.cs b/Assembly-CSharp/Global/Asset/AssetManager.cs index 1993a26d0..b9a183778 100644 --- a/Assembly-CSharp/Global/Asset/AssetManager.cs +++ b/Assembly-CSharp/Global/Asset/AssetManager.cs @@ -9,6 +9,7 @@ using Memoria.Prime.CSV; using Memoria.Assets; using Object = System.Object; +using System.Reflection; public static class AssetManager { @@ -33,7 +34,12 @@ public static class AssetManager static AssetManager() { - AssetManager.IsFullyInitialized = false; + Version assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version; + DateTime assemblyDate = new DateTime(2000, 1, 1).AddDays(assemblyVersion.Build).AddSeconds(assemblyVersion.Revision * 2); + Log.Message($"[Initialization] Memoria version: {assemblyDate.ToString("yyyy-MM-dd")}"); + Log.Message($"[Initialization] OS version: {Environment.OSVersion}"); + + AssetManager.IsFullyInitialized = false; Array moduleList = Enum.GetValues(typeof(AssetManagerUtil.ModuleBundle)); String[] foldname = new String[Configuration.Mod.FolderNames.Length + 1]; String path; diff --git a/Assembly-CSharp/Global/BGCAM_DEF.cs b/Assembly-CSharp/Global/BGCAM_DEF.cs index 95eca2624..3aad5d731 100644 --- a/Assembly-CSharp/Global/BGCAM_DEF.cs +++ b/Assembly-CSharp/Global/BGCAM_DEF.cs @@ -114,7 +114,7 @@ public Vector3 GetCamPos() return new Vector3(this.t[0], this.t[1], this.t[2]); } - private void RefreshCache(Boolean force) + public void RefreshCache(Boolean force) { Int16 actualFieldWidth = FieldMap.PsxFieldWidth; if (!force && _knownFieldWidth == actualFieldWidth) diff --git a/Assembly-CSharp/Global/BGOVERLAY_DEF.cs b/Assembly-CSharp/Global/BGOVERLAY_DEF.cs index ee715fcdc..f47f43bb9 100644 --- a/Assembly-CSharp/Global/BGOVERLAY_DEF.cs +++ b/Assembly-CSharp/Global/BGOVERLAY_DEF.cs @@ -9,10 +9,9 @@ public BGOVERLAY_DEF() { this.startOffset = 0L; this.spriteList = new List(); - this.isSpecialParallax = false; - this.canCombine = true; - this.isCreated = false; - } + this.canCombine = true; + this.isCreated = false; + } public void SetFlags(OVERLAY_FLAG flagDiff, Boolean isSet) { @@ -40,18 +39,18 @@ public void ReadData(BinaryReader reader) this.orgZ = (UInt16)(buffer >> 20 & 0xFFFu); this.w = reader.ReadUInt16(); this.h = reader.ReadUInt16(); - this.orgX = reader.ReadInt16(); - this.orgY = reader.ReadInt16(); - this.curX = reader.ReadInt16(); - this.curY = reader.ReadInt16(); + this.orgX = (float)reader.ReadInt16(); + this.orgY = (float)reader.ReadInt16(); + this.curX = (float)reader.ReadInt16(); + this.curY = (float)reader.ReadInt16(); this.minX = reader.ReadInt16(); this.maxX = reader.ReadInt16(); this.minY = reader.ReadInt16(); this.maxY = reader.ReadInt16(); - this.scrX = reader.ReadInt16(); - this.scrY = reader.ReadInt16(); - this.dX = reader.ReadInt16(); - this.dY = reader.ReadInt16(); + this.scrX = (float)reader.ReadInt16(); + this.scrY = (float)reader.ReadInt16(); + this.scrollX = reader.ReadInt16(); + this.scrollY = reader.ReadInt16(); this.fracX = reader.ReadInt16(); this.fracY = reader.ReadInt16(); Byte bitPos = 0; @@ -72,28 +71,31 @@ public void ReadData(BinaryReader reader) public UInt16 orgZ; public UInt16 w; public UInt16 h; - public Int16 orgX; - public Int16 orgY; - public Int16 curX; - public Int16 curY; + public float orgX; + public float orgY; + public float curX; + public float curY; + public float prevX; + public float prevY; public Int16 minX; public Int16 maxX; public Int16 minY; public Int16 maxY; - public Int16 scrX; - public Int16 scrY; + public float scrX; + public float scrY; - public Int16 dX; - public Int16 dY; + public Int16 scrollX; // negative is slower (further) than main, positive faster (closer) + public Int16 scrollY; public Int16 fracX; public Int16 fracY; - + public Byte camNdx; + public Byte isXOffset; - public UInt32 indnum; + public UInt32 indnum; public Byte viewportNdx; public UInt16 spriteCount; @@ -110,13 +112,8 @@ public void ReadData(BinaryReader reader) public Transform transform; - public Boolean canCombine; - public Boolean isCreated; - - public Boolean isSpecialParallax; - - public Single parallaxCurX; - public Single parallaxCurY; + public Boolean canCombine; + public Boolean isCreated; public Boolean isMemoria = false; public Vector2 memoriaSize; diff --git a/Assembly-CSharp/Global/BGSCENE_DEF.cs b/Assembly-CSharp/Global/BGSCENE_DEF.cs index e9795ab31..1ce5cd694 100644 --- a/Assembly-CSharp/Global/BGSCENE_DEF.cs +++ b/Assembly-CSharp/Global/BGSCENE_DEF.cs @@ -10,6 +10,7 @@ using Memoria.Scripts; using Global.TileSystem; using System.Linq; +using System.Globalization; #pragma warning disable 169 #pragma warning disable 414 @@ -68,8 +69,8 @@ public class BGSCENE_DEF public Int16 minY; public Int16 maxY; - public Int16 scrX; - public Int16 scrY; + public float scrX; + public float scrY; public String name; @@ -221,8 +222,8 @@ private Boolean ProcessMemoriaOverlay(BGOVERLAY_DEF bgOverlay, String operation, } else if (operation == "Position" && arguments.Length >= 3) { - Int16.TryParse(arguments[0], out bgOverlay.orgX); - Int16.TryParse(arguments[1], out bgOverlay.orgY); + float.TryParse(arguments[0], NumberStyles.Any, CultureInfo.InvariantCulture, out bgOverlay.orgX); + float.TryParse(arguments[1], NumberStyles.Any, CultureInfo.InvariantCulture, out bgOverlay.orgY); UInt16.TryParse(arguments[2], out bgOverlay.orgZ); bgOverlay.curX = bgOverlay.orgX; bgOverlay.curY = bgOverlay.orgY; @@ -511,7 +512,7 @@ public void ExportMemoriaBGX(String bgxExportPath) bgsStr += $"Position: {this.orgX + bgOverlay.orgX + spriteMinX}, {this.orgY + bgOverlay.orgY + spriteMinY}, {this.orgZ + bgOverlay.orgZ + spriteMinZ}\n"; bgsStr += $"Size: {spriteMaxX - spriteMinX}, {spriteMaxY - spriteMinY}\n"; if ((bgOverlay.flags & BGOVERLAY_DEF.OVERLAY_FLAG.ScrollWithOffset) != 0) - bgsStr += $"ScrollWithOffset: {bgOverlay.dX}, {bgOverlay.dY}\n"; + bgsStr += $"ScrollWithOffset: {bgOverlay.scrollX}, {bgOverlay.scrollY}\n"; bgsStr += $"Image: {textureName}\n"; bgsStr += $"Shader: PSX/FieldMap_Abr_{(bgFirstSprite.trans == 0 ? "None" : Math.Min(3, (Int32)bgFirstSprite.alpha).ToString())}\n"; TextureHelper.WriteTextureToFile(texture, folder + textureName); @@ -522,7 +523,7 @@ public void ExportMemoriaBGX(String bgxExportPath) bgsStr += $"Position: {this.orgX + bgOverlay.orgX}, {bgOverlay.orgY}, {bgOverlay.orgZ}\n"; bgsStr += $"Size: {bgOverlay.memoriaSize.x}, {bgOverlay.memoriaSize.y}\n"; if ((bgOverlay.flags & BGOVERLAY_DEF.OVERLAY_FLAG.ScrollWithOffset) != 0) - bgsStr += $"ScrollWithOffset: {bgOverlay.dX}, {bgOverlay.dY}\n"; + bgsStr += $"ScrollWithOffset: {bgOverlay.scrollX}, {bgOverlay.scrollY}\n"; bgsStr += $"Image: {textureName}\n"; bgsStr += $"Shader: {bgOverlay.memoriaMaterial.shader.name}\n"; TextureHelper.WriteTextureToFile(bgOverlay.memoriaImage, folder + textureName); @@ -1425,8 +1426,8 @@ private void doCreateAtlas(List layers, List overlays, // okay guise let's get a tile - int grabX = (overlayInfo.curX + spriteInfo.offX - tileSystem.MinX) / 16; - int grabY = (overlayInfo.curY + spriteInfo.offY - tileSystem.MinY) / 16; + int grabX = ((short)overlayInfo.curX + spriteInfo.offX - tileSystem.MinX) / 16; + int grabY = ((short)overlayInfo.curY + spriteInfo.offY - tileSystem.MinY) / 16; Tile memoriaTile = memoriaOverlay.GetTile(grabX, grabY); copyHelper.CopyTile(atlasArray, atlasSide, atlasX, atlasY, memoriaTile, memoriaOverlay, false); diff --git a/Assembly-CSharp/Global/BGSPRITE_LOC_DEF.cs b/Assembly-CSharp/Global/BGSPRITE_LOC_DEF.cs index 3d151a2dc..fd3ccd062 100644 --- a/Assembly-CSharp/Global/BGSPRITE_LOC_DEF.cs +++ b/Assembly-CSharp/Global/BGSPRITE_LOC_DEF.cs @@ -35,38 +35,27 @@ public void ReadData_BGSPRITELOC_DEF(BinaryReader reader) this.offX = (UInt16)BitUtil.ReadBits(input, ref b, 10); } - public UInt16 clutY; - public UInt16 clutX; - - public Byte texY; + public UInt16 clutY; public Byte texX; - + public Byte texY; public Byte res; - public Byte alpha; - - public Byte v; - public Byte u; - - public UInt16 h; + public Byte v; public UInt16 w; + public UInt16 h; public Byte trans; - public Byte pad; public Int32 depth; - public UInt16 offY; - public UInt16 offX; - + public UInt16 offY; public UInt16 atlasX; - public UInt16 atlasY; public Int64 startOffset; @@ -75,5 +64,5 @@ public void ReadData_BGSPRITELOC_DEF(BinaryReader reader) public Transform transform; - public Vector3 cacheLocalPos; + public Vector3 cacheLocalPos; } diff --git a/Assembly-CSharp/Global/Config/ConfigUI.cs b/Assembly-CSharp/Global/Config/ConfigUI.cs index e51bb2021..9ba9a529f 100644 --- a/Assembly-CSharp/Global/Config/ConfigUI.cs +++ b/Assembly-CSharp/Global/Config/ConfigUI.cs @@ -67,7 +67,8 @@ public enum Configurator MusicVolume, MovieVolume, VoiceVolume, - ATBMode + ATBMode, + AutoText } public enum ATBMode @@ -1269,6 +1270,9 @@ private void DisplayConfigValue() int mode = Configuration.Battle.ATBMode >= 3 ? 3 : Configuration.Battle.ATBMode; current.Value = mode / 3f; break; + case Configurator.AutoText: + current.Value = Configuration.VoiceActing.AutoDismissDialogAfterCompletion ? 0 : 1; + break; default: current.Value = 0f; break; @@ -1451,6 +1455,10 @@ private void setConfigValue(GameObject configGameObject, Single value, Boolean i Configuration.Battle.ATBMode = mode >= 3 ? 5 : mode; Configuration.Battle.SaveBattleSpeed(); break; + case Configurator.AutoText: + Configuration.VoiceActing.AutoDismissDialogAfterCompletion = configField.Value == 0; + Configuration.VoiceActing.SaveAutoText(); + break; default: configField.Value = 0f; break; @@ -1510,6 +1518,34 @@ private void ListComponents(GameObject go, int indent = 0) } }*/ + private GameObject CreateChoice(GameObject template, Configurator id, String choice1, String choice2, int siblingIndex) + { + try + { + GameObject go = Instantiate(template); + go.transform.parent = template.transform.parent; + go.transform.localPosition = template.transform.localPosition; + go.transform.localScale = template.transform.localScale; + go.transform.SetSiblingIndex(siblingIndex); + go.name = $"{id} Panel - Choice"; + go.GetComponent().ID = (int)id; + if (siblingIndex <= fieldMessageConfigIndex) + fieldMessageConfigIndex++; + + var locs = go.GetComponentsInChildren(); + locs[0].key = id.ToString(); + if (!String.IsNullOrEmpty(choice1)) locs[1].key = choice1; + if (!String.IsNullOrEmpty(choice2)) locs[2].key = choice2; + + return go; + } + catch (Exception ex) + { + Log.Error($"[ConfigUI] Couldn't create silder\n{ex.Message}\n{ex.StackTrace}"); + } + return null; + } + private GameObject CreateSlider(GameObject template, Configurator id, int siblingIndex) { try @@ -1572,15 +1608,20 @@ private void Awake() FadingComponent = ScreenFadeGameObject.GetComponent(); ConfigFieldList = new List(); - // Adding the volume sliders - GameObject template = SliderMenuTemplate; - CreateVolumeSlider(template, Configurator.SoundVolume, 0); - CreateVolumeSlider(template, Configurator.MusicVolume, 1); - CreateVolumeSlider(template, Configurator.MovieVolume, 2); + // Adding the volume sliders and auto-text + GameObject sliderTemplate = SliderMenuTemplate; + GameObject choiceTemplate = ConfigList.GetChild(1).GetChild(0).GetChild(0); + + CreateVolumeSlider(sliderTemplate, Configurator.SoundVolume, 0); + CreateVolumeSlider(sliderTemplate, Configurator.MusicVolume, 1); + CreateVolumeSlider(sliderTemplate, Configurator.MovieVolume, 2); if (Configuration.VoiceActing.Enabled) - CreateVolumeSlider(template, Configurator.VoiceVolume, 3); + { + CreateVolumeSlider(sliderTemplate, Configurator.VoiceVolume, 3); + CreateChoice(choiceTemplate, Configurator.AutoText, null, null, 4); + } - CreateATBModeSlider(template, Configurator.ATBMode, 9); + CreateATBModeSlider(sliderTemplate, Configurator.ATBMode, 9); foreach (Transform trans in ConfigList.GetChild(1).GetChild(0).transform) { diff --git a/Assembly-CSharp/Global/EBG_ATTACH_DEF.cs b/Assembly-CSharp/Global/EBG_ATTACH_DEF.cs index 279e7bad8..a32c5ee7f 100644 --- a/Assembly-CSharp/Global/EBG_ATTACH_DEF.cs +++ b/Assembly-CSharp/Global/EBG_ATTACH_DEF.cs @@ -3,16 +3,10 @@ public class EBG_ATTACH_DEF { public SByte surroundMode; - public Byte r; - public Byte g; - public Byte b; - public Int16 ndx; - public Int16 x; - public Int16 y; } diff --git a/Assembly-CSharp/Global/Event/Engine/EventEngine.DoEventCode.cs b/Assembly-CSharp/Global/Event/Engine/EventEngine.DoEventCode.cs index 4abc79b5c..b82a58930 100644 --- a/Assembly-CSharp/Global/Event/Engine/EventEngine.DoEventCode.cs +++ b/Assembly-CSharp/Global/Event/Engine/EventEngine.DoEventCode.cs @@ -568,6 +568,11 @@ public Int32 DoEventCode() { num12 = 2970; } + else if (FF9StateSystem.Common.FF9.fldMapNo == 53) // fix for scene where Blank jumps in hole, position adjustment + { + if (num11 == 250 && num12 == 1200) + num11 = 330; + } Boolean flag2 = this.MoveToward_mixed((Single)num11, 0.0f, (Single)num12, 0, (PosObj)null); eulerAngles1 = po.go.transform.localRotation.eulerAngles; if (flag2) @@ -1386,6 +1391,7 @@ public Int32 DoEventCode() } case EBin.event_code_binary.BGSSCROLL: { + //this.fieldmap.EBG_scene2DScroll((float)this.getv2(), (float)this.getv2(), (UInt16)this.getv1(), (UInt32)this.getv1()); this.fieldmap.EBG_scene2DScroll((Int16)this.getv2(), (Int16)this.getv2(), (UInt16)this.getv1(), (UInt32)this.getv1()); return 0; } @@ -1602,6 +1608,9 @@ public Int32 DoEventCode() case EBin.event_code_binary.CFLAG: { Int32 cflag = (Int32)(Byte)this.getv1(); + // Hotfix: do not hide NPCs when they are offscreen for widescreen compatibility + if (cflag == 14 && FF9StateSystem.Common.FF9.fldMapNo == 103 && this.gCur.uid >= 6 && this.gCur.uid <= 17) // In Alexandria/Square, many NPCs and the Jump Rope + return 0; if ((Int32)FF9StateSystem.Common.FF9.fldMapNo == 2934 && MBG.Instance.GetFrame < 10) { this.StartCoroutine(this.DelayedCFLAG(this.gCur, cflag)); diff --git a/Assembly-CSharp/Global/Event/Engine/EventEngine.GetSysvar.cs b/Assembly-CSharp/Global/Event/Engine/EventEngine.GetSysvar.cs index 03e35c397..c4c116233 100644 --- a/Assembly-CSharp/Global/Event/Engine/EventEngine.GetSysvar.cs +++ b/Assembly-CSharp/Global/Event/Engine/EventEngine.GetSysvar.cs @@ -1,6 +1,8 @@ using System; +using System.Reflection; using FF9; using UnityEngine; +using Memoria; public partial class EventEngine { @@ -14,7 +16,7 @@ public Int32 GetSysvar(Int32 code) num = Comn.random8(); break; case 1: - num = this.fieldmap.GetCurrentCameraIndex(); + num = this.fieldmap.camIdx; break; case 2: num = (Int32)this._context.usercontrol; @@ -75,10 +77,21 @@ public Int32 GetSysvar(Int32 code) break; case 19: num = FF9StateSystem.MiniGame.GetNumberOfCards(); + // Hotfix: in non-modded scripts, number of cards are retrieved either: + // - in order to check if the player has at least 5 (for playing with NPCs) + // - in order to check if the player has less than 100 (for preventing a card pickup) + // - in very special cases (Ticketmaster gifts / finding Hippaul secret cards), in order to check if the player has less than 96 or 98 + // So we use "Min(95, CardCount)" here except when the card count approaches the MaxCardCount + if (Configuration.TetraMaster.MaxCardCount != 100) + num = num + 4 >= Configuration.TetraMaster.MaxCardCount ? 100 - (Configuration.TetraMaster.MaxCardCount - num) : Math.Min(num, 95); //Debug.Log((object)("num of cards = " + (object)num)); break; case 20: num = Convert.ToInt32(FF9StateSystem.Settings.time); + if (Configuration.Hacks.ExcaliburIINoTimeLimit && FF9StateSystem.Common.FF9.fldMapNo == 2919) { + num = 0; + break; + } if (num > 8388607) { num = 8388607; diff --git a/Assembly-CSharp/Global/Event/Engine/EventEngine.ProcessEvents.cs b/Assembly-CSharp/Global/Event/Engine/EventEngine.ProcessEvents.cs index 7101ba891..65b3431d1 100644 --- a/Assembly-CSharp/Global/Event/Engine/EventEngine.ProcessEvents.cs +++ b/Assembly-CSharp/Global/Event/Engine/EventEngine.ProcessEvents.cs @@ -316,6 +316,7 @@ public Int32 ProcessEvents() } BGCAM_DEF new_camera_view = this.fieldmap.scene.cameraList[this.fieldmap.camIdx]; this.fieldmap.EBG_scene2DScroll((Int16)((new_camera_view.vrpMinX + new_camera_view.vrpMaxX) / 2), (Int16)((new_camera_view.vrpMinY + new_camera_view.vrpMaxY) / 2), 1, 0); + //this.fieldmap.EBG_scene2DScroll((float)((new_camera_view.vrpMinX + new_camera_view.vrpMaxX) / 2), (float)((new_camera_view.vrpMinY + new_camera_view.vrpMaxY) / 2), 1, 0); } else if (this.sExternalFieldFade < 510 && this.sExternalFieldFade + 25 >= 510) { @@ -430,6 +431,7 @@ public Int32 ProcessEvents() new_camera_position.x += cameraMove.x * 5f; new_camera_position.x = Mathf.Clamp(new_camera_position.x, bgCamera.vrpMinX, bgCamera.vrpMaxX); new_camera_position.y = Mathf.Clamp(new_camera_position.y, bgCamera.vrpMinY, bgCamera.vrpMaxY); + //this.fieldmap.EBG_scene2DScroll(new_camera_position[0], new_camera_position[1], 1, 0); this.fieldmap.EBG_scene2DScroll((Int16)new_camera_position[0], (Int16)new_camera_position[1], 1, 0); } } diff --git a/Assembly-CSharp/Global/Field/Map/Actor/FieldMapActorController.cs b/Assembly-CSharp/Global/Field/Map/Actor/FieldMapActorController.cs index 528d6972d..e3208b526 100644 --- a/Assembly-CSharp/Global/Field/Map/Actor/FieldMapActorController.cs +++ b/Assembly-CSharp/Global/Field/Map/Actor/FieldMapActorController.cs @@ -6,6 +6,8 @@ using UnityEngine; using Memoria; using Object = System.Object; +using Memoria.Prime; +using static Memoria.Configuration; public partial class FieldMapActorController : HonoBehavior { @@ -321,15 +323,15 @@ public void UpdateMovement(Boolean copyLastPos = true) this.isMoving = false; if (this.isPlayer) { - if (PersistenSingleton.Instance.GetUserControl() || FF9StateSystem.Common.FF9.fldMapNo == 1751 || FF9StateSystem.Common.FF9.fldMapNo == 404 || (FF9StateSystem.Common.FF9.fldMapNo == 205 && this.originalActor.sid == 16) || (FF9StateSystem.Common.FF9.fldMapNo == 2150 && this.originalActor.sid == 13) || (FF9StateSystem.Common.FF9.fldMapNo == 900 && this.originalActor.sid == 13)) - { - // Iifa Tree/Inner Roots (entrance after elevator) - // or Dali/Entrance - // or Prima Vista/Hallway (front of Steiner's cell), Steiner - // or L. Castle/Royal Chamber, Zidane - // or Treno/Pub, Dagger - if (copyLastPos) - this.CopyLastPos(); + if (PersistenSingleton.Instance.GetUserControl() + || FF9StateSystem.Common.FF9.fldMapNo == 1751 // Iifa Tree/Inner Roots (entrance after elevator) + || FF9StateSystem.Common.FF9.fldMapNo == 404 // Dali underground Entrance + || (FF9StateSystem.Common.FF9.fldMapNo == 205 && this.originalActor.sid == 16) //Prima Vista/ Hallway(front of Steiner's cell), Steiner + || (FF9StateSystem.Common.FF9.fldMapNo == 2150 && this.originalActor.sid == 13) //L. Castle/Royal Chamber, Zidane + || (FF9StateSystem.Common.FF9.fldMapNo == 900 && this.originalActor.sid == 13)) //Treno/Pub, Dagger + { + if (!PersistenSingleton.Instance.GetUserControl() || copyLastPos) + this.CopyLastPos(); } this.MovePC(); if (FF9StateSystem.Common.FF9.fldMapNo == 916 && this.originalActor.uid == 10 && this.curPos.z > -15900f && this.curPos.z < -15700f && this.curPos.x < 130f) @@ -345,13 +347,12 @@ public void UpdateMovement(Boolean copyLastPos = true) } else { - if ((FF9StateSystem.Common.FF9.fldMapNo == 2050 && this.originalActor.sid == 5) || (FF9StateSystem.Common.FF9.fldMapNo == 350 && this.originalActor.sid == 11) || (FF9StateSystem.Common.FF9.fldMapNo == 1315 && this.originalActor.sid == 12)) - { - // Alexandria/Main Street, Mistodon - // or Dali/Village Road, Dali_GirlA - // or Lindblum/Town Walls, Lindblum_Soldier - if (copyLastPos) - this.CopyLastPos(); + if ((FF9StateSystem.Common.FF9.fldMapNo == 2050 && this.originalActor.sid == 5) // Alexandria/Main Street, Mistodon + || (FF9StateSystem.Common.FF9.fldMapNo == 350 && this.originalActor.sid == 11) // Dali/Village Road, Dali_GirlA + || (FF9StateSystem.Common.FF9.fldMapNo == 1315 && this.originalActor.sid == 12)) // Lindblum/Town Walls, Lindblum_Soldier + { + if (!PersistenSingleton.Instance.GetUserControl() || copyLastPos) + this.CopyLastPos(); } this.MoveNPC(); } diff --git a/Assembly-CSharp/Global/Field/Map/FieldMap.cs b/Assembly-CSharp/Global/Field/Map/FieldMap.cs index 1059b4de6..bb91c007f 100644 --- a/Assembly-CSharp/Global/Field/Map/FieldMap.cs +++ b/Assembly-CSharp/Global/Field/Map/FieldMap.cs @@ -6,6 +6,8 @@ using Memoria; using Memoria.Scripts; using Object = System.Object; +using Memoria.Prime; +using Assets.Scripts.Common; [Flags] public enum FieldMapFlags : uint @@ -25,7 +27,6 @@ public enum FieldMapFlags : uint Unknown128 = 128, } - public class FieldMap : HonoBehavior { public FieldMap() @@ -107,6 +108,7 @@ public override void HonoAwake() this.rainRenderer = goCamera.AddComponent(); } this.camIdx = 0; + //Log.Message("HonoAwake() this.camIdx = 0;"); this.curCamIdx = -1; this.charAimHeight = 324; this.mapName = FF9StateSystem.Field.SceneName; @@ -118,7 +120,7 @@ public override void HonoAwake() HonoBehaviorSystem.TargetFrameTime = 0.0333333351f; this.attachList = new EBG_ATTACH_DEF[10]; this.isBattleBackupPos = false; - this.EBG_init(); + this.BG_init(); if (FF9StateSystem.Common.FF9.fldMapNo == 2507) // I. Castle/Stairwell, room with ladders and stairs { base.StartCoroutine(this.DelayedActiveTri()); @@ -183,9 +185,7 @@ public Camera GetMainCamera() public BGCAM_DEF GetCurrentBgCamera() { - if (FF9StateSystem.Common.FF9.fldMapNo == 70) // Opening-For FMV - return null; - if (this.curCamIdx < 0 || this.curCamIdx > this.scene.cameraList.Count) + if (FF9StateSystem.Common.FF9.fldMapNo == 70 || this.curCamIdx < 0 || this.curCamIdx > this.scene.cameraList.Count) return null; return this.scene.cameraList[this.camIdx]; } @@ -217,12 +217,12 @@ public void ChangeFieldMap(String name) public void CreateBorder(Int32 overlayNdx, Byte r, Byte g, Byte b) { - BGOVERLAY_DEF bgoverlay_DEF = this.scene.overlayList[overlayNdx]; + BGOVERLAY_DEF bgOverlay = this.scene.overlayList[overlayNdx]; Material material = new Material(ShadersLoader.Find("PSX/FieldMap_Abr_None")); for (Int32 i = 0; i < 4; i++) { GameObject gameObject = new GameObject("border" + i.ToString("D3")); - gameObject.transform.parent = bgoverlay_DEF.transform; + gameObject.transform.parent = bgOverlay.transform; gameObject.transform.localPosition = Vector3.zero; gameObject.transform.localRotation = Quaternion.identity; gameObject.transform.localScale = Vector3.one; @@ -241,27 +241,27 @@ public void CreateBorder(Int32 overlayNdx, Byte r, Byte g, Byte b) { case 0: width = -this.scene.cameraList[index].vrpMinX; - height = bgoverlay_DEF.h; + height = bgOverlay.h; posX = 0; posY = height; break; case 1: width = this.scene.cameraList[index].vrpMinX; - height = bgoverlay_DEF.h; - posX = bgoverlay_DEF.w; + height = bgOverlay.h; + posX = bgOverlay.w; posY = height; break; case 2: - width = bgoverlay_DEF.w; + width = bgOverlay.w; height = this.scene.cameraList[index].vrpMinY; posX = 0; posY = 0; break; case 3: - width = bgoverlay_DEF.w; + width = bgOverlay.w; height = -this.scene.cameraList[0].vrpMinY; posX = 0; - posY = bgoverlay_DEF.h; + posY = bgOverlay.h; break; } vertList.Add(new Vector3(posX, posY - height, 0f)); @@ -309,8 +309,19 @@ public override void HonoUpdate() } } this.ActivateCamera(); - this.EBG_animationService(); - this.EBG_attachService(); + this.BgAnimationService(); + this.BgAttachService(); + } + + public override void HonoLateUpdate() + { + this.SceneService2DScroll(); + this.SceneService3DScroll(); + if (Configuration.Graphics.InitializeWidescreenSupport()) + OnWidescreenSupportChanged(); + this.CenterCameraOnPlayer(); + this.SceneServiceScroll(this.scene); + this.UpdateOverlayAll(); } public override void HonoOnGUI() @@ -386,22 +397,6 @@ public static Int32 ff9fieldCharGetActiveList(List CharArray) return result; } - public override void HonoLateUpdate() - { - this.EBG_sceneService2DScroll(); - this.EBG_sceneService3DScroll(); - this.EBG_sceneServiceScroll(this.scene); - if (Configuration.Graphics.InitializeWidescreenSupport()) - OnWidescreenSupportChanged(); - this.CenterCameraOnPlayer(); - this.UpdateOverlayAll(); - } - - public Int32 GetCurrentCameraIndex() - { - return this.camIdx; - } - public void SetCurrentCameraIndex(Int32 newCamIdx) { if (this.camIdx == newCamIdx) @@ -413,6 +408,7 @@ public void SetCurrentCameraIndex(Int32 newCamIdx) BGCAM_DEF bgCamera = this.scene.cameraList[this.camIdx]; Vector2 centerOffset = bgCamera.GetCenterOffset(); this.offset.x = centerOffset.x + bgCamera.w / 2 - HalfFieldWidth; + if (dbug) Log.Message("SetCurrentCameraIndex(" + newCamIdx + ") | this.offset.x(" + this.offset.x + ") = centerOffset.x(" + centerOffset.x + ") + bgCamera.w(" + bgCamera.w + ") / 2 - HalfFieldWidth(" + HalfFieldWidth + ")"); this.offset.y = -centerOffset.y - bgCamera.h / 2 + HalfFieldHeight; Shader.SetGlobalFloat("_OffsetX", this.offset.x); Shader.SetGlobalFloat("_OffsetY", this.offset.y); @@ -430,11 +426,17 @@ public void SetCurrentCameraIndex(Int32 newCamIdx) this.flags |= FieldMapFlags.Unknown128; this.walkMesh.ProcessBGI(); this.walkMesh.UpdateActiveCameraWalkmesh(); + SmoothCamDelay = 6; + SmoothCamActive = (!SmoothCamExcludeMaps.Contains(FF9StateSystem.Common.FF9.fldMapNo)); + String camIdxIfCam = this.scene.cameraList.Count > 1 ? "-" + this.camIdx : ""; + PlayerWindow.Instance.SetTitle($"Map: {FF9StateSystem.Common.FF9.fldMapNo}{camIdxIfCam} ({FF9StateSystem.Common.FF9.mapNameStr}) | Index/Counter: {PersistenSingleton.Instance.eBin.getVarManually(EBin.MAP_INDEX_SVR)}/{PersistenSingleton.Instance.eBin.getVarManually(EBin.SC_COUNTER_SVR)} | Loc: {FF9StateSystem.Common.FF9.fldLocNo}"); + if (dbug) Log.Message(" |_ SetCurrentCameraIndex | ShaderMulX: " + ShaderMulX + " | bgCamera.depthOffset: " + bgCamera.depthOffset + " | bgCamera.vrpMaxX " + bgCamera.vrpMaxX + " | bgCamera.depthOffset: " + bgCamera.depthOffset + " | this.scene.maxX: " + this.scene.maxX); } public static Boolean IsNarrowMap() { - return NarrowMapList.IsCurrentMapNarrow(); + //Log.Message("NarrowMapList.IsCurrentMapNarrow((Int32)CalcPsxFieldWidth()) " + NarrowMapList.IsCurrentMapNarrow((Int32)CalcPsxFieldWidth())); + return NarrowMapList.IsCurrentMapNarrow((Int32)CalcPsxFieldWidth()); } public void LoadFieldMap(String name) @@ -452,6 +454,7 @@ public void LoadFieldMap(String name) BGCAM_DEF bgCamera = this.scene.cameraList[this.camIdx]; Vector2 centerOffset = bgCamera.GetCenterOffset(); this.offset.x = centerOffset.x + bgCamera.w / 2 - HalfFieldWidth; + if (dbug) Log.Message("LoadFieldMap(" + FF9StateSystem.Common.FF9.fldMapNo + " | this.offset.x(" + this.offset.x + ") = centerOffset.x(" + centerOffset.x + ") + bgCamera.w(" + bgCamera.w + ") / 2 - HalfFieldWidth(" + HalfFieldWidth + ")"); this.offset.y = -centerOffset.y - bgCamera.h / 2 + HalfFieldHeight; Shader.SetGlobalFloat("_OffsetX", this.offset.x); Shader.SetGlobalFloat("_OffsetY", this.offset.y); @@ -468,8 +471,30 @@ public void LoadFieldMap(String name) this.walkMesh.CreateWalkMesh(); this.walkMesh.CreateProjectedWalkMesh(); this.walkMesh.BGI_simInit(); + SmoothCamDelay = 6; + SmoothCamActive = (!SmoothCamExcludeMaps.Contains(FF9StateSystem.Common.FF9.fldMapNo)); FPSManager.DelayMainLoop(Time.realtimeSinceStartup - loadStartTime); - } + if (dbug) Log.Message("_ LoadFieldMap | ShaderMulX: " + ShaderMulX + " | bgCamera.depthOffset: " + bgCamera.depthOffset + " | bgCamera.vrpMaxX " + bgCamera.vrpMaxX + " | bgCamera.depthOffset: " + bgCamera.depthOffset + " | this.scene.maxX: " + this.scene.maxX); + } + public static readonly HashSet SmoothCamExcludeMaps = new HashSet() + { + 575, // Hunting festival + 767, // Burmecia, the queen slides from her layer + 1754, // Fast scroll on Iifa platform buggy + 3000, // ending + 3001, + 3002, + 3003, + 3004, + 3005, + 3006, + 3007, + 3008, + 3009, + 3010, + 3011, + 3012, + }; public void ActivateCamera() { @@ -565,11 +590,11 @@ public void RestoreShadowOff(int actorUid, Actor actorOfObj) private void SetCharScale(Actor actorOfObj, int sx, int sy, int sz) { - int num = 18; + int scalingFactor = 18; if (actorOfObj != null) { if (actorOfObj.go != null) - geo.geoScaleSetXYZ(actorOfObj.go, sx << 24 >> num, sy << 24 >> num, sz << 24 >> num); + geo.geoScaleSetXYZ(actorOfObj.go, sx << 24 >> scalingFactor, sy << 24 >> scalingFactor, sz << 24 >> scalingFactor); actorOfObj.scaley = (byte)sy; } } @@ -675,21 +700,25 @@ public void CenterCameraOnPlayer() return; if (this.curCamIdx < 0 || this.curCamIdx > this.scene.cameraList.Count) return; - BGCAM_DEF bgcam_DEF = this.scene.cameraList[this.camIdx]; + BGCAM_DEF bgCamera = this.scene.cameraList[this.camIdx]; Vector3 localPosition = camera.transform.localPosition; - localPosition.x = bgcam_DEF.centerOffset[0] + this.charOffset.x; - localPosition.y = bgcam_DEF.centerOffset[1] - this.charOffset.y; + float CamPositionX = bgCamera.centerOffset[0] + this.charOffset.x; + float CamPositionY = bgCamera.centerOffset[1] - this.charOffset.y; + //Log.Message("bgCamera.centerOffset[0] begin center camera on player " + bgCamera.centerOffset[0]); - if (Configuration.Graphics.InitializeWidescreenSupport()) + if (Configuration.Graphics.InitializeWidescreenSupport() && map != 931) { - Int32 threshmargin = Math.Min(bgcam_DEF.w - PsxFieldWidth, 0); // Offset value for fields that are between 320 & 398 - if (!IsNarrowMap() && map != 507) // Cargo Ship/Deck + Int32 mapWidth = NarrowMapList.MapWidth(map); + + Int32 threshmargin = Math.Min((Int32)bgCamera.w - PsxFieldWidth, 0); // Offset value for fields that are between 320 & 398 + //if (dbug) Log.Message("PsxFieldWidth" + PsxFieldWidth); + if (mapWidth > PsxFieldWidth && map != 507) // Cargo Ship/Deck { - foreach (KeyValuePair entry in mapCameraMargin) + foreach (KeyValuePair entry in NarrowMapList.mapCameraMargin) if (map == entry.Key) threshmargin = entry.Value; - Int32 threshright = bgcam_DEF.w - PsxFieldWidth - threshmargin; + Int32 threshright = bgCamera.w - PsxFieldWidth - threshmargin; if (map == 103 || map == 1853 || map == 2053 || map == 2606) // Exceptions in alex center, branbal threshmargin += 16; @@ -698,268 +727,69 @@ public void CenterCameraOnPlayer() else if (map == 2923) // Exception in crystal world threshmargin += 20; - localPosition.x = (Int32)Math.Max(threshmargin, localPosition.x); - localPosition.x = (Int32)Math.Min(threshright, localPosition.x); + CamPositionX = (float)Math.Max(threshmargin, CamPositionX); + CamPositionX = (float)Math.Min(threshright, CamPositionX); } - else if (map == 1205 || map == 1652 || map == 2552) + else if (map == 1205 || map == 1652 || map == 2552 || map == 154 || map == 1215 || map == 1807) // A. Castle/Chapel, Iifa Tree/Roots, Earth Shrine/Interior, Alex grand hall { - // A. Castle/Chapel, Iifa Tree/Roots or Earth Shrine/Interior if (map == 1652 && this.camIdx == 0) // Iifa Tree/Roots threshmargin += 16; - Int32 threshright = bgcam_DEF.w - PsxFieldWidth - threshmargin; - - localPosition.x = (Int32)Math.Max(threshmargin, localPosition.x); - localPosition.x = (Int32)Math.Min(threshright, localPosition.x); + Int32 threshright = bgCamera.w - PsxFieldWidth - threshmargin; + + CamPositionX = (float)Math.Max(threshmargin, CamPositionX); + CamPositionX = (float)Math.Min(threshright, CamPositionX); } else if (IsNarrowMap()) { - foreach (KeyValuePair entry in actualNarrowMapWidthDict) - if (map == entry.Key) - localPosition.x = (Int32)((bgcam_DEF.w - entry.Value) / 2); - switch (map) // offsets for scrolling maps stretched to WS + if (mapWidth <= PsxFieldWidth && mapWidth > 320) { - case 456: // Dali Mountain/Summit - localPosition.x = 160; - break; - case 505: // Cargo ship offset - localPosition.x = 105; - break; - case 1153: // Rose Rouge cockpit offset - localPosition.x = 175; - break; - default: - break; + CamPositionX = (float)((bgCamera.w - mapWidth) / 2); } } - if (Configuration.Graphics.ScreenIs16to10()) - { - switch (map) // offsets for scrolling maps stretched to WS - { - case 456: // Dali Mountain/Summit - localPosition.x = 160 + 35; - break; - case 505: // Cargo ship offset - localPosition.x = 105 - 35; - break; - case 1153: // Rose Rouge cockpit offset - localPosition.x = 175 - 35; - break; - default: - break; - } + + switch (map) // offsets for scrolling maps stretched to WS + { + case 456: // Dali Mountain/Summit + CamPositionX = Configuration.Graphics.ScreenIs16to10() ? 195 : 160; break; + case 505: // Cargo ship offset + CamPositionX = Configuration.Graphics.ScreenIs16to10() ? 70 : 105; break; + case 1153: // Rose Rouge cockpit offset + CamPositionX = Configuration.Graphics.ScreenIs16to10() ? 140 : 175; break; + case 2716: // fix for Kuja descending camera too high + CamPositionY = (float)Math.Min(0, CamPositionY); break; + default: + break; } } - camera.transform.localPosition = localPosition; - } + if (SmoothCamActive) + { + if (SmoothCamDelay <= 0) + { + SmoothCamDelta.x = (Prev_CamPositionX - CamPositionX) * (float)(SmoothCamPercent() / 100f); + CamPositionX += SmoothCamDelta.x; + Prev_CamPositionX = CamPositionX; + SmoothCamDelta.y = (Prev_CamPositionY - CamPositionY) * (float)(SmoothCamPercent() / 100f); + CamPositionY += SmoothCamDelta.y; + Prev_CamPositionY = CamPositionY; + } + else + { + SmoothCamDelay -= 1; + Prev_CamPositionX = CamPositionX; + Prev_CamPositionY = CamPositionY; + } + } + + localPosition.x = CamPositionX; + localPosition.y = CamPositionY; - private static readonly Dictionary mapCameraMargin = new Dictionary - { - //{mapNo,pixels on each side to crop because of scrollable} - {1051,8}, - {1057,16}, - {1058,16}, - {1060,16}, - {1652,16}, - {1653,16}, - }; + if (dbug) Log.Message("CenterCameraOnPlayer | X: " + CamPositionX + " Y:" + CamPositionY); - public static readonly Dictionary actualNarrowMapWidthDict = new Dictionary - { - //{mapNo,(actualWidth - 2)} - {203,334}, - {502,334}, - {503,334}, - {760,334}, - {814,334}, - {816,334}, - {1151,334}, - {1458,334}, - {1500,334}, - {1506,334}, - {1605,334}, - {1606,334}, - {1608,334}, - {1660,334}, - {1661,334}, - {1662,334}, - {1705,334}, - {1707,334}, - {1751,334}, - {2202,334}, - {2204,334}, - {2205,334}, - {2208,334}, - {2254,334}, - {2257,334}, - {2303,334}, - {2365,334}, - {2513,334}, - {2756,334}, - {2932,334}, - {3057,334}, - {114,350}, - {550,350}, - {620,350}, - {802,350}, - {803,350}, - {1212,350}, - {1300,350}, - {1370,350}, - {1508,350}, - {1650,350}, - {1752,350}, - {1757,350}, - {1863,350}, - {1951,350}, - {1952,350}, - {2000,350}, - {2055,350}, - {2771,350}, - {2203,350}, - {2261,350}, - {2356,350}, - {2362,350}, - {2500,350}, - {2501,350}, - {2654,350}, - {60,366}, - {150,366}, - {161,366}, - {201,366}, - {262,366}, - {565,366}, - {911,366}, - {1213,366}, - {1222,366}, - {1251,366}, - {1254,366}, - {1312,366}, - {1403,366}, - {1803,366}, - {1814,366}, - {1817,366}, - {1911,366}, - {1953,366}, - {2002,366}, - {2004,366}, - {2006,366}, - {2112,366}, - {2400,366}, - {2502,366}, - {2503,366}, - {2650,366}, - {2904,366}, - {2913,366}, - {2928,366}, - {3100,366}, - {102,382}, - {109,382}, - {162,382}, - {206,382}, - {207,382}, - {251,382}, - {252,382}, - {407,382}, - {553,382}, - {556,382}, - {705,382}, - {751,382}, - {813,382}, - {950,382}, - {1017,382}, - {1018,382}, - {1058,380}, - {1108,380}, - {1201,382}, - {1210,382}, - {1303,382}, - {1404,382}, - {1452,382}, - {1453,382}, - {1509,382}, - {1656,382}, - {1820,382}, - {1852,382}, - {1858,382}, - {2052,382}, - {2103,382}, - {2200,382}, - {2222,382}, - {2355,382}, - {2406,382}, - {2451,382}, - {2657,382}, - {2851,382}, - {2855,382}, - {2856,382}, - {2915,382}, - {3052,382}, - {55,398}, - {157,398}, - {405,398}, - {456,398}, - {505,398}, - {561,398}, - {566,398}, - {568,398}, - {569,398}, - {571,398}, - {613,398}, - {656,398}, - {657,398}, - {658,398}, - {659,398}, - {663,398}, - {753,398}, - {755,398}, - {806,398}, - {851,398}, - {855,398}, - {901,398}, - {913,398}, - {1054,398}, - {1104,398}, - {1153,398}, - {1218,398}, - {1313,398}, - {1363,398}, - {1408,398}, - {1414,398}, - {1424,398}, - {1456,398}, - {1600,398}, - {1601,398}, - {1602,398}, - {1700,398}, - {1701,398}, - {1702,398}, - {1810,398}, - {1901,398}, - {1913,398}, - {2113,398}, - {2163,398}, - {2212,398}, - {2213,398}, - {2352,398}, - {2353,398}, - {2551,398}, - {2601,398}, - {2658,398}, - {2706,398}, - {2906,398}, - {3005,398}, - {3055,398}, - {1205,384}, - {154,352}, - {1215,352}, - {1805,352}, - {1807,352}, - {1652,336}, - {2552,352}, - }; + camera.transform.localPosition = localPosition; + } public void ff9fieldInternalBattleEncountService() { @@ -985,6 +815,7 @@ public void ff9fieldInternalBattleEncountService() FF9StateSystem.Field.FF9Field.attr &= 4294960870u; PersistenSingleton.Instance.attr |= 2u; } + if (dbug) Log.Message("ff9fieldInternalBattleEncountStart"); } public void ff9fieldInternalBattleEncountStart() @@ -996,44 +827,33 @@ public void ff9fieldInternalBattleEncountStart() FieldMap.FF9FieldAttr.ff9[0, 0] = 67; FieldMap.FF9FieldAttr.ff9[0, 2] = 60; FieldMap.FF9FieldAttr.field[0, 2] = 6425; + if (dbug) Log.Message("ff9fieldInternalBattleEncountStart"); } - private void EBG_init() - { - this.EBG_stateInit(); - if (this.EBG_sceneInit() != 1) - return; - this.EBG_animationInit(); - this.EBG_attachInit(); - } - - private void EBG_stateInit() + private void BG_init() { + // EBG_stateInit(); this.flags = FieldMapFlags.GenericInitial; this.curVRP = Vector2.zero; this.charOffset = Vector2.zero; this.startPoint = Vector2.zero; this.endPoint = Vector2.zero; + this.SmoothCamDelta = Vector2.zero; this.curFrame = 0; this.prevScr = Vector2.zero; this.charAimHeight = 324; - } - private Int32 EBG_sceneInit() - { - if (FF9StateSystem.Common.FF9.fldMapNo == 70) // Opening-For FMV - return 0; - BGCAM_DEF bgcam_DEF = this.scene.cameraList[this.curCamIdx]; - Single num = (Single)((bgcam_DEF.vrpMinX + bgcam_DEF.vrpMaxX) / 2 - bgcam_DEF.centerOffset[0]) - HalfFieldWidth; - Single num2 = (Single)((bgcam_DEF.vrpMinY + bgcam_DEF.vrpMaxY) / 2 + bgcam_DEF.centerOffset[1]) - HalfFieldHeight; - Int32 index = 0; - Single value = num; - this.parallaxOrg[0] = value; - this.curVRP[index] = value; - Int32 index2 = 1; - value = num2; - this.parallaxOrg[1] = value; - this.curVRP[index2] = value; + if (FF9StateSystem.Common.FF9.fldMapNo == 70) // Opening-For FMV) + return; + + // EBG_stateInit() + BGCAM_DEF bgCamera = this.scene.cameraList[this.curCamIdx]; + Single centerOffsetX = (Single)((bgCamera.vrpMinX + bgCamera.vrpMaxX) / 2 - bgCamera.centerOffset[0]) - HalfFieldWidth; + Single centerOffsetY = (Single)((bgCamera.vrpMinY + bgCamera.vrpMaxY) / 2 + bgCamera.centerOffset[1]) - HalfFieldHeight; + this.parallaxOrg.x = centerOffsetX; + this.curVRP.x = centerOffsetX; + this.parallaxOrg.y = centerOffsetY; + this.curVRP.y = centerOffsetY; this.scrollWindowPos = new Int16[4][]; this.scrollWindowDim = new Int16[4][]; this.scrollWindowAlphaX = new Int16[4]; @@ -1041,19 +861,15 @@ private Int32 EBG_sceneInit() for (Int32 i = 0; i < 4; i++) { this.scrollWindowPos[i] = new Int16[2]; - this.scrollWindowDim[i] = new Int16[2]; this.scrollWindowPos[i][0] = 0; this.scrollWindowPos[i][1] = 0; - this.scrollWindowDim[i][0] = bgcam_DEF.w; - this.scrollWindowDim[i][1] = bgcam_DEF.h; + this.scrollWindowDim[i] = new Int16[2]; + this.scrollWindowDim[i][0] = bgCamera.w; + this.scrollWindowDim[i][1] = bgCamera.h; this.scrollWindowAlphaX[i] = 256; this.scrollWindowAlphaY[i] = 256; } - return 1; - } - - private Int32 EBG_animationInit() - { + // EBG_animationInit(); List animList = this.scene.animList; List overlayList = this.scene.overlayList; Int32 animCount = this.scene.animCount; @@ -1067,11 +883,7 @@ private Int32 EBG_animationInit() List frameList = bgAnim.frameList; overlayList[frameList[0].target].SetFlags(BGOVERLAY_DEF.OVERLAY_FLAG.Active, true); } - return 1; - } - - public Int32 EBG_attachInit() - { + // EBG_attachInit(); this.attachCount = 0; for (Int32 i = 0; i < 10; i++) { @@ -1084,7 +896,7 @@ public Int32 EBG_attachInit() this.attachList[i].x = 0; this.attachList[i].y = 0; } - return 1; + if (dbug) Log.Message("EBG_init()"); } public Int32 EBG_sceneGetVRP(ref Int16 x, ref Int16 y) @@ -1092,8 +904,9 @@ public Int32 EBG_sceneGetVRP(ref Int16 x, ref Int16 y) if (this.scene.cameraList.Count <= 0) return 0; BGCAM_DEF bgCamera = this.scene.cameraList[this.curCamIdx]; - x = (Int16)(this.curVRP[0] + bgCamera.centerOffset[0] + HalfFieldWidth); - y = (Int16)(this.curVRP[1] - bgCamera.centerOffset[1] + HalfFieldHeight); + x = (Int16)(this.curVRP.x + bgCamera.centerOffset[0] + HalfFieldWidth); + y = (Int16)(this.curVRP.y - bgCamera.centerOffset[1] + HalfFieldHeight); + //Log.Message("EBG_sceneGetVRP curVRP" + x); return 1; } @@ -1106,6 +919,11 @@ public Int32 EBG_overlaySetActive(Int32 overlayNdx, Int32 activeFlag) public Int32 EBG_overlayDefineViewport(Int32 viewportNdx, Int16 x, Int16 y, Int16 w, Int16 h) { + if (dbug) Log.Message("EBG_overlayDefineViewport " + viewportNdx + " | x:" + x + " y:" + y + " w:" + w + " h:" + h); + + if (!(viewportNdx >= 0 && viewportNdx < 4)) + viewportNdx = 0; + this.scrollWindowPos[viewportNdx][0] = x; this.scrollWindowPos[viewportNdx][1] = y; this.scrollWindowDim[viewportNdx][0] = w; @@ -1115,6 +933,7 @@ public Int32 EBG_overlayDefineViewport(Int32 viewportNdx, Int16 x, Int16 y, Int1 public Int32 EBG_overlayDefineViewportAlpha(Int32 viewportNdx, Int32 alphaX, Int32 alphaY) { + if (dbug) Log.Message("EBG_overlayDefineViewportAlpha " + viewportNdx + " | alphaX:" + alphaX + " alphaY:" + alphaY); this.scrollWindowAlphaX[viewportNdx] = (Int16)alphaX; this.scrollWindowAlphaY[viewportNdx] = (Int16)alphaY; return 1; @@ -1124,6 +943,8 @@ public Int32 EBG_overlaySetViewport(Int32 overlayNdx, Int32 viewportNdx) { BGOVERLAY_DEF bgOverlay = this.scene.overlayList[overlayNdx]; bgOverlay.viewportNdx = (Byte)viewportNdx; + + if (dbug) Log.Message("EBG_overlaySetViewport | overlayNdx:" + overlayNdx + " viewportNdx:" + bgOverlay.viewportNdx); return 1; } @@ -1132,18 +953,19 @@ public Int32 EBG_overlaySetLoop(Int32 overlayNdx, UInt32 flag, Int32 dx, Int32 d BGOVERLAY_DEF bgOverlay = this.scene.overlayList[overlayNdx]; if (flag != 0u) { + //SmoothCamActive = false; bgOverlay.flags |= BGOVERLAY_DEF.OVERLAY_FLAG.Loop; if (this.scene.combineMeshes) this.scene.CreateSeparateOverlay(this, this.UseUpscalFM, overlayNdx); + if (dbug) Log.Message("EBG_overlaySetLoop " + overlayNdx + " | loop | dx:" + dx + " dy:" + dy); } else { bgOverlay.flags &= ~BGOVERLAY_DEF.OVERLAY_FLAG.Loop; + if (dbug) Log.Message("EBG_overlaySetLoop " + overlayNdx + " | noloop | dx:" + dx + " dy:" + dy); } - bgOverlay.dX = (Int16)dx; - bgOverlay.fracX = 0; - bgOverlay.dY = (Int16)dy; - bgOverlay.fracY = 0; + bgOverlay.scrollX = (Int16)dx; + bgOverlay.scrollY = (Int16)dy; return 1; } @@ -1151,9 +973,16 @@ public Int32 EBG_overlaySetLoopType(Int32 overlayNdx, UInt32 isScreenAnchored) { BGOVERLAY_DEF bgOverlay = this.scene.overlayList[overlayNdx]; if (isScreenAnchored != 0u) + { + if (dbug) Log.Message("EBG_overlaySetLoopType " + overlayNdx + " | + ScreenAnchored"); bgOverlay.flags |= BGOVERLAY_DEF.OVERLAY_FLAG.ScreenAnchored; + } else + { + if (dbug) Log.Message("EBG_overlaySetLoopType " + overlayNdx + " | - ScreenAnchored"); bgOverlay.flags &= ~BGOVERLAY_DEF.OVERLAY_FLAG.ScreenAnchored; + } + return 1; } @@ -1162,39 +991,44 @@ public Int32 EBG_overlaySetScrollWithOffset(Int32 overlayNdx, UInt32 flag, Int32 BGOVERLAY_DEF bgOverlay = this.scene.overlayList[overlayNdx]; if (flag != 0u) { + if (dbug) Log.Message("EBG_overlaySetScrollWithOffset " + overlayNdx + " | ScrollWithOffset"); bgOverlay.flags |= BGOVERLAY_DEF.OVERLAY_FLAG.ScrollWithOffset; + //SmoothCamActive = false; if (this.scene.combineMeshes) this.scene.CreateSeparateOverlay(this, this.UseUpscalFM, overlayNdx); } else { + if (dbug) Log.Message("EBG_overlaySetScrollWithOffset " + overlayNdx + " | not ScrollWithOffset"); bgOverlay.flags &= ~BGOVERLAY_DEF.OVERLAY_FLAG.ScrollWithOffset; } if (isXOffset != 0u) { - bgOverlay.dX = (Int16)offset; - bgOverlay.dY = (Int16)delta; + if (dbug) Log.Message("EBG_overlaySetScrollWithOffset " + overlayNdx + " | isXOffset"); + bgOverlay.scrollX = (Int16)offset; + bgOverlay.scrollY = (Int16)delta; bgOverlay.isXOffset = 1; } else { - bgOverlay.dX = (Int16)delta; - bgOverlay.dY = (Int16)offset; + if (dbug) Log.Message("EBG_overlaySetScrollWithOffset " + overlayNdx + " | not isXOffset"); + bgOverlay.scrollX = (Int16)delta; + bgOverlay.scrollY = (Int16)offset; bgOverlay.isXOffset = 0; } - bgOverlay.fracX = 0; - bgOverlay.fracY = 0; return 1; } public Int32 EBG_charAttachOverlay(Int32 overlayNdx, Int16 attachX, Int16 attachY, SByte surroundMode, Byte r, Byte g, Byte b) { + if (dbug) Log.Message("EBG_charAttachOverlay " + overlayNdx + " | attachX:" + attachX + " attachY:" + attachY); this.attachList[this.attachCount].ndx = (Int16)overlayNdx; this.attachList[this.attachCount].x = attachX; this.attachList[this.attachCount].y = attachY; this.attachList[this.attachCount].surroundMode = surroundMode; if (surroundMode >= 0) { + if (dbug) Log.Message(" |_ EBG_charAttachOverlay surroundMode: RGB:" + r + g + b); this.attachList[this.attachCount].r = r; this.attachList[this.attachCount].g = g; this.attachList[this.attachCount].b = b; @@ -1206,6 +1040,7 @@ public Int32 EBG_charAttachOverlay(Int32 overlayNdx, Int16 attachX, Int16 attach public Int32 EBG_animAnimate(Int32 animNdx, Int32 frameNdx) { + if (dbug) Log.Message("EBG_animAnimate | anim:" + animNdx + " frame:" + frameNdx); BGANIM_DEF bgAnim = this.scene.animList[animNdx]; bgAnim.flags |= BGANIM_DEF.ANIM_FLAG.Animate; bgAnim.curFrame = frameNdx << 8; @@ -1215,6 +1050,7 @@ public Int32 EBG_animAnimate(Int32 animNdx, Int32 frameNdx) public Int32 EBG_animShowFrame(Int32 animNdx, Int32 frameNdx) { + if (dbug) Log.Message("EBG_animShowFrame | anim:" + animNdx + " frame:" + frameNdx); BGANIM_DEF bgAnim = this.scene.animList[animNdx]; List frameList = bgAnim.frameList; List overlayList = this.scene.overlayList; @@ -1228,31 +1064,30 @@ public Int32 EBG_animSetActive(Int32 animNdx, Int32 flag) { BGANIM_DEF bgAnim = this.scene.animList[animNdx]; if (flag != 0) + { + if (dbug) Log.Message("EBG_animSetActive | PLAY anim:" + animNdx); bgAnim.flags |= BGANIM_DEF.ANIM_FLAG.StartPlay; + } else + { + if (dbug) Log.Message("EBG_animSetActive | STOP anim:" + animNdx); bgAnim.flags &= ~BGANIM_DEF.ANIM_FLAG.StartPlay; + } return 1; } public Int32 EBG_animSetFrameRate(Int32 animNdx, Int32 frameRate) { + if (dbug) Log.Message("EBG_animSetFrameRate | anim:" + animNdx + " frameRate:" + frameRate); BGANIM_DEF bgAnim = this.scene.animList[animNdx]; bgAnim.frameRate = (Int16)frameRate; bgAnim.CalculateActualFrameCount(); return 1; } - public Int32 EBG_animSetFrameWaitAll(Int32 animNdx, Int32 frameWait) - { - BGANIM_DEF bgAnim = this.scene.animList[animNdx]; - List frameList = bgAnim.frameList; - for (Int32 i = 0; i < bgAnim.frameCount; i++) - frameList[i].value = (SByte)frameWait; - return 1; - } - public Int32 EBG_animSetFrameWait(Int32 animNdx, Int32 frameNdx, Int32 frameWait) { + if (dbug) Log.Message("EBG_animSetFrameWait | anim:" + animNdx + " frame:" + frameNdx + " frameWait:" + frameWait); BGANIM_DEF bgAnim = this.scene.animList[animNdx]; List frameList = bgAnim.frameList; frameList[frameNdx].value = (SByte)frameWait; @@ -1261,6 +1096,7 @@ public Int32 EBG_animSetFrameWait(Int32 animNdx, Int32 frameNdx, Int32 frameWait public Int32 EBG_animSetFlags(Int32 animNdx, Int32 flags) { + if (dbug) Log.Message("EBG_animSetFlags " + animNdx + " | flags:" + flags); BGANIM_DEF bgAnim = this.scene.animList[animNdx]; bgAnim.flags |= (BGANIM_DEF.ANIM_FLAG)flags & BGANIM_DEF.ANIM_FLAG.Modifiables; return 1; @@ -1268,6 +1104,7 @@ public Int32 EBG_animSetFlags(Int32 animNdx, Int32 flags) public Int32 EBG_animSetPlayRange(Int32 animNdx, Int32 frameStart, Int32 frameEnd) { + if (dbug) Log.Message("EBG_animSetPlayRange " + animNdx + " | frames: " + frameStart + " to " + frameEnd); BGANIM_DEF bgAnim = this.scene.animList[animNdx]; List frameList = bgAnim.frameList; bgAnim.flags |= BGANIM_DEF.ANIM_FLAG.StartPlay; @@ -1281,6 +1118,7 @@ public Int32 EBG_animSetPlayRange(Int32 animNdx, Int32 frameStart, Int32 frameEn public Int32 EBG_animSetVisible(Int32 animNdx, Int32 isVisible) { + if (dbug) Log.Message("EBG_animSetVisible | anim:"+ animNdx + " Visible:" + (isVisible != 0)); BGANIM_DEF bgAnim = this.scene.animList[animNdx]; List frameList = bgAnim.frameList; List overlayList = this.scene.overlayList; @@ -1300,19 +1138,15 @@ public Int32 EBG_cameraSetViewport(Int32 camNdx, Int16 minX, Int16 maxX, Int16 m bgCamera.vrpMaxX = (Int16)Math.Max(maxX - HalfFieldWidthNative, HalfFieldWidthNative); bgCamera.vrpMinY = (Int16)Math.Min(minY + HalfFieldHeight, bgCamera.h - HalfFieldHeight); bgCamera.vrpMaxY = (Int16)Math.Max(maxY - HalfFieldHeight, HalfFieldHeight); + if (dbug) Log.Message("EBG_cameraSetViewport | vrpMinX:" + bgCamera.vrpMinX + " vrpMaxX:" + bgCamera.vrpMaxX + " vrpMinY:" + bgCamera.vrpMinY + " vrpMaxY:" + bgCamera.vrpMaxY); return 1; } - public bool EBG_isCombineMesh(BGOVERLAY_DEF overlayPtr) - { - return overlayPtr.transform.GetComponent() != null; - } - public Int32 EBG_overlaySetShadeColor(Int32 overlayNdx, Byte r, Byte g, Byte b) { BGOVERLAY_DEF bgOverlay = this.scene.overlayList[overlayNdx]; List spriteList = bgOverlay.spriteList; - if (this.EBG_isCombineMesh(bgOverlay)) + if (bgOverlay.transform.GetComponent() != null) //EBG_isCombineMesh { Material material = bgOverlay.transform.gameObject.GetComponent().material; material.SetColor("_Color", new Color(r / 128f, g / 128f, b / 128f, 1f)); @@ -1320,6 +1154,7 @@ public Int32 EBG_overlaySetShadeColor(Int32 overlayNdx, Byte r, Byte g, Byte b) } else if (spriteList.Count > 0) { + //if (dbug) Log.Message("EBG_overlaySetShadeColor | !EBG_isCombineMesh(bgOverlay) && (spriteList.Count > 0)"); Material material = spriteList[0].transform.gameObject.GetComponent().material; Int32 spriteCount = bgOverlay.spriteCount; Int32 indexShift = FF9StateSystem.Common.FF9.id != 0 ? spriteCount : 0; @@ -1327,6 +1162,7 @@ public Int32 EBG_overlaySetShadeColor(Int32 overlayNdx, Byte r, Byte g, Byte b) for (Int32 i = 0; i < spriteCount; i++) spriteList[i + indexShift].transform.gameObject.GetComponent().material = material; } + if (dbug) Log.Message("EBG_overlaySetShadeColor " + overlayNdx + " | RGB:" + r + g + b); return 1; } @@ -1334,12 +1170,12 @@ public Int32 EBG_overlayMove(Int32 overlayNdx, Int16 dx, Int16 dy, Int16 dz) { BGOVERLAY_DEF bgOverlay = this.scene.overlayList[overlayNdx]; FieldMapInfo.fieldmapExtraOffset.UpdateOverlayOffset(this.mapName, overlayNdx, ref dz); - Int16 destX = (Int16)Mathf.Clamp(bgOverlay.orgX + dx, bgOverlay.minX, bgOverlay.maxX); - Int16 destY = (Int16)Mathf.Clamp(bgOverlay.orgY + dy, bgOverlay.minY, bgOverlay.maxY); + float destX = (float)Mathf.Clamp(bgOverlay.orgX + dx, bgOverlay.minX, bgOverlay.maxX); + float destY = (float)Mathf.Clamp(bgOverlay.orgY + dy, bgOverlay.minY, bgOverlay.maxY); // TODO Check Native: #147 UInt16 destZ; - if (FF9StateSystem.Common.FF9.fldMapNo == 2351 && overlayNdx >= 3 && overlayNdx <= 17) + if (FF9StateSystem.Common.FF9.fldMapNo == 2351 && overlayNdx >= 3 && overlayNdx <= 17) // official fix of the mine bucket destZ = 3000; else destZ = (UInt16)(bgOverlay.orgZ + (UInt16)dz); @@ -1351,17 +1187,19 @@ public Int32 EBG_overlayMove(Int32 overlayNdx, Int16 dx, Int16 dy, Int16 dz) bgOverlay.curY = destY; bgOverlay.curZ = destZ; bgOverlay.transform.localPosition = new Vector3(destX, destY, destZ); + if (dbug) Log.Message("EBG_overlayMove " + overlayNdx + " | destX:" + destX + " destY:" + destY + " destZ:" + destZ); return 1; } public Int32 EBG_overlaySetOrigin(Int32 overlayNdx, Int32 orgX, Int32 orgY) { BGOVERLAY_DEF bgOverlay = this.scene.overlayList[overlayNdx]; - bgOverlay.curX = (Int16)orgX; - bgOverlay.curY = (Int16)orgY; - bgOverlay.orgX = bgOverlay.curX; - bgOverlay.orgY = bgOverlay.curY; + bgOverlay.curX = (float)orgX; + bgOverlay.curY = (float)orgY; + bgOverlay.orgX = (float)orgX; + bgOverlay.orgY = (float)orgY; this.flags |= FieldMapFlags.Unknown128; + if (dbug) Log.Message("EBG_overlaySetOrigin " + overlayNdx + " | orgX:" + orgX + " orgY:" + orgY); return 1; } @@ -1369,11 +1207,17 @@ public Int32 EBG_overlaySetParallax(Int32 overlayNdx, UInt32 flag, Int32 dx, Int { BGOVERLAY_DEF bgOverlay = this.scene.overlayList[overlayNdx]; if (flag != 0u) + { + if (dbug) Log.Message("EBG_overlaySetParallax " + overlayNdx + " | + Parallax | dx:" + dx + " dy:" + dy); bgOverlay.flags |= BGOVERLAY_DEF.OVERLAY_FLAG.Parallax; + } else + { + if (dbug) Log.Message("EBG_overlaySetParallax " + overlayNdx + " | - Parallax | dx:" + dx + " dy:" + dy); bgOverlay.flags &= BGOVERLAY_DEF.OVERLAY_FLAG.Parallax; - bgOverlay.dX = (Int16)dx; - bgOverlay.dY = (Int16)dy; + } + bgOverlay.scrollX = (Int16)dx; + bgOverlay.scrollY = (Int16)dy; return 1; } @@ -1383,258 +1227,276 @@ public void UpdateOverlayAll() return; BGCAM_DEF bgCamera = this.scene.cameraList[this.curCamIdx]; Vector2 realVrp = new Vector2(); - realVrp[0] = this.curVRP[0] + bgCamera.centerOffset[0] + HalfFieldWidth; - realVrp[1] = this.curVRP[1] - bgCamera.centerOffset[1] + HalfFieldHeight; - this.scene.scrX = (Int16)(this.scene.curX + HalfFieldWidth - realVrp[0]); - this.scene.scrY = (Int16)(this.scene.curY + HalfFieldHeight - realVrp[1]); + realVrp.x = this.curVRP.x + bgCamera.centerOffset[0] + HalfFieldWidth; + realVrp.y = this.curVRP.y - bgCamera.centerOffset[1] + HalfFieldHeight; + this.scene.scrX = this.scene.curX + HalfFieldWidth - realVrp.x; + this.scene.scrY = this.scene.curY + HalfFieldHeight - realVrp.y; List overlayList = this.scene.overlayList; for (int i = 0; i < this.scene.overlayCount; i++) - this.UpdateOverlay(i, overlayList[i], realVrp); + { + try + { + this.UpdateOverlay(i, overlayList[i], realVrp); + } + catch (Exception e) + { + Log.Error(e); + } + } } - private void UpdateOverlay(Int32 ovrNdx, BGOVERLAY_DEF overlayPtr, Vector2 realVrp) + private void UpdateOverlay(Int32 ovrNdx, BGOVERLAY_DEF bgOverlay, Vector2 realVrp) { + //if (dbug && ovrNdx == 24) Log.Message("before: overlayPtr.curX:" + overlayPtr.curX); BGSCENE_DEF bgScene = this.scene; - ushort spriteCount = overlayPtr.spriteCount; - List spriteList = overlayPtr.spriteList; - short num = (short)(overlayPtr.curX + bgScene.scrX); - short num2 = (short)(overlayPtr.curY + bgScene.scrY); - short num3 = (short)(overlayPtr.curZ + (ushort)bgScene.curZ); - if ((overlayPtr.flags & BGOVERLAY_DEF.OVERLAY_FLAG.Loop) != 0) - { - short num4; - short num5; - if ((overlayPtr.flags & BGOVERLAY_DEF.OVERLAY_FLAG.ScreenAnchored) != 0) + ushort spriteCount = bgOverlay.spriteCount; + List spriteList = bgOverlay.spriteList; + float screenX = bgOverlay.curX + bgScene.scrX; + float screenY = bgOverlay.curY + bgScene.scrY; + if ((bgOverlay.flags & BGOVERLAY_DEF.OVERLAY_FLAG.Loop) != 0) + { + //if (dbug) Log.Message("UpdateOverlay | BGOVERLAY_DEF.OVERLAY_FLAG.Loop"); // example: scrolling sky 505 + float anchorX; + float anchorY; + if ((bgOverlay.flags & BGOVERLAY_DEF.OVERLAY_FLAG.ScreenAnchored) != 0) { - num4 = this.scrollWindowPos[(int)overlayPtr.viewportNdx][0]; - num5 = this.scrollWindowPos[(int)overlayPtr.viewportNdx][1]; + anchorX = this.scrollWindowPos[(int)bgOverlay.viewportNdx][0]; + anchorY = this.scrollWindowPos[(int)bgOverlay.viewportNdx][1]; + if (dbug) Log.Message("UpdateOverlay " + ovrNdx + " | Loop ScreenAnchored anchorX:" + anchorX + " anchorY:" + anchorY); } else { - num4 = (short)(HalfFieldWidth - realVrp[0] + (float)this.scrollWindowPos[(int)overlayPtr.viewportNdx][0]); - num5 = (short)(HalfFieldHeight - realVrp[1] + (float)this.scrollWindowPos[(int)overlayPtr.viewportNdx][1]); + anchorX = (float)(HalfFieldWidth - realVrp.x + this.scrollWindowPos[(int)bgOverlay.viewportNdx][0]); + anchorY = (float)(HalfFieldHeight - realVrp.y + this.scrollWindowPos[(int)bgOverlay.viewportNdx][1]); } - short num6 = this.scrollWindowDim[(int)overlayPtr.viewportNdx][0]; - short num7 = this.scrollWindowDim[(int)overlayPtr.viewportNdx][1]; - if (overlayPtr.dX < 0) + if (bgOverlay.scrollX != 0) { - short num8 = (short)(256 - (overlayPtr.dX << 8 >> 8)); - num = (short)((((int)overlayPtr.curX << 8 | (int)overlayPtr.fracX) + (int)num8 >> 8) + (int)bgScene.scrX); - } - if (overlayPtr.dY < 0) - { - short num9 = (short)(256 - (overlayPtr.dX << 8 >> 8)); - num2 = (short)((((int)overlayPtr.curY << 8 | (int)overlayPtr.fracY) + (int)num9 >> 8) + (int)bgScene.scrY); - } - if (overlayPtr.dX != 0) - { - num = (short)((num - (num6 - (short)overlayPtr.w)) % (short)overlayPtr.w + (num6 - (short)overlayPtr.w)); + if (bgOverlay.scrollX < 0) + { + short deltaX = (short)(256 - ((short)(bgOverlay.scrollX) << 8 >> 8)); + screenX = (float)((((int)bgOverlay.curX << 8) + (int)deltaX >> 8) + (int)bgScene.scrX); + } + screenX = (float)((screenX - (this.scrollWindowDim[(int)bgOverlay.viewportNdx][0] - (float)bgOverlay.w)) % (float)bgOverlay.w + (this.scrollWindowDim[(int)bgOverlay.viewportNdx][0] - (float)bgOverlay.w)); } - if (overlayPtr.dY != 0) + if (bgOverlay.scrollY != 0) { - num2 = (short)((num2 - (num7 - (short)overlayPtr.h)) % (short)overlayPtr.h + (num7 - (short)overlayPtr.h)); + if (bgOverlay.scrollY < 0) + { + short deltaY = (short)(256 - ((short)(bgOverlay.scrollX) << 8 >> 8)); + screenY = (float)((((int)bgOverlay.curY << 8) + (int)deltaY >> 8) + (int)bgScene.scrY); + } + screenY = (float)((screenY - (this.scrollWindowDim[(int)bgOverlay.viewportNdx][1] - (float)bgOverlay.h)) % (float)bgOverlay.h + (this.scrollWindowDim[(int)bgOverlay.viewportNdx][1] - (float)bgOverlay.h)); } - bool flag = this.mapName == "FBG_N18_GTRE_MAP360_GT_GRD_0"; - for (short num10 = 0; num10 < (short)spriteCount; num10 = (short)(num10 + 1)) + + for (short i = 0; i < spriteCount; i++) { - BGSPRITE_LOC_DEF bgsprite_LOC_DEF = spriteList[(int)num10]; - Vector3 cacheLocalPos = bgsprite_LOC_DEF.cacheLocalPos; - if ((overlayPtr.flags & BGOVERLAY_DEF.OVERLAY_FLAG.ScreenAnchored) != 0) + BGSPRITE_LOC_DEF bgSprite = spriteList[i]; + Vector3 cacheLocalPos = bgSprite.cacheLocalPos; + float anchoredX = screenX + bgSprite.offX; + float anchoredY = screenY + bgSprite.offY; + if ((bgOverlay.flags & BGOVERLAY_DEF.OVERLAY_FLAG.ScreenAnchored) != 0) { - short num11 = (short)(num + (short)bgsprite_LOC_DEF.offX); - if (overlayPtr.dX != 0) + //if (dbug) Log.Message("UpdateOverlay " + ovrNdx + " | ScreenAnchored"); // example: 507, 931, 951 + if (bgOverlay.scrollX != 0) // is moving on X axis { - if (num11 + 16 >= (short)overlayPtr.w) + if (anchoredX + 16f - SmoothCamDelta.x >= bgOverlay.w) { - num11 = (short)(num11 - (short)overlayPtr.w); + anchoredX -= bgOverlay.w; } - else if (num11 <= -16) + else if (anchoredX - SmoothCamDelta.x <= -16f) { - num11 = (short)(num11 + (short)overlayPtr.w); + anchoredX += bgOverlay.w; } } - short num12 = (short)(num2 + (short)bgsprite_LOC_DEF.offY); - if (overlayPtr.dY != 0) + if (bgOverlay.scrollY != 0) // is moving on Y axis { - if (num12 + 16 >= (short)overlayPtr.h) + if (anchoredY + 16f + SmoothCamDelta.y >= bgOverlay.h) { - num12 = (short)(num12 - (short)overlayPtr.h); + anchoredY -= bgOverlay.h; } - else if (num12 <= -16) + else if (anchoredY + SmoothCamDelta.y <= -16f) { - num12 = (short)(num12 + (short)overlayPtr.h); + anchoredY += bgOverlay.h; } } - cacheLocalPos.x = (float)(num11 + num4); - cacheLocalPos.y = (float)(num12 + num5); + cacheLocalPos.x = anchoredX + anchorX; + cacheLocalPos.y = anchoredY + anchorY; } else { - short num11 = (short)(num + (short)bgsprite_LOC_DEF.offX); - if (overlayPtr.dX != 0) + //if (dbug) Log.Message("UpdateOverlay " + ovrNdx + " | not enchored"); // example: 507, 931, 951 + if (bgOverlay.scrollX != 0) { - if (num11 + 16 >= (short)overlayPtr.w) + if (anchoredX + 16f >= bgOverlay.w) // - SmoothCamDelta.x { - num11 = (short)(num11 - (short)overlayPtr.w); + anchoredX -= bgOverlay.w; } - else if (num11 <= -16) + else if (anchoredX <= -16f) // + SmoothCamDelta.x) { - num11 = (short)(num11 + (short)overlayPtr.w); + anchoredX += bgOverlay.w; } - cacheLocalPos.x = (float)(num11 + num4); + cacheLocalPos.x = anchoredX + anchorX; } else { - cacheLocalPos.x = (float)num11; + cacheLocalPos.x = anchoredX; } - short num12 = (short)(num2 + (short)bgsprite_LOC_DEF.offY); - if (overlayPtr.dY != 0) + if (bgOverlay.scrollY != 0) { - if (num12 + 16 >= (short)overlayPtr.h) + if (anchoredY + 16f >= (short)bgOverlay.h) // - SmoothCamDelta.y { - num12 = (short)(num12 - (short)overlayPtr.h); + anchoredY -= bgOverlay.h; } - else if (num12 <= -16) + else if (anchoredY <= -16f) // + SmoothCamDelta.y) { - num12 = (short)(num12 + (short)overlayPtr.h); + anchoredY += bgOverlay.h; } - cacheLocalPos.y = (float)(num12 + num5); + cacheLocalPos.y = anchoredY + anchorY; } else { - cacheLocalPos.y = (float)num12; + cacheLocalPos.y = anchoredY; } } cacheLocalPos.y += 16f; - if (flag) - { + if (this.mapName == "FBG_N18_GTRE_MAP360_GT_GRD_0") // map 1000 cacheLocalPos.x += 8f; - } - cacheLocalPos.x -= (float)(this.scene.scrX + overlayPtr.curX); - cacheLocalPos.y -= (float)(this.scene.scrY + overlayPtr.curY); - bgsprite_LOC_DEF.cacheLocalPos = cacheLocalPos; - bgsprite_LOC_DEF.transform.localPosition = cacheLocalPos; + cacheLocalPos.x -= (this.scene.scrX + bgOverlay.curX); + cacheLocalPos.y -= (this.scene.scrY + bgOverlay.curY); + bgSprite.cacheLocalPos = cacheLocalPos; + bgSprite.transform.localPosition = cacheLocalPos; } - overlayPtr.transform.localPosition = new Vector3((float)overlayPtr.curX * 1f, (float)overlayPtr.curY * 1f, overlayPtr.transform.localPosition.z); + bgOverlay.transform.localPosition = new Vector3((float)bgOverlay.curX, (float)bgOverlay.curY, bgOverlay.transform.localPosition.z); } - else if ((overlayPtr.flags & BGOVERLAY_DEF.OVERLAY_FLAG.ScrollWithOffset) != 0) + else if ((bgOverlay.flags & BGOVERLAY_DEF.OVERLAY_FLAG.ScrollWithOffset) != 0) { - short num4; - short num5; - if ((overlayPtr.flags & BGOVERLAY_DEF.OVERLAY_FLAG.ScreenAnchored) != 0) + if (dbug) Log.Message("UpdateOverlay | BGOVERLAY_DEF.OVERLAY_FLAG.ScrollWithOffset - current map: " + FF9StateSystem.Common.FF9.fldMapNo); + float anchorX; + float anchorY; + if ((bgOverlay.flags & BGOVERLAY_DEF.OVERLAY_FLAG.ScreenAnchored) != 0) { - num4 = this.scrollWindowPos[(int)overlayPtr.viewportNdx][0]; - num5 = this.scrollWindowPos[(int)overlayPtr.viewportNdx][1]; + anchorX = this.scrollWindowPos[(int)bgOverlay.viewportNdx][0]; + anchorY = this.scrollWindowPos[(int)bgOverlay.viewportNdx][1]; + //if (dbug) Log.Message("UpdateOverlay | BGOVERLAY_DEF.OVERLAY_FLAG.ScrollWithOffset | anchorX:" + anchorX + " anchorY:" + anchorY); } else { - num4 = (short)(HalfFieldWidth - realVrp[0] + (float)this.scrollWindowPos[(int)overlayPtr.viewportNdx][0]); - num5 = (short)(HalfFieldHeight - realVrp[1] + (float)this.scrollWindowPos[(int)overlayPtr.viewportNdx][1]); + anchorX = HalfFieldWidth - realVrp.x + this.scrollWindowPos[(int)bgOverlay.viewportNdx][0]; + anchorY = HalfFieldHeight - realVrp.y + this.scrollWindowPos[(int)bgOverlay.viewportNdx][0]; } - short num6 = this.scrollWindowDim[(int)overlayPtr.viewportNdx][0]; - short num7 = this.scrollWindowDim[(int)overlayPtr.viewportNdx][1]; - if (overlayPtr.isXOffset != 0) + if (bgOverlay.isXOffset != 0) { - num2 = (short)((num2 - (num7 - (short)overlayPtr.h)) % (short)overlayPtr.h + (num7 - (short)overlayPtr.h)); - num = (short)(num + num2 * overlayPtr.dX / (short)overlayPtr.h % (short)overlayPtr.w); + screenY = (screenY - (this.scrollWindowDim[(int)bgOverlay.viewportNdx][1] - (short)bgOverlay.h)) % (short)bgOverlay.h + (this.scrollWindowDim[(int)bgOverlay.viewportNdx][1] - (short)bgOverlay.h); + screenX = screenX + screenY * bgOverlay.scrollX / (short)bgOverlay.h % (short)bgOverlay.w; } else { - num = (short)((num - (num6 - (short)overlayPtr.w)) % (short)overlayPtr.w + (num6 - (short)overlayPtr.w)); - num2 = (short)(num2 + num * overlayPtr.dY / (short)overlayPtr.w % (short)overlayPtr.h); + screenX = (screenX - (this.scrollWindowDim[(int)bgOverlay.viewportNdx][0] - (short)bgOverlay.w)) % (short)bgOverlay.w + (this.scrollWindowDim[(int)bgOverlay.viewportNdx][0] - (short)bgOverlay.w); + screenY = screenY + screenX * bgOverlay.scrollY / (short)bgOverlay.w % (short)bgOverlay.h; } - for (short num10 = 0; num10 < (short)spriteCount; num10 = (short)(num10 + 1)) + for (short i = 0; i < spriteCount; i++) { - BGSPRITE_LOC_DEF bgsprite_LOC_DEF2 = spriteList[(int)num10]; - Vector3 localPosition = bgsprite_LOC_DEF2.transform.localPosition; - if (overlayPtr.isXOffset != 0) + BGSPRITE_LOC_DEF bgSprite = spriteList[i]; + Vector3 localPosition = bgSprite.transform.localPosition; + if (bgOverlay.isXOffset != 0) { - short num13 = 0; - short num14 = (short)(num2 + (short)bgsprite_LOC_DEF2.offY); - if (num14 + 16 >= (short)overlayPtr.h) + float xOffset = 0; + float yOffset = screenY + bgSprite.offY; + if (yOffset + 16 >= (short)bgOverlay.h) { - num14 = (short)(num14 - (short)overlayPtr.h); - num13 = (short)(-overlayPtr.dX); + yOffset = yOffset - bgOverlay.h; + xOffset = -bgOverlay.scrollX; } - else if (num14 <= -16) + else if (yOffset <= -16) { - num14 = (short)(num14 + (short)overlayPtr.h); - num13 = overlayPtr.dX; + yOffset = yOffset + bgOverlay.h; + xOffset = bgOverlay.scrollX; } - short num15 = (short)(num + (short)bgsprite_LOC_DEF2.offX + num13); - localPosition.x = (float)num15; - localPosition.y = (float)(num14 + num5); + float xOffsetAdjusted = (screenX + (short)bgSprite.offX + xOffset); + localPosition.x = (float)xOffsetAdjusted; + localPosition.y = (float)(yOffset + anchorY); } else { - short num13 = 0; - short num15 = (short)(num + (short)bgsprite_LOC_DEF2.offX); - if (num15 + 16 >= (short)overlayPtr.w) + short xOffset = 0; + short xOffsetAdjusted = (short)(screenX + (short)bgSprite.offX); + if (xOffsetAdjusted + 16 >= (short)bgOverlay.w) { - num15 = (short)(num15 - (short)overlayPtr.w); - num13 = (short)(-overlayPtr.dY); + xOffsetAdjusted = (short)(xOffsetAdjusted - (short)bgOverlay.w); + xOffset = (short)(-bgOverlay.scrollY); } - else if (num15 <= -16) + else if (xOffsetAdjusted <= -16) { - num15 = (short)(num15 + (short)overlayPtr.w); - num13 = overlayPtr.dY; + xOffsetAdjusted = (short)(xOffsetAdjusted + (short)bgOverlay.w); + xOffset = (short)(bgOverlay.scrollY); } - short num14 = (short)(num2 + (short)bgsprite_LOC_DEF2.offY + num13); - localPosition.x = (float)(num15 + num4); - localPosition.y = (float)num14; + localPosition.x = (float)(xOffsetAdjusted + anchorX); + localPosition.y = screenY + (float)bgSprite.offY + xOffset; } localPosition.y += 16f; - localPosition.x -= (float)(this.scene.scrX + overlayPtr.curX); - localPosition.y -= (float)(this.scene.scrY + overlayPtr.curY); - bgsprite_LOC_DEF2.transform.localPosition = localPosition; + localPosition.x -= (this.scene.scrX + bgOverlay.curX); + localPosition.y -= (this.scene.scrY + bgOverlay.curY); + bgSprite.transform.localPosition = localPosition; } - overlayPtr.transform.localPosition = new Vector3((float)overlayPtr.curX * 1f, (float)overlayPtr.curY * 1f, overlayPtr.transform.localPosition.z); + bgOverlay.transform.localPosition = new Vector3((float)bgOverlay.curX * 1f, (float)bgOverlay.curY * 1f, bgOverlay.transform.localPosition.z); } else { - float num16; - float num17; - if ((overlayPtr.flags & BGOVERLAY_DEF.OVERLAY_FLAG.Parallax) != 0 && overlayPtr.isSpecialParallax) - { - num16 = overlayPtr.parallaxCurX; - num17 = overlayPtr.parallaxCurY; - } - else + bgOverlay.transform.localPosition = new Vector3(bgOverlay.curX, bgOverlay.curY, bgOverlay.transform.localPosition.z); + } + + //if (dbug && ovrNdx == 24) Log.Message("after: overlayPtr.curX:" + overlayPtr.curX); + bgOverlay.scrX = screenX; + bgOverlay.scrY = screenY; + + foreach (int[] entry in FixDepthOfLayer) + { + if (entry[0] == FF9StateSystem.Common.FF9.fldMapNo && entry[1] == this.camIdx && entry[2] == ovrNdx) { - num16 = (float)overlayPtr.curX; - num17 = (float)overlayPtr.curY; + bgOverlay.curZ = (ushort)entry[3]; + bgOverlay.transform.localPosition = new Vector3(bgOverlay.transform.localPosition.x, bgOverlay.transform.localPosition.y, entry[3]); } - overlayPtr.transform.localPosition = new Vector3(num16 * 1f, num17 * 1f, overlayPtr.transform.localPosition.z); } - overlayPtr.scrX = num; - overlayPtr.scrY = num2; } + public static readonly Int32[][] FixDepthOfLayer = + { + // [mapNo,camIdx,ovrNdx,Z], + [403,0,23,560], // Dali underground wall over box + [403,0,27,1523], // Dali underground barrel + [951,0,2,1214], // Gargan Roo's railing + [1000,0,12,0], // Clayra's Trunk text + [1652,1,5,911], // Iifa platform + [1656,0,3,998], // Iifa statue glow (was not active on PSX) + [2922,0,8,4329], // Crystal world (was not active on PSX) + [2922,0,10,3179], // Crystal world (was not active on PSX) + [2922,0,11,3179], // Crystal world (was not active on PSX) + [2922,0,12,6080], // Crystal world (was not active on PSX) + }; + public void EBG_scene2DScroll(Int16 destX, Int16 destY, UInt16 frameCount, UInt32 scrollType) { if (!IsActive) return; - this.startPoint[0] = (Int16)this.curVRP[0]; - this.startPoint[1] = (Int16)this.curVRP[1]; - BGCAM_DEF bgcam_DEF = this.scene.cameraList[this.curCamIdx]; + this.startPoint.x = this.curVRP.x; + this.startPoint.y = this.curVRP.y; + BGCAM_DEF bgCamera = this.scene.cameraList[this.curCamIdx]; if (Configuration.Graphics.WidescreenSupport) { - if (destX > bgcam_DEF.vrpMaxX) - destX = bgcam_DEF.vrpMaxX; - else if (destX < bgcam_DEF.vrpMinX) - destX = bgcam_DEF.vrpMinX; + destX = (Int16)Mathf.Clamp(destX, bgCamera.vrpMinX, bgCamera.vrpMaxX); } - this.endPoint[0] = destX; - this.endPoint[1] = destY; + this.endPoint.x = destX; + this.endPoint.y = destY; this.frameCount = (Int16)frameCount; this.curFrame = 1; this.flags &= ~FieldMapFlags.Generic15; if (scrollType == (UInt32)FieldMapFlags.RotationScroll) IsRotationScroll = true; this.flags |= FieldMapFlags.Unknown1; + if (dbug) Log.Message("EBG_scene2DScroll | X:" + startPoint.x + " -> " + endPoint.x + " | Y:" + startPoint.y + " -> " + endPoint.y + " | frameCount:" + frameCount + " scrollType:" + scrollType); } public void EBG_scene2DScrollRelease(Int32 frameCount, UInt32 scrollType) @@ -1642,9 +1504,9 @@ public void EBG_scene2DScrollRelease(Int32 frameCount, UInt32 scrollType) if (!IsActive) return; - BGCAM_DEF bgcam_DEF = this.scene.cameraList[this.curCamIdx]; - this.startPoint[0] = (Int16)this.curVRP[0]; - this.startPoint[1] = (Int16)this.curVRP[1]; + BGCAM_DEF bgCamera = this.scene.cameraList[this.curCamIdx]; + this.startPoint.x = (float)this.curVRP.x; + this.startPoint.y = (float)this.curVRP.y; Vector3 vertex = Vector3.zero; if (FF9StateSystem.Common.FF9.fldMapNo == 1656 && this.playerController == null) { @@ -1660,31 +1522,21 @@ public void EBG_scene2DScrollRelease(Int32 frameCount, UInt32 scrollType) this.playerController = ((Actor)PersistenSingleton.Instance.GetObjUID(2)).fieldMapActorController; } vertex = this.playerController.curPos; - vertex.y += (Single)this.charAimHeight; - vertex = PSX.CalculateGTE_RTPT(vertex, Matrix4x4.identity, bgcam_DEF.GetMatrixRT(), bgcam_DEF.GetViewDistance(), this.offset); + vertex.y += (float)this.charAimHeight; + vertex = PSX.CalculateGTE_RTPT(vertex, Matrix4x4.identity, bgCamera.GetMatrixRT(), bgCamera.GetViewDistance(), this.offset); } else { vertex.x += this.offset.x; vertex.y += this.offset.y; } - Single num = (Int32)vertex.x; - Single num2 = (Int32)vertex.y; - Single num3 = (bgcam_DEF.w >> 1) + bgcam_DEF.centerOffset[0] + (num - HalfFieldWidth); - Single num4 = (bgcam_DEF.h >> 1) + bgcam_DEF.centerOffset[1] + (num2 - HalfFieldHeight); - num3 -= this.offset.x - HalfFieldWidth; - num4 += this.offset.y - HalfFieldHeight; - num4 *= -1f; - if (num3 < bgcam_DEF.vrpMinX) - num3 = bgcam_DEF.vrpMinX; - else if (num3 > bgcam_DEF.vrpMaxX) - num3 = bgcam_DEF.vrpMaxX; - if (num4 < bgcam_DEF.vrpMinY) - num4 = bgcam_DEF.vrpMinY; - else if (num4 > bgcam_DEF.vrpMaxY) - num4 = bgcam_DEF.vrpMaxY; - this.endPoint[0] = (Int16)num3; - this.endPoint[1] = (Int16)num4; + float targetX = (bgCamera.w / 2) + bgCamera.centerOffset[0] + vertex.x - this.offset.x; + float targetY = -( (bgCamera.h / 2) + bgCamera.centerOffset[1] + vertex.y + this.offset.y - (2 * HalfFieldHeight) ); + targetX = Mathf.Clamp(targetX, bgCamera.vrpMinX, bgCamera.vrpMaxX); + targetY = Mathf.Clamp(targetY, bgCamera.vrpMinY, bgCamera.vrpMaxY); + this.endPoint.x = targetX; + this.endPoint.y = targetY; + if (frameCount == -1) this.frameCount = 30; else @@ -1696,9 +1548,11 @@ public void EBG_scene2DScrollRelease(Int32 frameCount, UInt32 scrollType) if (scrollType != UInt32.MaxValue) IsRotationScroll = scrollType == (UInt64)FieldMapFlags.RotationScroll; + + if (dbug) Log.Message("EBG_scene2DScrollRelease | targetX:" + targetX + " targetY:" + targetY); } - public Int32 EBG_animationService() + public Int32 BgAnimationService() { for (Int32 i = 0; i < this.scene.animList.Count; i++) { @@ -1759,19 +1613,20 @@ public Int32 EBG_animationService() } } } + //if (dbug) Log.Message("BgAnimationService"); return 1; } - private Int32 EBG_attachService() + private Int32 BgAttachService() { if (this.attachCount == 0) return 0; - BGCAM_DEF bgcam_DEF = this.scene.cameraList[this.camIdx]; - BGSCENE_DEF bgscene_DEF = this.scene; + BGCAM_DEF bgCamera = this.scene.cameraList[this.camIdx]; + BGSCENE_DEF bgScene = this.scene; List overlayList = this.scene.overlayList; Vector3 vertex = this.playerController.curPos; vertex.y += (Single)this.charAimHeight; - vertex = PSX.CalculateGTE_RTPT(vertex, Matrix4x4.identity, bgcam_DEF.GetMatrixRT(), bgcam_DEF.GetViewDistance(), this.offset); + vertex = PSX.CalculateGTE_RTPT(vertex, Matrix4x4.identity, bgCamera.GetMatrixRT(), bgCamera.GetViewDistance(), this.offset); vertex.y *= -1f; for (Byte i = 0; i < this.attachCount; i++) { @@ -1781,126 +1636,149 @@ private Int32 EBG_attachService() { Int16 x = ebg_ATTACH_DEF.x; Int16 y = ebg_ATTACH_DEF.y; - Int16 overlayX = overlayList[index].curX = (Int16)(vertex.x - bgscene_DEF.curX - x + bgcam_DEF.vrpMinX); - Int16 overlayY = overlayList[index].curY = (Int16)(vertex.y - bgscene_DEF.curY - y + bgcam_DEF.vrpMinY); - overlayList[index].transform.localPosition = new Vector3(overlayX, overlayY, 0f); + float overlayX = overlayList[index].curX = (Int16)(vertex.x - bgScene.curX - x + bgCamera.vrpMinX); + float overlayY = overlayList[index].curY = (Int16)(vertex.y - bgScene.curY - y + bgCamera.vrpMinY); + overlayList[index].transform.localPosition = new Vector3((short)overlayX, (short)overlayY, 0f); } } + if (dbug) Log.Message("BgAttachService | vertex.x:" + vertex.x + " vertex.y:" + vertex.y); return 1; } - public Int32 EBG_sceneServiceScroll(BGSCENE_DEF scenePtr) + public Int32 SceneServiceScroll(BGSCENE_DEF bgScene) { - Int32 overlayCount = (Int32)scenePtr.overlayCount; - List overlayList = scenePtr.overlayList; + Int16 map = FF9StateSystem.Common.FF9.fldMapNo; + Int32 overlayCount = (Int32)bgScene.overlayCount; + List overlayList = bgScene.overlayList; for (Int32 i = 0; i < overlayCount; i++) { - BGOVERLAY_DEF bgoverlay_DEF = overlayList[i]; - if ((bgoverlay_DEF.flags & BGOVERLAY_DEF.OVERLAY_FLAG.Loop) != 0) + BGOVERLAY_DEF bgOverlay = overlayList[i]; + if ((bgOverlay.flags & BGOVERLAY_DEF.OVERLAY_FLAG.Loop) != 0) { - if (bgoverlay_DEF.dX != 0 && bgoverlay_DEF.dX != 32767) + if (bgOverlay.scrollX != 0 && bgOverlay.scrollX != 32767) { - Int32 num = (Int32)(bgoverlay_DEF.curX - bgoverlay_DEF.orgX) << 8 | (Int32)(bgoverlay_DEF.fracX & 255); - num += (Int32)bgoverlay_DEF.dX; - bgoverlay_DEF.curX = (Int16)((num >> 8) % (Int32)bgoverlay_DEF.w + (Int32)bgoverlay_DEF.orgX); - bgoverlay_DEF.fracX = (Int16)(num & 255); + bgOverlay.curX = (bgOverlay.curX % (Int32)bgOverlay.w) + (bgOverlay.scrollX / 256f); } - if (bgoverlay_DEF.dY != 0 && bgoverlay_DEF.dY != 32767) + if (bgOverlay.scrollY != 0 && bgOverlay.scrollY != 32767) { - Int32 num = (Int32)(bgoverlay_DEF.curY - bgoverlay_DEF.orgY) << 8 | (Int32)(bgoverlay_DEF.fracY & 255); - num += (Int32)bgoverlay_DEF.dY; - bgoverlay_DEF.curY = (Int16)((num >> 8) % (Int32)bgoverlay_DEF.h + (Int32)bgoverlay_DEF.orgY); - bgoverlay_DEF.fracY = (Int16)(num & 255); + bgOverlay.curY = (bgOverlay.curY % (Int32)bgOverlay.h) + (bgOverlay.scrollY / 256f); + } + if (dbug) Log.Message("SceneServiceScroll " + i + " | Loop | curX:" + bgOverlay.curX + " / curY:" + bgOverlay.curY); + + if (Configuration.Graphics.InitializeWidescreenSupport()) + { + switch (map) + { + case 1651: // Iifa roots 1 + bgOverlay.curX = 200; break; + case 1758: // Iifa roots 2 + bgOverlay.curX = 200; bgOverlay.curY = 0; break; + } + } } - if ((bgoverlay_DEF.flags & BGOVERLAY_DEF.OVERLAY_FLAG.ScrollWithOffset) != 0) + if ((bgOverlay.flags & BGOVERLAY_DEF.OVERLAY_FLAG.ScrollWithOffset) != 0) // loop in diagonal (816) or loop + parallax (2904) { - if (bgoverlay_DEF.isXOffset != 0) + if (bgOverlay.isXOffset != 0) { - if (bgoverlay_DEF.dY != 32767) + if (bgOverlay.scrollY != 32767) { - Int32 num = (Int32)bgoverlay_DEF.curY << 8 | (Int32)(bgoverlay_DEF.fracY & 255); - num += (Int32)bgoverlay_DEF.dY; - bgoverlay_DEF.curY = (Int16)((num >> 8) % (Int32)bgoverlay_DEF.h); - bgoverlay_DEF.fracY = (Int16)(num & 255); + bgOverlay.curY = bgOverlay.curY % (Int32)bgOverlay.h + (bgOverlay.scrollY / 256f); } } - else if (bgoverlay_DEF.dX != 32767) + else if (bgOverlay.scrollX != 32767) { - Int32 num = (Int32)bgoverlay_DEF.curX << 8 | (Int32)(bgoverlay_DEF.fracX & 255); - num += (Int32)bgoverlay_DEF.dX; - bgoverlay_DEF.curX = (Int16)((num >> 8) % (Int32)bgoverlay_DEF.w); - bgoverlay_DEF.fracX = (Int16)(num & 255); + bgOverlay.curX = bgOverlay.curX % (Int32)bgOverlay.w + (bgOverlay.scrollX / 256f); } + if (dbug) Log.Message("SceneServiceScroll " + i + " | ScrollWithOffset | X:" + bgOverlay.curX + " Y:" + bgOverlay.curY); } - if ((bgoverlay_DEF.flags & BGOVERLAY_DEF.OVERLAY_FLAG.Parallax) != 0) + if ((bgOverlay.flags & BGOVERLAY_DEF.OVERLAY_FLAG.Parallax) != 0) { - Int32 num = (Int32)((Single)(bgoverlay_DEF.orgX << 8) + (this.curVRP[0] - this.parallaxOrg[0]) * (Single)bgoverlay_DEF.dX); - bgoverlay_DEF.curX = (Int16)(num >> 8); - bgoverlay_DEF.fracX = (Int16)(num & 255); - num = (Int32)((Single)(bgoverlay_DEF.orgY << 8) + (this.curVRP[1] - this.parallaxOrg[1]) * (Single)bgoverlay_DEF.dY); - bgoverlay_DEF.curY = (Int16)(num >> 8); - bgoverlay_DEF.fracY = (Int16)(num & 255); - if (FF9StateSystem.Common.FF9.fldMapNo == 1251 || FF9StateSystem.Common.FF9.fldMapNo == 150 || FF9StateSystem.Common.FF9.fldMapNo == 805 || FF9StateSystem.Common.FF9.fldMapNo == 808 || FF9StateSystem.Common.FF9.fldMapNo == 2953 || FF9StateSystem.Common.FF9.fldMapNo == 2952 || FF9StateSystem.Common.FF9.fldMapNo == 1009 || FF9StateSystem.Common.FF9.fldMapNo == 1108 || FF9StateSystem.Common.FF9.fldMapNo == 1758 || FF9StateSystem.Common.FF9.fldMapNo == 1651 || FF9StateSystem.Common.FF9.fldMapNo == 2851 || FF9StateSystem.Common.FF9.fldMapNo == 3100 || FF9StateSystem.Common.FF9.fldMapNo == 2720 || FF9StateSystem.Common.FF9.fldMapNo == 1908 || FF9StateSystem.Common.FF9.fldMapNo == 908) + bgOverlay.curX = bgOverlay.orgX + ((this.curVRP.x + SmoothCamDelta.x - this.parallaxOrg.x) * (bgOverlay.scrollX / 256f)); + bgOverlay.curY = bgOverlay.orgY + ((this.curVRP.y - SmoothCamDelta.y - this.parallaxOrg.y) * (bgOverlay.scrollY / 256f)); + + if (dbug) Log.Message("SceneServiceScroll " + i + " | Parallax | X:" + bgOverlay.curX + " Y:" + bgOverlay.curY + " SmoothCamDelta.x " + SmoothCamDelta.x); + + if (Configuration.Graphics.InitializeWidescreenSupport()) { - bgoverlay_DEF.isSpecialParallax = true; - Single num2 = (Single)(bgoverlay_DEF.orgX * 256) + (this.curVRP[0] - this.parallaxOrg[0]) * (Single)bgoverlay_DEF.dX; - bgoverlay_DEF.parallaxCurX = num2 / 256f; - bgoverlay_DEF.fracX = (Int16)((Int32)num2 & 255); - num2 = (Single)(bgoverlay_DEF.orgY * 256) + (this.curVRP[1] - this.parallaxOrg[1]) * (Single)bgoverlay_DEF.dY; - bgoverlay_DEF.parallaxCurY = num2 / 256f; - bgoverlay_DEF.fracY = (Int16)((Int32)num2 & 255); + switch (map) + { + case 1651: // Iifa roots 1 + bgOverlay.transform.localScale = new Vector3(1.1f, 1.1f, 1f); bgOverlay.curX = -8; break; + case 1657: + bgOverlay.curX = this.mainCamera.transform.localPosition.x * (bgOverlay.scrollX / 256f) - (float)0.25; break; + case 1758: // Iifa roots 2 + bgOverlay.transform.localScale = new Vector3(1.1f, 1.1f, 1f); bgOverlay.curX = -8; break; + case 2600: // 464/416 + bgOverlay.transform.localScale = new Vector3(1.12f, 1.12f, 1f); bgOverlay.curX -= 24; break; + case 2602: // 384/328 + bgOverlay.transform.localScale = new Vector3(1.05f, 1.05f, 1f); bgOverlay.curX = 28; break; + case 2605: // 400/368 + bgOverlay.transform.localScale = new Vector3(1.1f, 1.1f, 1f); bgOverlay.curX -= 16; break; + case 2606: + bgOverlay.curX = this.mainCamera.transform.localPosition.x * (bgOverlay.scrollX / 256f); break; + case 2607: // 416/400 + bgOverlay.transform.localScale = new Vector3(1.05f, 1.05f, 1f); bgOverlay.curX -= 8; bgOverlay.curY -= 8; break; + case 2651: + bgOverlay.transform.localScale = new Vector3(1.2f, 1.2f, 1f); bgOverlay.curX -= 56; bgOverlay.curY -= 16; break; + case 2660: // 536/528 + bgOverlay.transform.localScale = new Vector3(1.02f, 1.02f, 1f); bgOverlay.curX -= 8; break; + } } } } if ((this.flags & FieldMapFlags.Unknown128) != 0u) { - this.orgVRP[0] = this.curVRP[0]; - this.orgVRP[1] = this.curVRP[1]; + this.orgVRP.x = this.curVRP.x; + this.orgVRP.y = this.curVRP.y; this.flags &= FieldMapFlags.Generic127; } return 1; } - public void EBG_sceneService2DScroll() + public void SceneService2DScroll() { if (!IsActive) return; - FieldMapFlags fl = this.flags & FieldMapFlags.Generic7; - if (fl == 0 || fl >= FieldMapFlags.Unknown4) + FieldMapFlags flags = this.flags & FieldMapFlags.Generic7; + if (flags == 0 || flags >= FieldMapFlags.Unknown4) return; Int16 currentFrame = this.curFrame; Int16 totalFrames = this.frameCount; - BGCAM_DEF currentCamera = this.scene.cameraList[this.curCamIdx]; - Int16 aimX = (Int16)(this.endPoint.x - currentCamera.centerOffset[0] - HalfFieldWidth - this.startPoint.x); - Int16 aimY = (Int16)(this.endPoint.y + currentCamera.centerOffset[1] - HalfFieldHeight - this.startPoint.y); - Single viewportX = this.curVRP.x; - Single viewportY = this.curVRP.y; + BGCAM_DEF bgCamera = this.scene.cameraList[this.curCamIdx]; + float aimX = (float)(this.endPoint.x - bgCamera.centerOffset[0] - HalfFieldWidth - this.startPoint.x); + float aimY = (float)(this.endPoint.y + bgCamera.centerOffset[1] - HalfFieldHeight - this.startPoint.y); + float viewportX = this.curVRP.x; + float viewportY = this.curVRP.y; + if (IsRotationScroll) { - Int32 fixedPointAngle = 2048 * currentFrame / totalFrames + 2048; + Int32 fixedPointAngle = (2048 * currentFrame / totalFrames) + 2048; Int32 rcos = ff9.rcos(fixedPointAngle) + 4096; - Int32 rotX = aimX * rcos / 8192; - Int32 rotY = aimY * rcos / 8192; - this.curVRP[0] = this.startPoint[0] + rotX; - this.curVRP[1] = this.startPoint[1] + rotY; + float rotX = aimX * rcos / 8192; + float rotY = aimY * rcos / 8192; + this.curVRP.x = (float)(this.startPoint.x + rotX); + this.curVRP.y = (float)(this.startPoint.y + rotY); + //if (dbug) Log.Message("SceneService2DScroll(IsRotationScroll) | this.curVRP.x:" + this.curVRP.x + " this.curVRP.y:" + this.curVRP.y); } else { - this.curVRP[0] = this.startPoint[0] + aimX * currentFrame / (Single)totalFrames; - this.curVRP[1] = this.startPoint[1] + aimY * currentFrame / (Single)totalFrames; + this.curVRP.x = this.startPoint.x + aimX * currentFrame / totalFrames; + this.curVRP.y = this.startPoint.y + aimY * currentFrame / totalFrames; + //if (dbug) Log.Message("SceneService2DScroll | this.curVRP.x:" + this.curVRP.x + " this.curVRP.y:" + this.curVRP.y); } - viewportX = this.curVRP[0] - viewportX; - viewportY = this.curVRP[1] - viewportY; + viewportX = this.curVRP.x - viewportX; + viewportY = this.curVRP.y - viewportY; + //if (dbug) Log.Message("SceneService2DScroll | viewportX:" + viewportX + " viewportY:" + viewportY); - UpdateOverlayXY((Int16)viewportX, (Int16)viewportY); + UpdateOverlayXY(viewportX, viewportY); - this.charOffset = new Vector2(this.curVRP[0], this.curVRP[1]); + this.charOffset = new Vector2(this.curVRP.x, this.curVRP.y); - if (fl == FieldMapFlags.Unknown1) + if (flags == FieldMapFlags.Unknown1) { this.flags &= ~FieldMapFlags.Unknown1; this.flags |= FieldMapFlags.Unknown2; @@ -1921,50 +1799,96 @@ public void EBG_sceneService2DScroll() } } - private void UpdateOverlayXY(Int16 dx, Int16 dy) + private void UpdateOverlayXY(float dx, float dy) { - for (Int32 overlayIndex = 0; overlayIndex < this.scene.overlayCount; overlayIndex++) + for (Int32 overlayNdx = 0; overlayNdx < this.scene.overlayCount; overlayNdx++) { - BGOVERLAY_DEF overlay = this.scene.overlayList[overlayIndex]; - if ((overlay.flags & BGOVERLAY_DEF.OVERLAY_FLAG.Loop) != 0) - { - if (overlay.dX != 0) - overlay.curX = (Int16)(overlay.curX + dx); - if (overlay.dY != 0) - overlay.curY = (Int16)(overlay.curY + dy); + BGOVERLAY_DEF bgOverlay = this.scene.overlayList[overlayNdx]; - this.EBG_alphaScaleX(overlay, dx); - this.EBG_alphaScaleY(overlay, dy); + if ((bgOverlay.flags & BGOVERLAY_DEF.OVERLAY_FLAG.Loop) != 0) + { + if (bgOverlay.scrollX != 0) + bgOverlay.curX += dx; + if (bgOverlay.scrollY != 0) + bgOverlay.curY += dy; + if (dbug) Log.Message("UpdateOverlayXY " + overlayNdx + " | Loop | dx:" + dx + " scrollX:" + bgOverlay.scrollX + " curX:" + bgOverlay.curX + " scrollY:" + bgOverlay.scrollY + " curY:" + bgOverlay.curY); + this.alphaScaleX(bgOverlay, dx); + this.alphaScaleY(bgOverlay, dy); } - else if ((overlay.flags & BGOVERLAY_DEF.OVERLAY_FLAG.ScrollWithOffset) != 0) + else if ((bgOverlay.flags & BGOVERLAY_DEF.OVERLAY_FLAG.ScrollWithOffset) != 0) { - if (overlay.isXOffset != 0) - overlay.curY = (Int16)(overlay.curY + dy); + if (bgOverlay.isXOffset != 0) + bgOverlay.curY += dy; else - overlay.curX = (Int16)(overlay.curX + dx); - - this.EBG_alphaScaleX(overlay, dx); - this.EBG_alphaScaleY(overlay, dy); + bgOverlay.curX += dx; + if (dbug) Log.Message("UpdateOverlayXY " + overlayNdx + " | dx:" + dx + " ScrollWithOffset | curX:" + bgOverlay.curX + " curY:" + bgOverlay.curY); + this.alphaScaleX(bgOverlay, dx); + this.alphaScaleY(bgOverlay, dy); } } } - private void EBG_sceneService3DScroll() + public float alphaScaleX(BGOVERLAY_DEF bgOverlay, float dx) + { + float scaledValue = dx * 65536; + float ScaleFactor = (float)this.scrollWindowAlphaX[(Int32)bgOverlay.viewportNdx] * 256; + if (ScaleFactor == 65536) + { + return bgOverlay.curX; + } + scaledValue = (bgOverlay.curX * 65536) - scaledValue * Math3D.Fixed2Float((int)Math.Abs(ScaleFactor)); + bgOverlay.curX = scaledValue / 65536; + if (dbug) Log.Message("EBG_alphaScaleX | scaledValue:" + scaledValue + " ScaleFactor:" + ScaleFactor + " curX:" + bgOverlay.curX); + return bgOverlay.curX; + } + + public float alphaScaleY(BGOVERLAY_DEF bgOverlay, float dy) + { + float scaledValue = dy * 65536; + float ScaleFactor = (float)this.scrollWindowAlphaY[(Int32)bgOverlay.viewportNdx] * 256; + if (ScaleFactor == 65536) + { + return bgOverlay.curY; + } + scaledValue = (bgOverlay.curY * 65536) - Math3D.Float2Fixed(Math3D.Fixed2Float((int)scaledValue) * Math3D.Fixed2Float((int)Math.Abs(ScaleFactor))); + bgOverlay.curY = scaledValue / 65536; + if (dbug) Log.Message("EBG_alphaScaleY | scaledValue:" + scaledValue + " ScaleFactor:" + ScaleFactor + " curY:" + bgOverlay.curY); + return bgOverlay.curY; + } + + private void SceneService3DScroll() { - if (!IsScene3dScrollAllowed()) + Int16 map = FF9StateSystem.Common.FF9.fldMapNo; + + if ((this.flags & FieldMapFlags.Generic7) != 0u || !this.IsActive || map == 70 || this.curCamIdx < 0 || this.curCamIdx > this.scene.cameraList.Count) return; - CrutchForIpsenMap(); // EVT_IPSEN_IP_CNT_2 - CrutchForEvaMap(); // EVT_EVA1_IF_PTS_1 + if (map == 2512 && this.playerController == null) // CrutchForIpsenMap EVT_IPSEN_IP_CNT_2 + { + this.playerController = ((Actor)PersistenSingleton.Instance.GetObjUID(2)).fieldMapActorController; + if (dbug) Log.Message("SceneService3DScroll | CrutchForIpsenMap"); + } + + if (map == 1656) // CrutchForEvaMap EVT_EVA1_IF_PTS_1 + { + Int32 isNeedOffset = PersistenSingleton.Instance.eBin.getVarManually(7385); + if (isNeedOffset == 1) + { + this.playerController = null; + this.extraOffset.x = -16f; + this.extraOffset.y = -8f; + if (dbug) Log.Message("SceneService3DScroll | CrutchForEvaMap | isNeedOffset"); + } + } Vector3 prevScrOffset = Vector3.zero; - BGCAM_DEF currentCamera = this.scene.cameraList[this.curCamIdx]; + BGCAM_DEF bgCamera = this.scene.cameraList[this.curCamIdx]; if (this.playerController != null) { prevScrOffset = this.playerController.curPos; prevScrOffset.y += this.charAimHeight; - prevScrOffset = PSX.CalculateGTE_RTPT(prevScrOffset, Matrix4x4.identity, currentCamera.GetMatrixRT(), currentCamera.GetViewDistance(), this.offset); + prevScrOffset = PSX.CalculateGTE_RTPT(prevScrOffset, Matrix4x4.identity, bgCamera.GetMatrixRT(), bgCamera.GetViewDistance(), this.offset); } else { @@ -1973,165 +1897,37 @@ private void EBG_sceneService3DScroll() } this.prevScr = prevScrOffset; - Single aimX = (currentCamera.w >> 1) + currentCamera.centerOffset[0] + prevScrOffset.x - HalfFieldWidth; - Single aimY = (currentCamera.h >> 1) + currentCamera.centerOffset[1] + prevScrOffset.y - HalfFieldHeight; - Single prevScrX = prevScrOffset.x; - Single prevScrY = prevScrOffset.y; + float aimX = (bgCamera.w >> 1) + bgCamera.centerOffset[0] + prevScrOffset.x - HalfFieldWidth; + float aimY = (bgCamera.h >> 1) + bgCamera.centerOffset[1] + prevScrOffset.y - HalfFieldHeight; + float prevScrX = prevScrOffset.x; + float prevScrY = prevScrOffset.y; aimX -= this.offset.x - HalfFieldWidth; aimY += this.offset.y - HalfFieldHeight; aimY *= -1f; - if (aimX < currentCamera.vrpMinX) - prevScrX = this.offset.x - (currentCamera.w >> 1) - currentCamera.centerOffset[0] + currentCamera.vrpMinX; - else if (aimX > currentCamera.vrpMaxX) - prevScrX = this.offset.x - (currentCamera.w >> 1) - currentCamera.centerOffset[0] + currentCamera.vrpMaxX; - - if (aimY < currentCamera.vrpMinY) - prevScrY = this.offset.y + (currentCamera.h >> 1) + currentCamera.centerOffset[1] - currentCamera.vrpMinY; - else if (aimY > currentCamera.vrpMaxY) - prevScrY = this.offset.y + (currentCamera.h >> 1) + currentCamera.centerOffset[1] - currentCamera.vrpMaxY; - - this.charOffset.x = prevScrX - currentCamera.centerOffset[0]; - this.charOffset.y = -(prevScrY - currentCamera.centerOffset[1]); - - Int16 dx, dy; - this.EBG_lookAtPoint(currentCamera, aimX, aimY, out dx, out dy); - - UpdateOverlayXY(dx, dy); - } - - private void CrutchForEvaMap() - { - const Int32 evaMapIndex = 1656; //EVT_EVA1_IF_PTS_1 - - if (FF9StateSystem.Common.FF9.fldMapNo != evaMapIndex) - return; - - Int32 isNeedOffset = PersistenSingleton.Instance.eBin.getVarManually(7385); - if (isNeedOffset == 1) - { - this.playerController = null; - this.extraOffset.x = -16f; - this.extraOffset.y = -8f; - } - } - - private void CrutchForIpsenMap() - { - const Int32 ipsenMapIndex = 2512; // EVT_IPSEN_IP_CNT_2 - - if (FF9StateSystem.Common.FF9.fldMapNo == ipsenMapIndex && this.playerController == null) - { - this.playerController = ((Actor)PersistenSingleton.Instance.GetObjUID(2)).fieldMapActorController; - } - } - - private Boolean IsScene3dScrollAllowed() - { - if ((this.flags & FieldMapFlags.Generic7) != 0u) - return false; - if (!IsActive) - return false; - if (FF9StateSystem.Common.FF9.fldMapNo == 70) // Opening-For FMV - return false; - if (this.curCamIdx < 0 || this.curCamIdx > this.scene.cameraList.Count) - return false; + if (aimX < bgCamera.vrpMinX) + prevScrX = this.offset.x - (bgCamera.w >> 1) - bgCamera.centerOffset[0] + bgCamera.vrpMinX; + else if (aimX > bgCamera.vrpMaxX) + prevScrX = this.offset.x - (bgCamera.w >> 1) - bgCamera.centerOffset[0] + bgCamera.vrpMaxX; - return true; - } + if (aimY < bgCamera.vrpMinY) + prevScrY = this.offset.y + (bgCamera.h >> 1) + bgCamera.centerOffset[1] - bgCamera.vrpMinY; + else if (aimY > bgCamera.vrpMaxY) + prevScrY = this.offset.y + (bgCamera.h >> 1) + bgCamera.centerOffset[1] - bgCamera.vrpMaxY; - public static Int32 f1616_mul(Int32 a, Int32 b) - { - return Math3D.Float2Fixed(Math3D.Fixed2Float(a) * Math3D.Fixed2Float(b)); - } + this.charOffset.x = prevScrX - bgCamera.centerOffset[0]; + this.charOffset.y = -(prevScrY - bgCamera.centerOffset[1]); - public Int16 EBG_alphaScaleX(BGOVERLAY_DEF oPtr, Int16 val) - { - Int32 num = (Int32)val << 16; - Int32 num2 = (Int32)this.scrollWindowAlphaX[(Int32)oPtr.viewportNdx] << 8; - if (num2 == 65536) - { - return oPtr.curX; - } - if (num2 < 0) - { - num2 = -num2; - num = ((Int32)oPtr.curX << 16) - FieldMap.f1616_mul(num, num2); - oPtr.curX = (Int16)(num >> 16); - oPtr.fracX = (Int16)(num >> 8 & 255); - } - else - { - num = ((Int32)oPtr.curX << 16) + FieldMap.f1616_mul(num, num2); - oPtr.curX = (Int16)(num >> 16); - oPtr.fracX = (Int16)(num >> 8 & 255); - } - return oPtr.curX; - } - public Int16 EBG_alphaScaleY(BGOVERLAY_DEF oPtr, Int16 val) - { - Int32 num = (Int32)val << 16; - Int32 num2 = (Int32)this.scrollWindowAlphaY[(Int32)oPtr.viewportNdx] << 8; - if (num2 == 65536) - { - return oPtr.curY; - } - if (num2 < 0) - { - num2 = -num2; - num = ((Int32)oPtr.curY << 16) - FieldMap.f1616_mul(num, num2); - oPtr.curY = (Int16)(num >> 16); - oPtr.fracY = (Int16)(num >> 8 & 255); - } - else - { - num = ((Int32)oPtr.curY << 16) + FieldMap.f1616_mul(num, num2); - oPtr.curY = (Int16)(num >> 16); - oPtr.fracY = (Int16)(num >> 8 & 255); - } - return oPtr.curY; - } + float prevVRPx = this.curVRP.x; + float prevVRPy = this.curVRP.y; + this.curVRP.x = Mathf.Clamp(aimX, bgCamera.vrpMinX, bgCamera.vrpMaxX) - bgCamera.centerOffset[0] - HalfFieldWidth; + this.curVRP.y = Mathf.Clamp(aimY, bgCamera.vrpMinY, bgCamera.vrpMaxY) + bgCamera.centerOffset[1] - HalfFieldHeight; + float dx = this.curVRP.x - prevVRPx; + float dy = this.curVRP.y - prevVRPy; + if (dbug) Log.Message("SceneService3DScroll | dx:" + dx + " dy:" + dy + " curVRP.x:" + this.curVRP.x + " curVRP.y:" + this.curVRP.y); - public Int32 EBG_lookAtPoint(BGCAM_DEF camPtr, Single aimX, Single aimY, out Int16 dX, out Int16 dY) - { - if (!IsActive) - { - dX = 0; - dY = 0; - return 1; - } - Single x = this.curVRP.x; - Single y = this.curVRP.y; - if (aimX < (Single)camPtr.vrpMinX) - { - this.curVRP[0] = (Single)camPtr.vrpMinX; - } - else if (aimX > (Single)camPtr.vrpMaxX) - { - this.curVRP[0] = (Single)camPtr.vrpMaxX; - } - else - { - this.curVRP[0] = aimX; - } - if (aimY < (Single)camPtr.vrpMinY) - { - this.curVRP[1] = (Single)camPtr.vrpMinY; - } - else if (aimY > (Single)camPtr.vrpMaxY) - { - this.curVRP[1] = (Single)camPtr.vrpMaxY; - } - else - { - this.curVRP[1] = aimY; - } - this.curVRP[0] = this.curVRP[0] - (Single)camPtr.centerOffset[0] - HalfFieldWidth; - this.curVRP[1] = this.curVRP[1] + (Single)camPtr.centerOffset[1] - HalfFieldHeight; - dX = (Int16)(this.curVRP.x - x); - dY = (Int16)(this.curVRP.y - y); - return 1; + UpdateOverlayXY(dx, dy); } public void EBG_char3DScrollSetActive(UInt32 isActive, Int32 frameCount, UInt32 scrollType) @@ -2155,19 +1951,20 @@ public void EBG_charLookAtUnlock() if (!IsLocked) return; - BGSCENE_DEF bgscene_DEF = this.scene; - if (bgscene_DEF != null) - { - BGCAM_DEF bgcam_DEF = this.scene.cameraList[this.curCamIdx]; - this.origVRPMinX = bgcam_DEF.vrpMinX; - this.origVRPMaxX = bgcam_DEF.vrpMaxX; - this.origVRPMinY = bgcam_DEF.vrpMinY; - this.origVRPMaxY = bgcam_DEF.vrpMaxY; - bgcam_DEF.vrpMinX = (Int16)this.SHRT_MIN; - bgcam_DEF.vrpMaxX = (Int16)this.SHRT_MAX; - bgcam_DEF.vrpMinY = (Int16)this.SHRT_MIN; - bgcam_DEF.vrpMaxY = (Int16)this.SHRT_MAX; + BGSCENE_DEF bgScene = this.scene; + if (bgScene != null) + { + BGCAM_DEF bgCamera = this.scene.cameraList[this.curCamIdx]; + this.origVRPMinX = bgCamera.vrpMinX; + this.origVRPMaxX = bgCamera.vrpMaxX; + this.origVRPMinY = bgCamera.vrpMinY; + this.origVRPMaxY = bgCamera.vrpMaxY; + bgCamera.vrpMinX = (Int16)this.SHRT_MIN; + bgCamera.vrpMaxX = (Int16)this.SHRT_MAX; + bgCamera.vrpMinY = (Int16)this.SHRT_MIN; + bgCamera.vrpMaxY = (Int16)this.SHRT_MAX; IsLocked = false; + //if (dbug) Log.Message("EBG_charLookAtUnlock bgCamera.vrpMinX " + bgCamera.vrpMinX + " bgCamera.vrpMaxX " + bgCamera.vrpMaxX); } } @@ -2176,15 +1973,16 @@ public void EBG_charLookAtLock() if (IsLocked) return; - BGSCENE_DEF bgscene_DEF = this.scene; - if (bgscene_DEF != null) + BGSCENE_DEF bgScene = this.scene; + if (bgScene != null) { - BGCAM_DEF bgcam_DEF = this.scene.cameraList[this.curCamIdx]; - bgcam_DEF.vrpMinX = this.origVRPMinX; - bgcam_DEF.vrpMaxX = this.origVRPMaxX; - bgcam_DEF.vrpMinY = this.origVRPMinY; - bgcam_DEF.vrpMaxY = this.origVRPMaxY; + BGCAM_DEF bgCamera = this.scene.cameraList[this.curCamIdx]; + bgCamera.vrpMinX = this.origVRPMinX; + bgCamera.vrpMaxX = this.origVRPMaxX; + bgCamera.vrpMinY = this.origVRPMinY; + bgCamera.vrpMaxY = this.origVRPMaxY; IsLocked = true; + //if (dbug) Log.Message("EBG_charLookAtLock bgCamera.vrpMinX " + bgCamera.vrpMinX + " bgCamera.vrpMaxX " + bgCamera.vrpMaxX); } } @@ -2276,722 +2074,97 @@ public void EBG_charLookAtLock() private static readonly Dictionary combineMeshDict = new Dictionary { - { - 351, - (FieldMap.EbgCombineMeshData)null - }, - { - 358, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 13, - 14 - } - } - }, - { - 450, - (FieldMap.EbgCombineMeshData)null - }, - { - 407, - (FieldMap.EbgCombineMeshData)null - }, - { - 55, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 5 - } - } - }, - { - 57, - (FieldMap.EbgCombineMeshData)null - }, - { - 60, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 15, - 16 - } - } - }, - { - 111, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 10 - } - } - }, - { - 153, - (FieldMap.EbgCombineMeshData)null - }, - { - 154, - (FieldMap.EbgCombineMeshData)null - }, - { - 307, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 6, - 8 - } - } - }, - { - 308, - (FieldMap.EbgCombineMeshData)null - }, - { - 309, - (FieldMap.EbgCombineMeshData)null - }, - { - 507, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 8, - 9, - 10 - } - } - }, - { - 551, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 13 - } - } - }, - { - 556, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 27 - } - } - }, - { - 566, - (FieldMap.EbgCombineMeshData)null - }, - { - 576, - (FieldMap.EbgCombineMeshData)null - }, - { - 603, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 35 - } - } - }, - { - 612, - (FieldMap.EbgCombineMeshData)null - }, - { - 662, - (FieldMap.EbgCombineMeshData)null - }, - { - 705, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 25 - } - } - }, - { - 706, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 13 - } - } - }, - { - 707, - (FieldMap.EbgCombineMeshData)null - }, - { - 751, - (FieldMap.EbgCombineMeshData)null - }, - { - 755, - (FieldMap.EbgCombineMeshData)null - }, - { - 766, - (FieldMap.EbgCombineMeshData)null - }, - { - 802, - (FieldMap.EbgCombineMeshData)null - }, - { - 810, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 6, - 7 - } - } - }, - { - 815, - (FieldMap.EbgCombineMeshData)null - }, - { - 910, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 12, - 13, - 14, - 15, - 16, - 17, - 19 - } - } - }, - { - 1910, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 12, - 13, - 14, - 15, - 16, - 17, - 19 - } - } - }, - { - 916, - (FieldMap.EbgCombineMeshData)null - }, - { - 951, - (FieldMap.EbgCombineMeshData)null - }, - { - 952, - (FieldMap.EbgCombineMeshData)null - }, - { - 957, - (FieldMap.EbgCombineMeshData)null - }, - { - 1056, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 19, - 24 - } - } - }, - { - 1106, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 19, - 24 - } - } - }, - { - 1153, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 6, - 7 - } - } - }, - { - 1206, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 5, - 6, - 7, - 8, - 9, - 10, - 11 - } - } - }, - { - 1207, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 7, - 8 - } - } - }, - { - 1214, - (FieldMap.EbgCombineMeshData)null - }, - { - 1215, - (FieldMap.EbgCombineMeshData)null - }, - { - 1222, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 21, - 22, - 23, - 24, - 25 - } - } - }, - { - 1223, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 5, - 6, - 7, - 8, - 9, - 10, - 11 - } - } - }, - { - 1301, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 13 - } - } - }, - { - 1307, - (FieldMap.EbgCombineMeshData)null - }, - { - 1312, - (FieldMap.EbgCombineMeshData)null - }, - { - 1355, - (FieldMap.EbgCombineMeshData)null - }, - { - 1362, - (FieldMap.EbgCombineMeshData)null - }, - { - 1455, - (FieldMap.EbgCombineMeshData)null - }, - { - 3054, - (FieldMap.EbgCombineMeshData)null - }, - { - 1505, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 0, - 8, - 13 - } - } - }, - { - 1950, - (FieldMap.EbgCombineMeshData)null - }, - { - 1225, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 5, - 6, - 7, - 8, - 9, - 10, - 11 - } - } - }, - { - 1801, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 5, - 6, - 7, - 8, - 9, - 10, - 11 - } - } - }, - { - 1802, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 7, - 8 - } - } - }, - { - 3002, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 7, - 8 - } - } - }, - { - 1806, - (FieldMap.EbgCombineMeshData)null - }, - { - 1807, - (FieldMap.EbgCombineMeshData)null - }, - { - 1814, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 21, - 22, - 23, - 24, - 25 - } - } - }, - { - 1816, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 15, - 16, - 17, - 18, - 19 - } - } - }, - { - 1823, - (FieldMap.EbgCombineMeshData)null - }, - { - 1852, - (FieldMap.EbgCombineMeshData)null - }, - { - 1860, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 10 - } - } - }, - { - 1865, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 17, - 18, - 20 - } - } - }, - { - 2000, - (FieldMap.EbgCombineMeshData)null - }, - { - 2001, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 7, - 8 - } - } - }, - { - 2101, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 13 - } - } - }, - { - 565, - (FieldMap.EbgCombineMeshData)null - }, - { - 2112, - (FieldMap.EbgCombineMeshData)null - }, - { - 605, - (FieldMap.EbgCombineMeshData)null - }, - { - 2155, - (FieldMap.EbgCombineMeshData)null - }, - { - 2162, - (FieldMap.EbgCombineMeshData)null - }, - { - 2200, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 21, - 22, - 23, - 24, - 25 - } - } - }, - { - 2217, - (FieldMap.EbgCombineMeshData)null - }, - { - 2220, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 4, - 5, - 6, - 7 - } - } - }, - { - 2221, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 2, - 4, - 5, - 26, - 29 - } - } - }, - { - 2404, - (FieldMap.EbgCombineMeshData)null - }, - { - 2453, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 1 - } - } - }, - { - 2853, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15 - } - } - }, - { - 2502, - (FieldMap.EbgCombineMeshData)null - }, - { - 2506, - (FieldMap.EbgCombineMeshData)null - }, - { - 2509, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 2, - 3 - } - } - }, - { - 2652, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 4 - } - } - }, - { - 2906, - (FieldMap.EbgCombineMeshData)null - }, - { - 3100, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 38, - 40, - 46, - 47, - 48, - 49, - 50, - 52 - } - } - }, - { - 2107, - new FieldMap.EbgCombineMeshData - { - skipOverlayList = new List - { - 0, - 1, - 2, - 3, - 4, - 5, - 12 - } - } - } + {351, (FieldMap.EbgCombineMeshData)null}, + {358, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 13, 14 }}}, + {450, (FieldMap.EbgCombineMeshData)null }, + {407, (FieldMap.EbgCombineMeshData)null }, + {55, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 5 }}}, + {57, (FieldMap.EbgCombineMeshData)null }, + {60, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 15, 16 }}}, + {111, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 10 }}}, + {153, (FieldMap.EbgCombineMeshData)null }, + {154, (FieldMap.EbgCombineMeshData)null }, + {307, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 6, 8 }}}, + {308, (FieldMap.EbgCombineMeshData)null }, + {309, (FieldMap.EbgCombineMeshData)null }, + {507, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 8, 9, 10 }}}, + {551, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 13 }}}, + {556, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 27 }}}, + {566, (FieldMap.EbgCombineMeshData)null }, + {576, (FieldMap.EbgCombineMeshData)null }, + {603, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 35 }}}, + {612, (FieldMap.EbgCombineMeshData)null }, + {662, (FieldMap.EbgCombineMeshData)null }, + {705, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 25 }}}, + {706, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 13 }}}, + {707, (FieldMap.EbgCombineMeshData)null }, + {751, (FieldMap.EbgCombineMeshData)null }, + {755, (FieldMap.EbgCombineMeshData)null }, + {766, (FieldMap.EbgCombineMeshData)null }, + {802, (FieldMap.EbgCombineMeshData)null }, + {810, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 6, 7 }}}, + {815, (FieldMap.EbgCombineMeshData)null }, + {910, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 12, 13, 14, 15, 16, 17, 19 }}}, + {1910, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 12, 13, 14, 15, 16, 17, 19 }}}, + {916, (FieldMap.EbgCombineMeshData)null }, + {951, (FieldMap.EbgCombineMeshData)null }, + {952, (FieldMap.EbgCombineMeshData)null }, + {957, (FieldMap.EbgCombineMeshData)null }, + {1056, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 19, 24 }}}, + {1106, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 19, 24 }}}, + {1153, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 6, 7 }}}, + {1206, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 5, 6, 7, 8, 9, 10, 11 }}}, + {1207, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 7, 8 }}}, + {1214, (FieldMap.EbgCombineMeshData)null }, + {1215, (FieldMap.EbgCombineMeshData)null }, + {1222, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 21, 22, 23, 24, 25 }}}, + {1223, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 5, 6, 7, 8, 9, 10, 11 }}}, + {1301, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 13 }}}, + {1307, (FieldMap.EbgCombineMeshData)null }, + {1312, (FieldMap.EbgCombineMeshData)null }, + {1355, (FieldMap.EbgCombineMeshData)null }, + {1362, (FieldMap.EbgCombineMeshData)null }, + {1455, (FieldMap.EbgCombineMeshData)null }, + {3054, (FieldMap.EbgCombineMeshData)null }, + {1505, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 0, 8, 13 }}}, + {1950, (FieldMap.EbgCombineMeshData)null }, + {1225, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 5, 6, 7, 8, 9, 10, 11 }}}, + {1801, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 5, 6, 7, 8, 9, 10, 11 }}}, + {1802, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 7, 8 }}}, + {3002, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 7, 8 }}}, + {1806, (FieldMap.EbgCombineMeshData)null }, + {1807, (FieldMap.EbgCombineMeshData)null }, + {1814, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 21, 22, 23, 24, 25 }}}, + {1816, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 15, 16, 17, 18, 19 }}}, + {1823, (FieldMap.EbgCombineMeshData)null }, + {1852, (FieldMap.EbgCombineMeshData)null }, + {1860, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 10 }}}, + {1865, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 17, 18, 20 }}}, + {2000, (FieldMap.EbgCombineMeshData)null }, + {2001, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 7, 8 }}}, + {2101, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 13 }}}, + {565, (FieldMap.EbgCombineMeshData)null }, + {2112, (FieldMap.EbgCombineMeshData)null }, + {605, (FieldMap.EbgCombineMeshData)null }, + {2155, (FieldMap.EbgCombineMeshData)null }, + {2162, (FieldMap.EbgCombineMeshData)null }, + {2200, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25 }}}, + {2217, (FieldMap.EbgCombineMeshData)null }, + {2220, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 4, 5, 6, 7 }}}, + {2221, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 2, 4, 5, 26, 29 }}}, + {2404, (FieldMap.EbgCombineMeshData)null }, + {2453, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 1 }}}, + {2853, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }}}, + {2502, (FieldMap.EbgCombineMeshData)null }, + {2506, (FieldMap.EbgCombineMeshData)null }, + {2509, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 2, 3 }}}, + {2652, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 4 }}}, + {2906, (FieldMap.EbgCombineMeshData)null }, + {3100, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 38, 40, 46, 47, 48, 49, 50, 52 }}}, + {2107, new FieldMap.EbgCombineMeshData { skipOverlayList = new List { 0, 1, 2, 3, 4, 5, 12 }}} }; - public static List fieldMapNameWithAreaTitle = new List + public static readonly List fieldMapNameWithAreaTitle = new List { "FBG_N01_ALXT_MAP016_AT_MSA_0", "FBG_N02_ALXC_MAP042_AC_GDR_0", @@ -3073,14 +2246,34 @@ public static void OnWidescreenSupportChanged() { PsxFieldWidth = CalcPsxFieldWidth(); PsxScreenWidth = CalcPsxScreenWidth(); - if (Configuration.Graphics.InitializeWidescreenSupport() && IsNarrowMap()) + int map = FF9StateSystem.Common.FF9.fldMapNo; + //Log.Message("fldMapNo:" + FF9StateSystem.Common.FF9.fldMapNo + " MapWidth:" + NarrowMapList.MapWidth(FF9StateSystem.Common.FF9.fldMapNo) + " PsxFieldWidth:" + PsxFieldWidth + " PsxScreenWidth:" + PsxScreenWidth + " InitializeWidescreenSupport():" + Configuration.Graphics.InitializeWidescreenSupport() + " WidescreenSupport:" + Configuration.Graphics.WidescreenSupport); + if (Configuration.Graphics.InitializeWidescreenSupport()) { - foreach (KeyValuePair entry in actualNarrowMapWidthDict) + Int32 mapWidth = NarrowMapList.MapWidth(map); + //Log.Message("Configuration.Graphics.WidescreenSupport " + Configuration.Graphics.WidescreenSupport + " CalcPsxFieldWidth() " + CalcPsxFieldWidth() + " PsxScreenWidth 1 " + CalcPsxScreenWidth() + " Screen.width " + Screen.width + " Screen.height " + Screen.height + "mapWidth " + mapWidth); + + if (mapWidth <= PsxScreenWidth && PersistenSingleton.Instance.CurrentScene != "BattleMap") { - if (FF9StateSystem.Common.FF9.fldMapNo == entry.Key) + PsxFieldWidth = (Int16)mapWidth; + PsxScreenWidth = (Int16)mapWidth; + //Log.Message("PsxScreenWidth 2 " + PsxScreenWidth); + } + } + + if (map >= 3000 && map <= 3012) //pre-#324 way of doing to fix narrows in ending + { + PsxFieldWidth = Configuration.Graphics.WidescreenSupport ? CalcPsxFieldWidth() : PsxFieldWidthNative; + PsxScreenWidth = Configuration.Graphics.WidescreenSupport ? CalcPsxScreenWidth() : PsxScreenWidthNative; + if (Configuration.Graphics.InitializeWidescreenSupport() && IsNarrowMap()) + { + foreach (KeyValuePair entry in NarrowMapList.actualNarrowMapWidthDict) { - PsxFieldWidth = (Int16)(entry.Value); - PsxScreenWidth = PsxFieldWidth; + if (FF9StateSystem.Common.FF9.fldMapNo == entry.Key) + { + PsxFieldWidth = (Int16)(entry.Value); + PsxScreenWidth = PsxFieldWidth; + } } } } @@ -3090,10 +2283,12 @@ public static void OnWidescreenSupportChanged() ShaderMulY = CalcShaderMulY(); Shader.SetGlobalFloat("_MulX", ShaderMulX); Shader.SetGlobalFloat("_MulY", ShaderMulY); + //Log.Message("OnWidescreenSupportChanged()"); + //Log.Message("HalfFieldWidth " + HalfFieldWidth + " HalfScreenWidth " + HalfScreenWidth + " ShaderMulX " + ShaderMulX + " PsxFieldWidth " + CalcShaderMulX() + " CalcShaderMulX() "); } - private static Int16 CalcPsxFieldWidth() => Configuration.Graphics.WidescreenSupport ? (Int16)(PsxFieldHeightNative * Screen.width / Screen.height) : PsxFieldWidthNative; - private static Int16 CalcPsxScreenWidth() => Configuration.Graphics.WidescreenSupport ? (Int16)(PsxScreenHeightNative * Screen.width / Screen.height) : PsxScreenWidthNative; + private static Int16 CalcPsxFieldWidth() => Configuration.Graphics.InitializeWidescreenSupport() ? (Int16)(PsxFieldHeightNative * Screen.width / Screen.height) : PsxFieldWidthNative; + private static Int16 CalcPsxScreenWidth() => Configuration.Graphics.InitializeWidescreenSupport() ? (Int16)(PsxScreenHeightNative * Screen.width / Screen.height) : PsxScreenWidthNative; private static Single CalcShaderMulX() => 1f / HalfFieldWidth; private static Single CalcShaderMulY() => 1f / HalfFieldHeight; @@ -3132,4 +2327,15 @@ private Boolean IsRotationScroll this.flags &= ~FieldMapFlags.RotationScroll; } } + + private bool dbug = false; + + private float Prev_CamPositionX, Prev_CamPositionY; + private Int16 SmoothCamPercent() + { + return (Int16)Mathf.Clamp(Configuration.Graphics.CameraStabilizer, 0, 99); + } + private Int16 SmoothCamDelay; + private Vector2 SmoothCamDelta; + private Boolean SmoothCamActive; } diff --git a/Assembly-CSharp/Global/Field/Map/NarrowMapList.cs b/Assembly-CSharp/Global/Field/Map/NarrowMapList.cs index 7a1a6c04f..fca747624 100644 --- a/Assembly-CSharp/Global/Field/Map/NarrowMapList.cs +++ b/Assembly-CSharp/Global/Field/Map/NarrowMapList.cs @@ -2,33 +2,111 @@ using System.Collections.Generic; using System.Linq; using Memoria; +using Memoria.Prime; public static class NarrowMapList { - public static Boolean IsCurrentMapNarrow() => IsNarrowMap(FF9StateSystem.Common.FF9.fldMapNo, PersistenSingleton.Instance?.fieldmap?.camIdx ?? -1); - public static Boolean IsNarrowMap(Int32 mapId, Int32 camId) + public static Boolean IsCurrentMapNarrow(Int32 ScreenWidth) => IsNarrowMap(FF9StateSystem.Common.FF9.fldMapNo, PersistenSingleton.Instance?.fieldmap?.camIdx ?? -1, ScreenWidth); + public static Boolean IsNarrowMap(Int32 mapId, Int32 camId, Int32 ScreenWidth) { - if (_ScreenIs16to10 && ListWideWhen16to10.Contains(mapId)) - return false; - if (ListFullNarrow.Contains(mapId)) + if (SpecificScenesNarrow(mapId, camId)) return true; - - if (ListPartialNarrow.TryGetValue(mapId, out HashSet narrowCams) && narrowCams.Contains(camId)) + + if (MapWidth(mapId) <= ScreenWidth) return true; + + + //if (ListFullNarrow.Contains(mapId)) + // return true; + + //if (ListPartialNarrow.TryGetValue(mapId, out HashSet narrowCams) && narrowCams.Contains(camId)) + // return true; + //Log.Message("camId:" + camId + ", mapid:" + mapId); + + return false; + } + public static Boolean SpecificScenesNarrow(Int32 mapId, Int32 currCamera) + { + Int32 currIndex = PersistenSingleton.Instance.eBin.getVarManually(EBin.MAP_INDEX_SVR); + Int32 currCounter = PersistenSingleton.Instance.eBin.getVarManually(EBin.SC_COUNTER_SVR); + + foreach (int[] entry in Map_Index_Narrow_List) + { + if (entry[0] == mapId && entry[1] == currIndex) + return true; + } + foreach (int[] entry in Map_Counter_Narrow_List) + { + if (entry[0] == mapId && entry[1] == currCounter) + return true; + } + foreach (int[] entry in Map_Camera_Narrow_List) + { + if (entry[0] == mapId && entry[1] == currCamera) + return true; + } return false; } - private static readonly Boolean _ScreenIs16to10 = Configuration.Graphics.ScreenIs16to10(); + public static Int32 MapWidth(Int32 mapId) + { + Int32 width = 500; + Int32 currCamera = PersistenSingleton.Instance?.fieldmap?.camIdx ?? -1; + + if (ListFullNarrow.Contains(mapId) || SpecificScenesNarrow(mapId, currCamera)) + width = 320; + + foreach (KeyValuePair entry in actualNarrowMapWidthDict) + { + if (mapId == entry.Key && !SpecificScenesNarrow(entry.Key, currCamera)) + width = (Int32)entry.Value; + } + + //Log.Message("width:" + width + "PersistenSingleton.Instance?.fieldmap?.camIdx" + PersistenSingleton.Instance?.fieldmap?.camIdx); + return width; + } - private static readonly Dictionary> ListPartialNarrow = new Dictionary>() + public static readonly int[][] Map_Index_Narrow_List = { - // Not yet implemented - // For now, using this "per camera" narrow list bugs, surely because of the camera position shift in FieldMap.CenterCameraOnPlayer - //{ 0154, new HashSet() { 0 } }, // A. Castle/Hallway - //{ 1215, new HashSet() { 0 } }, // A. Castle/Hallway - //{ 1807, new HashSet() { 0 } }, // A. Castle/Hallway + // [mapNo,index], + [50,0], // first scene + [150,325], // Zidane infiltrate Alex Castle + [254,26], // MBG103 - Evil Forest + [352,3], // Arrival at Dali: vivi visible before sleeping + [355,18], // Steiner to the barmaid + [600,32], // Throne, meet cid + [615,57], // Meet garnet on Lindblum Tower + [615,58], // Meet garnet on Lindblum Tower (2) + [1206,0], // Queen and Kuja salon Alex, drug garnet + [1602,16], // scene at Madain Sari night w/ Vivi/Zidane/Eiko eavesdropping, bugged if you see too much + [1823,331], // Garnet coronation, garnet visible + [1815,0], // Love quiproquo at the docks + [1816,315], // Love quiproquo at the docks + [2007,2], // MBG111 - Alex castle changing + [2211,8], // Lindblum meeting after Alexander scene: ATE with kuja at his ship, Zorn & Thorn visible too soon and blending + [2404,25], // Baku seen waiting on the docks too soon + [2705,-1], // Pandemonium, you're not alone sequence, several glitches + [2706,-1], // Pandemonium, you're not alone sequence, several glitches + [2707,-1], // Pandemonium, you're not alone sequence, several glitches + [2708,-1], // Pandemonium, you're not alone sequence, several glitches + [2711,0], // Pandemonium, people are waiting in line after Kuja is defeated }; - private static readonly HashSet ListFullNarrow = new HashSet() + public static readonly int[][] Map_Counter_Narrow_List = + { + // [mapNo,counter], + //[951,4500], // Gargan roo, secondary screen is smaller, but only visible in 1 scene + [1554,6300], // MBG109 - roots + [1554,6305], // MBG109 - roots + [2905,11620], // MBG118 - Memoria pink castle + }; + + public static readonly int[][] Map_Camera_Narrow_List = + { + // [mapNo,camIdx], + //[951,1], // // Gargan roo, secondary screen is smaller, but only visible in 1 scene + }; + + public static readonly HashSet ListFullNarrow = new HashSet() { 0052, // Prima Vista/Meeting Rm 0053, // Prima Vista/Meeting Rm @@ -56,6 +134,7 @@ public static Boolean IsNarrowMap(Int32 mapId, Int32 camId) 0150, // A. Castle/Guardhouse 0151, // A. Castle/Throne 0153, // A. Castle/Hallway + 0154, 0157, // A. Castle/Kitchen 0160, // A. Castle/Courtyard 0161, // A. Castle/Courtyard @@ -73,7 +152,7 @@ public static Boolean IsNarrowMap(Int32 mapId, Int32 camId) 0209, // Prima Vista/Event 0251, // Evil Forest/Trail 0252, // Evil Forest/Trail - 0254, // Evil Forest/Swamp + //0254, // Evil Forest/Swamp 0255, // Evil Forest/Riverbank 0256, // Evil Forest/Trail 0259, // Evil Forest/Trail @@ -120,7 +199,7 @@ public static Boolean IsNarrowMap(Int32 mapId, Int32 camId) 0571, 0574, // Lindblum/Festival 0576, // Lindblum/Festival - 0600, // L. Castle/Royal Cham. + //0600, // L. Castle/Royal Cham. 0601, // L. Castle/Lift 0606, // L. Castle/Event 0607, // L. Castle/Hangar @@ -158,10 +237,12 @@ public static Boolean IsNarrowMap(Int32 mapId, Int32 camId) 0911, 0913, 0930, // Treno/Tot Residence + 0931, // Treno/Tot Residence 0932, // Treno/Event 0950, 0951, // Gargan Roo/Passage 0954, // Gargan Roo/Tunnel + 0955, 1000, // Cleyra/Tree Roots 1001, // Cleyra/Tree Roots 1002, // Cleyra/Tree Roots @@ -189,7 +270,8 @@ public static Boolean IsNarrowMap(Int32 mapId, Int32 camId) 1212, // A. Castle/East Tower 1213, // A. Castle/Guardhouse 1214, // A. Castle/Hallway - 1216, + 1215, + //1216, 1218, 1221, // A. Castle/Courtyard 1222, // A. Castle/Courtyard @@ -248,12 +330,12 @@ public static Boolean IsNarrowMap(Int32 mapId, Int32 camId) 1609, // Mdn. Sari/Cove 1610, // Mdn. Sari/Cove 1650, - 1651, // Iifa Tree/Tree Roots - 1652, // Iifa Tree/Roots + //1651, // Iifa Tree/Tree Roots + //1652, // Iifa Tree/Roots 1655, // Iifa Tree/Tree Path 1656, // Iifa Tree/Eidolon Moun 1657, // Iifa Tree/Tree Roots - 1658, // Iifa Tree/Silver Drago + 1658, // Iifa Tree/Silver Dragon 1660, 1661, 1662, @@ -272,15 +354,16 @@ public static Boolean IsNarrowMap(Int32 mapId, Int32 camId) 1755, // Iifa Tree/Bottom 1756, // Iifa Tree/Bottom 1757, - 1758, // Iifa Tree/Tree Roots + //1758, // Iifa Tree/Tree Roots 1800, // A. Castle/Tomb 1803, // A. Castle/Guardhouse 1806, // A. Castle/Hallway - 1808, + 1807, // A. Castle/Hallway + //1808, 1810, 1813, // A. Castle/Courtyard 1814, // A. Castle/Courtyard - 1816, // A. Castle/Courtyard + //1816, // A. Castle/Courtyard 1817, // A. Castle/Neptune 1818, // A. Castle/Neptune 1820, // A. Castle/West Tower @@ -303,7 +386,7 @@ public static Boolean IsNarrowMap(Int32 mapId, Int32 camId) 2004, 2005, // A. Castle/Altar 2006, - 2007, // A. Castle/Altar + //2007, // A. Castle/Altar 2008, // A. Castle/Altar 2050, // Alexandria/Main Street 2052, @@ -311,7 +394,7 @@ public static Boolean IsNarrowMap(Int32 mapId, Int32 camId) 2101, // Lindblum/B.D. Station 2103, // Lindblum/Inn 2108, // Lindblum/Synthesist - 2109, // Lindblum/Wpn. Shop + //2109, // Lindblum/Wpn. Shop 2112, 2113, 2114, // Lindblum/Theater Ave. @@ -366,19 +449,14 @@ public static Boolean IsNarrowMap(Int32 mapId, Int32 camId) 2513, 2551, 2552, // Earth Shrine/Interior - 2600, // Terra/Hilltop 2601, 2602, // Terra/Stepping Stones - 2605, // Terra/Treetop - 2606, // Terra/Tree base - 2607, // Terra/Bridge + //2606, // Terra/Tree base 2608, // Terra/Event 2650, - 2651, // Bran Bal/Entrance 2654, // Bran Bal/Pond 2657, // Bran Bal/Storage 2658, - 2660, // Bran Bal/Hilltop 2701, // Pand./Path 2706, 2715, // Pand./Event @@ -392,7 +470,6 @@ public static Boolean IsNarrowMap(Int32 mapId, Int32 camId) 2901, // Memoria/Entrance 2902, // Memoria/Stairs of Time 2904, // Memoria/Outer Path - 2905, 2906, 2908, // Memoria/Time Interval 2909, // Memoria/Ruins @@ -419,7 +496,9 @@ public static Boolean IsNarrowMap(Int32 mapId, Int32 camId) 2950, // Chocobo’s Forest 2953, // Chocobo’s Dream World 3001, + 3003, 3005, + 3006, 3008, // Ending/Prima Vista - Meeting Room 3009, 3010, // Ending/TH @@ -430,138 +509,217 @@ public static Boolean IsNarrowMap(Int32 mapId, Int32 camId) 3056, // Mage Village/Rooftop 3057, 3058, // Mage Village/Water Mil - 3100, + 3100, // Mog Post }; - private static readonly HashSet ListWideWhen16to10 = new HashSet() + public static readonly Dictionary mapCameraMargin = new Dictionary { - 55, - 60, - 102, - 109, - 150, - 157, - 161, - 162, - 201, - 206, - 207, - 251, - 252, - 262, - 405, - 407, - 456, - 505, - 553, - 556, - 561, - 565, - 566, - 568, - 569, - 571, - 613, - 656, - 657, - 658, - 659, - 663, - 705, - 751, - 753, - 755, - 806, - 813, - 851, - 855, - 901, - 911, - 913, - 950, - 1017, - 1018, - 1054, - 1058, - 1104, - 1108, - 1153, - 1201, - 1205, - 1210, - 1213, - 1218, - 1222, - 1251, - 1254, - 1303, - 1312, - 1313, - 1363, - 1403, - 1404, - 1408, - 1414, - 1424, - 1452, - 1453, - 1456, - 1509, - 1600, - 1601, - 1602, - 1656, - 1700, - 1701, - 1702, - 1803, - 1810, - 1814, - 1817, - 1820, - 1852, - 1858, - 1901, - 1911, - 1913, - 1953, - 2002, - 2004, - 2006, - 2052, - 2103, - 2112, - 2113, - 2163, - 2200, - 2212, - 2213, - 2222, - 2352, - 2353, - 2355, - 2400, - 2406, - 2451, - 2502, - 2503, - 2551, - 2601, - 2650, - 2657, - 2658, - 2706, - 2851, - 2855, - 2856, - 2904, - 2906, - 2913, - 2915, - 2928, - 3005, - 3052, - 3055, - 3100, + //{mapNo,pixels on each side to crop because of scrollable} + {1051,9}, + {1057,17}, + {1058,16}, + {1060,17}, + {1652,16}, + {1653,16}, + //{154,16}, + }; + + public static readonly Dictionary actualNarrowMapWidthDict = new Dictionary + { + //{mapNo,(actualWidth - 2)} + {163,318}, + {606,318}, + {1050,316}, + + {203,334}, + {760,334}, + {814,334}, + {816,334}, + {1151,334}, + {1458,334}, + {1500,334}, + {1506,334}, + {1605,334}, + {1606,334}, + {1608,334}, + {1660,334}, + {1661,334}, + {1662,334}, + {1705,334}, + {1707,334}, + {1751,334}, + {2202,334}, + {2204,334}, + {2205,334}, + {2208,334}, + {2254,334}, + {2257,334}, + {2303,334}, + {2365,334}, + {2513,334}, + {2756,334}, + {2932,334}, + {3057,334}, + {114,350}, + {550,350}, + {620,350}, + {802,350}, + {803,350}, + {1212,350}, + {1300,350}, + {1370,350}, + {1508,350}, + {1650,350}, + {1657,346}, + {1752,350}, + {1757,350}, + {1863,350}, + {1951,350}, + {1952,350}, + {2000,350}, + {2055,350}, + {2771,350}, + {2203,350}, + {2261,350}, + {2356,350}, + {2362,350}, + {2500,350}, + {2501,350}, + {2654,350}, + {60,366}, + {150,366}, + {161,366}, + {201,366}, + {262,366}, + {565,366}, + {911,366}, + {1213,366}, + {1222,366}, + {1251,366}, + {1254,366}, + {1312,366}, + {1403,366}, + {1803,366}, + {1814,366}, + {1817,366}, + {1911,366}, + {1953,366}, + {2002,366}, + {2004,366}, + {2006,366}, + {2112,366}, + {2400,366}, + {2502,366}, + {2503,366}, + {2650,366}, + {2904,366}, + {2913,366}, + {2928,366}, + {3100,366}, + {102,382}, + {109,382}, + {162,382}, + {206,382}, + {207,382}, + {251,382}, + {252,382}, + {407,382}, + {553,382}, + {556,382}, + {705,382}, + {751,382}, + {813,382}, + {950,382}, + {1017,382}, + {1018,382}, + {1058,380}, + {1108,380}, + {1201,382}, + {1210,382}, + {1303,382}, + {1404,382}, + {1452,382}, + {1453,382}, + {1509,382}, + {1656,382}, + {1820,382}, + {1852,382}, + {1858,382}, + {2052,382}, + {2103,382}, + {2200,382}, + {2222,382}, + {2355,382}, + {2406,382}, + {2451,382}, + {2602,382}, + {2657,382}, + {2851,382}, + {2855,382}, + {2856,382}, + {2915,382}, + {3052,382}, + {55,398}, + {157,398}, + {405,398}, + {456,398}, + {505,398}, + {561,398}, + {566,398}, + {568,398}, + {569,398}, + {571,398}, + {613,398}, + {656,398}, + {657,398}, + {658,398}, + {659,398}, + {663,398}, + {753,398}, + {755,398}, + {806,398}, + {851,398}, + {855,398}, + {901,398}, + {913,398}, + {1054,398}, + {1104,398}, + {1153,398}, + {1218,398}, + {1313,398}, + {1363,398}, + {1408,398}, + {1414,398}, + {1424,398}, + {1456,398}, + {1600,398}, + {1601,398}, + {1602,398}, + {1700,398}, + {1701,398}, + {1702,398}, + {1810,398}, + {1901,398}, + {1913,398}, + {2113,398}, + {2163,398}, + {2212,398}, + {2213,398}, + {2352,398}, + {2353,398}, + {2551,398}, + {2601,398}, + {2658,398}, + {2706,398}, + {2906,398}, + {3005,398}, + {3055,398}, + {1205,384}, + {154,352}, + {1215,352}, + {1805,352}, + {1807,352}, + //{1652,336}, + {2552,352}, }; } diff --git a/Assembly-CSharp/Global/Game/GameOverUI.cs b/Assembly-CSharp/Global/Game/GameOverUI.cs index e3845b3ae..1d3a5558e 100644 --- a/Assembly-CSharp/Global/Game/GameOverUI.cs +++ b/Assembly-CSharp/Global/Game/GameOverUI.cs @@ -1,16 +1,35 @@ using System; using System.Collections; using Assets.Scripts.Common; +using Memoria.Assets; using UnityEngine; public class GameOverUI : UIScene { public override void Show(UIScene.SceneVoidDelegate afterFinished = null) { - SceneDirector.FF9Wipe_FadeInEx(30); + SceneDirector.FF9Wipe_FadeInEx(30); UIScene.SceneVoidDelegate sceneVoidDelegate = delegate { - SceneDirector.FF9Wipe_FadeInEx(24); + // Replace gameover screen with modded version if it exists + UI2DSprite sprite2D = this.GameOverSprite.GetComponent(); + Sprite sprite = sprite2D.sprite2D; + String externalPath = AssetManager.SearchAssetOnDisc("EmbeddedAsset/UI/Sprites/gameover", true, false); + if (!String.IsNullOrEmpty(externalPath)) + { + Texture2D texture = StreamingResources.LoadTexture2D(externalPath); + sprite2D.sprite2D = Sprite.Create(texture, sprite.rect, sprite.pivot); + sprite2D.sprite2D.name = sprite.name; + } + externalPath = AssetManager.SearchAssetOnDisc("EmbeddedAsset/UI/Sprites/gameover.png", true, false); // also check .png for simplicity + if (!String.IsNullOrEmpty(externalPath)) + { + Texture2D texture = StreamingResources.LoadTexture2D(externalPath); + sprite2D.sprite2D = Sprite.Create(texture, sprite.rect, sprite.pivot); + sprite2D.sprite2D.name = sprite.name; + } + + SceneDirector.FF9Wipe_FadeInEx(24); this.AnimatePanel(1); }; TimerUI.SetEnable(false); @@ -56,7 +75,7 @@ public override Boolean OnKeyConfirm(GameObject go) private void AnimatePanel(Int32 alpha) { - TweenAlpha.Begin(this.GameOverSprite, this.duration, (Single)alpha); + TweenAlpha.Begin(this.GameOverSprite, this.duration, (Single)alpha); } private void GoToTitleScene() diff --git a/Assembly-CSharp/Global/Honolulu/HonoluluFieldMain.cs b/Assembly-CSharp/Global/Honolulu/HonoluluFieldMain.cs index d468c36e7..39ae72bbf 100644 --- a/Assembly-CSharp/Global/Honolulu/HonoluluFieldMain.cs +++ b/Assembly-CSharp/Global/Honolulu/HonoluluFieldMain.cs @@ -145,8 +145,12 @@ private void ff9InitStateFieldMap(Int32 MapNo) allSoundDispatchPlayer.FF9SOUND_SNDEFFECTRES_RESTORE(0); if (sndEffectResSoundID2 != -1 && sndEffectResSoundID2 == sndEffectResSoundID4) allSoundDispatchPlayer.FF9SOUND_SNDEFFECTRES_RESTORE(1); - PlayerWindow.Instance.SetTitle($"Map: {FF9StateSystem.Common.FF9.fldMapNo}, Loc: {FF9StateSystem.Common.FF9.fldLocNo} Name: {FF9StateSystem.Common.FF9.mapNameStr}"); - FPSManager.DelayMainLoop(Time.realtimeSinceStartup - loadStartTime); + Int32 camNumber = PersistenSingleton.Instance?.fieldmap?.camIdx ?? -1; + String camNumberStr = "-" + camNumber; + if (camNumber == -1) { camNumberStr = ""; }; + String camIdxIfCam = (PersistenSingleton.Instance?.fieldmap?.scene?.cameraList.Count > 1 && PersistenSingleton.Instance?.fieldmap?.camIdx != -1) ? "-" + PersistenSingleton.Instance.fieldmap.camIdx : ""; + PlayerWindow.Instance.SetTitle($"Map: {FF9StateSystem.Common.FF9.fldMapNo}{camIdxIfCam} ({FF9StateSystem.Common.FF9.mapNameStr}) | Index/Counter: {PersistenSingleton.Instance.eBin.getVarManually(EBin.MAP_INDEX_SVR)}/{PersistenSingleton.Instance.eBin.getVarManually(EBin.SC_COUNTER_SVR)} | Loc: {FF9StateSystem.Common.FF9.fldLocNo}"); + FPSManager.DelayMainLoop(Time.realtimeSinceStartup - loadStartTime); } public override void HonoUpdate() diff --git a/Assembly-CSharp/Global/ISd/ISdLibAPI.cs b/Assembly-CSharp/Global/ISd/ISdLibAPI.cs index ba076f732..e65e197ae 100644 --- a/Assembly-CSharp/Global/ISd/ISdLibAPI.cs +++ b/Assembly-CSharp/Global/ISd/ISdLibAPI.cs @@ -25,7 +25,7 @@ public virtual Int32 SdSoundSystem_Resume() return 0; } - public virtual Int32 SdSoundSystem_AddData(IntPtr akb) + public virtual Int32 SdSoundSystem_AddData(IntPtr akb, SoundProfile profile) { SoundLib.Log("No Implementation"); return 0; diff --git a/Assembly-CSharp/Global/ISd/ISdLibAPIProxy.cs b/Assembly-CSharp/Global/ISd/ISdLibAPIProxy.cs index afc7bc014..92558a85e 100644 --- a/Assembly-CSharp/Global/ISd/ISdLibAPIProxy.cs +++ b/Assembly-CSharp/Global/ISd/ISdLibAPIProxy.cs @@ -1,4 +1,5 @@ -using System; +using Global.Sound.SoLoud; +using Memoria; using UnityEngine; public class ISdLibAPIProxy @@ -24,11 +25,18 @@ private static void Initialize() { if (Application.HasProLicense()) { - ISdLibAPIProxy.instance = new SdLibAPIWithProLicense(); + if(Configuration.Audio.Backend == 0) + { + ISdLibAPIProxy.instance = new SdLibAPIWithProLicense(); + } + else + { + ISdLibAPIProxy.instance = new SdLibAPIWithSoloud(); + } } else { - ISdLibAPIProxy.instance = new SdLibApiWithoutProLicense(); + ISdLibAPIProxy.instance = new SdLibAPIWithSoloud(); } } diff --git a/Assembly-CSharp/Global/JsonParser.cs b/Assembly-CSharp/Global/JsonParser.cs index ea296443b..d4cc1461a 100644 --- a/Assembly-CSharp/Global/JsonParser.cs +++ b/Assembly-CSharp/Global/JsonParser.cs @@ -5,6 +5,7 @@ using SimpleJSON; using UnityEngine; using FF9; +using Memoria.Prime; public class JsonParser : ISharedDataParser { @@ -519,7 +520,7 @@ private void ParseEventJsonToData(JSONNode jsonData, Boolean oldSaveFormat = tru for (Int32 i = 0; i < jsonData["gAbilityUsage"].Count; i++) { JSONClass abilClass = jsonData["gAbilityUsage"][i].AsObject; - if (abilClass != null && abilClass["id"] != null && abilClass["count"] != null) + if (abilClass != null && abilClass["id"] != null && abilClass["count"] != null) // Regardless of whether the ability exists or not with the current settings eventState.gAbilityUsage[(BattleAbilityId)abilClass["id"].AsInt] = abilClass["count"].AsInt; } } @@ -640,9 +641,12 @@ private FF9SAVE_MINIGAME ParseQuadMistJsonToData(JSONNode jsonData, Boolean oldS JSONClass asObject = jsonData["MiniGameCard"][i].AsObject; if (asObject["id"] != null && (TetraMasterCardId)asObject["id"].AsInt != TetraMasterCardId.NONE) { + Int32 cardId = asObject["id"].AsInt; + if ((TetraMasterCardId)cardId == TetraMasterCardId.NONE || cardId >= CardPool.TOTAL_CARDS) // Cards that don't exist (not possible yet) are discarded + continue; QuadMistCard card = new QuadMistCard(); if (asObject["id"] != null) - card.id = (TetraMasterCardId)asObject["id"].AsInt; + card.id = (TetraMasterCardId)cardId; if (asObject["side"] != null) card.side = (Byte)asObject["side"].AsInt; if (asObject["atk"] != null) @@ -683,11 +687,18 @@ private void ParseQuadMistDataToJson(FF9SAVE_MINIGAME data, JSONClass dataNode, dataProfileClass.Add("sDraw", data.sDraw.ToString()); JSONArray dataProfileArray = new JSONArray(); Int32 count = oldSaveFormat ? 100 : data.MiniGameCard.Count; + Int32 cardIndex = 0; for (Int32 i = 0; i < count; i++) { - if (i < data.MiniGameCard.Count) + if (oldSaveFormat) + { + // Prevent adding cards with non-vanilla IDs at all (not yet possible) + while (cardIndex < data.MiniGameCard.Count && (Int32)data.MiniGameCard[cardIndex].id >= 100) + cardIndex++; + } + if (cardIndex < data.MiniGameCard.Count) { - QuadMistCard card = data.MiniGameCard[i]; + QuadMistCard card = data.MiniGameCard[cardIndex]; JSONClass cardClass = new JSONClass(); cardClass.Add("id", ((Int32)card.id).ToString()); cardClass.Add("side", "0"); @@ -713,6 +724,7 @@ private void ParseQuadMistDataToJson(FF9SAVE_MINIGAME data, JSONClass dataNode, { "arrow", "255" } }); } + cardIndex++; } dataProfileClass.Add("MiniGameCard", dataProfileArray); dataNode.Add("30000_MiniGame", dataProfileClass); @@ -932,14 +944,21 @@ private void ParseCommonDataToJson(FF9StateGlobal data, JSONClass dataNode, JSON } JSONArray dataItemClass = new JSONArray(); Int32 itemCount = oldSaveFormat ? 256 : data.item.Count; + Int32 itemIndex = 0; for (Int32 i = 0; i < itemCount; i++) { - if (i < data.item.Count) + if (oldSaveFormat) + { + // Prevent adding items with non-vanilla IDs at all + while (itemIndex < data.item.Count && (Int32)data.item[itemIndex].id >= 256) + itemIndex++; + } + if (itemIndex < data.item.Count) { dataItemClass.Add(new JSONClass { - { "id", ((Int32)data.item[i].id).ToString() }, - { "count", data.item[i].count.ToString() } + { "id", ((Int32)data.item[itemIndex].id).ToString() }, + { "count", data.item[itemIndex].count.ToString() } }); } else @@ -947,9 +966,10 @@ private void ParseCommonDataToJson(FF9StateGlobal data, JSONClass dataNode, JSON dataItemClass.Add(new JSONClass { { "id", "255" }, - { "count", "255" } + { "count", "0" } }); } + itemIndex++; } dataProfileClass.Add("items", dataItemClass); if (oldSaveFormat) @@ -1109,7 +1129,7 @@ private void ParseCommonJsonToData(JSONNode jsonData, Boolean oldSaveFormat = tr if (playerInfoClass != null && playerInfoClass["slot_no"] != null) charId = (CharacterId)playerInfoClass["slot_no"].AsInt; PLAYER player = ffglobal.GetPlayer(charId); - if (player == null) + if (player == null) // Discard playable characters that don't exist continue; if (oldSaveFormat && playerClass["category"] != null) { @@ -1193,10 +1213,13 @@ private void ParseCommonJsonToData(JSONNode jsonData, Boolean oldSaveFormat = tr player.info.menu_type = (CharacterPresetId)playerInfoClass["menu_type"].AsInt; if (playerClass["status"] != null) player.status = (BattleStatus)playerClass["status"].AsInt; - if (playerClass["equip"] != null) - for (Int32 j = 0; j < playerClass["equip"].Count && j < CharacterEquipment.Length; j++) - player.equip[j] = (RegularItem)playerClass["equip"][j].AsInt; - JSONClass playerBonusClass = playerClass["bonus"].AsObject; + if (playerClass["equip"] != null) + for (Int32 j = 0; j < playerClass["equip"].Count && j < CharacterEquipment.Length; j++) + if (ff9item._FF9Item_Data.ContainsKey((RegularItem)playerClass["equip"][j].AsInt)) + player.equip[j] = (RegularItem)playerClass["equip"][j].AsInt; + else + player.equip[j] = RegularItem.NoItem; + JSONClass playerBonusClass = playerClass["bonus"].AsObject; if (playerBonusClass["dex"] != null) player.bonus.dex = (UInt16)playerBonusClass["dex"].AsInt; if (playerBonusClass["str"] != null) @@ -1242,12 +1265,13 @@ private void ParseCommonJsonToData(JSONNode jsonData, Boolean oldSaveFormat = tr if ((player.sa[j >> 5] & (1u << j)) != 0u) player.saExtended.Add((SupportAbility)j); } - else if (playerClass["sa_extended"] != null) - { - for (Int32 j = 0; j < playerClass["sa_extended"].Count; j++) - ff9abil.FF9Abil_SetEnableSA(player, (SupportAbility)playerClass["sa_extended"][j].AsInt, true); - } - } + else if (playerClass["sa_extended"] != null) + { + for (Int32 j = 0; j < playerClass["sa_extended"].Count; j++) + if (ff9abil.FF9Abil_GetIndex(player, playerClass["sa_extended"][j].AsInt) > 0) + ff9abil.FF9Abil_SetEnableSA(player, (SupportAbility)playerClass["sa_extended"][j].AsInt, true); + } + } if (playerBonusClass["maxHpLimit"] != null) player.maxHpLimit = playerBonusClass["maxHpLimit"].AsUInt; if (playerBonusClass["maxMpLimit"] != null) @@ -1319,7 +1343,7 @@ private void ParseCommonJsonToData(JSONNode jsonData, Boolean oldSaveFormat = tr if (itemClass != null) { RegularItem itemId = (RegularItem)itemClass["id"].AsInt; - if (itemId != RegularItem.NoItem) + if (itemId != RegularItem.NoItem && ff9item._FF9Item_Data.ContainsKey(itemId)) // Discard items that are registerd in the save but that don't exist with the current settings ffglobal.item.Add(new FF9ITEM(itemId, (Byte)itemClass["count"].AsInt)); } } @@ -1340,7 +1364,7 @@ private void ParseCommonJsonToData(JSONNode jsonData, Boolean oldSaveFormat = tr JSONClass rareItemClass = jsonData["rareItemsEx"][i].AsObject; if (rareItemClass == null || rareItemClass["id"] == null) continue; - Int32 rareItemId = rareItemClass["id"].AsInt; + Int32 rareItemId = rareItemClass["id"].AsInt; // Rare items that don't exist (typically because a mod was disabled) appear as blank rare items; they are not discarded if (rareItemClass["obtained"] != null && rareItemClass["obtained"].AsBool) ffglobal.rare_item_obtained.Add(rareItemId); if (rareItemClass["used"] != null && rareItemClass["used"].AsBool) diff --git a/Assembly-CSharp/Global/MBG.cs b/Assembly-CSharp/Global/MBG.cs index 17ff69616..677438b6a 100644 --- a/Assembly-CSharp/Global/MBG.cs +++ b/Assembly-CSharp/Global/MBG.cs @@ -189,12 +189,12 @@ public void SetFieldMap(FieldMap fieldMap) { this.mbgCamera.depth = -4096f; this.currentFieldMap = fieldMap; - MBG.MBGParms.oldBGCamNdx = this.currentFieldMap.GetCurrentCameraIndex(); + MBG.MBGParms.oldBGCamNdx = this.currentFieldMap.camIdx; Camera mainCamera = fieldMap.GetMainCamera(); this.SetMovieCamera(mainCamera); - } + } - public void Play() + public void Play() { this.tempTargetFrameRate = FPSManager.GetTargetFPS(); this.tempVirtualAnalogStatus = VirtualAnalog.IsEnable; @@ -223,8 +223,8 @@ public void Play() this.isWaitForPause = false; this.played = true; FPSManager.SetTargetFPS(Mathf.RoundToInt((Single)this.movieMaterial.FPS)); - PlayerWindow.Instance.SetTitle($"FPS: {FPSManager.GetTargetFPS()}"); - this.movieMaterial.Play(); + PlayerWindow.Instance.SetTitle($"FMV: {this.movieMaterial.movieKey} | Map: {FF9StateSystem.Common.FF9.fldMapNo} ({FF9StateSystem.Common.FF9.mapNameStr}) | Index/Counter: {PersistenSingleton.Instance.eBin.getVarManually(EBin.MAP_INDEX_SVR)}/{PersistenSingleton.Instance.eBin.getVarManually(EBin.SC_COUNTER_SVR)} | Loc: {FF9StateSystem.Common.FF9.fldLocNo}"); + this.movieMaterial.Play(); } public void Pause(Boolean doPause) @@ -312,8 +312,10 @@ public void Stop() PersistenSingleton.Instance.SetVirtualAnalogEnable(this.tempVirtualAnalogStatus); SceneDirector.ToggleFadeAll(true); FPSManager.SetTargetFPS(this.tempTargetFrameRate); - PlayerWindow.Instance.SetTitle(String.Empty); - vib.VIB_actuatorReset(0); + //PlayerWindow.Instance.SetTitle(String.Empty); + PlayerWindow.Instance.SetTitle($"Map: {FF9StateSystem.Common.FF9.fldMapNo} ({FF9StateSystem.Common.FF9.mapNameStr}) | Index/Counter: {PersistenSingleton.Instance.eBin.getVarManually(EBin.MAP_INDEX_SVR)}/{PersistenSingleton.Instance.eBin.getVarManually(EBin.SC_COUNTER_SVR)} | Loc: {FF9StateSystem.Common.FF9.fldLocNo}"); + + vib.VIB_actuatorReset(0); this.movieMaterial.Transparency = 0f; this.movieMaterial.Stop(); this.mbgCamera.depth = -4096f; diff --git a/Assembly-CSharp/Global/SFX/SfxSoundPlayer.cs b/Assembly-CSharp/Global/SFX/SfxSoundPlayer.cs index f42c2cd5e..dc4d054de 100644 --- a/Assembly-CSharp/Global/SFX/SfxSoundPlayer.cs +++ b/Assembly-CSharp/Global/SFX/SfxSoundPlayer.cs @@ -136,20 +136,18 @@ public SoundProfile PlaySfxSound(Int32 soundIndexInSpecialEffect, Single soundVo return soundProfile; } base.CreateSound(soundProfile); - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); if (ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_IsExist(soundProfile.SoundID) != 0) { ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * this.Volume, 0); - SoundLib.Log("Panning: " + soundProfile.Panning); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPanning(soundProfile.SoundID, soundProfile.Panning, 0); Int32 fastForwardFactor = HonoBehaviorSystem.Instance.GetFastForwardFactor(); if (fastForwardFactor != 1) { - Single pitch2 = (Single)fastForwardFactor * soundProfile.Pitch; - soundProfile.Pitch = pitch2; + soundProfile.Pitch = (Single)fastForwardFactor * soundProfile.Pitch; } ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPitch(soundProfile.SoundID, soundProfile.Pitch, 0); - } + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); + } else { SoundLib.Log("failed to play sound"); diff --git a/Assembly-CSharp/Global/Sd/SdLibAPIWithProLicense.cs b/Assembly-CSharp/Global/Sd/SdLibAPIWithProLicense.cs index 099efc7bc..a3cf6cde2 100644 --- a/Assembly-CSharp/Global/Sd/SdLibAPIWithProLicense.cs +++ b/Assembly-CSharp/Global/Sd/SdLibAPIWithProLicense.cs @@ -41,7 +41,7 @@ public override Int32 SdSoundSystem_Resume() return SdLibAPI.SdSoundSystem_Resume(); } - public override Int32 SdSoundSystem_AddData(IntPtr akb) + public override Int32 SdSoundSystem_AddData(IntPtr akb, SoundProfile profile) { return SdLibAPI.SdSoundSystem_AddData(akb); } diff --git a/Assembly-CSharp/Global/Sound/Lib/SoundLib.cs b/Assembly-CSharp/Global/Sound/Lib/SoundLib.cs index def78bf7c..6449e18fc 100644 --- a/Assembly-CSharp/Global/Sound/Lib/SoundLib.cs +++ b/Assembly-CSharp/Global/Sound/Lib/SoundLib.cs @@ -21,10 +21,14 @@ public static void PlayMovieMusic(String movieName, Int32 offsetTimeMSec = 0) Int32 movieSoundIndex = SoundLib.GetMovieSoundIndex(movieName); if (movieSoundIndex != -1) { - //if (movieName == "FMV000") - // SoundLib.MovieAudioPlayer.PlayMusic(movieSoundIndex, offsetTimeMSec, SoundProfileType.MovieAudio); - //else - SoundLib.MovieAudioPlayer.PlayMusic(movieSoundIndex, offsetTimeMSec, SoundProfileType.MovieAudio); + if (movieName == "FMV000") + { + SoundLib.MusicPlayer.PlayMusic(movieSoundIndex, offsetTimeMSec, SoundProfileType.MovieAudio); + } + else + { + SoundLib.MovieAudioPlayer.PlayMusic(movieSoundIndex, offsetTimeMSec, SoundProfileType.MovieAudio); + } } else { @@ -150,9 +154,7 @@ public static void StopMovieMusic(String movieName, Boolean isForceStop = false) } else if (String.Equals(movieName, "FMV000")) { - Int32 ticks = 90; - Int32 fadeOut = AllSoundDispatchPlayer.ConvertTickToMillisec(ticks); - SoundLib.MovieAudioPlayer.StopMusic(fadeOut); + SoundLib.MusicPlayer.StopMusic(AllSoundDispatchPlayer.MINIMUM_SONG_FADE_MS); } else { diff --git a/Assembly-CSharp/Global/Sound/Loader/SoundImporter.cs b/Assembly-CSharp/Global/Sound/Loader/SoundImporter.cs index e7c2ca73c..d45f0909f 100644 --- a/Assembly-CSharp/Global/Sound/Loader/SoundImporter.cs +++ b/Assembly-CSharp/Global/Sound/Loader/SoundImporter.cs @@ -43,7 +43,7 @@ public override void Load(SoundProfile profile, ResultCallback callback, SoundDa try { - Int32 bankID = ISdLibAPIProxy.Instance.SdSoundSystem_AddData(akbData); + Int32 bankID = ISdLibAPIProxy.Instance.SdSoundSystem_AddData(akbData, profile); profile.AkbBin = akbData; profile.BankID = bankID; } diff --git a/Assembly-CSharp/Global/Sound/Loader/SoundLoaderDocumentDirectory.cs b/Assembly-CSharp/Global/Sound/Loader/SoundLoaderDocumentDirectory.cs index 8a763e93b..4827e6008 100644 --- a/Assembly-CSharp/Global/Sound/Loader/SoundLoaderDocumentDirectory.cs +++ b/Assembly-CSharp/Global/Sound/Loader/SoundLoaderDocumentDirectory.cs @@ -43,7 +43,7 @@ public override void Load(SoundProfile profile, ISoundLoader.ResultCallback call Byte[] source = File.ReadAllBytes(text); IntPtr intPtr = Marshal.AllocHGlobal((Int32)fileInfo.Length); Marshal.Copy(source, 0, intPtr, (Int32)fileInfo.Length); - Int32 bankID = ISdLibAPIProxy.Instance.SdSoundSystem_AddData(intPtr); + Int32 bankID = ISdLibAPIProxy.Instance.SdSoundSystem_AddData(intPtr, profile); profile.AkbBin = intPtr; profile.BankID = bankID; callback(profile, soundDatabase); diff --git a/Assembly-CSharp/Global/Sound/Loader/SoundLoaderResources.cs b/Assembly-CSharp/Global/Sound/Loader/SoundLoaderResources.cs index 617e67ae9..8f3f9410f 100644 --- a/Assembly-CSharp/Global/Sound/Loader/SoundLoaderResources.cs +++ b/Assembly-CSharp/Global/Sound/Loader/SoundLoaderResources.cs @@ -67,7 +67,7 @@ public override void Load(SoundProfile profile, ISoundLoader.ResultCallback call } Marshal.Copy(akbHeader.WriteToBytes(), 0, intPtr, 304); } - Int32 bankID = ISdLibAPIProxy.Instance.SdSoundSystem_AddData(intPtr); + Int32 bankID = ISdLibAPIProxy.Instance.SdSoundSystem_AddData(intPtr, profile); profile.AkbBin = intPtr; profile.BankID = bankID; callback(profile, soundDatabase); diff --git a/Assembly-CSharp/Global/Sound/Loader/SoundLoaderStreamingAssets.cs b/Assembly-CSharp/Global/Sound/Loader/SoundLoaderStreamingAssets.cs index 4d5d340f6..acab10358 100644 --- a/Assembly-CSharp/Global/Sound/Loader/SoundLoaderStreamingAssets.cs +++ b/Assembly-CSharp/Global/Sound/Loader/SoundLoaderStreamingAssets.cs @@ -31,7 +31,7 @@ public override void Load(SoundProfile profile, ISoundLoader.ResultCallback call { IntPtr intPtr = Marshal.AllocHGlobal((Int32)fileInfo.Length); Marshal.Copy(array, 0, intPtr, (Int32)fileInfo.Length); - Int32 bankID = ISdLibAPIProxy.Instance.SdSoundSystem_AddData(intPtr); + Int32 bankID = ISdLibAPIProxy.Instance.SdSoundSystem_AddData(intPtr, profile); profile.AkbBin = intPtr; profile.BankID = bankID; } diff --git a/Assembly-CSharp/Global/Sound/MusicPlayer.cs b/Assembly-CSharp/Global/Sound/MusicPlayer.cs index c6e31fcb0..d9db78efc 100644 --- a/Assembly-CSharp/Global/Sound/MusicPlayer.cs +++ b/Assembly-CSharp/Global/Sound/MusicPlayer.cs @@ -163,17 +163,17 @@ public void PlayMusic(SoundProfile soundProfileFromIndex, Int32 fadeIn) private void StartSoundCrossfadeIn(SoundProfile soundProfile) { - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); if (ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_IsExist(soundProfile.SoundID) == 0) { SoundLib.Log("failed to play sound"); soundProfile.SoundID = 0; return; - } - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, 0f, 0); + } + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, 0f, 0); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * this.Volume, (Int32)(this.fadeInDuration * 1000f)); this.SetMusicPanning(this.playerPanning, soundProfile); this.SetMusicPitch(this.playerPitch, soundProfile); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); this.upcomingSoundProfile = soundProfile; } @@ -302,13 +302,19 @@ public void SeekActiveSound(Int32 offsetTimeMSec) SoundLib.Log("(activeSoundProfile == null"); return; } - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Stop(this.activeSoundProfile.SoundID, 0); - this.activeSoundProfile.SoundID = ISdLibAPIProxy.Instance.SdSoundSystem_CreateSound(this.activeSoundProfile.BankID); - Int32 num = ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(this.activeSoundProfile.SoundID, offsetTimeMSec); - if (num != 0) + if (Configuration.Audio.Backend == 0) { - SoundLib.LogError("startSoundErrno errors with value: " + num); + Single volume = ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_GetVolume(this.activeSoundProfile.SoundID); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Stop(this.activeSoundProfile.SoundID, 0); + this.activeSoundProfile.SoundID = ISdLibAPIProxy.Instance.SdSoundSystem_CreateSound(this.activeSoundProfile.BankID); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(this.activeSoundProfile.SoundID, volume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(this.activeSoundProfile.SoundID, offsetTimeMSec); } + else + { + // This will seek with Soloud + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(this.activeSoundProfile.SoundID, offsetTimeMSec); + } } public override void Update() diff --git a/Assembly-CSharp/Global/Sound/SoLoud/Bus.cs b/Assembly-CSharp/Global/Sound/SoLoud/Bus.cs new file mode 100644 index 000000000..1ee077e16 --- /dev/null +++ b/Assembly-CSharp/Global/Sound/SoLoud/Bus.cs @@ -0,0 +1,225 @@ +using SoLoud; +using System; +using System.Runtime.InteropServices; + +namespace Global.Sound.SoLoud +{ + public class Bus : SoloudObject + { + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_create")] + internal static extern IntPtr Bus_create(); + public Bus() + { + objhandle = Bus_create(); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_destroy")] + internal static extern IntPtr Bus_destroy(IntPtr aObjHandle); + ~Bus() + { + Bus_destroy(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_setFilter")] + internal static extern void Bus_setFilter(IntPtr aObjHandle, uint aFilterId, IntPtr aFilter); + public void setFilter(uint aFilterId, SoloudObject aFilter) + { + Bus_setFilter(objhandle, aFilterId, aFilter.objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_playEx")] + internal static extern uint Bus_playEx(IntPtr aObjHandle, IntPtr aSound, float aVolume, float aPan, int aPaused); + public uint play(SoloudObject aSound, float aVolume = 1.0f, float aPan = 0.0f, int aPaused = 0) + { + return Bus_playEx(objhandle, aSound.objhandle, aVolume, aPan, aPaused); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_playClockedEx")] + internal static extern uint Bus_playClockedEx(IntPtr aObjHandle, double aSoundTime, IntPtr aSound, float aVolume, float aPan); + public uint playClocked(double aSoundTime, SoloudObject aSound, float aVolume = 1.0f, float aPan = 0.0f) + { + return Bus_playClockedEx(objhandle, aSoundTime, aSound.objhandle, aVolume, aPan); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_play3dEx")] + internal static extern uint Bus_play3dEx(IntPtr aObjHandle, IntPtr aSound, float aPosX, float aPosY, float aPosZ, float aVelX, float aVelY, float aVelZ, float aVolume, int aPaused); + public uint play3d(SoloudObject aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f, int aPaused = 0) + { + return Bus_play3dEx(objhandle, aSound.objhandle, aPosX, aPosY, aPosZ, aVelX, aVelY, aVelZ, aVolume, aPaused); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_play3dClockedEx")] + internal static extern uint Bus_play3dClockedEx(IntPtr aObjHandle, double aSoundTime, IntPtr aSound, float aPosX, float aPosY, float aPosZ, float aVelX, float aVelY, float aVelZ, float aVolume); + public uint play3dClocked(double aSoundTime, SoloudObject aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f) + { + return Bus_play3dClockedEx(objhandle, aSoundTime, aSound.objhandle, aPosX, aPosY, aPosZ, aVelX, aVelY, aVelZ, aVolume); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_setChannels")] + internal static extern int Bus_setChannels(IntPtr aObjHandle, uint aChannels); + public int setChannels(uint aChannels) + { + return Bus_setChannels(objhandle, aChannels); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_setVisualizationEnable")] + internal static extern void Bus_setVisualizationEnable(IntPtr aObjHandle, int aEnable); + public void setVisualizationEnable(int aEnable) + { + Bus_setVisualizationEnable(objhandle, aEnable); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_annexSound")] + internal static extern void Bus_annexSound(IntPtr aObjHandle, uint aVoiceHandle); + public void annexSound(uint aVoiceHandle) + { + Bus_annexSound(objhandle, aVoiceHandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_calcFFT")] + internal static extern IntPtr Bus_calcFFT(IntPtr aObjHandle); + public float[] calcFFT() + { + float[] ret = new float[256]; + IntPtr p = Bus_calcFFT(objhandle); + + byte[] buffer = new byte[4]; + for (int i = 0; i < ret.Length; ++i) + { + int f_bits = Marshal.ReadInt32(p, i * 4); + buffer[0] = (byte)((f_bits >> 0) & 0xff); + buffer[1] = (byte)((f_bits >> 8) & 0xff); + buffer[2] = (byte)((f_bits >> 16) & 0xff); + buffer[3] = (byte)((f_bits >> 24) & 0xff); + ret[i] = BitConverter.ToSingle(buffer, 0); + } + return ret; + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_getWave")] + internal static extern IntPtr Bus_getWave(IntPtr aObjHandle); + public float[] getWave() + { + float[] ret = new float[256]; + IntPtr p = Bus_getWave(objhandle); + + byte[] buffer = new byte[4]; + for (int i = 0; i < ret.Length; ++i) + { + int f_bits = Marshal.ReadInt32(p, i * 4); + buffer[0] = (byte)((f_bits >> 0) & 0xff); + buffer[1] = (byte)((f_bits >> 8) & 0xff); + buffer[2] = (byte)((f_bits >> 16) & 0xff); + buffer[3] = (byte)((f_bits >> 24) & 0xff); + ret[i] = BitConverter.ToSingle(buffer, 0); + } + return ret; + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_getApproximateVolume")] + internal static extern float Bus_getApproximateVolume(IntPtr aObjHandle, uint aChannel); + public float getApproximateVolume(uint aChannel) + { + return Bus_getApproximateVolume(objhandle, aChannel); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_getActiveVoiceCount")] + internal static extern uint Bus_getActiveVoiceCount(IntPtr aObjHandle); + public uint getActiveVoiceCount() + { + return Bus_getActiveVoiceCount(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_setVolume")] + internal static extern void Bus_setVolume(IntPtr aObjHandle, float aVolume); + public void setVolume(float aVolume) + { + Bus_setVolume(objhandle, aVolume); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_setLooping")] + internal static extern void Bus_setLooping(IntPtr aObjHandle, int aLoop); + public void setLooping(int aLoop) + { + Bus_setLooping(objhandle, aLoop); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_set3dMinMaxDistance")] + internal static extern void Bus_set3dMinMaxDistance(IntPtr aObjHandle, float aMinDistance, float aMaxDistance); + public void set3dMinMaxDistance(float aMinDistance, float aMaxDistance) + { + Bus_set3dMinMaxDistance(objhandle, aMinDistance, aMaxDistance); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_set3dAttenuation")] + internal static extern void Bus_set3dAttenuation(IntPtr aObjHandle, uint aAttenuationModel, float aAttenuationRolloffFactor); + public void set3dAttenuation(uint aAttenuationModel, float aAttenuationRolloffFactor) + { + Bus_set3dAttenuation(objhandle, aAttenuationModel, aAttenuationRolloffFactor); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_set3dDopplerFactor")] + internal static extern void Bus_set3dDopplerFactor(IntPtr aObjHandle, float aDopplerFactor); + public void set3dDopplerFactor(float aDopplerFactor) + { + Bus_set3dDopplerFactor(objhandle, aDopplerFactor); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_set3dListenerRelative")] + internal static extern void Bus_set3dListenerRelative(IntPtr aObjHandle, int aListenerRelative); + public void set3dListenerRelative(int aListenerRelative) + { + Bus_set3dListenerRelative(objhandle, aListenerRelative); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_set3dDistanceDelay")] + internal static extern void Bus_set3dDistanceDelay(IntPtr aObjHandle, int aDistanceDelay); + public void set3dDistanceDelay(int aDistanceDelay) + { + Bus_set3dDistanceDelay(objhandle, aDistanceDelay); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_set3dColliderEx")] + internal static extern void Bus_set3dColliderEx(IntPtr aObjHandle, IntPtr aCollider, int aUserData); + public void set3dCollider(SoloudObject aCollider, int aUserData = 0) + { + Bus_set3dColliderEx(objhandle, aCollider.objhandle, aUserData); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_set3dAttenuator")] + internal static extern void Bus_set3dAttenuator(IntPtr aObjHandle, IntPtr aAttenuator); + public void set3dAttenuator(SoloudObject aAttenuator) + { + Bus_set3dAttenuator(objhandle, aAttenuator.objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_setInaudibleBehavior")] + internal static extern void Bus_setInaudibleBehavior(IntPtr aObjHandle, int aMustTick, int aKill); + public void setInaudibleBehavior(int aMustTick, int aKill) + { + Bus_setInaudibleBehavior(objhandle, aMustTick, aKill); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_setLoopPoint")] + internal static extern void Bus_setLoopPoint(IntPtr aObjHandle, double aLoopPoint); + public void setLoopPoint(double aLoopPoint) + { + Bus_setLoopPoint(objhandle, aLoopPoint); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_getLoopPoint")] + internal static extern double Bus_getLoopPoint(IntPtr aObjHandle); + public double getLoopPoint() + { + return Bus_getLoopPoint(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Bus_stop")] + internal static extern void Bus_stop(IntPtr aObjHandle); + public void stop() + { + Bus_stop(objhandle); + } + } +} diff --git a/Assembly-CSharp/Global/Sound/SoLoud/Queue.cs b/Assembly-CSharp/Global/Sound/SoLoud/Queue.cs new file mode 100644 index 000000000..303c6719a --- /dev/null +++ b/Assembly-CSharp/Global/Sound/SoLoud/Queue.cs @@ -0,0 +1,157 @@ +using SoLoud; +using System; +using System.Runtime.InteropServices; + +namespace Global.Sound.SoLoud +{ + public class Queue : SoloudObject + { + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Queue_create")] + internal static extern IntPtr Queue_create(); + public Queue() + { + objhandle = Queue_create(); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Queue_destroy")] + internal static extern IntPtr Queue_destroy(IntPtr aObjHandle); + ~Queue() + { + Queue_destroy(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Queue_play")] + internal static extern int Queue_play(IntPtr aObjHandle, IntPtr aSound); + public int play(SoloudObject aSound) + { + return Queue_play(objhandle, aSound.objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Queue_getQueueCount")] + internal static extern uint Queue_getQueueCount(IntPtr aObjHandle); + public uint getQueueCount() + { + return Queue_getQueueCount(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Queue_isCurrentlyPlaying")] + internal static extern int Queue_isCurrentlyPlaying(IntPtr aObjHandle, IntPtr aSound); + public int isCurrentlyPlaying(SoloudObject aSound) + { + return Queue_isCurrentlyPlaying(objhandle, aSound.objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Queue_setParamsFromAudioSource")] + internal static extern int Queue_setParamsFromAudioSource(IntPtr aObjHandle, IntPtr aSound); + public int setParamsFromAudioSource(SoloudObject aSound) + { + return Queue_setParamsFromAudioSource(objhandle, aSound.objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Queue_setParamsEx")] + internal static extern int Queue_setParamsEx(IntPtr aObjHandle, float aSamplerate, uint aChannels); + public int setParams(float aSamplerate, uint aChannels = 2) + { + return Queue_setParamsEx(objhandle, aSamplerate, aChannels); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Queue_setVolume")] + internal static extern void Queue_setVolume(IntPtr aObjHandle, float aVolume); + public void setVolume(float aVolume) + { + Queue_setVolume(objhandle, aVolume); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Queue_setLooping")] + internal static extern void Queue_setLooping(IntPtr aObjHandle, int aLoop); + public void setLooping(int aLoop) + { + Queue_setLooping(objhandle, aLoop); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Queue_set3dMinMaxDistance")] + internal static extern void Queue_set3dMinMaxDistance(IntPtr aObjHandle, float aMinDistance, float aMaxDistance); + public void set3dMinMaxDistance(float aMinDistance, float aMaxDistance) + { + Queue_set3dMinMaxDistance(objhandle, aMinDistance, aMaxDistance); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Queue_set3dAttenuation")] + internal static extern void Queue_set3dAttenuation(IntPtr aObjHandle, uint aAttenuationModel, float aAttenuationRolloffFactor); + public void set3dAttenuation(uint aAttenuationModel, float aAttenuationRolloffFactor) + { + Queue_set3dAttenuation(objhandle, aAttenuationModel, aAttenuationRolloffFactor); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Queue_set3dDopplerFactor")] + internal static extern void Queue_set3dDopplerFactor(IntPtr aObjHandle, float aDopplerFactor); + public void set3dDopplerFactor(float aDopplerFactor) + { + Queue_set3dDopplerFactor(objhandle, aDopplerFactor); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Queue_set3dListenerRelative")] + internal static extern void Queue_set3dListenerRelative(IntPtr aObjHandle, int aListenerRelative); + public void set3dListenerRelative(int aListenerRelative) + { + Queue_set3dListenerRelative(objhandle, aListenerRelative); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Queue_set3dDistanceDelay")] + internal static extern void Queue_set3dDistanceDelay(IntPtr aObjHandle, int aDistanceDelay); + public void set3dDistanceDelay(int aDistanceDelay) + { + Queue_set3dDistanceDelay(objhandle, aDistanceDelay); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Queue_set3dColliderEx")] + internal static extern void Queue_set3dColliderEx(IntPtr aObjHandle, IntPtr aCollider, int aUserData); + public void set3dCollider(SoloudObject aCollider, int aUserData = 0) + { + Queue_set3dColliderEx(objhandle, aCollider.objhandle, aUserData); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Queue_set3dAttenuator")] + internal static extern void Queue_set3dAttenuator(IntPtr aObjHandle, IntPtr aAttenuator); + public void set3dAttenuator(SoloudObject aAttenuator) + { + Queue_set3dAttenuator(objhandle, aAttenuator.objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Queue_setInaudibleBehavior")] + internal static extern void Queue_setInaudibleBehavior(IntPtr aObjHandle, int aMustTick, int aKill); + public void setInaudibleBehavior(int aMustTick, int aKill) + { + Queue_setInaudibleBehavior(objhandle, aMustTick, aKill); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Queue_setLoopPoint")] + internal static extern void Queue_setLoopPoint(IntPtr aObjHandle, double aLoopPoint); + public void setLoopPoint(double aLoopPoint) + { + Queue_setLoopPoint(objhandle, aLoopPoint); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Queue_getLoopPoint")] + internal static extern double Queue_getLoopPoint(IntPtr aObjHandle); + public double getLoopPoint() + { + return Queue_getLoopPoint(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Queue_setFilter")] + internal static extern void Queue_setFilter(IntPtr aObjHandle, uint aFilterId, IntPtr aFilter); + public void setFilter(uint aFilterId, SoloudObject aFilter) + { + Queue_setFilter(objhandle, aFilterId, aFilter.objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Queue_stop")] + internal static extern void Queue_stop(IntPtr aObjHandle); + public void stop() + { + Queue_stop(objhandle); + } + } +} diff --git a/Assembly-CSharp/Global/Sound/SoLoud/SdLibAPIWithSoloud.cs b/Assembly-CSharp/Global/Sound/SoLoud/SdLibAPIWithSoloud.cs new file mode 100644 index 000000000..ba263969c --- /dev/null +++ b/Assembly-CSharp/Global/Sound/SoLoud/SdLibAPIWithSoloud.cs @@ -0,0 +1,333 @@ +using Memoria.Prime; +using Memoria.Prime.AKB2; +using SoLoud; +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using UnityEngine; + +namespace Global.Sound.SoLoud +{ + internal class SdLibAPIWithSoloud : ISdLibAPI + { + public static bool isQuitting = false; + + private const Int32 AkbHeaderSize = 304; + + private static Soloud soloud = null; + private static Bus sfxBus = null; + private static Bus voiceBus = null; + + private class StreamInfo + { + public AKB2Header akbHeader; + public WavStream data; + public SoundProfile profile; + } + + private class Sound + { + public Sound(Int32 BankID) + { + bankID = BankID; + } + public Int32 bankID; + public Single volume = 1f; + } + + private Dictionary streams = new Dictionary(); + private Dictionary sounds = new Dictionary(); + + private void CleanUpSounds() + { + List toRemove = new List(); + foreach (var id in sounds.Keys) + { + if (soloud.isValidVoiceHandle((uint)id) == 0) toRemove.Add(id); + } + foreach (var id in toRemove) + { + sounds.Remove(id); + } + SoundLib.Log($"Total sounds: {sounds.Count}"); + } + + public override Int32 SdSoundSystem_Create(String config) + { + SoundLib.Log("Create"); + // Initialize SoLoud + if (soloud == null) + { + soloud = new Soloud(); + soloud.init(1, 0, 48000); + Log.Message($"[Soloud] backend: {soloud.getBackendString()} samplerate:{soloud.getBackendSamplerate()}"); + + // Create buses + sfxBus = new Bus(); + voiceBus = new Bus(); + soloud.play(sfxBus, 1); + soloud.play(voiceBus, 1); + + GameLoopManager.Quit += () => { isQuitting = true; }; + } + + return 0; + } + + public override void SdSoundSystem_Release() + { + SoundLib.Log("Release"); + + soloud.stopAll(); + streams.Clear(); + soloud.deinit(); + } + + public override Int32 SdSoundSystem_Suspend() + { + SoundLib.Log("Suspend"); + soloud.setPauseAll(1); + return 0; + } + + public override Int32 SdSoundSystem_Resume() + { + SoundLib.Log("Resume"); + soloud.setPauseAll(0); + return 0; + } + + public override Int32 SdSoundSystem_AddData(IntPtr akb, SoundProfile profile) + { + SoundLib.Log($"AddData({akb})"); + unsafe + { + // Get the akb header + Byte[] akbBin = new byte[304]; + Marshal.Copy(akb, akbBin, 0, 304); + + StreamInfo stream = new StreamInfo(); + stream.akbHeader.ReadFromBytes(akbBin); + stream.data = new WavStream(); + stream.data.loadMem((IntPtr)((Byte*)akb + AkbHeaderSize), (uint)stream.akbHeader.ContentSize, true, true); + stream.profile = profile; + + Int32 bankID = (Int32)stream.data.objhandle; + streams.Add(bankID, stream); + return bankID; + } + } + + public override Int32 SdSoundSystem_AddStreamDataFromPath(String akbpath) + { + // Doesn't seem to be used + SoundLib.Log($"No Implementation - AddStreamDataFromPath({akbpath})"); + return 0; + } + + public override Int32 SdSoundSystem_RemoveData(Int32 bankID) + { + SoundLib.Log($"RemoveData({bankID})"); + return streams.Remove(bankID) ? 1 : 0; + } + + public override Int32 SdSoundSystem_CreateSound(Int32 bankID) + { + SoundLib.Log($"CreateSound({bankID})"); + CleanUpSounds(); + + StreamInfo stream = streams[bankID]; + + Int32 soundID = 0; + switch (stream.profile.SoundProfileType) + { + case SoundProfileType.Sfx: + soundID = (Int32)sfxBus.play(streams[bankID].data, 1, 0, 1); + break; + case SoundProfileType.Voice: + soundID = (Int32)voiceBus.play(streams[bankID].data, 1, 0, 1); + break; + default: + soundID = (Int32)soloud.play(streams[bankID].data, 1, 0, 1); + break; + } + + Sound voice = new Sound(bankID); + sounds.Add(soundID, voice); + + // Is it a loop? + if (stream.akbHeader.LoopEnd > 0) + { + double start = stream.akbHeader.LoopStart / (double)stream.akbHeader.SampleRate; + double end = stream.akbHeader.LoopEnd / (double)stream.akbHeader.SampleRate; + + SoundLib.Log($"LoopStart: {start} LoopEnd: {end} Length: {stream.data.getLength()}"); + + soloud.setLoopStartPoint((uint)soundID, start); + soloud.setLoopEndPoint((uint)soundID, end); + } + + return soundID; + } + + public override Int32 SdSoundSystem_SoundCtrl_GetElapsedPlaybackTime(Int32 soundID) + { + //SoundLib.Log($"SoundCtrl_GetElapsedPlaybackTime({soundID})"); + return (Int32)(soloud.getStreamTime((uint)soundID) * 1000); + } + + public override Int32 SdSoundSystem_SoundCtrl_GetPlayTime(Int32 soundID) + { + // Doesn't seem to be used + SoundLib.Log($"No Implementation - SoundCtrl_GetPlayTime({soundID}"); + return 0; + } + + public override Int32 SdSoundSystem_SoundCtrl_Start(Int32 soundID, Int32 offsetTimeMSec) + { + SoundLib.Log($"SoundCtrl_Start({soundID}, {offsetTimeMSec})"); + if (!sounds.ContainsKey(soundID)) return 0; + + if (offsetTimeMSec > 0) + { + soloud.seek((uint)soundID, offsetTimeMSec / 1000d); + } + soloud.setPause((uint)soundID, 0); + + return 1; + } + + public override void SdSoundSystem_SoundCtrl_Stop(Int32 soundID, Int32 transTimeMSec) + { + SoundLib.Log($"SoundCtrl_Stop({soundID}, {transTimeMSec})"); + if (!sounds.ContainsKey(soundID)) return; + + if (transTimeMSec < 100) transTimeMSec = 100; // Add a small fade + + soloud.fadeVolume((uint)soundID, 0, transTimeMSec / 1000d); + soloud.scheduleStop((uint)soundID, transTimeMSec / 1000d); + } + + public override Int32 SdSoundSystem_SoundCtrl_IsExist(Int32 soundID) + { + return soloud.isValidVoiceHandle((uint)soundID); ; + } + + public override void SdSoundSystem_SoundCtrl_SetPause(Int32 soundID, Int32 pauseOn, Int32 transTimeMSec) + { + SoundLib.Log($"SoundCtrl_SetPause({soundID}, {pauseOn}, {transTimeMSec})"); + if (!sounds.ContainsKey(soundID)) return; + + uint h = (uint)soundID; + double t = transTimeMSec / 1000d; + + if (transTimeMSec > 0) + { + if (pauseOn != 0) + { + soloud.fadeVolume(h, 0, t); + soloud.schedulePause(h, t); + } + else + { + soloud.setPause(h, pauseOn); + soloud.setVolume(h, 0); + soloud.fadeVolume(h, sounds[soundID].volume, t); + } + } + else + { + //Should a small fade (100ms) be added? + soloud.setPause(h, pauseOn); + soloud.setVolume(h, sounds[soundID].volume); + } + } + + public override Int32 SdSoundSystem_SoundCtrl_IsPaused(Int32 soundID) + { + SoundLib.Log("SoundCtrl_IsPaused"); + return soloud.getPause((uint)soundID); + } + + public override void SdSoundSystem_SoundCtrl_SetVolume(Int32 soundID, Single volume, Int32 transTimeMSec) + { + SoundLib.Log($"SoundCtrl_SetVolume({soundID}, {volume}, {transTimeMSec})"); + if (!sounds.ContainsKey(soundID)) return; + + if (volume < 0f || volume > 1f) Log.Message($"[SoLoud] Warning! Unexpected volume value. Volume = {volume} SoundID = {soundID}\n{Environment.StackTrace}"); + volume = Mathf.Clamp01(volume); + sounds[soundID].volume = volume; + + if (transTimeMSec > 0) + { + soloud.fadeVolume((uint)soundID, volume, transTimeMSec / 1000d); + } + else + { + soloud.setVolume((uint)soundID, volume); + } + } + + public override Single SdSoundSystem_SoundCtrl_GetVolume(Int32 soundID) + { + SoundLib.Log($"SoundCtrl_GetVolume({soundID})"); + return soloud.getVolume((uint)soundID); + } + + public override void SdSoundSystem_SoundCtrl_SetPitch(Int32 soundID, Single pitch, Int32 transTimeMSec) + { + // Soloud doesn't handle pitch (yet) + SoundLib.Log($"SoundCtrl_SetPitch({soundID}, {pitch}, {transTimeMSec})"); + + // Play at different speed (changes the pitch) + if (transTimeMSec > 0) + { + soloud.fadeRelativePlaySpeed((uint)soundID, pitch, transTimeMSec / 1000d); + } + else + { + soloud.setRelativePlaySpeed((uint)soundID, pitch); + } + } + + public override void SdSoundSystem_SoundCtrl_SetPanning(Int32 soundID, Single panning, Int32 transTimeMSec) + { + SoundLib.Log($"SoundCtrl_SetPanning({soundID}, {panning}, {transTimeMSec})"); + if (!sounds.ContainsKey(soundID)) return; + + if (transTimeMSec > 0) + { + soloud.fadePan((uint)soundID, panning, transTimeMSec / 1000d); + } + else + { + soloud.setPan((uint)soundID, panning); + } + } + + public override void SdSoundSystem_SoundCtrl_SetNextLoopRegion(Int32 soundID) + { + SoundLib.Log($"SoundCtrl_SetNextLoopRegion({soundID})"); + if (!sounds.ContainsKey(soundID)) return; + + StreamInfo stream = streams[sounds[soundID].bankID]; + if (stream.akbHeader.LoopEndAlternate > 0) + { + double start = stream.akbHeader.LoopStartAlternate / (double)stream.akbHeader.SampleRate; + double end = stream.akbHeader.LoopEndAlternate / (double)stream.akbHeader.SampleRate; + + SoundLib.Log($"LoopStart: ({start}) LoopEnd: {end}"); + + soloud.setLoopStartPoint((uint)soundID, start); + soloud.setLoopEndPoint((uint)soundID, end); + } + } + + public override Int32 SdSoundSystem_BankCtrl_IsLoop(Int32 bankID, Int32 soundID) + { + // Doesn't seem to be used + SoundLib.Log($"No Implementation - BankCtrl_IsLoop({bankID}, {soundID})"); + return 0; + } + } +} diff --git a/Assembly-CSharp/Global/Sound/SoLoud/Soloud.cs b/Assembly-CSharp/Global/Sound/SoLoud/Soloud.cs new file mode 100644 index 000000000..13c90a5f9 --- /dev/null +++ b/Assembly-CSharp/Global/Sound/SoLoud/Soloud.cs @@ -0,0 +1,755 @@ + +// SoLoud wrapper for C# (cs) +// This file is autogenerated; any changes will be overwritten + +using System; +using System.Runtime.InteropServices; + +namespace SoLoud +{ + + public class SoloudObject + { + public IntPtr objhandle; + } + + public class Soloud : SoloudObject + { + public const int AUTO = 0; + public const int SDL1 = 1; + public const int SDL2 = 2; + public const int PORTAUDIO = 3; + public const int WINMM = 4; + public const int XAUDIO2 = 5; + public const int WASAPI = 6; + public const int ALSA = 7; + public const int JACK = 8; + public const int OSS = 9; + public const int OPENAL = 10; + public const int COREAUDIO = 11; + public const int OPENSLES = 12; + public const int VITA_HOMEBREW = 13; + public const int MINIAUDIO = 14; + public const int NOSOUND = 15; + public const int NULLDRIVER = 16; + public const int BACKEND_MAX = 17; + public const int CLIP_ROUNDOFF = 1; + public const int ENABLE_VISUALIZATION = 2; + public const int LEFT_HANDED_3D = 4; + public const int NO_FPU_REGISTER_CHANGE = 8; + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_create")] + internal static extern IntPtr Soloud_create(); + public Soloud() + { + objhandle = Soloud_create(); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_destroy")] + internal static extern IntPtr Soloud_destroy(IntPtr aObjHandle); + ~Soloud() + { + Soloud_destroy(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_initEx")] + internal static extern int Soloud_initEx(IntPtr aObjHandle, uint aFlags, uint aBackend, uint aSamplerate, uint aBufferSize, uint aChannels); + public int init(uint aFlags = CLIP_ROUNDOFF, uint aBackend = AUTO, uint aSamplerate = AUTO, uint aBufferSize = AUTO, uint aChannels = 2) + { + return Soloud_initEx(objhandle, aFlags, aBackend, aSamplerate, aBufferSize, aChannels); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_deinit")] + internal static extern void Soloud_deinit(IntPtr aObjHandle); + public void deinit() + { + Soloud_deinit(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getVersion")] + internal static extern uint Soloud_getVersion(IntPtr aObjHandle); + public uint getVersion() + { + return Soloud_getVersion(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getErrorString")] + internal static extern IntPtr Soloud_getErrorString(IntPtr aObjHandle, int aErrorCode); + public string getErrorString(int aErrorCode) + { + IntPtr p = Soloud_getErrorString(objhandle, aErrorCode); + return Marshal.PtrToStringAnsi(p); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getBackendId")] + internal static extern uint Soloud_getBackendId(IntPtr aObjHandle); + public uint getBackendId() + { + return Soloud_getBackendId(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getBackendString")] + internal static extern IntPtr Soloud_getBackendString(IntPtr aObjHandle); + public string getBackendString() + { + IntPtr p = Soloud_getBackendString(objhandle); + return Marshal.PtrToStringAnsi(p); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getBackendChannels")] + internal static extern uint Soloud_getBackendChannels(IntPtr aObjHandle); + public uint getBackendChannels() + { + return Soloud_getBackendChannels(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getBackendSamplerate")] + internal static extern uint Soloud_getBackendSamplerate(IntPtr aObjHandle); + public uint getBackendSamplerate() + { + return Soloud_getBackendSamplerate(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getBackendBufferSize")] + internal static extern uint Soloud_getBackendBufferSize(IntPtr aObjHandle); + public uint getBackendBufferSize() + { + return Soloud_getBackendBufferSize(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_setSpeakerPosition")] + internal static extern int Soloud_setSpeakerPosition(IntPtr aObjHandle, uint aChannel, float aX, float aY, float aZ); + public int setSpeakerPosition(uint aChannel, float aX, float aY, float aZ) + { + return Soloud_setSpeakerPosition(objhandle, aChannel, aX, aY, aZ); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getSpeakerPosition")] + internal static extern int Soloud_getSpeakerPosition(IntPtr aObjHandle, uint aChannel, float[] aX, float[] aY, float[] aZ); + public int getSpeakerPosition(uint aChannel, float[] aX, float[] aY, float[] aZ) + { + return Soloud_getSpeakerPosition(objhandle, aChannel, aX, aY, aZ); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_playEx")] + internal static extern uint Soloud_playEx(IntPtr aObjHandle, IntPtr aSound, float aVolume, float aPan, int aPaused, uint aBus); + public uint play(SoloudObject aSound, float aVolume = -1.0f, float aPan = 0.0f, int aPaused = 0, uint aBus = 0) + { + return Soloud_playEx(objhandle, aSound.objhandle, aVolume, aPan, aPaused, aBus); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_playClockedEx")] + internal static extern uint Soloud_playClockedEx(IntPtr aObjHandle, double aSoundTime, IntPtr aSound, float aVolume, float aPan, uint aBus); + public uint playClocked(double aSoundTime, SoloudObject aSound, float aVolume = -1.0f, float aPan = 0.0f, uint aBus = 0) + { + return Soloud_playClockedEx(objhandle, aSoundTime, aSound.objhandle, aVolume, aPan, aBus); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_play3dEx")] + internal static extern uint Soloud_play3dEx(IntPtr aObjHandle, IntPtr aSound, float aPosX, float aPosY, float aPosZ, float aVelX, float aVelY, float aVelZ, float aVolume, int aPaused, uint aBus); + public uint play3d(SoloudObject aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f, int aPaused = 0, uint aBus = 0) + { + return Soloud_play3dEx(objhandle, aSound.objhandle, aPosX, aPosY, aPosZ, aVelX, aVelY, aVelZ, aVolume, aPaused, aBus); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_play3dClockedEx")] + internal static extern uint Soloud_play3dClockedEx(IntPtr aObjHandle, double aSoundTime, IntPtr aSound, float aPosX, float aPosY, float aPosZ, float aVelX, float aVelY, float aVelZ, float aVolume, uint aBus); + public uint play3dClocked(double aSoundTime, SoloudObject aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f, uint aBus = 0) + { + return Soloud_play3dClockedEx(objhandle, aSoundTime, aSound.objhandle, aPosX, aPosY, aPosZ, aVelX, aVelY, aVelZ, aVolume, aBus); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_playBackgroundEx")] + internal static extern uint Soloud_playBackgroundEx(IntPtr aObjHandle, IntPtr aSound, float aVolume, int aPaused, uint aBus); + public uint playBackground(SoloudObject aSound, float aVolume = -1.0f, int aPaused = 0, uint aBus = 0) + { + return Soloud_playBackgroundEx(objhandle, aSound.objhandle, aVolume, aPaused, aBus); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_seek")] + internal static extern int Soloud_seek(IntPtr aObjHandle, uint aVoiceHandle, double aSeconds); + public int seek(uint aVoiceHandle, double aSeconds) + { + return Soloud_seek(objhandle, aVoiceHandle, aSeconds); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_stop")] + internal static extern void Soloud_stop(IntPtr aObjHandle, uint aVoiceHandle); + public void stop(uint aVoiceHandle) + { + Soloud_stop(objhandle, aVoiceHandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_stopAll")] + internal static extern void Soloud_stopAll(IntPtr aObjHandle); + public void stopAll() + { + Soloud_stopAll(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_stopAudioSource")] + internal static extern void Soloud_stopAudioSource(IntPtr aObjHandle, IntPtr aSound); + public void stopAudioSource(SoloudObject aSound) + { + Soloud_stopAudioSource(objhandle, aSound.objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_countAudioSource")] + internal static extern int Soloud_countAudioSource(IntPtr aObjHandle, IntPtr aSound); + public int countAudioSource(SoloudObject aSound) + { + return Soloud_countAudioSource(objhandle, aSound.objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_setFilterParameter")] + internal static extern void Soloud_setFilterParameter(IntPtr aObjHandle, uint aVoiceHandle, uint aFilterId, uint aAttributeId, float aValue); + public void setFilterParameter(uint aVoiceHandle, uint aFilterId, uint aAttributeId, float aValue) + { + Soloud_setFilterParameter(objhandle, aVoiceHandle, aFilterId, aAttributeId, aValue); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getFilterParameter")] + internal static extern float Soloud_getFilterParameter(IntPtr aObjHandle, uint aVoiceHandle, uint aFilterId, uint aAttributeId); + public float getFilterParameter(uint aVoiceHandle, uint aFilterId, uint aAttributeId) + { + return Soloud_getFilterParameter(objhandle, aVoiceHandle, aFilterId, aAttributeId); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_fadeFilterParameter")] + internal static extern void Soloud_fadeFilterParameter(IntPtr aObjHandle, uint aVoiceHandle, uint aFilterId, uint aAttributeId, float aTo, double aTime); + public void fadeFilterParameter(uint aVoiceHandle, uint aFilterId, uint aAttributeId, float aTo, double aTime) + { + Soloud_fadeFilterParameter(objhandle, aVoiceHandle, aFilterId, aAttributeId, aTo, aTime); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_oscillateFilterParameter")] + internal static extern void Soloud_oscillateFilterParameter(IntPtr aObjHandle, uint aVoiceHandle, uint aFilterId, uint aAttributeId, float aFrom, float aTo, double aTime); + public void oscillateFilterParameter(uint aVoiceHandle, uint aFilterId, uint aAttributeId, float aFrom, float aTo, double aTime) + { + Soloud_oscillateFilterParameter(objhandle, aVoiceHandle, aFilterId, aAttributeId, aFrom, aTo, aTime); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getStreamTime")] + internal static extern double Soloud_getStreamTime(IntPtr aObjHandle, uint aVoiceHandle); + public double getStreamTime(uint aVoiceHandle) + { + return Soloud_getStreamTime(objhandle, aVoiceHandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getStreamPosition")] + internal static extern double Soloud_getStreamPosition(IntPtr aObjHandle, uint aVoiceHandle); + public double getStreamPosition(uint aVoiceHandle) + { + return Soloud_getStreamPosition(objhandle, aVoiceHandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getPause")] + internal static extern int Soloud_getPause(IntPtr aObjHandle, uint aVoiceHandle); + public int getPause(uint aVoiceHandle) + { + return Soloud_getPause(objhandle, aVoiceHandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getVolume")] + internal static extern float Soloud_getVolume(IntPtr aObjHandle, uint aVoiceHandle); + public float getVolume(uint aVoiceHandle) + { + return Soloud_getVolume(objhandle, aVoiceHandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getOverallVolume")] + internal static extern float Soloud_getOverallVolume(IntPtr aObjHandle, uint aVoiceHandle); + public float getOverallVolume(uint aVoiceHandle) + { + return Soloud_getOverallVolume(objhandle, aVoiceHandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getPan")] + internal static extern float Soloud_getPan(IntPtr aObjHandle, uint aVoiceHandle); + public float getPan(uint aVoiceHandle) + { + return Soloud_getPan(objhandle, aVoiceHandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getSamplerate")] + internal static extern float Soloud_getSamplerate(IntPtr aObjHandle, uint aVoiceHandle); + public float getSamplerate(uint aVoiceHandle) + { + return Soloud_getSamplerate(objhandle, aVoiceHandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getProtectVoice")] + internal static extern int Soloud_getProtectVoice(IntPtr aObjHandle, uint aVoiceHandle); + public int getProtectVoice(uint aVoiceHandle) + { + return Soloud_getProtectVoice(objhandle, aVoiceHandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getActiveVoiceCount")] + internal static extern uint Soloud_getActiveVoiceCount(IntPtr aObjHandle); + public uint getActiveVoiceCount() + { + return Soloud_getActiveVoiceCount(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getVoiceCount")] + internal static extern uint Soloud_getVoiceCount(IntPtr aObjHandle); + public uint getVoiceCount() + { + return Soloud_getVoiceCount(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_isValidVoiceHandle")] + internal static extern int Soloud_isValidVoiceHandle(IntPtr aObjHandle, uint aVoiceHandle); + public int isValidVoiceHandle(uint aVoiceHandle) + { + return Soloud_isValidVoiceHandle(objhandle, aVoiceHandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getRelativePlaySpeed")] + internal static extern float Soloud_getRelativePlaySpeed(IntPtr aObjHandle, uint aVoiceHandle); + public float getRelativePlaySpeed(uint aVoiceHandle) + { + return Soloud_getRelativePlaySpeed(objhandle, aVoiceHandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getPostClipScaler")] + internal static extern float Soloud_getPostClipScaler(IntPtr aObjHandle); + public float getPostClipScaler() + { + return Soloud_getPostClipScaler(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getGlobalVolume")] + internal static extern float Soloud_getGlobalVolume(IntPtr aObjHandle); + public float getGlobalVolume() + { + return Soloud_getGlobalVolume(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getMaxActiveVoiceCount")] + internal static extern uint Soloud_getMaxActiveVoiceCount(IntPtr aObjHandle); + public uint getMaxActiveVoiceCount() + { + return Soloud_getMaxActiveVoiceCount(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getLooping")] + internal static extern int Soloud_getLooping(IntPtr aObjHandle, uint aVoiceHandle); + public int getLooping(uint aVoiceHandle) + { + return Soloud_getLooping(objhandle, aVoiceHandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getLoopPoint")] + internal static extern double Soloud_getLoopPoint(IntPtr aObjHandle, uint aVoiceHandle); + public double getLoopPoint(uint aVoiceHandle) + { + return Soloud_getLoopPoint(objhandle, aVoiceHandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_setLoopStartPoint")] + internal static extern void Soloud_setLoopStartPoint(IntPtr aObjHandle, uint aVoiceHandle, double aLoopPoint); + public void setLoopStartPoint(uint aVoiceHandle, double aLoopPoint) + { + Soloud_setLoopStartPoint(objhandle, aVoiceHandle, aLoopPoint); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_setLoopEndPoint")] + internal static extern void Soloud_setLoopEndPoint(IntPtr aObjHandle, uint aVoiceHandle, double aLoopPoint); + public void setLoopEndPoint(uint aVoiceHandle, double aLoopPoint) + { + Soloud_setLoopEndPoint(objhandle, aVoiceHandle, aLoopPoint); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_setLooping")] + internal static extern void Soloud_setLooping(IntPtr aObjHandle, uint aVoiceHandle, int aLooping); + public void setLooping(uint aVoiceHandle, int aLooping) + { + Soloud_setLooping(objhandle, aVoiceHandle, aLooping); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_setMaxActiveVoiceCount")] + internal static extern int Soloud_setMaxActiveVoiceCount(IntPtr aObjHandle, uint aVoiceCount); + public int setMaxActiveVoiceCount(uint aVoiceCount) + { + return Soloud_setMaxActiveVoiceCount(objhandle, aVoiceCount); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_setInaudibleBehavior")] + internal static extern void Soloud_setInaudibleBehavior(IntPtr aObjHandle, uint aVoiceHandle, int aMustTick, int aKill); + public void setInaudibleBehavior(uint aVoiceHandle, int aMustTick, int aKill) + { + Soloud_setInaudibleBehavior(objhandle, aVoiceHandle, aMustTick, aKill); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_setGlobalVolume")] + internal static extern void Soloud_setGlobalVolume(IntPtr aObjHandle, float aVolume); + public void setGlobalVolume(float aVolume) + { + Soloud_setGlobalVolume(objhandle, aVolume); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_setPostClipScaler")] + internal static extern void Soloud_setPostClipScaler(IntPtr aObjHandle, float aScaler); + public void setPostClipScaler(float aScaler) + { + Soloud_setPostClipScaler(objhandle, aScaler); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_setPause")] + internal static extern void Soloud_setPause(IntPtr aObjHandle, uint aVoiceHandle, int aPause); + public void setPause(uint aVoiceHandle, int aPause) + { + Soloud_setPause(objhandle, aVoiceHandle, aPause); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_setPauseAll")] + internal static extern void Soloud_setPauseAll(IntPtr aObjHandle, int aPause); + public void setPauseAll(int aPause) + { + Soloud_setPauseAll(objhandle, aPause); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_setRelativePlaySpeed")] + internal static extern int Soloud_setRelativePlaySpeed(IntPtr aObjHandle, uint aVoiceHandle, float aSpeed); + public int setRelativePlaySpeed(uint aVoiceHandle, float aSpeed) + { + return Soloud_setRelativePlaySpeed(objhandle, aVoiceHandle, aSpeed); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_setProtectVoice")] + internal static extern void Soloud_setProtectVoice(IntPtr aObjHandle, uint aVoiceHandle, int aProtect); + public void setProtectVoice(uint aVoiceHandle, int aProtect) + { + Soloud_setProtectVoice(objhandle, aVoiceHandle, aProtect); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_setSamplerate")] + internal static extern void Soloud_setSamplerate(IntPtr aObjHandle, uint aVoiceHandle, float aSamplerate); + public void setSamplerate(uint aVoiceHandle, float aSamplerate) + { + Soloud_setSamplerate(objhandle, aVoiceHandle, aSamplerate); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_setPan")] + internal static extern void Soloud_setPan(IntPtr aObjHandle, uint aVoiceHandle, float aPan); + public void setPan(uint aVoiceHandle, float aPan) + { + Soloud_setPan(objhandle, aVoiceHandle, aPan); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_setPanAbsoluteEx")] + internal static extern void Soloud_setPanAbsoluteEx(IntPtr aObjHandle, uint aVoiceHandle, float aLVolume, float aRVolume, float aLBVolume, float aRBVolume, float aCVolume, float aSVolume); + public void setPanAbsolute(uint aVoiceHandle, float aLVolume, float aRVolume, float aLBVolume = 0, float aRBVolume = 0, float aCVolume = 0, float aSVolume = 0) + { + Soloud_setPanAbsoluteEx(objhandle, aVoiceHandle, aLVolume, aRVolume, aLBVolume, aRBVolume, aCVolume, aSVolume); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_setVolume")] + internal static extern void Soloud_setVolume(IntPtr aObjHandle, uint aVoiceHandle, float aVolume); + public void setVolume(uint aVoiceHandle, float aVolume) + { + Soloud_setVolume(objhandle, aVoiceHandle, aVolume); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_setDelaySamples")] + internal static extern void Soloud_setDelaySamples(IntPtr aObjHandle, uint aVoiceHandle, uint aSamples); + public void setDelaySamples(uint aVoiceHandle, uint aSamples) + { + Soloud_setDelaySamples(objhandle, aVoiceHandle, aSamples); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_fadeVolume")] + internal static extern void Soloud_fadeVolume(IntPtr aObjHandle, uint aVoiceHandle, float aTo, double aTime); + public void fadeVolume(uint aVoiceHandle, float aTo, double aTime) + { + Soloud_fadeVolume(objhandle, aVoiceHandle, aTo, aTime); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_fadePan")] + internal static extern void Soloud_fadePan(IntPtr aObjHandle, uint aVoiceHandle, float aTo, double aTime); + public void fadePan(uint aVoiceHandle, float aTo, double aTime) + { + Soloud_fadePan(objhandle, aVoiceHandle, aTo, aTime); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_fadeRelativePlaySpeed")] + internal static extern void Soloud_fadeRelativePlaySpeed(IntPtr aObjHandle, uint aVoiceHandle, float aTo, double aTime); + public void fadeRelativePlaySpeed(uint aVoiceHandle, float aTo, double aTime) + { + Soloud_fadeRelativePlaySpeed(objhandle, aVoiceHandle, aTo, aTime); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_fadeGlobalVolume")] + internal static extern void Soloud_fadeGlobalVolume(IntPtr aObjHandle, float aTo, double aTime); + public void fadeGlobalVolume(float aTo, double aTime) + { + Soloud_fadeGlobalVolume(objhandle, aTo, aTime); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_schedulePause")] + internal static extern void Soloud_schedulePause(IntPtr aObjHandle, uint aVoiceHandle, double aTime); + public void schedulePause(uint aVoiceHandle, double aTime) + { + Soloud_schedulePause(objhandle, aVoiceHandle, aTime); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_scheduleStop")] + internal static extern void Soloud_scheduleStop(IntPtr aObjHandle, uint aVoiceHandle, double aTime); + public void scheduleStop(uint aVoiceHandle, double aTime) + { + Soloud_scheduleStop(objhandle, aVoiceHandle, aTime); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_oscillateVolume")] + internal static extern void Soloud_oscillateVolume(IntPtr aObjHandle, uint aVoiceHandle, float aFrom, float aTo, double aTime); + public void oscillateVolume(uint aVoiceHandle, float aFrom, float aTo, double aTime) + { + Soloud_oscillateVolume(objhandle, aVoiceHandle, aFrom, aTo, aTime); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_oscillatePan")] + internal static extern void Soloud_oscillatePan(IntPtr aObjHandle, uint aVoiceHandle, float aFrom, float aTo, double aTime); + public void oscillatePan(uint aVoiceHandle, float aFrom, float aTo, double aTime) + { + Soloud_oscillatePan(objhandle, aVoiceHandle, aFrom, aTo, aTime); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_oscillateRelativePlaySpeed")] + internal static extern void Soloud_oscillateRelativePlaySpeed(IntPtr aObjHandle, uint aVoiceHandle, float aFrom, float aTo, double aTime); + public void oscillateRelativePlaySpeed(uint aVoiceHandle, float aFrom, float aTo, double aTime) + { + Soloud_oscillateRelativePlaySpeed(objhandle, aVoiceHandle, aFrom, aTo, aTime); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_oscillateGlobalVolume")] + internal static extern void Soloud_oscillateGlobalVolume(IntPtr aObjHandle, float aFrom, float aTo, double aTime); + public void oscillateGlobalVolume(float aFrom, float aTo, double aTime) + { + Soloud_oscillateGlobalVolume(objhandle, aFrom, aTo, aTime); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_setGlobalFilter")] + internal static extern void Soloud_setGlobalFilter(IntPtr aObjHandle, uint aFilterId, IntPtr aFilter); + public void setGlobalFilter(uint aFilterId, SoloudObject aFilter) + { + Soloud_setGlobalFilter(objhandle, aFilterId, aFilter.objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_setVisualizationEnable")] + internal static extern void Soloud_setVisualizationEnable(IntPtr aObjHandle, int aEnable); + public void setVisualizationEnable(int aEnable) + { + Soloud_setVisualizationEnable(objhandle, aEnable); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_calcFFT")] + internal static extern IntPtr Soloud_calcFFT(IntPtr aObjHandle); + public float[] calcFFT() + { + float[] ret = new float[256]; + IntPtr p = Soloud_calcFFT(objhandle); + + byte[] buffer = new byte[4]; + for (int i = 0; i < ret.Length; ++i) + { + int f_bits = Marshal.ReadInt32(p, i * 4); + buffer[0] = (byte)((f_bits >> 0) & 0xff); + buffer[1] = (byte)((f_bits >> 8) & 0xff); + buffer[2] = (byte)((f_bits >> 16) & 0xff); + buffer[3] = (byte)((f_bits >> 24) & 0xff); + ret[i] = BitConverter.ToSingle(buffer, 0); + } + return ret; + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getWave")] + internal static extern IntPtr Soloud_getWave(IntPtr aObjHandle); + public float[] getWave() + { + float[] ret = new float[256]; + IntPtr p = Soloud_getWave(objhandle); + + byte[] buffer = new byte[4]; + for (int i = 0; i < ret.Length; ++i) + { + int f_bits = Marshal.ReadInt32(p, i * 4); + buffer[0] = (byte)((f_bits >> 0) & 0xff); + buffer[1] = (byte)((f_bits >> 8) & 0xff); + buffer[2] = (byte)((f_bits >> 16) & 0xff); + buffer[3] = (byte)((f_bits >> 24) & 0xff); + ret[i] = BitConverter.ToSingle(buffer, 0); + } + return ret; + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getApproximateVolume")] + internal static extern float Soloud_getApproximateVolume(IntPtr aObjHandle, uint aChannel); + public float getApproximateVolume(uint aChannel) + { + return Soloud_getApproximateVolume(objhandle, aChannel); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getLoopCount")] + internal static extern uint Soloud_getLoopCount(IntPtr aObjHandle, uint aVoiceHandle); + public uint getLoopCount(uint aVoiceHandle) + { + return Soloud_getLoopCount(objhandle, aVoiceHandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_getInfo")] + internal static extern float Soloud_getInfo(IntPtr aObjHandle, uint aVoiceHandle, uint aInfoKey); + public float getInfo(uint aVoiceHandle, uint aInfoKey) + { + return Soloud_getInfo(objhandle, aVoiceHandle, aInfoKey); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_createVoiceGroup")] + internal static extern uint Soloud_createVoiceGroup(IntPtr aObjHandle); + public uint createVoiceGroup() + { + return Soloud_createVoiceGroup(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_destroyVoiceGroup")] + internal static extern int Soloud_destroyVoiceGroup(IntPtr aObjHandle, uint aVoiceGroupHandle); + public int destroyVoiceGroup(uint aVoiceGroupHandle) + { + return Soloud_destroyVoiceGroup(objhandle, aVoiceGroupHandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_addVoiceToGroup")] + internal static extern int Soloud_addVoiceToGroup(IntPtr aObjHandle, uint aVoiceGroupHandle, uint aVoiceHandle); + public int addVoiceToGroup(uint aVoiceGroupHandle, uint aVoiceHandle) + { + return Soloud_addVoiceToGroup(objhandle, aVoiceGroupHandle, aVoiceHandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_isVoiceGroup")] + internal static extern int Soloud_isVoiceGroup(IntPtr aObjHandle, uint aVoiceGroupHandle); + public int isVoiceGroup(uint aVoiceGroupHandle) + { + return Soloud_isVoiceGroup(objhandle, aVoiceGroupHandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_isVoiceGroupEmpty")] + internal static extern int Soloud_isVoiceGroupEmpty(IntPtr aObjHandle, uint aVoiceGroupHandle); + public int isVoiceGroupEmpty(uint aVoiceGroupHandle) + { + return Soloud_isVoiceGroupEmpty(objhandle, aVoiceGroupHandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_update3dAudio")] + internal static extern void Soloud_update3dAudio(IntPtr aObjHandle); + public void update3dAudio() + { + Soloud_update3dAudio(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_set3dSoundSpeed")] + internal static extern int Soloud_set3dSoundSpeed(IntPtr aObjHandle, float aSpeed); + public int set3dSoundSpeed(float aSpeed) + { + return Soloud_set3dSoundSpeed(objhandle, aSpeed); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_get3dSoundSpeed")] + internal static extern float Soloud_get3dSoundSpeed(IntPtr aObjHandle); + public float get3dSoundSpeed() + { + return Soloud_get3dSoundSpeed(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_set3dListenerParametersEx")] + internal static extern void Soloud_set3dListenerParametersEx(IntPtr aObjHandle, float aPosX, float aPosY, float aPosZ, float aAtX, float aAtY, float aAtZ, float aUpX, float aUpY, float aUpZ, float aVelocityX, float aVelocityY, float aVelocityZ); + public void set3dListenerParameters(float aPosX, float aPosY, float aPosZ, float aAtX, float aAtY, float aAtZ, float aUpX, float aUpY, float aUpZ, float aVelocityX = 0.0f, float aVelocityY = 0.0f, float aVelocityZ = 0.0f) + { + Soloud_set3dListenerParametersEx(objhandle, aPosX, aPosY, aPosZ, aAtX, aAtY, aAtZ, aUpX, aUpY, aUpZ, aVelocityX, aVelocityY, aVelocityZ); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_set3dListenerPosition")] + internal static extern void Soloud_set3dListenerPosition(IntPtr aObjHandle, float aPosX, float aPosY, float aPosZ); + public void set3dListenerPosition(float aPosX, float aPosY, float aPosZ) + { + Soloud_set3dListenerPosition(objhandle, aPosX, aPosY, aPosZ); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_set3dListenerAt")] + internal static extern void Soloud_set3dListenerAt(IntPtr aObjHandle, float aAtX, float aAtY, float aAtZ); + public void set3dListenerAt(float aAtX, float aAtY, float aAtZ) + { + Soloud_set3dListenerAt(objhandle, aAtX, aAtY, aAtZ); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_set3dListenerUp")] + internal static extern void Soloud_set3dListenerUp(IntPtr aObjHandle, float aUpX, float aUpY, float aUpZ); + public void set3dListenerUp(float aUpX, float aUpY, float aUpZ) + { + Soloud_set3dListenerUp(objhandle, aUpX, aUpY, aUpZ); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_set3dListenerVelocity")] + internal static extern void Soloud_set3dListenerVelocity(IntPtr aObjHandle, float aVelocityX, float aVelocityY, float aVelocityZ); + public void set3dListenerVelocity(float aVelocityX, float aVelocityY, float aVelocityZ) + { + Soloud_set3dListenerVelocity(objhandle, aVelocityX, aVelocityY, aVelocityZ); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_set3dSourceParametersEx")] + internal static extern void Soloud_set3dSourceParametersEx(IntPtr aObjHandle, uint aVoiceHandle, float aPosX, float aPosY, float aPosZ, float aVelocityX, float aVelocityY, float aVelocityZ); + public void set3dSourceParameters(uint aVoiceHandle, float aPosX, float aPosY, float aPosZ, float aVelocityX = 0.0f, float aVelocityY = 0.0f, float aVelocityZ = 0.0f) + { + Soloud_set3dSourceParametersEx(objhandle, aVoiceHandle, aPosX, aPosY, aPosZ, aVelocityX, aVelocityY, aVelocityZ); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_set3dSourcePosition")] + internal static extern void Soloud_set3dSourcePosition(IntPtr aObjHandle, uint aVoiceHandle, float aPosX, float aPosY, float aPosZ); + public void set3dSourcePosition(uint aVoiceHandle, float aPosX, float aPosY, float aPosZ) + { + Soloud_set3dSourcePosition(objhandle, aVoiceHandle, aPosX, aPosY, aPosZ); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_set3dSourceVelocity")] + internal static extern void Soloud_set3dSourceVelocity(IntPtr aObjHandle, uint aVoiceHandle, float aVelocityX, float aVelocityY, float aVelocityZ); + public void set3dSourceVelocity(uint aVoiceHandle, float aVelocityX, float aVelocityY, float aVelocityZ) + { + Soloud_set3dSourceVelocity(objhandle, aVoiceHandle, aVelocityX, aVelocityY, aVelocityZ); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_set3dSourceMinMaxDistance")] + internal static extern void Soloud_set3dSourceMinMaxDistance(IntPtr aObjHandle, uint aVoiceHandle, float aMinDistance, float aMaxDistance); + public void set3dSourceMinMaxDistance(uint aVoiceHandle, float aMinDistance, float aMaxDistance) + { + Soloud_set3dSourceMinMaxDistance(objhandle, aVoiceHandle, aMinDistance, aMaxDistance); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_set3dSourceAttenuation")] + internal static extern void Soloud_set3dSourceAttenuation(IntPtr aObjHandle, uint aVoiceHandle, uint aAttenuationModel, float aAttenuationRolloffFactor); + public void set3dSourceAttenuation(uint aVoiceHandle, uint aAttenuationModel, float aAttenuationRolloffFactor) + { + Soloud_set3dSourceAttenuation(objhandle, aVoiceHandle, aAttenuationModel, aAttenuationRolloffFactor); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_set3dSourceDopplerFactor")] + internal static extern void Soloud_set3dSourceDopplerFactor(IntPtr aObjHandle, uint aVoiceHandle, float aDopplerFactor); + public void set3dSourceDopplerFactor(uint aVoiceHandle, float aDopplerFactor) + { + Soloud_set3dSourceDopplerFactor(objhandle, aVoiceHandle, aDopplerFactor); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_mix")] + internal static extern void Soloud_mix(IntPtr aObjHandle, float[] aBuffer, uint aSamples); + public void mix(float[] aBuffer, uint aSamples) + { + Soloud_mix(objhandle, aBuffer, aSamples); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Soloud_mixSigned16")] + internal static extern void Soloud_mixSigned16(IntPtr aObjHandle, IntPtr aBuffer, uint aSamples); + public void mixSigned16(IntPtr aBuffer, uint aSamples) + { + Soloud_mixSigned16(objhandle, aBuffer, aSamples); + } + } +} diff --git a/Assembly-CSharp/Global/Sound/SoLoud/WavStream.cs b/Assembly-CSharp/Global/Sound/SoLoud/WavStream.cs new file mode 100644 index 000000000..8734043aa --- /dev/null +++ b/Assembly-CSharp/Global/Sound/SoLoud/WavStream.cs @@ -0,0 +1,179 @@ +using SoLoud; +using System; +using System.Runtime.InteropServices; + +namespace Global.Sound.SoLoud +{ + public class WavStream : SoloudObject + { + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_create")] + internal static extern IntPtr WavStream_create(); + public WavStream() + { + objhandle = WavStream_create(); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_destroy")] + internal static extern void WavStream_destroy(IntPtr aObjHandle); + ~WavStream() + { + // Can cause a crash if called while quitting + if (!SdLibAPIWithSoloud.isQuitting) WavStream_destroy(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_load")] + internal static extern int WavStream_load(IntPtr aObjHandle, [MarshalAs(UnmanagedType.LPStr)] string aFilename); + public int load(string aFilename) + { + return WavStream_load(objhandle, aFilename); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_loadMemEx")] + internal static extern int WavStream_loadMemEx(IntPtr aObjHandle, IntPtr aData, uint aDataLen, bool aCopy, bool aTakeOwnership); + public int loadMem(IntPtr aData, uint aDataLen, bool aCopy = false, bool aTakeOwnership = true) + { + return WavStream_loadMemEx(objhandle, aData, aDataLen, aCopy, aTakeOwnership); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_loadToMem")] + internal static extern int WavStream_loadToMem(IntPtr aObjHandle, [MarshalAs(UnmanagedType.LPStr)] string aFilename); + public int loadToMem(string aFilename) + { + return WavStream_loadToMem(objhandle, aFilename); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_loadFile")] + internal static extern int WavStream_loadFile(IntPtr aObjHandle, IntPtr aFile); + public int loadFile(SoloudObject aFile) + { + return WavStream_loadFile(objhandle, aFile.objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_loadFileToMem")] + internal static extern int WavStream_loadFileToMem(IntPtr aObjHandle, IntPtr aFile); + public int loadFileToMem(SoloudObject aFile) + { + return WavStream_loadFileToMem(objhandle, aFile.objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_getLength")] + internal static extern double WavStream_getLength(IntPtr aObjHandle); + public double getLength() + { + return WavStream_getLength(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_setVolume")] + internal static extern void WavStream_setVolume(IntPtr aObjHandle, float aVolume); + public void setVolume(float aVolume) + { + WavStream_setVolume(objhandle, aVolume); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_setLooping")] + internal static extern void WavStream_setLooping(IntPtr aObjHandle, int aLoop); + public void setLooping(int aLoop) + { + WavStream_setLooping(objhandle, aLoop); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_set3dMinMaxDistance")] + internal static extern void WavStream_set3dMinMaxDistance(IntPtr aObjHandle, float aMinDistance, float aMaxDistance); + public void set3dMinMaxDistance(float aMinDistance, float aMaxDistance) + { + WavStream_set3dMinMaxDistance(objhandle, aMinDistance, aMaxDistance); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_set3dAttenuation")] + internal static extern void WavStream_set3dAttenuation(IntPtr aObjHandle, uint aAttenuationModel, float aAttenuationRolloffFactor); + public void set3dAttenuation(uint aAttenuationModel, float aAttenuationRolloffFactor) + { + WavStream_set3dAttenuation(objhandle, aAttenuationModel, aAttenuationRolloffFactor); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_set3dDopplerFactor")] + internal static extern void WavStream_set3dDopplerFactor(IntPtr aObjHandle, float aDopplerFactor); + public void set3dDopplerFactor(float aDopplerFactor) + { + WavStream_set3dDopplerFactor(objhandle, aDopplerFactor); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_set3dListenerRelative")] + internal static extern void WavStream_set3dListenerRelative(IntPtr aObjHandle, int aListenerRelative); + public void set3dListenerRelative(int aListenerRelative) + { + WavStream_set3dListenerRelative(objhandle, aListenerRelative); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_set3dDistanceDelay")] + internal static extern void WavStream_set3dDistanceDelay(IntPtr aObjHandle, int aDistanceDelay); + public void set3dDistanceDelay(int aDistanceDelay) + { + WavStream_set3dDistanceDelay(objhandle, aDistanceDelay); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_set3dColliderEx")] + internal static extern void WavStream_set3dColliderEx(IntPtr aObjHandle, IntPtr aCollider, int aUserData); + public void set3dCollider(SoloudObject aCollider, int aUserData = 0) + { + WavStream_set3dColliderEx(objhandle, aCollider.objhandle, aUserData); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_set3dAttenuator")] + internal static extern void WavStream_set3dAttenuator(IntPtr aObjHandle, IntPtr aAttenuator); + public void set3dAttenuator(SoloudObject aAttenuator) + { + WavStream_set3dAttenuator(objhandle, aAttenuator.objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_setInaudibleBehavior")] + internal static extern void WavStream_setInaudibleBehavior(IntPtr aObjHandle, int aMustTick, int aKill); + public void setInaudibleBehavior(int aMustTick, int aKill) + { + WavStream_setInaudibleBehavior(objhandle, aMustTick, aKill); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_setLoopStartPoint")] + internal static extern void WavStream_setLoopStartPoint(IntPtr aObjHandle, double aLoopPoint); + public void setLoopStartPoint(double aLoopPoint) + { + WavStream_setLoopStartPoint(objhandle, aLoopPoint); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_setLoopEndPoint")] + internal static extern void WavStream_setLoopEndPoint(IntPtr aObjHandle, double aLoopPoint); + public void setLoopEndPoint(double aLoopPoint) + { + WavStream_setLoopEndPoint(objhandle, aLoopPoint); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_getLoopStartPoint")] + internal static extern double WavStream_getLoopStartPoint(IntPtr aObjHandle); + public double getLoopStartPoint() + { + return WavStream_getLoopStartPoint(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_getLoopEndPoint")] + internal static extern double WavStream_getLoopEndPoint(IntPtr aObjHandle); + public double getLoopEndPoint() + { + return WavStream_getLoopEndPoint(objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_setFilter")] + internal static extern void WavStream_setFilter(IntPtr aObjHandle, uint aFilterId, IntPtr aFilter); + public void setFilter(uint aFilterId, SoloudObject aFilter) + { + WavStream_setFilter(objhandle, aFilterId, aFilter.objhandle); + } + + [DllImport("soloud", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WavStream_stop")] + internal static extern void WavStream_stop(IntPtr aObjHandle); + public void stop() + { + WavStream_stop(objhandle); + } + } +} diff --git a/Assembly-CSharp/Global/Sound/SoLoud/x64/soloud.dll b/Assembly-CSharp/Global/Sound/SoLoud/x64/soloud.dll new file mode 100644 index 000000000..1940aae62 Binary files /dev/null and b/Assembly-CSharp/Global/Sound/SoLoud/x64/soloud.dll differ diff --git a/Assembly-CSharp/Global/Sound/SoLoud/x86/soloud.dll b/Assembly-CSharp/Global/Sound/SoLoud/x86/soloud.dll new file mode 100644 index 000000000..e8ea8295b Binary files /dev/null and b/Assembly-CSharp/Global/Sound/SoLoud/x86/soloud.dll differ diff --git a/Assembly-CSharp/Global/Sound/SoundPlayer.cs b/Assembly-CSharp/Global/Sound/SoundPlayer.cs index 1fbb54ab5..62a493d28 100644 --- a/Assembly-CSharp/Global/Sound/SoundPlayer.cs +++ b/Assembly-CSharp/Global/Sound/SoundPlayer.cs @@ -59,17 +59,16 @@ public static void StaticCreateSound(SoundProfile soundProfile) public static void StaticStartSound(SoundProfile soundProfile, Single playerVolume = 1f) { - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); if (ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_IsExist(soundProfile.SoundID) == 0) { SoundLib.Log("failed to play sound"); soundProfile.SoundID = 0; return; - } - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * playerVolume, 0); - SoundLib.Log("Panning: " + soundProfile.Panning); + } + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * playerVolume, 0); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPanning(soundProfile.SoundID, soundProfile.Panning, 0); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPitch(soundProfile.SoundID, soundProfile.Pitch, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); SoundLib.Log("StartSound Success"); } diff --git a/Assembly-CSharp/Global/TileSystem/TileSystem.cs b/Assembly-CSharp/Global/TileSystem/TileSystem.cs index d7eef59bd..337583a2c 100644 --- a/Assembly-CSharp/Global/TileSystem/TileSystem.cs +++ b/Assembly-CSharp/Global/TileSystem/TileSystem.cs @@ -384,9 +384,9 @@ public static byte[] GetImageData(Layer layer, BGOVERLAY_DEF overlayInfo, uint f long overlayWidth = overlayInfo.w * factor; Rectangle rect = layer.Rect; - long left = overlayInfo.curX; + long left = (short)overlayInfo.curX; long right = left + overlayInfo.w; - long top = overlayInfo.curY; + long top = (short)overlayInfo.curY; long bottom = top + overlayInfo.h; long product = overlayHeight * overlayWidth; long verticalOffset = (SPRITE_H - rect.Bottom % SPRITE_H) % SPRITE_H; @@ -793,8 +793,8 @@ private static void GetBounds(List overlayList, int camIndex, out for (int k = 0; k < overlay.spriteList.Count; k++) { BGSPRITE_LOC_DEF sprite = overlay.spriteList[k]; - int offX = sprite.offX + overlay.curX; - int offY = sprite.offY + overlay.curY; + int offX = sprite.offX + (short)overlay.curX; + int offY = sprite.offY + (short)overlay.curY; if (offX < minX) minX = offX; if (offX > maxX) maxX = offX; if (offY < minY) minY = offY; @@ -969,8 +969,8 @@ public Overlay(byte[] layerImageData, BGOVERLAY_DEF overlayInfo, int orderNumber Tile tileToPush = new Tile(); tileToPush.info = info.spriteList[k]; BGSPRITE_LOC_DEF spriteInfo = info.spriteList[k]; - tileToPush.x = (info.orgX + spriteInfo.offX - minX) / 16; // get global x - tileToPush.y = (info.orgY + spriteInfo.offY - minY) / 16; // get global y + tileToPush.x = ((short)(info.orgX) + spriteInfo.offX - minX) / 16; // get global x + tileToPush.y = ((short)(info.orgY) + spriteInfo.offY - minY) / 16; // get global y tileToPush.overlay = this; _map[tileToPush.x, tileToPush.y] = tileToPush; } diff --git a/Assembly-CSharp/Global/TimerUI.cs b/Assembly-CSharp/Global/TimerUI.cs index 035c0f429..78c44cff4 100644 --- a/Assembly-CSharp/Global/TimerUI.cs +++ b/Assembly-CSharp/Global/TimerUI.cs @@ -130,6 +130,8 @@ private static void Create(Boolean resetFlag) GameObject prefab = Resources.Load("EmbeddedAsset/UI/Prefabs/Timer Container") as GameObject; GameObject gameObject = NGUITools.AddChild(PersistenSingleton.Instance.gameObject, prefab); gameObject.name = "Timer Container"; + if (Configuration.Graphics.WidescreenSupport) + gameObject.transform.AddX(-200f); // Fix https://github.com/Albeoris/Memoria/issues/366 (adapted to 16:9 widescreen only) TimerUI.digit0 = gameObject.gameObject.FindChild("Digit Panel/Digit0").GetComponent(); TimerUI.digit1 = gameObject.gameObject.FindChild("Digit Panel/Digit1").GetComponent(); TimerUI.digit2 = gameObject.gameObject.FindChild("Digit Panel/Digit2").GetComponent(); diff --git a/Assembly-CSharp/Global/TitleUI.cs b/Assembly-CSharp/Global/TitleUI.cs index d836a29e8..d43d0e780 100644 --- a/Assembly-CSharp/Global/TitleUI.cs +++ b/Assembly-CSharp/Global/TitleUI.cs @@ -14,6 +14,7 @@ using Memoria.Speedrun; using UnityEngine; using UnityEngine.UI; +using static AssetManager; // ReSharper disable InconsistentNaming // ReSharper disable NotAccessedField.Local @@ -368,20 +369,31 @@ public override void Show(SceneVoidDelegate afterFinished = null) sprite2D.sprite2D = Sprite.Create(texture, sprite.rect, sprite.pivot); sprite2D.sprite2D.name = sprite.name; } - else + + // Replace title screen with modded version if it exists + externalPath = AssetManager.SearchAssetOnDisc("EmbeddedAsset/UI/Sprites/title_bg", true, false); + if (!String.IsNullOrEmpty(externalPath)) { - //TextureHelper.WriteTextureToFile(TextureHelper.CopyAsReadable(sprite.texture), "StreamingAssets/UI/Sprites/US/" + sprite.name + ".png"); + Texture2D texture = StreamingResources.LoadTexture2D(externalPath); + sprite2D.sprite2D = Sprite.Create(texture, sprite.rect, sprite.pivot); + sprite2D.sprite2D.name = sprite.name; } - // - UITexture logo = this.MenuPanelObject.GetChild(1).GetComponent(); - externalPath = "StreamingAssets/UI/Sprites/US/" + logo.name + ".png"; - if (File.Exists(externalPath)) + + externalPath = AssetManager.SearchAssetOnDisc("EmbeddedAsset/UI/Sprites/title_bg.png", true, false); // also check .png for simplicity + if (!String.IsNullOrEmpty(externalPath)) { - logo.mainTexture = StreamingResources.LoadTexture2D("StreamingAssets/UI/Sprites/US/" + logo.name + ".png"); + Texture2D texture = StreamingResources.LoadTexture2D(externalPath); + sprite2D.sprite2D = Sprite.Create(texture, sprite.rect, sprite.pivot); + sprite2D.sprite2D.name = sprite.name; } - else + + // Replace title logo with modded version if it exists (advice: replace with transparent and include logo in title_bg.png) + UITexture texture2D = this.MenuPanelObject.GetChild(1).GetComponent(); + externalPath = AssetManager.SearchAssetOnDisc("EmbeddedAsset/UI/Materials/title_logo", true, false); + if (!String.IsNullOrEmpty(externalPath)) { - //TextureHelper.WriteTextureToFile(TextureHelper.CopyAsReadable(logo.mainTexture), "StreamingAssets/UI/Sprites/US/" + logo.name + ".png"); + Texture2D texture = StreamingResources.LoadTexture2D(externalPath); + texture2D.mainTexture = texture; } } catch (Exception ex) diff --git a/Assembly-CSharp/Global/UI/UIManager.cs b/Assembly-CSharp/Global/UI/UIManager.cs index 3fe676d3a..dfb6c687d 100644 --- a/Assembly-CSharp/Global/UI/UIManager.cs +++ b/Assembly-CSharp/Global/UI/UIManager.cs @@ -65,8 +65,8 @@ public UIManager.UIState State { if (value == UIState.FieldHUD && FieldMap.IsNarrowMap()) Configuration.Graphics.DisableWidescreenSupportForSingleMap(); - else - Configuration.Graphics.RestoreDisabledWidescreenSupport(); + else if (state == UIState.FieldHUD && value != UIState.Pause) + Configuration.Graphics.RestoreDisabledWidescreenSupport(); this.state = value; } diff --git a/Assembly-CSharp/Global/UI/UIRoot.cs b/Assembly-CSharp/Global/UI/UIRoot.cs index dfa36beee..5fb9a30d5 100644 --- a/Assembly-CSharp/Global/UI/UIRoot.cs +++ b/Assembly-CSharp/Global/UI/UIRoot.cs @@ -139,7 +139,7 @@ private void FixWideScreenPauseBackground() { try { - UISprite pauseBackground = gameObject + UISprite pauseBackground = gameObject .FindChild("Pause Container") .FindChild("Panel") .FindChild("Dim Background") @@ -151,7 +151,21 @@ private void FixWideScreenPauseBackground() { Log.Error(ex, "Failed to fix wide screen pause background."); } - } + try + { + UISprite quitBackground = gameObject + .FindChild("Quit Container") + .FindChild("Panel") + .FindChild("Dim Background") + .GetComponent(); + + quitBackground.width = 4096; + } + catch (Exception ex) + { + Log.Error(ex, "Failed to fix wide screen quit background."); + } + } protected virtual void OnEnable() { diff --git a/Assembly-CSharp/Global/UI/UIStretch.cs b/Assembly-CSharp/Global/UI/UIStretch.cs index 9adb5b19d..70ce41f36 100644 --- a/Assembly-CSharp/Global/UI/UIStretch.cs +++ b/Assembly-CSharp/Global/UI/UIStretch.cs @@ -55,7 +55,7 @@ private void Update() { UIWidget uiwidget = (!(this.container == (UnityEngine.Object)null)) ? this.container.GetComponent() : ((UIWidget)null); UIPanel uipanel = (!(this.container == (UnityEngine.Object)null) || !(uiwidget == (UnityEngine.Object)null)) ? this.container.GetComponent() : ((UIPanel)null); - Single num = 1f; + Single widgetWidth = 1f; if (uiwidget != (UnityEngine.Object)null) { Bounds bounds = uiwidget.CalculateBounds(base.transform.parent); @@ -68,9 +68,9 @@ private void Update() { if (uipanel.clipping == UIDrawCall.Clipping.None) { - Single num2 = (!(this.mRoot != (UnityEngine.Object)null)) ? 0.5f : ((Single)this.mRoot.activeHeight / (Single)Screen.height * 0.5f); - this.mRect.xMin = (Single)(-(Single)Screen.width) * num2; - this.mRect.yMin = (Single)(-(Single)Screen.height) * num2; + Single widgetHeight = (!(this.mRoot != (UnityEngine.Object)null)) ? 0.5f : ((Single)this.mRoot.activeHeight / (Single)Screen.height * 0.5f); + this.mRect.xMin = (Single)(-(Single)Screen.width) * widgetHeight; + this.mRect.yMin = (Single)(-(Single)Screen.height) * widgetHeight; this.mRect.xMax = -this.mRect.xMin; this.mRect.yMax = -this.mRect.yMin; } @@ -101,73 +101,73 @@ private void Update() this.mRect = this.uiCamera.pixelRect; if (this.mRoot != (UnityEngine.Object)null) { - num = this.mRoot.pixelSizeAdjustment; + widgetWidth = this.mRoot.pixelSizeAdjustment; } } - Single num3 = this.mRect.width; - Single num4 = this.mRect.height; - if (num != 1f && num4 > 1f) + Single scaleFactorX = this.mRect.width; + Single scaleFactorY = this.mRect.height; + if (widgetWidth != 1f && scaleFactorY > 1f) { - Single num5 = (Single)this.mRoot.activeHeight / num4; - num3 *= num5; - num4 *= num5; + Single pixelSizeAdjustment = (Single)this.mRoot.activeHeight / scaleFactorY; + scaleFactorX *= pixelSizeAdjustment; + scaleFactorY *= pixelSizeAdjustment; } Vector3 vector = (!(this.mWidget != (UnityEngine.Object)null)) ? this.mTrans.localScale : new Vector3((Single)this.mWidget.width, (Single)this.mWidget.height); if (this.style == UIStretch.Style.BasedOnHeight) { - vector.x = this.relativeSize.x * num4; - vector.y = this.relativeSize.y * num4; + vector.x = this.relativeSize.x * scaleFactorY; + vector.y = this.relativeSize.y * scaleFactorY; } else if (this.style == UIStretch.Style.FillKeepingRatio) { - Single num6 = num3 / num4; - Single num7 = this.initialSize.x / this.initialSize.y; - if (num7 < num6) + Single widthHeightRatio = scaleFactorX / scaleFactorY; + Single initialWidthHeightRatio = this.initialSize.x / this.initialSize.y; + if (initialWidthHeightRatio < widthHeightRatio) { - Single num8 = num3 / this.initialSize.x; - vector.x = num3; + Single num8 = scaleFactorX / this.initialSize.x; + vector.x = scaleFactorX; vector.y = this.initialSize.y * num8; } else { - Single num9 = num4 / this.initialSize.y; + Single num9 = scaleFactorY / this.initialSize.y; vector.x = this.initialSize.x * num9; - vector.y = num4; + vector.y = scaleFactorY; } } else if (this.style == UIStretch.Style.FitInternalKeepingRatio) { - Single num10 = num3 / num4; - Single num11 = this.initialSize.x / this.initialSize.y; - if (num11 > num10) + Single widthHeightRatio = scaleFactorX / scaleFactorY; + Single initialWidthHeightRatio = this.initialSize.x / this.initialSize.y; + if (initialWidthHeightRatio > widthHeightRatio) { - Single num12 = num3 / this.initialSize.x; - vector.x = num3; + Single num12 = scaleFactorX / this.initialSize.x; + vector.x = scaleFactorX; vector.y = this.initialSize.y * num12; } else { - Single num13 = num4 / this.initialSize.y; + Single num13 = scaleFactorY / this.initialSize.y; vector.x = this.initialSize.x * num13; - vector.y = num4; + vector.y = scaleFactorY; } } else { if (this.style != UIStretch.Style.Vertical) { - vector.x = this.relativeSize.x * num3; + vector.x = this.relativeSize.x * scaleFactorX; } if (this.style != UIStretch.Style.Horizontal) { - vector.y = this.relativeSize.y * num4; + vector.y = this.relativeSize.y * scaleFactorY; } } if (this.mSprite != (UnityEngine.Object)null) { - Single num14 = (!(this.mSprite.atlas != (UnityEngine.Object)null)) ? 1f : this.mSprite.atlas.pixelSize; - vector.x -= this.borderPadding.x * num14; - vector.y -= this.borderPadding.y * num14; + Single atlasPixelSize = (!(this.mSprite.atlas != (UnityEngine.Object)null)) ? 1f : this.mSprite.atlas.pixelSize; + vector.x -= this.borderPadding.x * atlasPixelSize; + vector.y -= this.borderPadding.y * atlasPixelSize; if (this.style != UIStretch.Style.Vertical) { this.mSprite.width = Mathf.RoundToInt(vector.x); diff --git a/Assembly-CSharp/Global/World/WorldHUD.cs b/Assembly-CSharp/Global/World/WorldHUD.cs index 24fd969e7..a3fb5fe42 100644 --- a/Assembly-CSharp/Global/World/WorldHUD.cs +++ b/Assembly-CSharp/Global/World/WorldHUD.cs @@ -623,19 +623,29 @@ public void InitialHUD() { if (WMUIData.ActiveMapNo == 1) { - Sprite sprite = AssetManager.Load("EmbeddedAsset/UI/Sprites/world_map_full_all", false); - this.miniMapSprite.spriteName = "world_map_mini_all"; + String externalPath = AssetManager.SearchAssetOnDisc("EmbeddedAsset/UI/Sprites/world_map_full_all.png", true, false); + if (!String.IsNullOrEmpty(externalPath)) + externalPath = "EmbeddedAsset/UI/Sprites/world_map_full_all.png"; + else + externalPath = "EmbeddedAsset/UI/Sprites/world_map_full_all"; + Sprite fullMapSprite = AssetManager.Load(externalPath, false); + this.miniMapSprite.spriteName = "world_map_mini_all"; this.miniMapButton.normalSprite = "world_map_mini_all"; - this.mapSprite.sprite2D = sprite; - this.mapButton.normalSprite2D = sprite; + this.mapSprite.sprite2D = fullMapSprite; + this.mapButton.normalSprite2D = fullMapSprite; } else { - Sprite sprite2 = AssetManager.Load("EmbeddedAsset/UI/Sprites/world_map_full_mistcontinent", false); + String externalPath = AssetManager.SearchAssetOnDisc("EmbeddedAsset/UI/Sprites/world_map_full_mistcontinent.png", true, false); + if (!String.IsNullOrEmpty(externalPath)) + externalPath = "EmbeddedAsset/UI/Sprites/world_map_full_mistcontinent.png"; + else + externalPath = "EmbeddedAsset/UI/Sprites/world_map_full_mistcontinent"; + Sprite mistContinentMapSprite = AssetManager.Load(externalPath, false); this.miniMapSprite.spriteName = "world_map_mini_mistcontinent"; this.miniMapButton.normalSprite = "world_map_mini_mistcontinent"; - this.mapSprite.sprite2D = sprite2; - this.mapButton.normalSprite2D = sprite2; + this.mapSprite.sprite2D = mistContinentMapSprite; + this.mapButton.normalSprite2D = mistContinentMapSprite; } } diff --git a/Assembly-CSharp/Global/battle/BattleHUD/BattleHUD.cs b/Assembly-CSharp/Global/battle/BattleHUD/BattleHUD.cs index 5ec7151d4..6f4becc2b 100644 --- a/Assembly-CSharp/Global/battle/BattleHUD/BattleHUD.cs +++ b/Assembly-CSharp/Global/battle/BattleHUD/BattleHUD.cs @@ -1218,9 +1218,9 @@ private AbilityStatus GetAbilityState(Int32 abilId, Int32 playerIndex = -1) playerIndex = CurrentPlayerIndex; AbilityPlayerDetail abilityPlayerDetail = _abilityDetailDict[playerIndex]; BattleUnit unit = FF9StateSystem.Battle.FF9Battle.GetUnit(playerIndex); - AA_DATA aaData = ff9abil.GetActionAbility(abilId); + AA_DATA patchedAbil = FF9StateSystem.Battle.FF9Battle.aa_data[BattleAbilityHelper.Patch(ff9abil.GetActiveAbilityFromAbilityId(abilId), unit.Player.Data)]; - if ((Configuration.Battle.LockEquippedAbilities == 2 || Configuration.Battle.LockEquippedAbilities == 3) && abilityPlayerDetail.Player.Index != CharacterId.Quina && abilityPlayerDetail.HasAp && !abilityPlayerDetail.AbilityEquipList.ContainsKey(abilId) && ff9abil.IsAbilityActive(abilId)) + if ((Configuration.Battle.LockEquippedAbilities == 2 || Configuration.Battle.LockEquippedAbilities == 3) && abilityPlayerDetail.Player.Index != CharacterId.Quina && abilityPlayerDetail.HasAp && !abilityPlayerDetail.AbilityEquipList.ContainsKey(abilId) && ff9abil.IsAbilityActive(abilId)) return AbilityStatus.None; if (abilityPlayerDetail.HasAp && !abilityPlayerDetail.AbilityEquipList.ContainsKey(abilId) && ff9abil.IsAbilityActive(abilId)) { @@ -1235,7 +1235,7 @@ private AbilityStatus GetAbilityState(Int32 abilId, Int32 playerIndex = -1) } } - if ((aaData.Category & 2) != 0) + if ((patchedAbil.Category & 2) != 0) { if (FF9StateSystem.Battle.FF9Battle.btl_scene.Info.NoMagical) return AbilityStatus.Disable; @@ -1244,7 +1244,7 @@ private AbilityStatus GetAbilityState(Int32 abilId, Int32 playerIndex = -1) return AbilityStatus.Disable; } - if (GetActionMpCost(aaData, unit) > unit.CurrentMp) + if (GetActionMpCost(patchedAbil, unit) > unit.CurrentMp) return AbilityStatus.Disable; return AbilityStatus.Enable; diff --git a/Assembly-CSharp/Global/battle/Result/BattleResultUI.cs b/Assembly-CSharp/Global/battle/Result/BattleResultUI.cs index 7aa556de5..fc4260687 100644 --- a/Assembly-CSharp/Global/battle/Result/BattleResultUI.cs +++ b/Assembly-CSharp/Global/battle/Result/BattleResultUI.cs @@ -98,21 +98,20 @@ public override Boolean OnKeyConfirm(GameObject go) { FF9Sfx.FF9SFX_StopLoop(105); this.currentState = BattleResultUI.ResultState.EndEXPAndAP; - BattleEndValue[] array = this.expValue; - for (Int32 i = 0; i < (Int32)array.Length; i++) + for (Int32 i = 0; i < this.expValue.Length; i++) { - BattleEndValue battleEndValue = array[i]; - battleEndValue.step = battleEndValue.value; + BattleEndValue endValue = this.expValue[i]; + endValue.step = endValue.value; } this.UpdateExp(); - BattleEndValue[] array2 = this.apValue; - for (Int32 j = 0; j < (Int32)array2.Length; j++) + for (Int32 i = 0; i < this.apValue.Length; i++) { - BattleEndValue battleEndValue2 = array2[j]; - battleEndValue2.step = battleEndValue2.value; + BattleEndValue endValue = this.apValue[i]; + endValue.step = endValue.value; } this.UpdateAp(); this.DisplayEXPAndAPInfo(); + this.DisplayCharacterInfo(); this.ApplyTweenAndFade(); break; } @@ -223,20 +222,17 @@ private void DisplayCharacterInfo() PLAYER player = FF9StateSystem.Common.FF9.party.member[i]; if (player != null) { - UInt64 num = (player.level >= ff9level.LEVEL_COUNT) ? player.exp : ff9level.CharacterLevelUps[player.level].ExperienceToLevel; + UInt64 nextLvl = (player.level >= ff9level.LEVEL_COUNT) ? player.exp : ff9level.CharacterLevelUps[player.level].ExperienceToLevel; BattleResultUI.CharacterBattleResultInfoHUD characterBattleResultInfoHUD = this.characterBRInfoHudList[i]; characterBattleResultInfoHUD.Content.SetActive(true); characterBattleResultInfoHUD.NameLabel.text = player.Name; characterBattleResultInfoHUD.LevelLabel.text = player.level.ToString(); characterBattleResultInfoHUD.ExpLabel.text = player.exp.ToString(); - characterBattleResultInfoHUD.NextLvLabel.text = (num - player.exp).ToString(); + characterBattleResultInfoHUD.NextLvLabel.text = (nextLvl - player.exp).ToString(); FF9UIDataTool.DisplayCharacterAvatar(player, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), characterBattleResultInfoHUD.AvatarSprite, false); UISprite[] statusesSpriteList = characterBattleResultInfoHUD.StatusesSpriteList; for (Int32 j = 0; j < statusesSpriteList.Length; j++) - { - UISprite uisprite = statusesSpriteList[j]; - uisprite.alpha = 0f; - } + statusesSpriteList[j].alpha = 0f; Int32 spriteSlot = 0; foreach (KeyValuePair kvp in BattleResultUI.BadIconDict) { @@ -277,7 +273,9 @@ private void ShowLevelUpAnimation(Int32 index) { if (this.finishedLevelUpAnimation[index] >= this.totalLevelUp[index]) return; - FF9Sfx.FF9SFX_Play(683); + if (!this.isLevelUpSoundPlayed) + FF9Sfx.FF9SFX_Play(683); + this.isLevelUpSoundPlayed = true; this.levelUpSpriteTween[index].TweenIn(new Byte[1], delegate { this.levelUpSpriteTween[index].dialogList[0].SetActive(false); @@ -388,17 +386,14 @@ private void InitialNormal() this.abilityLearned[2] = new List(); this.abilityLearned[3] = new List(); this.isReadyToShowNextAbil = new Boolean[] { true, true, true, true }; - Boolean flag = true; - for (Int32 i = 0; i < this.expValue.Length && flag; i++) + Boolean skipEXPAndAP = true; + for (Int32 i = 0; i < this.expValue.Length && skipEXPAndAP; i++) if (this.expValue[i].value != 0u) - flag = false; - for (Int32 i = 0; i < this.apValue.Length && flag; i++) + skipEXPAndAP = false; + for (Int32 i = 0; i < this.apValue.Length && skipEXPAndAP; i++) if (this.apValue[i].value != 0u) - flag = false; - for (Int32 i = 0; i < this.expValue.Length && flag; i++) - if (this.expValue[i].value != 0u) - flag = false; - if (!flag) + skipEXPAndAP = false; + if (!skipEXPAndAP) this.currentState = BattleResultUI.ResultState.Start; else this.currentState = BattleResultUI.ResultState.EndEXPAndAP; @@ -650,7 +645,9 @@ private void AddAp(Int32 id, UInt32 ap) private void ApLearned(Int32 id, Int32 abilId) { - FF9Sfx.FF9SFX_Play(1043); + if (!this.isAbilityLearnSoundPlayed) + FF9Sfx.FF9SFX_Play(1043); + this.isAbilityLearnSoundPlayed = true; this.abilityLearned[id].Add(abilId); BattleAchievement.UpdateAbilitiesAchievement(abilId, true); } @@ -783,16 +780,15 @@ private void Update() { if (PersistenSingleton.Instance.State == UIManager.UIState.BattleResult) { + this.isLevelUpSoundPlayed = false; + this.isAbilityLearnSoundPlayed = false; BattleResultUI.ResultState resultState = this.currentState; - if (resultState != BattleResultUI.ResultState.EXPAndAPTick) + if (resultState == BattleResultUI.ResultState.GilTick) { - if (resultState == BattleResultUI.ResultState.GilTick) - { - this.UpdateGil(); - this.DisplayGilAndItemInfo(); - } + this.UpdateGil(); + this.DisplayGilAndItemInfo(); } - else + else if (resultState == BattleResultUI.ResultState.EXPAndAPTick) { this.UpdateExp(); this.UpdateAp(); @@ -934,6 +930,11 @@ private void Awake() private Boolean isTimerDisplay; + [NonSerialized] + private Boolean isLevelUpSoundPlayed = false; + [NonSerialized] + private Boolean isAbilityLearnSoundPlayed = false; + public static Dictionary BadIconDict = new Dictionary { { BattleStatus.Petrify, 154 }, diff --git a/Assembly-CSharp/Global/btl_cmd.cs b/Assembly-CSharp/Global/btl_cmd.cs index c4782452d..e8addb1ae 100644 --- a/Assembly-CSharp/Global/btl_cmd.cs +++ b/Assembly-CSharp/Global/btl_cmd.cs @@ -35,16 +35,16 @@ public class btl_cmd { /* Notes on commands: - Each BTL_DATA has 6 potential commands at the same time. - Only the first 3 are initialized for enemies by default (btl_cmd.InitCommand). - With Memoria: the 6 commands are all used even for enemies (the last 3 are used for btl_scrp.SetCharacterData(id == 114)). - btl.cmd[0] -> normal commands (including berserk/confuse) - btl.cmd[1] -> counter-attacks - btl.cmd[2] -> reserved for death/stone animation (cmd_no == 60/62, sub_no == 0) - btl.cmd[3] -> first cast of a double-cast command or Spear (saved duplicate) or Eidolon phantom - btl.cmd[4] -> reserved for trance animation (cmd_no == 59, sub_no == 0) - btl.cmd[5] -> reserved for reraise animation (cmd_no == 61, sub_no == 0) - */ + Each BTL_DATA has 6 potential commands at the same time. + Only the first 3 are initialized for enemies by default (btl_cmd.InitCommand). + With Memoria: the 6 commands are all used even for enemies (the last 3 are used for btl_scrp.SetCharacterData(id == 114)). + btl.cmd[0] -> normal commands (including berserk/confuse) + btl.cmd[1] -> counter-attacks + btl.cmd[2] -> reserved for death/stone animation (cmd_no == 60/62, sub_no == 0) + btl.cmd[3] -> first cast of a double-cast command or Spear (saved duplicate) or Eidolon phantom + btl.cmd[4] -> reserved for trance animation (cmd_no == 59, sub_no == 0) + btl.cmd[5] -> reserved for reraise animation (cmd_no == 61, sub_no == 0) + */ public btl_cmd() { } @@ -289,7 +289,7 @@ public static void SetCommand(CMD_DATA cmd, BattleCommandId commandId, Int32 sub } public static UInt16 GetRandomTargetForCommand(BTL_DATA caster, BattleCommandId commandId, Int32 subNo) - { + { CMD_DATA testCmd = new CMD_DATA { regist = caster, @@ -695,6 +695,10 @@ public static void CommandEngine(FF9StateBattleSystem btlsys) if (btl_stat.CheckStatus(caster, BattleStatus.Berserk)) BattleVoice.TriggerOnStatusChange(caster, "Used", BattleStatus.Berserk); } + else if (cmd.cmd_no == BattleCommandId.JumpAttack || cmd.cmd_no == BattleCommandId.JumpTrance) + { + BattleVoice.TriggerOnStatusChange(caster, "Used", BattleStatus.Jump); + } BattleVoice.TriggerOnBattleAct(caster, "CommandPerform", cmd); } btl_vfx.SelectCommandVfx(cmd); @@ -846,7 +850,7 @@ private static void DequeueCommand(CMD_DATA cmd, Boolean escape_check) cmdData.info.stat = 0; cmdData.info.priority = 0; if (escape_check && cmdData.cmd_no == BattleCommandId.SysEscape) - FF9StateSystem.Battle.FF9Battle.cmd_status &= 65534; + FF9StateSystem.Battle.FF9Battle.cmd_status &= 0xFFFE; } public static Boolean CheckSpecificCommand(BTL_DATA btl, BattleCommandId cmd_no) @@ -1110,7 +1114,7 @@ public static Boolean CheckCommandCondition(FF9StateBattleSystem btlsys, CMD_DAT { BattleMesages tranceMessage = BattleMesages.Trance; if (caster.IsUnderPermanentStatus(BattleStatus.Trance)) - { + { tranceMessage = BattleMesages.PermanentTrance; String permTrance = FF9TextTool.BattleFollowText((Int32)tranceMessage + 7); if (String.IsNullOrEmpty(permTrance) || permTrance.Length <= 1) @@ -1203,7 +1207,7 @@ public static void KillAllCommand(FF9StateBattleSystem btlsys) else cp = ncp; } - btlsys.cmd_status &= 65523; + btlsys.cmd_status &= 0xFFF3; btlsys.phantom_no = BattleAbilityId.Void; btlsys.phantom_cnt = 0; } @@ -1214,7 +1218,7 @@ public static void ClearSysPhantom(BTL_DATA btl) return; FF9StateBattleSystem stateBattleSystem = FF9StateSystem.Battle.FF9Battle; KillSpecificCommand(btl, BattleCommandId.SysPhantom); - stateBattleSystem.cmd_status &= 65523; + stateBattleSystem.cmd_status &= 0xFFF3; stateBattleSystem.phantom_no = BattleAbilityId.Void; stateBattleSystem.phantom_cnt = 0; } @@ -1348,7 +1352,7 @@ public static void FinishCommand(FF9StateBattleSystem btlsys, CMD_DATA cmd) else if (commandId == BattleCommandId.JumpAttack) { caster.RemoveStatus(BattleStatus.Jump); - FF9StateSystem.Battle.FF9Battle.cmd_status &= 65519; + FF9StateSystem.Battle.FF9Battle.cmd_status &= 0xFFEF; } else if (commandId == BattleCommandId.JumpTrance) { @@ -1362,7 +1366,7 @@ public static void FinishCommand(FF9StateBattleSystem btlsys, CMD_DATA cmd) caster.Data.tar_mode = 2; caster.Data.SetDisappear(true, 2); } - FF9StateSystem.Battle.FF9Battle.cmd_status &= 65519; + FF9StateSystem.Battle.FF9Battle.cmd_status &= 0xFFEF; } if (IsNeedToDecreaseTrance(caster, commandId, cmd)) @@ -1398,7 +1402,7 @@ public static void FinishCommand(FF9StateBattleSystem btlsys, CMD_DATA cmd) caster.RemoveStatus(BattleStatus.Trance); } else - { + { if (caster.Trance - tranceDelta < Byte.MaxValue) caster.Trance += (Byte)(-tranceDelta); else @@ -1414,7 +1418,7 @@ public static void FinishCommand(FF9StateBattleSystem btlsys, CMD_DATA cmd) } else if (cmd.cmd_no == BattleCommandId.SysPhantom) { - btlsys.cmd_status &= 65527; + btlsys.cmd_status &= 0xFFF7; btlsys.phantom_cnt = GetPhantomCount(caster); } else if (cmd.cmd_no < BattleCommandId.EnemyCounter && CheckUsingCommand(caster.Data.cmd[0])) diff --git a/Assembly-CSharp/Global/ff9/ff9.cs b/Assembly-CSharp/Global/ff9/ff9.cs index 3fc1825d2..7cfbf8a9f 100644 --- a/Assembly-CSharp/Global/ff9/ff9.cs +++ b/Assembly-CSharp/Global/ff9/ff9.cs @@ -6522,13 +6522,13 @@ private static void w_movementShipOperation() private static void w_movementPlaneOperation() { - Int32 num; - ff9.w_moveGetPadStateLX(out num); - Int32 num2; - ff9.w_moveGetPadStateLY(out num2); - Int32 num3; - ff9.w_moveGetPadStateR(out num3); - if (num3 < 0) + Int32 leftStickX; + ff9.w_moveGetPadStateLX(out leftStickX); + Int32 leftStickY; + ff9.w_moveGetPadStateLY(out leftStickY); + Int32 rightStick; + ff9.w_moveGetPadStateR(out rightStick); + if (rightStick < 0) { ff9.w_movePadDOWN = true; } @@ -6536,8 +6536,8 @@ private static void w_movementPlaneOperation() { ff9.w_movePadDOWN = false; } - num2 = -num2; - Int32 num4 = num; + leftStickY = -leftStickY; + Int32 cameraChangeThreshold = leftStickX; ff9.w_moveCHRControl_LR = false; ff9.Pad pad = ff9.w_getPad(); if (pad.kPadR1 && pad.kPadL1 && !ff9.w_cameraSysData.cameraNotrot && ff9.w_moveAutoPilot != 0) @@ -6548,11 +6548,11 @@ private static void w_movementPlaneOperation() { if (pad.kPadL1) { - num = -127; + leftStickX = -127; } if (pad.kPadR1) { - num = 127; + leftStickX = 127; } } else @@ -6569,12 +6569,12 @@ private static void w_movementPlaneOperation() } } ff9.w_cameraSysDataCamera.rotationRev = 0f; - ff9.w_moveCHRControl_RotSpeed = ff9.PsxRot(ff9.w_moveCHRControlPtr.speed_rotation * num >> 7); - Single num5 = ff9.S(-(Int32)ff9.w_moveCHRControlPtr.speed_updown * num2 / ff9.p1); - ff9.w_moveCHRControl_YAlpha += (num5 - ff9.w_moveCHRControl_YAlpha) / ff9.p2; + ff9.w_moveCHRControl_RotSpeed = ff9.PsxRot(ff9.w_moveCHRControlPtr.speed_rotation * leftStickX >> 7); + Single verticalMovementSpeed = ff9.S(-(Int32)ff9.w_moveCHRControlPtr.speed_updown * leftStickY / ff9.p1); + ff9.w_moveCHRControl_YAlpha += (verticalMovementSpeed - ff9.w_moveCHRControl_YAlpha) / ff9.p2; ff9.w_moveCHRControl_YSpeed = ff9.w_moveCHRControl_YAlpha / ff9.p3; - num5 = ff9.S(ff9.w_moveCHRControlPtr.speed_move * num3 / ff9.p1); - ff9.w_moveCHRControl_XZAlpha += (num5 - ff9.w_moveCHRControl_XZAlpha) / ff9.p2; + verticalMovementSpeed = ff9.S(ff9.w_moveCHRControlPtr.speed_move * rightStick / ff9.p1); + ff9.w_moveCHRControl_XZAlpha += (verticalMovementSpeed - ff9.w_moveCHRControl_XZAlpha) / ff9.p2; ff9.w_moveCHRControl_XZSpeed = ff9.w_moveCHRControl_XZAlpha / ff9.p3; if (ff9.w_moveDoping) { @@ -6591,52 +6591,52 @@ private static void w_movementPlaneOperation() ff9.w_moveCHRControl_RotSpeed *= 580f - ff9.w_moveCHRControl_XZSpeed * 256f / 2f; ff9.w_moveCHRControl_RotSpeed /= 256f; } - if (num != 0 || num3 < 0) + if (leftStickX != 0 || rightStick < 0) { ff9.w_movementAutoPilotOFF(); } - Byte b = ff9.w_moveAutoPilot; - if (b != 1) + Byte autoPilotMode = ff9.w_moveAutoPilot; + if (autoPilotMode != 1) { - if (b == 2) + if (autoPilotMode == 2) { - Single num6 = -(ff9.S(ff9.w_naviLocationPos[ff9.w_naviMapno, ff9.w_frameAutoid].tx) - ff9.w_moveActorPtr.RealPosition[0]); - Single num7 = -(ff9.S(ff9.w_naviLocationPos[ff9.w_naviMapno, ff9.w_frameAutoid].ty) - ff9.w_moveActorPtr.RealPosition[2]); - if (num6 > ff9.S(196608)) + Single horizontalMovementSpeed = -(ff9.S(ff9.w_naviLocationPos[ff9.w_naviMapno, ff9.w_frameAutoid].tx) - ff9.w_moveActorPtr.RealPosition[0]); + Single speedFactorUpDown = -(ff9.S(ff9.w_naviLocationPos[ff9.w_naviMapno, ff9.w_frameAutoid].ty) - ff9.w_moveActorPtr.RealPosition[2]); + if (horizontalMovementSpeed > ff9.S(196608)) { - num6 -= ff9.S(393216); + horizontalMovementSpeed -= ff9.S(393216); } - if (num6 < ff9.S(-196608)) + if (horizontalMovementSpeed < ff9.S(-196608)) { - num6 += ff9.S(393216); + horizontalMovementSpeed += ff9.S(393216); } - if (num7 > ff9.S(163840)) + if (speedFactorUpDown > ff9.S(163840)) { - num7 -= ff9.S(327680); + speedFactorUpDown -= ff9.S(327680); } - if (num7 < ff9.S(-163840)) + if (speedFactorUpDown < ff9.S(-163840)) { - num7 += ff9.S(327680); + speedFactorUpDown += ff9.S(327680); } - Single num8 = (-ff9.ratan2(num7, num6) + ff9.PsxRot(1024)) % 360f; + Single speedFactorLR = (-ff9.ratan2(speedFactorUpDown, horizontalMovementSpeed) + ff9.PsxRot(1024)) % 360f; Vector3 rot = ff9.w_moveActorPtr.rot; - Single num9 = num8; - num9 -= rot[1]; - if (num9 < ff9.PsxRot(-2048)) + Single speedFactorForwardBackward = speedFactorLR; + speedFactorForwardBackward -= rot[1]; + if (speedFactorForwardBackward < ff9.PsxRot(-2048)) { - num9 += ff9.PsxRot(4096); + speedFactorForwardBackward += ff9.PsxRot(4096); } - if (num9 > ff9.PsxRot(2048)) + if (speedFactorForwardBackward > ff9.PsxRot(2048)) { - num9 -= ff9.PsxRot(4096); + speedFactorForwardBackward -= ff9.PsxRot(4096); } if (ff9.w_moveCHRControl_AutoPrev > ff9.S(50)) { - if (num9 > ff9.PsxRot(20)) + if (speedFactorForwardBackward > ff9.PsxRot(20)) { ff9.w_moveCHRControl_RotSpeed = ff9.PsxRot(20); } - else if (num9 < ff9.PsxRot(-20)) + else if (speedFactorForwardBackward < ff9.PsxRot(-20)) { ff9.w_moveCHRControl_RotSpeed = ff9.PsxRot(-20); } @@ -6649,9 +6649,9 @@ private static void w_movementPlaneOperation() } else { - Single num10 = (ff9.S(ff9.w_naviLocationPos[ff9.w_naviMapno, ff9.w_frameAutoid].tx) - ff9.w_moveActorPtr.RealPosition[0]) / 32f; - Single num11 = (ff9.S(ff9.w_naviLocationPos[ff9.w_naviMapno, ff9.w_frameAutoid].ty) - ff9.w_moveActorPtr.RealPosition[2]) / 32f; - ff9.w_moveCHRControl_XZSpeed = ff9.SquareRoot0(num10 * num10 + num11 * num11); + Single distanceToTargetX = (ff9.S(ff9.w_naviLocationPos[ff9.w_naviMapno, ff9.w_frameAutoid].tx) - ff9.w_moveActorPtr.RealPosition[0]) / 32f; + Single distanceToTargetY = (ff9.S(ff9.w_naviLocationPos[ff9.w_naviMapno, ff9.w_frameAutoid].ty) - ff9.w_moveActorPtr.RealPosition[2]) / 32f; + ff9.w_moveCHRControl_XZSpeed = ff9.SquareRoot0(distanceToTargetX * distanceToTargetX + distanceToTargetY * distanceToTargetY); if (ff9.w_moveCHRControl_XZSpeed > ff9.S(400)) { ff9.w_moveCHRControl_XZSpeed = ff9.S(400); @@ -6664,31 +6664,31 @@ private static void w_movementPlaneOperation() } Vector3 rot2 = ff9.w_moveActorPtr.rot; Int32 index2; - Single num12; + Single rotationChange; if (rot2[2] > 180f) { Int32 index = index2 = 2; - num12 = rot2[index2]; - rot2[index] = num12 - 360f; + rotationChange = rot2[index2]; + rot2[index] = rotationChange - 360f; } Int32 index3 = index2 = 1; - num12 = rot2[index2]; - rot2[index3] = num12 + ff9.w_moveCHRControl_RotSpeed; + rotationChange = rot2[index2]; + rot2[index3] = rotationChange + ff9.w_moveCHRControl_RotSpeed; Int32 index4 = index2 = 1; - num12 = rot2[index2]; - rot2[index4] = num12 % 360f; + rotationChange = rot2[index2]; + rot2[index4] = rotationChange % 360f; ff9.w_moveCHRControl_RotTrue = rot2[1] % 360f; - if (ff9.w_moveCHRControl_RotSpeed > 0f && ff9.w_cameraRotAngle > ff9.PsxRot(-(num4 * 1))) + if (ff9.w_moveCHRControl_RotSpeed > 0f && ff9.w_cameraRotAngle > ff9.PsxRot(-(cameraChangeThreshold * 1))) { - ff9.w_cameraRotAngle += ff9.PsxRot(num4 / 8); + ff9.w_cameraRotAngle += ff9.PsxRot(cameraChangeThreshold / 8); } - if (ff9.w_moveCHRControl_RotSpeed < 0f && ff9.w_cameraRotAngle < ff9.PsxRot(-(num4 * 1))) + if (ff9.w_moveCHRControl_RotSpeed < 0f && ff9.w_cameraRotAngle < ff9.PsxRot(-(cameraChangeThreshold * 1))) { - ff9.w_cameraRotAngle += ff9.PsxRot(num4 / 8); + ff9.w_cameraRotAngle += ff9.PsxRot(cameraChangeThreshold / 8); } if (ff9.UnityUnit(ff9.w_moveCHRControl_XZSpeed) == 0) { - ff9.w_cameraRotAngle += ff9.PsxRot(num4 / 8); + ff9.w_cameraRotAngle += ff9.PsxRot(cameraChangeThreshold / 8); } if (ff9.w_cameraRotAngle > ff9.PsxRot(ff9.w_moveCHRControlPtr.speed_roll)) { @@ -6698,17 +6698,17 @@ private static void w_movementPlaneOperation() { ff9.w_cameraRotAngle = ff9.PsxRot(-ff9.w_moveCHRControlPtr.speed_roll); } - if (ff9.w_moveCHRControl_RotSpeed > 0f && rot2[2] > ff9.PsxRot(-(num4 * 2))) + if (ff9.w_moveCHRControl_RotSpeed > 0f && rot2[2] > ff9.PsxRot(-(cameraChangeThreshold * 2))) { Int32 index5 = index2 = 2; - num12 = rot2[index2]; - rot2[index5] = num12 + ff9.PsxRot(num4 / 4); + rotationChange = rot2[index2]; + rot2[index5] = rotationChange + ff9.PsxRot(cameraChangeThreshold / 4); } - if (ff9.w_moveCHRControl_RotSpeed < 0f && rot2[2] < ff9.PsxRot(-(num4 * 2))) + if (ff9.w_moveCHRControl_RotSpeed < 0f && rot2[2] < ff9.PsxRot(-(cameraChangeThreshold * 2))) { Int32 index6 = index2 = 2; - num12 = rot2[index2]; - rot2[index6] = num12 + ff9.PsxRot(num4 / 4); + rotationChange = rot2[index2]; + rot2[index6] = rotationChange + ff9.PsxRot(cameraChangeThreshold / 4); } if (rot2[2] > ff9.PsxRot(ff9.w_moveCHRControlPtr.speed_roll * 2)) { @@ -6721,7 +6721,7 @@ private static void w_movementPlaneOperation() ff9.w_moveActorPtr.rot = rot2; if ((ff9.w_frameCounter & 1) != 0) { - Int64 num13 = ff9.m_GetIDTopograph(ff9.m_moveActorID); + Int64 rollSpeedThreshold = ff9.m_GetIDTopograph(ff9.m_moveActorID); Boolean flag = ff9.w_movementCheckTopographID(ff9.w_movementWaterStatus, ff9.m_moveActorID); switch (ff9.w_moveActorPtr.originalActor.index) { @@ -6731,8 +6731,8 @@ private static void w_movementPlaneOperation() { ff9.w_effectRegist(ff9.w_moveActorPtr.pos[0], ff9.S(200), ff9.w_moveActorPtr.pos[2], 6, 19200); } - Int32 num14 = (Int32)(ff9.w_moveCHRControl_XZSpeed * 256f); - if (num13 == 41L && num14 != 0 && ff9.w_moveActorPtr.pos[1] <= ff9.SH2) + Int32 rotationSpeed = (Int32)(ff9.w_moveCHRControl_XZSpeed * 256f); + if (rollSpeedThreshold == 41L && rotationSpeed != 0 && ff9.w_moveActorPtr.pos[1] <= ff9.SH2) { ff9.w_effectRegist(ff9.w_moveActorPtr.pos[0], ff9.w_moveActorPtr.pos[1] + ff9.S(-100), ff9.w_moveActorPtr.pos[2], 14, 25600); } @@ -6745,27 +6745,27 @@ private static void w_movementPlaneOperation() { ff9.w_effectMoveStockHeight = 4096 - ff9.abs((Int32)(ff9.w_moveActorPtr.pos[1] * 256f) - 400) * 2; ff9.w_effectRegist(ff9.w_moveActorPtr.pos[0], ff9.S(200), ff9.w_moveActorPtr.pos[2], 18, 32000); - Int32 num15 = ff9.abs((Int32)(ff9.w_moveCHRControl_XZSpeed * 256f)); - if (num15 > 511) + Int32 effectStockHeight = ff9.abs((Int32)(ff9.w_moveCHRControl_XZSpeed * 256f)); + if (effectStockHeight > 511) { - num15 = 511; + effectStockHeight = 511; } - Int32 num16 = (Int32)(ff9.abs(ff9.w_moveActorPtr.pos[1]) * 256f) >> 6; - if (num16 > 48) + Int32 heightThreshold = (Int32)(ff9.abs(ff9.w_moveActorPtr.pos[1]) * 256f) >> 6; + if (heightThreshold > 48) { - num16 = 48; + heightThreshold = 48; } - num16 = 48 - num16; - num16 *= num15; - num16 >>= 9; - ff9.w_musicSEVolumeIntpl(38, 20, (Byte)num16); + heightThreshold = 48 - heightThreshold; + heightThreshold *= effectStockHeight; + heightThreshold >>= 9; + ff9.w_musicSEVolumeIntpl(38, 20, (Byte)heightThreshold); } else { ff9.w_musicSEVolumeIntpl(38, 30, 0); } - Int32 num17 = (Int32)(ff9.w_moveCHRControl_XZSpeed * 256f); - if (num13 == 41L && num17 != 0 && ff9.w_moveActorPtr.pos[1] <= ff9.SH1) + Int32 speedThreshold = (Int32)(ff9.w_moveCHRControl_XZSpeed * 256f); + if (rollSpeedThreshold == 41L && speedThreshold != 0 && ff9.w_moveActorPtr.pos[1] <= ff9.SH1) { ff9.w_effectMoveStockHeight = 4096 - ((Int32)(ff9.w_moveActorPtr.pos[1] * 256f) + 1300) * 2; ff9.w_effectRegist(ff9.w_moveActorPtr.pos[0], ff9.w_moveActorPtr.pos[1] + ff9.S(-100), ff9.w_moveActorPtr.pos[2], 19, 32000); @@ -6778,21 +6778,21 @@ private static void w_movementPlaneOperation() private static void w_movementHumanCamOperation() { - Single num = (ff9.w_cameraSysDataCamera.rotation + ff9.w_cameraSysDataCamera.rotationRev) % 360f; - Single num2 = ff9.w_moveCHRControl_RotTrue % 360f; - if (num - num2 >= ff9.PsxRot(2048)) + Single cameraRotation = (ff9.w_cameraSysDataCamera.rotation + ff9.w_cameraSysDataCamera.rotationRev) % 360f; + Single characterRotation = ff9.w_moveCHRControl_RotTrue % 360f; + if (cameraRotation - characterRotation >= ff9.PsxRot(2048)) { - num -= ff9.PsxRot(4096); + cameraRotation -= ff9.PsxRot(4096); } - if (num - num2 < ff9.PsxRot(-2048)) + if (cameraRotation - characterRotation < ff9.PsxRot(-2048)) { - num += ff9.PsxRot(4096); + cameraRotation += ff9.PsxRot(4096); } - Single num3 = (ff9.w_moveCHRControl_RotTrue - num) * ff9.PsxRot(3072) / ff9.PsxRot(4096); + Single rotationDifference = (ff9.w_moveCHRControl_RotTrue - cameraRotation) * ff9.PsxRot(3072) / ff9.PsxRot(4096); ff9.cn5 = ff9.abs(ff9.w_cameraSysDataCamera.rotationMax) / 8f; - if (ff9.abs(num3) < ff9.cn5) + if (ff9.abs(rotationDifference) < ff9.cn5) { - num3 = 0f; + rotationDifference = 0f; } if (ff9.UnityUnit(ff9.w_moveCHRControl_XZSpeed) != 0) { @@ -6808,7 +6808,7 @@ private static void w_movementHumanCamOperation() } if (!ff9.w_moveCHRControl_LR && !ff9.w_cameraSysData.cameraNotrot && ff9.w_framePhase == 2) { - ff9.cn2 = ff9.abs(num3); + ff9.cn2 = ff9.abs(rotationDifference); if (ff9.cn2 < ff9.cn3) { ff9.cn2 = ff9.cn3; @@ -6817,17 +6817,17 @@ private static void w_movementHumanCamOperation() { ff9.cn2 = ff9.cn4; } - Single num4 = num3 * ff9.S(256) / ff9.cn2; - Single num5 = ((ff9.PsxRot(2048) - ff9.abs(num3)) * ff9.cn1 + 2048f) * 2f; - num5 = num5 * ff9.w_movementCamRemain / 4096f; - ff9.w_cameraSysDataCamera.rotation += num4 * num5 / 4096f; + Single rotationFactor = rotationDifference * ff9.S(256) / ff9.cn2; + Single rotationSpeedFactor = ((ff9.PsxRot(2048) - ff9.abs(rotationDifference)) * ff9.cn1 + 2048f) * 2f; + rotationSpeedFactor = rotationSpeedFactor * ff9.w_movementCamRemain / 4096f; + ff9.w_cameraSysDataCamera.rotation += rotationFactor * rotationSpeedFactor / 4096f; } ff9.w_cameraSysDataCamera.rotation %= 360f; } private static void w_movementPlaneCamOperation() { - Single num = ff9.w_cameraSysDataCamera.rotation; + Single cameraRotation = ff9.w_cameraSysDataCamera.rotation; if (ff9.w_cameraSysDataCamera.rotation - ff9.w_moveActorPtr.rot[1] > ff9.PsxRot(2048)) { ff9.w_cameraSysDataCamera.rotation -= ff9.PsxRot(4096); @@ -6836,58 +6836,58 @@ private static void w_movementPlaneCamOperation() { ff9.w_cameraSysDataCamera.rotation += ff9.PsxRot(4096); } - if (num < 0f) + if (cameraRotation < 0f) { - num += ff9.PsxRot(4096); + cameraRotation += ff9.PsxRot(4096); } - num %= ff9.PsxRot(4096); - if (num - ff9.w_moveActorPtr.rot[1] > ff9.PsxRot(2048)) + cameraRotation %= ff9.PsxRot(4096); + if (cameraRotation - ff9.w_moveActorPtr.rot[1] > ff9.PsxRot(2048)) { - num -= ff9.PsxRot(4096); + cameraRotation -= ff9.PsxRot(4096); } - if (num - ff9.w_moveActorPtr.rot[1] < ff9.PsxRot(-2048)) + if (cameraRotation - ff9.w_moveActorPtr.rot[1] < ff9.PsxRot(-2048)) { - num += ff9.PsxRot(4096); + cameraRotation += ff9.PsxRot(4096); } - Single num2 = ff9.w_moveActorPtr.rot[1] - num; - num2 %= ff9.PsxRot(4096); + Single rotationDifference = ff9.w_moveActorPtr.rot[1] - cameraRotation; + rotationDifference %= ff9.PsxRot(4096); if (!ff9.w_moveCHRControl_LR && !ff9.w_cameraSysData.cameraNotrot) { - Int32 num3 = ff9.UnityRot(num2); - Int32 num4 = 16; + Int32 rotationDelta = ff9.UnityRot(rotationDifference); + Int32 rotationFactor = 16; if (ff9.w_movementSoftRot) { - num4 = ff9.abs(num3) * 256 >> 12; - if (num4 == 0) + rotationFactor = ff9.abs(rotationDelta) * 256 >> 12; + if (rotationFactor == 0) { - num4 = 1; + rotationFactor = 1; } } - Int32 num5 = num3 % 4096 / num4; - if (num5 != 0) + Int32 rotationIncrement = rotationDelta % 4096 / rotationFactor; + if (rotationIncrement != 0) { - ff9.w_cameraSysDataCamera.rotation += ff9.PsxRot((UInt16)num5); + ff9.w_cameraSysDataCamera.rotation += ff9.PsxRot((UInt16)rotationIncrement); } - else if (num4 > 1) + else if (rotationFactor > 1) { do { - num4 /= 2; - if (num4 == 0) + rotationFactor /= 2; + if (rotationFactor == 0) { break; } - num5 = num3 % 4096 / num4; + rotationIncrement = rotationDelta % 4096 / rotationFactor; } - while (num5 == 0); - ff9.w_cameraSysDataCamera.rotation += ff9.PsxRot((UInt16)num5); + while (rotationIncrement == 0); + ff9.w_cameraSysDataCamera.rotation += ff9.PsxRot((UInt16)rotationIncrement); } else { ff9.w_cameraSysDataCamera.rotation = ff9.w_moveActorPtr.rot[1]; } ff9.w_cameraSysDataCamera.rotation %= 360f; - if (ff9.abs(num3) < 100) + if (ff9.abs(rotationDelta) < 100) { ff9.w_movementSoftRot = false; } @@ -7167,11 +7167,11 @@ public static void w_musicSEPlay(Int32 seno, Byte vol) ff9.s_musicID s_musicID; if (ff9.w_musicGetID(seno, out s_musicID)) { - Int32 num = s_musicID.attr; + Int32 attributeNum = s_musicID.attr; for (Int32 i = 0; i < s_musicID.figure; i++) { - FF9Snd.ff9wldsnd_sndeffect_play(s_musicID.id[i], num, vol, 127); - num >>= 1; + FF9Snd.ff9wldsnd_sndeffect_play(s_musicID.id[i], attributeNum, vol, 127); + attributeNum >>= 1; } } } @@ -7181,11 +7181,11 @@ public static void w_musicSEVolume(Int64 seno, Byte vol) ff9.s_musicID s_musicID; if (ff9.w_musicProgress == 0 && ff9.w_musicGetID(seno, out s_musicID)) { - Int32 num = s_musicID.attr; + Int32 attributeNum = s_musicID.attr; for (Int32 i = 0; i < s_musicID.figure; i++) { - FF9Snd.ff9wldsnd_sndeffect_vol(s_musicID.id[i], num, vol); - num >>= 1; + FF9Snd.ff9wldsnd_sndeffect_vol(s_musicID.id[i], attributeNum, vol); + attributeNum >>= 1; } } } @@ -7195,11 +7195,11 @@ public static void w_musicSEVolumeIntpl(Int32 seno, UInt16 tick, Byte vol) ff9.s_musicID s_musicID; if (ff9.w_musicGetID(seno, out s_musicID)) { - Int32 num = s_musicID.attr; + Int32 attributeNum = s_musicID.attr; for (Int32 i = 0; i < s_musicID.figure; i++) { - FF9Snd.ff9wldsnd_sndeffect_vol_intpl(s_musicID.id[i], num, tick, vol); - num >>= 1; + FF9Snd.ff9wldsnd_sndeffect_vol_intpl(s_musicID.id[i], attributeNum, tick, vol); + attributeNum >>= 1; } } } @@ -7209,11 +7209,11 @@ public static void w_musicSEStop(Int32 seno) ff9.s_musicID s_musicID; if (ff9.w_musicGetID(seno, out s_musicID)) { - Int32 num = s_musicID.attr; + Int32 attributeNum = s_musicID.attr; for (Int32 i = 0; i < s_musicID.figure; i++) { - FF9Snd.ff9wldsnd_sndeffect_stop(s_musicID.id[i], num); - num >>= 1; + FF9Snd.ff9wldsnd_sndeffect_stop(s_musicID.id[i], attributeNum); + attributeNum >>= 1; } } } diff --git a/Assembly-CSharp/Memoria/Application/SmoothFrameUpdater_Field.cs b/Assembly-CSharp/Memoria/Application/SmoothFrameUpdater_Field.cs index 09cf7409e..ce06c4ee4 100644 --- a/Assembly-CSharp/Memoria/Application/SmoothFrameUpdater_Field.cs +++ b/Assembly-CSharp/Memoria/Application/SmoothFrameUpdater_Field.cs @@ -76,7 +76,7 @@ public static void RegisterState() { foreach (BGOVERLAY_DEF bgLayer in fieldmap.scene.overlayList) { - if (bgLayer.transform != null && (bgLayer.flags & BGOVERLAY_DEF.OVERLAY_FLAG.Active) != 0) + if (bgLayer.transform != null && !((bgLayer.flags & BGOVERLAY_DEF.OVERLAY_FLAG.Loop) != 0) && !((bgLayer.flags & BGOVERLAY_DEF.OVERLAY_FLAG.ScrollWithOffset) != 0) ) // && (bgLayer.flags & BGOVERLAY_DEF.OVERLAY_FLAG.Active) != 0) { if (bgLayer._smoothUpdateRegistered) bgLayer._smoothUpdatePosPrevious = bgLayer._smoothUpdatePosActual; @@ -141,8 +141,8 @@ public static void Apply(Single smoothFactor) { foreach (BGOVERLAY_DEF bgLayer in fieldmap.scene.overlayList) { - if (bgLayer.transform != null && (bgLayer.flags & BGOVERLAY_DEF.OVERLAY_FLAG.Active) != 0 && bgLayer._smoothUpdateRegistered) - { + if (bgLayer.transform != null && bgLayer._smoothUpdateRegistered) // && (bgLayer.flags & BGOVERLAY_DEF.OVERLAY_FLAG.Active) != 0 + { Vector3 frameMove = bgLayer._smoothUpdatePosActual - bgLayer._smoothUpdatePosPrevious; if (frameMove.sqrMagnitude > 0f && frameMove.sqrMagnitude < OverlaySmoothMovementMaxSqr) bgLayer.transform.position = bgLayer._smoothUpdatePosActual + smoothFactor * frameMove; @@ -187,8 +187,8 @@ public static void ResetState() } if (fieldmap?.scene?.overlayList != null) foreach (BGOVERLAY_DEF bgLayer in fieldmap.scene.overlayList) - if (bgLayer.transform != null && (bgLayer.flags & BGOVERLAY_DEF.OVERLAY_FLAG.Active) != 0 && bgLayer._smoothUpdateRegistered) - bgLayer.transform.position = bgLayer._smoothUpdatePosActual; + if (bgLayer.transform != null && bgLayer._smoothUpdateRegistered) // && (bgLayer.flags & BGOVERLAY_DEF.OVERLAY_FLAG.Active) != 0 + bgLayer.transform.position = bgLayer._smoothUpdatePosActual; if (_cameraRegistered) { Camera mainCamera = fieldmap?.GetMainCamera(); diff --git a/Assembly-CSharp/Memoria/Assets/Export/Grahpics/Export/FieldSceneExporter.cs b/Assembly-CSharp/Memoria/Assets/Export/Grahpics/Export/FieldSceneExporter.cs index 3ada815d8..847443c8e 100644 --- a/Assembly-CSharp/Memoria/Assets/Export/Grahpics/Export/FieldSceneExporter.cs +++ b/Assembly-CSharp/Memoria/Assets/Export/Grahpics/Export/FieldSceneExporter.cs @@ -252,7 +252,7 @@ private static void ExportOverlay(BGOVERLAY_DEF overlay, Texture2D atlas, String TextureHelper.WriteTextureToFile(result, outputPath); layer.Name = Path.GetFileNameWithoutExtension(outputPath); layer.Opacity = 255; - layer.Rect = new Rectangle(overlay.curX * factor, overlay.curY * factor, textureWidth, textureHeight); + layer.Rect = new Rectangle((short)overlay.curX * factor, (short)overlay.curY * factor, textureWidth, textureHeight); layer.Masks = new MaskInfo(); layer.BlendingRangesData = new BlendingRanges(layer); layer.CreateMissingChannels(); diff --git a/Assembly-CSharp/Memoria/Assets/FieldCreator/FieldCreatorScene.cs b/Assembly-CSharp/Memoria/Assets/FieldCreator/FieldCreatorScene.cs index 0e332c39c..74a6f4324 100644 --- a/Assembly-CSharp/Memoria/Assets/FieldCreator/FieldCreatorScene.cs +++ b/Assembly-CSharp/Memoria/Assets/FieldCreator/FieldCreatorScene.cs @@ -453,8 +453,8 @@ private static void ExportField() // Update the overlay Org positions with their Cur positions foreach (BGOVERLAY_DEF bgOverlay in scene.overlayList) { - bgOverlay.orgX = bgOverlay.curX; - bgOverlay.orgY = bgOverlay.curY; + bgOverlay.orgX = (short)bgOverlay.curX; + bgOverlay.orgY = (short)bgOverlay.curY; bgOverlay.orgZ = bgOverlay.curZ; } diff --git a/Assembly-CSharp/Memoria/Configuration/Access/Audio.cs b/Assembly-CSharp/Memoria/Configuration/Access/Audio.cs index 1a2324bab..a5f4a687e 100644 --- a/Assembly-CSharp/Memoria/Configuration/Access/Audio.cs +++ b/Assembly-CSharp/Memoria/Configuration/Access/Audio.cs @@ -27,6 +27,8 @@ public static Int32 MovieVolume public static Boolean PriorityToOGG => Instance._audio.PriorityToOGG; + public static Int32 Backend => Instance._audio.Backend; + public static void SaveSoundVolume() { SaveValue(Instance._audio.Name, Instance._audio.SoundVolume); diff --git a/Assembly-CSharp/Memoria/Configuration/Access/Graphics.cs b/Assembly-CSharp/Memoria/Configuration/Access/Graphics.cs index cf1180363..03bf82cc1 100644 --- a/Assembly-CSharp/Memoria/Configuration/Access/Graphics.cs +++ b/Assembly-CSharp/Memoria/Configuration/Access/Graphics.cs @@ -1,3 +1,4 @@ +using Memoria.Prime; using System; using UnityEngine; @@ -20,6 +21,7 @@ public static class Graphics public static Int32 GarnetHair => Instance._graphics.GarnetHair; public static Int32 TileSize => Instance._graphics.TileSize; public static Int32 AntiAliasing => Instance._graphics.AntiAliasing; + public static Int32 CameraStabilizer => Instance._graphics.CameraStabilizer; private static volatile Boolean _widescreenSupport = InitializeWidescreenSupport(); @@ -31,8 +33,12 @@ public static Boolean InitializeWidescreenSupport() return false; if ((Math.Abs(((Double)Screen.width / (Double)Screen.height) - (16d / 9d)) < 0.01) || (Math.Abs(((Double)Screen.width / (Double)Screen.height) - (16d / 10d)) < 0.01)) + { + //Log.Message("WIDESCREEN | Screen.width:" + (Double)Screen.width + " Screen.height:" + (Double)Screen.height); return true; + } + //Log.Message("Not Widescreen | Screen.width:" + (Double)Screen.width + " Screen.height:" + (Double)Screen.height); return false; } public static Boolean ScreenIs16to10() diff --git a/Assembly-CSharp/Memoria/Configuration/Access/Hacks.cs b/Assembly-CSharp/Memoria/Configuration/Access/Hacks.cs index 7b637cf35..944c4ad99 100644 --- a/Assembly-CSharp/Memoria/Configuration/Access/Hacks.cs +++ b/Assembly-CSharp/Memoria/Configuration/Access/Hacks.cs @@ -13,6 +13,7 @@ public static class Hacks public static Int32 HippaulRacingViviSpeed => Instance._hacks.HippaulRacingViviSpeed; public static Int32 StealingAlwaysWorks => Instance._hacks.StealingAlwaysWorks; public static Boolean DisableNameChoice => Instance._hacks.DisableNameChoice; + public static Boolean ExcaliburIINoTimeLimit => Instance._hacks.ExcaliburIINoTimeLimit; } } } diff --git a/Assembly-CSharp/Memoria/Configuration/Access/VoiceActing.cs b/Assembly-CSharp/Memoria/Configuration/Access/VoiceActing.cs index 31ba6e61b..352004e90 100644 --- a/Assembly-CSharp/Memoria/Configuration/Access/VoiceActing.cs +++ b/Assembly-CSharp/Memoria/Configuration/Access/VoiceActing.cs @@ -12,19 +12,19 @@ public static class VoiceActing public static Boolean LogVoiceActing => Instance._voiceActing.LogVoiceActing; public static Boolean StopVoiceWhenDialogDismissed = Instance._voiceActing.StopVoiceWhenDialogDismissed; public static Boolean AutoDismissDialogAfterCompletion = Instance._voiceActing.AutoDismissDialogAfterCompletion; - public static Int32 Volume - { - get => Instance._voiceActing.Volume; - set => Instance._voiceActing.Volume.Value = value; - } + public static Int32 Volume = Instance._voiceActing.Volume.Value; public static void SaveVolume() { - // We need to make sure VoiceActing is enabled otherwise the volume won't apply - // This can happen if a mod enable the VoiceActing - SaveValue(Instance._voiceActing.Name, Instance._voiceActing.Enabled); + Instance._voiceActing.Volume.Value = Volume; SaveValue(Instance._voiceActing.Name, Instance._voiceActing.Volume); } + + public static void SaveAutoText() + { + Instance._voiceActing.AutoDismissDialogAfterCompletion.Value = AutoDismissDialogAfterCompletion; + SaveValue(Instance._voiceActing.Name, Instance._voiceActing.AutoDismissDialogAfterCompletion); + } } } } \ No newline at end of file diff --git a/Assembly-CSharp/Memoria/Configuration/Memoria.ini b/Assembly-CSharp/Memoria/Configuration/Memoria.ini index a907a93ae..cd9ee4d07 100644 --- a/Assembly-CSharp/Memoria/Configuration/Memoria.ini +++ b/Assembly-CSharp/Memoria/Configuration/Memoria.ini @@ -32,6 +32,7 @@ PriorityToOGG = 0 ; GarnetHair (default 0) 0 = Default / 1 = Long / 2 = Short ; TileSize (default 32) Vanilla 32 / Moguri Mod 64 ; AntiAliasing (default 8) Must be either 0, 2, 4 or 8: enable Unity's anti-aliasing algorithm to improve the render of 3D model edges + ; CameraStabilizer (0 to 99, default 85) Adds a smooth delay on the camera following the player. Value represents "stickiness" of camera to its original position, each frame. Enabled = 0 BattleFPS = 30 BattleTPS = 15 @@ -47,6 +48,7 @@ SkipIntros = 0 GarnetHair = 0 TileSize = 32 AntiAliasing = 8 +CameraStabilizer = 85 [Control] ; DisableMouse (default 0) 0 = Can use the mouse to navigate in menus and move on the fields / 7 = Disable the mouse completly / 1 = Disable mouse for field menus and dialogs / 2 = Disable mouse for field movements / 4 = Disable mouse for battle menus @@ -174,6 +176,7 @@ GilMax = 0 ; HippaulRacingViviSpeed (default 33) Vivi's speed in the hippaul racing ; StealingAlwaysWorks (default 0) 1 = Always steals when move succeeds / 2 = Stealing has a 100% success rate (bandit ability) ; DisableNameChoice (default 0) Skip the character renaming windows + ; ExcaliburIINoTimeLimit (default 0) Give Excalibur II even when time is over Enabled = 0 AllCharactersAvailable = 0 RopeJumpingIncrement = 1 @@ -181,6 +184,7 @@ FrogCatchingIncrement = 1 HippaulRacingViviSpeed = 33 StealingAlwaysWorks = 0 DisableNameChoice = 0 +ExcaliburIINoTimeLimit = 0 [TetraMaster] ; TripleTriad (defaut 0) 0 = Tetra Master / 1 = "Tetra Triad" (a mix with both card games!) / 2 = Triple Triad (like FF8!) diff --git a/Assembly-CSharp/Memoria/Configuration/Structure/AudioSection.cs b/Assembly-CSharp/Memoria/Configuration/Structure/AudioSection.cs index adc718f8e..4d416b078 100644 --- a/Assembly-CSharp/Memoria/Configuration/Structure/AudioSection.cs +++ b/Assembly-CSharp/Memoria/Configuration/Structure/AudioSection.cs @@ -11,6 +11,7 @@ private sealed class AudioSection : IniSection public readonly IniValue MusicVolume; public readonly IniValue MovieVolume; public readonly IniValue PriorityToOGG; + public readonly IniValue Backend; public AudioSection() : base(nameof(AudioSection), true) { @@ -18,6 +19,7 @@ public AudioSection() : base(nameof(AudioSection), true) MusicVolume = BindInt32(nameof(MusicVolume), 100); MovieVolume = BindInt32(nameof(MovieVolume), 100); PriorityToOGG = BindBoolean(nameof(PriorityToOGG), false); + Backend = BindInt32(nameof(Backend), 1); } } } diff --git a/Assembly-CSharp/Memoria/Configuration/Structure/GraphicsSection.cs b/Assembly-CSharp/Memoria/Configuration/Structure/GraphicsSection.cs index fe63262ff..cfa72543f 100644 --- a/Assembly-CSharp/Memoria/Configuration/Structure/GraphicsSection.cs +++ b/Assembly-CSharp/Memoria/Configuration/Structure/GraphicsSection.cs @@ -21,6 +21,7 @@ private sealed class GraphicsSection : IniSection public readonly IniValue AntiAliasing; public readonly IniValue SkipIntros; public readonly IniValue GarnetHair; + public readonly IniValue CameraStabilizer; public GraphicsSection() : base(nameof(GraphicsSection), false) { @@ -38,6 +39,7 @@ public GraphicsSection() : base(nameof(GraphicsSection), false) AntiAliasing = BindInt32(nameof(AntiAliasing), 0); SkipIntros = BindInt32(nameof(SkipIntros), 0); GarnetHair = BindInt32(nameof(GarnetHair), 0); + CameraStabilizer = BindInt32(nameof(CameraStabilizer), 0); } } } diff --git a/Assembly-CSharp/Memoria/Configuration/Structure/HacksSection.cs b/Assembly-CSharp/Memoria/Configuration/Structure/HacksSection.cs index a3d9828b6..7e9cdb649 100644 --- a/Assembly-CSharp/Memoria/Configuration/Structure/HacksSection.cs +++ b/Assembly-CSharp/Memoria/Configuration/Structure/HacksSection.cs @@ -14,6 +14,7 @@ private sealed class HacksSection : IniSection public readonly IniValue HippaulRacingViviSpeed; public readonly IniValue StealingAlwaysWorks; public readonly IniValue DisableNameChoice; + public readonly IniValue ExcaliburIINoTimeLimit; public HacksSection() : base(nameof(HacksSection), false) { @@ -24,6 +25,7 @@ public HacksSection() : base(nameof(HacksSection), false) HippaulRacingViviSpeed = BindInt32(nameof(HippaulRacingViviSpeed), 33); StealingAlwaysWorks = BindInt32(nameof(StealingAlwaysWorks), 0); DisableNameChoice = BindBoolean(nameof(DisableNameChoice), false); + ExcaliburIINoTimeLimit = BindBoolean(nameof(ExcaliburIINoTimeLimit), false); } } } diff --git a/Assembly-CSharp/Memoria/VoiceActing/BattleVoice.cs b/Assembly-CSharp/Memoria/VoiceActing/BattleVoice.cs index e3a89628e..65d85c382 100644 --- a/Assembly-CSharp/Memoria/VoiceActing/BattleVoice.cs +++ b/Assembly-CSharp/Memoria/VoiceActing/BattleVoice.cs @@ -63,7 +63,7 @@ public BTL_DATA FindBtlUnlimited() public static Boolean CheckCanSpeak(BTL_DATA btl, Int32 voicePriority, BattleStatus statusException = 0) { - if (btl.bi.disappear != 0) + if (btl.bi.disappear != 0 && ((statusException & BattleStatus.Jump) == 0 || !btl_stat.CheckStatus(btl, BattleStatus.Jump))) return false; if (btl_stat.CheckStatus(btl, BattleStatusConst.CannotSpeak & ~statusException)) return false; @@ -238,6 +238,7 @@ public static void TriggerOnBattleInOut(String when) } catch (Exception err) { + Log.Error($"[VoiceActing] Couldn't evaluate condition: '{effect.Condition.Trim()}'"); Log.Error(err); continue; } @@ -295,6 +296,7 @@ public static void TriggerOnBattleAct(BTL_DATA actingChar, String when, CMD_DATA } catch (Exception err) { + Log.Error($"[VoiceActing] Couldn't evaluate condition: '{effect.Condition.Trim()}'"); Log.Error(err); continue; } @@ -341,6 +343,7 @@ public static void TriggerOnHitted(BTL_DATA hittedChar, BattleCalculator calc) } catch (Exception err) { + Log.Error($"[VoiceActing] Couldn't evaluate condition: '{effect.Condition.Trim()}'"); Log.Error(err); continue; } @@ -389,6 +392,7 @@ public static void TriggerOnStatusChange(BTL_DATA statusedChar, String when, Bat } catch (Exception err) { + Log.Error($"[VoiceActing] Couldn't evaluate condition: '{effect.Condition.Trim()}'"); Log.Error(err); continue; } diff --git a/Assembly-CSharp/Memoria/VoiceActing/VoicePlayer.cs b/Assembly-CSharp/Memoria/VoiceActing/VoicePlayer.cs index 4300b3bf2..3a2b3061b 100644 --- a/Assembly-CSharp/Memoria/VoiceActing/VoicePlayer.cs +++ b/Assembly-CSharp/Memoria/VoiceActing/VoicePlayer.cs @@ -75,9 +75,8 @@ public void StartSound(SoundProfile soundProfile, Action onFinished = null) SoundLib.Log("failed to play sound"); soundProfile.SoundID = 0; return; - } - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * this.Volume, 0); - SoundLib.Log("Panning: " + soundProfile.Panning); + } + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * this.Volume, 0); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPanning(soundProfile.SoundID, soundProfile.Panning, 0); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPitch(soundProfile.SoundID, soundProfile.Pitch, 0); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); @@ -92,6 +91,7 @@ public static void PlayFieldZoneDialogAudio(Int32 FieldZoneId, Int32 messageNumb String vaPath = String.Format("Voices/{0}/{1}/va_{2}", Localization.GetSymbol(), FieldZoneId, messageNumber); Boolean useAlternatePath = false; String vaAlternatePath = null; + String vaAlternatePath2 = null; if (dialog.Po != null) { vaAlternatePath = String.Format("Voices/{0}/{1}/va_{2}_{3}", Localization.GetSymbol(), FieldZoneId, messageNumber, dialog.Po.uid); @@ -112,6 +112,17 @@ public static void PlayFieldZoneDialogAudio(Int32 FieldZoneId, Int32 messageNumb String[] msgStrings = dialog.Phrase.Split(new String[] { "[CHOO]" }, StringSplitOptions.None); String msgString = msgStrings.Length > 0 ? messageOpcodeRegex.Replace(msgStrings[0], (match) => { return ""; }) : ""; + if (!useAlternatePath && msgString.Length > 0 && msgString.Contains("\n“")) + { + string name = msgString.Split('\n')[0].Trim(); + vaAlternatePath2 = string.Format("Voices/{0}/{1}/va_{2}_{3}", Localization.GetSymbol(), FieldZoneId, messageNumber, name); + if (AssetManager.HasAssetOnDisc("Sounds/" + vaAlternatePath2 + ".akb", true, true) || AssetManager.HasAssetOnDisc("Sounds/" + vaAlternatePath2 + ".ogg", true, false)) + { + vaPath = vaAlternatePath = vaAlternatePath2; + useAlternatePath = true; + } + } + Boolean hasChoices = dialog.ChoiceNumber > 0; Boolean isMsgEmpty = msgString.Length == 0; Boolean shouldDismiss = Configuration.VoiceActing.AutoDismissDialogAfterCompletion && !hasChoices; @@ -154,8 +165,10 @@ public static void PlayFieldZoneDialogAudio(Int32 FieldZoneId, Int32 messageNumb { if (String.IsNullOrEmpty(vaAlternatePath)) SoundLib.VALog(String.Format("field:{0}, msg:{1}, text:{2}, path:{3} (not found)", FieldZoneId, messageNumber, msgString, vaPath)); - else + else if (String.IsNullOrEmpty(vaAlternatePath2)) SoundLib.VALog(String.Format("field:{0}, msg:{1}, text:{2}, path:{3}, multiplay-path:{4} (not found)", FieldZoneId, messageNumber, msgString, vaPath, vaAlternatePath)); + else + SoundLib.VALog(String.Format("field:{0}, msg:{1}, text:{2}, path:{3}, multiplay-path:{4} named-path:{5} (not found)", FieldZoneId, messageNumber, msgString, vaPath, vaAlternatePath, vaAlternatePath2)); isMsgEmpty = true; } @@ -220,7 +233,7 @@ public static SoundProfile CreateLoadThenPlayVoice(Int32 soundIndex, String vaPa SoundProfileType = SoundProfileType.Voice, SoundVolume = 1f, Panning = 0f, - Pitch = 0.5f + Pitch = Configuration.Audio.Backend == 0 ? 0.5f : 1f // SdLib needs 0.5f for some reason }; SoundLoaderProxy.Instance.Load(soundProfile, @@ -283,17 +296,17 @@ public void ResumeAllSounds() private void StartSoundCrossfadeIn(SoundProfile soundProfile) { - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); if (ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_IsExist(soundProfile.SoundID) == 0) { SoundLib.Log("failed to play sound"); soundProfile.SoundID = 0; return; - } - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, 0f, 0); + } + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, 0f, 0); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * this.Volume, (Int32)(this.fadeInDuration * 1000f)); this.SetMusicPanning(this.playerPanning, soundProfile); this.SetMusicPitch(this.playerPitch, soundProfile); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); this.upcomingSoundProfile = soundProfile; } diff --git a/Memoria.Launcher/Images/new_launcher_bg.png b/Memoria.Launcher/Images/new_launcher_bg.png index 5481761c0..172bae1ac 100644 Binary files a/Memoria.Launcher/Images/new_launcher_bg.png and b/Memoria.Launcher/Images/new_launcher_bg.png differ diff --git a/Memoria.Launcher/Images/new_launcher_bg.psd b/Memoria.Launcher/Images/new_launcher_bg.psd index bf26905e9..dbc2f8a92 100644 Binary files a/Memoria.Launcher/Images/new_launcher_bg.psd and b/Memoria.Launcher/Images/new_launcher_bg.psd differ diff --git a/Memoria.Launcher/Images/new_launcher_bg_bak.psd b/Memoria.Launcher/Images/new_launcher_bg_bak.psd new file mode 100644 index 000000000..bf26905e9 Binary files /dev/null and b/Memoria.Launcher/Images/new_launcher_bg_bak.psd differ diff --git a/Memoria.Launcher/Ini/Memoria.ini b/Memoria.Launcher/Ini/Memoria.ini index a907a93ae..128dd1c44 100644 --- a/Memoria.Launcher/Ini/Memoria.ini +++ b/Memoria.Launcher/Ini/Memoria.ini @@ -13,10 +13,12 @@ Size = 24 [Audio] ; PriorityToOGG (default 0) When enabled, ".ogg" audio files are used instead of the ".akb.bytes" counterpart when both exist; the AKB header is then generated again at each usage + ; Backend (default 1) Choose the audio backend. 0 = SdLib, legacy backend (not recommended) / 1 = Soloud, new better sounding backend MusicVolume = 100 SoundVolume = 100 MovieVolume = 100 PriorityToOGG = 0 +Backend = 1 [Graphics] ; BattleFPS (default 30) Controls the fluidity of battle graphics (frame per second) @@ -32,6 +34,7 @@ PriorityToOGG = 0 ; GarnetHair (default 0) 0 = Default / 1 = Long / 2 = Short ; TileSize (default 32) Vanilla 32 / Moguri Mod 64 ; AntiAliasing (default 8) Must be either 0, 2, 4 or 8: enable Unity's anti-aliasing algorithm to improve the render of 3D model edges + ; CameraStabilizer (0 to 99, default 85) Adds a smooth delay on the camera following the player. Value represents "stickiness" of camera to its original position, each frame. Enabled = 0 BattleFPS = 30 BattleTPS = 15 @@ -47,6 +50,7 @@ SkipIntros = 0 GarnetHair = 0 TileSize = 32 AntiAliasing = 8 +CameraStabilizer = 85 [Control] ; DisableMouse (default 0) 0 = Can use the mouse to navigate in menus and move on the fields / 7 = Disable the mouse completly / 1 = Disable mouse for field menus and dialogs / 2 = Disable mouse for field movements / 4 = Disable mouse for battle menus @@ -174,6 +178,7 @@ GilMax = 0 ; HippaulRacingViviSpeed (default 33) Vivi's speed in the hippaul racing ; StealingAlwaysWorks (default 0) 1 = Always steals when move succeeds / 2 = Stealing has a 100% success rate (bandit ability) ; DisableNameChoice (default 0) Skip the character renaming windows + ; ExcaliburIINoTimeLimit (default 0) Give Excalibur II even when time is over Enabled = 0 AllCharactersAvailable = 0 RopeJumpingIncrement = 1 @@ -181,6 +186,7 @@ FrogCatchingIncrement = 1 HippaulRacingViviSpeed = 33 StealingAlwaysWorks = 0 DisableNameChoice = 0 +ExcaliburIINoTimeLimit = 0 [TetraMaster] ; TripleTriad (defaut 0) 0 = Tetra Master / 1 = "Tetra Triad" (a mix with both card games!) / 2 = Triple Triad (like FF8!) diff --git a/Memoria.Launcher/Languages/Lang.cs b/Memoria.Launcher/Languages/Lang.cs index f889769f6..f1df04c69 100644 --- a/Memoria.Launcher/Languages/Lang.cs +++ b/Memoria.Launcher/Languages/Lang.cs @@ -1,6 +1,5 @@ using System; using System.Globalization; -using System.IO; using System.Reflection; using System.Xml; using Ini; @@ -28,8 +27,8 @@ private static Lang Initialize() String forcedLang = iniFile.ReadValue("Memoria", "LauncherLanguage"); String[] fileNames = String.IsNullOrEmpty(forcedLang) ? - new String[] { CultureInfo.CurrentCulture.Name, CultureInfo.CurrentCulture.TwoLetterISOLanguageName } : - new String[] { forcedLang, CultureInfo.CurrentCulture.Name, CultureInfo.CurrentCulture.TwoLetterISOLanguageName }; + new String[] { CultureInfo.CurrentCulture.Name, CultureInfo.CurrentCulture.TwoLetterISOLanguageName, CultureInfo.CurrentCulture.ThreeLetterISOLanguageName } : + new String[] { forcedLang, CultureInfo.CurrentCulture.Name, CultureInfo.CurrentCulture.TwoLetterISOLanguageName, CultureInfo.CurrentCulture.ThreeLetterISOLanguageName, }; foreach (String name in fileNames) { cur = XmlHelper.LoadEmbadedDocument(assembly, $"Languages.{name}.xml"); @@ -40,7 +39,6 @@ private static Lang Initialize() } } //File.AppendAllText("MBROutput2.txt", name + \n"); - return new Lang(def, cur ?? def); } catch (Exception ex) @@ -144,6 +142,8 @@ private static String GetSettings(string name) return Instance.Value.GetString(name, nameof(Settings)); } + public static readonly string LauncherWindowTitle = GetSettings(nameof(LauncherWindowTitle)); + public static readonly string ActiveMonitor = GetSettings(nameof(ActiveMonitor)); public static readonly string PrimaryMonitor = GetSettings(nameof(PrimaryMonitor)); public static readonly string Resolution = GetSettings(nameof(Resolution)); @@ -161,14 +161,12 @@ private static String GetSettings(string name) public static readonly string BattleInterfaceType0 = GetSettings(nameof(BattleInterfaceType0)); public static readonly string BattleInterfaceType1 = GetSettings(nameof(BattleInterfaceType1)); public static readonly string BattleInterfaceType2 = GetSettings(nameof(BattleInterfaceType2)); - public static readonly string BattleInterfaceTooltip = GetSettings(nameof(BattleInterfaceTooltip)); public static readonly string SkipIntrosToMainMenu = GetSettings(nameof(SkipIntrosToMainMenu)); public static readonly string SkipBattleSwirl = GetSettings(nameof(SkipBattleSwirl)); public static readonly string AntiAliasing = GetSettings(nameof(AntiAliasing)); public static readonly string SkipBattleLoading = GetSettings(nameof(SkipBattleLoading)); public static readonly string HideCardsBubbles = GetSettings(nameof(HideCardsBubbles)); public static readonly string HideSteamBubbles = GetSettings(nameof(HideSteamBubbles)); - public static readonly string HideSteamBubblesTooltip = GetSettings(nameof(HideSteamBubblesTooltip)); public static readonly string TurnBasedBattles = GetSettings(nameof(TurnBasedBattles)); public static readonly string SpeedChoice = GetSettings(nameof(SpeedChoice)); public static readonly string SpeedChoiceType0 = GetSettings(nameof(SpeedChoiceType0)); @@ -177,7 +175,6 @@ private static String GetSettings(string name) public static readonly string SpeedChoiceType3 = GetSettings(nameof(SpeedChoiceType3)); public static readonly string SpeedChoiceType4 = GetSettings(nameof(SpeedChoiceType4)); public static readonly string SpeedChoiceType5 = GetSettings(nameof(SpeedChoiceType5)); - public static readonly string SpeedChoiceTooltip = GetSettings(nameof(SpeedChoiceTooltip)); public static readonly string TripleTriad = GetSettings(nameof(TripleTriad)); public static readonly string TripleTriadType0 = GetSettings(nameof(TripleTriadType0)); public static readonly string TripleTriadType1 = GetSettings(nameof(TripleTriadType1)); @@ -195,7 +192,6 @@ private static String GetSettings(string name) public static readonly string AccessBattleMenuType1 = GetSettings(nameof(AccessBattleMenuType1)); public static readonly string AccessBattleMenuType2 = GetSettings(nameof(AccessBattleMenuType2)); public static readonly string AccessBattleMenuType3 = GetSettings(nameof(AccessBattleMenuType3)); - public static readonly string AccessBattleMenuTooltip = GetSettings(nameof(AccessBattleMenuTooltip)); public static readonly string SpeedMode = GetSettings(nameof(SpeedMode)); public static readonly string SpeedFactor = GetSettings(nameof(SpeedFactor)); public static readonly string BattleAssistance = GetSettings(nameof(BattleAssistance)); @@ -208,10 +204,63 @@ private static String GetSettings(string name) public static readonly string SBUIenabled = GetSettings(nameof(SBUIenabled)); public static readonly string BattleTPS = GetSettings(nameof(BattleTPS)); public static readonly string SharedFPS = GetSettings(nameof(SharedFPS)); + public static readonly string BattleFPS = GetSettings(nameof(BattleFPS)); + public static readonly string FieldFPS = GetSettings(nameof(FieldFPS)); + public static readonly string WorldFPS = GetSettings(nameof(WorldFPS)); + public static readonly string CameraStabilizer = GetSettings(nameof(CameraStabilizer)); public static readonly string UseOrchestralMusic = GetSettings(nameof(UseOrchestralMusic)); public static readonly string Use30FpsVideo = GetSettings(nameof(Use30FpsVideo)); + public static readonly string MaxCardCount = GetSettings(nameof(MaxCardCount)); + + // Settings.ini Tooltips + public static readonly string ActiveMonitor_Tooltip = GetSettings(nameof(ActiveMonitor_Tooltip)); + public static readonly string WindowMode_Tooltip = GetSettings(nameof(WindowMode_Tooltip)); + public static readonly string Resolution_Tooltip = GetSettings(nameof(Resolution_Tooltip)); + public static readonly string Xsixfour_Tooltip = GetSettings(nameof(Xsixfour_Tooltip)); + public static readonly string Debuggable_Tooltip = GetSettings(nameof(Debuggable_Tooltip)); + public static readonly string CheckUpdates_Tooltip = GetSettings(nameof(CheckUpdates_Tooltip)); + public static readonly string SteamOverlayFix_Tooltip = GetSettings(nameof(SteamOverlayFix_Tooltip)); + + // Memoria.ini Tooltips + public static readonly string UseOrchestralMusic_Tooltip = GetSettings(nameof(UseOrchestralMusic_Tooltip)); + public static readonly string Use30FpsVideo_Tooltip = GetSettings(nameof(Use30FpsVideo_Tooltip)); + public static readonly string Widescreen_Tooltip = GetSettings(nameof(Widescreen_Tooltip)); + public static readonly string AntiAliasing_Tooltip = GetSettings(nameof(AntiAliasing_Tooltip)); + public static readonly string BattleTPS_Tooltip = GetSettings(nameof(BattleTPS_Tooltip)); + public static readonly string SharedFPS_Tooltip = GetSettings(nameof(SharedFPS_Tooltip)); + public static readonly string BattleFPS_Tooltip = GetSettings(nameof(BattleFPS_Tooltip)); + public static readonly string FieldFPS_Tooltip = GetSettings(nameof(FieldFPS_Tooltip)); + public static readonly string WorldFPS_Tooltip = GetSettings(nameof(WorldFPS_Tooltip)); + public static readonly string CameraStabilizer_Tooltip = GetSettings(nameof(CameraStabilizer_Tooltip)); + public static readonly string BattleInterface_Tooltip = GetSettings(nameof(BattleInterface_Tooltip)); + public static readonly string SkipIntrosToMainMenu_Tooltip = GetSettings(nameof(SkipIntrosToMainMenu_Tooltip)); + public static readonly string SkipBattleSwirl_Tooltip = GetSettings(nameof(SkipBattleSwirl_Tooltip)); + public static readonly string HideSteamBubbles_Tooltip = GetSettings(nameof(HideSteamBubbles_Tooltip)); + public static readonly string SpeedChoice_Tooltip = GetSettings(nameof(SpeedChoice_Tooltip)); + public static readonly string TripleTriad_Tooltip = GetSettings(nameof(TripleTriad_Tooltip)); + public static readonly string SoundVolume_Tooltip = GetSettings(nameof(SoundVolume_Tooltip)); + public static readonly string MusicVolume_Tooltip = GetSettings(nameof(MusicVolume_Tooltip)); + public static readonly string MovieVolume_Tooltip = GetSettings(nameof(MovieVolume_Tooltip)); + public static readonly string UsePsxFont_Tooltip = GetSettings(nameof(UsePsxFont_Tooltip)); + public static readonly string FontChoice_Tooltip = GetSettings(nameof(FontChoice_Tooltip)); + + // Memoria.ini Cheats tooltips + public static readonly string MaxStealRate_Tooltip = GetSettings(nameof(MaxStealRate_Tooltip)); + public static readonly string DisableCantConcentrate_Tooltip = GetSettings(nameof(DisableCantConcentrate_Tooltip)); + public static readonly string BreakDamageLimit_Tooltip = GetSettings(nameof(BreakDamageLimit_Tooltip)); + public static readonly string AccessBattleMenu_Tooltip = GetSettings(nameof(AccessBattleMenu_Tooltip)); + public static readonly string SpeedMode_Tooltip = GetSettings(nameof(SpeedMode_Tooltip)); + public static readonly string SpeedFactor_Tooltip = GetSettings(nameof(SpeedFactor_Tooltip)); + public static readonly string BattleAssistance_Tooltip = GetSettings(nameof(BattleAssistance_Tooltip)); + public static readonly string NoRandomBattles_Tooltip = GetSettings(nameof(NoRandomBattles_Tooltip)); + public static readonly string PermanentCheats_Tooltip = GetSettings(nameof(PermanentCheats_Tooltip)); + public static readonly string MaxCardCount_Tooltip = GetSettings(nameof(MaxCardCount_Tooltip)); + + + } + public static class SdLib { private static String GetSdLib(string name) diff --git a/Memoria.Launcher/Languages/de.xml b/Memoria.Launcher/Languages/de.xml new file mode 100644 index 000000000..2fae2c1f6 --- /dev/null +++ b/Memoria.Launcher/Languages/de.xml @@ -0,0 +1,336 @@ + + + + +