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 | #include "gfCMapPopUpGui.h"
#include <fsCore/fsIResourceNamePathAdjuster.h>
#include <fsAppCore/src/fsCLocalisedStrings.h>
#include <fsAppCore/src/fsCProfileManager.h>
#include <fsAppCore/src/components/gui/elements/fsCTextEntryComponent.h>
#include <fsAppCore/src/components/gui/elements/fsCButtonComponent.h>
#include "../../src/gfCHogUserSavedData.h"
#include "../../src/gfCHogCoreMain.h"
#include "../gfCBonusEntityCountComponent.h"
#include "fsAppCore/src/fsCSerialisableToStr.h"
const fsCUniqueId fsCMapPopUpGui::mTypeId("fsCMapPopUpGui");
void fsCMapPopUpGui::nextMapLocationClear(const fsStr& pTargetLevel)
{
fsStr newLev = fsCProfileManager::instanceGet()->userSavedDataGet()->strGet(gfCHogUserSavedData::mMapLocation);
#if defined fsDownCaseFilename
newLev.downcase();
#endif
if (newLev == pTargetLevel)
{
fsCProfileManager::instanceGet()->userSavedDataGet()->strSet(gfCHogUserSavedData::mMapLocation, "");
}
}
void fsCMapPopUpGui::nextLevelStart(const fsStr& pNextLevel)
{
fsCAppCoreMain::instanceGet()->fadeOut();
gfCHogCoreMain::instanceGet()->nextLocationSet(pNextLevel);
nextMapLocationClear(pNextLevel);
}
fsStr fsCMapPopUpGui::levelCompletionRankGet(const fsStr& pLevel)
{
fsS32 totTrash = 0;
fsS32 bestTrash = 0;
fsS32 totLost = 0;
fsS32 bestLost = 0;
trashTotalGet(pLevel, bestTrash, totTrash, bestLost, totLost);
if ((bestTrash == totTrash) && (bestLost == totLost))
{
return "gold";
}
if ((bestTrash == totTrash) || (bestLost == totLost))
{
return "silver";
}
return "bronze";
}
void fsCMapPopUpGui::bonusBonusTotalGet(const fsStr& pLevel, fsS32& pBonusBonusTotal)
{
fsStr saveStr = fsCProfileManager::instanceGet()->userSavedDataGet()->strGet(
gfCHogUserSavedData::mLevelDataPrefix + pLevel);
if (!saveStr.emptyGet())
{
saveStr.erase(0, saveStr.find(fsStr(gfCBonusEntityCountComponent::mTypeId.idGet())));
fsCSerialisableToStr::strStipFromSaveStr(saveStr);
fsS32 _ = fsCSerialisableToStr::s32StipFromSaveStr(saveStr);<--- _ is initialized
_ = fsCSerialisableToStr::s32StipFromSaveStr(saveStr);<--- _ is overwritten<--- _ is assigned
_ = fsCSerialisableToStr::s32StipFromSaveStr(saveStr);<--- _ is overwritten<--- _ is assigned
_ = fsCSerialisableToStr::s32StipFromSaveStr(saveStr);<--- _ is overwritten
pBonusBonusTotal = fsCSerialisableToStr::s32StipFromSaveStr(saveStr);
}
}
void fsCMapPopUpGui::trashTotalGet(const fsStr& pLevel, fsS32& pTrashCount, fsS32& pTrashTotal, fsS32& pLostFoundCount,
fsS32& pLostFoundTotal)
{
fsStr saveStr = fsCProfileManager::instanceGet()->userSavedDataGet()->strGet(
gfCHogUserSavedData::mLevelDataPrefix + pLevel);
if (!saveStr.emptyGet())
{
saveStr.erase(0, saveStr.find(fsStr(gfCBonusEntityCountComponent::mTypeId.idGet())));
fsCSerialisableToStr::strStipFromSaveStr(saveStr);
pTrashCount = fsCSerialisableToStr::s32StipFromSaveStr(saveStr);
pTrashTotal = fsCSerialisableToStr::s32StipFromSaveStr(saveStr);
pLostFoundCount = fsCSerialisableToStr::s32StipFromSaveStr(saveStr);
pLostFoundTotal = fsCSerialisableToStr::s32StipFromSaveStr(saveStr);
}
}
fsBool fsCMapPopUpGui::onButtonClicked(fsCButtonComponent* pButtonComp)
{
const fsStr& btnName = pButtonComp->parentGet()->nameGet();
if ("ScenePopupGoButton" == btnName)
{
nextLevelStart(mTarget);
return true;
}
return false;
}
void fsCMapPopUpGui::starInit(const fsStr& pName, fsBool pVisible)
{
if (fsCEntity* const starEnt = parentGet()->childFind(pName))
{
starEnt->visibleSet(pVisible);
}
}
void fsCMapPopUpGui::completionStarsInit()
{
const fsStr levelRank = levelCompletionRankGet(mTarget);
starInit("ratingStarBronze", true);
if (levelRank == "bronze")
{
starInit("ratingStarSilver", false);
starInit("ratingStarGold", false);
}
else if (levelRank == "silver")
{
starInit("ratingStarSilver", true);
starInit("ratingStarGold", false);
}
else if (levelRank == "gold")
{
starInit("ratingStarSilver", true);
starInit("ratingStarGold", true);
}
else
{
starInit("ratingStarBronze", false);
starInit("ratingStarSilver", false);
starInit("ratingStarGold", false);
}
}
void fsCMapPopUpGui::init(const fsStr& pLevel)
{
mTarget = pLevel;
auto lev = pLevel;
lev.erase(0,lev.rfind(fsIResourceNamePathAdjuster::mPathSeparator) + 1);
lev.erase(lev.rfind("."));
parentGet()->childFind("ScenePopupDestintationText")->textComponentGet()->textSet(
fsCLocalisedStrings::localisedStringGet(lev));
parentGet()->childFind("ScenePopupRoundScore")->textComponentGet()->textSet("");
trashTotalGet(mTarget, mTrashCount, mTrashTotal, mLostFoundCount, mLostFoundTotal);
stringSet("ScenePopupTrashText", "trashInfo", mTrashCount, mTrashTotal);
stringSet("ScenePopupLostFoundText", "lostFoundInfo", mLostFoundCount, mLostFoundTotal);
parentGet()->childFind("ScenePopupPerfectText")->textComponentGet()->textSet(
levelCompletionRankGet(mTarget) == "gold" ? fsCLocalisedStrings::localisedStringGet("perfect") : "");
completionStarsInit();
}
void fsCMapPopUpGui::stringSet(const fsStr& pTxtBoxName, const fsStr& pStrId, fsStr pNumGot, fsStr pNumTot) const
{
fsCEntity* txtEnt = parentGet()->childFind(pTxtBoxName);
fsStr txt = fsCLocalisedStrings::localisedStringGet(pStrId) + pNumGot +
fsCLocalisedStrings::localisedStringGet("numOfNum") + pNumTot;
txtEnt->textComponentGet()->textSet(txt);
}
fsIComponent* fsCMapPopUpGui::create(fsCEntity* pParent)
{
return new fsCMapPopUpGui(pParent);
}
fsCMapPopUpGui::fsCMapPopUpGui(fsCEntity* const pParent) :
fsIGuiComponent(pParent),
mTarget(""),
mTrashCount(0),
mTrashTotal(0),
mLostFoundCount(0),
mLostFoundTotal(0)
{
}
fsCMapPopUpGui::~fsCMapPopUpGui()
{
}
|