16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 18:19:19 +02:00

renderer changes, time and environment window

This commit is contained in:
milek7
2019-03-09 14:18:10 +01:00
parent 748e7b1dda
commit 3693c1660e
30 changed files with 299 additions and 93 deletions

View File

@@ -133,8 +133,10 @@ void ui::map_panel::render_labels(glm::mat4 transform, ImVec2 origin, glm::vec2
for (TDynamicObject *vehicle : simulation::Vehicles.sequence()) {
if (vehicle->Prev() || !vehicle->Mechanik)
continue;
if (vehicle->Mechanik->TrainName().empty())
continue;
std::string label = vehicle->Mechanik->TrainName();
if (label.empty() || label == "none")
label = ToUpper(vehicle->name());
glm::vec4 ndc_pos = transform * glm::vec4(glm::vec3(vehicle->GetPosition()), 1.0f);
if (glm::abs(ndc_pos.x) > 1.0f || glm::abs(ndc_pos.z) > 1.0f)
@@ -144,11 +146,10 @@ void ui::map_panel::render_labels(glm::mat4 transform, ImVec2 origin, glm::vec2
TDynamicObject *veh = vehicle;
const char *desc = vehicle->Mechanik->TrainName().c_str();
ImVec2 textsize = ImGui::CalcTextSize(desc);
ImVec2 textsize = ImGui::CalcTextSize(label.c_str());
ImGui::SetCursorPos(ImVec2(origin.x + gui_pos.x - textsize.x / 2.0f,
origin.y + gui_pos.y - textsize.y / 2.0f));
ImGui::TextUnformatted(desc);
ImGui::TextUnformatted(label.c_str());
}
ImGui::PopStyleColor();

41
widgets/time.cpp Normal file
View File

@@ -0,0 +1,41 @@
#include "stdafx.h"
#include "widgets/time.h"
#include "simulationtime.h"
#include "Globals.h"
ui::time_panel::time_panel()
: ui_panel(LOC_STR(time_window), false)
{
size.x = 450;
}
void ui::time_panel::render_contents()
{
ImGui::SliderFloat(LOC_STR(time_time), &time, 0.0f, 24.0f, "%.1f");
ImGui::SliderInt(LOC_STR(time_yearday), &yearday, 1, 365);
ImGui::SliderFloat(LOC_STR(time_visibility), &fog, 50.0f, 3000.0f, "%.0f");
ImGui::SliderFloat(LOC_STR(time_weather), &overcast, 0.0f, 2.0f, "%.1f");
ImGui::SliderFloat(LOC_STR(time_temperature), &temperature, -20.0f, 40.0f, "%.0f");
if (ImGui::Button(LOC_STR(time_apply))) {
m_relay.post(user_command::setdatetime, (double)yearday, time, 1, 0);
m_relay.post(user_command::setweather, fog, overcast, 1, 0);
m_relay.post(user_command::settemperature, temperature, 0.0, 1, 0);
is_open = false;
}
}
void ui::time_panel::open()
{
auto &data = simulation::Time.data();
time = (float)data.wHour + (float)data.wMinute / 60.0f;
yearday = simulation::Time.year_day();
fog = Global.fFogEnd;
overcast = Global.Overcast;
temperature = Global.AirTemperature;
is_open = true;
}

21
widgets/time.h Normal file
View File

@@ -0,0 +1,21 @@
#include "uilayer.h"
#include "translation.h"
#include "command.h"
namespace ui {
class time_panel : public ui_panel {
command_relay m_relay;
float time;
int yearday;
float fog;
float overcast;
float temperature;
public:
time_panel();
void render_contents() override;
void open();
};
}