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

Merge remote-tracking branch 'manul-public/master' into manul-staging

This commit is contained in:
WLs50
2025-04-05 14:24:53 +02:00
45 changed files with 875 additions and 477 deletions

View File

@@ -21,8 +21,15 @@ bool ui::keymapper_panel::key(int key)
key |= keyboard_input::keymodifier::shift;
if (Global.ctrlState)
key |= keyboard_input::keymodifier::control;
// F10 unbinds the key.
if (it->second.compare("f10") == 0)
key = 0;
keyboard.bindings().insert_or_assign(bind_active, key);
// Replace the binding with a new key.
auto it2 = keyboard.bindings().find(bind_active);
if (it2 != keyboard.bindings().end()) {
it2->second = std::tuple<int, std::string>(key, std::get<std::string>(it2->second));
}
bind_active = user_command::none;
keyboard.bind();
@@ -45,18 +52,26 @@ void ui::keymapper_panel::render()
if (ImGui::Button(STR_C("Save")))
keyboard.dump_bindings();
for (const std::pair<user_command, int> &binding : keyboard.bindings()) {
for (const std::pair<user_command, std::tuple<int, std::string>> &binding : keyboard.bindings()) {
// Binding ID
ImGui::AlignTextToFramePadding();
ImGui::Text(simulation::Commands_descriptions[static_cast<std::size_t>(binding.first)].name.c_str());
// Binding description
std::string description = std::get<std::string>(binding.second);
ImGui::SameLine(260);
ImGui::Text((description.size() > 0 ? description : "(No description)").c_str());
// Binding key button
int keycode = std::get<int>(binding.second);
std::string label;
if (binding.second & keyboard_input::keymodifier::control)
if (keycode & keyboard_input::keymodifier::control)
label += "ctrl + ";
if (binding.second & keyboard_input::keymodifier::shift)
if (keycode & keyboard_input::keymodifier::shift)
label += "shift + ";
auto it = keyboard.keytonamemap.find(binding.second & 0xFFFF);
auto it = keyboard.keytonamemap.find(keycode & 0xFFFF);
if (it != keyboard.keytonamemap.end())
label += it->second;
@@ -64,7 +79,7 @@ void ui::keymapper_panel::render()
bool styles_pushed = false;
if (bind_active == binding.first) {
label = "?";
label = "Press key (F10 to unbind)";
ImVec4 active_col = ImGui::GetStyleColorVec4(ImGuiCol_ButtonActive);
ImGui::PushStyleColor(ImGuiCol_Button, active_col);
styles_pushed = true;

View File

@@ -95,7 +95,7 @@ void ui::vehicles_bank::parse_category_entry(const std::string &param)
std::string mini;
std::getline(stream, mini, ',');
category_icons.emplace(ctx_type, "textures/mini/" + ToLower(mini));
category_icons.emplace(ctx_type, "textures/mini/" + ToLower(mini) + ".bmp");
}
void ui::vehicles_bank::parse_controllable_entry(const std::string &target, const std::string &param)
@@ -122,12 +122,12 @@ void ui::vehicles_bank::parse_texture_info(const std::string &target, const std:
set.meta = meta;
if (!mini.empty())
group_icons.emplace(mini, std::move(deferred_image("textures/mini/" + ToLower(mini))));
group_icons.emplace(mini, std::move(deferred_image("textures/mini/" + ToLower(mini) + ".bmp")));
if (!miniplus.empty())
set.mini = std::move(deferred_image("textures/mini/" + ToLower(miniplus)));
set.mini = std::move(deferred_image("textures/mini/" + ToLower(miniplus) + ".bmp"));
else if (!mini.empty())
set.mini = std::move(deferred_image("textures/mini/" + ToLower(mini)));
set.mini = std::move(deferred_image("textures/mini/" + ToLower(mini) + ".bmp"));
set.skin = ToLower(target);
erase_extension(set.skin);

View File

@@ -19,7 +19,7 @@ private:
std::shared_ptr<const vehicle_desc> selected_vehicle;
const std::string *selected_group = nullptr;
const skin_set *selected_skinset = nullptr;
bool display_by_groups = false;
bool display_by_groups = true;
deferred_image placeholder_mini;
std::array<char, 128> search_query = { 0 };