Merge pull request #1014 from MihailRis/patch-0.32.2
Some checks are pending
x86-64 AppImage / build-appimage (ubuntu-22.04) (push) Waiting to run
Build / Build (push) Waiting to run
Macos Build / build-dmg (push) Waiting to run
Windows Build (CLang) / build-windows (clang, windows-latest) (push) Waiting to run
MSVC Build / build-windows (windows-2022) (push) Waiting to run

0.32.2 patch
This commit is contained in:
MihailRis 2026-10-07 23:31:28 +03:00 • committed by GitHub
commit 05c0a1868d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 22 additions and 8 deletions

View file

@ -8,7 +8,7 @@ using runnable = std::function<void()>;
template<class T> using supplier = std::function<T()>;
template<class T> using consumer = std::function<void(T)>;
using KeyCallback = std::function<bool()>;
using InputCallback = std::function<bool()>;
// data sources
using wstringsupplier = std::function<std::wstring()>;

View file

@ -28,7 +28,10 @@ MenuScreen::~MenuScreen() = default;
void MenuScreen::onOpen() {
engine.getContentControl().resetContent({});
auto menu = engine.getGUI().getMenu();
auto& gui = engine.getGUI();
gui.setActiveFrame(gui::GUI::CORE_MAIN);
auto menu = gui.getMenu();
menu->reset();
}

View file

@ -44,10 +44,13 @@ static int l_add_callback(lua::State* L) {
auto& input = engine->getInput();
if (pos != std::string::npos) {
std::string prefix = bindname.substr(0, pos);
auto prefix = std::string_view(bindname).substr(0, pos);
if (prefix == "key") {
auto key = input_util::keycode_from(bindname.substr(pos + 1));
handler = input.addKeyCallback(key, actual_callback);
} else if (prefix == "mouse") {
auto mouse = input_util::mousecode_from(bindname.substr(pos + 1));
handler = input.addMouseCallback(mouse, actual_callback);
}
}

View file

@ -263,7 +263,7 @@ runnable lua::create_runnable(State* L) {
};
}
KeyCallback lua::create_simple_handler(State* L) {
InputCallback lua::create_simple_handler(State* L) {
auto funcptr = create_lambda_handler(L);
return [=]() -> bool {
if (!get_from_registry(L, LAMBDAS_TABLE, *funcptr, false)) {

View file

@ -665,7 +665,7 @@ namespace lua {
}
runnable create_runnable(lua::State*);
KeyCallback create_simple_handler(lua::State*);
InputCallback create_simple_handler(lua::State*);
scripting::common_func create_lambda(lua::State*);
scripting::common_func create_lambda_nothrow(lua::State*);

View file

@ -216,10 +216,17 @@ public:
return bindings;
}
ObserverHandler addKeyCallback(Keycode key, KeyCallback callback) override {
ObserverHandler addKeyCallback(Keycode key, InputCallback callback) override {
return keyCallbacks[key].add(std::move(callback));
}
ObserverHandler addMouseCallback(Mousecode button, InputCallback callback) override {
return addKeyCallback(
static_cast<Keycode>(MOUSE_KEYS_OFFSET + static_cast<int>(button)),
std::move(callback)
);
}
const std::vector<Keycode>& getPressedKeys() const override {
return pressedKeys;
}

View file

@ -288,12 +288,13 @@ public:
virtual const Bindings& getBindings() const = 0;
virtual ObserverHandler addKeyCallback(Keycode key, KeyCallback callback) = 0;
virtual ObserverHandler addKeyCallback(Keycode key, InputCallback callback) = 0;
virtual ObserverHandler addMouseCallback(Mousecode button, InputCallback callback) = 0;
virtual const std::vector<Keycode>& getPressedKeys() const = 0;
virtual const std::vector<uint>& getCodepoints() const = 0;
ObserverHandler addCallback(const std::string& name, KeyCallback callback) {
ObserverHandler addCallback(const std::string& name, InputCallback callback) {
return getBindings().require(name).onactived.add(callback);
}
};