Add onBorderVisibilityToggled callback
This commit is contained in:
parent
3e7bfe126a
commit
be4a5e8528
5 changed files with 17 additions and 3 deletions
|
@ -88,7 +88,7 @@ public:
|
|||
void setSelectedConnectionFromMap(QString mapName);
|
||||
void updatePrimaryTileset(QString tilesetLabel, bool forceLoad = false);
|
||||
void updateSecondaryTileset(QString tilesetLabel, bool forceLoad = false);
|
||||
void toggleBorderVisibility(bool visible);
|
||||
void toggleBorderVisibility(bool visible, bool enableScriptCallback = true);
|
||||
void updateCustomMapHeaderValues(QTableWidget *);
|
||||
void configureEncounterJSON(QWidget *);
|
||||
Tileset *getCurrentMapPrimaryTileset();
|
||||
|
|
|
@ -22,6 +22,7 @@ enum CallbackType {
|
|||
OnTilesetUpdated,
|
||||
OnMainTabChanged,
|
||||
OnMapViewTabChanged,
|
||||
OnBorderVisibilityToggled,
|
||||
};
|
||||
|
||||
class Scripting
|
||||
|
@ -52,6 +53,7 @@ public:
|
|||
static void cb_TilesetUpdated(QString tilesetName);
|
||||
static void cb_MainTabChanged(int oldTab, int newTab);
|
||||
static void cb_MapViewTabChanged(int oldTab, int newTab);
|
||||
static void cb_BorderVisibilityToggled(bool visible);
|
||||
static bool tryErrorJS(QJSValue js);
|
||||
|
||||
private:
|
||||
|
|
|
@ -1936,11 +1936,13 @@ void Editor::updateSecondaryTileset(QString tilesetLabel, bool forceLoad)
|
|||
}
|
||||
}
|
||||
|
||||
void Editor::toggleBorderVisibility(bool visible)
|
||||
void Editor::toggleBorderVisibility(bool visible, bool enableScriptCallback)
|
||||
{
|
||||
this->setBorderItemsVisible(visible);
|
||||
this->setConnectionsVisibility(visible);
|
||||
porymapConfig.setShowBorder(visible);
|
||||
if (enableScriptCallback)
|
||||
Scripting::cb_BorderVisibilityToggled(visible);
|
||||
}
|
||||
|
||||
void Editor::updateCustomMapHeaderValues(QTableWidget *table)
|
||||
|
|
|
@ -794,7 +794,7 @@ bool MainWindow::getGridVisibility() {
|
|||
}
|
||||
|
||||
void MainWindow::setBorderVisibility(bool visible) {
|
||||
this->editor->toggleBorderVisibility(visible);
|
||||
this->editor->toggleBorderVisibility(visible, false);
|
||||
}
|
||||
|
||||
bool MainWindow::getBorderVisibility() {
|
||||
|
|
|
@ -15,6 +15,7 @@ QMap<CallbackType, QString> callbackFunctions = {
|
|||
{OnTilesetUpdated, "onTilesetUpdated"},
|
||||
{OnMainTabChanged, "onMainTabChanged"},
|
||||
{OnMapViewTabChanged, "onMapViewTabChanged"},
|
||||
{OnBorderVisibilityToggled, "onBorderVisibilityToggled"},
|
||||
};
|
||||
|
||||
Scripting *instance = nullptr;
|
||||
|
@ -241,6 +242,15 @@ void Scripting::cb_MapViewTabChanged(int oldTab, int newTab) {
|
|||
instance->invokeCallback(OnMapViewTabChanged, args);
|
||||
}
|
||||
|
||||
void Scripting::cb_BorderVisibilityToggled(bool visible) {
|
||||
if (!instance) return;
|
||||
|
||||
QJSValueList args {
|
||||
visible,
|
||||
};
|
||||
instance->invokeCallback(OnBorderVisibilityToggled, args);
|
||||
}
|
||||
|
||||
QJSValue Scripting::fromBlock(Block block) {
|
||||
QJSValue obj = instance->engine->newObject();
|
||||
obj.setProperty("metatileId", block.metatileId);
|
||||
|
|
Loading…
Reference in a new issue