porymap icon indicating copy to clipboard operation
porymap copied to clipboard

Improvements for the scripting API

Open GriffinRichards opened this issue 1 year ago • 0 comments

Wanted to track some possibilities for adding new features to the API so they aren't forgotten.

  • [x] A more user-friendly way to load scripts, for example by having some Options item to open a file navigator for selecting scripts. (#543)
  • [x] A way to reload scripts without having to reload the whole project (#543)
  • [ ] Interacting with events (in-progress)
  • [x] Replace xflip and yflip in createImage with horizontal and vertical scale. (#456)
  • [x] Reading/writing the border (#455)
  • [ ] Reading/writing connections?
  • [ ] Reading/writing encounter data?
  • [ ] Opening a different map?
  • [ ] Creating/deleting/renaming maps?
  • [ ] Reading/writing other config settings
  • [x] Reading Porymap version (#456)
  • [x] map.get[Primary|Secondary]Tilesets, returns list of all tileset names in respective list (#466)
  • [ ] Reading the current metatile and/or collision selection (superseded by Prefabs tab, support that as well)
  • [ ] Reading positions set with the ruler, or callback(s) for when the ruler is used
  • [ ] Overlay rendering can slow to a crawl or even stop while the mouse is moving. I believe this is the result of updating the scene for the cursor rectangles and generating the message for the status bar (both in Editor::onHoveredMapMetatileChanged)
  • [x] Text rendering is very slow (#475)
  • [ ] Improve text rendering speed further by rendering it once onto an image and subsequently rendering the image. (Done this already, but the resolution is very bad, trying to fix that). This would additionally allow us to support text decoration (e.g. underlining, tables, etc)
  • [ ] Tileset editing functions are very inefficient at scale
  • [x] Update manual to alert users to text formatting features of drawText.
  • [x] Arbitrary shape drawing? (#478, though straight lined shapes only)
  • [ ] let statements in single-line context (e.g. if (true) let foo = 0;) is a syntax error, but for some reason this crashes QJSEngine::importModule rather than returning an Error object. Might not be anything that can reasonably be done about that.
  • [ ] Give each script its own private version of the overlay so that scripts don't need to worry about stomping on changes made by other scripts.
  • [ ] Interactive overlay elements?
  • [ ] The properties added to the global object by Porymap (e.g. map) should not be writable. Their own properties are not, but new ones can be added, and map = {}; for instance is valid and can crash Porymap
  • [x] Handle the case where utility.registerAction("function", "Action") replaces the value of Action if it already exists (either by using unique internal identifier, or just logging a warning) (#518)
  • [x] Display a message if a script fails to load (and allow the message to be turned off). (#518)
  • [x] Display a message(?) if Scripting::invokeAction fails because the registered function name doesn't exist (#518)
  • [ ] Throw JS exceptions for when Porymap logs certain errors from script functions (this might not actually be allowed?)
  • [ ] Reading which mouse tools are selected and when (perhaps this could be used to give the plain mouse tool something more useful to do, with an "on-click" callback)

Additional suggestions more than welcome.

GriffinRichards avatar Aug 04 '22 01:08 GriffinRichards