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

reformat: use auto on certain types

This commit is contained in:
jerrrrycho
2026-07-04 05:22:52 +02:00
parent f61068ff89
commit 20e7a99516
118 changed files with 2118 additions and 2063 deletions

View File

@@ -209,8 +209,8 @@ void eu07_application::DiscordRPCService()
Discord_Initialize(discord_app_id, &handlers, 1, nullptr);
// calculate startup timestamp
auto now = std::chrono::system_clock::now();
auto now_c = std::chrono::system_clock::to_time_t(now);
const auto now = std::chrono::system_clock::now();
const auto now_c = std::chrono::system_clock::to_time_t(now);
// Init RPC object
static DiscordRichPresence discord_rpc;
@@ -221,7 +221,7 @@ void eu07_application::DiscordRPCService()
// run loop
while (!glfwWindowShouldClose(m_windows.front()) && !m_modestack.empty() && !Global.applicationQuitOrder)
{
auto currentMode = m_modestack.top();
const auto currentMode = m_modestack.top();
if (currentMode == mode::launcher)
{
// in launcher mode
@@ -278,7 +278,7 @@ void eu07_application::DiscordRPCService()
PlayerVehicle = Translations.lookup_s("Driving: ") + PlayerVehicle;
discord_rpc.details = PlayerVehicle.c_str();
uint16_t playerTrainVelocity = simulation::Train->Dynamic()->GetVelocity();
const uint16_t playerTrainVelocity = simulation::Train->Dynamic()->GetVelocity();
if (playerTrainVelocity > 1)
{
// ikonka ze jedziemy i nie spimy
@@ -444,7 +444,7 @@ void eu07_application::queue_quit(bool direct)
return;
}
command_relay relay;
const command_relay relay;
relay.post(user_command::quitsimulation, 0.0, 0.0, GLFW_PRESS, 0);
}
@@ -483,7 +483,7 @@ int eu07_application::run()
//
// trivia: being client and server is possible
double frameStartTime = Timer::GetTime();
const double frameStartTime = Timer::GetTime();
if (m_modes[m_modestack.top()]->is_command_processor())
{
@@ -512,7 +512,7 @@ int eu07_application::run()
auto frame_info = m_network->client->get_next_delta(MAX_NETWORK_PER_FRAME - loop_remaining);
// use delta and commands received from master
double delta = std::get<0>(frame_info);
const double delta = std::get<0>(frame_info);
Timer::set_delta_override(delta);
slave_sync = std::get<1>(frame_info);
add_to_dequemap(commands_to_exec, std::get<2>(frame_info));
@@ -542,14 +542,14 @@ int eu07_application::run()
// update continuous commands
simulation::Commands.update();
double sync = generate_sync();
const double sync = generate_sync();
// if we're the server
if (m_network && m_network->servers)
{
// send delta, sync, and commands we just executed to clients
double delta = Timer::GetDeltaTime();
double render = Timer::GetDeltaRenderTime();
const double delta = Timer::GetDeltaTime();
const double render = Timer::GetDeltaRenderTime();
m_network->servers->push_delta(render, delta, sync, commands_to_exec);
}
@@ -565,7 +565,7 @@ int eu07_application::run()
}
// set total delta for rendering code
double totalDelta = Timer::GetTime() - frameStartTime;
const double totalDelta = Timer::GetTime() - frameStartTime;
Timer::set_delta_override(totalDelta);
}
}
@@ -573,8 +573,8 @@ int eu07_application::run()
if (!loop_remaining)
{
// loop break forced by counter
float received = m_network->client->get_frame_counter();
float awaiting = m_network->client->get_awaiting_frames();
const float received = m_network->client->get_frame_counter();
const float awaiting = m_network->client->get_awaiting_frames();
// TODO: don't meddle with mode progresbar
m_modes[m_modestack.top()]->set_progress(100.0f * (received - awaiting) / received);
@@ -901,7 +901,7 @@ void eu07_application::on_focus_change(bool focus)
{
if (Global.bInactivePause && m_network.has_value() && !m_network->client)
{ // jeśli ma być pauzowanie okna w tle
command_relay relay;
const command_relay relay;
relay.post(user_command::focuspauseset, focus ? 1.0 : 0.0, 0.0, GLFW_PRESS, 0);
}
}
@@ -1047,7 +1047,7 @@ void eu07_application::init_console()
// as text ("←[32m" etc). Open CONOUT$ directly to get the real screen
// buffer handle, then flip VT on it.
auto enable_vt = [](const char *devName) {
HANDLE h = ::CreateFileA(
const HANDLE h = ::CreateFileA(
devName,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
@@ -1109,7 +1109,7 @@ int eu07_application::init_settings(int Argc, char *Argv[])
{
Global.asVersion = VERSION_INFO;
fs::path iniPath = user_config_path("eu07.ini");
const fs::path iniPath = user_config_path("eu07.ini");
if (!iniPath.empty() && fs::exists(iniPath))
{
@@ -1461,15 +1461,15 @@ bool eu07_application::init_network()
{
// we're simulation master
// TODO: sort out this timezone mess
std::time_t utc_now = std::time(nullptr);
const std::time_t utc_now = std::time(nullptr);
tm tm_local, tm_utc;
tm *tmp = std::localtime(&utc_now);
const tm *tmp = std::localtime(&utc_now);
memcpy(&tm_local, tmp, sizeof(tm));
tmp = std::gmtime(&utc_now);
memcpy(&tm_utc, tmp, sizeof(tm));
int64_t offset = tm_local.tm_hour * 3600 + tm_local.tm_min * 60 + tm_local.tm_sec - (tm_utc.tm_hour * 3600 + tm_utc.tm_min * 60 + tm_utc.tm_sec);
const int64_t offset = tm_local.tm_hour * 3600 + tm_local.tm_min * 60 + tm_local.tm_sec - (tm_utc.tm_hour * 3600 + tm_utc.tm_min * 60 + tm_utc.tm_sec);
Global.starting_timestamp = utc_now + offset;
Global.ready_to_load = true;

View File

@@ -74,7 +74,7 @@ bool driver_mode::drivermode_input::init()
{
// initialize input devices
auto result = keyboard.init() && mouse.init();
const auto result = keyboard.init() && mouse.init();
if (true == Global.InputGamepad)
{
gamepad.init();
@@ -419,7 +419,7 @@ bool driver_mode::update()
void driver_mode::enter()
{
TDynamicObject *nPlayerTrain{(Global.local_start_vehicle != "ghostview" ? simulation::Vehicles.find(Global.local_start_vehicle) : nullptr)};
const TDynamicObject *nPlayerTrain{(Global.local_start_vehicle != "ghostview" ? simulation::Vehicles.find(Global.local_start_vehicle) : nullptr)};
Camera.Init(Global.FreeCameraInit[0], Global.FreeCameraInitAngle[0], nullptr);
Global.pCamera = Camera;
@@ -472,7 +472,7 @@ void driver_mode::on_key(int const Key, int const Scancode, int const Action, in
Global.altState = Mods & GLFW_MOD_ALT ? true : false;
#endif
bool anyModifier = Mods & (GLFW_MOD_SHIFT | GLFW_MOD_CONTROL | GLFW_MOD_ALT);
const bool anyModifier = Mods & (GLFW_MOD_SHIFT | GLFW_MOD_CONTROL | GLFW_MOD_ALT);
// give the ui first shot at the input processing...
if (!anyModifier && true == m_userinterface->on_key(Key, Action))

View File

@@ -209,7 +209,7 @@ void driver_ui::update()
{
auto const pausemask{1 | 2};
auto ispaused{false == DebugModeFlag && (Global.iPause & pausemask) != 0};
const auto ispaused{false == DebugModeFlag && (Global.iPause & pausemask) != 0};
if (ispaused != m_paused && false == Global.ControlPicking)
{
set_cursor(ispaused);

View File

@@ -473,13 +473,13 @@ timetable_panel::render() {
ImGui::PushFont(ui_layer::font_mono);
auto flags =
const auto flags =
ImGuiWindowFlags_NoFocusOnAppearing
| ImGuiWindowFlags_NoCollapse
| ( size.x > 0 ? ImGuiWindowFlags_NoResize : 0 );
// HACK: Make sure the timetable window is of correct width when using a larger font size.
float horizontalScale = Global.ui_fontsize / 13;
const float horizontalScale = Global.ui_fontsize / 13;
if( size.x > 0 ) {
ImGui::SetNextWindowSize( ImVec2S( size.x * horizontalScale, size.y ) );
}
@@ -565,7 +565,7 @@ debug_panel::render() {
ImGui::PushFont(ui_layer::font_mono);
auto flags =
const auto flags =
ImGuiWindowFlags_NoFocusOnAppearing
| ImGuiWindowFlags_NoCollapse
| ( size.x > 0 ? ImGuiWindowFlags_NoResize : 0 );
@@ -591,7 +591,7 @@ debug_panel::render() {
if( true == render_section( "Vehicle", m_vehiclelines ) ) {
if( DebugModeFlag && m_input.mover && m_input.mover->DamageFlag != 0 ) {
if( true == ImGui::Button( "Stop and repair consist" ) ) {
command_relay relay;
const command_relay relay;
relay.post(user_command::resetconsist, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &m_input.vehicle->name());
}
}
@@ -611,8 +611,8 @@ debug_panel::render() {
render_section_developer(); // Developer tools
#ifdef WITH_UART
if(true == render_section( "UART", m_uartlines)) {
int ports_num = UartStatus.available_ports.size();
auto avlports = new char*[ports_num];
const int ports_num = UartStatus.available_ports.size();
const auto avlports = new char*[ports_num];
for (int i=0; i < ports_num; i++) {
avlports[i] = (char *) UartStatus.available_ports[i].c_str();
}
@@ -625,7 +625,7 @@ debug_panel::render() {
ImGui::Separator();
bool flag = DebugModeFlag;
if (ImGui::Checkbox("Debug Mode", &flag)) {
command_relay relay;
const command_relay relay;
relay.post(user_command::debugtoggle, 0.0, 0.0, GLFW_RELEASE, 0);
}
}
@@ -647,7 +647,7 @@ debug_panel::render_section_scenario() {
auto fogrange = std::log( Global.fFogEnd );
if( ImGui::SliderFloat(
( to_string( std::exp( fogrange ), 0, 5 ) + " m###fogend" ).c_str(), &fogrange, std::log( 10.0f ), std::log( 50000.0f ), "Fog distance" ) ) {
command_relay relay;
const command_relay relay;
relay.post(
user_command::setweather,
std::clamp( std::exp( fogrange ), 10.0f, 50000.0f ),
@@ -661,7 +661,7 @@ debug_panel::render_section_scenario() {
(to_string(Airtemperature, 1) + " deg C###Airtemperature").c_str(),
&Airtemperature, -35.0f, 40.0f, "Air Temperature"))
{
command_relay relay;
const command_relay relay;
relay.post(
user_command::settemperature,
std::clamp(Airtemperature, -35.0f, 40.0f),
@@ -673,7 +673,7 @@ debug_panel::render_section_scenario() {
{
if( ImGui::SliderFloat(
( to_string( Global.Overcast, 2, 5 ) + " (" + Global.Weather + ")###overcast" ).c_str(), &Global.Overcast, 0.0f, 2.0f, "Cloud cover" ) ) {
command_relay relay;
const command_relay relay;
relay.post(
user_command::setweather,
Global.fFogEnd,
@@ -685,7 +685,7 @@ debug_panel::render_section_scenario() {
{
if( ImGui::SliderFloat(
( to_string( Global.fMoveLight, 0, 5 ) + " (" + Global.Season + ")###movelight" ).c_str(), &Global.fMoveLight, 0.0f, 364.0f, "Day of year" ) ) {
command_relay relay;
const command_relay relay;
relay.post(
user_command::setdatetime,
std::clamp( Global.fMoveLight, 0.0f, 365.0f ),
@@ -713,7 +713,7 @@ debug_panel::render_section_scenario() {
+ ":"
+ std::string( std::to_string( int( 100 + simulation::Time.data().wMinute ) ).substr( 1, 2 ) ) ) };
if( ImGui::SliderInt( ( timestring + " (" + Global.Period + ")###simulationtime" ).c_str(), &time, 0, 1439, "Time of day" ) ) {
command_relay relay;
const command_relay relay;
relay.post(
user_command::setdatetime,
Global.fMoveLight,
@@ -980,7 +980,7 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
}
if (!std::isnan(last_time)) {
double dt = Timer::GetTime() - last_time;
const double dt = Timer::GetTime() - last_time;
AccN_jerk_graph.update((mover.AccN - last_AccN) / dt);
AccN_acc_graph.update(mover.AccN);
}
@@ -1012,7 +1012,7 @@ debug_panel::update_vehicle_coupler( int const Side ) {
auto const &mover { *m_input.mover };
std::string const controltype{ ( mover.Couplers[ Side ].control_type.empty() ? "[*]" : "[" + mover.Couplers[ Side ].control_type + "]" ) };
std::string couplerstatus { STR("none") };
const std::string couplerstatus { STR("none") };
std::string const adapterstatus { ( mover.Couplers[ Side ].adapter_type == TCouplerType::NoCoupler ? "" : "[A]" ) };
auto const *connected { m_input.vehicle->MoverParameters->Neighbours[ Side ].vehicle };
@@ -1041,7 +1041,7 @@ debug_panel::update_vehicle_brake() const {
std::string brakedelay;
std::vector<std::pair<int, std::string>> delays {
const std::vector<std::pair<int, std::string>> delays {
{ bdelay_G, "G" },
{ bdelay_P, "P" },
{ bdelay_R, "R" },
@@ -1285,7 +1285,7 @@ debug_panel::update_section_scantable( std::vector<text_line> &Output ) {
#ifdef WITH_UART
void
debug_panel::update_section_uart( std::vector<text_line> &Output ) {
uart_status *status = &UartStatus;
const uart_status *status = &UartStatus;
Output.emplace_back(
("Port: " + status->port_name).c_str(),
@@ -1296,7 +1296,7 @@ debug_panel::update_section_uart( std::vector<text_line> &Output ) {
Global.UITextColor
);
if(status->is_connected) {
std::string synctext = status->is_synced ? "SYNCED" : "NOT SYNCED";
const std::string synctext = status->is_synced ? "SYNCED" : "NOT SYNCED";
Output.emplace_back(("CONNECTED, " + synctext).c_str(), Global.UITextColor);
} else {
Output.emplace_back("* NOT CONNECTED *", Global.UITextColor);
@@ -1595,7 +1595,7 @@ debug_panel::render_section_settings() {
if (simulation::Train) {
float val = simulation::Train->get_radiovolume();
if( ImGui::SliderFloat( ( std::to_string( static_cast<int>( val * 100 ) ) + "%###volumeradio" ).c_str(), &val, 0.0f, 1.0f, "Vehicle radio volume" ) ) {
command_relay relay;
const command_relay relay;
relay.post(user_command::radiovolumeset, val, 0.0, GLFW_PRESS, 0);
}
}
@@ -1624,7 +1624,7 @@ transcripts_panel::render() {
if( false == is_open ) { return; }
if( true == text_lines.empty() ) { return; }
auto flags =
const auto flags =
ImGuiWindowFlags_NoFocusOnAppearing
| ImGuiWindowFlags_NoCollapse
| ( size.x > 0 ? ImGuiWindowFlags_NoResize : 0 );

View File

@@ -345,7 +345,7 @@ void editor_mode::add_to_hierarchy(scene::basic_node *node)
void editor_mode::remove_from_hierarchy(scene::basic_node *node)
{
if (!node) return;
auto it = scene::Hierarchy.find(node->uuid.to_string());
const auto it = scene::Hierarchy.find(node->uuid.to_string());
if (it != scene::Hierarchy.end())
scene::Hierarchy.erase(it);
}
@@ -353,7 +353,7 @@ void editor_mode::remove_from_hierarchy(scene::basic_node *node)
scene::basic_node* editor_mode::find_in_hierarchy(const std::string &uuid_str)
{
if (uuid_str.empty()) return nullptr;
auto it = scene::Hierarchy.find(uuid_str);
const auto it = scene::Hierarchy.find(uuid_str);
return it != scene::Hierarchy.end() ? it->second : nullptr;
}
@@ -389,7 +389,7 @@ void editor_mode::push_snapshot(scene::basic_node *node, EditorSnapshot::Action
snap.position = node->location();
snap.uuid = node->uuid;
if (auto *model = dynamic_cast<TAnimModel *>(node))
if (const auto *model = dynamic_cast<TAnimModel *>(node))
{
snap.rotation = model->Angles();
snap.scale = model->Scale();
@@ -417,7 +417,7 @@ void editor_mode::push_snapshot(scene::basic_node *node, EditorSnapshot::Action
glm::dvec3 editor_mode::clamp_mouse_offset_to_max(const glm::dvec3 &offset)
{
double len = glm::length(offset);
const double len = glm::length(offset);
if (len <= static_cast<double>(kMaxPlacementDistance) || len <= 1e-6)
return offset;
return glm::normalize(offset) * static_cast<double>(kMaxPlacementDistance);
@@ -681,7 +681,7 @@ bool editor_mode::update()
{
auto const terrains = active_terrains();
bool any_dirty = false;
for (editor_terrain *terrain : terrains)
for (const editor_terrain *terrain : terrains)
if (terrain->dirty())
{
any_dirty = true;
@@ -910,7 +910,7 @@ void editor_mode::render_terrain_ui()
editor_terrain *editor_mode::terrain_at(double X, double Z)
{
for (auto &terrain : m_terrains)
for (const auto &terrain : m_terrains)
if (terrain && terrain->contains(X, Z))
return terrain.get();
double const size = chunk_grid_size();
@@ -1402,7 +1402,7 @@ void editor_mode::on_key(int const Key, int const Scancode, int const Action, in
Global.ctrlState = Mods & GLFW_MOD_CONTROL ? true : false;
Global.altState = Mods & GLFW_MOD_ALT ? true : false;
#endif
bool anyModifier = Mods & (GLFW_MOD_SHIFT | GLFW_MOD_CONTROL | GLFW_MOD_ALT);
const bool anyModifier = Mods & (GLFW_MOD_SHIFT | GLFW_MOD_CONTROL | GLFW_MOD_ALT);
// first give UI a chance to handle the key
if (!anyModifier && m_userinterface->on_key(Key, Action))
@@ -1473,14 +1473,14 @@ void editor_mode::on_key(int const Key, int const Scancode, int const Action, in
case GLFW_KEY_DELETE:
if (is_press(Action))
{
auto model = dynamic_cast<TAnimModel *>(m_node);
const auto model = dynamic_cast<TAnimModel *>(m_node);
if (model)
{
// record deletion for undo (serialize full node)
std::string as_text;
model->export_as_text(as_text);
std::string debug = "Deleting node: " + as_text + "\nSerialized data:\n";
const std::string debug = "Deleting node: " + as_text + "\nSerialized data:\n";
push_snapshot(model, EditorSnapshot::Action::Delete, as_text);
WriteLog(debug, logtype::generic);
@@ -1654,7 +1654,7 @@ void editor_mode::render_change_history(){
m_max_history_size = std::max(0, maxsize);
if ((int)m_history.size() > m_max_history_size && m_max_history_size >= 0)
{
auto remove_count = (int)m_history.size() - m_max_history_size;
const auto remove_count = (int)m_history.size() - m_max_history_size;
m_history.erase(m_history.begin(), m_history.begin() + remove_count);
// adjust selected index
if (m_selected_history_idx >= (int)m_history.size())
@@ -1705,8 +1705,8 @@ void editor_mode::render_change_history(){
{
if (m_selected_history_idx >= 0 && m_selected_history_idx < (int)m_history.size())
{
int target = m_selected_history_idx;
int undoCount = (int)m_history.size() - 1 - target;
const int target = m_selected_history_idx;
const int undoCount = (int)m_history.size() - 1 - target;
for (int k = 0; k < undoCount; ++k)
undo_last();
m_selected_history_idx = -1;

View File

@@ -44,7 +44,7 @@ void editor_ui::update()
m_itempropertiespanel.update(m_node);
m_functionspanel.update(m_node);
auto ptr = get_active_node_template(true);
const auto ptr = get_active_node_template(true);
if (ptr)
m_brushobjects.update(*ptr);
}

View File

@@ -272,7 +272,7 @@ void itemproperties_panel::render()
return;
}
auto flags = ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoCollapse | (size.x > 0 ? ImGuiWindowFlags_NoResize : 0);
const auto flags = ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoCollapse | (size.x > 0 ? ImGuiWindowFlags_NoResize : 0);
if (size.x > 0)
{
@@ -383,7 +383,7 @@ brush_object_list::brush_object_list(std::string const &Name, bool const Isopen)
bool brush_object_list::VectorGetter(void *data, int idx, const char **out_text)
{
auto *vec = static_cast<std::vector<std::string> *>(data);
const auto *vec = static_cast<std::vector<std::string> *>(data);
if (idx < 0 || idx >= vec->size())
return false;
@@ -416,7 +416,7 @@ void brush_object_list::render()
return;
}
auto flags = ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoCollapse | (size.x > 0 ? ImGuiWindowFlags_NoResize : 0);
const auto flags = ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoCollapse | (size.x > 0 ? ImGuiWindowFlags_NoResize : 0);
if (ImGui::Begin("Brush random set", nullptr, flags))
{
ImGui::SliderFloat("Spacing", &spacing, 0.1f, 20.0f, "%.1f m");
@@ -513,7 +513,7 @@ void nodebank_panel::render()
return;
}
auto flags = ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoCollapse | (size.x > 0 ? ImGuiWindowFlags_NoResize : 0);
const auto flags = ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoCollapse | (size.x > 0 ? ImGuiWindowFlags_NoResize : 0);
if (size.x > 0)
{
@@ -639,7 +639,7 @@ void functions_panel::render()
return;
}
auto flags = ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoCollapse | (size.x > 0 ? ImGuiWindowFlags_NoResize : 0);
const auto flags = ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoCollapse | (size.x > 0 ? ImGuiWindowFlags_NoResize : 0);
if (size.x > 0)
{

View File

@@ -23,7 +23,7 @@ size_t utf8_char_count(const std::string& str)
size_t count = 0;
for (size_t i = 0; i < str.length(); )
{
unsigned char c = static_cast<unsigned char>(str[i]);
const unsigned char c = static_cast<unsigned char>(str[i]);
if ((c & 0x80) == 0x00)
{
// 1-byte character (ASCII)
@@ -108,7 +108,7 @@ std::vector<std::string> scenarioloader_ui::get_random_trivia()
size_t current_chars = 0;
for (size_t i = 0; i < str.length() && current_chars < char_count; )
{
unsigned char c = static_cast<unsigned char>(str[i]);
const unsigned char c = static_cast<unsigned char>(str[i]);
if ((c & 0x80) == 0x00)
{
i += 1;
@@ -137,8 +137,8 @@ std::vector<std::string> scenarioloader_ui::get_random_trivia()
// UTF-8 safe find space within character limit
auto find_space_before_char_count = [&](const std::string& str, size_t max_chars) -> size_t {
size_t byte_limit = get_byte_pos_for_char_count(str, max_chars);
size_t search_limit = std::min(str.length(), byte_limit);
const size_t byte_limit = get_byte_pos_for_char_count(str, max_chars);
const size_t search_limit = std::min(str.length(), byte_limit);
// Search backwards for a space that's not in the middle of a UTF-8 sequence
for (int idx = static_cast<int>(search_limit); idx >= 0; idx--) {

View File

@@ -501,7 +501,7 @@ void ui_layer::clear_panels()
void ui_layer::add_owned_panel(ui_panel *Panel)
{
for (auto &panel : m_ownedpanels)
for (const auto &panel : m_ownedpanels)
if (panel->name() == Panel->name())
{
delete Panel;
@@ -516,7 +516,7 @@ void ui_layer::render_panels()
{
for (auto *panel : m_panels)
panel->render();
for (auto &panel : m_ownedpanels)
for (const auto &panel : m_ownedpanels)
panel->render();
if (m_imgui_demo)
@@ -540,7 +540,7 @@ void ui_layer::render_menu_contents()
bool flag = DebugModeFlag;
if (ImGui::MenuItem(STR_C("Debug mode"), nullptr, &flag))
{
command_relay relay;
const command_relay relay;
relay.post(user_command::debugtoggle, 0.0, 0.0, GLFW_RELEASE, 0);
}
ImGui::MenuItem(STR_C("Quit"), "F10", &m_quit_active);
@@ -606,21 +606,21 @@ void ui_layer::render_background()
if (m_background == 0)
return;
ImVec2 display_size = ImGui::GetIO().DisplaySize;
const ImVec2 display_size = ImGui::GetIO().DisplaySize;
ITexture &tex = GfxRenderer->Texture(m_background);
tex.create();
float tex_w = (float)tex.get_width();
float tex_h = (float)tex.get_height();
const float tex_w = (float)tex.get_width();
const float tex_h = (float)tex.get_height();
// skalowanie "cover" wypełnia cały ekran, zachowując proporcje
float scale_factor = display_size.x / display_size.y > tex_w / tex_h ? display_size.x / tex_w : display_size.y / tex_h;
const float scale_factor = display_size.x / display_size.y > tex_w / tex_h ? display_size.x / tex_w : display_size.y / tex_h;
ImVec2 image_size(tex_w * scale_factor, tex_h * scale_factor);
const ImVec2 image_size(tex_w * scale_factor, tex_h * scale_factor);
// wyśrodkowanie obrazka
ImVec2 start_position((display_size.x - image_size.x) * 0.5f, (display_size.y - image_size.y) * 0.5f);
ImVec2 end_position(start_position.x + image_size.x, start_position.y + image_size.y);
const ImVec2 start_position((display_size.x - image_size.x) * 0.5f, (display_size.y - image_size.y) * 0.5f);
const ImVec2 end_position(start_position.x + image_size.x, start_position.y + image_size.y);
// obrazek jest odwrócony w pionie odwracamy UV
ImGui::GetBackgroundDrawList()->AddImage(reinterpret_cast<ImTextureID>(tex.get_id()), start_position, end_position, ImVec2(0, 1), ImVec2(1, 0));