|
|
|
|
@@ -13,14 +13,8 @@ ui::scenerylist_panel::scenerylist_panel(scenery_scanner &scanner)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ui::scenerylist_panel::render()
|
|
|
|
|
void ui::scenerylist_panel::render_contents()
|
|
|
|
|
{
|
|
|
|
|
if (!is_open)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
auto const panelname{(title.empty() ? m_name : title) + "###" + m_name};
|
|
|
|
|
|
|
|
|
|
if (ImGui::Begin(panelname.c_str(), &is_open)) {
|
|
|
|
|
ImGui::Columns(3);
|
|
|
|
|
|
|
|
|
|
if (ImGui::BeginChild("child1", ImVec2(0, -200))) {
|
|
|
|
|
@@ -140,7 +134,7 @@ void ui::scenerylist_panel::render()
|
|
|
|
|
set += selected_trainset->name + " ";
|
|
|
|
|
set += selected_trainset->track + " ";
|
|
|
|
|
set += std::to_string(selected_trainset->offset) + " ";
|
|
|
|
|
set += std::to_string(selected_trainset->velocity) + " ";
|
|
|
|
|
set += std::to_string(selected_trainset->velocity) + "\n";
|
|
|
|
|
for (const auto &veh : selected_trainset->vehicles) {
|
|
|
|
|
set += "node -1 0 " + veh.name + " dynamic ";
|
|
|
|
|
set += veh.vehicle->path.parent_path().generic_string() + " ";
|
|
|
|
|
@@ -153,12 +147,12 @@ void ui::scenerylist_panel::render()
|
|
|
|
|
set += " " + std::to_string(veh.loadcount) + " ";
|
|
|
|
|
if (veh.loadcount > 0)
|
|
|
|
|
set += veh.loadtype + " ";
|
|
|
|
|
set += "enddynamic ";
|
|
|
|
|
set += "enddynamic\n";
|
|
|
|
|
}
|
|
|
|
|
set += "endtrainset";
|
|
|
|
|
set += "endtrainset\n";
|
|
|
|
|
WriteLog(set);
|
|
|
|
|
|
|
|
|
|
Global.trainset_overrides.push_back(std::make_pair(selected_trainset->file_bounds.first, set));
|
|
|
|
|
Global.trainset_overrides.emplace(selected_trainset->file_bounds.first, set);
|
|
|
|
|
|
|
|
|
|
Application.pop_mode();
|
|
|
|
|
Application.push_mode(eu07_application::mode::scenarioloader);
|
|
|
|
|
@@ -182,11 +176,10 @@ void ui::scenerylist_panel::render()
|
|
|
|
|
} ImGui::EndChild();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::End();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ui::scenerylist_panel::draw_trainset(trainset_desc &trainset)
|
|
|
|
|
{
|
|
|
|
|
ImGui::SetItemAllowOverlap();
|
|
|
|
|
|
|
|
|
|
static std::unordered_map<coupling, std::string> coupling_names =
|
|
|
|
|
{
|
|
|
|
|
{ coupling::faux, STRN("faux") },
|
|
|
|
|
@@ -206,7 +199,7 @@ void ui::scenerylist_panel::draw_trainset(trainset_desc &trainset)
|
|
|
|
|
draw_droptarget(trainset, position++);
|
|
|
|
|
ImGui::SameLine(15.0f);
|
|
|
|
|
|
|
|
|
|
for (auto const &dyn_desc : trainset.vehicles) {
|
|
|
|
|
for (auto &dyn_desc : trainset.vehicles) {
|
|
|
|
|
deferred_image *mini = nullptr;
|
|
|
|
|
|
|
|
|
|
if (dyn_desc.skin && dyn_desc.skin->mini.get() != -1)
|
|
|
|
|
@@ -220,7 +213,10 @@ void ui::scenerylist_panel::draw_trainset(trainset_desc &trainset)
|
|
|
|
|
float width = 30.0f / size.y * size.x;
|
|
|
|
|
ImGui::Image(reinterpret_cast<void*>(mini->get()), ImVec2(width, 30), ImVec2(0, 1), ImVec2(1, 0));
|
|
|
|
|
|
|
|
|
|
if (ImGui::IsItemHovered()) {
|
|
|
|
|
if (ImGui::IsItemClicked(1)) {
|
|
|
|
|
register_popup(std::make_unique<ui::dynamic_edit_popup>(*this, dyn_desc));
|
|
|
|
|
}
|
|
|
|
|
else if (ImGui::IsItemHovered()) {
|
|
|
|
|
ImGui::BeginTooltip();
|
|
|
|
|
std::string name = (dyn_desc.vehicle->path.parent_path() / dyn_desc.vehicle->path.stem()).string();
|
|
|
|
|
std::string skin = dyn_desc.skin->skin;
|
|
|
|
|
@@ -267,7 +263,6 @@ void ui::scenerylist_panel::draw_trainset(trainset_desc &trainset)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#include "Logs.h"
|
|
|
|
|
void ui::scenerylist_panel::draw_droptarget(trainset_desc &trainset, int position)
|
|
|
|
|
{
|
|
|
|
|
ImGui::Dummy(ImVec2(15, 30));
|
|
|
|
|
@@ -291,3 +286,98 @@ void ui::scenerylist_panel::draw_droptarget(trainset_desc &trainset, int positio
|
|
|
|
|
ImGui::EndDragDropTarget();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ui::dynamic_edit_popup::dynamic_edit_popup(ui_panel &panel, dynamic_desc &dynamic)
|
|
|
|
|
: popup(panel), dynamic(dynamic)
|
|
|
|
|
{
|
|
|
|
|
prepare_str(dynamic.name, name_buf);
|
|
|
|
|
prepare_str(dynamic.loadtype, load_buf);
|
|
|
|
|
prepare_str(dynamic.params, param_buf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ui::dynamic_edit_popup::render_content()
|
|
|
|
|
{
|
|
|
|
|
static std::unordered_map<coupling, std::string> coupling_names =
|
|
|
|
|
{
|
|
|
|
|
{ coupling::faux, STRN("faux") },
|
|
|
|
|
{ coupling::coupler, STRN("coupler") },
|
|
|
|
|
{ coupling::brakehose, STRN("brake hose") },
|
|
|
|
|
{ coupling::control, STRN("control") },
|
|
|
|
|
{ coupling::highvoltage, STRN("high voltage") },
|
|
|
|
|
{ coupling::gangway, STRN("gangway") },
|
|
|
|
|
{ coupling::mainhose, STRN("main hose") },
|
|
|
|
|
{ coupling::heating, STRN("heating") },
|
|
|
|
|
{ coupling::permanent, STRN("permanent") },
|
|
|
|
|
{ coupling::uic, STRN("uic") }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static std::vector<std::string> occupancy_names = {
|
|
|
|
|
STRN("headdriver"),
|
|
|
|
|
STRN("reardriver"),
|
|
|
|
|
STRN("passenger"),
|
|
|
|
|
STRN("nobody")
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
std::string name = (dynamic.vehicle->path.parent_path() / dynamic.vehicle->path.stem()).string();
|
|
|
|
|
|
|
|
|
|
ImGui::Text(STR_C("Type: %s"), name.c_str());
|
|
|
|
|
ImGui::NewLine();
|
|
|
|
|
|
|
|
|
|
if (ImGui::InputText(STR_C("Name"), name_buf.data(), name_buf.size()))
|
|
|
|
|
dynamic.name = name_buf.data();
|
|
|
|
|
|
|
|
|
|
if (ImGui::BeginCombo(STR_C("Skin"), dynamic.skin->skin.c_str(), ImGuiComboFlags_HeightLargest))
|
|
|
|
|
{
|
|
|
|
|
for (auto const &skin : dynamic.vehicle->matching_skinsets) {
|
|
|
|
|
bool is_selected = (skin == dynamic.skin);
|
|
|
|
|
if (ImGui::Selectable(skin->skin.c_str(), is_selected))
|
|
|
|
|
dynamic.skin = skin;
|
|
|
|
|
if (is_selected)
|
|
|
|
|
ImGui::SetItemDefaultFocus();
|
|
|
|
|
}
|
|
|
|
|
ImGui::EndCombo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ImGui::BeginCombo(STR_C("Occupancy"), Translations.lookup_c(dynamic.drivertype.c_str())))
|
|
|
|
|
{
|
|
|
|
|
for (auto const &str : occupancy_names) {
|
|
|
|
|
bool is_selected = (str == dynamic.drivertype);
|
|
|
|
|
if (ImGui::Selectable(Translations.lookup_c(str.c_str()), is_selected))
|
|
|
|
|
dynamic.drivertype = str;
|
|
|
|
|
if (is_selected)
|
|
|
|
|
ImGui::SetItemDefaultFocus();
|
|
|
|
|
}
|
|
|
|
|
ImGui::EndCombo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ImGui::InputText(STR_C("Load type"), load_buf.data(), load_buf.size())) {
|
|
|
|
|
dynamic.loadtype = load_buf.data();
|
|
|
|
|
if (!load_buf[0])
|
|
|
|
|
dynamic.loadtype = "none";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dynamic.loadtype != "none")
|
|
|
|
|
ImGui::InputInt(STR_C("Load count"), &dynamic.loadcount, 1, 10);
|
|
|
|
|
else
|
|
|
|
|
dynamic.loadcount = 0;
|
|
|
|
|
|
|
|
|
|
if (dynamic.loadcount < 0)
|
|
|
|
|
dynamic.loadcount = 0;
|
|
|
|
|
|
|
|
|
|
if (ImGui::InputText(STR_C("Parameters"), param_buf.data(), param_buf.size()))
|
|
|
|
|
dynamic.params = param_buf.data();
|
|
|
|
|
|
|
|
|
|
ImGui::NewLine();
|
|
|
|
|
ImGui::TextUnformatted(STR_C("Coupling:"));
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i <= 0x100; i <<= 1) {
|
|
|
|
|
bool selected = dynamic.coupling & i;
|
|
|
|
|
|
|
|
|
|
std::string label = STRN("unknown");
|
|
|
|
|
auto it = coupling_names.find(static_cast<coupling>(i));
|
|
|
|
|
if (it != coupling_names.end())
|
|
|
|
|
label = it->second;
|
|
|
|
|
if (ImGui::Checkbox(Translations.lookup_c(label.c_str()), &selected))
|
|
|
|
|
dynamic.coupling ^= i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|