Skip to content

Commit

Permalink
completed shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
tritonas00 committed Aug 28, 2021
1 parent 9cc97ec commit 1c292cb
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
44 changes: 41 additions & 3 deletions source/main/gui/panels/GUI_ConsoleWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,27 +81,28 @@ void ConsoleWindow::Draw()
ImGui::Dummy(ImVec2(720.f, 1.f)); // Manually resize width (DearIMGUI bug workaround)
ImGui::Columns(3);
ImGui::SetColumnWidth(0, 230);
ImGui::SetColumnWidth(1, 130);
ImGui::SetColumnWidth(1, 160);
ImGui::SetColumnWidth(2, 400);

this->DrawRowSlider("void scaleTruck()", "game.getCurrentTruck().scaleTruck({})", "Scales the truck", 1.f, 1.5f, scale);
this->DrawRowText("string getTruckName()", "game.log(game.getCurrentTruck().getTruckName())", "Gets the name of the truck");
this->DrawRowText("string getTruckFileName()", "game.log(game.getCurrentTruck().getTruckFileName())", "Gets the name of the truck file");
this->DrawRowText("string getSectionConfig()", "game.log(game.getCurrentTruck().getSectionConfig())", "Gets the name of the loaded section for a truck");
this->DrawRowText("int getTruckType()", "game.log(' ' + game.getCurrentTruck().getTruckType())", "Gets the type of the truck");
this->DrawRowCheckbox("void reset()", "game.getCurrentTruck().reset({})", "Resets the truck", reset, "keep position");
this->DrawRowCheckbox("void reset()", "game.getCurrentTruck().reset({})", "Resets the truck", reset, "Keep position");
this->DrawRowText("void parkingbrakeToggle()", "game.getCurrentTruck().parkingbrakeToggle()", "Toggles the parking brake");
this->DrawRowText("void tractioncontrolToggle()", "game.getCurrentTruck().tractioncontrolToggle()", "Toggles the tracktion control");
this->DrawRowText("void antilockbrakeToggle()", "game.getCurrentTruck().antilockbrakeToggle()", "Toggles the anti-lock brakes");
this->DrawRowText("void beaconsToggle()", "game.getCurrentTruck().beaconsToggle()", "Toggles the beacons");
this->DrawRowText("void toggleCustomParticles()", "game.getCurrentTruck().toggleCustomParticles()", "Toggles the custom particles");
this->DrawRowText("int getNodeCount()", "game.log(' ' + game.getCurrentTruck().getNodeCount())", "Gets the total amount of nodes of the truck");
this->DrawRowCheckbox("float getTotalMass()", "game.log(' ' + game.getCurrentTruck().getTotalMass({}))", "Gets the total mass of the truck", locked, "with locked");
this->DrawRowCheckbox("float getTotalMass()", "game.log(' ' + game.getCurrentTruck().getTotalMass({}))", "Gets the total mass of the truck", locked, "With locked");
this->DrawRowText("int getWheelNodeCount()", "game.log(' ' + game.getCurrentTruck().getWheelNodeCount())", "Gets the total amount of nodes of the wheels of the truck");
ImGui::NextColumn();
this->DrawRowSlider("void setMass()", "game.getCurrentTruck().setMass({})", "Sets the mass of the truck", 1000.f, 10000.f, mass);
this->DrawRowText("bool getBrakeLightVisible()", "game.log(' ' + game.getCurrentTruck().getBrakeLightVisible())", "Returns true if the brake light is enabled");
this->DrawRowInt("bool getCustomLightVisible()", "game.log(' ' + game.getCurrentTruck().getCustomLightVisible({}))", "Returns true if the custom light with the number is enabled", light);
this->DrawRowIntCheckbox("void setCustomLightVisible()", "game.getCurrentTruck().setCustomLightVisible({}, {})", "Enables or disables the custom light", custom_light, visible, "On");
this->DrawRowText("bool getBeaconMode()", "game.log(' ' + game.getCurrentTruck().getBeaconMode())", "Gets the mode of the beacon");
this->DrawRowInt("void setBlinkType()", "game.getCurrentTruck().setBlinkType({})", "Sets the blinking type", blink);
this->DrawRowText("int getBlinkType()", "game.log(' ' + game.getCurrentTruck().getBlinkType())", "Gets the blinking type");
Expand All @@ -114,6 +115,7 @@ void ConsoleWindow::Draw()
this->DrawRowText("vector3 getGForces()", "game.log(' ' + game.getCurrentTruck().getGForces().x + ' ' + game.getCurrentTruck().getGForces().y + ' ' + game.getCurrentTruck().getGForces().z )", "Gets the G-forces that this truck is currently experiencing");
this->DrawRowText("float getRotation()", "game.log(' ' + game.getCurrentTruck().getRotation())", "Gets the current rotation of the vehicle");
this->DrawRowText("vector3 getVehiclePosition()", "game.log(' ' + game.getCurrentTruck().getVehiclePosition().x + ' ' + game.getCurrentTruck().getVehiclePosition().y + ' ' + game.getCurrentTruck().getVehiclePosition().z )", "Gets the current position of the vehicle");
this->DrawRowIntNode("vector3 getNodePosition()", "game.log(' ' + game.getCurrentTruck().getNodePosition({}).x + ' ' + game.getCurrentTruck().getNodePosition({}).y + ' ' + game.getCurrentTruck().getNodePosition({}).z )", "Gets the node position", node, node, node, node);

ImGui::Columns(1); // reset
ImGui::EndMenu();
Expand Down Expand Up @@ -266,4 +268,40 @@ void ConsoleWindow::DrawRowInt(const char* nameStr, std::string codeStr, const c
ImGui::AlignFirstTextHeightToWidgets();
ImGui::Text(descStr);
ImGui::PopID();
}

void ConsoleWindow::DrawRowIntNode(const char* nameStr, std::string codeStr, const char* descStr, int &var_ref, int &node_x, int &node_y, int &node_z)
{
ImGui::PushID(nameStr);
ImGui::NextColumn();
ImGui::AlignFirstTextHeightToWidgets();
if (ImGui::Selectable(nameStr)) { App::GetScriptEngine()->executeString(fmt::format(codeStr, node_x, node_y, node_z)); }
ImGui::NextColumn();
ImGui::AlignFirstTextHeightToWidgets();
ImGui::PushItemWidth(-1);
ImGui::InputInt("", &var_ref, 1, 1);
ImGui::PopItemWidth();
ImGui::NextColumn();
ImGui::AlignFirstTextHeightToWidgets();
ImGui::Text(descStr);
ImGui::PopID();
}

void ConsoleWindow::DrawRowIntCheckbox(const char* nameStr, std::string codeStr, const char* descStr, int &var_ref, bool &on, const char* label)
{
ImGui::PushID(nameStr);
ImGui::NextColumn();
ImGui::AlignFirstTextHeightToWidgets();
if (ImGui::Selectable(nameStr)) { App::GetScriptEngine()->executeString(fmt::format(codeStr, var_ref, on)); }
ImGui::NextColumn();
ImGui::AlignFirstTextHeightToWidgets();
ImGui::PushItemWidth(96);
ImGui::InputInt("", &var_ref, 1, 1);
ImGui::PopItemWidth();
ImGui::SameLine();
ImGui::Checkbox(label, &on);
ImGui::NextColumn();
ImGui::AlignFirstTextHeightToWidgets();
ImGui::Text(descStr);
ImGui::PopID();
}
5 changes: 5 additions & 0 deletions source/main/gui/panels/GUI_ConsoleWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,18 @@ class ConsoleWindow
void DrawRowText(const char* nameStr, std::string codeStr, const char* descStr);
void DrawRowCheckbox(const char* nameStr, std::string codeStr, const char* descStr, bool &var_ref, const char* label);
void DrawRowInt(const char* nameStr, std::string codeStr, const char* descStr, int &var_ref);
void DrawRowIntCheckbox(const char* nameStr, std::string codeStr, const char* descStr, int &var_ref, bool &on, const char* label);
void DrawRowIntNode(const char* nameStr, std::string codeStr, const char* descStr, int &var_ref, int &node_x, int &node_y, int &node_z);

float scale = 1.f;
float mass = 1000.f;
bool reset = false;
bool locked = false;
int light = 1;
int blink = 1;
int node = 1;
bool visible = false;
int custom_light = 1;
};

} // namespace GUI
Expand Down

0 comments on commit 1c292cb

Please # to comment.