Skip to content

Commit

Permalink
gui sld, cfg, paint filter
Browse files Browse the repository at this point in the history
  • Loading branch information
cryham committed Nov 18, 2024
1 parent 55213f0 commit ea3d22c
Show file tree
Hide file tree
Showing 13 changed files with 147 additions and 68 deletions.
33 changes: 28 additions & 5 deletions data/gui/Game.layout
Original file line number Diff line number Diff line change
Expand Up @@ -1251,23 +1251,46 @@
</Widget> <!-- panel -->


<!-- paint rate -->
<Widget type="ImageBox" skin="ImageBox" position="140 14 20 20">
<!-- paint filter all -->
<Widget type="ImageBox" skin="ImageBox" position="140 2 20 20">
<Property key="ImageTexture" value="gui_icons.png"/>
<Property key="ImageCoord" value="640 896 128 128"/>
<Property key="Alpha" value="0.6"/>
<UserString key="tip" value="#{TerFilter} - #{user}: #{rating}"/>
</Widget>
<Widget type="TextBox" skin="TextBox" position="164 4 16 16" name="PaintFilterVal">
<Property key="Caption" value="5"/>
<Property key="TextColour" value="0.6 0.8 1"/>
<UserString key="tip" value="#{TerFilter} - #{user}: #{rating}"/>
</Widget>
<Widget type="Slider" skin="Slider" position="182 6 70 12" name="PaintFilter">
<Property key="Colour" value="0.6 1 1"/>
<UserString key="tip" value="#{TerFilter} - #{user}: #{rating}"/>
</Widget>
<Widget type="TextBox" skin="TextBox" position="256 4 66 16" name="PaintFilterTxt">
<Property key="TextColour" value="0.6 0.5 0.7"/>
<UserString key="tip" value="#{TerFilter} % - #{user}: #{rating}"/>
<Property key="FontName" value="font.small"/>
</Widget>

<!-- paint rate cur -->
<Widget type="ImageBox" skin="ImageBox" position="140 20 20 20">
<Property key="ImageTexture" value="track_icons.png"/>
<Property key="ImageCoord" value="288 32 32 32"/>
<Property key="Alpha" value="0.6"/>
<UserString key="tip" value="#{user}: #{rating}"/>
</Widget>
<Widget type="TextBox" skin="TextBox" position="164 16 16 16" name="PaintRateVal">
<Widget type="TextBox" skin="TextBox" position="164 22 16 16" name="PaintRateVal">
<Property key="Caption" value="5"/>
<Property key="TextColour" value="0.6 0.8 1"/>
<UserString key="tip" value="#{user}: #{rating}"/>
<Property key="FontName" value="font.small"/>
</Widget>
<Widget type="Slider" skin="Slider" position="182 18 70 12" name="PaintRate">
<Widget type="Slider" skin="Slider" position="182 24 70 12" name="PaintRate">
<Property key="Colour" value="0.6 1 1"/>
<UserString key="tip" value="#{user}: #{rating}"/>
</Widget>

<!-- Random -->
<Widget type="Button" skin="Button" position="12 352 346 24" name="PaintRandom">
<Property key="Caption" value="#{CarClrRandom}"/>
Expand Down
3 changes: 3 additions & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ WIP means work in progress, unfinished, still being developed.
- Apply buttons work for Shadows and Reflections
- WIP try, Global Illumination ([GI methods](https://ogrecave.github.io/ogre-next/api/latest/_gi_methods.html): IFD+VCT), no terrain
- new Gui tab Advanced after Effects, has also debug visuals
- Game
- Setup - Paints tab has filter, to show paints only from filter rating and above
but editing paints list must be done w/o filter, on highest value

### Version 3.2 - 23.09.2024

Expand Down
3 changes: 3 additions & 0 deletions docs/Roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ More in [Tasks tracker](https://stuntrally.tuxfamily.org/mantis/view_all_bug_pag

Marked: `crucial`, **Next or Big**, _Important_.


----
### 🪄 Effects

**HDR**, bloom
lens flare [shaders](https://www.shadertoy.com/results?query=lens+flare)
sunrays [shaders](https://www.shadertoy.com/results?query=tag%3Dgodrays)
**Soft** Particles
old motion blur


### 🔉 Sound

Expand Down
2 changes: 1 addition & 1 deletion src/common/GuiCom_Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void CGuiCom::ReInitGuiRSrest()
170, y, 220, 22, Align::Center, "RSc"+toStr(y));
cb->setTextColour(Colour(0.6,0.8,1.0));
cb->setColour(Colour(0.6,0.8,1.0));
cb->setEditReadOnly(true);
cb->setEditReadOnly(true); cb->setComboModeDrop(true);
setOrigPos(cb, "OptionsWnd");
vwGuiRS.push_back(cb);

Expand Down
2 changes: 1 addition & 1 deletion src/common/Gui_Def.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class BGui


// combo _ mode true = no edit, click drops | cmb->setMaxListLength(530);
#define Cmb(cmb, name, event) \
#define Cmb(cmb, name, event) \
cmb = fCmb(name); \
if (cmb) { cmb->setComboModeDrop(true); \
if (cmb->eventComboChangePosition.empty()) cmb->eventComboChangePosition += newDelegate(this, &CGui::event); }
Expand Down
4 changes: 2 additions & 2 deletions src/game/CGui.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ class CGui : public BGui
WP panPaintAdj =0, panPaintHSV =0, panPaintMix =0;
CK(PaintNewLine);

SV svPaintType, svPaintRate;
SlV(PaintType); SlV(PaintRate);
SlV(PaintFilter); Txt txPaintFilter =0;
Tab tbColorType =0; void tabColorType(Tab, size_t);
void slPaintType(SV*), slPaintRate(SV*);

SV svPaintH, svPaintS, svPaintV; // h s v sliders
SV svPaintGloss, svPaintRough, svPaintFresnel; // pbs
Expand Down
2 changes: 2 additions & 0 deletions src/game/Gui_Init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,8 @@ void CGui::InitGui()
if (valLocPlayers)
valLocPlayers->setCaption(toStr(pSet->gui.local_players));

sv= &svNumLaps; sv->Init("NumLaps", &pSet->gui.num_laps, 1,10, 1.3f); sv->DefaultI(2);


// 🆕 Startup ------------------------------------------------------------
// ck= &ckShowPics; ck->Init("ShowPictures",&pSet->loadingbackground);
Expand Down
7 changes: 4 additions & 3 deletions src/game/Gui_InitCar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void CGui::InitGuiCar()
imgPaint = fImg("ImgPaint"); imgPaintCur = fImg("ImgPaintCur");
txPaintRgb = fTxt("txPaintRgb");
sv= &svPaintRate; sv->Init("PaintRate", &i, 0, 3); Sev(PaintRate);
sv= &svPaintFilter; sv->Init("PaintFilter", &i, 0, 3); Sev(PaintRate);

sv= &svPaintType; sv->strMap[0] = TR("#{P_1color}");
sv->strMap[1] = TR("#{P_2colors}"); sv->strMap[2] = TR("#{P_3colors}");
Expand Down Expand Up @@ -100,16 +101,16 @@ void CGui::InitGuiCar()
SldUpd_TireSet();


/// 🚗 Car
/// 🚗 Car Paint
//------------------------------------------------------------
tbPlrPaint = fTbi("PlrPaints");
scvPaints = fScv("scvPaints");
UpdPaintImgs();
Btn("PaintRandom", btnPaintRandom); //btPaintRandom = btn;
Btn("PaintSave", btnPaintSave); Btn("PaintAdd", btnPaintAdd); Btn("PaintDel", btnPaintDel);
Btn("PaintLoad", btnPaintLoad); Btn("PaintLoadDef", btnPaintLoadDef);

sv= &svNumLaps; sv->Init("NumLaps", &pSet->gui.num_laps, 1,10, 1.3f); sv->DefaultI(2);
sv= &svPaintFilter; sv->Init("PaintFilter", &pSet->paint_filter, 0,3); sv->DefaultI(1); Sev(PaintFilter);
txPaintFilter = fTxt("PaintFilterTxt");

// car stats
for (i=0; i < iCarSt; ++i)
Expand Down
153 changes: 99 additions & 54 deletions src/game/Gui_Paints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void CGui::imgBtnPaint(WP img)
auto& c = pSet->car_clr;
auto i = s2i(img->getUserString("i"));

auto& v = data->paints->v;
auto& v = data->paints->vf;
int si = v.size();
if (c >= si) c = -1; //return; }
if (i < 0 || i >= si) return;
Expand Down Expand Up @@ -247,7 +247,7 @@ void CGui::btnPaintRandom(WP)
// 🎨 pick random from list
if (!pSet->paintAdj)
{
auto& v = data->paints->v;
auto& v = data->paints->vf;
int si = v.size() - 1;
pSet->car_clr = Math::RangeRandom(0, si);
pSet->gui.clr[i] = v[pSet->car_clr];
Expand Down Expand Up @@ -306,6 +306,12 @@ void CGui::btnPaintLoad(WP)
}

// upd all
void CGui::slPaintFilter(SV*)
{
UpdPaints();
UpdPaintImgs();
}

void CGui::slPaintRate(SV*)
{
// todo: drag freezes
Expand Down Expand Up @@ -356,7 +362,7 @@ void CGui::UpdPaintImgs()
{
Ogre::Timer ti;
auto* p = data->paints;
const int all = p->v.size(),
const int //all = p->v.size(),
clrRow = p->perRow, sx = p->imgSize;

// destroy old
Expand Down Expand Up @@ -393,6 +399,33 @@ void CGui::UpdPaintImgs()
return img;
};

// pepass filter, fills vf
p->vf.clear();
const int all1 = p->v.size();
std::string group, old_group; // gui txt title
bool new_line = false; // gui
group = ""; old_group = "";

for (int i=0; i < all1; ++i)
{
auto cl = p->v[i];
bool add = cl.rate >= pSet->paint_filter;

if (!cl.group.empty())
group = cl.group;

if (add)
{
if (old_group != group)
cl.group = group;
else
cl.group = "";

p->vf.push_back(cl);
old_group = group;
}
}

// Grid palette --------------------
int x = 0, y = 0, x0 = 5, y0 = 5;
int px = x0, py = y0, rmax = 0; // pos
Expand All @@ -401,15 +434,20 @@ void CGui::UpdPaintImgs()
x = 0; px = x0;
++y; py += sx + 6 + 2*rmax/3; rmax = 0;
};

const int all = p->vf.size();
for (int i=0; i < all; ++i)
{
auto& cl = p->v[i];
auto cl = p->vf[i];
const int r = cl.rate * 6;
rmax = max(rmax, r);

// group text ----
// group text ------
if (!cl.group.empty())
{
if (px != x0)
inc_y();

Txt txt = scv->createWidget<TextBox>("TextBox",
px, py+6,
320, sx, Align::Left);
Expand All @@ -425,63 +463,70 @@ void CGui::UpdPaintImgs()
inc_y();
}

// create clr img 1..3 ------
Img img = 0, im2 = 0, im3 = 0;
switch (cl.type)
{
case CP_OneClr:
img = AddImg(scv, r,1, px,py, sx-1,sx-1, 0, 1, &cl.clr[0]);
break;

case CP_DiffSpec:
{
int p2 = 8 *sx/32, s2 = 24 *sx/32;
img = AddImg(scv, r,1, px,py, sx-1,sx-1, 0, 1, &cl.clr[0]);
im2 = AddImg(img, r,0, p2, 0, sx-1,sx-1, 3, 0, &cl.clr[1]);
} break;

case CP_3Clrs:
{ int p2 = 0 *sx/32, s2 = 33 *sx/32;
int p3 = 14 *sx/32, s3 = 20 *sx/32;
float m = min(1.f, cl.paintMulAll / 0.3f);
img = AddImg(scv, r,1, px,py, sx-1,sx-1, 0, 1, &cl.paints[2], m);
im2 = AddImg(img, r,0, p2,p2, s2,s2, 3, 0, &cl.paints[1]);
im3 = AddImg(img, r,0, p3,p3, s3,s3, 3, 0, &cl.paints[0]);
} break;
}
cl.y = py;

// shine rough * ` ----
int s1 = cl.rough * 2.5f * sx + 2; s1 = min(64, s1); // 32
im2 = AddImg(img, r,0, 0,0, s1,s1, 1, 0, 0);

float a = cl.gloss * cl.clear_coat * 2.f; a = min(1.f, a);
im2->setAlpha(a);
// if (!cl.one_clr) // own spec
// img2->setColour(cl.clr[1]);

// bool add = cl.rate >= pSet->paint_filter;
// if (add)
{ //++ady;
// create clr img 1..3 ------
Img img = 0, im2 = 0, im3 = 0;
switch (cl.type)
{
case CP_OneClr:
img = AddImg(scv, r,1, px,py, sx-1,sx-1, 0, 1, &cl.clr[0]);
break;

case CP_DiffSpec:
{
int p2 = 8 *sx/32, s2 = 24 *sx/32;
img = AddImg(scv, r,1, px,py, sx-1,sx-1, 0, 1, &cl.clr[0]);
im2 = AddImg(img, r,0, p2, 0, sx-1,sx-1, 3, 0, &cl.clr[1]);
} break;

case CP_3Clrs:
{ int p2 = 0 *sx/32, s2 = 33 *sx/32;
int p3 = 14 *sx/32, s3 = 20 *sx/32;
float m = min(1.f, cl.paintMulAll / 0.3f);
img = AddImg(scv, r,1, px,py, sx-1,sx-1, 0, 1, &cl.paints[2], m);
im2 = AddImg(img, r,0, p2,p2, s2,s2, 3, 0, &cl.paints[1]);
im3 = AddImg(img, r,0, p3,p3, s3,s3, 3, 0, &cl.paints[0]);
} break;
}
cl.y = py;

// shine rough * ` ----
int s1 = cl.rough * 2.5f * sx + 2; s1 = min(64, s1); // 32
im2 = AddImg(img, r,0, 0,0, s1,s1, 1, 0, 0);

float a = cl.gloss * cl.clear_coat * 2.f; a = min(1.f, a);
im2->setAlpha(a);
// if (!cl.one_clr) // own spec
// img2->setColour(cl.clr[1]);

a = 1.f - cl.rough * 0.5f;
// img->setAlpha(a); // *

// gui main ----
img->eventMouseButtonClick += newDelegate(this, &CGui::imgBtnPaint);

img->setUserString("i", toStr(i));
img->setUserString("tip", toStr(i)+"\n"+TR("#{TipCarColor}"));
img->setNeedToolTip(true);
img->eventToolTip += newDelegate(gcom, &CGuiCom::notifyToolTip);

imgsPaint.push_back(img);
a = 1.f - cl.rough * 0.5f;
// img->setAlpha(a); // *

// gui main ----
img->eventMouseButtonClick += newDelegate(this, &CGui::imgBtnPaint);

img->setUserString("i", toStr(i));
img->setUserString("tip", toStr(i)+"\n"+TR("#{TipCarColor}"));
img->setNeedToolTip(true);
img->eventToolTip += newDelegate(gcom, &CGuiCom::notifyToolTip);

imgsPaint.push_back(img);

// inc pos ---
++x; px += sx + r;
// inc pos ---
++x; px += sx + r;
}
if (x >= clrRow || cl.new_line)
inc_y();
}
if (bGI) // resize
gcom->doSizeGUI(tbPlrPaint->getEnumerator());

float fp = 100.f * all / all1;
if (txPaintFilter)
txPaintFilter->setCaption(fToStr(fp,0) + "%");

UpdPaintCur();
LogO(String(":::* Time upd Paints: ") + fToStr(ti.getMilliseconds(),0,3) + " ms");
Expand Down
2 changes: 1 addition & 1 deletion src/game/Gui_Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ void CGui::LNext(int rel)

case TAB_Setup: // Paints
auto& c = pSet->car_clr;
auto& v = data->paints->v;
auto& v = data->paints->vf;
int si = v.size();
c = (c + rel + si) % si;
pSet->gui.clr[iCurCar] = v[c];
Expand Down
2 changes: 1 addition & 1 deletion src/game/PaintsIni.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const int MaxPaints = 990; // par max ini
class PaintsIni
{
public:
std::vector<CarPaint> v;
std::vector<CarPaint> v, vf; // orig from ini and filtered
int perRow = 12, imgSize = 18; // gui params

//------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/game/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ void SETTINGS::Serialize(bool w, CONFIGFILE & c)
Param(c,w, "gui.champ_tab", champ_type); Param(c,w, "gui.champ_info", champ_info);
Param(c,w, "gui.chall_tab", chall_type); Param(c,w, "gui.collect_tab", collect_type);
Param(c,w, "gui.car_clr", car_clr);
Param(c,w, "gui.paint_filter", paint_filter);
// 🎚️ hud size
Param(c,w, "hud_size.gauges", size_gauges); Param(c,w, "hud_size.arrow", size_arrow);
Param(c,w, "hud_size.minimap", size_minimap); Param(c,w, "hud_size.minipos", size_minipos);
Expand Down
1 change: 1 addition & 0 deletions src/game/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class SETTINGS : public SETcom
bool champ_info =1;
int car_ed_tab = 0, tweak_tab = 0; // gui only
int car_clr = -1; // paints.ini id
int paint_filter = 0; // low

// 🪟 font, hud
float font_hud = 1.f; // scales
Expand Down

0 comments on commit ea3d22c

Please sign in to comment.