comparison Game/CreateParty.cpp @ 2553:48708da03b7f

Party Creation UI logic separated from MainMenu
author a.parshin
date Wed, 13 May 2015 02:20:05 +0200
parents
children 117c219bf913
comparison
equal deleted inserted replaced
2552:ac16f4a3a91e 2553:48708da03b7f
1 #include "Engine/Engine.h"
2 #include "Engine/Party.h"
3 #include "Engine/Graphics/Viewport.h"
4 #include "Engine/Graphics/Overlays.h"
5
6 #include "IO/Keyboard.h"
7
8 #include "GUI/UI/UIPartyCreation.h"
9
10 #include "Media/Audio/AudioPlayer.h"
11 #include "Media/Audio/AIL.h"
12
13 void CreateParty_EventLoop()
14 {
15 auto pPlayer = pParty->pPlayers.data();
16 while (pMessageQueue_50CBD0->uNumMessages)
17 {
18 UIMessageType msg;
19 int param, param2;
20 pMessageQueue_50CBD0->PopMessage(&msg, &param, &param2);
21
22 switch (msg)
23 {
24 case UIMSG_PlayerCreation_SelectAttribute:
25 {
26 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
27 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * param;
28 uPlayerCreationUI_SelectedCharacter = param;
29 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0);
30 }
31 break;
32
33 case UIMSG_PlayerCreation_VoicePrev:
34 {
35 int sex = pParty->pPlayers[param].GetSexByVoice();
36 do
37 {
38 if (pParty->pPlayers[param].uVoiceID == 0)
39 pParty->pPlayers[param].uVoiceID = 19;
40 else --pParty->pPlayers[param].uVoiceID;
41 } while (pParty->pPlayers[param].GetSexByVoice() != sex);
42 auto pButton = pCreationUI_BtnPressLeft2[param];
43
44 new OnButtonClick(pButton->uX, pButton->uY, 0, 0, (int)pButton, (char *)1);
45 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0);
46 pParty->pPlayers[param].PlaySound(SPEECH_PickMe, 0);
47 }
48 break;
49
50 case UIMSG_PlayerCreation_VoiceNext:
51 {
52 int sex = pParty->pPlayers[param].GetSexByVoice();
53 do
54 {
55 pParty->pPlayers[param].uVoiceID = (pParty->pPlayers[param].uVoiceID + 1) % 20;
56 } while (pParty->pPlayers[param].GetSexByVoice() != sex);
57 auto pButton = pCreationUI_BtnPressRight2[param];
58 new OnButtonClick(pButton->uX, pButton->uY, 0, 0, (int)pButton, (char *)1);
59 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0);
60 pParty->pPlayers[param].PlaySound(SPEECH_PickMe, 0);
61 }
62 break;
63 case UIMSG_PlayerCreation_FacePrev:
64 //pPlayer = &pParty->pPlayers[pParam];
65 if (!pParty->pPlayers[param].uCurrentFace)
66 pParty->pPlayers[param].uCurrentFace = 19;
67 else
68 pParty->pPlayers[param].uCurrentFace -= 1;
69 pParty->pPlayers[param].uVoiceID = pParty->pPlayers[param].uCurrentFace;
70 pParty->pPlayers[param].SetInitialStats();
71 pParty->pPlayers[param].SetSexByVoice();
72 pParty->pPlayers[param].RandomizeName();
73 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
74 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * param;
75 uPlayerCreationUI_SelectedCharacter = param;
76 new OnButtonClick(pCreationUI_BtnPressLeft[param]->uX, pCreationUI_BtnPressLeft[param]->uY, 0, 0, (int)pCreationUI_BtnPressLeft[param], (char *)1);
77 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0.0, 0);
78 pParty->pPlayers[param].PlaySound(SPEECH_PickMe, 0);
79 break;
80 case UIMSG_PlayerCreation_FaceNext:
81 //pPlayer = &pParty->pPlayers[pParam];
82 int v20; v20 = (char)((int)pParty->pPlayers[param].uCurrentFace + 1) % 20;
83 pParty->pPlayers[param].uCurrentFace = v20;
84 pParty->pPlayers[param].uVoiceID = v20;
85 pParty->pPlayers[param].SetInitialStats();
86 pParty->pPlayers[param].SetSexByVoice();
87 pParty->pPlayers[param].RandomizeName();
88 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
89 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * param;
90 uPlayerCreationUI_SelectedCharacter = param;
91 new OnButtonClick(pCreationUI_BtnPressRight[param]->uX, pCreationUI_BtnPressRight[param]->uY, 0, 0, (int)pCreationUI_BtnPressRight[param], (char *)1);
92 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0);
93 pParty->pPlayers[param].PlaySound(SPEECH_PickMe, 0);
94 break;
95 case UIMSG_PlayerCreationClickPlus:
96 new OnButtonClick2(613, 393, 0, 0, (int)pPlayerCreationUI_BtnPlus, (char *)1);
97 pPlayer[uPlayerCreationUI_SelectedCharacter].IncreaseAttribute((pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7);
98 pAudioPlayer->PlaySound(SOUND_ClickMinus, 0, 0, -1, 0, 0, 0, 0);
99 break;
100 case UIMSG_PlayerCreationClickMinus:
101 new OnButtonClick2(523, 393, 0, 0, (int)pPlayerCreationUI_BtnMinus, (char *)1);
102 pPlayer[uPlayerCreationUI_SelectedCharacter].DecreaseAttribute((pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7);
103 pAudioPlayer->PlaySound(SOUND_ClickPlus, 0, 0, -1, 0, 0, 0, 0);
104 break;
105 case UIMSG_PlayerCreationSelectActiveSkill:
106 if (pPlayer[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(3) == 37)
107 pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].pActiveSkills[pPlayer[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(param + 4)] = 1;
108 pAudioPlayer->PlaySound(SOUND_ClickSkill, 0, 0, -1, 0, 0, 0, 0);
109 break;
110 case UIMSG_PlayerCreationSelectClass:
111 pPlayer[uPlayerCreationUI_SelectedCharacter].Reset((PLAYER_CLASS_TYPE)param);
112 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0);
113 break;
114 case UIMSG_PlayerCreationClickOK:
115 new OnButtonClick2(580, 431, 0, 0, (int)pPlayerCreationUI_BtnOK, 0);
116 if (PlayerCreation_GetUnspentAttributePointCount() || !PlayerCreation_Choose4Skills())
117 GameUI_Footer_TimeLeft = GetTickCount() + 4000;
118 else
119 uGameState = GAME_STATE_STARTING_NEW_GAME;
120 break;
121 case UIMSG_PlayerCreationClickReset:
122 new OnButtonClick2(527, 431, 0, 0, (int)pPlayerCreationUI_BtnReset, 0);
123 pParty->Reset();
124 break;
125 case UIMSG_PlayerCreationRemoveUpSkill:
126 {
127 int v4; v4 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem;
128 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = v4 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * param;
129 if (pPlayer[param].GetSkillIdxByOrder(2) != 37)//37 - None(Νες)
130 pParty->pPlayers[param].pActiveSkills[pPlayer[param].GetSkillIdxByOrder(2)] = 0;
131 }
132 break;
133 case UIMSG_PlayerCreationRemoveDownSkill:
134 {
135 int v4; v4 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem;
136 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = v4 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * param;
137 if (pPlayer[param].GetSkillIdxByOrder(3) != 37)//37 - None(Νες)
138 pParty->pPlayers[param].pActiveSkills[pPlayer[param].GetSkillIdxByOrder(3)] = 0;
139 }
140 break;
141 case UIMSG_PlayerCreationChangeName:
142 pAudioPlayer->PlaySound(SOUND_ClickSkill, 0, 0, -1, 0, 0, 0, 0);
143 uPlayerCreationUI_SelectedCharacter = param;
144 pKeyActionMap->EnterText(0, 15, pGUIWindow_CurrentMenu);
145 pGUIWindow_CurrentMenu->ptr_1C = (void *)param;
146 break;
147 case UIMSG_Escape:
148 if (pModalWindow)
149 {
150 pModalWindow->Release();
151 pModalWindow = nullptr;
152 break;
153 }
154 if (!(dword_6BE364_game_settings_1 & GAME_SETTINGS_4000))
155 break;
156 viewparams->bRedrawGameUI = true;
157 viewparams->field_48 = 1;
158 if (GetCurrentMenuID() == MENU_MAIN || GetCurrentMenuID() == MENU_MMT_MAIN_MENU
159 || GetCurrentMenuID() == MENU_CREATEPARTY || GetCurrentMenuID() == MENU_NAMEPANELESC)
160 {
161 //if ( current_screen_type == SCREEN_VIDEO )
162 //pVideoPlayer->FastForwardToFrame(pVideoPlayer->pResetflag);
163 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ChangeGameState, 0, 0);
164 }
165 break;
166 case UIMSG_ChangeGameState:
167 uGameState = GAME_FINISHED;
168 break;
169 }
170 }
171 }
172
173 bool CreateParty_Loop()
174 {
175 // -------------------------------------------------------
176 // 00462C94 bool MM_Main(const wchar_t *pCmdLine) --- part
177 extern bool use_music_folder;
178 if (use_music_folder)
179 alSourceStop(mSourceID);
180 else
181 {
182 if (pAudioPlayer->hAILRedbook)
183 AIL_redbook_stop(pAudioPlayer->hAILRedbook);
184 }
185 pParty->Reset();
186 pOtherOverlayList->Reset();
187 strcpy(pCurrentMapName, pStartingMapName);
188 pParty->CreateDefaultParty(0);
189
190 pGUIWindow_CurrentMenu = new GUIWindow_PartyCreation();//PlayerCreationUI_Initialize();
191 if (PlayerCreationUI_Loop())
192 {
193 DeleteCCharFont();
194 return false;
195 }
196 else
197 {
198 DeleteCCharFont();
199 return true;
200 }
201 }