Skip to content

Commit

Permalink
Collections list gui ok, hud wip
Browse files Browse the repository at this point in the history
  • Loading branch information
cryham committed Apr 27, 2024
1 parent 5c9bded commit 7d43bdd
Show file tree
Hide file tree
Showing 18 changed files with 111 additions and 72 deletions.
31 changes: 26 additions & 5 deletions config/collections.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
// eg. using 2 will need 2.0 points less for silver etc.
// and will make it easier to pass challenge, but harder to win gold
<pass totalTime="123" prizes="2" factor="1.5" />
<pass timeNeeded="123" prizes="2" factor="1.5" />
<track name="" >
Expand All @@ -76,12 +76,33 @@
<!-- 🏞️ 0 short,easy infinite -->
<!--========================================================================================================================-->

<collection name="#A0C000Easy test" ver="1" difficulty="1" type="0"
descr="Very simple test.">
<cartype names="Gravel|Terrain" />
<pass totalTime="21" />
<collection name="#A0C000Easy test" ver="1" difficulty="0" type="0"
descr="Easy test cars.">
<cartype names="Gravel|Asphalt|Extreme" />
<pass timeNeeded="21" />
<track name="TestC6-Temp" />
</collection>

<collection name="#A0C000Easy hover" ver="1" difficulty="1" type="1"
descr="Simple test hover.">
<cartype names="Hover" />
<pass timeNeeded="21" />
<track name="TestC4-Ow" />
</collection>

<collection name="#A0C000Easy drone" ver="1" difficulty="3" type="2"
descr="Test drone.">
<cartype names="Drone" />
<pass timeNeeded="21" />
<track name="Test13-Hills" />
</collection>

<collection name="#A0C000Easy space" ver="1" difficulty="4" type="3"
descr="Test Spaceship.">
<cartype names="Spaceship" />
<pass timeNeeded="21" />
<track name="Test14-Terrains" />
</collection>


</collections>
10 changes: 5 additions & 5 deletions data/gui/Game.layout
Original file line number Diff line number Diff line change
Expand Up @@ -1956,13 +1956,13 @@
<Widget type="TabControl" skin="TabControl" position="25 26 603 36" name="SubTabCollectType">
<Property key="Colour" value="0.9 0.8 1.0"/>
<Widget type="TabItem" skin="" position="2 24 578 8">
<Property key="Caption" value="#A0D0FF#{Diff2}"/>
<Property key="Caption" value="#80C0FF#{Chall_Endurance}"/>
</Widget>
<!-- <Widget type="TabItem" skin="" position="2 24 578 8">
<Property key="Caption" value="#C0FF80#{Chall_Endurance}"/>
</Widget> -->
<Widget type="TabItem" skin="" position="2 24 578 8">
<Property key="Caption" value="#FFC060#{Chall_Chase}"/>
<Property key="Caption" value="#C060FF#{Chall_Chase}"/>
</Widget>
<Widget type="TabItem" skin="" position="2 24 578 8">
<Property key="Caption" value="#A0D0FF#{Diff6}"/>
</Widget>
<Widget type="TabItem" skin="" position="2 24 578 8">
<Property key="Caption" value="#909090#{Test}"/>
Expand Down
2 changes: 1 addition & 1 deletion src/common/GuiCom_Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const int CGui::colCar[16] = {34, 80, 27, wi, wi, wi, wi, 37, 45, 24}; // car
const int CGui::colCh [16] = {16, 200, 120, 50, 80, 80, 60, 40}; // champs
const int CGui::colChL[16] = {16, 180, 90, 100, 50, 60, 60, 60, 50}; // challs
const int CGui::colSt [16] = {30, 170, 100, 90, 50, 80, 70}; // stages
const int CGui::colCol[16] = {16, 180, 90, 100, 50, 50}; // collect
const int CGui::colCol[16] = {16, 80, 90, 100, 50, 50}; // collect
#endif

// get scenery color string from track name
Expand Down
2 changes: 1 addition & 1 deletion src/editor/brushes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void BrushesIni::Load(std::string sfile)
{
CONFIGFILE c; c.Load(sfile);
Serialize(false, c);
LogO("**** Loaded brushes: "+toStr(v.size()));
LogO("L*** Loaded brushes: "+toStr(v.size()));
}
void BrushesIni::Save(std::string sfile)
{
Expand Down
8 changes: 4 additions & 4 deletions src/game/CGui.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@ class CGui : public BGui
/// 🏆 Championships, Challenges, Collections
///-----------------------------------------------------------------------------------------------------------------

Btn btStTut =0, btStChamp =0, btStChall =0, btStCollect =0;
Img imgTut =0, imgChamp =0, imgChall =0, imgCollect =0, imgCareer =0;
Btn btStTut =0, btStChamp =0, btStChall =0, btStCollect =0; // start
Img imgTut =0, imgChamp =0, imgChall =0, imgCollect =0, imgCareer =0; // ico
Tab tabChamp =0, tabChall =0, tabCollect =0; // tabs

void tabChampType(Tab, size_t), tabChallType(Tab, size_t), tabCollectType(Tab, size_t);
Expand Down Expand Up @@ -501,11 +501,11 @@ class CGui : public BGui
CK(ChampRev); CK(Ch_All);

void ReadTrkStatsChamp(Ogre::String track,bool reverse);
void updChampListDim();
void updChsListDim();

// chall util
bool IsChallCar(Ogre::String name), IsCollectCar(Ogre::String name);
bool isChallGui(), isCollectGui(); void BackFromChs();
bool isChampGui(), isChallGui(), isCollectGui(); void BackFromChs();


// 🛠️ _Tools_ ----
Expand Down
6 changes: 3 additions & 3 deletions src/game/CGui_Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ void CGui::btnMainMenu(WP wp)
if (wp == app->mMainGamesBtns[i])
{ switch (i)
{
case Games_Single: GuiShortcut(MN_Single, TAB_Track); SetNumPlayers(1); break;
case Games_SplitScreen: GuiShortcut(MN_Single, TAB_Split); SetNumPlayers(-2); break; // 👥
case Games_Multiplayer: GuiShortcut(MN_Single, TAB_Multi); SetNumPlayers(1); break; // 📡
case Games_Single: SetNumPlayers(1); GuiShortcut(MN_Single, TAB_Track); break;
case Games_SplitScreen: SetNumPlayers(-2); GuiShortcut(MN_Single, TAB_Split); break; // 👥
case Games_Multiplayer: SetNumPlayers(1); GuiShortcut(MN_Single, TAB_Multi); break; // 📡

case Games_Tutorial: pSet->iMenu = MN_Tutorial; break;
case Games_Champ: pSet->iMenu = MN_Champ; break;
Expand Down
5 changes: 5 additions & 0 deletions src/game/Challenges.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "pch.h"
#include "Def_Str.h"
#include "CData.h"
#include "settings.h"
#include "TracksXml.h"
#include "GuiCom.h"
#include "CScene.h"
Expand Down Expand Up @@ -29,6 +30,10 @@ void CGui::BackFromChs()
CarListUpd(); // off filtering
}

bool CGui::isChampGui()
{
return pSet->iMenu == MN_Champ || pSet->iMenu == MN_Tutorial;
}
bool CGui::isChallGui()
{
return pSet->iMenu == MN_Chall;
Expand Down
17 changes: 10 additions & 7 deletions src/game/ChampChall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void App::Ch_NewGame()
pSet->game.BoostDefault(); //

pGame->pause = false; // wait for wnd close ..?
pGame->timer.waiting = true;
pGame->timer.waiting = false;
}
else
{ pGame->pause = false; // single race
Expand Down Expand Up @@ -180,18 +180,21 @@ void CGui::UpdChsTabVis()
collect = pSet->iMenu == MN_Collect, career = pSet->iMenu == MN_Career;
bool chAny = tutor || champ || chall || collect || career;

btNewGameCar->setVisible(!chAny);
imgTut->setVisible(tutor); btStTut->setVisible(tutor);
panCh->setColour(tutor ? Colour(0.9,0.8,0.7) : champ ? Colour(0.7,0.9,0.8) : Colour(0.77,0.75,0.92));

tabChamp->setVisible(champ); imgChamp->setVisible(champ); btStChamp->setVisible(champ);
liChamps->setVisible(champ || tutor); liChamps->setColour(tutor ? Colour(0.85,0.8,0.75) : Colour(0.75,0.8,0.85));

tabChall->setVisible(chall); imgChall->setVisible(chall); btStChall->setVisible(chall);
btNewGameCar->setVisible(!chAny);
liChalls->setVisible(chall); liChalls->setColour(Colour(0.74,0.7,0.82));

imgCollect->setVisible(collect); btStCollect->setVisible(collect);
tabCollect->setVisible(collect);
liCollect->setVisible(collect); liCollect->setColour(Colour(0.7,0.6,0.8));
imgCareer->setVisible(career);

liChamps->setVisible(!chall); liChamps->setColour(tutor ? Colour(0.85,0.8,0.75) : Colour(0.75,0.8,0.85));
liChalls->setVisible( chall); liChalls->setColour(Colour(0.74,0.7,0.82));
liCollect->setVisible( collect); liCollect->setColour(Colour(1,0.74,0.7));
panCh->setColour(tutor ? Colour(0.9,0.8,0.7) : champ ? Colour(0.7,0.9,0.8) : Colour(0.77,0.75,0.92));

if (collect) CollectListUpdate(); else
if (chall) ChallsListUpdate(); else
ChampsListUpdate();
Expand Down
10 changes: 3 additions & 7 deletions src/game/Championships.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void CGui::fillChampsList(std::vector<int> vIds)
const int ntrks = pc.trks.size(), ct = pc.curTrack;
const String& clr = clrCh[ch.type];

liChamps->addItem(""/*clr+ toStr(i)*/, i+1); int l = liChamps->getItemCount()-1;
liChamps->addItem("", i+1); int l = liChamps->getItemCount()-1;
liChamps->setSubItemNameAt(1,l, clr+ ch.name.c_str());
liChamps->setSubItemNameAt(2,l, gcom->getClrDiff(ch.diff)+ TR("#{Diff"+toStr(ch.diff)+"}"));

Expand All @@ -127,14 +127,13 @@ void CGui::fillChampsList(std::vector<int> vIds)


/// upd dim champ,chall,stages lists ----------
void CGui::updChampListDim()
void CGui::updChsListDim()
{
const IntCoord& wi = app->mWndGame->getCoord();

// Champs -----
if (!liChamps) return;
int c,w;

int sum = 0, cnt = liChamps->getColumnCount(), sw = 0;
for (c=0; c < cnt; ++c) sum += colCh[c];
for (c=0; c < cnt; ++c)
Expand All @@ -144,11 +143,10 @@ void CGui::updChampListDim()
}
int xt = 0.03*wi.width, yt = 0.10*wi.height; // pos
liChamps->setCoord(xt, yt, sw + 8/*frame*/, 0.40/*height*/*wi.height);
liChamps->setVisible(!isChallGui());
liChamps->setVisible(isChampGui());

// Stages -----
if (!liStages) return;

sum = 0; cnt = liStages->getColumnCount(); sw = 0;
for (c=0; c < cnt; ++c) sum += colSt[c]; sum += 43;//-
for (c=0; c < cnt; ++c)
Expand All @@ -161,7 +159,6 @@ void CGui::updChampListDim()

// Challs -----
if (!liChalls) return;

sum = 0; cnt = liChalls->getColumnCount(); sw = 0;
for (c=0; c < cnt; ++c) sum += colChL[c];
for (c=0; c < cnt; ++c)
Expand All @@ -175,7 +172,6 @@ void CGui::updChampListDim()

// Collect -----
if (!liCollect) return;

sum = 0; cnt = liCollect->getColumnCount(); sw = 0;
for (c=0; c < cnt; ++c) sum += colCol[c];
for (c=0; c < cnt; ++c)
Expand Down
11 changes: 7 additions & 4 deletions src/game/Collections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ void CGui::CollectListUpdate()
const Collect& col = data->collect->all[id];
if (pSet->ch_all || (
col.diff >= pSet->difficulty &&
col.diff <= pSet->difficulty+1)) vIds[col.type].emplace_back(id);
col.diff <= pSet->difficulty+1))
vIds[col.type].emplace_back(id);
}

int cntCur = vIds[pSet->collect_type].size();
Expand Down Expand Up @@ -90,9 +91,11 @@ void CGui::fillCollectList(std::vector<int> vIds)
const String& clr = clrCh[col.type];
//String cars = data->carsXml.colormap[col.ci->type]; if (cars.length() != 7) clr = "#C0D0E0";

liCollect->addItem(""/*clr+ toStr(n/10)+toStr(n%10)*/, i+1); int l = liCollect->getItemCount()-1;
liCollect->setSubItemNameAt(1,l, "AAAA"); //clr+ col.nameGui.c_str());
liCollect->setSubItemNameAt(2,l, gcom->clrsDiff[col.diff]+ TR("#{Diff"+toStr(col.diff)+"}"));
liCollect->addItem("", i+1); int l = liCollect->getItemCount()-1;
liCollect->setSubItemNameAt(1,l, clr+ col.name);
liCollect->setSubItemNameAt(2,l, col.track);
liCollect->setSubItemNameAt(3,l, gcom->clrsDiff[col.diff]+ TR("#{Diff"+toStr(col.diff)+"}"));
liCollect->setSubItemNameAt(4,l, col.cars.GetStr(data->cars));

// liCollect->setSubItemNameAt(5,l, gcom->clrsDiff[std::min(8,int(col.time/3.f/60.f))]+ StrTime2(col.time));
// liCollect->setSubItemNameAt(6,l, ct == 0 || ct == ntrks ? "" :
Expand Down
2 changes: 1 addition & 1 deletion src/game/Game_Update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void App::update( float dt )
gcom->ResizeOptWnd();
gcom->SizeGUI();
gcom->updTrkListDim();
gui->updChampListDim(); // resize lists
gui->updChsListDim(); // resize lists
gui->slSSS(0);
gui->listCarChng(gui->carList,0); // had wrong size
bRecreateHUD = true;
Expand Down
35 changes: 17 additions & 18 deletions src/game/Gui_InitChamps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ void CGui::InitGuiChamps()
li->addColumn(" ", colChL[c++]);
liChalls = li;

// 💎 Collections list -------------
li = trktab->createWidget<MultiList2>("MultiListBox",0,0,400,300, Align::Left | Align::VStretch);
Lev(li, CollectChng); li->setVisible(false);

li->removeAllColumns(); c=0;
li->addColumn("#80A080", colCol[c++]);
li->addColumn(TR("#60F060#{Name}"), colCol[c++]); li->addColumn(TR("#80F040#{Track}"), colCol[c++]);
li->addColumn(TR("#F0D040#{Difficulty}"), colChL[c++]); li->addColumn(TR("#F09090#{Vehicles}"), colCol[c++]);
li->addColumn(TR("#F0F8FF#{Prize}"), colCol[c++]); li->addColumn(TR("#80E0FF#{Time}"), colCol[c++]);
li->addColumn(" ", colChL[c++]);
liCollect = li;


// 🏞️ Stages list -------------
trktab = (TabItem*)app->mWndGame->findWidget("TabStages");
Expand All @@ -96,19 +108,6 @@ void CGui::InitGuiChamps()
liStages = li;


// 💎 Collections list -------------
li = trktab->createWidget<MultiList2>("MultiListBox",0,0,400,300, Align::Left | Align::VStretch);
Lev(li, CollectChng); li->setVisible(false);

li->removeAllColumns(); c=0;
li->addColumn("#80A080", colChL[c++]);
li->addColumn(TR("#60F060#{Name}"), colChL[c++]); li->addColumn(TR("#F0D040#{Difficulty}"), colChL[c++]);
li->addColumn(TR("#F09090#{Vehicles}"), colChL[c++]);
li->addColumn(TR("#F0F8FF#{Prize}"), colChL[c++]); li->addColumn(TR("#80E0FF#{Time}"), colChL[c++]);
li->addColumn(" ", colChL[c++]);
liCollect = li;


// tabs
tabChamp = fTab("ChampType"); Tev(tabChamp, ChampType); tabChamp->setIndexSelected(pSet->champ_type);
tabChall = fTab("SubTabChallType"); Tev(tabChall, ChallType); tabChall->setIndexSelected(pSet->chall_type);
Expand All @@ -117,15 +116,15 @@ void CGui::InitGuiChamps()
imgTut = fImg("imgTut"); imgChamp = fImg("imgChamp"); imgChall = fImg("imgChall");
imgCollect = fImg("imgCollect"); imgCareer = fImg("imgCareer");

updChampListDim();
updChsListDim();
ChampsListUpdate(); listChampChng(liChamps, liChamps->getIndexSelected());
ChallsListUpdate(); listChallChng(liChalls, liChalls->getIndexSelected());
CollectListUpdate(); listCollectChng(liCollect, liCollect->getIndexSelected());

Btn("btnTutStart", btnChampStart); btStTut = btn;
Btn("btnChampStart",btnChampStart); btStChamp = btn;
Btn("btnChallStart",btnChallStart); btStChall = btn; Btn("btnChRestart", btnChRestart); btChRestart = btn;
Btn("btnCollectStart",btnChallStart); btStCollect = btn;
Btn("btnTutStart", btnChampStart); btStTut = btn;
Btn("btnChampStart", btnChampStart); btStChamp = btn;
Btn("btnChallStart", btnChallStart); btStChall = btn; Btn("btnChRestart", btnChRestart); btChRestart = btn;
Btn("btnCollectStart", btnCollectStart); btStCollect = btn;


// ch other
Expand Down
6 changes: 3 additions & 3 deletions src/game/Gui_KeyPress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ void App::keyPressed(const SDL_KeyboardEvent &arg)
case key(RETURN):
switch (pSet->yGames)
{
case Games_Single: gui->GuiShortcut(MN_Single, TAB_Track); gui->SetNumPlayers(1); break;
case Games_SplitScreen: gui->GuiShortcut(MN_Single, TAB_Split); gui->SetNumPlayers(-2); break; // 👥
case Games_Multiplayer: gui->GuiShortcut(MN_Single, TAB_Multi); gui->SetNumPlayers(1); break; // 📡
case Games_Single: gui->SetNumPlayers(1); gui->GuiShortcut(MN_Single, TAB_Track); break;
case Games_SplitScreen: gui->SetNumPlayers(-2); gui->GuiShortcut(MN_Single, TAB_Split); break; // 👥
case Games_Multiplayer: gui->SetNumPlayers(1); gui->GuiShortcut(MN_Single, TAB_Multi); break; // 📡

case Games_Tutorial: pSet->iMenu = MN_Tutorial; break;
case Games_Champ: pSet->iMenu = MN_Champ; break;
Expand Down
2 changes: 1 addition & 1 deletion src/game/Gui_TweakSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ void CGui::TweakColSave()
TweakColUpd(true);

app->scn->data->objs->LoadXml();
LogO(String("**** Loaded Vegetation collisions: ") + toStr(app->scn->data->objs->colsMap.size()));
LogO(String("L*** Loaded Vegetation collisions: ") + toStr(app->scn->data->objs->colsMap.size()));
app->NewGame();
}

Expand Down
9 changes: 5 additions & 4 deletions src/game/Gui_Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ void CGui::toggleGui(bool toggle)
tutor = mnu == MN_Tutorial, chall = mnu == MN_Chall,
collect = mnu == MN_Collect, career = mnu == MN_Career,
chAny = tutor || champ || chall || collect || career,
stages = tutor || champ || chall,
gc = game || chAny,
split = !chAny && pSet->yGames == Games_SplitScreen,
multi = !chAny && pSet->yGames == Games_Multiplayer;
Expand All @@ -126,16 +127,16 @@ void CGui::toggleGui(bool toggle)
TabItem* t = app->mTabsGame->getItemAt(TAB_Champs);
t->setCaption(sCh);
}
if (notMain && gc) // show hide champs,stages
if (notMain && gc) // show hide tabs track,stages,
{
Tab t = app->mTabsGame;
size_t id = t->getIndexSelected();
t->setButtonWidthAt(TAB_Track, chAny ? 1 :-1); if (id == TAB_Track && chAny) t->setIndexSelected(TAB_Champs);
t->setButtonWidthAt(TAB_Split, split ?-1 : 1); if (id == TAB_Split && chAny) t->setIndexSelected(TAB_Champs);
t->setButtonWidthAt(TAB_Multi, multi ?-1 : 1); if (id == TAB_Multi && chAny) t->setIndexSelected(TAB_Champs);
t->setButtonWidthAt(TAB_Split, split ?-1 : 1); if (id == TAB_Split && !split) t->setIndexSelected(TAB_Champs);
t->setButtonWidthAt(TAB_Multi, multi ?-1 : 1); if (id == TAB_Multi && !multi) t->setIndexSelected(TAB_Champs);

t->setButtonWidthAt(TAB_Champs,chAny ?-1 : 1); if (id == TAB_Champs && !chAny) t->setIndexSelected(TAB_Track);
t->setButtonWidthAt(TAB_Stages,chAny ?-1 : 1); if (id == TAB_Stages && !chAny) t->setIndexSelected(TAB_Track);
t->setButtonWidthAt(TAB_Stages,stages?-1 : 1); if (id == TAB_Stages && !stages) t->setIndexSelected(TAB_Track);
t->setButtonWidthAt(TAB_Stage, chAny ?-1 : 1); if (id == TAB_Stage && !chAny) t->setIndexSelected(TAB_Track);
}

Expand Down
Loading

0 comments on commit 7d43bdd

Please sign in to comment.