Skip to content

Commit

Permalink
UpdCollects() snd
Browse files Browse the repository at this point in the history
  • Loading branch information
cryham committed Apr 28, 2024
1 parent c17c53a commit 3e397fa
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 19 deletions.
2 changes: 2 additions & 0 deletions src/common/HlmsPbs2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ void HlmsPbs2::calculateHashForPreCreate(
case DB_Fluid: fluid = 1;
setProperty( "water", 1 ); break;
case DB_Paint: setProperty( "paint", 1 ); break;
default: break;
}

if (mtr.substr(0,5) == "River")
Expand Down Expand Up @@ -123,6 +124,7 @@ void HlmsPbs2::calculateHashForPreCaster(
// case DB_Fluid: fluid = 1;
// setProperty( "water", 1 ); break;
// case DB_Paint: setProperty( "paint", 1 ); break;
default: break;
}

/*if (mtr.find("body") != String::npos)
Expand Down
36 changes: 35 additions & 1 deletion src/common/SceneCollects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "CData.h"
#include "PresetsXml.h"

#include "SoundMgr.h"
#include "Axes.h"
#include "BtOgreGP.h"
#include "ShapeData.h"
Expand Down Expand Up @@ -43,6 +44,8 @@ using namespace std;
//-------------------------------------------------------------------------------------------------------
void App::CreateCollects()
{
iCollected = 0; oldCollected = 0; // game, hud

for (int i=0; i < scn->sc->collects.size(); ++i)
{
SCollect& o = scn->sc->collects[i];
Expand Down Expand Up @@ -97,7 +100,7 @@ void App::CreateCollects()
bco->setUserPointer(new ShapeData(ST_Collect, 0, 0, 0, &o)); /// *
#ifndef SR_EDITOR
pGame->collision.world->addCollisionObject(bco);
pGame->collision.shapes.push_back(bshp);
// pGame->collision.shapes.push_back(bshp); //?
o.co = bco;
#else
world->addCollisionObject(bco);
Expand Down Expand Up @@ -137,6 +140,7 @@ void App::DestroyCollects(bool clear)

void App::ResetCollects()
{
iCollected = 0; oldCollected = 0;
for (SCollect& o : scn->sc->collects)
if (o.nd)
{
Expand All @@ -145,6 +149,36 @@ void App::ResetCollects()
}
}

#ifndef SR_EDITOR // game

// Update collection game frame
void App::UpdCollects()
{
int all = sc->collects.size();
if (!all)
return;

// count collected
int cols = 0;
for (auto& c : sc->collects)
if (c.collected)
{ ++cols;
c.nd->setVisible(0);
}
oldCollected = iCollected;
iCollected = cols;

if (oldCollected != iCollected)
{
if (iCollected == all)
pGame->snd_lap->start(); // 🔉 end
else
pGame->snd_chk->start(); // 🔉 one

// todo: show wnd, check best time, pass etc
}
}
#endif

#if 0 /// TODO.. ed
// 👆 Pick
Expand Down
1 change: 1 addition & 0 deletions src/editor/CApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class App : public BaseApp

// 💎 Collectibles
void CreateCollects(), DestroyCollects(bool clear), ResetCollects();
int iCollected = 0, oldCollected = 0; //-


// 🌍 minimap ----
Expand Down
2 changes: 2 additions & 0 deletions src/game/CGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ class App : public BaseApp, public ICS::ChannelListener

// 💎 Collectibles
void CreateCollects(), DestroyCollects(bool clear), ResetCollects();
int iCollected = 0, oldCollected = 0;
void UpdCollects();


// New Game ----
Expand Down
6 changes: 4 additions & 2 deletions src/game/Collections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,22 +115,24 @@ void CGui::fillCollectList(std::vector<int> vIds)
void CGui::listCollectChng(MyGUI::MultiList2* chlist, size_t id)
{
if (id==ITEM_NONE || liCollect->getItemCount() == 0) return;
if (id >= liCollect->getItemCount())
id = 0; // liCollect->getItemCount()-1;

int nch = *liCollect->getItemDataAt<int>(id)-1;
if (nch < 0 || nch >= data->collect->all.size()) { LogO("Error collect sel > size."); return; }

CarListUpd(); // filter car list

// fill stages
liStages->removeAllItems();
// liStages->removeAllItems();

int n = 1, p = pSet->gui.champ_rev ? 1 : 0;
const Collect& ch = data->collect->all[nch];

if (edChDesc) edChDesc->setCaption(ch.descr);
txtChName->setCaption(ch.nameGui);

// UpdCollectDetail(nch);
// todo: fill track ..
}


Expand Down
9 changes: 1 addition & 8 deletions src/game/Hud_UpdatesAll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,14 +422,7 @@ void CHud::UpdTimes(int carId, Hud& h, float time, CAR* pCar, CarModel* pCarM)
if (h.txTimes)
if (pSet->game.collect_num >= 0)
{
// count collected
int cols = 0, all = app->sc->collects.size();
for (auto& c : app->sc->collects)
if (c.collected)
{ c.nd->setVisible(0);
++cols;
// todo ..
}
int cols = app->iCollected, all = app->sc->collects.size();
h.txTimes->setCaption(
"\n#D0B0FF" + toStr(cols)+" / "+toStr(all) +
"\n#A0E0E0" + StrTime(tim.GetPlayerTime(carId)));
Expand Down
7 changes: 5 additions & 2 deletions src/game/SceneInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,8 +843,11 @@ void App::NewGameDoLoad()
for (int i=0; i < carModels.size(); ++i)
{ CarModel* cm = carModels[i];
cm->updTimes = true;
cm->updLap = true; cm->fLapAlpha = 1.f;
}

bool collect = pSet->game.collect_num >= 0;
if (!collect)
{ cm->updLap = true; cm->fLapAlpha = 1.f;
} }

//if (pSet->show_fps)
// mFpsOverlay->show();
Expand Down
23 changes: 17 additions & 6 deletions src/game/Update_Poses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ void App::newPoses(float time) // time only for camera update
///-----------------------------------------------------------------------


// 💎 collection game
//-----------------------------------------------------------------------
bool collect = pSet->game.collect_num >= 0;
if (collect)
UpdCollects();


// 🏁 checkpoints, lap start
//-----------------------------------------------------------------------
if (bGhost && !gui->bLesson) // dont check for ghost
Expand Down Expand Up @@ -253,7 +260,7 @@ void App::newPoses(float time) // time only for camera update
/// Lap
bool finished = (pGame->timer.GetCurrentLap(c) >= pSet->game.num_laps)
&& (mClient || pSet->game.local_players > 1); // 📡 networked or 👥 splitscreen
bool best = finished ? false : // dont inc laps when race over (in ^)
bool best = finished || collect ? false : // dont inc laps when race over (in ^)
pGame->timer.Lap(c, !finished, pSet->game.track_reversed); //,boost_type?
double timeCur = pGame->timer.GetPlayerTimeTot(c);

Expand All @@ -275,7 +282,7 @@ void App::newPoses(float time) // time only for camera update
bool champ = pSet->game.champ_num >= 0, chall = pSet->game.chall_num >= 0;
bool chs = champ || chall;

if (!chs)
if (!chs && !collect)
{ if (newbest) // 🔉
pGame->snd_lapbest->start();
else
Expand All @@ -295,12 +302,15 @@ void App::newPoses(float time) // time only for camera update
carM->pCar->dynamics.fDamage - pSet->game.damage_dec);

// ⏱️ upd lap results ----
carM->updLap = false;
carM->fLapAlpha = 1.f;
if (!collect)
{
carM->updLap = false;
carM->fLapAlpha = 1.f;
}

/// all laps
finished = pGame->timer.GetCurrentLap(c) >= pSet->game.num_laps;
if (finished && !mClient)
if (finished && !mClient && !collect)
{
if (!chs)
{ // 👥 splitscreen winner places
Expand Down Expand Up @@ -369,7 +379,8 @@ void App::newPoses(float time) // time only for camera update
pGame->snd_chk->start(); // 🔉
}
else
if (carM->iInChk != carM->iCurChk && !bRplPlay &&
if (!collect && //?
carM->iInChk != carM->iCurChk && !bRplPlay &&
!scn->sc->noWrongChks) // denies
{
carM->bWrongChk = true; //
Expand Down

0 comments on commit 3e397fa

Please sign in to comment.