17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-08 22:07:20 +01:00
Files
maszyna/launcher/scenery_list.h
maj00r a6778c9fe2 refactor: the Sonar remarks on the small fixes taken care of
- the log stops through a flag kept in a function, not a global one
- the messages are put together with std::format
- a vehicle dropped on a trainset in the launcher goes in once the
  trainset is drawn, so the vehicles are gone through with a plain loop
  again; the drop split into a new vehicle and a moved one
- the scenario that can't be opened is caught as the runtime error it
  is, a file name outside of the code page as the system error it is
- a track of an unknown type is left out through the pointer owning it
- the keyword of a track type written out by a function of its own
- the picked node forgotten with ranges::replace_if, the empty
  Forget_Node of the base renderer told why it is empty
- FileCased takes the path it works on
2026-11-06 19:54:54 +01:00

77 lines
2.0 KiB
C++

#pragma once
#include "input/driverkeyboardinput.h"
#include "application/uilayer.h"
#include "scenery_scanner.h"
#include "widgets/popup.h"
namespace ui
{
class dynamic_edit_popup : public popup
{
dynamic_desc &dynamic;
std::array<char, 128> name_buf;
std::array<char, 128> load_buf;
std::array<char, 128> param_buf;
template <size_t n>
void prepare_str(std::string &str, std::array<char, n> &array) {
if (str.size() > array.size() - 1)
str.resize(array.size() - 1);
std::copy(str.begin(), str.end(), array.data());
array[str.size()] = 0;
}
public:
dynamic_edit_popup(ui_panel &panel, dynamic_desc &dynamic);
virtual void render_content() override;
};
class scenerylist_panel : public ui_panel
{
public:
scenerylist_panel(scenery_scanner &scanner);
void render_contents() override;
bool on_key(int key, int action);
private:
driverkeyboard_input keyboard;
struct vehicle_moved {
trainset_desc &source;
dynamic_desc &dynamic;
int position;
vehicle_moved(trainset_desc &source, dynamic_desc &dynamic, int position)
: source(source), dynamic(dynamic), position(position) {}
};
scenery_scanner &scanner;
scenery_desc *selected_scenery = nullptr;
trainset_desc *selected_trainset = nullptr;
deferred_image placeholder_mini;
// a vehicle dropped on a gap between the vehicles of a trainset: put in there once they're all drawn, not while they are
std::function<void()> m_drop;
void draw_scenery_list();
void draw_scenery_info();
void draw_scenery_image();
void draw_launch_box();
void draw_trainset_box();
bool launch_simulation();
void add_replace_entry(const trainset_desc &trainset);
void draw_summary_tooltip(const dynamic_desc &dyn_desc);
void open_link(const std::string &link);
void draw_trainset(trainset_desc &trainset);
void draw_droptarget(trainset_desc &trainset, int position);
void drop_new_vehicle(trainset_desc &trainset, int position, skin_set const *Skin);
void drop_moved_vehicle(trainset_desc &trainset, int position, vehicle_moved const &Moved);
void purge_selected_trainset();
};
} // namespace ui