indexing description: "[ GUI_MAIN_MENU This class is part of the XAE Extended Adventure Engine Project. ]" author: "Ralph Wiedemeier, ralphw@student.ethz.ch" date: "$Date$" revision: "$Revision$" class GUI_MAIN_MENU inherit GUI_CONTAINER redefine draw end GUI_SHARED export {NONE} all undefine out end create make feature -- Initialization make is -- Create the main menu --local --rect: EM_RECT do -- Set attributes for menu frame make_from_position_and_size (menu_x, menu_y, menu_width, menu_height) set_border_thickness (2) set_special_corner_size (10) set_special_corner_bottom_left set_item_spacing (5) set_border_color_normal (gui_constants.color_menu_border_normal) set_border_color_hoover (gui_constants.color_menu_border_hoover) set_fill_color_normal (gui_constants.color_menu_fill) -- Create menu entries --create rect.make (0, 0, 100, 24) create button_open_script.make_with_text_and_image ("Open script", gui_constants.font_normal, "images/icon_green.tga") set_menu_button_attributes (button_open_script) extend (button_open_script) create button_load_game.make_with_text_and_image ("Load game", gui_constants.font_normal, "images/icon_green.tga") set_menu_button_attributes (button_load_game) extend (button_load_game) create button_save_game.make_with_text_and_image ("Save game", gui_constants.font_normal, "images/icon_green.tga") set_menu_button_attributes (button_save_game) extend (button_save_game) create button_credits.make_with_text_and_image ("Credits", gui_constants.font_normal, "images/icon_green.tga") set_menu_button_attributes (button_credits) extend (button_credits) create button_exit.make_with_text_and_image ("Exit", gui_constants.font_normal, "images/icon_orange.tga") set_menu_button_attributes (button_exit) extend (button_exit) end feature -- Representation draw (a_surface: EM_VIDEO_SURFACE) is -- Draw the main menu do gui_constants.font_normal.set_max_characters (1000) Precursor (a_surface) end feature -- Main Menu Buttons button_open_script: GUI_SPECIAL_BUTTON button_load_game: GUI_SPECIAL_BUTTON button_save_game: GUI_SPECIAL_BUTTON button_credits: GUI_SPECIAL_BUTTON button_exit: GUI_SPECIAL_BUTTON feature -- Operations disable_except (button: GUI_SPECIAL_BUTTON) is -- Disable the menu buttons during open / save game closeups -- except the one passed as an argument and the exit button. -- Set 'button' text to "Close". do button_open_script.set_disabled button_load_game.set_disabled button_save_game.set_disabled button_credits.set_disabled button.set_enabled button.set_text ("Cancel") end enable_all is -- enable menu buttons (except 'Exit') and reset text to default value do button_open_script.set_enabled button_open_script.set_text ("Open script") button_load_game.set_enabled button_load_game.set_text ("Load game") button_save_game.set_enabled button_save_game.set_text ("Save game") button_credits.set_enabled button_credits.set_text ("Credits") end feature {NONE} -- Implementation set_menu_button_attributes (button: GUI_SPECIAL_BUTTON) is -- set standard attributes for 'button' do button.set_layout_horizontal button.set_padding_horizontal (4) button.set_padding_vertical (0) button.set_border_thickness (1) button.set_special_corner_size (8) button.set_special_corner_bottom_left button.set_font_size (0.63) button.set_border_color_normal (gui_constants.color_button_border_normal) button.set_fill_color_normal (gui_constants.color_button_fill_normal) button.set_fill_color_hoover (gui_constants.color_button_fill_hoover) button.set_height (24) button.set_width (110) end -- Position and size of the main menu dialog menu_x: INTEGER is 442 menu_y: INTEGER is 53 menu_width: INTEGER is 584 menu_height: INTEGER is 38 end -- class GUI_MAIN_MENU