comparison Game/Game.cpp @ 2549:3121fb54a110

Rest & Spelbook refactored into class
author a.parshin
date Tue, 12 May 2015 11:07:32 +0200
parents 87e5590d034b
children f2a8ed07e921
comparison
equal deleted inserted replaced
2548:87e5590d034b 2549:3121fb54a110
39 #include "GUI/UI/UIGame.h" 39 #include "GUI/UI/UIGame.h"
40 #include "GUI/UI/UICharacter.h" 40 #include "GUI/UI/UICharacter.h"
41 #include "GUI/UI/UIQuickReference.h" 41 #include "GUI/UI/UIQuickReference.h"
42 #include "GUI/UI/UISaveLoad.h" 42 #include "GUI/UI/UISaveLoad.h"
43 #include "GUI/UI/UIModal.h" 43 #include "GUI/UI/UIModal.h"
44 #include "GUI/UI/UIRest.h"
45 #include "GUI/UI/Spellbook.h"
44 #include "GUI/UI/UIBooks.h" 46 #include "GUI/UI/UIBooks.h"
45 #include "GUI/UI/Books/LloydsBook.h" 47 #include "GUI/UI/Books/LloydsBook.h"
46 #include "GUI/UI/Books/TownPortalBook.h" 48 #include "GUI/UI/Books/TownPortalBook.h"
47 #include "GUI/UI/Books/QuestBook.h" 49 #include "GUI/UI/Books/QuestBook.h"
48 #include "GUI/UI/Books/AutonotesBook.h" 50 #include "GUI/UI/Books/AutonotesBook.h"
2147 _506F18_num_minutes_to_sleep = 60; 2149 _506F18_num_minutes_to_sleep = 60;
2148 continue; 2150 continue;
2149 case UIMSG_RentRoom: 2151 case UIMSG_RentRoom:
2150 _506F14_resting_stage = 2; 2152 _506F14_resting_stage = 2;
2151 2153
2152 PrepareToLoadRestUI(); 2154 pGUIWindow_CurrentMenu = new GUIWindow_Rest();
2153 current_screen_type = SCREEN_REST;
2154 pGUIWindow_CurrentMenu = RestUI_Load();
2155 2155
2156 v86 = 60 * (_494820_training_time(pParty->uCurrentHour) + 1) - pParty->uCurrentMinute; 2156 v86 = 60 * (_494820_training_time(pParty->uCurrentHour) + 1) - pParty->uCurrentMinute;
2157 _506F18_num_minutes_to_sleep = v86; 2157 _506F18_num_minutes_to_sleep = v86;
2158 if (uMessageParam == 111 || uMessageParam == 114 || uMessageParam == 116) // 107 = Emerald Isle tavern 2158 if (uMessageParam == 111 || uMessageParam == 114 || uMessageParam == 116) // 107 = Emerald Isle tavern
2159 _506F18_num_minutes_to_sleep = v86 + 12 * 60; 2159 _506F18_num_minutes_to_sleep = v86 + 12 * 60;
2190 ShowStatusBarString(pGlobalTXT_LocalizationStrings[478], 2);// "You can't rest in turn-based mode!" 2190 ShowStatusBarString(pGlobalTXT_LocalizationStrings[478], 2);// "You can't rest in turn-based mode!"
2191 continue; 2191 continue;
2192 } 2192 }
2193 if (!(pParty->uFlags & 0x88)) 2193 if (!(pParty->uFlags & 0x88))
2194 { 2194 {
2195 PrepareToLoadRestUI(); 2195 pGUIWindow_CurrentMenu = new GUIWindow_Rest();
2196 current_screen_type = SCREEN_REST;
2197 pGUIWindow_CurrentMenu = RestUI_Load();
2198 continue; 2196 continue;
2199 } 2197 }
2200 if (pParty->bTurnBasedModeOn == 1) 2198 if (pParty->bTurnBasedModeOn == 1)
2201 { 2199 {
2202 ShowStatusBarString(pGlobalTXT_LocalizationStrings[478], 2);// "You can't rest in turn-based mode!" 2200 ShowStatusBarString(pGlobalTXT_LocalizationStrings[478], 2);// "You can't rest in turn-based mode!"
2366 { 2364 {
2367 ++uAction; 2365 ++uAction;
2368 if (uAction >= skill_count) 2366 if (uAction >= skill_count)
2369 uAction = 0; 2367 uAction = 0;
2370 } 2368 }
2371 OnCloseSpellBookPage(); 2369 ((GUIWindow_Spellbook *)pGUIWindow_CurrentMenu)->OpenSpellbookPage(v217[uAction]);
2372 pPlayers[uActiveCharacter]->lastOpenedSpellbookPage = LOBYTE(v217[uAction]);
2373 pGUIWindow_CurrentMenu->OpenSpellBook();
2374 pAudioPlayer->PlaySound((SoundID)(rand() % 2 + SOUND_TurnPageU), 0, 0, -1, 0, 0, 0, 0);
2375 } 2370 }
2376 continue; 2371 continue;
2377 } 2372 }
2378 case UIMSG_OpenSpellbookPage: 2373 case UIMSG_OpenSpellbookPage:
2379 if (pTurnEngine->turn_stage == TE_MOVEMENT || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->lastOpenedSpellbookPage) 2374 if (pTurnEngine->turn_stage == TE_MOVEMENT || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->lastOpenedSpellbookPage)
2380 continue; 2375 continue;
2381 OnCloseSpellBookPage(); 2376 ((GUIWindow_Spellbook *)pGUIWindow_CurrentMenu)->OpenSpellbookPage(uMessageParam);
2382 pPlayers[uActiveCharacter]->lastOpenedSpellbookPage = uMessageParam;
2383 pGUIWindow_CurrentMenu->OpenSpellBook();
2384 pAudioPlayer->PlaySound((SoundID)(rand() % 2 + SOUND_TurnPageU), 0, 0, -1, 0, 0, 0, 0);
2385 continue; 2377 continue;
2386 case UIMSG_SelectSpell: 2378 case UIMSG_SelectSpell:
2387 { 2379 {
2388 if (pTurnEngine->turn_stage == TE_MOVEMENT) 2380 if (pTurnEngine->turn_stage == TE_MOVEMENT)
2389 continue; 2381 continue;
2446 if (uActiveCharacter && !pPlayers[uActiveCharacter]->uTimeToRecovery) 2438 if (uActiveCharacter && !pPlayers[uActiveCharacter]->uTimeToRecovery)
2447 { 2439 {
2448 if (current_screen_type == SCREEN_GAME) 2440 if (current_screen_type == SCREEN_GAME)
2449 { 2441 {
2450 new OnButtonClick2(476, 450, 0, 0, (int)pBtn_CastSpell, 0); 2442 new OnButtonClick2(476, 450, 0, 0, (int)pBtn_CastSpell, 0);
2451 current_screen_type = SCREEN_SPELL_BOOK; 2443 pGUIWindow_CurrentMenu = new GUIWindow_Spellbook();
2452 pEventTimer->Pause();
2453 pGUIWindow_CurrentMenu = new GUIWindow_Spellbook(0, 0, window->GetWidth(), window->GetHeight(), 0, 0);
2454 pAudioPlayer->PlaySound(SOUND_48, 0, 0, -1, 0, 0, 0, 0);
2455 viewparams->field_48 = 1;
2456 continue; 2444 continue;
2457 } 2445 }
2458 if (current_screen_type != SCREEN_REST && current_screen_type != SCREEN_CHARACTERS 2446 if (current_screen_type != SCREEN_REST && current_screen_type != SCREEN_CHARACTERS
2459 && (current_screen_type <= SCREEN_63 || current_screen_type > SCREEN_67)) 2447 && (current_screen_type <= SCREEN_63 || current_screen_type > SCREEN_67))
2460 { 2448 {
2461 pGUIWindow_CurrentMenu->Release(); 2449 pGUIWindow_CurrentMenu->Release();
2462 new OnButtonClick2(476, 450, 0, 0, (int)pBtn_CastSpell, 0); 2450 new OnButtonClick2(476, 450, 0, 0, (int)pBtn_CastSpell, 0);
2463 current_screen_type = SCREEN_SPELL_BOOK; 2451 pGUIWindow_CurrentMenu = new GUIWindow_Spellbook();
2464 pEventTimer->Pause();
2465 pGUIWindow_CurrentMenu = new GUIWindow_Spellbook(0, 0, window->GetWidth(), window->GetHeight(), 0, 0);
2466 pAudioPlayer->PlaySound(SOUND_48, 0, 0, -1, 0, 0, 0, 0);
2467 viewparams->field_48 = 1;
2468 continue; 2452 continue;
2469 } 2453 }
2470 } 2454 }
2471 } 2455 }
2472 continue; 2456 continue;