Skip to content

Commit

Permalink
getHudScale fix vel,times in splitscr
Browse files Browse the repository at this point in the history
  • Loading branch information
cryham committed Nov 5, 2024
1 parent 2849a59 commit 1bb7cd8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 30 deletions.
1 change: 1 addition & 0 deletions src/game/CHud.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class CHud : public BGui


// ⛓️ util
float getHudScale();
Txt CreateNickText(int carId, Ogre::String text);
Ogre::Vector3 projectPoint(const Ogre::Camera* cam, const Ogre::Vector3& pos); // 2d xy, z - out info

Expand Down
15 changes: 8 additions & 7 deletions src/game/Hud_Create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ void CHud::Create()


// gear text ----
float f = pSet->font_hud;
float f = pSet->font_hud * getHudScale();

h.parent = app->mGui->createWidget<Widget>("", 0,0, wx, wy,
Align::Left,"Back","main"+s);

Expand Down Expand Up @@ -170,7 +171,7 @@ void CHud::Create()
h.txVel = h.parent->createWidget<TextBox>("TextBox",
0,y, 160*f,72*f, Align::Right, "Vel"+s); h.txVel->setVisible(false);
h.txVel->setFontName("DigGear");
//h.txVel->setFontHeight(64);
h.txVel->setFontHeight(72 * f); //par
//h.txVel->setInheritsAlpha(false);
h.txVel->setTextShadowColour(Colour::Black); h.txVel->setTextShadow(true);

Expand Down Expand Up @@ -235,7 +236,7 @@ void CHud::Create()


/// ⏱️ times text ----------------------
const float t = pSet->font_times;
const float t = pSet->font_times * f; // scale
h.bckTimes = h.parent->createWidget<ImageBox>("ImageBox",
0,y, 320/*420*/*t,220*t, Align::Left, "TimP"+s); h.bckTimes->setVisible(false);
h.bckTimes->setColour(Colour(0.1,0.1,0.1));
Expand All @@ -245,7 +246,7 @@ void CHud::Create()
h.txTimTxt = h.parent->createWidget<TextBox>("TextBox",
0,y, 170*t,260*t, Align::Left, "TimT"+s);
h.txTimTxt->setFontName(hudTimes);
// h.txTimTxt->setFontHeight(32*t);
h.txTimTxt->setFontHeight(32*t);
h.txTimTxt->setTextShadowColour(Colour::Black); h.txTimTxt->setTextShadow(true);
h.txTimTxt->setInheritsAlpha(false);

Expand All @@ -268,7 +269,7 @@ void CHud::Create()
0,y, 240*t,260*t, Align::Left, "Tim"+s);
h.txTimes->setInheritsAlpha(false);
h.txTimes->setFontName(hudTimes);
// h.txTimes->setFontHeight(32);
h.txTimes->setFontHeight(32*t);
h.txTimes->setTextShadow(true);

h.txCollect = h.parent->createWidget<TextBox>("TextBox",
Expand All @@ -289,7 +290,7 @@ void CHud::Create()
h.txLapTxt = h.parent->createWidget<TextBox>("TextBox",
0,y, 120*t,300*t, Align::Left, "LapT"+s);
h.txLapTxt->setFontName(hudTimes);
// h.txLapTxt->setFontHeight(25);
h.txLapTxt->setFontHeight(32*t);
h.txLapTxt->setTextShadow(true);
h.txLapTxt->setInheritsAlpha(false);
h.txLapTxt->setCaption(//String("\n")+
Expand All @@ -305,7 +306,7 @@ void CHud::Create()
0,y, 230*t,320*t, Align::Left, "Lap"+s);
h.txLap->setInheritsAlpha(false);
h.txLap->setFontName(hudTimes);
// h.txLap->setFontHeight(25);
h.txLap->setFontHeight(32*t);
h.txLap->setTextShadow(true);
h.txLap->setVisible(false);

Expand Down
37 changes: 14 additions & 23 deletions src/game/Hud_Size.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ using namespace Ogre;
using namespace MyGUI;


// util
float CHud::getHudScale()
{
const int plr = pSet->game.local_players;
const static float scPlr[6] =
{ 1.f, 0.8f, 0.7f, 0.6f, 0.5f, 0.4f };
return scPlr[plr-1]; // scale down for SplitScreen
}

/// 🗜️ HUD resize
//---------------------------------------------------------------------------------------------------------------
void CHud::Size()
Expand Down Expand Up @@ -111,10 +120,11 @@ void CHud::Size()

// ⏱️ Times
// bool hasLaps = pSet->game.hasLaps();
const float t = pSet->font_times;
int w = 160 * t, tx = xMin + 40, ty = yMin + 55; //40
tx *= t; ty *= t;
h.bckTimes->setPosition(tx-20,ty);
const float t = pSet->font_times * getHudScale();
int w = 160 * t, tx = xMin + 40 * t, ty = yMin + 55 * t; //40
// tx *= t; ty *= t;

h.bckTimes->setPosition(xMin + 20 * t,ty);
//tx = 24; ty = (hasLaps ? 16 : 4);
h.txTimTxt->setPosition(tx,ty);
h.txTimes->setPosition(tx+w,ty); //?-
Expand Down Expand Up @@ -247,22 +257,3 @@ void CHud::Show(bool hideAll)
if (app->mWndRplTxt && !app->bLoading && app->gui->bLesson)
app->mWndRplTxt->setVisible(app->bRplPlay);
}


/*void CHud::ShowVp(bool vp) //?
{
// show/hide for render viewport / gui viewport
// first show everything
Show(false); // todo: don't here
// now hide things we dont want
if (!vp)
{
/// for gui viewport ----------------------
//if (ovCarDbg) ovCarDbg->hide(); if (ovCarDbgTxt) ovCarDbgTxt->hide();
}else{
/// for render viewport ---------
//if (ovCam) ovCam->hide();
//bckFps->setVisible(false);
}
}
*/

0 comments on commit 1bb7cd8

Please sign in to comment.