#include "StarInterfaceLuaBindings.hpp" #include "StarWidgetLuaBindings.hpp" #include "StarJsonExtra.hpp" #include "StarLuaGameConverters.hpp" #include "StarMainInterface.hpp" #include "StarGuiContext.hpp" namespace Star { LuaCallbacks LuaBindings::makeInterfaceCallbacks(MainInterface* mainInterface) { LuaCallbacks callbacks; callbacks.registerCallback("bindCanvas", [mainInterface](String const& canvasName, Maybe ignoreInterfaceScale) -> Maybe { if (auto canvas = mainInterface->fetchCanvas(canvasName, ignoreInterfaceScale.value(false))) return canvas; return {}; }); callbacks.registerCallback("bindRegisteredPane", [mainInterface](String const& registeredPaneName) -> Maybe { if (auto pane = mainInterface->paneManager()->maybeRegisteredPane(MainInterfacePanesNames.getLeft(registeredPaneName))) return pane->makePaneCallbacks(); return {}; }); callbacks.registerCallback("displayRegisteredPane", [mainInterface](String const& registeredPaneName) { auto pane = MainInterfacePanesNames.getLeft(registeredPaneName); auto paneManager = mainInterface->paneManager(); if (paneManager->maybeRegisteredPane(pane)) paneManager->displayRegisteredPane(pane); }); callbacks.registerCallback("scale", [mainInterface]() -> int { return GuiContext::singleton().interfaceScale(); }); callbacks.registerCallback("queueMessage", [mainInterface](String const& message, Maybe cooldown, Maybe springState) { mainInterface->queueMessage(message, cooldown, springState.value(0)); }); return callbacks; } }