mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-23 01:39:19 +02:00
reformat: use auto on certain types
This commit is contained in:
@@ -112,17 +112,17 @@ void ui::cameraview_panel::render_contents()
|
||||
}
|
||||
}
|
||||
|
||||
ImVec2 surface_size = ImGui::GetContentRegionAvail();
|
||||
const ImVec2 surface_size = ImGui::GetContentRegionAvail();
|
||||
ImGui::Image((ImTextureID)(intptr_t)(texture->id), surface_size);
|
||||
}
|
||||
|
||||
void ui::cameraview_panel::capture_func()
|
||||
{
|
||||
std::string cmdline = Global.extcam_cmd;
|
||||
const std::string cmdline = Global.extcam_cmd;
|
||||
|
||||
piped_proc proc(cmdline);
|
||||
|
||||
size_t frame_size = Global.extcam_res.x * Global.extcam_res.y * 3;
|
||||
const size_t frame_size = Global.extcam_res.x * Global.extcam_res.y * 3;
|
||||
auto read_buffer = new uint8_t[frame_size];
|
||||
auto active_buffer = new uint8_t[frame_size];
|
||||
|
||||
@@ -165,15 +165,15 @@ void ui::cameraview_panel::record_func()
|
||||
|
||||
if (!rec_name.empty()) {
|
||||
const std::string magic{"{RECORD}"};
|
||||
size_t pos = cmdline.find(magic);
|
||||
const size_t pos = cmdline.find(magic);
|
||||
if (pos != -1)
|
||||
cmdline.replace(pos, magic.size(), rec_name);
|
||||
}
|
||||
|
||||
piped_proc proc(cmdline, true);
|
||||
|
||||
size_t frame_size = Global.extcam_res.x * Global.extcam_res.y * 3;
|
||||
auto read_buffer = new uint8_t[frame_size];
|
||||
const size_t frame_size = Global.extcam_res.x * Global.extcam_res.y * 3;
|
||||
const auto read_buffer = new uint8_t[frame_size];
|
||||
uint32_t last_cnt = 0;
|
||||
size_t bufpos = frame_size;
|
||||
|
||||
@@ -182,7 +182,7 @@ void ui::cameraview_panel::record_func()
|
||||
if (bufpos == frame_size)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mutex);
|
||||
auto r = notify_var.wait_for(lock, std::chrono::milliseconds(50), [this, last_cnt]{return last_cnt != frame_cnt;});
|
||||
const auto r = notify_var.wait_for(lock, std::chrono::milliseconds(50), [this, last_cnt]{return last_cnt != frame_cnt;});
|
||||
last_cnt = frame_cnt;
|
||||
if (!image_ptr || !r)
|
||||
continue;
|
||||
|
||||
@@ -544,7 +544,7 @@ ui::track_switch_window::track_switch_window(ui_panel &panel, std::shared_ptr<ma
|
||||
bool ui::track_switch_window::render()
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f);
|
||||
bool ret = popup::render();
|
||||
const bool ret = popup::render();
|
||||
ImGui::PopStyleVar();
|
||||
return ret;
|
||||
}
|
||||
@@ -557,7 +557,7 @@ void ui::track_switch_window::render_content()
|
||||
|
||||
highlight.clear();
|
||||
|
||||
std::array<std::string, 4> names = { "ac", "ad", "bc", "bd" };
|
||||
const std::array<std::string, 4> names = { "ac", "ad", "bc", "bd" };
|
||||
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
if (m_switch->action[i]) {
|
||||
@@ -661,19 +661,19 @@ void ui::vehicle_click_window::render_content()
|
||||
ImGui::TextUnformatted(STR_C("Light signal:"));
|
||||
|
||||
if (ImGui::Button(STR_C("none"))) {
|
||||
std::string name = m_vehicle->name + "%SetSignal";
|
||||
const std::string name = m_vehicle->name + "%SetSignal";
|
||||
m_relay.post(user_command::sendaicommand, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(), &name);
|
||||
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
if (ImGui::Button(STR_C("Pc6"))) {
|
||||
std::string name = m_vehicle->name + "%SetSignal";
|
||||
const std::string name = m_vehicle->name + "%SetSignal";
|
||||
m_relay.post(user_command::sendaicommand, Signal_Pc6, 1.0, GLFW_PRESS, 0, glm::vec3(), &name);
|
||||
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
if (ImGui::Button(STR_C("A1"))) {
|
||||
std::string name = m_vehicle->name + "%SetSignal";
|
||||
const std::string name = m_vehicle->name + "%SetSignal";
|
||||
m_relay.post(user_command::sendaicommand, Signal_A1, 1.0, GLFW_PRESS, 0, glm::vec3(), &name);
|
||||
|
||||
ImGui::CloseCurrentPopup();
|
||||
@@ -701,7 +701,7 @@ void ui::vehicle_click_window::render_content()
|
||||
ImGui::InputInt(STR_C("Param 1"), &command_param1);
|
||||
ImGui::InputInt(STR_C("Param 2"), &command_param2);
|
||||
if (ImGui::Button(STR_C("Send"))) {
|
||||
std::string name = m_vehicle->name + "%" + std::string(command_buf.data());
|
||||
const std::string name = m_vehicle->name + "%" + std::string(command_buf.data());
|
||||
m_relay.post(user_command::sendaicommand, command_param1, command_param2, GLFW_PRESS, 0, glm::vec3(), &name);
|
||||
|
||||
ImGui::CloseCurrentPopup();
|
||||
|
||||
@@ -30,7 +30,7 @@ struct semaphore : public map_object
|
||||
TMemCell *memcell = nullptr;
|
||||
|
||||
virtual gfx::basic_vertex vertex() override {
|
||||
bool stop_signal = memcell->IsVelocity() && (memcell->Value1() == 0.0);
|
||||
const bool stop_signal = memcell->IsVelocity() && (memcell->Value1() == 0.0);
|
||||
return gfx::basic_vertex(location, glm::vec3(),
|
||||
(!stop_signal) ? glm::vec2(0.0f, 0.2f) : glm::vec2(0.2f, 0.4f));
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ void perfgraph_panel::render_contents() {
|
||||
{
|
||||
for (size_t i = 0; i < (size_t)TIMER_MAX; i++)
|
||||
{
|
||||
bool is_selected = (current_timer == (timers_e)i);
|
||||
const bool is_selected = (current_timer == (timers_e)i);
|
||||
if (ImGui::Selectable(timer_label[i].c_str(), is_selected))
|
||||
current_timer = (timers_e)i;
|
||||
if (is_selected)
|
||||
@@ -19,7 +19,7 @@ void perfgraph_panel::render_contents() {
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
Timer::stopwatch *stopwatch = nullptr;
|
||||
const Timer::stopwatch *stopwatch = nullptr;
|
||||
|
||||
if (current_timer == gfx_total)
|
||||
stopwatch = &Timer::subsystem.gfx_total;
|
||||
|
||||
@@ -26,7 +26,7 @@ void ui::time_panel::render_contents()
|
||||
|
||||
void ui::time_panel::open()
|
||||
{
|
||||
auto &data = simulation::Time.data();
|
||||
const auto &data = simulation::Time.data();
|
||||
time = (float)data.wHour + (float)data.wMinute / 60.0f;
|
||||
|
||||
yearday = simulation::Time.year_day();
|
||||
|
||||
@@ -91,7 +91,7 @@ void trainingcard_panel::render_contents()
|
||||
if (ImGui::BeginPopupModal("Zapisywanie danych"))
|
||||
{
|
||||
ImGui::SetWindowSize(ImVec2(-1, -1));
|
||||
int s = state.load();
|
||||
const int s = state.load();
|
||||
|
||||
if (s == 1)
|
||||
{
|
||||
@@ -121,8 +121,8 @@ void trainingcard_panel::render_contents()
|
||||
|
||||
if (start_time_wall)
|
||||
{
|
||||
std::tm *tm = std::localtime(&(*start_time_wall));
|
||||
std::string rep = "Czas rozpoczęcia: " + std::to_string(tm->tm_year + 1900) + "-" + std::to_string(tm->tm_mon + 1) + "-" + std::to_string(tm->tm_mday) + " " + std::to_string(tm->tm_hour) +
|
||||
const std::tm *tm = std::localtime(&(*start_time_wall));
|
||||
const std::string rep = "Czas rozpoczęcia: " + std::to_string(tm->tm_year + 1900) + "-" + std::to_string(tm->tm_mon + 1) + "-" + std::to_string(tm->tm_mday) + " " + std::to_string(tm->tm_hour) +
|
||||
":" + std::to_string(tm->tm_min);
|
||||
ImGui::TextUnformatted(rep.c_str());
|
||||
}
|
||||
@@ -159,11 +159,11 @@ void trainingcard_panel::render_contents()
|
||||
if (ImGui::Button("Rozpocznij szkolenie"))
|
||||
{
|
||||
start_time_wall = std::time(nullptr);
|
||||
std::tm *tm = std::localtime(&(*start_time_wall));
|
||||
const std::tm *tm = std::localtime(&(*start_time_wall));
|
||||
recording_timestamp = std::to_string(tm->tm_year + 1900) + std::to_string(tm->tm_mon + 1) + std::to_string(tm->tm_mday) + std::to_string(tm->tm_hour) + std::to_string(tm->tm_min) + "_" +
|
||||
std::string(trainee_name.c_str()) + "_" + std::string(instructor_name.c_str());
|
||||
|
||||
int ret = StartRecording();
|
||||
const int ret = StartRecording();
|
||||
if (ret != 1)
|
||||
{
|
||||
state.store(ret);
|
||||
|
||||
@@ -12,7 +12,7 @@ ui::vehiclelist_panel::vehiclelist_panel(ui_layer &parent)
|
||||
void ui::vehiclelist_panel::render_contents()
|
||||
{
|
||||
if (m_first_show && Global.gui_trainingdefault) {
|
||||
for (TDynamicObject *vehicle : simulation::Vehicles.sequence())
|
||||
for (const TDynamicObject *vehicle : simulation::Vehicles.sequence())
|
||||
{
|
||||
if (!vehicle->Mechanik || vehicle->name() != ToLower(Global.local_start_vehicle))
|
||||
continue;
|
||||
@@ -26,13 +26,13 @@ void ui::vehiclelist_panel::render_contents()
|
||||
return;
|
||||
}
|
||||
|
||||
for (TDynamicObject *vehicle : simulation::Vehicles.sequence())
|
||||
for (const TDynamicObject *vehicle : simulation::Vehicles.sequence())
|
||||
{
|
||||
if (!vehicle->Mechanik)
|
||||
continue;
|
||||
|
||||
std::string name = vehicle->name();
|
||||
double speed = vehicle->GetVelocity();
|
||||
const double speed = vehicle->GetVelocity();
|
||||
std::string timetable;
|
||||
if (vehicle->Mechanik)
|
||||
timetable = vehicle->Mechanik->TrainName() + ", ";
|
||||
|
||||
@@ -12,7 +12,7 @@ ui::vehicleparams_panel::vehicleparams_panel(const std::string &vehicle) : ui_pa
|
||||
|
||||
void screen_window_callback(ImGuiSizeCallbackData *data)
|
||||
{
|
||||
auto config = static_cast<const global_settings::pythonviewport_config *>(data->UserData);
|
||||
const auto config = static_cast<const global_settings::pythonviewport_config *>(data->UserData);
|
||||
data->DesiredSize.y = data->DesiredSize.x * (float)config->size.y / (float)config->size.x;
|
||||
}
|
||||
|
||||
@@ -20,11 +20,11 @@ void ui::vehicleparams_panel::draw_infobutton(const char *str, ImVec2 pos, const
|
||||
{
|
||||
if (pos.x != -1.0f)
|
||||
{
|
||||
ImVec2 window_size = ImGui::GetWindowSize();
|
||||
const ImVec2 window_size = ImGui::GetWindowSize();
|
||||
|
||||
ImGuiStyle &style = ImGui::GetStyle();
|
||||
ImVec2 text_size = ImGui::CalcTextSize(str);
|
||||
auto button_size = ImVec2(text_size.x + style.FramePadding.x * 2.0f, text_size.y + style.FramePadding.y * 2.0f);
|
||||
const ImGuiStyle &style = ImGui::GetStyle();
|
||||
const ImVec2 text_size = ImGui::CalcTextSize(str);
|
||||
const auto button_size = ImVec2(text_size.x + style.FramePadding.x * 2.0f, text_size.y + style.FramePadding.y * 2.0f);
|
||||
|
||||
pos.x = pos.x * window_size.x / 512.0f - button_size.x / 2.0f;
|
||||
pos.y = pos.y * window_size.y / 118.0f - button_size.y / 2.0f;
|
||||
@@ -54,9 +54,9 @@ void ui::vehicleparams_panel::draw_mini(const TMoverParameters &mover)
|
||||
auto &tex = GfxRenderer->Texture(vehicle_mini);
|
||||
tex.create();
|
||||
|
||||
ImVec2 size = ImGui::GetContentRegionAvail();
|
||||
float x = size.x;
|
||||
float y = x * ((float)tex.get_height() / tex.get_width());
|
||||
const ImVec2 size = ImGui::GetContentRegionAvail();
|
||||
const float x = size.x;
|
||||
const float y = x * ((float)tex.get_height() / tex.get_width());
|
||||
|
||||
if (ImGui::BeginChild("mini", ImVec2(x, y)))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user