18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 00:22:42 +01:00
Files
maszyna/application/driveruipanels.h
T
Hirek d0387753f8 refactor(physics): TMoverParameters becomes physics::Vehicle, the mover is gone
The physics of a vehicle loses the name it had from the Pascal of 2001. Done by
tools/rename/mover_to_physics.py, committed with it:

  physics/mover.h                  physics/vehicle.h
  TMoverParameters                 physics::Vehicle (in namespace physics)
  TDynamicObject::MoverParameters  physics
  mvOccupied, mvControlled         occupied, controlled (TTrain, TController)
  mvSecond, mvThird                secondUnit, thirdUnit
  mvPantographUnit                 pantographUnit
  mover, Mover, movers             physics, Physics, vehicles (locals, params)
  m_mover, othermover, currentMover, from_movers, renderMoverEventSounds
                                   m_physics, otherPhysics, currentPhysics,
                                   from_vehicles, renderPhysicsEventSounds

The code and the comments are renamed, the string literals are not: no text
the game shows, logs or looks up has changed (none had the names). The movers
of the editor, the tracks a slide moves, keep their name.

By hand: two member functions of TDynamicObject (gather_off_track_terrain,
begin_off_track) had a local mover aliasing their own MoverParameters, which
the rename made physics { *physics }; the alias is gone, they use physics->.
No other function has a renamed local meeting a renamed member (checked over
all the functions of the code before the rename).

For the branches made before it: run the script on the branch (python
tools/rename/mover_to_physics.py, from the root of the repository) before
merging it with this one, and the names don't conflict. It can be run again;
the second time it changes nothing.

The class is the same as it was; breaking it into its parts (braking,
electrics, controls, load) and making its data private are the next stages.

No change in behaviour: 1149/1149 tests, golden traces exact against staging
62f7a29b.
2026-11-28 23:56:46 +01:00

168 lines
5.2 KiB
C++

/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "application/uilayer.h"
#include "utilities/Classes.h"
#include "physics/vehicletypes.h"
#include "rendering/renderer.h"
class drivingaid_panel : public ui_expandable_panel {
public:
drivingaid_panel( std::string const &Name, bool const Isopen )
: ui_expandable_panel( Name, Isopen )
{}
void update() override;
void render_contents() override;
private:
// members
std::array<char, 256> m_buffer;
// the broken coupler next to the camera, which the panel offers to repair: the vehicle and its end
TDynamicObject const *m_brokenvehicle { nullptr };
VehicleEnd m_brokenend { VehicleEnd::front };
};
class timetable_panel : public ui_expandable_panel {
public:
timetable_panel( std::string const &Name, bool const Isopen )
: ui_expandable_panel( Name, Isopen ) {}
void update() override;
void render() override;
private:
// members
std::array<char, 256> m_buffer;
std::vector<text_line> m_tablelines;
};
class scenario_panel : public ui_panel {
public:
scenario_panel( std::string const &Name, bool const Isopen )
: ui_panel( Name, Isopen ) {}
void update() override;
void render() override;
bool is_expanded{ false };
private:
// members
TDynamicObject const *m_nearest { nullptr };
};
class debug_panel : public ui_panel {
public:
debug_panel( std::string const &Name, bool const Isopen )
: ui_panel( Name, Isopen ) {
m_eventsearch.fill( 0 ); }
void update() override;
void render() override;
private:
// types
struct input_data {
TTrain const *train;
TDynamicObject const *controlled;
TCamera const *camera;
TDynamicObject const *vehicle;
physics::Vehicle *physics;
TController const *mechanik;
};
// methods
// generate and send section data to provided output
void update_section_vehicle( std::vector<text_line> &Output );
void update_section_engine( std::vector<text_line> &Output ) const;
void update_section_ai( std::vector<text_line> &Output ) const;
void update_section_scantable( std::vector<text_line> &Output ) const;
void update_section_scenario( std::vector<text_line> &Output ) const;
void update_section_eventqueue( std::vector<text_line> &Output );
void update_section_powergrid( std::vector<text_line> &Output ) const;
void update_section_camera( std::vector<text_line> &Output ) const;
void update_section_renderer( std::vector<text_line> &Output );
// the coupler nearest to the camera, and the state of its coupling
void update_section_coupler( std::vector<text_line> &Output );
#ifdef WITH_UART
void update_section_uart( std::vector<text_line> &Output ) const;
#endif
// section update helpers
std::string update_vehicle_coupler( VehicleEnd const Side );
std::string update_vehicle_brake() const;
// renders provided lines, under specified collapsing header
bool render_section( std::string const &Header, std::vector<text_line> const &Lines );
bool render_section( std::vector<text_line> const &Lines ) const;
bool render_section_scenario();
bool render_section_eventqueue();
bool render_section_renderer();
// the coupler section, with the parameters of the physical model to try out in the debug mode
bool render_section_coupler();
bool render_section_settings() const;
bool render_section_developer() const;
// members
std::array<char, 1024> m_buffer;
std::array<char, 128> m_eventsearch;
input_data m_input;
std::vector<text_line> m_vehiclelines;
std::vector<text_line> m_enginelines;
std::vector<text_line> m_ailines;
std::vector<text_line> m_scantablelines;
std::vector<text_line> m_cameralines;
std::vector<text_line> m_scenariolines;
std::vector<text_line> m_eventqueuelines;
std::vector<text_line> m_powergridlines;
std::vector<text_line> m_rendererlines;
std::vector<gfx_renderer::info_section> m_renderersections; // the data of the renderer, each part under a header of its own
std::vector<text_line> m_uartlines;
std::vector<text_line> m_couplerlines;
// the coupler nearest to the camera
struct coupler_pick {
TDynamicObject const *vehicle { nullptr };
VehicleEnd end { VehicleEnd::front };
};
coupler_pick m_coupler;
bool m_couplerbothends { true }; // changes to the parameters apply to the end of the other vehicle of the pair too
double last_time = std::numeric_limits<double>::quiet_NaN();
struct graph_data
{
double last_val = 0.0;
std::array<float, 150> data = { 0.0f };
size_t pos = 0;
float range = 25.0f;
void update(float data);
void render();
};
graph_data AccN_jerk_graph;
graph_data AccN_acc_graph;
float last_AccN;
bool m_eventqueueactivevehicleonly { false };
};
class transcripts_panel : public ui_panel {
public:
transcripts_panel( std::string const &Name, bool const Isopen )
: ui_panel( Name, Isopen ) {}
void update() override;
void render() override;
};