Skip to content

Commit

Permalink
TweakTireLoad works, Reset btn,
Browse files Browse the repository at this point in the history
TweakTireSave does LoadTires and FillTweakLists
  • Loading branch information
cryham committed Oct 29, 2014
1 parent 9282d4e commit b2eb1e8
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 52 deletions.
54 changes: 27 additions & 27 deletions data/gui/Game.layout
Expand Up @@ -4031,10 +4031,6 @@
<Property key="Caption" value="#{TireEdCommonY}"/>
<Property key="TextColour" value="0.7 0.95 1.0"/>
</Widget>
<Widget type="Button" skin="CheckBox" position="16 184 256 24" name="TE_Reference">
<Property key="Caption" value="#{TireEdReference}"/>
<Property key="TextColour" value="0.7 0.85 0.7"/>
</Widget>

<Widget type="TextBox" skin="TextBox" position="16 276 444 20">
<Property key="Caption" value="#{CarTireVisCircles}"/>
Expand Down Expand Up @@ -4288,47 +4284,65 @@
<Property key="Caption" value="#{Setup}"/>
<Property key="TextColour" value="0.9 1 1.0"/>
</Widget>
<Widget type="EditBox" skin="EditBox" position="160 28 200 32" name="TweakTireSet">
<Widget type="EditBox" skin="EditBox" position="140 28 200 32" name="TweakTireSet">
<Property key="InheritsAlpha" value="false"/>
<Property key="TextColour" value="0.8 0.98 1.0"/>
<Property key="Colour" value="0.7 0.9 0.9"/>
<Property key="Colour" value="0.5 0.7 0.7"/>
</Widget>
<Widget type="TextBox" skin="TextBoxS" position="20 60 480 24" name="TweakTireTxtSaved">
<Property key="InheritsAlpha" value="false"/>
<Property key="TextColour" value="0.8 0.8 1.0"/>
</Widget>
<Widget type="Button" skin="Button" position="380 8 140 26" name="TweakTireSave">
<Widget type="Button" skin="Button" position="380 8 140 32" name="TweakTireSave">
<Property key="InheritsAlpha" value="false"/>
<Property key="Caption" value="#{RplSave}"/>
<Property key="FontName" value="font.small"/>
<Property key="TextColour" value="0.2 1 1"/>
<Property key="Colour" value="0.2 1 1"/>
</Widget>

<Widget type="Button" skin="CheckBox" position="32 120 300 24" name="TE_Reference">
<Property key="Caption" value="#{TireEdReference}"/>
<Property key="TextColour" value="0.7 0.85 0.7"/>
<Property key="FontName" value="font.small"/>
</Widget>
<Widget type="ListBox" skin="ListBox" position="184 180 144 464" name="TweakTiresUser">
<Property key="Colour" value="0.7 1 1"/>
</Widget>
<Widget type="ListBox" skin="ListBox" position="20 180 144 460" name="TweakTiresOrig">
<Property key="Colour" value="0.6 0.8 1"/>
</Widget>
<Widget type="Button" skin="Button" position="348 180 160 32" name="TweakTireLoad">
<Widget type="Button" skin="Button" position="348 180 160 40" name="TweakTireLoad">
<Property key="InheritsAlpha" value="false"/>
<Property key="Caption" value="#{RplLoad}.."/>
<Property key="FontName" value="font.small"/>
<Property key="TextColour" value="1.0 0.9 0.2"/>
<Property key="Colour" value="1.0 0.9 0.1"/>
</Widget>
<!--<Widget type="Button" skin="Button" position="348 232 160 56" name="TweakTireLoadRef">
<Widget type="Button" skin="Button" position="348 366 160 48" name="TweakTireReset">
<Property key="InheritsAlpha" value="false"/>
<Property key="Caption" value="#{RplLoad}"/>
<Property key="Caption" value="#{Reset} #{RplAll}"/>
<Property key="FontName" value="font.small"/>
<Property key="TextColour" value="0.4 1.0 0.2"/>
<Property key="Colour" value="0.3 1.0 0.2"/>
</Widget>-->
<Property key="TextColour" value="1.0 0.7 0.2"/>
<Property key="Colour" value="1.0 0.7 0.2"/>
</Widget>
</Widget>
<Widget type="TabItem" skin="" position="2 24 522 692">
<Property key="Caption" value="#A090FF#{Surface}"/>
<Property key="Colour" value="0.7 0.6 1"/>
<Widget type="ComboBox" skin="ComboBox" position="132 548 132 28" name="CmbSuTire">
<Property key="Colour" value="0.45 0.9 0.9"/>
<Property key="TextColour" value="0.75 1 1.0"/>
<Property key="Static" value="true"/>
<Property key="ReadOnly" value="true"/>
</Widget>
<Widget type="ComboBox" skin="ComboBox" position="132 592 132 28" name="CmbSuType">
<Property key="Colour" value="0.6 0.8 1"/>
<Property key="TextColour" value="0.8 0.9 1"/>
<Property key="Static" value="true"/>
<Property key="ReadOnly" value="true"/>
</Widget>

<Widget type="Button" skin="Button" position="344 80 160 36" name="TweakSurfPickWh">
<Property key="InheritsAlpha" value="false"/>
<Property key="Caption" value="Pick from wheel"/>
Expand Down Expand Up @@ -4465,20 +4479,6 @@
<Property key="Caption" value="#{Tires}"/>
<Property key="TextColour" value="0.5 1 1"/>
</Widget>
<Widget type="ComboBox" skin="ComboBox" position="132 548 132 28" name="CmbSuTire">
<Property key="Static" value="true"/>
<Property key="ReadOnly" value="true"/>
<Property key="Colour" value="0.45 0.9 0.9"/>
<Property key="TextColour" value="0.75 1 1.0"/>
<UserString key="tip" value="#{TipSurfType}"/>
</Widget>
<Widget type="ComboBox" skin="ComboBox" position="132 592 132 28" name="CmbSuType">
<Property key="Static" value="true"/>
<Property key="ReadOnly" value="true"/>
<Property key="Colour" value="0.6 0.8 1"/>
<Property key="TextColour" value="0.8 0.9 1"/>
<UserString key="tip" value="#{TipSurfType}"/>
</Widget>
</Widget>
<Widget type="TabItem" skin="" position="2 24 522 692">
<Property key="Caption" value="#D0D0D0#{Car}#{Test}"/>
Expand Down
2 changes: 1 addition & 1 deletion source/ogre/CGui.h
Expand Up @@ -145,7 +145,7 @@ class CGui : public BGui,
Ed edTweakTireSet; void editTweakTireSet(Ed);
Li liTwkTiresUser, liTwkTiresOrig;
void listTwkTiresUser(Li, size_t), listTwkTiresOrig(Li, size_t);
void btnTweakTireLoad(WP);
void btnTweakTireLoad(WP), btnTweakTireReset(WP);
void FillTweakLists();

/// surface
Expand Down
1 change: 1 addition & 0 deletions source/ogre/Gui_Init.cpp
Expand Up @@ -613,6 +613,7 @@ void CGui::InitGui()
liTwkTiresUser = fLi("TweakTiresUser"); Lev(liTwkTiresUser, TwkTiresUser);
liTwkTiresOrig = fLi("TweakTiresOrig"); Lev(liTwkTiresOrig, TwkTiresOrig);
Btn("TweakTireLoad", btnTweakTireLoad);
Btn("TweakTireReset", btnTweakTireReset);


/// tweak surfaces ----
Expand Down
72 changes: 49 additions & 23 deletions source/ogre/Gui_Tweak.cpp
Expand Up @@ -165,19 +165,33 @@ void CGui::listTwkTiresOrig(Li li, size_t id)
liTwkTiresUser->setIndexSelected(ITEM_NONE);
}

// Load Tire
void CGui::btnTweakTireLoad(WP)
{
// load as current..
if (app->carModels.size() < 1) return;
CAR* pCar = app->carModels[0]->pCar;
if (!pCar) return;

// load as current, from wheel
CARTIRE* tire = pCar->dynamics.GetTire(FRONT_LEFT);
if (!tire) return;

string s, st = tire->name;
size_t id = liTwkTiresUser->getIndexSelected();
if (id != ITEM_NONE)
{

return;
if (id != ITEM_NONE) // user
s = liTwkTiresUser->getItemNameAt(id).substr(7);
else
{ id = liTwkTiresOrig->getIndexSelected();
if (id != ITEM_NONE)
s = liTwkTiresOrig->getItemNameAt(id).substr(7);
}
id = liTwkTiresOrig->getIndexSelected();
if (id != ITEM_NONE)
if (!s.empty())
{
int ti = pGame->tires_map[s]-1; if (ti == -1) return;
*tire = pGame->tires[ti]; // set pars
tire->CalculateSigmaHatAlphaHat();

txtTweakTire->setCaption(TR("#FFFF30#{Loaded}: "+s+" into "+st));
return;
}
}
Expand Down Expand Up @@ -214,7 +228,7 @@ void CGui::FillTweakLists()
}
}

// surfaces
// Surfaces
//-----------------------------------------------------------------------------------------------------------
void CGui::listTwkSurfaces(Li, size_t id)
{
Expand Down Expand Up @@ -269,7 +283,7 @@ void CGui::comboSurfType(Cmb cmb, size_t val)
}


// Tweak collisions
// collisions
//-----------------------------------------------------------------------------------------------------------

void CGui::TweakColSave()
Expand Down Expand Up @@ -340,6 +354,7 @@ void CGui::TweakToggle()
static string lastPath = "";
if (lastPath != path || app->ctrl) // force reload ctrl-alt-Z
{ lastPath = path;

TweakCarLoad();
TweakColLoad();
FillTweakLists();
Expand Down Expand Up @@ -436,27 +451,29 @@ const String CGui::csAlign[18][2] = {
const String CGui::sCommon = "#C8C8F0Pacejka's Magic Formula coeffs\n";


// tweak save car and reload game
// Save Tire
void CGui::TweakTireSave()
{
//TODO: game reload tires, user
// ed car setup, name, load
// jump to section, help on current line
//Nope todos: sliders for vals=
// jump to section-, help on current line=
// ed find text? syntax clr?=

const CARTIRE* tire = app->carModels[0]->pCar->dynamics.GetTire(FRONT_LEFT); //!

txtTweakTire->setCaption("");
if (app->carModels.size() < 1) return;
CAR* pCar = app->carModels[0]->pCar;
if (!pCar) return;

const CARTIRE* tire = app->carModels[0]->pCar->dynamics.GetTire(FRONT_LEFT);
if (!tire) return;
const std::vector <Dbl>& a = tire->lateral, b = tire->longitudinal, c = tire->aligning;
//#define f2s(f) fToStr(f, 4,6);

string file = edTweakTireSet->getCaption();
string pathUserT = PATHMANAGER::CarSimU() + "/" + pSet->game.sim_mode + "/tires/";
PATHMANAGER::CreateDir(pathUserT, pGame->error_output);
file = pathUserT+"/"+file+".tire";
if (PATHMANAGER::FileExists(file))
{
if (txtTweakTire)
{ txtTweakTire->setCaption(TR("#{AlreadyExists}."));
txtTweakTire->setTextColour(Colour(1,0.2,0.2)); }
txtTweakTire->setCaption(TR("#FF3030#{AlreadyExists}."));
return;
}

Expand Down Expand Up @@ -512,9 +529,18 @@ void CGui::TweakTireSave()
fo << "c17="<<c[i++] << " # Vertical shift at load = 0 (Nm) C17\n";
fo << "#---------\n";

if (txtTweakTire)
{ txtTweakTire->setCaption(TR("#{Saved}."));
txtTweakTire->setTextColour(Colour(0.2,1,0.2)); }

//Fill lists, reload sim tires..
txtTweakTire->setCaption(TR("#30FF30#{Saved}."));

// LoadTires in game thread, FillTweakLists after, in render
pGame->reloadSimNeed = true;
//todo: this resets current, load it back..
}


// reset all
void CGui::btnTweakTireReset(WP)
{
pGame->reloadSimNeed = true;
txtTweakTire->setCaption(TR("#FF9030#{Reset}."));
}
6 changes: 6 additions & 0 deletions source/ogre/Gui_Util.cpp
Expand Up @@ -3,6 +3,7 @@
#include "common/Gui_Def.h"
#include "../vdrift/pathmanager.h"
#include "../vdrift/settings.h"
#include "../vdrift/game.h"
#include "CGame.h"
#include "CGui.h"
#include "common/data/CData.h"
Expand Down Expand Up @@ -686,4 +687,9 @@ void CGui::GuiUpdate()
CarListUpd(false);
}

// upd tweak tire save
if (app->pGame->reloadSimDone)
{ app->pGame->reloadSimDone = false;
FillTweakLists();
}
}
10 changes: 9 additions & 1 deletion source/vdrift/game.cpp
Expand Up @@ -37,7 +37,8 @@ GAME::GAME(ostream & info_out, ostream & err_out, SETTINGS* pSettings) :
track(info_out, err_out), /*tracknode(NULL),*/
framerate(1.0 / pSettings->game_fq),
app(NULL),
tire_ref_id(0)
tire_ref_id(0),
reloadSimNeed(0),reloadSimDone(0)
{
track.pGame = this;
carcontrols_local.first = NULL;
Expand Down Expand Up @@ -403,6 +404,13 @@ void GAME::Test()
//----------------------------------------------------------------------------------------------------------------------------
bool GAME::OneLoop(double dt)
{
if (reloadSimNeed)
{ // upd tweak tire save
reloadSimNeed = false;
ReloadSimData();
reloadSimDone = true;
}

PROFILER.beginBlock(" oneLoop");

clocktime += dt; //only for stats
Expand Down
1 change: 1 addition & 0 deletions source/vdrift/game.h
Expand Up @@ -33,6 +33,7 @@ class GAME
bool OneLoop(double dt);

std::string strProfInfo;
bool reloadSimNeed,reloadSimDone; //for tweak tire save

bool ParseArguments(std::list <std::string> & args);
bool InitializeSound();
Expand Down

0 comments on commit b2eb1e8

Please sign in to comment.