Skip to content

Commit

Permalink
tracks gallery wip
Browse files Browse the repository at this point in the history
  • Loading branch information
cryham committed May 18, 2024
1 parent 218f879 commit aa188a1
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 84 deletions.
19 changes: 13 additions & 6 deletions config/collections.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ descr="Difficult gems on top of ballons with fast drone.">
</collection>

<collection name="SBridge terrain" ver="1" difficulty="3" type="0" groups="1"
descr="Gems located on terrain tops, and in bumpy places. Careful for damage, no rewind.">
descr="Gems located on terrain tops, and in bumpy places. Endurance type, careful for damage, no rewind.">
<cartype names="Gravel" />
<sim boost="2" damage="2" rewind="0" />
<sim boost="2" damage="1" rewind="0" />
<track name="Des4-SBridge" />
</collection>

Expand Down Expand Up @@ -179,10 +179,10 @@ descr="Small but dense jungle track with hidden gems.">
<track name="Jng11-Temple" />
</collection>

<collection name="Mad Mntn Dark" ver="1" difficulty="6" type="2" groups="3"
descr="Mad Mntn track in dark with heavy rain. Difficult places for gems, many on hexrock platforms and on top of caves or hills.">
<collection name="Mad Mntn Dark" ver="1" difficulty="5" type="2" groups="3"
descr="Mad Mntn track in dark with heavy rain. Difficult places for gems, many on hexrock platforms and on top of caves or hills. But with Spaceship it's easier and softer to navigate here.">
<cartype names="Spaceship" />
<sim boost="3" damage="0" />
<sim boost="3" damage="1" />
<track name="For9-MadMntnDark" />
</collection>

Expand All @@ -193,12 +193,19 @@ descr="Few gems to collect on vast Greece landscape, on top of hills with good v
</collection>

<collection name="Canyon hills" ver="1" difficulty="3" type="0" groups="3"
descr="Plenty of gems on canyon hills, few under bridges and on platforms for look out.">
descr="Plenty of gems on canyon hills, few under bridges and on platforms for look out. For fast hovering vehicles.">
<cartype names="Hover|Drone|Spaceship" />
<sim boost="3" />
<track name="Aus3-Canyon" />
</collection>

<collection name="#D0D040Volcanic dark islands" ver="1" difficulty="2" type="0" groups="1"
descr="Gems located on hill tops and on few small islands, in almost dark.">
<cartype names="Hovercraft" />
<sim boost="1" />
<track name="Vlc1-Dark" />
</collection>

<collection name="#B0A0D0Satellite visits" ver="1" difficulty="2" type="0" groups="1"
descr="Easy collection, each satellite antenna (near road) has a gem, usually in front.">
<cartype names="Extreme" />
Expand Down
2 changes: 2 additions & 0 deletions src/common/GuiCom.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ class CGuiCom : public BGui

Mli2 trkList =0; Scv scvTracks =0;
int xTrk = 0, yTrk = 0;
std::vector<Img> imgGal;
std::vector<Txt> txtGal;

WP panTrkDesc[2] ={0,0};
Ed trkDesc[2] ={0,0}, trkAdvice[2] ={0,0}; // description, advice
Expand Down
38 changes: 34 additions & 4 deletions src/common/GuiCom_Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "CScene.h"
#include "CGui.h"
#include "App.h"
#include "settings_com.h"
#ifndef SR_EDITOR
#include "game.h"
#include "CHud.h"
Expand Down Expand Up @@ -122,7 +123,38 @@ void CGuiCom::AddTrkL(std::string name, int user,
shrt = name.substr(p+1); // short name
}else
{ pre = name; shrt = name; }



// gallery img [] ----
if (1 && scvTracks)
{
int sx = 160, sm = sx + 16, ya = 24;
Img img = scvTracks->createWidget<ImageBox>("ImageBox",
xTrk, yTrk+ya, sx, sx+ya, Align::Left);
// xTrk, yTrk, sx, sx, Align::Left);
img->setImageTexture(name+".jpg"); // _previews/

Txt txt = scvTracks->createWidget<TextBox>("TextBox",
xTrk, yTrk, sx, sx, Align::Left);
txt->setCaption(c+ shrt); txt->setTextShadow(1);
txt->setFontName("font.small");

// setOrigPos(img, "GameWnd");
// img->setNeedMouseFocus(0);
if (pSet->tracks_view == TV_GalleryList)
yTrk += sm+ya;
else
{ xTrk += sm;
if (xTrk > 800)
{ xTrk = 0;
yTrk += sm+ya;
} }
imgGal.push_back(img);
txtGal.push_back(txt);
}
// scvTracks->setSc


// add name = prefix-short
li->addItem(c+ pre, 0);
int l = li->getItemCount()-1;
Expand Down Expand Up @@ -175,9 +207,7 @@ void CGuiCom::GuiInitTrack()
li->eventListChangePosition += newDelegate(this, &CGuiCom::listTrackChng);
li->setVisible(false);

// gallery
scvTracks = fScv("scvTracks");
// trktab->createWidget<ScrollView>
scvTracks = fScv("scvTracks"); // gallery

// 🖼️ preview images
#ifdef SR_EDITOR // game in Gui_Init
Expand Down
155 changes: 81 additions & 74 deletions src/common/GuiCom_TrackUpd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,86 +90,93 @@ bool TrkSort(const TrkL& t1, const TrkL& t2)
//-----------------------------------------------------------------------------------------------------------
void CGuiCom::TrackListUpd(bool resetNotFound)
{
if (trkList)
{ trkList->removeAllItems();
xTrk = 0; yTrk = 0;
int ii = 0, a = 0, si = -1; bool bFound = false;

// sort
TrkL::idSort = min(18, (int)trkList->mSortColumnIndex);

auto liTrk2 = liTrk; // copy
liTrk2.sort(TrkSort);
if (!trkList->mSortUp) liTrk2.reverse();
if (!trkList) return;
trkList->removeAllItems();
xTrk = 0; yTrk = 0;
int ii = 0, a = 0, si = -1; bool bFound = false;

// gal dest
for (auto img : imgGal)
mGui->destroyWidget(img);
imgGal.clear();
for (auto txt : txtGal)
mGui->destroyWidget(txt);
txtGal.clear();

// sort
TrkL::idSort = min(18, (int)trkList->mSortColumnIndex);

auto liTrk2 = liTrk; // copy
liTrk2.sort(TrkSort);
if (!trkList->mSortUp) liTrk2.reverse();

// original
for (auto i = liTrk2.begin(); i != liTrk2.end(); ++i)
{
String name = (*i).name, nlow = name; StringUtil::toLowerCase(nlow);
const auto* ti = (*i).ti; const auto* ui = (*i).ui;

if (!pSet->gui.track_user && name == pSet->gui.track)
{ bFound = true; bListTrackU = 0; }

// original
for (auto i = liTrk2.begin(); i != liTrk2.end(); ++i)
bool add = 0;
if (sTrkFind == "" || strstr(nlow.c_str(), sTrkFind.c_str()) != 0)
if (!pSet->tracks_filter || !ti || !ui || // filtering
ti->ver >= pSet->col_fil[0][0] && ti->ver <= pSet->col_fil[1][0] &&
ti->diff >= pSet->col_fil[0][1] && ti->diff <= pSet->col_fil[1][1] &&
ti->rating >= pSet->col_fil[0][2] && ti->rating <= pSet->col_fil[1][2] &&

ti->objects >= pSet->col_fil[0][3] && ti->objects <= pSet->col_fil[1][3] &&
ti->obstacles>= pSet->col_fil[0][4] && ti->obstacles<= pSet->col_fil[1][4] &&
ti->fluids >= pSet->col_fil[0][5] && ti->fluids <= pSet->col_fil[1][5] &&
ti->bumps >= pSet->col_fil[0][6] && ti->bumps <= pSet->col_fil[1][6] &&
ti->jumps >= pSet->col_fil[0][7] && ti->jumps <= pSet->col_fil[1][7] &&
ti->loops >= pSet->col_fil[0][8] && ti->loops <= pSet->col_fil[1][8] &&
ti->pipes >= pSet->col_fil[0][9] && ti->pipes <= pSet->col_fil[1][9] &&
ti->banked >= pSet->col_fil[0][10] && ti->banked <= pSet->col_fil[1][10] &&
ti->frenzy >= pSet->col_fil[0][11] && ti->frenzy <= pSet->col_fil[1][11] &&
ti->sum >= pSet->col_fil[0][12] && ti->sum <= pSet->col_fil[1][12] &&
ti->longn >= pSet->col_fil[0][13] && ti->longn <= pSet->col_fil[1][13] &&

ui->rating >= pSet->col_fil[0][14] && ui->rating <= pSet->col_fil[1][14] &&
ui->bookm >= pSet->col_fil[0][15] && ui->bookm <= pSet->col_fil[1][15])
{
String name = (*i).name, nlow = name; StringUtil::toLowerCase(nlow);
const auto* ti = (*i).ti; const auto* ui = (*i).ui;
AddTrkL(name, 0, (*i).ti, (*i).ui);
if (!pSet->gui.track_user && name == pSet->gui.track) { si = ii;
trkList->setIndexSelected(si); }

if (!pSet->gui.track_user && name == pSet->gui.track)
{ bFound = true; bListTrackU = 0; }

bool add = 0;
if (sTrkFind == "" || strstr(nlow.c_str(), sTrkFind.c_str()) != 0)
if (!pSet->tracks_filter || !ti || !ui || // filtering
ti->ver >= pSet->col_fil[0][0] && ti->ver <= pSet->col_fil[1][0] &&
ti->diff >= pSet->col_fil[0][1] && ti->diff <= pSet->col_fil[1][1] &&
ti->rating >= pSet->col_fil[0][2] && ti->rating <= pSet->col_fil[1][2] &&

ti->objects >= pSet->col_fil[0][3] && ti->objects <= pSet->col_fil[1][3] &&
ti->obstacles>= pSet->col_fil[0][4] && ti->obstacles<= pSet->col_fil[1][4] &&
ti->fluids >= pSet->col_fil[0][5] && ti->fluids <= pSet->col_fil[1][5] &&
ti->bumps >= pSet->col_fil[0][6] && ti->bumps <= pSet->col_fil[1][6] &&
ti->jumps >= pSet->col_fil[0][7] && ti->jumps <= pSet->col_fil[1][7] &&
ti->loops >= pSet->col_fil[0][8] && ti->loops <= pSet->col_fil[1][8] &&
ti->pipes >= pSet->col_fil[0][9] && ti->pipes <= pSet->col_fil[1][9] &&
ti->banked >= pSet->col_fil[0][10] && ti->banked <= pSet->col_fil[1][10] &&
ti->frenzy >= pSet->col_fil[0][11] && ti->frenzy <= pSet->col_fil[1][11] &&
ti->sum >= pSet->col_fil[0][12] && ti->sum <= pSet->col_fil[1][12] &&
ti->longn >= pSet->col_fil[0][13] && ti->longn <= pSet->col_fil[1][13] &&

ui->rating >= pSet->col_fil[0][14] && ui->rating <= pSet->col_fil[1][14] &&
ui->bookm >= pSet->col_fil[0][15] && ui->bookm <= pSet->col_fil[1][15])
{
AddTrkL(name, 0, (*i).ti, (*i).ui);
if (!pSet->gui.track_user && name == pSet->gui.track) { si = ii;
trkList->setIndexSelected(si); }

if (ti && !ti->test && !ti->testC) ++a; // dont count test tracks
++ii; add = 1;
}
//if (!add) LogO("!add: " + name); // test missing
if (ti && !ti->test && !ti->testC) ++a; // dont count test tracks
++ii; add = 1;
}
int all = max(1, app->scn->data->tracks->cntAll);
txtTracksFCur->setCaption(TR("#{Road_Cur}: ")+toStr(a) +" "+
getClrSum((iClrsSum-1) * a/all)+ fToStr(100.f * a/all, 1,4)+"%");
txtTracksFAll->setCaption(TR("#{RplAll}: "+toStr(all)));

// user
for (auto i = liTracksUser.begin(); i != liTracksUser.end(); ++i)
//if (!add) LogO("!add: " + name); // test missing
}
int all = max(1, app->scn->data->tracks->cntAll);
txtTracksFCur->setCaption(TR("#{Road_Cur}: ")+toStr(a) +" "+
getClrSum((iClrsSum-1) * a/all)+ fToStr(100.f * a/all, 1,4)+"%");
txtTracksFAll->setCaption(TR("#{RplAll}: "+toStr(all)));

// user
for (auto i = liTracksUser.begin(); i != liTracksUser.end(); ++i)
{
String name = *i, nlow = name; StringUtil::toLowerCase(nlow);
if (sTrkFind == "" || strstr(nlow.c_str(), sTrkFind.c_str()) != 0)
{
String name = *i, nlow = name; StringUtil::toLowerCase(nlow);
if (sTrkFind == "" || strstr(nlow.c_str(), sTrkFind.c_str()) != 0)
{
AddTrkL("*" + (*i) + "*", 1, 0, 0);
if (pSet->gui.track_user && name == pSet->gui.track) { si = ii;
trkList->setIndexSelected(si);
bFound = true; bListTrackU = 1; }
++ii;
} }

// not found last track, set 1st .. only
if (resetNotFound && !bFound && !liTracks.empty())
{ pSet->gui.track = *liTracks.begin(); pSet->gui.track_user = 0;
#ifdef SR_EDITOR
app->UpdWndTitle();
#endif
}
if (si > -1) // center
trkList->beginToItemAt(max(0, si-11));
AddTrkL("*" + (*i) + "*", 1, 0, 0);
if (pSet->gui.track_user && name == pSet->gui.track) { si = ii;
trkList->setIndexSelected(si);
bFound = true; bListTrackU = 1; }
++ii;
} }

// not found last track, set 1st .. only
if (resetNotFound && !bFound && !liTracks.empty())
{ pSet->gui.track = *liTracks.begin(); pSet->gui.track_user = 0;
#ifdef SR_EDITOR
app->UpdWndTitle();
#endif
}
if (si > -1) // center
trkList->beginToItemAt(max(0, si-11));
}

bool CGuiCom::needSort(Mli2 li)
Expand Down

0 comments on commit aa188a1

Please sign in to comment.