2023-07-04 09:27:16 +00:00
|
|
|
#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"
|
2023-07-04 09:27:16 +00:00
|
|
|
|
|
|
|
namespace Star {
|
|
|
|
|
|
|
|
LuaCallbacks LuaBindings::makeInterfaceCallbacks(MainInterface* mainInterface) {
|
|
|
|
LuaCallbacks callbacks;
|
|
|
|
|
2023-07-05 08:25:16 +00:00
|
|
|
callbacks.registerCallback("bindCanvas", [mainInterface](String const& canvasName, Maybe<bool> ignoreInterfaceScale) -> Maybe<CanvasWidgetPtr> {
|
|
|
|
if (auto canvas = mainInterface->fetchCanvas(canvasName, ignoreInterfaceScale.value(false)))
|
2023-07-04 09:27:16 +00:00
|
|
|
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 {};
|
|
|
|
});
|
|
|
|
|
|
|
|
callbacks.registerCallback("scale", [mainInterface]() -> int {
|
|
|
|
return GuiContext::singleton().interfaceScale();
|
|
|
|
});
|
|
|
|
|
2023-07-04 09:27:16 +00:00
|
|
|
return callbacks;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|