Skip to content

Commit

Permalink
Dashboard mods: added dashboard_category 200=Generic, 201=Truck, 20…
Browse files Browse the repository at this point in the history
…2=Boat
  • Loading branch information
ohlidalp committed Feb 15, 2025
1 parent 024c09b commit 9e03dc9
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 70 deletions.
2 changes: 2 additions & 0 deletions resources/dashboards/default_boat.dashboard
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
; Optional filename tags:
; * '_rpmN' ~ N is the redline RPM
; * '_Xph' ~ X is units (k=Kilometers | m=Miles)
; Categories: 200=Generic, 201=Truck, 202=Boat
; ------------------------------------------------------------

dashboard_name "Default - Boat"
dashboard_description "Default dashboard for boats"
dashboard_category 202
4 changes: 3 additions & 1 deletion resources/dashboards/default_truck_analog.dashboard
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
; Optional filename tags:
; * '_rpmN' ~ N is the redline RPM
; * '_Xph' ~ X is units (k=Kilometers | m=Miles)
; Categories: 200=Generic, 201=Truck, 202=Boat
; ------------------------------------------------------------

dashboard_name "Default - Truck analog"
dashboard_description "Default dashboard with analog speedometer"
dashboard_author "7000 RPM tacho" -1 "Klink"
dashboard_author "7000 RPM tacho" -1 "Klink"
dashboard_category 201
4 changes: 3 additions & 1 deletion resources/dashboards/default_truck_digital.dashboard
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
; Optional filename tags:
; * '_Nrpm' ~ N is the redline RPM
; * '_Xph' ~ X is units (k=Kilometers | m=Miles)
; Categories: 200=Generic, 201=Truck, 202=Boat
; ------------------------------------------------------------

dashboard_name "Default - Truck digital"
dashboard_description "Default dashboard with digital speedometer"
dashboard_author "7000 RPM tacho" -1 "Klink"
dashboard_author "7000 RPM tacho" -1 "Klink"
dashboard_category 201
84 changes: 16 additions & 68 deletions source/main/gui/DashBoardManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,77 +198,23 @@ static char DashXPH(const std::string& input) {

static std::string DashBestRPM(float redlineRPM, const std::string& input1, const std::string& input2)
{
// Find best fit for redline RPM
// -----------------------------
const float rpmdiff1 = (float)DashRPM(input1) - redlineRPM;
const float rpmdiff2 = (float)DashRPM(input2) - redlineRPM;

const float rpm1 = (float)DashRPM(input1);
const float rpm2 = (float)DashRPM(input2);

if (redlineRPM > rpm1 && redlineRPM > rpm2)
{
return (rpm1 > rpm2) ? input1 : input2;
}
else if (redlineRPM > rpm1)
{
return input1;
}
else if (redlineRPM > rpm2)
{
return input2;
}
else
{
return (rpm1 < rpm2) ? input1 : input2;
}
if (rpmdiff1 < 0) return input2;
else if (rpmdiff2 < 0) return input1;
else if (rpmdiff1 < rpmdiff2) return input1;
else return input2;
}

static std::string DashBestXPH(bool imperial, const std::string& input1, const std::string& input2)
static std::string DashBestXPH(char desiredX, const std::string& input1, const std::string& input2)
{
// Find best fit for speedometer unit
// ----------------------------------

const char xph1 = DashXPH(input1);
const char xph2 = DashXPH(input2);

if (imperial)
{
if (xph1 == 'm' && xph2 == 'm')
{
return input1;
}
else if (xph1 == 'm')
{
return input1;
}
else if (xph2 == 'm')
{
return input2;
}
else
{
return input1;
}
}
else
{
if (xph1 == 'k' && xph2 == 'k')
{
return input1;
}
else if (xph1 == 'k')
{
return input1;
}
else if (xph2 == 'k')
{
return input2;
}
else
{
return input1;
}
}
const char x1 = DashXPH(input1);
const char x2 = DashXPH(input2);

if (x1 == desiredX) return input1;
else if (x2 == desiredX) return input2;
else return input1;
}

std::string DashBoardManager::determineLayoutFromDashboardMod(CacheEntryPtr& entry, std::string const& basename)
Expand All @@ -282,8 +228,10 @@ std::string DashBoardManager::determineLayoutFromDashboardMod(CacheEntryPtr& ent
{
if (m_actor->ar_driveable == TRUCK)
{
layout = DashBestRPM(m_actor->ar_engine->getShiftUpRPM(), layout, fileinfo.filename);
layout = DashBestXPH(App::gfx_speedo_imperial->getBool(), layout, fileinfo.filename);
const char desiredX = App::gfx_speedo_imperial->getBool() ? 'm' : 'k';
layout = DashBestXPH(desiredX, layout, fileinfo.filename);
const float redlineRPM = m_actor->ar_engine->getShiftUpRPM();
layout = DashBestRPM(redlineRPM, layout, fileinfo.filename);
}
}
return layout;
Expand Down
4 changes: 4 additions & 0 deletions source/main/gui/panels/GUI_MainSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,10 @@ void MainSelector::UpdateDisplayLists()
query.cqy_search_method = m_search_method;
query.cqy_search_string = m_search_string;
query.cqy_filter_guid = m_filter_guid;
if (m_loader_type == LT_DashBoard) // HACK for dashboards
{
query.cqy_filter_category_id = App::GetGuiManager()->GameSettings.default_dash_being_selected;
}

App::GetCacheSystem()->Query(query);

Expand Down
4 changes: 4 additions & 0 deletions source/main/resources/CacheSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,10 @@ void CacheSystem::FillDashboardDetailInfo(CacheEntryPtr& entry, Ogre::DataStream
{
entry->description = ctx->getTokString(1);
}
else if (ctx->isTokKeyword() && ctx->getTokKeyword() == "dashboard_category" && ctx->isTokInt(1))
{
entry->categoryid = ctx->getTokInt(1);
}
else if (ctx->isTokKeyword() && ctx->getTokKeyword() == "dashboard_author")
{
int n = ctx->countLineArgs();
Expand Down

0 comments on commit 9e03dc9

Please sign in to comment.