diff --git a/Data/Scripts/801_UI controls/002_ControlsContainer.rb b/Data/Scripts/801_UI controls/002_ControlsContainer.rb index e8c0c76e4..1978ef8fb 100644 --- a/Data/Scripts/801_UI controls/002_ControlsContainer.rb +++ b/Data/Scripts/801_UI controls/002_ControlsContainer.rb @@ -147,6 +147,15 @@ class UIControls::ControlsContainer add_dropdown_list(id, options, value, true) end + def add_text_box_dropdown_list(id, options, value, has_label = false) + add_control(id, UIControls::TextBoxDropdownList.new(*control_size(has_label), @viewport, options, value), has_label) + end + + def add_labelled_text_box_dropdown_list(id, label, options, value) + add_label(id, label) + add_text_box_dropdown_list(id, options, value, true) + end + #----------------------------------------------------------------------------- def repaint diff --git a/Data/Scripts/801_UI controls/Control elements/008_List.rb b/Data/Scripts/801_UI controls/Control elements/008_List.rb index 972f8497d..0c2288d1c 100644 --- a/Data/Scripts/801_UI controls/Control elements/008_List.rb +++ b/Data/Scripts/801_UI controls/Control elements/008_List.rb @@ -91,7 +91,9 @@ class UIControls::List < UIControls::BaseControl end def mouse_in_control? - return true if super + mouse_x, mouse_y = mouse_pos + return false if !mouse_x || !mouse_y + return true if Rect.new(0, 0, width, height).contains?(mouse_x, mouse_y) return true if @scrollbar.mouse_in_control? return false end @@ -219,10 +221,12 @@ class UIControls::List < UIControls::BaseControl @selected = @hover_area if @hover_area.is_a?(Integer) elsif @hover_area wheel_v = Input.scroll_v + scroll_dist = UIControls::Scrollbar::SCROLL_DISTANCE + scroll_dist /= 2 if @values.length / @rows_count > 20 # Arbitrary 20 if wheel_v > 0 # Scroll up - @scrollbar.slider_top -= UIControls::Scrollbar::SCROLL_DISTANCE + @scrollbar.slider_top -= scroll_dist elsif wheel_v < 0 # Scroll down - @scrollbar.slider_top += UIControls::Scrollbar::SCROLL_DISTANCE + @scrollbar.slider_top += scroll_dist end if wheel_v != 0 self.top_row = (@scrollbar.position.to_f / ROW_HEIGHT).round diff --git a/Data/Scripts/801_UI controls/Control elements/009_DropdownList.rb b/Data/Scripts/801_UI controls/Control elements/009_DropdownList.rb index c98589ee9..44dc35ffe 100644 --- a/Data/Scripts/801_UI controls/Control elements/009_DropdownList.rb +++ b/Data/Scripts/801_UI controls/Control elements/009_DropdownList.rb @@ -34,7 +34,7 @@ class UIControls::DropdownList < UIControls::BaseControl def set_interactive_rects @button_rect = Rect.new(TEXT_BOX_X, (height - TEXT_BOX_HEIGHT) / 2, - [@box_width, width - (TEXT_BOX_X * 2)].min, TEXT_BOX_HEIGHT) + [@box_width, width - (TEXT_BOX_X * 2)].min, TEXT_BOX_HEIGHT) @interactions = { :button => @button_rect } diff --git a/Data/Scripts/801_UI controls/Control elements/010_TextBoxDropdownList.rb b/Data/Scripts/801_UI controls/Control elements/010_TextBoxDropdownList.rb new file mode 100644 index 000000000..b240662d2 --- /dev/null +++ b/Data/Scripts/801_UI controls/Control elements/010_TextBoxDropdownList.rb @@ -0,0 +1,210 @@ +#=============================================================================== +# Also known as a Combo Box. +# NOTE: This control lets you type in whatever text you want. The dropdown list +# only offers autocomplete-like suggestions, but you don't need to match +# any of them. +#=============================================================================== +class UIControls::TextBoxDropdownList < UIControls::TextBox + attr_accessor :max_rows + + TEXT_BOX_WIDTH = 200 - TEXT_BOX_HEIGHT + BUTTON_X = TEXT_BOX_X + TEXT_BOX_WIDTH + BUTTON_WIDTH = TEXT_BOX_HEIGHT + BUTTON_HEIGHT = TEXT_BOX_HEIGHT + MAX_LIST_ROWS = 8 + + def initialize(width, height, viewport, options, value = "") + super(width, height, viewport, value) + @box_width = TEXT_BOX_WIDTH + @options = options + @toggling_dropdown_list = false + @max_rows = MAX_LIST_ROWS + end + + def dispose + remove_dropdown_menu + super + end + + def values=(new_vals) + @options = new_vals + @dropdown_menu.values = @options if @dropdown_menu + end + + def set_interactive_rects + @text_box_rect = Rect.new(TEXT_BOX_X, (height - TEXT_BOX_HEIGHT) / 2, + [@box_width, width - (TEXT_BOX_X * 2) - BUTTON_WIDTH].min, TEXT_BOX_HEIGHT) + @button_rect = Rect.new(BUTTON_X, @text_box_rect.y, BUTTON_WIDTH, BUTTON_HEIGHT) + @interactions = { + :text_box => @text_box_rect, + :button => @button_rect + } + end + + #----------------------------------------------------------------------------- + + def busy? + return true if @dropdown_menu || @toggling_dropdown_list + return super + end + + #----------------------------------------------------------------------------- + + def make_dropdown_menu + menu_height = UIControls::List::ROW_HEIGHT * [@options.length, @max_rows].min + # Draw menu's background + @dropdown_menu_bg = BitmapSprite.new(@text_box_rect.width + @button_rect.width, menu_height + 4, self.viewport) + @dropdown_menu_bg.x = self.x + @text_box_rect.x + @dropdown_menu_bg.y = self.y + @text_box_rect.y + @text_box_rect.height + @dropdown_menu_bg.z = self.z + 1 + @dropdown_menu_bg.bitmap.outline_rect(0, 0, @dropdown_menu_bg.width, @dropdown_menu_bg.height, Color.black) + @dropdown_menu_bg.bitmap.fill_rect(1, 1, @dropdown_menu_bg.width - 2, @dropdown_menu_bg.height - 2, Color.white) + # Create menu + @dropdown_menu = UIControls::List.new(@text_box_rect.width + @button_rect.width - 4, menu_height, self.viewport, @options) + @dropdown_menu.x = @dropdown_menu_bg.x + 2 + @dropdown_menu.y = @dropdown_menu_bg.y + 2 + @dropdown_menu.z = self.z + 2 + @dropdown_menu.set_interactive_rects + @dropdown_menu.repaint + end + + def remove_dropdown_menu + @dropdown_menu_bg&.dispose + @dropdown_menu_bg = nil + @dropdown_menu&.dispose + @dropdown_menu = nil + @captured_area = nil + @applied_filter = false + end + + #----------------------------------------------------------------------------- + + def draw_area_highlight + highlight_color = nil + if @captured_area == :text_box && !@hover_area && Input.press?(Input::MOUSELEFT) + highlight_color = CAPTURE_COLOR + elsif !@captured_area && [:text_box, :button].include?(@hover_area) + # Draw mouse hover over area highlight + highlight_color = HOVER_COLOR + end + return if !highlight_color + [:text_box, :button].each do |area| + rect = @interactions[area] + self.bitmap.fill_rect(rect.x, rect.y, rect.width, rect.height, highlight_color) if rect + end + end + + def refresh + @dropdown_menu&.refresh + super + # Draw disabled colour in button + if disabled? + self.bitmap.fill_rect(@button_rect.x, @button_rect.y, + @button_rect.width, @button_rect.height, + DISABLED_COLOR) + end + # Draw button outline + self.bitmap.outline_rect(@button_rect.x, @button_rect.y, + @button_rect.width, @button_rect.height, + self.bitmap.font.color) + # Draw down arrow + arrow_area_x = @button_rect.x + @button_rect.width - @button_rect.height + 1 + arrow_area_width = @button_rect.height - 2 + # self.bitmap.fill_rect(arrow_area_x, @button_rect.y + 1, arrow_area_width, arrow_area_width, + # (@hover_area && @captured_area != :button) ? HOVER_COLOR : Color.white) + 6.times do |i| + self.bitmap.fill_rect(arrow_area_x + (arrow_area_width / 2) - 5 + i, + @button_rect.y + (arrow_area_width / 2) - 1 + i, + 11 - (2 * i), 1, (disabled?) ? DISABLED_COLOR_DARK : self.bitmap.font.color) + end + end + + #----------------------------------------------------------------------------- + + def on_mouse_press + mouse_x, mouse_y = mouse_pos + return if !mouse_x || !mouse_y + if @dropdown_menu + if @text_box_rect.contains?(mouse_x, mouse_y) + # Clicked into the text box; put the text cursor in there + @captured_area = :text_box + @cursor_pos = get_cursor_index_from_mouse_position + @cursor_timer = System.uptime + invalidate + elsif !@dropdown_menu.mouse_in_control? + @value.strip! if @value.respond_to?("strip!") + @value = @initial_value.dup if disabled? + set_changed if @initial_value && @value != @initial_value + reset_interaction + remove_dropdown_menu + @toggling_dropdown_list = true + end + else + @captured_area = nil + super + if @captured_area + make_dropdown_menu + @toggling_dropdown_list = true + end + end + end + + def on_mouse_release + return if !@captured_area && !@dropdown_menu && !@toggling_dropdown_list + if @toggling_dropdown_list + @toggling_dropdown_list = false + mouse_x, mouse_y = mouse_pos + if mouse_x && mouse_y && @interactions[:text_box].contains?(mouse_x, mouse_y) + @initial_value = @value.dup + Input.text_input = true + invalidate + end + return + end + if @dropdown_menu + if @dropdown_menu.changed? + new_val = @dropdown_menu.value + new_val = @options[new_val] if new_val.is_a?(Integer) + if new_val && new_val != @value + self.value = new_val + set_changed + end + @value.strip! if @value.respond_to?("strip!") + reset_interaction + remove_dropdown_menu + @captured_area = nil + elsif @captured_area + mouse_x, mouse_y = mouse_pos + if mouse_x && mouse_y && @interactions[:text_box].contains?(mouse_x, mouse_y) + @captured_area = :text_box + @initial_value = @value.dup + Input.text_input = true + end + elsif !mouse_in_control? && !@dropdown_menu.mouse_in_control? + @value.strip! if @value.respond_to?("strip!") + self.value = @initial_value if disabled? + set_changed if @initial_value && @value != @initial_value + reset_interaction + remove_dropdown_menu + @captured_area = nil + end + else + super + end + invalidate + end + + def update + @dropdown_menu&.update + @dropdown_menu&.repaint + super + # Filter the dropdown menu options based on @value if it changes + if @dropdown_menu && @initial_value && (@applied_filter || @value != @initial_value) + filtered_options = @options.select do |key, val| + key.downcase.include?(@value.downcase) || val.downcase.include?(@value.downcase) + end + @dropdown_menu.values = filtered_options + @applied_filter = true + end + end +end diff --git a/Data/Scripts/904_Anim Editor/001_AnimationEditor.rb b/Data/Scripts/904_Anim Editor/001_AnimationEditor.rb index 30c1273f4..56dd57c05 100644 --- a/Data/Scripts/904_Anim Editor/001_AnimationEditor.rb +++ b/Data/Scripts/904_Anim Editor/001_AnimationEditor.rb @@ -32,18 +32,18 @@ class AnimationEditor PARTICLE_LIST_HEIGHT = WINDOW_HEIGHT - PARTICLE_LIST_Y - BORDER_THICKNESS # Pop-up windows - ANIM_PROPERTIES_LABEL_WIDTH = UIControls::ControlsContainer::OFFSET_FROM_LABEL_X + 80 - ANIM_PROPERTIES_WIDTH = SIDE_PANE_WIDTH + 80 + 8 - ANIM_PROPERTIES_HEIGHT = WINDOW_HEIGHT * 3 / 4 - ANIM_PROPERTIES_X = (WINDOW_WIDTH - ANIM_PROPERTIES_WIDTH) / 2 - ANIM_PROPERTIES_Y = (WINDOW_HEIGHT - ANIM_PROPERTIES_HEIGHT) / 2 - MESSAGE_BOX_WIDTH = WINDOW_WIDTH * 3 / 4 MESSAGE_BOX_HEIGHT = 160 MESSAGE_BOX_BUTTON_WIDTH = 150 MESSAGE_BOX_BUTTON_HEIGHT = 32 MESSAGE_BOX_SPACING = 16 + ANIM_PROPERTIES_LABEL_WIDTH = UIControls::ControlsContainer::OFFSET_FROM_LABEL_X + 80 + ANIM_PROPERTIES_WIDTH = SIDE_PANE_WIDTH + 80 + ANIM_PROPERTIES_HEIGHT = WINDOW_HEIGHT * 3 / 4 + ANIM_PROPERTIES_X = (WINDOW_WIDTH - ANIM_PROPERTIES_WIDTH) / 2 + ANIM_PROPERTIES_Y = (WINDOW_HEIGHT - ANIM_PROPERTIES_HEIGHT) / 2 + CHOOSER_BUTTON_WIDTH = 150 CHOOSER_BUTTON_HEIGHT = MESSAGE_BOX_BUTTON_HEIGHT CHOOSER_FILE_LIST_X = 8 @@ -52,18 +52,37 @@ class AnimationEditor CHOOSER_FILE_LIST_HEIGHT = UIControls::List::ROW_HEIGHT * 15 GRAPHIC_CHOOSER_PREVIEW_SIZE = 320 # Square - GRAPHIC_CHOOSER_WINDOW_WIDTH = CHOOSER_FILE_LIST_X + CHOOSER_FILE_LIST_WIDTH + 10 + GRAPHIC_CHOOSER_PREVIEW_SIZE + 8 + (BORDER_THICKNESS * 2) - GRAPHIC_CHOOSER_WINDOW_HEIGHT = CHOOSER_FILE_LIST_Y + CHOOSER_FILE_LIST_HEIGHT + 10 + CHOOSER_BUTTON_HEIGHT + 8 + (BORDER_THICKNESS * 2) + GRAPHIC_CHOOSER_WINDOW_WIDTH = CHOOSER_FILE_LIST_X + CHOOSER_FILE_LIST_WIDTH + 10 + GRAPHIC_CHOOSER_PREVIEW_SIZE + 8 + GRAPHIC_CHOOSER_WINDOW_HEIGHT = CHOOSER_FILE_LIST_Y + CHOOSER_FILE_LIST_HEIGHT + 10 + CHOOSER_BUTTON_HEIGHT + 8 GRAPHIC_CHOOSER_X = ((WINDOW_WIDTH - GRAPHIC_CHOOSER_WINDOW_WIDTH) / 2) GRAPHIC_CHOOSER_Y = ((WINDOW_HEIGHT - GRAPHIC_CHOOSER_WINDOW_HEIGHT) / 2) AUDIO_CHOOSER_LABEL_WIDTH = UIControls::ControlsContainer::OFFSET_FROM_LABEL_X AUDIO_CHOOSER_SLIDER_WIDTH = (CHOOSER_BUTTON_WIDTH * 2) - AUDIO_CHOOSER_LABEL_WIDTH - AUDIO_CHOOSER_WINDOW_WIDTH = CHOOSER_FILE_LIST_X + CHOOSER_FILE_LIST_WIDTH + 8 + (CHOOSER_BUTTON_WIDTH * 2) + 4 + (BORDER_THICKNESS * 2) - AUDIO_CHOOSER_WINDOW_HEIGHT = CHOOSER_FILE_LIST_Y + CHOOSER_FILE_LIST_HEIGHT + 10 + CHOOSER_BUTTON_HEIGHT + 8 + (BORDER_THICKNESS * 2) + AUDIO_CHOOSER_WINDOW_WIDTH = CHOOSER_FILE_LIST_X + CHOOSER_FILE_LIST_WIDTH + 8 + (CHOOSER_BUTTON_WIDTH * 2) + 4 + AUDIO_CHOOSER_WINDOW_HEIGHT = CHOOSER_FILE_LIST_Y + CHOOSER_FILE_LIST_HEIGHT + 10 + CHOOSER_BUTTON_HEIGHT + 8 AUDIO_CHOOSER_X = ((WINDOW_WIDTH - AUDIO_CHOOSER_WINDOW_WIDTH) / 2) AUDIO_CHOOSER_Y = ((WINDOW_HEIGHT - AUDIO_CHOOSER_WINDOW_HEIGHT) / 2) + # This list of animations was gathered manually by looking at all instances of + # pbCommonAnimation. + COMMON_ANIMATIONS = [ + "Attract", "BanefulBunker", "BeakBlast", "Bind", "Burn", + "Clamp", "Confusion", "CraftyShield", "EatBerry", "ElectricTerrain", + "FireSpin", "FocusPunch", "Frozen", "GrassyTerrain", "Hail", + "HarshSun", "HealingWish", "HealthDown", "HealthUp", "HeavyRain", + "Infestation", "KingsShield", "LeechSeed", "LevelUp", "LunarDance", + "MagmaStorm", "MegaEvolution", "MegaEvolution2", "MistyTerrain", "Obstruct", + "Octolock", "Paralysis", "ParentalBond", "Poison", "Powder", + "PrimalGroudon", "PrimalGroudon2", "PrimalKyogre", "PrimalKyogre2", "Protect", + "PsychicTerrain", "QuickGuard", "Rain", "Rainbow", "RainbowOpp", + "Sandstorm", "SandTomb", "SeaOfFire", "SeaOfFireOpp", "Shadow", + "ShadowSky", "ShellTrap", "Shiny", "Sleep", "SpikyShield", + "StatDown", "StatUp", "StrongWinds", "Sun", "SuperShiny", + "Swamp", "SwampOpp", "Toxic", "UseItem", "WideGuard", + "Wrap" + ] + def initialize(anim_id, anim) @anim_id = anim_id @anim = anim @@ -110,21 +129,18 @@ class AnimationEditor @components[:particle_list].set_interactive_rects # Animation properties pop-up window @components[:animation_properties] = UIControls::ControlsContainer.new( - ANIM_PROPERTIES_X + BORDER_THICKNESS + 4, ANIM_PROPERTIES_Y + BORDER_THICKNESS, - ANIM_PROPERTIES_WIDTH - ((BORDER_THICKNESS + 4) * 2), ANIM_PROPERTIES_HEIGHT - (BORDER_THICKNESS * 2) + ANIM_PROPERTIES_X + 4, ANIM_PROPERTIES_Y, ANIM_PROPERTIES_WIDTH - 8, ANIM_PROPERTIES_HEIGHT ) @components[:animation_properties].viewport.z = @pop_up_viewport.z + 1 @components[:animation_properties].label_offset_x = 170 # Graphic chooser pop-up window @components[:graphic_chooser] = UIControls::ControlsContainer.new( - GRAPHIC_CHOOSER_X + BORDER_THICKNESS, GRAPHIC_CHOOSER_Y + BORDER_THICKNESS, - GRAPHIC_CHOOSER_WINDOW_WIDTH - (BORDER_THICKNESS * 2), GRAPHIC_CHOOSER_WINDOW_HEIGHT - (BORDER_THICKNESS * 2) + GRAPHIC_CHOOSER_X, GRAPHIC_CHOOSER_Y, GRAPHIC_CHOOSER_WINDOW_WIDTH, GRAPHIC_CHOOSER_WINDOW_HEIGHT ) @components[:graphic_chooser].viewport.z = @pop_up_viewport.z + 1 # Audio chooser pop-up window @components[:audio_chooser] = UIControls::ControlsContainer.new( - AUDIO_CHOOSER_X + BORDER_THICKNESS, AUDIO_CHOOSER_Y + BORDER_THICKNESS, - AUDIO_CHOOSER_WINDOW_WIDTH - (BORDER_THICKNESS * 2), AUDIO_CHOOSER_WINDOW_HEIGHT - (BORDER_THICKNESS * 2) + AUDIO_CHOOSER_X, AUDIO_CHOOSER_Y, AUDIO_CHOOSER_WINDOW_WIDTH, AUDIO_CHOOSER_WINDOW_HEIGHT ) @components[:audio_chooser].viewport.z = @pop_up_viewport.z + 1 @captured = nil @@ -297,19 +313,9 @@ class AnimationEditor # Create "opp" variant anim_properties.add_labelled_checkbox(:opp_variant, _INTL("User is opposing?"), false) # Create move control - # TODO: Instead of having the :common_anim TextBox control, make this a - # TextBoxDropdownList control instead. Make it allow custom text - # as well as any option in the list. Its options will be changed - # depending on the animation's type. Also have a list of existing - # Common animation names for it. - move_list = [] - GameData::Move.each { |m| move_list.push([m.id.to_s, m.name]) } - move_list.sort! { |a, b| a[1] <=> b[1] } - anim_properties.add_labelled_dropdown_list(:move, _INTL("Move"), move_list.to_h, move_list[0][0]) + anim_properties.add_labelled_text_box_dropdown_list(:move, "", [], "") move_ctrl = anim_properties.get_control(:move) move_ctrl.max_rows = 16 - common_text = UIControls::TextBox.new(move_ctrl.width, move_ctrl.height, move_ctrl.viewport, "") - anim_properties.add_control_at(:common_anim, common_text, move_ctrl.x, move_ctrl.y) # Create version control anim_properties.add_labelled_number_text_box(:version, _INTL("Version"), 0, 99, 0) # Create animation name control @@ -444,6 +450,20 @@ class AnimationEditor end end + def refresh_move_property_options + ctrl = @components[:animation_properties].get_control(:move) + case @anim[:type] + when :move, :opp_move + move_list = [] + GameData::Move.each { |m| move_list.push([m.id.to_s, m.name]) } + move_list.push(["STRUGGLE", _INTL("Struggle")]) if move_list.none? { |val| val[0] == "STRUGGLE" } + move_list.sort! { |a, b| a[1] <=> b[1] } + ctrl.values = move_list.to_h + when :common, :opp_common + ctrl.values = COMMON_ANIMATIONS + end + end + def refresh_component_values(component_sym) component = @components[component_sym] case component_sym @@ -515,17 +535,13 @@ class AnimationEditor # TODO: Set the possible focus options depending on whether the animation # has a target/user. when :animation_properties + refresh_move_property_options case @anim[:type] when :move, :opp_move component.get_control(:move_label).text = _INTL("Move") - component.get_control(:move).visible = true component.get_control(:move).value = @anim[:move] - component.get_control(:common_anim).visible = false when :common, :opp_common component.get_control(:move_label).text = _INTL("Common animation") - component.get_control(:move).visible = false - component.get_control(:common_anim).visible = true - component.get_control(:common_anim).value = @anim[:move] end # TODO: Maybe other things as well? end @@ -653,8 +669,6 @@ class AnimationEditor @anim[:type] = (opp) ? :opp_common : :common end refresh_component(:animation_properties) - when :common_anim - @anim[:move] = value when :pbs_path txt = value.gsub!(/\.txt$/, "") @anim[property] = txt diff --git a/Data/Scripts/904_Anim Editor/002_AnimationEditor_popups.rb b/Data/Scripts/904_Anim Editor/002_AnimationEditor_popups.rb index 88323098f..8612e5e70 100644 --- a/Data/Scripts/904_Anim Editor/002_AnimationEditor_popups.rb +++ b/Data/Scripts/904_Anim Editor/002_AnimationEditor_popups.rb @@ -3,21 +3,18 @@ #=============================================================================== class AnimationEditor def create_pop_up_window(width, height) - ret = BitmapSprite.new(width, height, @pop_up_viewport) - ret.x = (WINDOW_WIDTH - width) / 2 - ret.y = (WINDOW_HEIGHT - height) / 2 + ret = BitmapSprite.new(width + (BORDER_THICKNESS * 2), + height + (BORDER_THICKNESS * 2), @pop_up_viewport) + ret.x = (WINDOW_WIDTH - ret.width) / 2 + ret.y = (WINDOW_HEIGHT - ret.height) / 2 ret.z = -1 ret.bitmap.font.color = Color.black ret.bitmap.font.size = 18 - # Draw message box border - ret.bitmap.border_rect(BORDER_THICKNESS, BORDER_THICKNESS, - ret.width - (BORDER_THICKNESS * 2), ret.height - (BORDER_THICKNESS * 2), + # Draw pop-up box border + ret.bitmap.border_rect(BORDER_THICKNESS, BORDER_THICKNESS, width, height, BORDER_THICKNESS, Color.white, Color.black) - # Fill message box with white - ret.bitmap.fill_rect(BORDER_THICKNESS, BORDER_THICKNESS, - ret.width - (BORDER_THICKNESS * 2), - ret.height - (BORDER_THICKNESS * 2), - Color.white) + # Fill pop-up box with white + ret.bitmap.fill_rect(BORDER_THICKNESS, BORDER_THICKNESS, width, height, Color.white) return ret end @@ -79,6 +76,55 @@ class AnimationEditor #----------------------------------------------------------------------------- + def edit_animation_properties + # Show pop-up window + @pop_up_bg_bitmap.visible = true + bg_bitmap = create_pop_up_window(ANIM_PROPERTIES_WIDTH, ANIM_PROPERTIES_HEIGHT) + # TODO: Draw box around list control(s), i.e. flags. Note that an extra +4 + # should be added to its x coordinate because of padding created when + # defining @components[:animation_properties]. + anim_properties = @components[:animation_properties] + anim_properties.visible = true + # Set control values + case @anim[:type] + when :move, :opp_move + anim_properties.get_control(:type).value = :move + when :common, :opp_common + anim_properties.get_control(:type).value = :common + end + anim_properties.get_control(:opp_variant).value = ([:opp_move, :opp_common].include?(@anim[:type])) + anim_properties.get_control(:version).value = @anim[:version] || 0 + anim_properties.get_control(:name).value = @anim[:name] || "" + anim_properties.get_control(:pbs_path).value = (@anim[:pbs_path] || "unsorted") + ".txt" + anim_properties.get_control(:has_target).value = !@anim[:no_target] + anim_properties.get_control(:usable).value = !(@anim[:ignore] || false) + # TODO: Populate flags. + refresh_component(:animation_properties) # This sets the :move control's value + # Interaction loop + ret = nil + loop do + Graphics.update + Input.update + anim_properties.update + if anim_properties.changed? + break if anim_properties.values.keys.include?(:close) + anim_properties.values.each_pair do |property, value| + apply_changed_value(:animation_properties, property, value) + end + anim_properties.clear_changed + end + break if !anim_properties.busy? && Input.trigger?(Input::BACK) + anim_properties.repaint + end + # Dispose and return + bg_bitmap.dispose + @pop_up_bg_bitmap.visible = false + anim_properties.clear_changed + anim_properties.visible = false + end + + #----------------------------------------------------------------------------- + # Generates a list of all files in the given folder which have a file # extension that matches one in exts. Removes any files from the list whose # filename is the same as one in prepends (case insensitive), and then adds @@ -106,7 +152,7 @@ class AnimationEditor graphic_chooser.visible = true # Draw box around list control list = graphic_chooser.get_control(:list) - bg_bitmap.bitmap.outline_rect(list.x + BORDER_THICKNESS - 2, list.y + BORDER_THICKNESS - 2, + bg_bitmap.bitmap.outline_rect(BORDER_THICKNESS + list.x - 2, BORDER_THICKNESS + list.y - 2, list.width + 4, list.height + 4, Color.black) # Get a list of files files = get_all_files_in_folder_and_prepend( @@ -210,7 +256,7 @@ class AnimationEditor audio_chooser.visible = true # Draw box around list control list = audio_chooser.get_control(:list) - bg_bitmap.bitmap.outline_rect(list.x + BORDER_THICKNESS - 2, list.y + BORDER_THICKNESS - 2, + bg_bitmap.bitmap.outline_rect(BORDER_THICKNESS + list.x - 2, BORDER_THICKNESS + list.y - 2, list.width + 4, list.height + 4, Color.black) # Get a list of files files = get_all_files_in_folder_and_prepend( @@ -274,51 +320,4 @@ class AnimationEditor return [ret, vol, ptch] end - #----------------------------------------------------------------------------- - - def edit_animation_properties - # Show pop-up window - @pop_up_bg_bitmap.visible = true - bg_bitmap = create_pop_up_window(ANIM_PROPERTIES_WIDTH, ANIM_PROPERTIES_HEIGHT) - # TODO: Draw box around list control(s), i.e. flags. - anim_properties = @components[:animation_properties] - anim_properties.visible = true - # Set control values - case @anim[:type] - when :move, :opp_move - anim_properties.get_control(:type).value = :move - when :common, :opp_common - anim_properties.get_control(:type).value = :common - end - anim_properties.get_control(:opp_variant).value = ([:opp_move, :opp_common].include?(@anim[:type])) - anim_properties.get_control(:version).value = @anim[:version] || 0 - anim_properties.get_control(:name).value = @anim[:name] || "" - anim_properties.get_control(:pbs_path).value = (@anim[:pbs_path] || "unsorted") + ".txt" - anim_properties.get_control(:has_target).value = !@anim[:no_target] - anim_properties.get_control(:usable).value = !(@anim[:ignore] || false) - # TODO: Populate flags. - refresh_component(:animation_properties) # This sets the :move control's value - # Interaction loop - ret = nil - loop do - Graphics.update - Input.update - anim_properties.update - if anim_properties.changed? - break if anim_properties.values.keys.include?(:close) - anim_properties.values.each_pair do |property, value| - apply_changed_value(:animation_properties, property, value) - end - anim_properties.clear_changed - end - break if !anim_properties.busy? && Input.trigger?(Input::BACK) - anim_properties.repaint - end - # Dispose and return - bg_bitmap.dispose - @pop_up_bg_bitmap.visible = false - anim_properties.clear_changed - anim_properties.visible = false - end - end