forked from diasurgical/devilution
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainmenu.cpp
More file actions
211 lines (197 loc) · 5.46 KB
/
mainmenu.cpp
File metadata and controls
211 lines (197 loc) · 5.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
// ref: 0x10008164
void __cdecl MainMenu_cpp_init()
{
mainmenu_cpp_float = mainmenu_cpp_float_value;
}
// 1001F434: using guessed type int mainmenu_cpp_float_value;
// 1002A0D4: using guessed type int mainmenu_cpp_float;
// ref: 0x1000816F
BOOL __stdcall UiMainMenuDialog(const char *name, int *pdwResult, void(__stdcall *fnSound)(const char *file), int attractTimeOut)
{
int v4; // eax
int v5; // esi
menu_item_timer = attractTimeOut;
TitleSnd_SetSoundFunction(fnSound);
artfont_LoadAllFonts();
menu_version_str[0] = 0;
if (name)
strncpy(menu_version_str, name, 0x40u);
v4 = (int)SDrawGetFrameWindow(NULL);
v5 = SDlgDialogBoxParam(ghUiInst, "MAINMENU_DIALOG", v4, MainMenu_WndProc, 0);
if (v5 == 5)
artfont_FreeAllFonts();
if (pdwResult)
*pdwResult = v5;
return 1;
}
// 10010382: using guessed type DWORD __stdcall SDrawGetFrameWindow();
// 1002A118: using guessed type int menu_item_timer;
// ref: 0x100081E3
LRESULT __stdcall MainMenu_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
HWND v5; // eax
if (Msg <= 0x113) {
if (Msg != 275) {
if (Msg == 2) {
MainMenu_KillAndFreeMenu(hWnd);
} else if (Msg > 0x103) {
if (Msg <= 0x105) {
v5 = (HWND)SDrawGetFrameWindow(NULL);
SendMessageA(v5, Msg, wParam, lParam);
} else {
if (Msg == 272) {
MainMenu_LoadMenuGFX(hWnd);
PostMessageA(hWnd, 0x7E8u, 0, 0);
return 1;
}
if (Msg == 273) {
MainMenu_SetMenuTimer(hWnd);
switch (HIWORD(wParam)) {
case 7:
Focus_GetAndBlitSpin(hWnd, lParam);
break;
case 6:
Focus_CheckPlayMove(lParam);
Focus_DoBlitSpinIncFrame(hWnd, (HWND)lParam);
break;
case 0:
MainMenu_CheckWParamFocus(hWnd, (unsigned short)wParam);
break;
}
}
}
}
return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam);
}
if (wParam == 3 && !DiabloUI_GetSpawned()) {
if (app_is_active)
MainMenu_DoOptions(hWnd, 6, 0);
else
MainMenu_SetMenuTimer(hWnd);
}
return 0;
}
if (Msg >= 0x200) {
if (Msg <= 0x202)
goto LABEL_34;
if (Msg <= 0x203)
return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam);
if (Msg <= 0x205) {
LABEL_34:
MainMenu_SetMenuTimer(hWnd);
return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam);
}
if (Msg == 2024) {
if (!Fade_CheckRange5())
Fade_SetFadeTimer((int)hWnd);
return 0;
}
}
return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam);
}
// 10010382: using guessed type DWORD __stdcall SDrawGetFrameWindow();
// 10029728: using guessed type int app_is_active;
// ref: 0x10008354
void __fastcall MainMenu_KillAndFreeMenu(HWND hWnd)
{
void **v2; // eax
Title_KillTitleTimer(hWnd);
Focus_KillFocusTimer(hWnd);
Doom_DeleteFreeProcs(hWnd, menumsgs_5options);
Doom_DeleteFreeProcs(hWnd, menumsgs_1option);
v2 = (void **)GetWindowLongA(hWnd, -21);
local_FreeMemPtr(v2);
local_SetCursorDefault();
}
// ref: 0x10008391
void __fastcall MainMenu_SetMenuTimer(HWND hWnd)
{
SDlgSetTimer((int)hWnd, 3, 1000 * menu_item_timer, 0);
}
// 1002A118: using guessed type int menu_item_timer;
// ref: 0x100083A8
void __fastcall MainMenu_LoadMenuGFX(HWND hWnd)
{
DWORD *v2; // eax MAPDST
bool v4; // zf
const char *v5; // eax
HWND v6; // eax
v2 = local_AllocWndLongData();
if (v2) {
SetWindowLongA(hWnd, -21, (LONG)v2);
v4 = DiabloUI_GetSpawned() == 0;
v5 = "ui_art\\swmmenu.pcx";
if (v4)
v5 = "ui_art\\mainmenu.pcx";
local_LoadArtWithPal(hWnd, 0, &nullcharacter, -1, 1, v5, (BYTE **)v2, v2 + 1, 0);
Fade_NoInputAndArt(hWnd, 1);
}
v6 = GetDlgItem(hWnd, 1042);
SetWindowTextA(v6, menu_version_str);
Doom_ParseWndProc3(hWnd, menumsgs_1option, AF_SMALLGRAY);
Doom_ParseWndProcs(hWnd, menumsgs_5options, AF_HUGE, 1);
Focus_SetFocusTimer(hWnd, "ui_art\\focus42.pcx");
Title_LoadImgSetTimer(hWnd, "ui_art\\smlogo.pcx");
MainMenu_SetMenuTimer(hWnd);
local_DoUiWndProc2(hWnd, (DWORD *)menumsgs_5options);
}
// ref: 0x1000845A
void __fastcall MainMenu_DoOptions(HWND hWnd, int option, int PlaySelect)
{
SDlgKillTimer((int)hWnd, 3);
if (DiabloUI_GetSpawned() && option == 3) {
SelYesNo_SpawnErrDialog(hWnd, 70, 1);
LABEL_7:
SDlgSetTimer((int)hWnd, 3, 1000 * menu_item_timer, 0);
return;
}
if (option == 2 && !MainMenu_CheckEnoughMemory()) {
SelYesNo_SpawnErrDialog(hWnd, 78, 1);
goto LABEL_7;
}
Fade_Range5SetZero();
if (PlaySelect)
TitleSnd_PlaySelectSound();
Fade_UpdatePaletteRange(10);
SDlgEndDialog(hWnd, (HANDLE)option);
}
// 1002A118: using guessed type int menu_item_timer;
// ref: 0x100084D5
BOOL __cdecl MainMenu_CheckEnoughMemory()
{
struct _MEMORYSTATUS Buffer; // [esp+0h] [ebp-20h]
Buffer.dwLength = 32;
GlobalMemoryStatus(&Buffer);
return Buffer.dwTotalPhys > 0xDAC000;
}
// ref: 0x100084FA
void __fastcall MainMenu_CheckWParamFocus(HWND hWnd, WPARAM wParam)
{
HWND v3; // eax
LONG v4; // eax
int v5; // [esp-8h] [ebp-Ch]
switch (wParam) {
case 1u:
v3 = GetFocus();
v4 = GetWindowLongA(v3, -12);
SendMessageA(hWnd, 0x111u, v4, 0);
return;
case 2u:
v5 = 5;
goto LABEL_12;
case 0x3E9u:
v5 = 2;
goto LABEL_12;
case 0x3EAu:
v5 = 3;
goto LABEL_12;
case 0x3EBu:
v5 = 4;
LABEL_12:
MainMenu_DoOptions(hWnd, v5, 1);
return;
case 0x414u:
MainMenu_DoOptions(hWnd, 1, 1);
break;
}
}