From 3e397fab814d544650573781b40c95f5556e32f3 Mon Sep 17 00:00:00 2001 From: cryham Date: Sun, 28 Apr 2024 19:30:07 +0200 Subject: [PATCH] UpdCollects() snd --- src/common/HlmsPbs2.cpp | 2 ++ src/common/SceneCollects.cpp | 36 +++++++++++++++++++++++++++++++++++- src/editor/CApp.h | 1 + src/game/CGame.h | 2 ++ src/game/Collections.cpp | 6 ++++-- src/game/Hud_UpdatesAll.cpp | 9 +-------- src/game/SceneInit.cpp | 7 +++++-- src/game/Update_Poses.cpp | 23 +++++++++++++++++------ 8 files changed, 67 insertions(+), 19 deletions(-) diff --git a/src/common/HlmsPbs2.cpp b/src/common/HlmsPbs2.cpp index 28da9285..427a67cf 100644 --- a/src/common/HlmsPbs2.cpp +++ b/src/common/HlmsPbs2.cpp @@ -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") @@ -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) diff --git a/src/common/SceneCollects.cpp b/src/common/SceneCollects.cpp index 952a2fb4..bf467e20 100644 --- a/src/common/SceneCollects.cpp +++ b/src/common/SceneCollects.cpp @@ -16,6 +16,7 @@ #include "CData.h" #include "PresetsXml.h" +#include "SoundMgr.h" #include "Axes.h" #include "BtOgreGP.h" #include "ShapeData.h" @@ -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]; @@ -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); @@ -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) { @@ -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 diff --git a/src/editor/CApp.h b/src/editor/CApp.h index b7960b4b..70eeb854 100644 --- a/src/editor/CApp.h +++ b/src/editor/CApp.h @@ -94,6 +94,7 @@ class App : public BaseApp // 💎 Collectibles void CreateCollects(), DestroyCollects(bool clear), ResetCollects(); + int iCollected = 0, oldCollected = 0; //- // 🌍 minimap ---- diff --git a/src/game/CGame.h b/src/game/CGame.h index bb3d4934..aebb3847 100644 --- a/src/game/CGame.h +++ b/src/game/CGame.h @@ -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 ---- diff --git a/src/game/Collections.cpp b/src/game/Collections.cpp index 10ab4fa9..b66df1b7 100644 --- a/src/game/Collections.cpp +++ b/src/game/Collections.cpp @@ -115,6 +115,8 @@ void CGui::fillCollectList(std::vector 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(id)-1; if (nch < 0 || nch >= data->collect->all.size()) { LogO("Error collect sel > size."); return; } @@ -122,15 +124,15 @@ void CGui::listCollectChng(MyGUI::MultiList2* chlist, size_t id) 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 .. } diff --git a/src/game/Hud_UpdatesAll.cpp b/src/game/Hud_UpdatesAll.cpp index bc39c137..4e4cccbd 100644 --- a/src/game/Hud_UpdatesAll.cpp +++ b/src/game/Hud_UpdatesAll.cpp @@ -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))); diff --git a/src/game/SceneInit.cpp b/src/game/SceneInit.cpp index ef979a8c..2c9cc18d 100644 --- a/src/game/SceneInit.cpp +++ b/src/game/SceneInit.cpp @@ -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(); diff --git a/src/game/Update_Poses.cpp b/src/game/Update_Poses.cpp index cb12bc43..cec400bc 100644 --- a/src/game/Update_Poses.cpp +++ b/src/game/Update_Poses.cpp @@ -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 @@ -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); @@ -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 @@ -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 @@ -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; // ❌