Skip to content

Instantly share code, notes, and snippets.

@cmann1
Last active January 9, 2023 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmann1/ac55444265f134ff8bdf83bc25e25d6b to your computer and use it in GitHub Desktop.
Save cmann1/ac55444265f134ff8bdf83bc25e25d6b to your computer and use it in GitHub Desktop.
/*
- Selection:
- Uses prop bounding boxes
- Shift + ctrl to snap to whole tiles instead of half tiles
- Props and entities are snapped by whole tiles if any tiles are selected
- Shift + ctrl to rotate in 5 degree increments
- Props:
- Scaled props stay centred under the mouse
- Ctrl + scroll will no longer skip layers and can also cycle between backdrop layers
- Scroll and shift or scroll and ctrl + shift to rotate props in 5 and 1 degree increments
- Shift + ctrl to snap to whole tiles instead of half tiles
- Prop tool state is not reset when clicking a prop or prop group for the first time
- scale, rotation, palette
- sub layer is never reset
- Prop palette ui updated when changing props with arrow keys
- One prop group must always be selected to prevent crash
- Prop group/sprite scrolling: The mouse wheel consistently scrolls an entire row regardless of the scroll view height
- Scrolling while a tome is open won't change the debug zoom
- The dustmod menu is always accessible in edit mode
- Fixed options menu focus rect remaining when opening dustmod menu
- Plugins are no longer shown in the script trigger/enemy script dropdown
- Scripts panel:
- Script file input and label now on same line
- Script and plugin input won't be cleared when gaining focus
- Scripts without any vars won't have a tab in the script panel
- Script names are displayed without extensions and left truncated to fit panel
- Right click can be used to compile a script instead of control clicking the remove button
- F9 will recompile the first script (can be changed in the editor options)
- Plugin menu:
- Plugins are displayed in a scrollbox to prevent the menu from getting too tall
- Moved Dustmod button above exit level
- Option to move "Dustmod" item above "Exit" in nexus menu
- Enter/jump to edit currently selected map
- Publish requires confirmation
- Plugin menu:
- Slight improvements to list view
- Enter will focus next text box
- Delete button (disabled because currently no way to delete files)
- Left click plugin name to auto-populate source and name fields. Right click to compile
- The source field will be guessed based on the plugin name: [ed/]LOWERCASE_UNDERSCORED_NAME/main.cpp
- Increased "npc" buffer size to help with texture glitches
- Var editor:
- Changed label font, CamelCased property labels, and highlighted headings
- Right align text inputs and reduced width slightly
- Better scrolling behaviour and more consistent layout
- Escape to cancel edit
- Text boxes keep text on focus
- Navigate with tab/shift tab
- Shift to snap angles to 22.5 degrees
- Escape to cancel, and click to accept position/entity select
- Control+Backspace to delete the previous word in a text box
- Control+Shift+Backspace to clear text box
- Prevent "Failed to find class" console spam before a type is selected
- Don't show script in type select if it has no types
- Attributes:
- Added label attribute [label:string]
- Multiple attributes supported with "|", eg. for adding a tooltip to a variable that already has an existing annotation: [colour|tooltip:"TOOLTIP"]
- Added tooltip attribute [tooltip:string,delay:int,font:string,size:int,colour/color:colour]
- Colour value format: AARRGGBB ARGB, "#" and "0x" prefixes optional, alpha value is optional
- Scripttriggers/enemies with the [hidden] attribute won't be displayed in the type menu
- Camera and trigger circles drawn at lower resolution as they become smaller on screen. Might help with lag and black screens when zooming out on large/dense maps
- Zero length camera tolerance handles are not drawn
- Accurate camera node mouse selection
- Fixed gaps in 3 2 1 let's go background at different resolutions
- Fixed player sprite not rotating on slant ceilings
- Script panel: Won't try to compile if source is empty
- Added the [fixed:MODE] annotation for arrays which prevents items being added or removed from arrays.
- Optional MODE can be set to "top" to allow subsequent levels of a multidimensional arrays to be modified.
- Editor plugins now use the "plugin" sprite set
*/
/* - Editor plugins are only loaded once when first entering the editor: */
/* Called when entering editor mode. Only applicable to editor plugins */
void editor_loaded();
/* Called before entering play mode. Only applicable to editor plugins */
void editor_unloaded();
/* - Misc API: */
/* Returns false in the editor and true in game */
bool is_playing()
/* Returns true if a replay is being watched */
bool is_replay()
/* - Persistent streams and override sounds: */
/* Play a sound that will continue to play after a reset, similar to in game music.
* If the specified audio is already playing nothing will happen. script_sound indicates if the sound being played is a script, or built in sound.
* Note that calling audio.stop() on the returned audio won't automatically remove it from the script music registry, use scene.stop_persistent_stream instead. */
audio@ scene.play_persistent_stream(string name, uint sound_group, bool loop, float volume, const bool script_sound);
/* Returns true if the specified persistent stream was stopped. */
bool scene.stop_persistent_stream(string name);
/* Returns the specified persitent sound if it is playing, or null otherwise. */
audio@ scene.get_persistent_stream(string name);
/* Overrides the built in sound named "sound" with "override_sound".
* Any time the game tries to play that sound, the override will be played instead.
* script_sound indicates whether an embedded, or built in sound will be used for the override */
void scene.override_sound(string sound, string override_sound, bool script_sound);
/* Returns true if the sound has been overridden */
bool scene.has_sound_override(string sound);
/* Returns the override for the specified sound, or an empty string */
string scene.get_sound_override(string sound);
/* Returns true if the specified override uses a script sound */
bool scene.is_sound_override_script(string sound);
/* Clears the specified sound overrides if there is one */
void scene.clear_sound_override(string sound);
/* Clears all sound overrides */
void scene.clear_sound_overrides();
/* - Added editor_var_changed callbacks and sync methods for scripts, triggers, and enemies: */
/* Called when one of this script/trigger/enemy's variables is modified in the editor */
void editor_var_changed(var_info@);
class var_info{
/* Returns the name of the variable that changed */
string api_get_name();
/* Returns the index that was changed, or -1 if this variable is not an array */
int api_get_index();
/* For nested variables returns the number of variables above this one */
int api_get_path_length();
/* Returns the name of the parent variable at the specified level */
string api_get_name(uint index);
/* Returns the array index of the parent variable at the specified level, or -1 if it is not an array */
int api_get_index(uint index);
/* Convenience method that returns the entire path as a string in the format: "parent_var.parent_var2.var"
* If include_array_indices is true, arrays in the path will also include an index, e.g. "parent_var[i]" */
string api_get_path(bool include_array_indices);
}
/* Use after changing persistent variables via script to update values in the script/trigger/enemy panel. */
void editor_sync_vars_menu();
void scripttrigger.editor_sync_vars_menu();
void scriptenemy.editor_sync_vars_menu();
/* - Added methods to editor_api for checking focus */
class editor_api {
/* Returns true if a control in the editor has focus */
bool has_focus();
/* Returns true if a control in the editor, e.g. a text box, is taking keyboard input */
bool is_polling_keyboard();
}
/* - Custom collision handling: */
class tilecollision {
int type();
void hit(bool is_solid);
void hit_x(float outside_x);
void hit_y(float outside_y);
void type(int type);
}
class controllable {
/* Change which ground surface angles this entity considers slopes, or slants.
* Slopes default to 45, and slants to 26.
* Required to allow non-45 degress slope sliding and for the player sprite to
* automatically rotate to match the ground angle. */
void set_ground_angles(int slope_min, int slope_max, int slant_min, int slant_max);
/* Change which roof surface angles this entity considers slopes, or slants.
* Slopes defaults to 135, and slants to 154.
* Required for the player sprite to automatically rotate to match the
* ceiling angle. */
void set_roof_angles(int slope_min, int slope_max, int slant_min, int slant_max);
/* Change which wall surface angles this entity considers down and up facing
* slants.
* Down facing defaults to 116, and up facing to 64.
* Required or wall angles outside of the range
* slant_up_min < 90 < slant_down_max
* won't work, even if the custom collision handler returns a collision. */
void set_wall_angles(int slant_down_min, int slant_down_max, int slant_up_min, int slant_up_max);
/* Performs the default collision check on the specified side used by
* all entities and writes the result into t.
*
* `moving` indicates if the collision should compensate for movement of
* the hitbox over the previous subframe (i.e. for checking for collisions
* between subframes).
*
* `snap_offset` indicates an additional offset outside of the collision
* for the entity to look for a surface used in e.g. wall snap jumps/dashes.
*
* Returns true if the collision hits anything.
*/
bool check_collision(tilecollision@ t, int side, bool moving, float snap_offset)
/* Overrides the default collision checking for this entity. Setting
* this to null will clear the handler.
*
* The callback should have the signature:
*
* void func_name(controllable@ ec, tilecollision@ tc, int side, bool moving, float snap_offset, int arg)
* `ec`: The entity to check collisions for
* `tc`: The tile collision object to write results to
* `side`: which surface type to check for collisions, see the `side_types` enum.
* `moving`: Indicates if the collision should compensate for movement over the last subframe.
* `snap_offset`: Indicates an extra offset to look for collisions used in e.g. snap jumps/dashes
*
* Use the provided tilecollision object to return the results of the custom collision:
* hit(): Set to true to indicate a collision happened
* type(): Sets the surface angle of the collision (angle() is not used)
* hit_x/y(): The position of the collision
* Calling controllable::check_collision_ground() can be used
* perform the default tile collision handling when needed
* */
void set_collision_handler(callback_base@ base_obj, string callback_method, int arg);
/* Overrides the default surface texture type lookup for entity.
* Setting this to null will clear the handler.
* The callback should have the signature void func_name(controllable@, texture_type_query@, int) */
void set_texture_type_handler(callback_base@ base_obj, string callback_method, int arg);
/* Set the drawing offsets. This does not include stun offsets. */
void draw_offset_x(float x_offset);
void draw_offset_y(float y_offset);
}
/* Certain sounds, e.g. player footstep sounds, check the tiles around the
* player's feet to determine which sounds to play based on the tile
* sprite set and index. controllable::set_texture_type_handler can be used
* to bypass that behaviour and provide a custom texture type.
*
* This class is used to pass values back and forth during a texture
* type callback registered with controllable::set_texture_type_handler.
* */
class texture_type_query {
/* The location to check */
int x();
int y():
/* Is the query for a ground surface? */
bool top_surface();
/* Set this to return the texture type. Valid values are:
* none, stone, dirt, metal, stone, grass,
* water, wood, wood, dirt, carpet, poly
* or return an empty string to indicate that the built in tile texture lookup should be run.
* */
void result(string _result);
string result();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment