annotate OSWindow.cpp @ 1879:7efa09ddb8b4

Actor::AI_SpellAttack1 cleaned up
author Grumpy7
date Thu, 17 Oct 2013 10:00:57 +0200
parents 5ea627a263dd
children 8cd321994943
rev   line source
1804
Nomad
parents:
diff changeset
1 #include "OSWindow.h"
Nomad
parents:
diff changeset
2 #include "mm7_data.h"
Nomad
parents:
diff changeset
3 #include "Arcomage.h"
Nomad
parents:
diff changeset
4 #include "AudioPlayer.h"
Nomad
parents:
diff changeset
5 #include "VideoPlayer.h"
Nomad
parents:
diff changeset
6 #include "Mouse.h"
Nomad
parents:
diff changeset
7 #include "Time.h"
Nomad
parents:
diff changeset
8 #include "GUIWindow.h"
Nomad
parents:
diff changeset
9 #include "Party.h"
Nomad
parents:
diff changeset
10 #include "Game.h"
Nomad
parents:
diff changeset
11 #include "IndoorCameraD3D.h"
Nomad
parents:
diff changeset
12 #include "Keyboard.h"
Nomad
parents:
diff changeset
13 #include "Render.h"
Nomad
parents:
diff changeset
14 #include "Viewport.h"
Nomad
parents:
diff changeset
15 #include "Vis.h"
Nomad
parents:
diff changeset
16 #include "Texts.h"
Nomad
parents:
diff changeset
17 #include "AIL.h"
Nomad
parents:
diff changeset
18 #include "Bink_Smacker.h"
Nomad
parents:
diff changeset
19 #include "ErrorHandling.h"
Nomad
parents:
diff changeset
20
Nomad
parents:
diff changeset
21
Nomad
parents:
diff changeset
22 bool OSWindow::OnMouseLeftClick(int x, int y)
Nomad
parents:
diff changeset
23 {
1815
bd899dfd976c MainMenuWindow
Nomad
parents: 1806
diff changeset
24 if (UIControl::OnMouseLeftClick(x, y))
bd899dfd976c MainMenuWindow
Nomad
parents: 1806
diff changeset
25 return true;
bd899dfd976c MainMenuWindow
Nomad
parents: 1806
diff changeset
26
1804
Nomad
parents:
diff changeset
27 if (pVideoPlayer->pVideoFrame.pPixels)
Nomad
parents:
diff changeset
28 pVideoPlayer->bStopBeforeSchedule = true;
Nomad
parents:
diff changeset
29
Nomad
parents:
diff changeset
30 pMouse->SetMouseClick(x, y);
Nomad
parents:
diff changeset
31
Nomad
parents:
diff changeset
32 if (GetCurrentMenuID() == MENU_CREATEPARTY)
Nomad
parents:
diff changeset
33 UI_OnKeyDown(VK_SELECT);
Nomad
parents:
diff changeset
34
Nomad
parents:
diff changeset
35 if (pGame)
Nomad
parents:
diff changeset
36 pGame->PickMouse(512.0, x, y, false, &vis_sprite_filter_3, &vis_door_filter);
Nomad
parents:
diff changeset
37
Nomad
parents:
diff changeset
38 UI_OnMouseLeftClick(0);
Nomad
parents:
diff changeset
39 return true;
Nomad
parents:
diff changeset
40 }
Nomad
parents:
diff changeset
41
Nomad
parents:
diff changeset
42 bool OSWindow::OnMouseRightClick(int x, int y)
Nomad
parents:
diff changeset
43 {
1815
bd899dfd976c MainMenuWindow
Nomad
parents: 1806
diff changeset
44 if (UIControl::OnMouseRightClick(x, y))
bd899dfd976c MainMenuWindow
Nomad
parents: 1806
diff changeset
45 return true;
bd899dfd976c MainMenuWindow
Nomad
parents: 1806
diff changeset
46
1804
Nomad
parents:
diff changeset
47 if (pVideoPlayer->pVideoFrame.pPixels)
Nomad
parents:
diff changeset
48 pVideoPlayer->bStopBeforeSchedule = true;
Nomad
parents:
diff changeset
49
Nomad
parents:
diff changeset
50 pMouse->SetMouseClick(x, y);
Nomad
parents:
diff changeset
51
Nomad
parents:
diff changeset
52 if (pGame)
Nomad
parents:
diff changeset
53 pGame->PickMouse(pGame->pIndoorCameraD3D->GetPickDepth(), x, y, 0, &vis_sprite_filter_2, &vis_door_filter);
Nomad
parents:
diff changeset
54
Nomad
parents:
diff changeset
55 UI_OnMouseRightClick(0);
Nomad
parents:
diff changeset
56 return true;
Nomad
parents:
diff changeset
57 }
Nomad
parents:
diff changeset
58
Nomad
parents:
diff changeset
59
1830
5ea627a263dd Clicking works again
Nomad
parents: 1827
diff changeset
60 bool _507B98_ctrl_pressed = false;
1804
Nomad
parents:
diff changeset
61 bool OSWindow::WinApiMessageProc(UINT msg, WPARAM wparam, LPARAM lparam, LRESULT *result)
Nomad
parents:
diff changeset
62 {
Nomad
parents:
diff changeset
63 switch (msg)
Nomad
parents:
diff changeset
64 {
Nomad
parents:
diff changeset
65 case WM_KEYUP:
Nomad
parents:
diff changeset
66 {
1830
5ea627a263dd Clicking works again
Nomad
parents: 1827
diff changeset
67 if (wparam == VK_CONTROL)
5ea627a263dd Clicking works again
Nomad
parents: 1827
diff changeset
68 _507B98_ctrl_pressed = false;
5ea627a263dd Clicking works again
Nomad
parents: 1827
diff changeset
69
1804
Nomad
parents:
diff changeset
70 OnKey(wparam);
Nomad
parents:
diff changeset
71 return *result = 0, true;
Nomad
parents:
diff changeset
72 }
Nomad
parents:
diff changeset
73
Nomad
parents:
diff changeset
74 case WM_SIZING: return *result = 1, true;
Nomad
parents:
diff changeset
75 case WM_WINDOWPOSCHANGED:
Nomad
parents:
diff changeset
76 if (pVideoPlayer && pVideoPlayer->AnyMovieLoaded() && pVideoPlayer->pBinkBuffer)
Nomad
parents:
diff changeset
77 BinkBufferSetOffset(pVideoPlayer->pBinkBuffer, 0, 0);
Nomad
parents:
diff changeset
78 return false;
Nomad
parents:
diff changeset
79
Nomad
parents:
diff changeset
80 case WM_CHAR:
Nomad
parents:
diff changeset
81 if (!pKeyActionMap->_459F10(wparam) && !viewparams->field_4C)
Nomad
parents:
diff changeset
82 GUI_HandleHotkey(wparam);
Nomad
parents:
diff changeset
83 return false;
Nomad
parents:
diff changeset
84
Nomad
parents:
diff changeset
85 case WM_DESTROY:
Nomad
parents:
diff changeset
86 ExitProcess(GetLastError());
Nomad
parents:
diff changeset
87 // SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
Nomad
parents:
diff changeset
88 // PostQuitMessage(0);
Nomad
parents:
diff changeset
89 // return 0;
Nomad
parents:
diff changeset
90
Nomad
parents:
diff changeset
91 //case WM_DEVICECHANGE:
Nomad
parents:
diff changeset
92 //{
Nomad
parents:
diff changeset
93 // if (wParam == 0x8000) // CD or some device has been inserted - notify InsertCD dialog
Nomad
parents:
diff changeset
94 // PostMessageW(hInsertCDWindow, WM_USER + 1, 0, 0);
Nomad
parents:
diff changeset
95 // return 0;
Nomad
parents:
diff changeset
96 //}
Nomad
parents:
diff changeset
97
Nomad
parents:
diff changeset
98 case WM_COMMAND:
Nomad
parents:
diff changeset
99 if (OnOSMenu(wparam))
Nomad
parents:
diff changeset
100 return *result = 0, true;
Nomad
parents:
diff changeset
101 return false;
Nomad
parents:
diff changeset
102
Nomad
parents:
diff changeset
103 case WM_LBUTTONDOWN:
Nomad
parents:
diff changeset
104 {
Nomad
parents:
diff changeset
105 if (pArcomageGame->bGameInProgress)
Nomad
parents:
diff changeset
106 {
Nomad
parents:
diff changeset
107 pArcomageGame->stru1.field_0 = 7;
Nomad
parents:
diff changeset
108 ArcomageGame::OnMouseClick(0, true);
Nomad
parents:
diff changeset
109 return false;
Nomad
parents:
diff changeset
110 }
Nomad
parents:
diff changeset
111
Nomad
parents:
diff changeset
112 OnMouseLeftClick(LOWORD(lparam), HIWORD(lparam));
Nomad
parents:
diff changeset
113 }
Nomad
parents:
diff changeset
114 return false;
Nomad
parents:
diff changeset
115
Nomad
parents:
diff changeset
116
Nomad
parents:
diff changeset
117 case WM_RBUTTONDOWN:
Nomad
parents:
diff changeset
118 {
Nomad
parents:
diff changeset
119 if (pArcomageGame->bGameInProgress)
Nomad
parents:
diff changeset
120 {
Nomad
parents:
diff changeset
121 pArcomageGame->stru1.field_0 = 8;
Nomad
parents:
diff changeset
122 ArcomageGame::OnMouseClick(1, true);
Nomad
parents:
diff changeset
123 return false;
Nomad
parents:
diff changeset
124 }
Nomad
parents:
diff changeset
125
Nomad
parents:
diff changeset
126 OnMouseRightClick(LOWORD(lparam), HIWORD(lparam));
Nomad
parents:
diff changeset
127 }
Nomad
parents:
diff changeset
128 return false;
Nomad
parents:
diff changeset
129
Nomad
parents:
diff changeset
130
Nomad
parents:
diff changeset
131 case WM_LBUTTONUP:
Nomad
parents:
diff changeset
132 if ( !pArcomageGame->bGameInProgress )
Nomad
parents:
diff changeset
133 {
Nomad
parents:
diff changeset
134 back_to_game();
Nomad
parents:
diff changeset
135 return false;
Nomad
parents:
diff changeset
136 }
Nomad
parents:
diff changeset
137 pArcomageGame->stru1.field_0 = 3;
Nomad
parents:
diff changeset
138 ArcomageGame::OnMouseClick(0, 0);
Nomad
parents:
diff changeset
139 return false;
Nomad
parents:
diff changeset
140
Nomad
parents:
diff changeset
141 case WM_RBUTTONUP:
Nomad
parents:
diff changeset
142 if ( !pArcomageGame->bGameInProgress )
Nomad
parents:
diff changeset
143 {
Nomad
parents:
diff changeset
144 back_to_game();
Nomad
parents:
diff changeset
145 return false;
Nomad
parents:
diff changeset
146 }
Nomad
parents:
diff changeset
147 pArcomageGame->stru1.field_0 = 4;
Nomad
parents:
diff changeset
148 ArcomageGame::OnMouseClick(1, false);
Nomad
parents:
diff changeset
149 return false;
Nomad
parents:
diff changeset
150
Nomad
parents:
diff changeset
151 case WM_LBUTTONDBLCLK:
Nomad
parents:
diff changeset
152 {
Nomad
parents:
diff changeset
153 if ( pArcomageGame->bGameInProgress )
Nomad
parents:
diff changeset
154 {
Nomad
parents:
diff changeset
155 pArcomageGame->stru1.field_0 = 7;
Nomad
parents:
diff changeset
156 return false;
Nomad
parents:
diff changeset
157 }
Nomad
parents:
diff changeset
158
Nomad
parents:
diff changeset
159 OnMouseLeftClick(LOWORD(lparam), HIWORD(lparam));
Nomad
parents:
diff changeset
160 }
Nomad
parents:
diff changeset
161 return false;
Nomad
parents:
diff changeset
162
Nomad
parents:
diff changeset
163 case WM_RBUTTONDBLCLK:
Nomad
parents:
diff changeset
164 {
Nomad
parents:
diff changeset
165 if (pArcomageGame->bGameInProgress)
Nomad
parents:
diff changeset
166 {
Nomad
parents:
diff changeset
167 pArcomageGame->stru1.field_0 = 8;
Nomad
parents:
diff changeset
168 return false;
Nomad
parents:
diff changeset
169 }
Nomad
parents:
diff changeset
170
Nomad
parents:
diff changeset
171 OnMouseRightClick(LOWORD(lparam), HIWORD(lparam));
Nomad
parents:
diff changeset
172 }
Nomad
parents:
diff changeset
173 return false;
Nomad
parents:
diff changeset
174
Nomad
parents:
diff changeset
175 /*case WM_MBUTTONDOWN:
Nomad
parents:
diff changeset
176 if (pRenderer->pRenderD3D && pGame)
Nomad
parents:
diff changeset
177 {
Nomad
parents:
diff changeset
178 pGame->PickMouse(pGame->pIndoorCameraD3D->GetPickDepth(), LOWORD(lParam), HIWORD(lParam), 1, &vis_sprite_filter_3, &vis_face_filter);
Nomad
parents:
diff changeset
179 }
Nomad
parents:
diff changeset
180 return false;*/
Nomad
parents:
diff changeset
181
Nomad
parents:
diff changeset
182 case WM_MOUSEMOVE:
Nomad
parents:
diff changeset
183 if ( pArcomageGame->bGameInProgress )
Nomad
parents:
diff changeset
184 {
Nomad
parents:
diff changeset
185 ArcomageGame::OnMouseMove(LOWORD(lparam), HIWORD(lparam));
Nomad
parents:
diff changeset
186 ArcomageGame::OnMouseClick(0, wparam == MK_LBUTTON);
Nomad
parents:
diff changeset
187 ArcomageGame::OnMouseClick(1, wparam == MK_RBUTTON);
Nomad
parents:
diff changeset
188 }
Nomad
parents:
diff changeset
189 else if (pMouse)
Nomad
parents:
diff changeset
190 pMouse->SetMouseClick(LOWORD(lparam), HIWORD(lparam));
Nomad
parents:
diff changeset
191 return false;
Nomad
parents:
diff changeset
192
Nomad
parents:
diff changeset
193 case WM_SYSCOMMAND:
Nomad
parents:
diff changeset
194 if ( wparam == SC_SCREENSAVE || wparam == SC_MONITORPOWER )
Nomad
parents:
diff changeset
195 return *result = 0, true;
Nomad
parents:
diff changeset
196 return false;
Nomad
parents:
diff changeset
197
Nomad
parents:
diff changeset
198 case WM_KEYDOWN:
Nomad
parents:
diff changeset
199 if ( uGameMenuUI_CurentlySelectedKeyIdx != -1 )
Nomad
parents:
diff changeset
200 {
Nomad
parents:
diff changeset
201 pKeyActionMap->_459F10(wparam);
Nomad
parents:
diff changeset
202 return false;
Nomad
parents:
diff changeset
203 }
Nomad
parents:
diff changeset
204 if ( !pArcomageGame->bGameInProgress )
Nomad
parents:
diff changeset
205 {
Nomad
parents:
diff changeset
206 if ( pVideoPlayer->pVideoFrame.pPixels )
Nomad
parents:
diff changeset
207 pVideoPlayer->bStopBeforeSchedule = 1;
Nomad
parents:
diff changeset
208 if ( wparam == VK_RETURN )
Nomad
parents:
diff changeset
209 {
Nomad
parents:
diff changeset
210 if ( !viewparams->field_4C )
Nomad
parents:
diff changeset
211 UI_OnKeyDown(wparam);
Nomad
parents:
diff changeset
212 return 0;
Nomad
parents:
diff changeset
213 }
1830
5ea627a263dd Clicking works again
Nomad
parents: 1827
diff changeset
214 if (wparam == VK_CONTROL)
5ea627a263dd Clicking works again
Nomad
parents: 1827
diff changeset
215 {
5ea627a263dd Clicking works again
Nomad
parents: 1827
diff changeset
216 _507B98_ctrl_pressed = true;
5ea627a263dd Clicking works again
Nomad
parents: 1827
diff changeset
217 return false;
5ea627a263dd Clicking works again
Nomad
parents: 1827
diff changeset
218 }
1804
Nomad
parents:
diff changeset
219 if ( wparam == VK_ESCAPE )
Nomad
parents:
diff changeset
220 {
Nomad
parents:
diff changeset
221 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, window_SpeakInHouse != 0, 0);
Nomad
parents:
diff changeset
222 return 0;
Nomad
parents:
diff changeset
223 }
Nomad
parents:
diff changeset
224 if ( wparam <= VK_HOME )
Nomad
parents:
diff changeset
225 return 0;
Nomad
parents:
diff changeset
226 if ( wparam > VK_DOWN )
Nomad
parents:
diff changeset
227 {
Nomad
parents:
diff changeset
228 if ( wparam != VK_F4 || pVideoPlayer->AnyMovieLoaded() )
Nomad
parents:
diff changeset
229 return 0;
Nomad
parents:
diff changeset
230
Nomad
parents:
diff changeset
231 // F4 - toggle fullscreen
Nomad
parents:
diff changeset
232 SendMessageW(api_handle, WM_COMMAND, 104, 0);
Nomad
parents:
diff changeset
233 return 0;
Nomad
parents:
diff changeset
234 }
Nomad
parents:
diff changeset
235 if ( wparam >= VK_LEFT && wparam <= VK_DOWN )
Nomad
parents:
diff changeset
236 {
Nomad
parents:
diff changeset
237 if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_MODAL_WINDOW )
Nomad
parents:
diff changeset
238 {
Nomad
parents:
diff changeset
239 if ( !viewparams->field_4C )
Nomad
parents:
diff changeset
240 UI_OnKeyDown(wparam);
Nomad
parents:
diff changeset
241 return 0;
Nomad
parents:
diff changeset
242 }
Nomad
parents:
diff changeset
243 }
Nomad
parents:
diff changeset
244 if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_MODAL_WINDOW )
Nomad
parents:
diff changeset
245 return 0;
Nomad
parents:
diff changeset
246 }
Nomad
parents:
diff changeset
247
Nomad
parents:
diff changeset
248 pArcomageGame->stru1.field_0 = 1;
Nomad
parents:
diff changeset
249
Nomad
parents:
diff changeset
250 set_stru1_field_8_InArcomage(MapVirtualKey(wparam, MAPVK_VK_TO_CHAR));
Nomad
parents:
diff changeset
251 if ( wparam == 27 )
Nomad
parents:
diff changeset
252 {
Nomad
parents:
diff changeset
253 pArcomageGame->GameOver = 1;
Nomad
parents:
diff changeset
254 pArcomageGame->field_F4 = 1;
Nomad
parents:
diff changeset
255 pArcomageGame->uGameResult = 2;
Nomad
parents:
diff changeset
256 pArcomageGame->field_B0 = -2;
Nomad
parents:
diff changeset
257 return false;
Nomad
parents:
diff changeset
258 }
Nomad
parents:
diff changeset
259 if ( wparam != 114 )
Nomad
parents:
diff changeset
260 {
Nomad
parents:
diff changeset
261 if ( wparam == 115 && !pVideoPlayer->AnyMovieLoaded() )
Nomad
parents:
diff changeset
262 SendMessage(api_handle, WM_COMMAND, 104, 0);
Nomad
parents:
diff changeset
263 return false;
Nomad
parents:
diff changeset
264 }
Nomad
parents:
diff changeset
265 SendMessageW(api_handle, WM_COMMAND, 103, 0);
Nomad
parents:
diff changeset
266 return *result = 0, true;
Nomad
parents:
diff changeset
267
Nomad
parents:
diff changeset
268 case WM_ACTIVATEAPP:
Nomad
parents:
diff changeset
269 if ( wparam && (GetForegroundWindow() == api_handle || GetForegroundWindow() == hInsertCDWindow) )
Nomad
parents:
diff changeset
270 {
Nomad
parents:
diff changeset
271 if ( BYTE1(dword_6BE364_game_settings_1) & 1 )
Nomad
parents:
diff changeset
272 {
Nomad
parents:
diff changeset
273 dword_4E98BC_bApplicationActive = 1;
Nomad
parents:
diff changeset
274 if ( pRenderer->bWindowMode )
Nomad
parents:
diff changeset
275 {
Nomad
parents:
diff changeset
276 HDC hDC = GetDC(api_handle);
Nomad
parents:
diff changeset
277 int bitsPerPixel = GetDeviceCaps(hDC, BITSPIXEL);
Nomad
parents:
diff changeset
278 int planes = GetDeviceCaps(hDC, PLANES);
Nomad
parents:
diff changeset
279 ReleaseDC(api_handle, hDC);
Nomad
parents:
diff changeset
280 if (bitsPerPixel != 16 || planes != 1)
Nomad
parents:
diff changeset
281 Error(pGlobalTXT_LocalizationStrings[62]);
Nomad
parents:
diff changeset
282 }
Nomad
parents:
diff changeset
283 BYTE1(dword_6BE364_game_settings_1) &= 0xFEu;
Nomad
parents:
diff changeset
284
Nomad
parents:
diff changeset
285 if ( pArcomageGame->bGameInProgress )
Nomad
parents:
diff changeset
286 {
Nomad
parents:
diff changeset
287 pArcomageGame->field_F9 = 1;
Nomad
parents:
diff changeset
288 }
Nomad
parents:
diff changeset
289 else
Nomad
parents:
diff changeset
290 {
Nomad
parents:
diff changeset
291 if ( BYTE1(dword_6BE364_game_settings_1) & 2 )
Nomad
parents:
diff changeset
292 BYTE1(dword_6BE364_game_settings_1) &= 0xFDu;
Nomad
parents:
diff changeset
293 else
Nomad
parents:
diff changeset
294 pEventTimer->Resume();
Nomad
parents:
diff changeset
295 if ( BYTE1(dword_6BE364_game_settings_1) & 4 )
Nomad
parents:
diff changeset
296 BYTE1(dword_6BE364_game_settings_1) &= 0xFBu;
Nomad
parents:
diff changeset
297 else
Nomad
parents:
diff changeset
298 pMiscTimer->Resume();
Nomad
parents:
diff changeset
299
Nomad
parents:
diff changeset
300 viewparams->bRedrawGameUI = true;
Nomad
parents:
diff changeset
301 if ( pVideoPlayer->pSmackerMovie )
Nomad
parents:
diff changeset
302 {
Nomad
parents:
diff changeset
303 pRenderer->RestoreFrontBuffer();
Nomad
parents:
diff changeset
304 pRenderer->_4A184C();
Nomad
parents:
diff changeset
305 pVideoPlayer->_4BF5B2();
Nomad
parents:
diff changeset
306 }
Nomad
parents:
diff changeset
307 }
Nomad
parents:
diff changeset
308 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop && !pVideoPlayer->pSmackerMovie )
Nomad
parents:
diff changeset
309 AIL_redbook_resume(pAudioPlayer->hAILRedbook);
Nomad
parents:
diff changeset
310 }
Nomad
parents:
diff changeset
311 }
Nomad
parents:
diff changeset
312 else
Nomad
parents:
diff changeset
313 {
Nomad
parents:
diff changeset
314 if (!(dword_6BE364_game_settings_1 & 0x100))
Nomad
parents:
diff changeset
315 {
Nomad
parents:
diff changeset
316 dword_4E98BC_bApplicationActive = 0;
Nomad
parents:
diff changeset
317 if ( (pVideoPlayer->pSmackerMovie || pVideoPlayer->pBinkMovie) && pVideoPlayer->bPlayingMovie )
Nomad
parents:
diff changeset
318 pVideoPlayer->bStopBeforeSchedule = 1;
Nomad
parents:
diff changeset
319
Nomad
parents:
diff changeset
320 if (/*pRenderer->bUserDirect3D && */pRenderer->uAcquiredDirect3DDevice == 1)
Nomad
parents:
diff changeset
321 SetWindowPos(api_handle, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u);
Nomad
parents:
diff changeset
322 ClipCursor(0);
Nomad
parents:
diff changeset
323 dword_6BE364_game_settings_1 |= 0x100u;
Nomad
parents:
diff changeset
324 if ( pEventTimer->bPaused )
Nomad
parents:
diff changeset
325 BYTE1(dword_6BE364_game_settings_1) |= 2u;
Nomad
parents:
diff changeset
326 else
Nomad
parents:
diff changeset
327 pEventTimer->Pause();
Nomad
parents:
diff changeset
328 if ( pMiscTimer->bPaused )
Nomad
parents:
diff changeset
329 BYTE1(dword_6BE364_game_settings_1) |= 4u;
Nomad
parents:
diff changeset
330 else
Nomad
parents:
diff changeset
331 pMiscTimer->Pause();
Nomad
parents:
diff changeset
332
Nomad
parents:
diff changeset
333 pAudioPlayer->StopChannels(-1, -1);
Nomad
parents:
diff changeset
334 if ( pAudioPlayer->hAILRedbook )
Nomad
parents:
diff changeset
335 AIL_redbook_pause(pAudioPlayer->hAILRedbook);
Nomad
parents:
diff changeset
336 }
Nomad
parents:
diff changeset
337 }
Nomad
parents:
diff changeset
338 return *result = 0, true;
Nomad
parents:
diff changeset
339
Nomad
parents:
diff changeset
340 case WM_SETFOCUS:
Nomad
parents:
diff changeset
341 dword_4E98BC_bApplicationActive = 0;
Nomad
parents:
diff changeset
342 if (pRenderer)
Nomad
parents:
diff changeset
343 {
Nomad
parents:
diff changeset
344 if (/*pRenderer->bUserDirect3D && */pRenderer->uAcquiredDirect3DDevice == 1)
Nomad
parents:
diff changeset
345 SetWindowPos(api_handle, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u);
Nomad
parents:
diff changeset
346 }
Nomad
parents:
diff changeset
347 ClipCursor(0);
Nomad
parents:
diff changeset
348 return false;
Nomad
parents:
diff changeset
349
Nomad
parents:
diff changeset
350 case WM_KILLFOCUS:
Nomad
parents:
diff changeset
351 dword_4E98BC_bApplicationActive = 1;
Nomad
parents:
diff changeset
352 return false;
Nomad
parents:
diff changeset
353
Nomad
parents:
diff changeset
354 case WM_PAINT:
1805
830f196a69ea WinXP fix
Nomad
parents: 1804
diff changeset
355 if (pRenderer)
830f196a69ea WinXP fix
Nomad
parents: 1804
diff changeset
356 {
830f196a69ea WinXP fix
Nomad
parents: 1804
diff changeset
357 if ( !GetUpdateRect(api_handle, 0, 0) || !dword_4E98BC_bApplicationActive && !pRenderer->bWindowMode )
830f196a69ea WinXP fix
Nomad
parents: 1804
diff changeset
358 return *result = 0, true;
830f196a69ea WinXP fix
Nomad
parents: 1804
diff changeset
359 }
1806
Nomad
parents: 1805
diff changeset
360 if (!api_handle || !pRenderer)
1805
830f196a69ea WinXP fix
Nomad
parents: 1804
diff changeset
361 return false;
1804
Nomad
parents:
diff changeset
362 PAINTSTRUCT Paint;
Nomad
parents:
diff changeset
363 BeginPaint(api_handle, &Paint);
Nomad
parents:
diff changeset
364 if ( pArcomageGame->bGameInProgress )
Nomad
parents:
diff changeset
365 {
Nomad
parents:
diff changeset
366 pArcomageGame->field_F9 = 1;
Nomad
parents:
diff changeset
367 }
Nomad
parents:
diff changeset
368 else
Nomad
parents:
diff changeset
369 {
Nomad
parents:
diff changeset
370 if (/*!pRenderer->pRenderD3D && !pRenderer->UsingDirect3D() ||*/ !AreRenderSurfacesOk())
Nomad
parents:
diff changeset
371 {
Nomad
parents:
diff changeset
372 EndPaint(api_handle, &Paint);
Nomad
parents:
diff changeset
373 return *result = 0, true;
Nomad
parents:
diff changeset
374 }
Nomad
parents:
diff changeset
375 }
Nomad
parents:
diff changeset
376 pRenderer->Present();
Nomad
parents:
diff changeset
377 EndPaint(api_handle, &Paint);
Nomad
parents:
diff changeset
378 return *result = 0, true;
Nomad
parents:
diff changeset
379
Nomad
parents:
diff changeset
380 }
Nomad
parents:
diff changeset
381 return false;
Nomad
parents:
diff changeset
382 }
Nomad
parents:
diff changeset
383
Nomad
parents:
diff changeset
384
Nomad
parents:
diff changeset
385
Nomad
parents:
diff changeset
386 bool OSWindow::Initialize(const wchar_t *title, int window_width, int window_height)
Nomad
parents:
diff changeset
387 {
Nomad
parents:
diff changeset
388 WNDCLASSEXW wcxw;
Nomad
parents:
diff changeset
389 wcxw.cbClsExtra = 0;
Nomad
parents:
diff changeset
390 wcxw.cbSize = sizeof(wcxw);
Nomad
parents:
diff changeset
391 wcxw.cbWndExtra = 0;
Nomad
parents:
diff changeset
392 wcxw.hbrBackground = (HBRUSH)(COLOR_BACKGROUND + 1);
Nomad
parents:
diff changeset
393 wcxw.hCursor = nullptr;
Nomad
parents:
diff changeset
394 wcxw.hIcon = wcxw.hIconSm = nullptr;
Nomad
parents:
diff changeset
395 wcxw.hInstance = GetModuleHandleW(nullptr);
Nomad
parents:
diff changeset
396 wcxw.lpfnWndProc = WinApiMsgRouter;
Nomad
parents:
diff changeset
397 wcxw.lpszClassName = L"M&MTrilogy";
Nomad
parents:
diff changeset
398 wcxw.lpszMenuName = nullptr;
Nomad
parents:
diff changeset
399 wcxw.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
Nomad
parents:
diff changeset
400 if (!RegisterClassExW(&wcxw))
Nomad
parents:
diff changeset
401 return false;
Nomad
parents:
diff changeset
402
Nomad
parents:
diff changeset
403 api_handle = CreateWindowExW(0, wcxw.lpszClassName, title,
Nomad
parents:
diff changeset
404 0,
Nomad
parents:
diff changeset
405 0, 0, window_width, window_height, nullptr,
Nomad
parents:
diff changeset
406 nullptr, wcxw.hInstance, this);
Nomad
parents:
diff changeset
407 if (!api_handle)
Nomad
parents:
diff changeset
408 {
Nomad
parents:
diff changeset
409 UnregisterClassW(wcxw.lpszClassName, wcxw.hInstance);
Nomad
parents:
diff changeset
410 return false;
Nomad
parents:
diff changeset
411 }
Nomad
parents:
diff changeset
412
Nomad
parents:
diff changeset
413 SetWindowedMode(window_width, window_height);
Nomad
parents:
diff changeset
414 Show();
Nomad
parents:
diff changeset
415
Nomad
parents:
diff changeset
416 SetActiveWindow(api_handle);
Nomad
parents:
diff changeset
417
Nomad
parents:
diff changeset
418 MSG msg;
Nomad
parents:
diff changeset
419 while (PeekMessageW(&msg, api_handle, 0, 0, PM_REMOVE))
Nomad
parents:
diff changeset
420 {
Nomad
parents:
diff changeset
421 TranslateMessage(&msg);
Nomad
parents:
diff changeset
422 DispatchMessageW(&msg);
Nomad
parents:
diff changeset
423 }
Nomad
parents:
diff changeset
424
Nomad
parents:
diff changeset
425 return true;
Nomad
parents:
diff changeset
426 }
Nomad
parents:
diff changeset
427
Nomad
parents:
diff changeset
428
Nomad
parents:
diff changeset
429
Nomad
parents:
diff changeset
430
Nomad
parents:
diff changeset
431 OSWindow *OSWindow::Create(const wchar_t *title, int window_width, int window_height)
Nomad
parents:
diff changeset
432 {
Nomad
parents:
diff changeset
433 auto window = new OSWindow;
Nomad
parents:
diff changeset
434 if (window)
Nomad
parents:
diff changeset
435 if (!window->Initialize(title, window_width, window_height))
Nomad
parents:
diff changeset
436 {
Nomad
parents:
diff changeset
437 delete window;
Nomad
parents:
diff changeset
438 window = nullptr;
Nomad
parents:
diff changeset
439 }
Nomad
parents:
diff changeset
440
Nomad
parents:
diff changeset
441 return window;
Nomad
parents:
diff changeset
442 }
Nomad
parents:
diff changeset
443
Nomad
parents:
diff changeset
444
Nomad
parents:
diff changeset
445
Nomad
parents:
diff changeset
446 LRESULT __stdcall OSWindow::WinApiMsgRouter(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Nomad
parents:
diff changeset
447 {
Nomad
parents:
diff changeset
448 if (msg == WM_NCCREATE)
Nomad
parents:
diff changeset
449 {
Nomad
parents:
diff changeset
450 auto cs = (CREATESTRUCTA *)(lparam);
Nomad
parents:
diff changeset
451 auto window = (OSWindow *)cs->lpCreateParams;
Nomad
parents:
diff changeset
452
Nomad
parents:
diff changeset
453 SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR)window);
Nomad
parents:
diff changeset
454 return DefWindowProcW(hwnd, msg, wparam, lparam);
Nomad
parents:
diff changeset
455 }
Nomad
parents:
diff changeset
456
Nomad
parents:
diff changeset
457 auto window = (OSWindow *)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
Nomad
parents:
diff changeset
458 if (window && window->api_handle == hwnd)
Nomad
parents:
diff changeset
459 {
Nomad
parents:
diff changeset
460 LPARAM result;
Nomad
parents:
diff changeset
461 if (window->WinApiMessageProc(msg, wparam, lparam, &result))
Nomad
parents:
diff changeset
462 return result;
Nomad
parents:
diff changeset
463 }
Nomad
parents:
diff changeset
464 return DefWindowProcW(hwnd, msg, (WPARAM)wparam, (LPARAM)lparam);
Nomad
parents:
diff changeset
465 }
Nomad
parents:
diff changeset
466
Nomad
parents:
diff changeset
467
Nomad
parents:
diff changeset
468 void OSWindow::Show()
Nomad
parents:
diff changeset
469 {
Nomad
parents:
diff changeset
470 ShowWindow(api_handle, SW_SHOWNORMAL);
Nomad
parents:
diff changeset
471 UpdateWindow(api_handle);
Nomad
parents:
diff changeset
472 }
Nomad
parents:
diff changeset
473
Nomad
parents:
diff changeset
474
Nomad
parents:
diff changeset
475 void OSWindow::SetCursor(const char *cursor_name)
Nomad
parents:
diff changeset
476 {
Nomad
parents:
diff changeset
477 POINT cursor_pos;
Nomad
parents:
diff changeset
478 GetCursorPos(&cursor_pos);
Nomad
parents:
diff changeset
479
Nomad
parents:
diff changeset
480 if (!strcmp(cursor_name, "MICON1") )
Nomad
parents:
diff changeset
481 SetClassLongPtrW(api_handle, GCLP_HCURSOR, (LONG)LoadCursorW(GetModuleHandleW(nullptr), IDC_ARROW));
Nomad
parents:
diff changeset
482 else if (!strcmp(cursor_name, "MICON2") )
Nomad
parents:
diff changeset
483 SetClassLongPtrW(api_handle, GCLP_HCURSOR, (LONG)LoadCursorW(GetModuleHandleW(nullptr), L"Target"));
Nomad
parents:
diff changeset
484 else if (!strcmp(cursor_name, "MICON3") )
Nomad
parents:
diff changeset
485 SetClassLongPtrW(api_handle, GCLP_HCURSOR, (LONG)LoadCursorW(GetModuleHandleW(nullptr), IDC_WAIT));
Nomad
parents:
diff changeset
486
Nomad
parents:
diff changeset
487 //ClientToScreen(api_handle, &cursor_pos);
Nomad
parents:
diff changeset
488 SetCursorPos(cursor_pos.x, cursor_pos.y);
Nomad
parents:
diff changeset
489 }
Nomad
parents:
diff changeset
490
Nomad
parents:
diff changeset
491 void OSWindow::SetFullscreenMode()
Nomad
parents:
diff changeset
492 {
Nomad
parents:
diff changeset
493 SetMenu(api_handle, nullptr);
Nomad
parents:
diff changeset
494 SetWindowLongW(api_handle, GWL_EXSTYLE, WS_EX_TOPMOST);
Nomad
parents:
diff changeset
495 SetWindowLongW(api_handle, GWL_STYLE, WS_VISIBLE | WS_POPUP);
Nomad
parents:
diff changeset
496
Nomad
parents:
diff changeset
497 SetWindowPos(api_handle, HWND_TOP, 0, 0, -1, -1, SWP_NOSIZE | SWP_SHOWWINDOW);
Nomad
parents:
diff changeset
498 }
Nomad
parents:
diff changeset
499
Nomad
parents:
diff changeset
500 void OSWindow::SetWindowedMode(int new_window_width, int new_window_height)
Nomad
parents:
diff changeset
501 {
Nomad
parents:
diff changeset
502 SetWindowLongW(api_handle, GWL_EXSTYLE, 0);
Nomad
parents:
diff changeset
503 SetWindowLongW(api_handle, GWL_STYLE, WS_VISIBLE | WS_OVERLAPPEDWINDOW);
Nomad
parents:
diff changeset
504
Nomad
parents:
diff changeset
505 RECT rcWindow;
Nomad
parents:
diff changeset
506 GetWindowRect(api_handle, &rcWindow);
Nomad
parents:
diff changeset
507
Nomad
parents:
diff changeset
508 RECT rcClient;
Nomad
parents:
diff changeset
509 GetClientRect(api_handle, &rcClient);
Nomad
parents:
diff changeset
510
Nomad
parents:
diff changeset
511 int window_borders_width = (rcWindow.right - rcWindow.left) - (rcClient.right - rcClient.left),
Nomad
parents:
diff changeset
512 window_borders_height = (rcWindow.bottom - rcWindow.top) - (rcClient.bottom - rcClient.top);
Nomad
parents:
diff changeset
513 int window_total_width = new_window_width + window_borders_width,
Nomad
parents:
diff changeset
514 window_total_height = new_window_height + window_borders_height;
Nomad
parents:
diff changeset
515
Nomad
parents:
diff changeset
516 #ifdef _DEBUG
Nomad
parents:
diff changeset
517 if (!GetMenu(api_handle))
Nomad
parents:
diff changeset
518 window_total_height += GetSystemMetrics(SM_CYMENU);
Nomad
parents:
diff changeset
519 #endif
Nomad
parents:
diff changeset
520 MoveWindow(api_handle, (GetSystemMetrics(SM_CXSCREEN) - window_total_width) / 2,
Nomad
parents:
diff changeset
521 (GetSystemMetrics(SM_CYSCREEN) - window_total_height) / 2,
Nomad
parents:
diff changeset
522 window_total_width,
Nomad
parents:
diff changeset
523 window_total_height, 0);
Nomad
parents:
diff changeset
524 #ifdef _DEBUG
Nomad
parents:
diff changeset
525 static HMENU debug_menu = CreateDebugMenuPanel();
Nomad
parents:
diff changeset
526 SetMenu(api_handle, debug_menu);
Nomad
parents:
diff changeset
527 #endif
Nomad
parents:
diff changeset
528 }
Nomad
parents:
diff changeset
529
Nomad
parents:
diff changeset
530
Nomad
parents:
diff changeset
531
Nomad
parents:
diff changeset
532
Nomad
parents:
diff changeset
533 HMENU OSWindow::CreateDebugMenuPanel()
Nomad
parents:
diff changeset
534 {
Nomad
parents:
diff changeset
535 HMENU menu = CreateMenu();
Nomad
parents:
diff changeset
536 {
Nomad
parents:
diff changeset
537 HMENU file = CreatePopupMenu();
Nomad
parents:
diff changeset
538 AppendMenuW(menu, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)file, L"&File");
Nomad
parents:
diff changeset
539 {
Nomad
parents:
diff changeset
540 AppendMenuW(file, MF_ENABLED | MF_STRING, 40001, L"Exit");
Nomad
parents:
diff changeset
541 }
Nomad
parents:
diff changeset
542
Nomad
parents:
diff changeset
543 HMENU debug = CreatePopupMenu();
Nomad
parents:
diff changeset
544 AppendMenuW(menu, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug, L"&Debug");
Nomad
parents:
diff changeset
545 {
Nomad
parents:
diff changeset
546 HMENU debug_party = CreatePopupMenu();
Nomad
parents:
diff changeset
547 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_party, L"&Party");
Nomad
parents:
diff changeset
548 {
Nomad
parents:
diff changeset
549 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40007, L"Give Gold (10 000)");
Nomad
parents:
diff changeset
550 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40008, L"Give Exp (20 000)");
Nomad
parents:
diff changeset
551 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40059, L"Give Skills (50 each)");
Nomad
parents:
diff changeset
552 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40013, L"Remove Gold");
Nomad
parents:
diff changeset
553
Nomad
parents:
diff changeset
554 HMENU debug_party_setconditions = CreatePopupMenu();
Nomad
parents:
diff changeset
555 AppendMenuW(debug_party, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_party_setconditions, L"Set Condition");
Nomad
parents:
diff changeset
556 {
Nomad
parents:
diff changeset
557 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40044, L"Afraid");
Nomad
parents:
diff changeset
558 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40043, L"Asleep");
Nomad
parents:
diff changeset
559 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40037, L"Curse");
Nomad
parents:
diff changeset
560 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40036, L"Disease1");
Nomad
parents:
diff changeset
561 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40035, L"Disease2");
Nomad
parents:
diff changeset
562 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40034, L"Disease3");
Nomad
parents:
diff changeset
563 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40041, L"Dead");
Nomad
parents:
diff changeset
564 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40039, L"Drunk");
Nomad
parents:
diff changeset
565 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40042, L"Eradicated");
Nomad
parents:
diff changeset
566 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40038, L"Insane");
Nomad
parents:
diff changeset
567 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40045, L"Paralyzed");
Nomad
parents:
diff changeset
568 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40033, L"Poison1");
Nomad
parents:
diff changeset
569 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40032, L"Poison2");
Nomad
parents:
diff changeset
570 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40031, L"Poison3");
Nomad
parents:
diff changeset
571 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40029, L"&Stone");
Nomad
parents:
diff changeset
572 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40040, L"Unconscious");
Nomad
parents:
diff changeset
573 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40030, L"Weak");
Nomad
parents:
diff changeset
574 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40073, L"Zombie");
Nomad
parents:
diff changeset
575 }
Nomad
parents:
diff changeset
576
Nomad
parents:
diff changeset
577 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40006, L"Set Food (20)");
Nomad
parents:
diff changeset
578
Nomad
parents:
diff changeset
579 HMENU debug_party_alignment = CreatePopupMenu();
Nomad
parents:
diff changeset
580 AppendMenuW(debug_party, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_party_alignment, L"Alignment");
Nomad
parents:
diff changeset
581 {
Nomad
parents:
diff changeset
582 AppendMenuW(debug_party_alignment, MF_ENABLED | MF_STRING, 40062, L"Good");
Nomad
parents:
diff changeset
583 AppendMenuW(debug_party_alignment, MF_ENABLED | MF_STRING | MF_CHECKED, 40063, L"Neutral");
Nomad
parents:
diff changeset
584 AppendMenuW(debug_party_alignment, MF_ENABLED | MF_STRING, 40064, L"Evil");
Nomad
parents:
diff changeset
585 }
Nomad
parents:
diff changeset
586 }
Nomad
parents:
diff changeset
587
Nomad
parents:
diff changeset
588 HMENU debug_time = CreatePopupMenu();
Nomad
parents:
diff changeset
589 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_time, L"&Time");
Nomad
parents:
diff changeset
590 {
Nomad
parents:
diff changeset
591 AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40009, L"Add 1 Day");
Nomad
parents:
diff changeset
592 AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40010, L"Add 1 Week");
Nomad
parents:
diff changeset
593 AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40011, L"Add 1 Month");
Nomad
parents:
diff changeset
594 AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40012, L"Add 1 Year");
Nomad
parents:
diff changeset
595 }
Nomad
parents:
diff changeset
596
Nomad
parents:
diff changeset
597 HMENU debug_items = CreatePopupMenu();
Nomad
parents:
diff changeset
598 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_items, L"&Items");
Nomad
parents:
diff changeset
599 {
Nomad
parents:
diff changeset
600 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40015, L"Generate level &1 item");
Nomad
parents:
diff changeset
601 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40016, L"Generate level &2 item");
Nomad
parents:
diff changeset
602 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40017, L"Generate level &3 item");
Nomad
parents:
diff changeset
603 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40018, L"Generate level &4 item");
Nomad
parents:
diff changeset
604 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40019, L"Generate level &5 item");
Nomad
parents:
diff changeset
605 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40020, L"Generate level &6 item");
Nomad
parents:
diff changeset
606 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40061, L"Generate special item");
Nomad
parents:
diff changeset
607 }
Nomad
parents:
diff changeset
608
Nomad
parents:
diff changeset
609 HMENU debug_graphics = CreatePopupMenu();
Nomad
parents:
diff changeset
610 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_graphics, L"&Graphics");
Nomad
parents:
diff changeset
611 {
Nomad
parents:
diff changeset
612 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40023, L"Lighting Mode");
Nomad
parents:
diff changeset
613 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40024, L"Lighting Geometry");
Nomad
parents:
diff changeset
614 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING | MF_GRAYED, 40104, L"Lights Off");
Nomad
parents:
diff changeset
615 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40105, L"Colored Lights");
Nomad
parents:
diff changeset
616 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40025, L"Debug Lights");
Nomad
parents:
diff changeset
617 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40101, L"Debug Decals");
Nomad
parents:
diff changeset
618 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40027, L"HWID Portals");
Nomad
parents:
diff changeset
619 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40047, L"SWID Portals");
Nomad
parents:
diff changeset
620 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40051, L"OD Frustum");
Nomad
parents:
diff changeset
621 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40054, L"SWOD Constant Redraw");
Nomad
parents:
diff changeset
622 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40055, L"SWOD Lit Rasterizer");
Nomad
parents:
diff changeset
623 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40056, L"Party Light off");
Nomad
parents:
diff changeset
624 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40060, L"SWOD Nice Lighting off");
Nomad
parents:
diff changeset
625 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40067, L"HWOD Additive Fog Lights");
Nomad
parents:
diff changeset
626 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40072, L"HWID Nice Lighting");
Nomad
parents:
diff changeset
627 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40048, L"Wireframe");
Nomad
parents:
diff changeset
628 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40049, L"Fog");
Nomad
parents:
diff changeset
629 }
Nomad
parents:
diff changeset
630
Nomad
parents:
diff changeset
631 HMENU debug_misc = CreatePopupMenu();
Nomad
parents:
diff changeset
632 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_misc, L"&Misc");
Nomad
parents:
diff changeset
633 {
Nomad
parents:
diff changeset
634 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40066, L"Object Viewcone Culling");
Nomad
parents:
diff changeset
635 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40068, L"Red Tint");
Nomad
parents:
diff changeset
636 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40071, L"Display Secrets");
Nomad
parents:
diff changeset
637 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40102, L"Massive Bloodsplat");
Nomad
parents:
diff changeset
638 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40103, L"Underwater Gravity");
Nomad
parents:
diff changeset
639 }
Nomad
parents:
diff changeset
640
Nomad
parents:
diff changeset
641 HMENU debug_eax = CreatePopupMenu();
Nomad
parents:
diff changeset
642 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_eax, L"EAX Environs");
Nomad
parents:
diff changeset
643 {
Nomad
parents:
diff changeset
644 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40074, L"NONE");
Nomad
parents:
diff changeset
645 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40075, L"GENERIC");
Nomad
parents:
diff changeset
646 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40076, L"PADDEDCELL");
Nomad
parents:
diff changeset
647 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40077, L"ROOM");
Nomad
parents:
diff changeset
648 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40078, L"BATHROOM");
Nomad
parents:
diff changeset
649 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40079, L"LIVINGROOM");
Nomad
parents:
diff changeset
650 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40080, L"STONEROOM");
Nomad
parents:
diff changeset
651 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40081, L"AUDITORIUM");
Nomad
parents:
diff changeset
652 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40082, L"CONCERTHALL");
Nomad
parents:
diff changeset
653 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40083, L"CAVE");
Nomad
parents:
diff changeset
654 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40084, L"ARENA");
Nomad
parents:
diff changeset
655 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40085, L"HANGAR");
Nomad
parents:
diff changeset
656 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40086, L"CARPETEDHALLWAY");
Nomad
parents:
diff changeset
657 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40087, L"HALLWAY");
Nomad
parents:
diff changeset
658 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40088, L"STONECORRIDOR");
Nomad
parents:
diff changeset
659 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40089, L"ALLEY");
Nomad
parents:
diff changeset
660 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40090, L"FOREST");
Nomad
parents:
diff changeset
661 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40091, L"CITY");
Nomad
parents:
diff changeset
662 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40092, L"MOUNTAINS");
Nomad
parents:
diff changeset
663 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40093, L"QUARRY");
Nomad
parents:
diff changeset
664 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40094, L"PLAIN");
Nomad
parents:
diff changeset
665 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40095, L"PARKINGLOT");
Nomad
parents:
diff changeset
666 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40096, L"SEWERPIPE");
Nomad
parents:
diff changeset
667 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40097, L"UNDERWATER");
Nomad
parents:
diff changeset
668 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40098, L"DRUGGED");
Nomad
parents:
diff changeset
669 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40099, L"DIZZY");
Nomad
parents:
diff changeset
670 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40100, L"PSICHOTIC");
Nomad
parents:
diff changeset
671 }
Nomad
parents:
diff changeset
672 }
Nomad
parents:
diff changeset
673 }
Nomad
parents:
diff changeset
674 return menu;
Nomad
parents:
diff changeset
675 }
Nomad
parents:
diff changeset
676
Nomad
parents:
diff changeset
677
Nomad
parents:
diff changeset
678
Nomad
parents:
diff changeset
679
Nomad
parents:
diff changeset
680 bool OSWindow::OnOSMenu(int item_id)
Nomad
parents:
diff changeset
681 {
Nomad
parents:
diff changeset
682 switch (item_id)
Nomad
parents:
diff changeset
683 {
Nomad
parents:
diff changeset
684 default: return false;
Nomad
parents:
diff changeset
685
Nomad
parents:
diff changeset
686
Nomad
parents:
diff changeset
687 case 103: pRenderer->SavePCXScreenshot(); break;
Nomad
parents:
diff changeset
688 case 101: // Quit game
Nomad
parents:
diff changeset
689 case 40001:
Nomad
parents:
diff changeset
690 SendMessageW(api_handle, WM_DESTROY, 0, 0);
Nomad
parents:
diff changeset
691 break;
Nomad
parents:
diff changeset
692
Nomad
parents:
diff changeset
693 case 104:
Nomad
parents:
diff changeset
694 pRenderer->ChangeBetweenWinFullscreenModes();
Nomad
parents:
diff changeset
695 if (pArcomageGame->bGameInProgress)
Nomad
parents:
diff changeset
696 pArcomageGame->field_F6 = 1;
Nomad
parents:
diff changeset
697 break;
Nomad
parents:
diff changeset
698
Nomad
parents:
diff changeset
699 //SubMenu "Party"
Nomad
parents:
diff changeset
700 case 40006: pParty->SetFood(pParty->uNumFoodRations + 20); break;
Nomad
parents:
diff changeset
701 case 40007: pParty->SetGold(pParty->uNumGold + 10000); break;
1827
0c75c3e7e436 cleaned up part of party.cpp, renamed byte_AE3368 to playerAlreadyPicked + 3 vars after it, moved them to party.cpp, some player.cpp bugfixes
Grumpy7
parents: 1815
diff changeset
702 case 40008: pParty->GivePartyExp(20000); break;
1804
Nomad
parents:
diff changeset
703 case 40013: pParty->SetGold(0); break;
Nomad
parents:
diff changeset
704
Nomad
parents:
diff changeset
705 case 40059:
Nomad
parents:
diff changeset
706 for (uint i = 0; i < 4; ++i)
Nomad
parents:
diff changeset
707 pParty->pPlayers[i].uSkillPoints = 50;
Nomad
parents:
diff changeset
708 break;
Nomad
parents:
diff changeset
709
Nomad
parents:
diff changeset
710 case 40029: pPlayers[uActiveCharacter]->SetPertified(true); break;
Nomad
parents:
diff changeset
711 case 40030: pPlayers[uActiveCharacter]->SetWeak(true); break;
Nomad
parents:
diff changeset
712 case 40031: pPlayers[uActiveCharacter]->SetPoison3(true); break;
Nomad
parents:
diff changeset
713 case 40032: pPlayers[uActiveCharacter]->SetPoison2(true); break;
Nomad
parents:
diff changeset
714 case 40033: pPlayers[uActiveCharacter]->SetPoison1(true); break;
Nomad
parents:
diff changeset
715 case 40034: pPlayers[uActiveCharacter]->SetDisease3(true); break;
Nomad
parents:
diff changeset
716 case 40035: pPlayers[uActiveCharacter]->SetDisease2(true); break;
Nomad
parents:
diff changeset
717 case 40036: pPlayers[uActiveCharacter]->SetDisease1(true); break;
Nomad
parents:
diff changeset
718 case 40037: pPlayers[uActiveCharacter]->SetCursed(true); break;
Nomad
parents:
diff changeset
719 case 40038: pPlayers[uActiveCharacter]->SetInsane(true); break;
Nomad
parents:
diff changeset
720 case 40039: pPlayers[uActiveCharacter]->SetDrunk(true); break;
Nomad
parents:
diff changeset
721 case 40040: pPlayers[uActiveCharacter]->SetUnconcious(true); break;
Nomad
parents:
diff changeset
722 case 40041: pPlayers[uActiveCharacter]->SetDead(true); break;
Nomad
parents:
diff changeset
723 case 40042: pPlayers[uActiveCharacter]->SetEradicated(true); break;
Nomad
parents:
diff changeset
724 case 40043: pPlayers[uActiveCharacter]->SetAsleep(true); break;
Nomad
parents:
diff changeset
725 case 40044: pPlayers[uActiveCharacter]->SetAfraid(true); break;
Nomad
parents:
diff changeset
726 case 40045: pPlayers[uActiveCharacter]->SetParalyzed(true); break;
Nomad
parents:
diff changeset
727 case 40073: pPlayers[uActiveCharacter]->SetZombie(true); break;
Nomad
parents:
diff changeset
728
Nomad
parents:
diff changeset
729 case 40062:
Nomad
parents:
diff changeset
730 pParty->alignment = PartyAlignment_Good;
Nomad
parents:
diff changeset
731 SetUserInterface(pParty->alignment, true);
Nomad
parents:
diff changeset
732 break;
Nomad
parents:
diff changeset
733 case 40063:
Nomad
parents:
diff changeset
734 pParty->alignment = PartyAlignment_Neutral;
Nomad
parents:
diff changeset
735 SetUserInterface(pParty->alignment, true);
Nomad
parents:
diff changeset
736 break;
Nomad
parents:
diff changeset
737 case 40064:
Nomad
parents:
diff changeset
738 pParty->alignment = PartyAlignment_Evil;
Nomad
parents:
diff changeset
739 SetUserInterface(pParty->alignment, true);
Nomad
parents:
diff changeset
740 break;
Nomad
parents:
diff changeset
741
Nomad
parents:
diff changeset
742
Nomad
parents:
diff changeset
743
Nomad
parents:
diff changeset
744 //SubMenu "Time"
Nomad
parents:
diff changeset
745 case 40009: pParty->uTimePlayed += Timer::Day; break;
Nomad
parents:
diff changeset
746 case 40010: pParty->uTimePlayed += Timer::Week; break;
Nomad
parents:
diff changeset
747 case 40011: pParty->uTimePlayed += Timer::Month; break;
Nomad
parents:
diff changeset
748 case 40012: pParty->uTimePlayed += Timer::Year; break;
Nomad
parents:
diff changeset
749
Nomad
parents:
diff changeset
750 //SubMenu "Items"
Nomad
parents:
diff changeset
751 case 40015: // uItemID_Rep_St == 1
Nomad
parents:
diff changeset
752 case 40016: // uItemID_Rep_St == 2
Nomad
parents:
diff changeset
753 case 40017: // uItemID_Rep_St == 3
Nomad
parents:
diff changeset
754 case 40018: // uItemID_Rep_St == 4
Nomad
parents:
diff changeset
755 case 40019: // uItemID_Rep_St == 5
Nomad
parents:
diff changeset
756 case 40020: // uItemID_Rep_St == 6
Nomad
parents:
diff changeset
757 {
Nomad
parents:
diff changeset
758 int pItemID = rand() % 500;
Nomad
parents:
diff changeset
759 for (uint i = 0; i < 500; ++i)
Nomad
parents:
diff changeset
760 {
Nomad
parents:
diff changeset
761 if (pItemID + i > 499)
Nomad
parents:
diff changeset
762 pItemID = 0;
Nomad
parents:
diff changeset
763 if (pItemsTable->pItems[pItemID + i].uItemID_Rep_St == (item_id - 40015 + 1))
Nomad
parents:
diff changeset
764 {
Nomad
parents:
diff changeset
765 pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i);
Nomad
parents:
diff changeset
766 break;
Nomad
parents:
diff changeset
767 }
Nomad
parents:
diff changeset
768 }
Nomad
parents:
diff changeset
769 }
Nomad
parents:
diff changeset
770 break;
Nomad
parents:
diff changeset
771
Nomad
parents:
diff changeset
772 case 40061:
Nomad
parents:
diff changeset
773 {
Nomad
parents:
diff changeset
774 int pItemID = rand() % 500;
Nomad
parents:
diff changeset
775 for (uint i = 0; i < 500; ++i)
Nomad
parents:
diff changeset
776 {
Nomad
parents:
diff changeset
777 if (pItemID + i > 499)
Nomad
parents:
diff changeset
778 pItemID = 0;
Nomad
parents:
diff changeset
779 if (pItemsTable->pItems[pItemID + i].uItemID_Rep_St > 6)
Nomad
parents:
diff changeset
780 {
Nomad
parents:
diff changeset
781 pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i);
Nomad
parents:
diff changeset
782 break;
Nomad
parents:
diff changeset
783 }
Nomad
parents:
diff changeset
784 }
Nomad
parents:
diff changeset
785 }
Nomad
parents:
diff changeset
786 break;
Nomad
parents:
diff changeset
787 }
Nomad
parents:
diff changeset
788
Nomad
parents:
diff changeset
789 return true;
Nomad
parents:
diff changeset
790 }