1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00
Files
vcmi/client/windows/settings/KeyBindingsWindow.h

79 lines
2.2 KiB
C++
Raw Normal View History

2025-07-18 22:31:16 +02:00
/*
2025-07-19 16:46:22 +02:00
* KeyBindingsWindow.h, part of VCMI engine
2025-07-18 22:31:16 +02:00
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#pragma once
#include "../CWindowObject.h"
#include "../../../lib/json/JsonNode.h"
2025-07-19 15:45:34 +02:00
#include "../../../lib/texts/MetaString.h"
2025-07-18 22:31:16 +02:00
class CFilledTexture;
class CButton;
class CLabel;
class TransparentFilledRectangle;
class CSlider;
2025-07-19 13:59:55 +02:00
class CTextBox;
2025-07-18 22:31:16 +02:00
const int MAX_LINES = 11;
const int LINE_HEIGHT = 30;
2025-07-19 16:46:22 +02:00
class KeyBindingElement : public CIntObject
2025-07-18 22:31:16 +02:00
{
private:
std::shared_ptr<CButton> buttonEdit;
std::shared_ptr<CLabel> labelName;
std::shared_ptr<CLabel> labelKeys;
std::shared_ptr<TransparentFilledRectangle> seperationLine; // rectangle is cleaner than line...
2025-07-19 15:45:34 +02:00
MetaString popupText;
2025-07-19 13:59:55 +02:00
std::function<void(const std::string & id, const std::string & keyName)> func;
2025-07-19 15:45:34 +02:00
void showPopupWindow(const Point & cursorPosition) override;
2025-07-18 22:31:16 +02:00
public:
2025-07-19 16:46:22 +02:00
KeyBindingElement(std::string id, JsonNode keys, int elem, std::function<void(const std::string & id, const std::string & keyName)> func);
KeyBindingElement(std::string group, int elem);
2025-07-18 22:31:16 +02:00
};
2025-07-19 16:46:22 +02:00
class KeyBindingsWindow : public CWindowObject
2025-07-18 22:31:16 +02:00
{
private:
std::shared_ptr<CFilledTexture> backgroundTexture;
std::shared_ptr<CButton> buttonOk;
std::shared_ptr<CLabel> labelTitle;
std::shared_ptr<TransparentFilledRectangle> backgroundRect;
std::shared_ptr<CSlider> slider;
2025-07-19 16:46:22 +02:00
std::vector<std::shared_ptr<KeyBindingElement>> listElements;
2025-07-19 14:28:48 +02:00
std::shared_ptr<CButton> buttonReset;
2025-07-18 22:31:16 +02:00
void fillList(int start);
2025-07-19 15:19:09 +02:00
void setKeyBinding(const std::string & id, const std::string & group, const std::string & keyName, bool append);
2025-07-19 14:28:48 +02:00
void resetKeyBinding();
2025-07-18 22:31:16 +02:00
public:
2025-07-19 16:46:22 +02:00
KeyBindingsWindow();
2025-07-18 22:31:16 +02:00
};
2025-07-19 16:46:22 +02:00
class KeyBindingsEditWindow : public CWindowObject
2025-07-19 13:09:15 +02:00
{
private:
2025-07-19 13:59:55 +02:00
std::shared_ptr<CFilledTexture> backgroundTexture;
std::shared_ptr<CTextBox> text;
std::string id;
std::function<void(const std::string & id, const std::string & keyName)> func;
2025-07-19 15:45:34 +02:00
void keyReleased(const std::string & keyName) override;
2025-07-19 16:32:19 +02:00
void notFocusedClick() override;
2025-07-19 13:09:15 +02:00
public:
2025-07-19 16:46:22 +02:00
KeyBindingsEditWindow(const std::string & id, std::function<void(const std::string & id, const std::string & keyName)> func);
2025-07-19 13:09:15 +02:00
};