osb/source/frontend/StarInterfaceLuaBindings.cpp

46 lines
1.6 KiB
C++
Raw Normal View History

#include "StarInterfaceLuaBindings.hpp"
#include "StarWidgetLuaBindings.hpp"
#include "StarJsonExtra.hpp"
#include "StarLuaGameConverters.hpp"
#include "StarMainInterface.hpp"
2023-07-04 12:36:27 +00:00
#include "StarGuiContext.hpp"
namespace Star {
LuaCallbacks LuaBindings::makeInterfaceCallbacks(MainInterface* mainInterface) {
LuaCallbacks callbacks;
callbacks.registerCallback("bindCanvas", [mainInterface](String const& canvasName, Maybe<bool> ignoreInterfaceScale) -> Maybe<CanvasWidgetPtr> {
if (auto canvas = mainInterface->fetchCanvas(canvasName, ignoreInterfaceScale.value(false)))
return canvas;
return {};
});
2023-07-04 12:36:27 +00:00
callbacks.registerCallback("bindRegisteredPane", [mainInterface](String const& registeredPaneName) -> Maybe<LuaCallbacks> {
if (auto pane = mainInterface->paneManager()->maybeRegisteredPane(MainInterfacePanesNames.getLeft(registeredPaneName)))
return pane->makePaneCallbacks();
return {};
});
2023-10-31 04:31:53 +00:00
callbacks.registerCallback("displayRegisteredPane", [mainInterface](String const& registeredPaneName) {
auto pane = MainInterfacePanesNames.getLeft(registeredPaneName);
auto paneManager = mainInterface->paneManager();
if (paneManager->maybeRegisteredPane(pane))
paneManager->displayRegisteredPane(pane);
});
2023-07-04 12:36:27 +00:00
callbacks.registerCallback("scale", []() -> int {
2023-07-04 12:36:27 +00:00
return GuiContext::singleton().interfaceScale();
});
2023-07-17 12:20:39 +00:00
callbacks.registerCallback("queueMessage", [mainInterface](String const& message, Maybe<float> cooldown, Maybe<float> springState) {
mainInterface->queueMessage(message, cooldown, springState.value(0));
});
return callbacks;
}
}