2021-02-20 08:21:58 +01:00
|
|
|
#ifndef EDITOR_H
|
|
|
|
#define EDITOR_H
|
|
|
|
|
2023-03-21 17:34:08 +01:00
|
|
|
#include "Constants.h"
|
2021-02-21 00:40:11 +01:00
|
|
|
#include "CustomLevels.h"
|
|
|
|
|
2023-05-24 01:21:53 +02:00
|
|
|
#include <map>
|
2021-02-21 00:40:11 +01:00
|
|
|
#include <SDL.h>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2023-05-24 01:21:53 +02:00
|
|
|
enum EditorTilesets
|
|
|
|
{
|
|
|
|
EditorTileset_SPACE_STATION = 0,
|
|
|
|
EditorTileset_OUTSIDE = 1,
|
|
|
|
EditorTileset_LAB = 2,
|
|
|
|
EditorTileset_WARP_ZONE = 3,
|
|
|
|
EditorTileset_SHIP = 4,
|
|
|
|
|
|
|
|
NUM_EditorTilesets
|
|
|
|
};
|
|
|
|
|
|
|
|
struct EditorTilecolInfo
|
|
|
|
{
|
|
|
|
const char* foreground_type;
|
|
|
|
int foreground_base;
|
|
|
|
const char* background_type;
|
|
|
|
int background_base;
|
2023-06-06 21:08:51 +02:00
|
|
|
bool direct_mode;
|
2023-12-10 03:26:30 +01:00
|
|
|
bool bg_ignores_walls;
|
2023-05-24 01:21:53 +02:00
|
|
|
};
|
|
|
|
|
2023-03-02 07:45:22 +01:00
|
|
|
enum EditorTools
|
|
|
|
{
|
|
|
|
EditorTool_WALLS,
|
|
|
|
EditorTool_BACKING,
|
|
|
|
EditorTool_SPIKES,
|
|
|
|
EditorTool_TRINKETS,
|
|
|
|
EditorTool_CHECKPOINTS,
|
|
|
|
EditorTool_DISAPPEARING_PLATFORMS,
|
|
|
|
EditorTool_CONVEYORS,
|
|
|
|
EditorTool_MOVING_PLATFORMS,
|
|
|
|
EditorTool_ENEMIES,
|
|
|
|
EditorTool_GRAVITY_LINES,
|
|
|
|
EditorTool_ROOMTEXT,
|
|
|
|
EditorTool_TERMINALS,
|
|
|
|
EditorTool_SCRIPTS,
|
|
|
|
EditorTool_WARP_TOKENS,
|
|
|
|
EditorTool_WARP_LINES,
|
|
|
|
EditorTool_CREWMATES,
|
|
|
|
EditorTool_START_POINT,
|
|
|
|
|
|
|
|
NUM_EditorTools
|
|
|
|
};
|
|
|
|
|
|
|
|
enum EditorStates
|
|
|
|
{
|
|
|
|
EditorState_DRAW,
|
|
|
|
EditorState_SCRIPTS,
|
|
|
|
EditorState_MENU
|
|
|
|
};
|
|
|
|
|
|
|
|
enum EditorSubStates
|
|
|
|
{
|
|
|
|
EditorSubState_MAIN,
|
|
|
|
|
|
|
|
EditorSubState_DRAW_INPUT,
|
|
|
|
EditorSubState_DRAW_BOX,
|
|
|
|
EditorSubState_DRAW_WARPTOKEN,
|
|
|
|
|
2023-03-05 19:59:36 +01:00
|
|
|
EditorSubState_SCRIPTS_EDIT,
|
|
|
|
|
|
|
|
EditorSubState_MENU_INPUT
|
2023-03-02 07:45:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enum TileTypes
|
|
|
|
{
|
|
|
|
TileType_NONSOLID,
|
|
|
|
TileType_SOLID,
|
|
|
|
TileType_SPIKE
|
|
|
|
};
|
|
|
|
|
|
|
|
enum BoxTypes
|
|
|
|
{
|
|
|
|
BoxType_SCRIPT,
|
|
|
|
BoxType_ENEMY,
|
2023-03-05 19:59:36 +01:00
|
|
|
BoxType_PLATFORM,
|
|
|
|
BoxType_COPY
|
|
|
|
};
|
|
|
|
|
|
|
|
enum BoxCorner
|
|
|
|
{
|
|
|
|
BoxCorner_FIRST,
|
|
|
|
BoxCorner_LAST
|
2023-03-02 07:45:22 +01:00
|
|
|
};
|
|
|
|
|
2021-02-21 00:40:11 +01:00
|
|
|
// Text entry field type
|
2023-03-05 19:59:36 +01:00
|
|
|
enum TextMode
|
2021-02-21 00:40:11 +01:00
|
|
|
{
|
|
|
|
TEXT_NONE,
|
|
|
|
|
|
|
|
// In-editor text fields
|
|
|
|
TEXT_LOAD,
|
|
|
|
TEXT_SAVE,
|
|
|
|
TEXT_ROOMNAME,
|
|
|
|
TEXT_SCRIPT,
|
|
|
|
TEXT_ROOMTEXT,
|
|
|
|
TEXT_GOTOROOM,
|
|
|
|
LAST_EDTEXT = TEXT_GOTOROOM,
|
|
|
|
|
|
|
|
// Settings-mode text fields
|
|
|
|
TEXT_TITLE,
|
2023-03-05 19:59:36 +01:00
|
|
|
TEXT_DESC1,
|
|
|
|
TEXT_DESC2,
|
|
|
|
TEXT_DESC3,
|
2021-02-21 00:40:11 +01:00
|
|
|
TEXT_WEBSITE,
|
|
|
|
TEXT_CREATOR,
|
|
|
|
NUM_TEXTMODES,
|
|
|
|
|
|
|
|
// Text modes with an entity
|
|
|
|
FIRST_ENTTEXT = TEXT_SCRIPT,
|
|
|
|
LAST_ENTTEXT = TEXT_ROOMTEXT
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GhostInfo
|
|
|
|
{
|
|
|
|
int rx; // game.roomx-100
|
|
|
|
int ry; // game.roomy-100
|
|
|
|
int x; // .xp
|
|
|
|
int y; // .yp
|
|
|
|
int col; // .colour
|
2023-01-02 01:36:43 +01:00
|
|
|
SDL_Color realcol;
|
2021-02-21 00:40:11 +01:00
|
|
|
int frame; // .drawframe
|
|
|
|
};
|
|
|
|
|
|
|
|
class editorclass
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
editorclass(void);
|
|
|
|
void reset(void);
|
|
|
|
|
2023-05-24 01:21:53 +02:00
|
|
|
void register_tileset(EditorTilesets tileset, const char* name);
|
2023-12-10 03:26:30 +01:00
|
|
|
void register_tilecol(EditorTilesets tileset, int index, const char* foreground_type, int foreground_base, const char* background_type, int background_base, bool direct, bool bg_ignores_walls);
|
2023-06-06 21:08:51 +02:00
|
|
|
void register_tilecol(EditorTilesets tileset, int index, const char* foreground_type, int foreground_base, const char* background_type, int background_base, bool direct);
|
2023-05-24 01:21:53 +02:00
|
|
|
void register_tilecol(EditorTilesets tileset, int index, const char* foreground_type, int foreground_base, const char* background_type, int background_base);
|
|
|
|
|
2023-03-02 07:45:22 +01:00
|
|
|
void register_tool(EditorTools tool, const char* name, const char* keychar, SDL_KeyCode key, bool shift);
|
|
|
|
|
|
|
|
void draw_tool(EditorTools tool, int x, int y);
|
|
|
|
|
2023-03-21 17:34:08 +01:00
|
|
|
void get_tile_fill(int tilex, int tiley, int tile, bool connected[SCREEN_HEIGHT_TILES][SCREEN_WIDTH_TILES]);
|
|
|
|
|
2023-03-02 07:45:22 +01:00
|
|
|
void handle_tile_placement(int tile);
|
|
|
|
|
|
|
|
void tool_remove();
|
|
|
|
void entity_clicked(int index);
|
|
|
|
void tool_place();
|
|
|
|
|
2023-03-20 13:00:58 +01:00
|
|
|
void get_input_line(enum TextMode mode, const std::string& prompt, std::string* ptr);
|
2021-02-21 00:40:11 +01:00
|
|
|
|
2023-03-05 19:59:36 +01:00
|
|
|
void show_note(const char* text);
|
2023-03-02 07:45:22 +01:00
|
|
|
|
2023-03-29 09:18:42 +02:00
|
|
|
void add_entity(int rx, int ry, int xp, int yp, int tp, int p1 = 0, int p2 = 0, int p3 = 0, int p4 = 0, int p5 = 320, int p6 = 240);
|
2023-03-02 07:45:22 +01:00
|
|
|
|
2023-03-05 19:59:36 +01:00
|
|
|
void remove_entity(int t);
|
2023-03-02 07:45:22 +01:00
|
|
|
|
2023-03-29 09:18:42 +02:00
|
|
|
int get_entity_at(int rx, int ry, int xp, int yp);
|
2021-02-21 00:40:11 +01:00
|
|
|
|
2023-03-05 19:59:36 +01:00
|
|
|
void set_tile(int x, int y, int t);
|
2023-05-24 01:21:53 +02:00
|
|
|
int get_tile(int x, int y);
|
2021-02-21 00:40:11 +01:00
|
|
|
|
2023-05-24 01:21:53 +02:00
|
|
|
bool is_warp_zone_background(int tile);
|
|
|
|
int autotile(int tile_x, int tile_y);
|
|
|
|
bool autotile_connector(int x, int y, TileTypes original_type);
|
|
|
|
EditorTilecolInfo get_tilecol_data(void);
|
2021-02-21 00:40:11 +01:00
|
|
|
|
2023-03-05 19:59:36 +01:00
|
|
|
TileTypes get_abs_tile_type(int x, int y, bool wrap);
|
|
|
|
TileTypes get_tile_type(int x, int y, bool wrap);
|
2021-02-21 00:40:11 +01:00
|
|
|
|
2023-03-05 19:59:36 +01:00
|
|
|
bool lines_can_pass(int x, int y);
|
2021-02-21 00:40:11 +01:00
|
|
|
|
2023-12-01 03:24:10 +01:00
|
|
|
void make_autotiling_base(void);
|
|
|
|
|
2023-03-05 19:59:36 +01:00
|
|
|
int get_enemy_tile(int t);
|
2021-02-21 00:40:11 +01:00
|
|
|
|
|
|
|
void switch_tileset(const bool reversed);
|
|
|
|
void switch_tilecol(const bool reversed);
|
|
|
|
void clamp_tilecol(const int rx, const int ry, const bool wrap);
|
|
|
|
void switch_enemy(const bool reversed);
|
|
|
|
void switch_warpdir(const bool reversed);
|
|
|
|
|
2023-03-02 07:45:22 +01:00
|
|
|
EditorStates state;
|
|
|
|
EditorSubStates substate;
|
|
|
|
|
2023-05-24 01:21:53 +02:00
|
|
|
std::map<std::string, std::vector<int> > autotile_types;
|
|
|
|
std::map<EditorTilesets, std::map<int, EditorTilecolInfo> > tileset_colors;
|
|
|
|
|
|
|
|
const char* tileset_names[NUM_EditorTilesets];
|
|
|
|
int tileset_min_colour[NUM_EditorTilesets];
|
|
|
|
int tileset_max_colour[NUM_EditorTilesets];
|
2023-06-06 21:08:51 +02:00
|
|
|
int tileset_min_colour_direct[NUM_EditorTilesets];
|
|
|
|
int tileset_max_colour_direct[NUM_EditorTilesets];
|
2023-05-24 01:21:53 +02:00
|
|
|
|
2023-03-05 19:59:36 +01:00
|
|
|
const char* tool_names[NUM_EditorTools];
|
|
|
|
const char* tool_key_chars[NUM_EditorTools];
|
|
|
|
SDL_KeyCode tool_keys[NUM_EditorTools];
|
|
|
|
bool tool_requires_shift[NUM_EditorTools];
|
2023-03-02 07:45:22 +01:00
|
|
|
|
|
|
|
EditorTools current_tool;
|
|
|
|
|
2023-03-05 19:59:36 +01:00
|
|
|
BoxTypes box_type;
|
|
|
|
BoxCorner box_corner;
|
|
|
|
|
|
|
|
SDL_Point box_point;
|
|
|
|
|
2021-02-21 00:40:11 +01:00
|
|
|
int entcol;
|
2023-01-02 01:36:43 +01:00
|
|
|
SDL_Color entcolreal;
|
2021-02-21 00:40:11 +01:00
|
|
|
|
|
|
|
int kludgewarpdir[customlevelclass::numrooms];
|
|
|
|
|
2023-03-05 19:59:36 +01:00
|
|
|
int note_timer;
|
|
|
|
int old_note_timer;
|
2021-02-21 00:40:11 +01:00
|
|
|
std::string note;
|
|
|
|
std::string keybuffer;
|
|
|
|
std::string filename;
|
|
|
|
std::string loaded_filepath;
|
|
|
|
|
2023-03-09 19:21:03 +01:00
|
|
|
int old_tilex, old_tiley;
|
2021-02-21 00:40:11 +01:00
|
|
|
int tilex, tiley;
|
|
|
|
int keydelay, lclickdelay;
|
|
|
|
bool savekey, loadkey;
|
|
|
|
int levx, levy;
|
|
|
|
int entframe, entframedelay;
|
|
|
|
|
|
|
|
int scripttexttype;
|
2023-03-05 19:59:36 +01:00
|
|
|
std::string old_entity_text;
|
2021-02-21 00:40:11 +01:00
|
|
|
|
2023-03-05 19:59:36 +01:00
|
|
|
enum TextMode current_text_mode; // In text entry
|
|
|
|
std::string* current_text_ptr; // Pointer to text we're changing
|
|
|
|
std::string current_text_desc; // Description (for editor mode text fields)
|
2021-02-21 00:40:11 +01:00
|
|
|
union
|
|
|
|
{
|
|
|
|
int desc; // Which description row we're changing
|
2023-03-09 18:10:58 +01:00
|
|
|
int text_entity; // Entity ID for text prompt
|
2021-02-21 00:40:11 +01:00
|
|
|
};
|
2023-03-21 17:34:08 +01:00
|
|
|
bool x_modifier, z_modifier, c_modifier, v_modifier, b_modifier, h_modifier, f_modifier, toolbox_open;
|
2021-02-21 00:40:11 +01:00
|
|
|
|
|
|
|
int roomnamehide;
|
|
|
|
bool saveandquit;
|
2023-03-09 18:10:58 +01:00
|
|
|
bool help_open, shiftkey;
|
2023-03-05 19:59:36 +01:00
|
|
|
bool settingskey;
|
2023-03-09 18:10:58 +01:00
|
|
|
int warp_token_entity;
|
2021-02-21 00:40:11 +01:00
|
|
|
bool updatetiles, changeroom;
|
2023-03-09 18:10:58 +01:00
|
|
|
bool backspace_held;
|
2021-02-21 00:40:11 +01:00
|
|
|
|
|
|
|
//Script editor stuff
|
2023-03-09 18:10:58 +01:00
|
|
|
void remove_line(int t);
|
|
|
|
void insert_line(int t);
|
2021-02-21 00:40:11 +01:00
|
|
|
|
2023-03-09 18:10:58 +01:00
|
|
|
std::vector<std::string> script_buffer;
|
|
|
|
std::string current_script;
|
|
|
|
int script_cursor_x, script_cursor_y;
|
|
|
|
int script_offset;
|
2023-01-12 05:27:52 +01:00
|
|
|
int lines_visible;
|
2021-02-21 00:40:11 +01:00
|
|
|
|
|
|
|
//Functions for interfacing with the script:
|
2023-03-09 18:10:58 +01:00
|
|
|
void create_script(const std::string& name, const std::vector<std::string>& contents);
|
|
|
|
void create_script(const std::string& name);
|
|
|
|
void remove_script(const std::string& name);
|
|
|
|
void load_script_in_editor(const std::string& name);
|
|
|
|
void clear_script_buffer(void);
|
|
|
|
bool script_exists(const std::string& name);
|
|
|
|
|
|
|
|
int script_list_offset, selected_script;
|
2021-02-21 00:40:11 +01:00
|
|
|
|
|
|
|
//Direct Mode variables
|
2023-03-09 18:10:58 +01:00
|
|
|
int direct_mode_tile;
|
|
|
|
int direct_mode_drawer;
|
2021-02-21 00:40:11 +01:00
|
|
|
|
2023-03-09 18:10:58 +01:00
|
|
|
int return_message_timer;
|
|
|
|
int old_return_message_timer;
|
2021-02-21 00:40:11 +01:00
|
|
|
|
|
|
|
std::vector<GhostInfo> ghosts;
|
2023-03-09 18:10:58 +01:00
|
|
|
int current_ghosts;
|
2021-02-21 00:40:11 +01:00
|
|
|
};
|
|
|
|
|
2021-02-20 08:21:58 +01:00
|
|
|
void editorrender(void);
|
|
|
|
|
|
|
|
void editorrenderfixed(void);
|
|
|
|
|
|
|
|
void editorlogic(void);
|
|
|
|
|
|
|
|
void editorinput(void);
|
|
|
|
|
2021-02-21 00:40:11 +01:00
|
|
|
#ifndef ED_DEFINITION
|
|
|
|
extern editorclass ed;
|
|
|
|
#endif
|
|
|
|
|
2021-02-20 08:21:58 +01:00
|
|
|
#endif /* EDITOR_H */
|