mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
add reset button
This commit is contained in:
@@ -264,6 +264,9 @@
|
||||
"vcmi.shortcuts.editButton.help" : "Edit key binding",
|
||||
"vcmi.shortcuts.input" : "Change key binding for {%s}.\n\nPlease enter a key or key kombination.",
|
||||
"vcmi.shortcuts.inputSet" : "Key binding for {%s} will be changed to {%s}.\n\nAppend to existing bindings? Otherwise it will be replaced.",
|
||||
"vcmi.shortcuts.reset" : "Reset",
|
||||
"vcmi.shortcuts.reset.help" : "{Reset}\n\nResets key bindings to default",
|
||||
"vcmi.shortcuts.resetConfirm" : "Do you want to reset all key bindings to default?",
|
||||
"vcmi.shortcuts.group.keyboard" : "Keyboard",
|
||||
"vcmi.shortcuts.group.joystickAxes" : "Joystick Axes",
|
||||
"vcmi.shortcuts.group.joystickButtons" : "Joystick Buttons",
|
||||
|
||||
@@ -264,6 +264,9 @@
|
||||
"vcmi.shortcuts.editButton.help" : "Tastenbelegung bearbeiten",
|
||||
"vcmi.shortcuts.input" : "Tastenbelegung für {%s} ändern.\n\nBitte eine Taste oder Tastenkombination eingeben.",
|
||||
"vcmi.shortcuts.inputSet" : "Tastenbelegung für {%s} wird zu {%s}. geändert\n\nZu den existierenten hinzufügen? Ansonsten wird ersetzt.",
|
||||
"vcmi.shortcuts.reset" : "Zurücks.",
|
||||
"vcmi.shortcuts.reset.help" : "{Zurücksetzen}\n\nSetzt Tastenbelegungen auf Standardeinstellungen zurück",
|
||||
"vcmi.shortcuts.resetConfirm" : "Alle Tastenkürzel auf Standardeinstellungen zurücksetzen?",
|
||||
"vcmi.shortcuts.group.keyboard" : "Tastatur",
|
||||
"vcmi.shortcuts.group.joystickAxes" : "Joystick-Achsen",
|
||||
"vcmi.shortcuts.group.joystickButtons" : "Joystick-Tasten",
|
||||
|
||||
@@ -57,6 +57,14 @@ ShortcutsWindow::ShortcutsWindow()
|
||||
slider->setPanningStep(LINE_HEIGHT);
|
||||
slider->setScrollBounds(Rect(-backgroundRect->pos.w + slider->pos.w, 0, slider->pos.x - pos.x + slider->pos.w, slider->pos.h));
|
||||
|
||||
buttonReset = std::make_shared<CButton>(Point(411, 403), AnimationPath::builtin("settingsWindow/button80"), std::make_pair("", MetaString::createFromTextID("vcmi.shortcuts.reset").toString()));
|
||||
buttonReset->setOverlay(std::make_shared<CLabel>(0, 0, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, MetaString::createFromTextID("vcmi.shortcuts.reset").toString()));
|
||||
buttonReset->addCallback([this](){
|
||||
GAME->interface()->showYesNoDialog(MetaString::createFromTextID("vcmi.shortcuts.resetConfirm").toString(), [this](){
|
||||
resetKeyBinding();
|
||||
}, nullptr);
|
||||
});
|
||||
|
||||
fillList(0);
|
||||
}
|
||||
|
||||
@@ -98,7 +106,17 @@ void ShortcutsWindow::fillList(int start)
|
||||
|
||||
void ShortcutsWindow::setKeyBinding(const std::string & id, const std::string & keyName, bool append)
|
||||
{
|
||||
// TODO
|
||||
std::cout << id << " " << keyName << " " << append << "\n";
|
||||
|
||||
fillList(slider->getValue());
|
||||
}
|
||||
|
||||
void ShortcutsWindow::resetKeyBinding()
|
||||
{
|
||||
// TODO
|
||||
|
||||
fillList(slider->getValue());
|
||||
}
|
||||
|
||||
ShortcutElement::ShortcutElement(std::string id, JsonNode keys, int elem, std::function<void(const std::string & id, const std::string & keyName)> func)
|
||||
|
||||
@@ -47,11 +47,13 @@ private:
|
||||
std::shared_ptr<TransparentFilledRectangle> backgroundRect;
|
||||
std::shared_ptr<CSlider> slider;
|
||||
std::vector<std::shared_ptr<ShortcutElement>> listElements;
|
||||
std::shared_ptr<CButton> buttonReset;
|
||||
|
||||
JsonNode shortcuts;
|
||||
|
||||
void fillList(int start);
|
||||
void setKeyBinding(const std::string & id, const std::string & keyName, bool append);
|
||||
void resetKeyBinding();
|
||||
|
||||
public:
|
||||
ShortcutsWindow();
|
||||
|
||||
Reference in New Issue
Block a user