indexing description: "[ GUI_REPOSITORY This class is part of the XAE Extended Adventure Engine Project. ]" author: "Ralph Wiedemeier, ralphw@student.ethz.ch" date: "$Date$" revision: "$Revision$" class GUI_REPOSITORY inherit GUI_CONTAINER redefine extend, draw, execute_event_action_hoover_in, execute_event_action_hoover_out end GUI_SHARED export {NONE} all undefine out end create make_empty, make_from_repository feature -- Initialization make_empty is -- Create the repository view local rx: INTEGER do --rx := - repository_width + repository_handle rx := repository_x make_from_position_and_size (rx, repository_y, repository_width, repository_height) set_border_thickness (2) set_special_corner_size (16) set_special_corner_top_right set_item_spacing (8) set_border_color_normal (gui_constants.color_repository_border_normal) set_border_color_hoover (gui_constants.color_repository_border_hoover) set_fill_color_normal (gui_constants.color_repository_fill) end make_from_repository (a_repository: LIST [ITEM]) is -- Create new repository view from game repository do make_empty update (a_repository) end feature -- Representation draw (a_surface: EM_VIDEO_SURFACE) is -- Draw representation of current local --d: INTEGER --t: DOUBLE do -- if animate and then target_x /= x then -- d := target_x - start_x -- t := (gui_constants.ticks - timer_start) / wipe_duration -- if t >= 0 then -- if t < 1 then -- set_x ((start_x + smooth(t) * d).truncated_to_integer) -- else -- set_x (target_x) -- animate := False -- end -- end -- end Precursor (a_surface) end feature -- Operation update (rep_list: LIST [ITEM]) is -- Update the repository view using the specified repository local button: GUI_SPECIAL_BUTTON do clear from rep_list.start until rep_list.after loop create button.make_with_image (rep_list.item.repository_path) button.set_data (rep_list.item) set_repository_button_attributes (button) extend (button) rep_list.forth end end deselect is -- If an item is selected in the repository, deselect it do if selected_item /= Void then selected_item.set_border_color_normal (gui_constants.color_button_border_normal) selected_item.set_border_color_hoover (gui_constants.color_button_border_normal) selected_item := Void end end feature -- Status selected_item: GUI_SPECIAL_FRAME feature -- Event handler execute_event_action_hoover_in is -- Execute action for mouse hoover event do Precursor timer_start := gui_constants.ticks start_x := x target_x := repository_x animate := True end execute_event_action_hoover_out is -- Execute action for mouse hoover event outside do Precursor timer_start := gui_constants.ticks + timer_wait start_x := x target_x := - repository_width + repository_handle animate := True end handle_item_click_event (a_target: GUI_SPECIAL_FRAME) is -- Handle mouse clicks on repository items do if selected_item /= Void then selected_item.set_border_color_normal (gui_constants.color_button_border_normal) selected_item.set_border_color_hoover (gui_constants.color_button_border_normal) end if selected_item = Void or else a_target /= selected_item then a_target.set_border_color_normal (gui_constants.color_item_border_selected) a_target.set_border_color_hoover (gui_constants.color_item_border_selected) selected_item := a_target else selected_item := Void end end feature {NONE} -- Implementation extend (an_item: GUI_SPECIAL_BUTTON) is -- Add 'an_item' to item_list do if action_item_click /= Void then an_item.set_event_action_click (action_item_click) end Precursor (an_item) end set_repository_button_attributes (button: GUI_SPECIAL_BUTTON) is -- set standard attributes for 'button' do button.set_layout_vertical button.set_border_thickness (1) button.set_special_corner_size (12) button.set_special_corner_top_right button.set_border_color_normal (gui_constants.color_button_border_normal) button.set_fill_color_normal (gui_constants.color_item_fill_normal) button.set_fill_color_hoover (gui_constants.color_item_fill_hoover) button.set_height (110) button.set_width (110) button.set_event_action_click (agent handle_item_click_event) end smooth (t: DOUBLE): DOUBLE is -- Get smooth transition (0..1) do result := 3*t*t - 2*t*t*t end repository_handle: INTEGER is 30 repository_x: INTEGER is -1 repository_y: INTEGER is 574 repository_width: INTEGER is 720 repository_height: INTEGER is 124 action_item_click: PROCEDURE [ANY, TUPLE] timer_start: INTEGER timer_wait: INTEGER is 2500 wipe_duration: INTEGER is 1300 animate: BOOLEAN target_x: INTEGER start_x: INTEGER end -- class GUI_REPOSITORY