feat(Vehicle): Added ability to change position of speedo meter

This commit is contained in:
Yimura 2021-08-03 20:29:54 +02:00
parent 4f29578d15
commit 35d1869d33
3 changed files with 45 additions and 12 deletions

View File

@ -6,10 +6,7 @@ namespace big
{
void looped::vehicle_speedo_meter()
{
static const float x = .9f;
static const float y = .72f;
SpeedoMeter speedo_type = g.vehicle.speedo_meter;
SpeedoMeter speedo_type = g.vehicle.speedo_meter.type;
if (speedo_type == SpeedoMeter::DISABLED || HUD::IS_PAUSE_MENU_ACTIVE() || HUD::IS_WARNING_MESSAGE_ACTIVE() || CAM::IS_SCREEN_FADED_OUT() || CAM::IS_SCREEN_FADING_OUT() || CAM::IS_SCREEN_FADING_IN()) return;
@ -31,20 +28,20 @@ namespace big
break;
}
sprintf(speed, "%*d", 3, (int)veh_speed);
sprintf(speed, "%*d", g.vehicle.speedo_meter.left_side ? 0 : 3, (int)veh_speed);
HUD::SET_TEXT_FONT(2);
HUD::SET_TEXT_SCALE(.9f, .9f);
HUD::SET_TEXT_OUTLINE();
HUD::BEGIN_TEXT_COMMAND_DISPLAY_TEXT("STRING");
HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(speed);
HUD::END_TEXT_COMMAND_DISPLAY_TEXT(x, y + .04f, 1);
HUD::END_TEXT_COMMAND_DISPLAY_TEXT(g.vehicle.speedo_meter.x, g.vehicle.speedo_meter.y + .04f, 1);
HUD::SET_TEXT_FONT(2);
HUD::SET_TEXT_SCALE(.91f, .91f);
HUD::SET_TEXT_OUTLINE();
HUD::BEGIN_TEXT_COMMAND_DISPLAY_TEXT("STRING");
HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(speed_type);
HUD::END_TEXT_COMMAND_DISPLAY_TEXT(x, y, 1);
HUD::END_TEXT_COMMAND_DISPLAY_TEXT(g.vehicle.speedo_meter.x, g.vehicle.speedo_meter.y, 1);
}
}

View File

@ -60,8 +60,17 @@ struct globals {
};
struct vehicle {
struct speedo_meter {
SpeedoMeter type = SpeedoMeter::DISABLED;
float x = .9f;
float y = .72f;
bool left_side = false;
};
bool horn_boost = false;
SpeedoMeter speedo_meter = SpeedoMeter::DISABLED;
speedo_meter speedo_meter{};
};
struct weapons {
@ -127,7 +136,11 @@ struct globals {
this->self.frame_flags.super_jump = j["self"]["frame_flags"]["super_jump"];
this->vehicle.horn_boost = j["vehicle"]["horn_boost"];
this->vehicle.speedo_meter = (SpeedoMeter)j["vehicle"]["speedo_meter"];
this->vehicle.speedo_meter.type = (SpeedoMeter)j["vehicle"]["speedo_meter"]["type"];
this->vehicle.speedo_meter.left_side = j["vehicle"]["speedo_meter"]["left_side"];
this->vehicle.speedo_meter.x = j["vehicle"]["speedo_meter"]["position_x"];
this->vehicle.speedo_meter.y = j["vehicle"]["speedo_meter"]["position_y"];
this->weapons.custom_weapon = (CustomWeapon)j["weapons"]["custom_weapon"];
@ -187,7 +200,14 @@ struct globals {
{
"vehicle", {
{ "horn_boost", this->vehicle.horn_boost },
{ "speedo_meter", (int)this->vehicle.speedo_meter }
{
"speedo_meter", {
{ "type", (int)this->vehicle.speedo_meter.type },
{ "left_side", this->vehicle.speedo_meter.left_side },
{ "position_x", this->vehicle.speedo_meter.x },
{ "position_y", this->vehicle.speedo_meter.y }
}
}
}
},
{

View File

@ -52,15 +52,31 @@ namespace big
if (ImGui::TreeNode("Speedo Meter"))
{
SpeedoMeter selected = g.vehicle.speedo_meter;
SpeedoMeter selected = g.vehicle.speedo_meter.type;
ImGui::Text("Position");
float pos[2];
pos[0] = g.vehicle.speedo_meter.x;
pos[1] = g.vehicle.speedo_meter.y;
if (ImGui::SliderFloat2("###speedo_pos", pos, .001f, .999f, "%.3f"))
{
g.vehicle.speedo_meter.x = pos[0];
g.vehicle.speedo_meter.y = pos[1];
}
ImGui::Checkbox("Left Sided", &g.vehicle.speedo_meter.left_side);
ImGui::Separator();
ImGui::Text("Type:");
if (ImGui::BeginCombo("###speedo_type", speedo_meters[(int)selected].name))
{
for (const speedo_meter &speedo : speedo_meters)
{
if (ImGui::Selectable(speedo.name, speedo.id == selected))
{
g.vehicle.speedo_meter = speedo.id;
g.vehicle.speedo_meter.type = speedo.id;
}
if (speedo.id == selected)