Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split API functions into separate objects #460

Merged
merged 8 commits into from Sep 24, 2022

Conversation

GriffinRichards
Copy link
Collaborator

@GriffinRichards GriffinRichards commented Sep 5, 2022

Renamed API functions

The following are all the previously-existing API functions that had their name changed for 5.0.0. Any functions not listed here remained the same (or were introduced for or after version 5.0.0).

Old name New name
map.getMaxPrimaryTilesetTiles() constants.max_primary_tiles
map.getMaxSecondaryTilesetTiles() constants.max_secondary_tiles
map.getMaxPrimaryTilesetMetatiles() constants.max_primary_metatiles
map.getMaxSecondaryTilesetMetatiles() constants.max_secondary_metatiles
map.getNumTilesInMetatile() constants.tiles_per_metatile
map.getNumMetatileLayers() constants.layers_per_metatile
map.getBaseGameVersion() constants.base_game_version
map.getGridVisibility() utility.getGridVisibility()
map.setGridVisibility(visible) utility.setGridVisibility(visible)
map.getBorderVisibility() utility.getBorderVisibility()
map.setBorderVisibility(visible) utility.setBorderVisibility(visible)
map.getSmartPathsEnabled() utility.getSmartPathsEnabled()
map.setSmartPathsEnabled(enabled) utility.setSmartPathsEnabled(enabled)
map.getCustomScripts() utility.getCustomScripts()
map.getMainTab() utility.getMainTab()
map.setMainTab(tab) utility.setMainTab(tab)
map.getMapViewTab() utility.getMapViewTab()
map.setMapViewTab(tab) utility.setMapViewTab(tab)
map.registerAction(...) utility.registerAction(...)
map.setTimeout(...) utility.setTimeout(...)
map.log(message) utility.log(message)
map.warn(message) utility.warn(message)
map.error(message) utility.error(message)
map.clearOverlay(layer = 0) overlay.clear(layer)
map.clearOverlays() overlay.clear()
map.hideOverlay(layer = 0) overlay.hide(layer)
map.hideOverlays() overlay.hide()
map.showOverlay(layer = 0) overlay.show(layer)
map.showOverlays() overlay.show()
map.getOverlayVisibility(layer = 0) overlay.getVisibility(layer = 0)
map.setOverlayVisbility(visible, layer = 0) overlay.setVisibility(visible, layer)
map.setOverlaysVisibility(visible) overlay.setVisibility(visible)
map.getOverlayX(layer = 0) overlay.getX(layer = 0)
map.getOverlayY(layer = 0) overlay.getY(layer = 0)
map.setOverlayX(x, layer = 0) overlay.setX(x, layer)
map.setOverlayY(y, layer = 0) overlay.setY(y, layer)
map.setOverlaysX(x) overlay.setX(x)
map.setOverlaysY(y) overlay.setY(y)
map.getOverlayPosition(layer = 0) overlay.getPosition(layer = 0)
map.setOverlayPosition(x, y, layer = 0) overlay.setPosition(x, y, layer)
map.setOverlaysPosition(x, y) overlay.setPosition(x, y)
map.moveOverlay(deltaX, deltaY, layer = 0) overlay.move(deltaX, deltaY, layer)
map.moveOverlays(deltaX, deltaY) overlay.move(deltaX, deltaY)
map.addText(...) overlay.addText(...)
map.addRect(...) overlay.addRect(...)
map.addFilledRect(...) [ Removed ]
map.addImage(...) overlay.addImage(...)
map.createImage(...) overlay.createImage(...)
map.addTileImage(...) overlay.addTileImage(...)
map.addMetatileImage(...) overlay.addMetatileImage(...)

Original description

  • All the overlay API functions were acting on MainWindow's graphicsView_Map, now they're actually part of that class. They've all been moved under a new overlay object in the API, and any functions with Overlay in the name have dropped it (e.g. map.setOverlayX becomes overlay.setX).
  • All the overlay functions that address all layers have been replaced with overloaded functions with no layer argument. Example: map.clearOverlay(layer) and map.clearOverlays() become overlay.clear(layer) and overlay.clear().
  • All the miscellaneous logging and utility API functions have been put in a new class called ScriptUtility, and moved to their own object utility in the API. This new class is now fully responsible for the registered action list
  • API functions that always return the same value during a single Porymap session have been replaced with a new constants object in the API that has properties with each of these values.

The behavior of the API functions is otherwise unchanged. I'd like the overlay to be provided separately to each script so they don't need to worry about stomping on each others changes, but that's proving more annoying to do than I thought.

If this looks good I'll update the manual (and changelog) accordingly, and update this description with a full table of all the name changes.

@huderlem huderlem merged commit c81829c into huderlem:master Sep 24, 2022
@GriffinRichards GriffinRichards deleted the api-redesign branch September 24, 2022 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants