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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343 | #include "gfCMainMenuGui.h"
#include <fsCore/fsIHardware.h>
#include <fsCore/src/fsCAppSettings.h>
#include <fsAppCore/src/components/gui/elements/fsCButtonComponent.h>
#include <fsAppCore/src/fsCAppCoreMain.h>
#include <fsRenderer/src/components/fsCTextSpriteComponent.h>
#include <fsAppCore/src/components/gui/fsCConfirmBoxGui.h>
#include <fsAppCore/src/fsCGuiMessageDispatcher.h>
#include <fsAppCore/src/fsCLocalisedStrings.h>
#include <fsAppCore/src/fsCScreenFade.h>
#include <fsAppCore/src/fsCProfileManager.h>
#include <fsAudio/fsIAudioManager.h>
#if defined fsInAppPurchase
#include <fsAppCore/src/fsCProfileManager.h>
#endif
#if defined fsFacebook
#include <fsPlatform/social/fsIFacebook.h>
#endif
#if defined fsReview
#include "gfCNagManager.h"
#endif
#include "fsIDisplay.h"
#include "gfCChoosePlayerGui.h"
#include "../../src/gfCHogCoreMain.h"
#include "../../src/gfCHogUserSavedData.h"
#include "../../src/gfCInGameAdsManager.h"
const fsCUniqueId fsCMainMenuGui::mTypeId("fsCMainMenuGui");
void fsCMainMenuGui::initialiseDo()
{
if (auto errorBox = fsCAppCoreMain::instanceGet()->appOverlayEntityNamed("ConfirmBoxGui"))
{ // recreate so we are in front and registered first to get user input
auto confirmBoxGuiComponent = errorBox->componentGet<fsCConfirmBoxGui>();
auto message = confirmBoxGuiComponent->messageTextGet();
errorBox->destroy();
fsCConfirmBoxGui::okBoxCreate(parentGet(), message);
}
}
void fsCMainMenuGui::updateDo(fsS32 pDeltaMs)
{
#if !defined fsRELEASE
static fsBool startupCheckDone = false;
static fsBool skipping = false;
if ( !startupCheckDone )
{
if ( "newGame" == fsCAppCoreMain::instanceGet()->settingsGet()->debugSettingsGet()->strGetWithDefault( "startupType", "normal" ) )
{
newGameButtonHandle();
skipping = true;
}
else if ( "continueGame" == fsCAppCoreMain::instanceGet()->settingsGet()->debugSettingsGet()->strGetWithDefault( "startupType", "normal" ) )
{
continueButtonHandle();
skipping = true;
}
startupCheckDone = true;
}
else if ( startupCheckDone && !skipping )<--- Condition 'startupCheckDone' is always true
#endif
newPlayerGuiLaunch();
}
void fsCMainMenuGui::initialiseFromVariableTableDo(const fsCVariableTable& pVars)
{
const auto chapter = fsCProfileManager::instanceGet()->userSavedDataGet()->strGet(gfCHogUserSavedData::mGameChapter);
fsCProfileManager::instanceGet()->userSavedDataGet()->strSet(gfCHogUserSavedData::mGameChapter, chapter);
fsCLocalisedStrings::create();
fsIGuiComponent::initialiseFromVariableTableDo(pVars);
configure();
fsIAudioManager::instanceGet()->musicPlay(fsCResourceName(
fsCAppCoreMain::instanceGet()->settingsGet()->strGetWithDefault(
"mainmenumusic", "audio/music/mainmenumusic.mp3"), fsCResourceName::eRES_LOCATION_ASSETS));
}
void fsCMainMenuGui::listenersDeregisterDo()
{
fsIMessageListenerGuiComponent::listenersDeregisterDo();
fsCGuiMessageDispatcher::instanceGet()->listenerDeregister(gfCChoosePlayerGui::mProfileChangedMsg, this);
fsCGuiMessageDispatcher::instanceGet()->listenerDeregister(fsCProfileManager::mPayWallBreachedMsg, this);
fsCGuiMessageDispatcher::instanceGet()->listenerDeregister(fsCScreenFade::mFadeOutCompleteMsg, this);
fsCGuiMessageDispatcher::instanceGet()->listenerDeregister(fsCConfirmBoxGui::mEventConfirmYesMsg, this);
}
void fsCMainMenuGui::listenersRegisterDo()
{
fsIMessageListenerGuiComponent::listenersRegisterDo();
fsCGuiMessageDispatcher::instanceGet()->listenerRegister(gfCChoosePlayerGui::mProfileChangedMsg, this);
fsCGuiMessageDispatcher::instanceGet()->listenerRegister(fsCProfileManager::mPayWallBreachedMsg, this);
fsCGuiMessageDispatcher::instanceGet()->listenerRegister(fsCScreenFade::mFadeOutCompleteMsg, this);
fsCGuiMessageDispatcher::instanceGet()->listenerRegister(fsCConfirmBoxGui::mEventConfirmYesMsg, this);
}
fsStr fsCMainMenuGui::quitGameWarningMessageGet() const
{
return fsCLocalisedStrings::localisedStringGet("quitwarning");
}
fsBool fsCMainMenuGui::messageProcessDo(const fsCUniqueId& pMessageType,
const fsIMessageDispatcher::sMessageParameters& pParam)
{
if (gfCChoosePlayerGui::mProfileChangedMsg == pMessageType)
{
configure();
}
else if (fsCProfileManager::mPayWallBreachedMsg == pMessageType)
{
configure();
return true;
}
else if (fsCScreenFade::mFadeOutCompleteMsg == pMessageType)
{
if (chapterActiveGet())
{
grandparentGet()->destroy();
}
else
{
parentGet()->destroy();
}
}
else if (fsCConfirmBoxGui::mEventConfirmYesMsg == pMessageType)
{
const fsIMessageDispatcher::sStrMessageParam& param = static_cast<const fsIMessageDispatcher::sStrMessageParam&>(pParam);
if (fsStr::npos != param.mStr.find(quitGameWarningMessageGet()))
{
if (chapterActiveGet())
{
chapterMainMenuClose();
}
else
{
fsCAppCoreMain::instanceGet()->quitTheAppSet(true);
}
}
return true;
}
return false;
}
fsBool fsCMainMenuGui::onButtonClicked(fsCButtonComponent* pButtonComp)
{
const fsStr& btnName = pButtonComp->parentGet()->nameGet();
if ("MainMenuQuitButton" == btnName)
{
if (chapterActiveGet())
{
chapterMainMenuClose();
return true;
}
fsCConfirmBoxGui::confirmBoxCreate(parentGet(), quitGameWarningMessageGet());
return true;
}
if ("MainMenuNewGameButton" == btnName)
{
newGameButtonHandle();
return true;
}
if ("MainMenuContinueButton" == btnName)
{
continueButtonHandle();
return true;
}
if ("MainMenuPlayButton" == btnName)
{
fsIGuiComponent::guiCreateFromFile(fsCResourceName("gui/choosePlayer/choosePlayer.txt", fsCResourceName::eRES_LOCATION_ASSETS), parentGet(), true);
return true;
}
#if defined fsReview
else if ( "MainMenuRateMeButton" == btnName )
{
static_cast<gfCHogCoreMain*>(fsCAppCoreMain::instanceGet())->nagManagerGet()->rateMe();
return true;
}
#endif
if ("MainMenuMoreGamesButton" == btnName)
{
if (fsIHardware::eMOBILE == fsCAppCoreMain::instanceGet()->hardwareGet()->platformGet())
{
fsCAppCoreMain::instanceGet()->hardwareGet()->browserLaunch(
fsCAppCoreMain::instanceGet()->settingsGet()->strGet("moreGamesUrl"));
}
else
{
fsCEntity* const moreGamesEnt = guiCreateFromFile(fsCResourceName(
"gui/moreGames/moreGames.txt",
fsCResourceName::eRES_LOCATION_ASSETS), parentGet(),
true);
moreGameScrenLinksEnable(moreGamesEnt);
}
return true;
}
return false;
}
void fsCMainMenuGui::moreGameScrenLinksEnable(fsCEntity* const pEnt)
{
if (!fsCAppCoreMain::instanceGet()->settingsGet()->boolGetWithDefault("moreGamesWebLinks", true))
{
auto ents = pEnt->childEntitiesWithComponentsOfFamilyType<fsCButtonComponent>();
for (fsCEntity* ent : ents)
{
if (fsStr::npos != ent->parentGet()->nameGet().find("MoreGamesProduct") ||
(ent->parentGet()->parentGet() && fsStr::npos != ent->parentGet()->parentGet()->nameGet().find(
"MoreGamesProduct")))
{
ent->visibleSet(false);
}
}
}
}
void fsCMainMenuGui::newGameButtonHandle()
{
gfCHogCoreMain::instanceGet()->newGameStart();
fsCAppCoreMain::instanceGet()->fadeOut();
}
void fsCMainMenuGui::continueButtonHandle()
{
#if defined fsFacebook
// fsIFacebook::instanceGet()->updatePost("Continued another game", "https://scontent-lhr3-1.xx.fbcdn.net/hphotos-xtf1/v/t1.0-9/12928169_1070133759717300_5243388509296571124_n.jpg?oh=3ee2250cb92c71eb2b6230c497fd265f&oe=57B99E67");
// fsIFacebook::instanceGet()->updatePost("Continued another game", "http://www.casual-arts.com/images/character.png");
// fsIFacebook::instanceGet()->updatePost("Continued another game", "gui/achievements/ecoCub.png");
#endif
#if defined fsInAppPurchaseProcess
const fsBool rewardGateActive =
#if defined fsInGameAds
gfCInGameAdsManager::instanceGet().rewardUnlockAvailable();
#else
false;<--- Assignment 'rewardGateActive=false', assigned value is 0
#endif
if (!rewardGateActive && fsCProfileManager::instanceGet()->progressBlockedByPaywallGet())<--- Condition '!rewardGateActive' is always true
{
fsIGuiComponent::guiCreateFromFile( fsCResourceName( "gui/buyNowGui/buyNowGui.txt", fsCResourceName::eRES_LOCATION_ASSETS ), parentGet() );
}
else
#endif
{
gfCHogCoreMain::instanceGet()->gameContinue();
}
}
void fsCMainMenuGui::newPlayerGuiLaunch() const
{
const fsBool noPlayerLoaded = (fsCGlobalSavedData::mNoProfileLoaded ==
fsCProfileManager::instanceGet()->savedDataGet()->currentProfileIndexGet());
const fsBool guiWindowNotOpen = (parentGet()->childFind("NewPlayerWindow") == nullptr);
if (noPlayerLoaded && guiWindowNotOpen)
{
guiCreateFromFile(fsCResourceName("gui/newPlayer/newPlayer.txt", fsCResourceName::eRES_LOCATION_ASSETS),
parentGet());
}
}
fsBool fsCMainMenuGui::profileExists()
{
return fsCGlobalSavedData::mNoProfileLoaded != fsCProfileManager::instanceGet()->savedDataGet()->
currentProfileIndexGet();
}
fsBool fsCMainMenuGui::chapterActiveGet()
{
return !fsCProfileManager::instanceGet()->chapterGet().emptyGet();
}
void fsCMainMenuGui::chapterMainMenuClose()
{
fsCProfileManager::instanceGet()->chapterSet("");
gfCHogCoreMain::instanceGet()->chapterClear();
fsCLocalisedStrings::create();
parentGet()->destroy();
}
void fsCMainMenuGui::configure() const
{
fsCGlobalSavedData* globalData = fsCProfileManager::instanceGet()->savedDataGet();
const fsBool gameStarted = (fsCProfileManager::instanceGet()->userSavedDataGet()->gameHasBeenStartedGet())
|| 0 == gfCHogCoreMain::instanceGet()->levelCountGet();
welcomeMessageConfigure(profileExists());
buttonVisibilityConfigure("MainMenuContinueButton", (gameStarted));
buttonVisibilityConfigure("MainMenuNewGameButton", (profileExists() && !gameStarted));
#if defined fsInAppPurchaseProcess
buttonVisibilityConfigure( "MainMenuBuyNowButton", !fsCProfileManager::instanceGet()->fullGamePurchasedGet() );
buttonVisibilityConfigure("MainMenuQuitButton", chapterActiveGet());
#else
buttonVisibilityConfigure("MainMenuBuyNowButton", false);
#endif
mPlayerProfile = globalData->currentProfileIndexGet();
}
void fsCMainMenuGui::welcomeMessageConfigure(fsBool pPlayerLoaded) const
{
fsCGlobalSavedData* globalData = fsCProfileManager::instanceGet()->savedDataGet();
if (fsCEntity* childEnt = parentGet()->childFind("MainMenuWelcomeMessage"))
{
childEnt->visibleSet(pPlayerLoaded);
if (pPlayerLoaded)
{
fsStr welcomMsg = fsCLocalisedStrings::localisedStringGet("welcomemsg");
welcomMsg.replaceAll("$NAME", globalData->profileNameGet(globalData->currentProfileIndexGet()));
childEnt->textComponentGet()->textSet(welcomMsg);
}
}
}
void fsCMainMenuGui::buttonVisibilityConfigure(const fsStr& pButtonName, fsBool pVisible) const
{
if (fsCEntity* childEnt = parentGet()->childFind(pButtonName))
{
childEnt->visibleSet(pVisible);
}
}
fsIComponent* fsCMainMenuGui::create(fsCEntity* pParent)
{
return new fsCMainMenuGui(pParent);
}
fsCMainMenuGui::fsCMainMenuGui(fsCEntity* const pParent) :
fsIMessageListenerGuiComponent(pParent),
mPlayerProfile(fsCProfileManager::instanceGet()->savedDataGet()->currentProfileIndexGet())
{
}
fsCMainMenuGui::~fsCMainMenuGui()
{
}
|