Mercurial > mm7
diff GUI/GUIWindow.h @ 2544:c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
author | a.parshin |
---|---|
date | Mon, 11 May 2015 09:51:04 +0200 |
parents | b6140dfeac27 |
children | e06a3fe9ad6e |
line wrap: on
line diff
--- a/GUI/GUIWindow.h Sun May 10 03:21:14 2015 +0200 +++ b/GUI/GUIWindow.h Mon May 11 09:51:04 2015 +0200 @@ -267,54 +267,54 @@ { WINDOW_null = 0, WINDOW_MainMenu = 1, - WINDOW_GameMenu = 3, + WINDOW_GameMenu = 3, WINDOW_CharacterRecord = 4, WINDOW_Options = 6, WINDOW_8 = 8, WINDOW_Book = 9, - WINDOW_Dialogue = 10, - WINDOW_QuickReference = 12, - WINDOW_F = 15, - WINDOW_Rest = 16, - WINDOW_ChangeLocation = 17, - WINDOW_SpellBook = 18, - WINDOW_GreetingNPC = 19, - WINDOW_Chest = 20, - WINDOW_22 = 0x16, + WINDOW_Dialogue = 10, + WINDOW_QuickReference = 12, + WINDOW_F = 15, + WINDOW_Rest = 16, + WINDOW_ChangeLocation = 17, + WINDOW_SpellBook = 18, + WINDOW_GreetingNPC = 19, + WINDOW_Chest = 20, + WINDOW_22 = 0x16, WINDOW_SaveLoadButtons = 23, - WINDOW_MainMenu_Load = 0x18, - WINDOW_HouseInterior = 0x19, - WINDOW_Transition = 26, - WINDOW_CastSpell = 27, - WINDOW_Scroll = 0x1E, + WINDOW_MainMenu_Load = 0x18, + WINDOW_HouseInterior = 0x19, + WINDOW_Transition = 26, + WINDOW_CastSpell = 27, // OnCastTargetedSpell + WINDOW_Scroll = 0x1E, WINDOW_CastSpell_InInventory = 31, - WINDOW_ModalWindow = 70, - WINDOW_50 = 80, - WINDOW_59 = 89, + WINDOW_ModalWindow = 70, + WINDOW_50 = 80, + WINDOW_59 = 89, WINDOW_PressedButton2 = 90, WINDOW_CharactersPressedButton = 91, - WINDOW_PressedButton = 92, - WINDOW_5D = 93, - WINDOW_SaveLoadBtn = 94, - WINDOW_LoadGame_CancelBtn = 95, - WINDOW_CloseRestWindowBtn = 96, - WINDOW_ExitCharacterWindow = 97, - WINDOW_RestWindow = 0x62, - WINDOW_BooksWindow = 99, - WINDOW_CharacterWindow_Stats = 0x64, - WINDOW_CharacterWindow_Skills = 0x65, - WINDOW_CharacterWindow_Awards = 0x66, + WINDOW_PressedButton = 92, + WINDOW_5D = 93, + WINDOW_SaveLoadBtn = 94, + WINDOW_LoadGame_CancelBtn = 95, // OnCancel3 + WINDOW_CloseRestWindowBtn = 96, + WINDOW_ExitCharacterWindow = 97, // OnCancel2 + WINDOW_RestWindow = 0x62, + WINDOW_BooksWindow = 99, + WINDOW_CharacterWindow_Stats = 0x64, + WINDOW_CharacterWindow_Skills = 0x65, + WINDOW_CharacterWindow_Awards = 0x66, WINDOW_CharacterWindow_Inventory = 0x67, - WINDOW_68 = 104, + WINDOW_68 = 104, WINDOW_KeyMappingOptions = 0x69, - WINDOW_VideoOptions = 0x6A, - WINDOW_LloydsBeacon = 177, - WINDOW_TownPortal = 195, - WINDOW_QuestBook = 200, - WINDOW_AutonotesBook = 0xC9, - WINDOW_MapsBook = 0xCA, - WINDOW_CalendarBook = 0xCB, - WINDOW_JournalBook = 0xE0, + WINDOW_VideoOptions = 0x6A, + WINDOW_LloydsBeacon = 177, + WINDOW_TownPortal = 195, + WINDOW_QuestBook = 200, + WINDOW_AutonotesBook = 0xC9, + WINDOW_MapsBook = 0xCA, + WINDOW_CalendarBook = 0xCB, + WINDOW_JournalBook = 0xE0, }; struct GUIButton; @@ -330,11 +330,9 @@ #pragma pack(push, 1) struct GUIWindow { - inline GUIWindow() - { - pControlsHead = pControlsTail = nullptr; - eWindowType = WINDOW_null; - } + GUIWindow(); + GUIWindow(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, int pButton, const char* hint); + virtual ~GUIWindow() {} GUIButton *CreateButton(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, int a6, int a7, UIMessageType msg, unsigned int msg_param, unsigned __int8 uHotkey, const char *pName, struct Texture *pTextures, ...); @@ -348,11 +346,11 @@ void InitializeBookView(); void DrawMessageBox(int arg0); GUIButton *GetControl(unsigned int uID); - void Release(); void _41D08F_set_keyboard_control_group(int num_buttons, int a3, int a4, int a5); void _41D73D_draw_buff_tooltip(); - static GUIWindow *Create(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, enum WindowType eWindowType, int pButton, const char* hint); + virtual void Update() {} + virtual void Release(); unsigned int uFrameX; unsigned int uFrameY; @@ -381,8 +379,300 @@ }; #pragma pack(pop) +struct GUIWindow_GameMenu : public GUIWindow +{ + GUIWindow_GameMenu(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + {} + virtual ~GUIWindow_GameMenu() {} + virtual void Update(); +}; +struct GUIWindow_CharacterRecord : public GUIWindow +{ + GUIWindow_CharacterRecord(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + {} + virtual ~GUIWindow_CharacterRecord() {} + virtual void Update(); +}; +struct GUIWindow_Options : public GUIWindow +{ + GUIWindow_Options(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + {} + virtual ~GUIWindow_Options() {} + + virtual void Update(); +}; +struct GUIWindow_KeymappingOptions : public GUIWindow +{ + GUIWindow_KeymappingOptions(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + {} + virtual ~GUIWindow_KeymappingOptions() {} + + virtual void Update(); +}; +struct GUIWindow_VideoOptions : public GUIWindow +{ + GUIWindow_VideoOptions(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + {} + virtual ~GUIWindow_VideoOptions() {} + + virtual void Update(); +}; +struct GUIWindow_Book : public GUIWindow +{ + GUIWindow_Book(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + { + InitializeBookView(); + } + virtual ~GUIWindow_Book() {} + + virtual void Update(); + virtual void Release(); +}; +struct GUIWindow_BooksWindow : public GUIWindow +{ + GUIWindow_BooksWindow(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + {} + virtual ~GUIWindow_BooksWindow() {} + + virtual void Update(); +}; +struct GUIWindow_QuickReference : public GUIWindow +{ + GUIWindow_QuickReference(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + {} + virtual ~GUIWindow_QuickReference() {} + + virtual void Update(); +}; +struct GUIWindow_Rest : public GUIWindow +{ + GUIWindow_Rest(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + {} + virtual ~GUIWindow_Rest() {} + + virtual void Update(); +}; +struct GUIWindow_RestWindow : public GUIWindow +{ + GUIWindow_RestWindow(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + {} + virtual ~GUIWindow_RestWindow() {} + + virtual void Update(); + virtual void Release(); +}; +struct GUIWindow_Travel : public GUIWindow +{ + GUIWindow_Travel(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint); + virtual ~GUIWindow_Travel() {} + + virtual void Update(); + virtual void Release(); +}; +struct GUIWindow_Transition : public GUIWindow +{ + GUIWindow_Transition(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint); + virtual ~GUIWindow_Transition() {} + + virtual void Update(); + virtual void Release(); +}; +struct GUIWindow_Dialogue : public GUIWindow +{ + GUIWindow_Dialogue(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint); + virtual ~GUIWindow_Dialogue() {} + + virtual void Update(); + virtual void Release(); +}; +struct GUIWindow_Spellbook : public GUIWindow +{ + GUIWindow_Spellbook(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint); + virtual ~GUIWindow_Spellbook() {} + + virtual void Update(); + virtual void Release(); +}; +struct GUIWindow_GenericDialogue : public GUIWindow +{ + GUIWindow_GenericDialogue(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint); + virtual ~GUIWindow_GenericDialogue() {} + + virtual void Update(); + virtual void Release(); +}; +struct GUIWindow_Chest : public GUIWindow +{ + GUIWindow_Chest(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + { + CreateButton(61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0); + CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0); + CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0); + CreateButton(407, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0); + CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, 9, "", 0); + } + virtual ~GUIWindow_Chest() {} + + virtual void Update(); +}; +struct GUIWindow_Save : public GUIWindow +{ + GUIWindow_Save(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + {} + virtual ~GUIWindow_Save() {} + + virtual void Update(); +}; +struct GUIWindow_Load : public GUIWindow +{ + GUIWindow_Load(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + {} + virtual ~GUIWindow_Load() {} + + virtual void Update(); +}; +struct GUIWindow_House : public GUIWindow +{ + GUIWindow_House(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint); + virtual ~GUIWindow_House() {} + + virtual void Update(); + virtual void Release(); +}; +struct GUIWindow_Scroll : public GUIWindow +{ + GUIWindow_Scroll(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + { + CreateButton(61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0); + CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0); + CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0); + CreateButton(407, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0); + CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, '\t', "", 0); + } + virtual ~GUIWindow_Scroll() {} + + virtual void Update(); +}; +struct GUIWindow_Inventory : public GUIWindow +{ + GUIWindow_Inventory(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + {} + virtual ~GUIWindow_Inventory() {} + + virtual void Update(); + virtual void Release(); +}; +struct GUIWindow_Inventory_CastSpell : public GUIWindow +{ + GUIWindow_Inventory_CastSpell(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint); + virtual ~GUIWindow_Inventory_CastSpell() {} + + virtual void Update(); +}; +struct GUIWindow_Modal : public GUIWindow +{ + GUIWindow_Modal(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + {} + virtual ~GUIWindow_Modal() {} + + virtual void Update(); +}; +struct OnButtonClick : public GUIWindow +{ + OnButtonClick(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + {} + virtual ~OnButtonClick() {} + + virtual void Update(); +}; +struct OnButtonClick2 : public GUIWindow +{ + OnButtonClick2(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + {} + virtual ~OnButtonClick2() {} + + virtual void Update(); +}; +struct OnButtonClick3 : public GUIWindow +{ + OnButtonClick3(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + {} + virtual ~OnButtonClick3() {} + + virtual void Update(); +}; +struct OnButtonClick4 : public GUIWindow +{ + OnButtonClick4(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + {} + virtual ~OnButtonClick4() {} + + virtual void Update(); + virtual void Release(); +}; +struct OnSaveLoad : public GUIWindow +{ + OnSaveLoad(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + {} + virtual ~OnSaveLoad() {} + + virtual void Update(); +}; +struct OnCancel : public GUIWindow +{ + OnCancel(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + {} + virtual ~OnCancel() {} + + virtual void Update(); +}; +struct OnCancel2 : public GUIWindow +{ + OnCancel2(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + {} + virtual ~OnCancel2() {} + + virtual void Update(); +}; +struct OnCancel3 : public GUIWindow +{ + OnCancel3(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint) : + GUIWindow(x, y, width, height, button, hint) + {} + virtual ~OnCancel3() {} + + virtual void Update(); +}; +struct OnCastTargetedSpell : public GUIWindow +{ + OnCastTargetedSpell(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int button, const char *hint); + virtual ~OnCastTargetedSpell() {} +}; @@ -473,10 +763,10 @@ -extern int pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[]; // idb +extern enum WindowType current_character_screen_window; extern struct GUIWindow *pWindow_MMT_MainMenu; extern struct GUIWindow *pWindow_MainMenu; -extern std::array<struct GUIWindow, 20> pWindowList; +extern std::array<struct GUIWindow *, 20> pWindowList; @@ -616,7 +906,7 @@ unsigned int UI_GetHealthManaAndOtherQualitiesStringColor(signed int current_pos, signed int base_pos); unsigned int __fastcall GetSizeInInventorySlots(unsigned int uNumPixels); struct GUIButton *__fastcall GUI_HandleHotkey(unsigned __int8 uHotkey); // idb -int __fastcall GUI_ReplaceHotkey(unsigned __int8 uOldHotkey, unsigned __int8 uNewHotkey, char bFirstCall); +void GUI_ReplaceHotkey(unsigned __int8 uOldHotkey, unsigned __int8 uNewHotkey, char bFirstCall); void DrawBuff_remaining_time_string(int uY, struct GUIWindow *window, __int64 remaining_time, struct GUIFont *Font); void GameUI_DrawItemInfo(struct ItemGen* inspect_item); // idb void MonsterPopup_Draw(unsigned int uActorID, struct GUIWindow *window); @@ -748,11 +1038,6 @@ extern struct GUIButton *pMMT_MainMenu_BtnContinue; extern struct GUIButton *pMMT_MainMenu_BtnExit; -extern struct GUIButton *pMainMenu_BtnExit; -extern struct GUIButton *pMainMenu_BtnCredits; -extern struct GUIButton *pMainMenu_BtnLoad; -extern struct GUIButton *pMainMenu_BtnNew; - extern struct GUIButton *pBtn_Up; extern struct GUIButton *pBtn_Down;