gcsx_define.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. /* GCSx
  2. ** DEFINE.H
  3. **
  4. ** General defines- menu commands, config options, constants, debug levels,
  5. ** file types, etc. (separated from modules that can otherwise be generic)
  6. */
  7. /*****************************************************************************
  8. ** Copyright (C) 2003-2006 Janson
  9. **
  10. ** This program is free software; you can redistribute it and/or modify
  11. ** it under the terms of the GNU General Public License as published by
  12. ** the Free Software Foundation; either version 2 of the License, or
  13. ** (at your option) any later version.
  14. **
  15. ** This program is distributed in the hope that it will be useful,
  16. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ** GNU General Public License for more details.
  19. **
  20. ** You should have received a copy of the GNU General Public License
  21. ** along with this program; if not, write to the Free Software
  22. ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
  23. *****************************************************************************/
  24. #ifndef __GCSx_DEFINE_H_
  25. #define __GCSx_DEFINE_H_
  26. // Menu/etc commands
  27. enum {
  28. // Special commands for passing events to listview handling functions
  29. LV_LCLICK = -100, // Left click
  30. LV_RCLICK, // Includes popup-menu access key
  31. LV_SELECT, // Includes double-click, space, enter
  32. LV_DELETE, // Includes backspace
  33. LV_MOVE, // Whenever an item becomes selected, in addition to any other event
  34. // Special commands for menu creation (still negative values)
  35. MENU_SUB,
  36. MENU_SEP,
  37. // Release of the last command key being held
  38. CMD_RELEASE,
  39. // Dummy command
  40. NO_COMMAND = 0,
  41. // Standard editor/frontend menu commands
  42. // Assigned static values as they should not ever
  43. // change, for upwards compatibility (configuration/shortcuts)
  44. FILE_NEW = 1,
  45. // (not simply FILE_OPEN due to symbol conflict on Windows platform)
  46. FILE_OPENEXIST = 61,
  47. FILE_SAVE = 58,
  48. FILE_SAVEAS = 62,
  49. FILE_CLOSE = 59,
  50. FILE_SAVEALL = 60,
  51. FILE_CLOSEALL = 2,
  52. FILE_EXIT = 3,
  53. FILE_QUIT = 70,
  54. FILE_EDITOR = 68,
  55. FILE_RETURNGAME = 98,
  56. FILE_CLOSEGAME = 99,
  57. CONFIG_RESOLUTION = 4,
  58. WINDOW_NEXT = 6,
  59. WINDOW_PREV = 7,
  60. WINDOW_CLOSE = 8,
  61. WINDOW_MIN = 9,
  62. WINDOW_MAX = 10,
  63. WINDOW_SWITCHPANEL = 11,
  64. WINDOW_TILEHORIZ = 93,
  65. WINDOW_TILEVERT = 94,
  66. WINDOW_CASCADE = 95,
  67. WINDOW_CLOSEALL = 96,
  68. WINDOW_CLOSEALLBUT = 97,
  69. TOOLS_CHOOSE = 13,
  70. TOOLS_CHOOSER = 65,
  71. TOOLS_PEN = 14,
  72. TOOLS_LINE = 15,
  73. TOOLS_RECT = 16,
  74. TOOLS_RECTFILL = 17,
  75. TOOLS_ELLIPSE = 18,
  76. TOOLS_ELLIPSEFILL = 19,
  77. TOOLS_FILL = 20,
  78. TOOLS_SELECT = 21,
  79. TOOLS_SELECTELLIPSE = 22,
  80. TOOLS_WAND = 23,
  81. TOOLS_DROPPER = 24,
  82. TOOLS_PLACEITEM = 75,
  83. TOOLS_PLACESERIES = 92,
  84. TOOLS_SELECTITEM = 76,
  85. TOOLS_SELECTDRAG = 25, // Not officially a tool, but used internally
  86. TOOLS_SELECTITEMDRAG = 91, // Not officially a tool, but used internally
  87. TOOLS_GLYPHWIDTHDRAG = 63, // Not officially a tool, but used internally
  88. TOOLS_SETTINGS = 26,
  89. TOOLS_BLENDUP = 27,
  90. TOOLS_BLENDDOWN = 28,
  91. TOOLS_TOLERANCEUP = 29,
  92. TOOLS_TOLERANCEDOWN = 30,
  93. TOOLS_ANTIALIAS = 31,
  94. TOOLS_CONTIGUOUS = 85,
  95. TOOLS_NEXTCOLOR = 32,
  96. TOOLS_PREVCOLOR = 33,
  97. TOOLS_EDITCOLOR = 34,
  98. TOOLS_NEXTIMAGE = 89,
  99. TOOLS_PREVIMAGE = 90,
  100. MODE_EDITTILES = 86,
  101. MODE_EDITCOLLISION = 87,
  102. MODE_EDITASSIGN = 88,
  103. EDIT_SELECTALL = 35,
  104. EDIT_DESELECTALL = 36,
  105. EDIT_DELETE = 37,
  106. EDIT_CUT = 38,
  107. EDIT_COPY = 39,
  108. EDIT_PASTE = 40,
  109. EDIT_UNDO = 41,
  110. EDIT_REDO = 42,
  111. EDIT_FLIP = 43,
  112. EDIT_MIRROR = 44,
  113. EDIT_SIZEROTATE = 45,
  114. EDIT_GRADIENT = 46,
  115. EDIT_COLORIZE = 47,
  116. EDIT_FILTER = 48,
  117. EDIT_SETGLYPHWIDTH = 64,
  118. EDIT_MOVEUP = 81,
  119. EDIT_MOVEDOWN = 82,
  120. EDIT_MOVETOP = 83,
  121. EDIT_MOVEBOTTOM = 84,
  122. NEW_ANIM = 100,
  123. NEW_FONT = 101,
  124. NEW_LIBRARY = 102,
  125. NEW_IMAGE = 103,
  126. NEW_NOTES = 104,
  127. NEW_SCENE = 105,
  128. NEW_SCRIPT = 106,
  129. NEW_IMPORT_IMAGE = 107,
  130. NEW_IMPORT_FONT = 108,
  131. NEW_FOLDER = 109, // Last code used
  132. NEW_LAYER = 71,
  133. VIEW_BROWSER = 5,
  134. VIEW_CONSOLE = 66,
  135. VIEW_ZOOMIN = 49,
  136. VIEW_ZOOMOUT = 50,
  137. VIEW_PREV = 51,
  138. VIEW_NEXT = 52,
  139. VIEW_DOTS_CHOOSE = 53,
  140. VIEW_DOTS_NONE = 54,
  141. VIEW_DOTS_TRANS = 55,
  142. VIEW_DOTS_ALPHA = 56,
  143. VIEW_GRID = 57,
  144. VIEW_TOOLPANEL = 12,
  145. VIEW_TOOLBAR = 67,
  146. VIEW_ALLLAYER = 72,
  147. VIEW_DIMLAYER = 73,
  148. VIEW_NOLAYER = 74,
  149. VIEW_OUTLINE_CHOOSE = 77,
  150. VIEW_OUTLINE_NONE = 78,
  151. VIEW_OUTLINE_NORMAL = 79,
  152. VIEW_OUTLINE_HANDLE = 80,
  153. MENU_HELP_INDEX = 69,
  154. };
  155. // Mins and maxes
  156. // * marks those that are currently arbitrary
  157. // Others have a specific reason for the limit
  158. enum {
  159. MAX_TILES = 65535,
  160. MAX_COLLMAPS = 2046, // (11 bits in layer data, minus allon/alloff codes)
  161. MIN_TILESIZE = 4, // * setting this to 1 breaks a couple things in editor like cursors
  162. MAX_TILESIZE = 256, // *
  163. MAX_LAYERS = 32,
  164. MAX_LAYERTILESIZE = 32767, // So multiplying together to get size fits in a signed int
  165. MAX_ANIMGROUP = 32767, // * Maximum animation sequences
  166. MIN_SPRITESIZE = 4, // *
  167. MAX_SPRITESIZE = 1024, // *
  168. MAX_ANIMCOMP = 255, // * Maximum components in an animation frame
  169. MAX_ANIMFRAME = 255, // * Maximum frames in an animation sequence
  170. // This restriction is due to crashes that happen with longer text lines
  171. // in font routines, etc. This seems to be ok up to font sizes of around 30-40.
  172. // Not a hard and fast restriction- a couple chars over shouldn't hurt.
  173. // @TODO: Still might want to put some additional checks/safeguards in once
  174. // font size selection is implemented.
  175. MAX_LINELENGTH = 500, // Maximum length of a text line (editbox, etc.)
  176. };
  177. // Debug levels
  178. #define DEBUG_VERSION 0
  179. #define DEBUG_VIDEO 0
  180. #define DEBUG_FATALERROR 0
  181. #define DEBUG_UNDO 1
  182. #define DEBUG_COMPILE 2
  183. #define DEBUG_TOKENIZE 4
  184. #define DEBUG_BYTECODE 8
  185. #ifdef NDEBUG
  186. #ifdef MEMDEBUG
  187. #define DEBUG_MEMORY 16
  188. #define DEBUG_STACK 32
  189. #define DEBUG_MAX 63
  190. #else
  191. #define DEBUG_MAX 15
  192. #endif
  193. #else
  194. #ifdef MEMDEBUG
  195. #define DEBUG_INTERPRET 16
  196. #define DEBUG_MEMORY 32
  197. #define DEBUG_STACK 64
  198. #define DEBUG_MAX 127
  199. #else
  200. #define DEBUG_INTERPRET 16
  201. #define DEBUG_MAX 31
  202. #endif
  203. #endif
  204. // Debugging console
  205. #define DEBUG_BUFFER_SIZE 1024
  206. #define CONSOLE_PROMPT "GCSx> "
  207. #define CONSOLE_LENGTH 6
  208. // File types; each type remembers the last directory used
  209. // and has associated extension(s)
  210. enum {
  211. FILETYPE_WORLD = 0,
  212. FILETYPE_IMAGE,
  213. FILETYPE_MODULE,
  214. FILETYPE_COUNT,
  215. };
  216. void initFileExtensions(std::vector<std::string>* fileExtensions);
  217. // Filenames used for various things
  218. #define FILENAME_ICON "gcsxicon.bmp"
  219. #define FILENAME_CFG "gcsx.cfg"
  220. #define FILENAME_TREEICONS "treeicon.bmp"
  221. #define FILENAME_EDITORICONS "editoricon.bmp"
  222. #define FILENAME_BKFRONT "gcsx_bk.png"
  223. #define FILENAME_BKEDITOR "gcsx_bk2.png"
  224. #define FILENAME_COLORICONS "coloricon.bmp"
  225. // Config settings- assigned static values as they
  226. // should not ever change, for upwards compatibility
  227. enum {
  228. CONFIG_NO_SETTING = 0,
  229. // Numeric settings
  230. VIDEO_X = 1,
  231. VIDEO_Y = 2,
  232. VIDEO_BPP = 3,
  233. VIDEO_FULLSCREEN = 4,
  234. VIDEO_RESIZABLE = 12,
  235. TILEPAINT_ZOOM = 5,
  236. TILEPAINT_ANTIALIAS = 6,
  237. TILEPAINT_TOLERANCE = 7,
  238. TILEPAINT_GRID = 8,
  239. TILEPAINT_DOTS = 9,
  240. LAYEREDIT_GRID = 11,
  241. ANIMEDIT_OUTLINE = 13,
  242. RGBSELECT_METHOD = 10,
  243. WARN_GAMEMENU = 14,
  244. FRONTEND_ACTIVE_ALPHA = 15,
  245. FRONTEND_INACTIVE_ALPHA = 16,
  246. FRONTEND_ACTIVE_BKALPHA = 17,
  247. FRONTEND_INACTIVE_BKALPHA = 18,
  248. LINKED_RETAIN = 19,
  249. LINKED_PREGENERATE = 20,
  250. // Numeric settings that aren't saved to file
  251. // Features marked with * should not be modified outside of testing/debugging
  252. CONFIG_FIRST_VOLATILE_SETTING = 8192,
  253. OGL_MIN_SIZE = 8192, // *
  254. OGL_MAX_SIZE = 8193, // *
  255. OGL_POWER_OF_TWO = 8194, // * Texture sizes must be ^2
  256. OGL_FORCE_SINGLE = 8195, // Never use sub-textures
  257. OGL_PREFER_GROUPING = 8196, // Use a single large texture for graphic sets when possible
  258. // (otherwise, aims for most efficient texture mem usage)
  259. // Overridden by OGL_FORCE_SINGLE
  260. // String settings
  261. CONFIG_FIRST_STRING_SETTING = 16384,
  262. CONFIG_LAST_STRING_SETTING = 32767,
  263. // Shortcut keys- add this to command code
  264. CONFIG_ADD_SHORTCUT = 32768,
  265. // For each alternate shortcut key, add this
  266. CONFIG_ADD_SHORTCUT_ALTERNATE = 4096,
  267. // Max number of alternates, in addition to main key
  268. // One less than the theoritical max to prevent potential wrap
  269. // around when doing math
  270. CONFIG_MAX_SHORTCUT_ALTERNATE = 6,
  271. // Max total settings- 16bits, but we discard the last 4096
  272. // sinc we only want max 7 shortcut keys per
  273. CONFIG_MAX_SETTING = 61439,
  274. };
  275. void initConfigDefaults(std::map<Uint16, Sint32>& configN);
  276. // Default shortcut keys
  277. struct defaultShortcut {
  278. Uint16 cmd;
  279. Uint16 mod;
  280. Uint16 key;
  281. };
  282. extern const defaultShortcut shortcutDefault[];
  283. // SDL_OBJECTCHANGE constants
  284. enum {
  285. // Masks
  286. OBJMASK_TYPE = 0x00000FFF, // Type of object modified
  287. OBJMASK_MOD = 0xFFFFF000, // Type of modification
  288. // Objects that can update
  289. OBJ_WORLD = 0x00000001,
  290. OBJ_TILESET = 0x00000002,
  291. OBJ_SCENE = 0x00000004,
  292. OBJ_LAYER = 0x00000008,
  293. OBJ_ANIMGROUP = 0x00000010,
  294. OBJ_SCRIPT = 0x00000020,
  295. OBJ_SPAWN = 0x00000040,
  296. OBJ_FOLDER = 0x00000080,
  297. // Object modifications
  298. // All objects
  299. OBJMOD_DELETE = 0x00001000,
  300. OBJMOD_NAME = 0x00002000,
  301. OBJMOD_CREATE = 0x00004000,
  302. // OBJ_WORLD
  303. OBJMOD_START = 0x00008000,
  304. // OBJ_TILESET
  305. OBJMOD_WIDTH = 0x00008000, // this also means all tiles have modified
  306. OBJMOD_HEIGHT = 0x00010000, // this also means all tiles have modified
  307. OBJMOD_COUNT = 0x00020000,
  308. OBJMOD_COUNTCOLL=0x00040000,
  309. OBJMOD_DEFTRANS= 0x00080000,
  310. OBJMOD_TILE = 0x00100000, // info set to first tile mod; info2 last tile (never tile 0)
  311. OBJMOD_COLL = 0x00200000, // info set to first coll mod; info2 last coll (never coll 0)
  312. OBJMOD_PERLINE = 0x00400000,
  313. OBJMOD_GLYPHW = 0x00800000, // info set to tile number modified
  314. // OBJ_SCENE
  315. OBJMOD_LAYERADD= 0x00008000, // info set to pos of layer added (all layers at or above moved)
  316. OBJMOD_LAYERDEL= 0x00010000, // info set to old pos of layer removed (all layers above moved)
  317. OBJMOD_LAYERMOVE=0x00020000, // info and info2 set to pos of layers swapped
  318. // OBJ_LAYER
  319. //OBJMOD_WIDTH 0x00008000,
  320. //OBJMOD_HEIGHT 0x00010000,
  321. OBJMOD_TYPE = 0x00020000,
  322. OBJMOD_USESEXT = 0x00040000, // (LAYER_TILE)
  323. OBJMOD_USESFX = 0x00080000, // (LAYER_TILE)
  324. OBJMOD_TILES = 0x00100000, // (LAYER_TILE) includes effects layer changes
  325. OBJMOD_TILESET = 0x00200000, // (LAYER_TILE)
  326. // OBJ_ANIMGROUP
  327. OBJMOD_ANIM = 0x00008000, // An animation sequence (any part of it)
  328. // OBJ_SCRIPT
  329. // (line numbers are 0-based)
  330. OBJMOD_LINE = 0x00008000, // info set to first line modified; info2 number of lines
  331. OBJMOD_INSERT = 0x00010000, // info set to first line; info2 number of lines inserted
  332. OBJMOD_REMOVE = 0x00020000, // info set to first line; info2 number of lines deleted
  333. OBJMOD_DEFAULT = 0x00040000,
  334. // OBJ_SPAWN
  335. OBJMOD_POS = 0x00008000,
  336. OBJMOD_SCRIPT = 0x00010000,
  337. OBJMOD_IMAGE = 0x00020000,
  338. // OBJ_FOLDER
  339. OBJMOD_CONTENT = 0x00008000, // Any add, remove, move within
  340. };
  341. // Token types and subtypes
  342. enum {
  343. TOKEN_NONE = 0,
  344. TOKEN_ENDLINE,
  345. TOKEN_IDENTIFIER,
  346. TOKEN_INTEGER,
  347. TOKEN_HEX,
  348. TOKEN_DECIMAL,
  349. TOKEN_STRING,
  350. TOKEN_STRINGTYPE,
  351. TOKEN_CONFIG,
  352. TOKEN_RESERVED,
  353. TOKEN_UNKNOWN,
  354. TOKEN_COMMENT_LINE, // Used internally only
  355. TOKEN_COMMENT_BLOCK, // Used internally only
  356. TOKEN_OPEN_BRACE,
  357. TOKEN_CLOSE_BRACE,
  358. TOKEN_OPEN_PAREN,
  359. TOKEN_CLOSE_PAREN,
  360. TOKEN_OPEN_BRACKET,
  361. TOKEN_CLOSE_BRACKET,
  362. TOKEN_COMMA,
  363. TOKEN_NAMESPACE, // colon colon ::
  364. TOKEN_LABEL, // colon :
  365. // Types with subtypes; primary type is designed to be a bitflag
  366. TOKEN_KEYWORD = 256,
  367. KEYW_ARRAY,
  368. KEYW_HASH,
  369. KEYW_STR,
  370. KEYW_INT,
  371. KEYW_FLOAT,
  372. KEYW_VAR,
  373. KEYW_GLOBAL,
  374. KEYW_LOCAL,
  375. KEYW_PRIVATE,
  376. KEYW_PUBLIC,
  377. KEYW_CONST,
  378. KEYW_VOID,
  379. KEYW_OBJ_ENTITY,
  380. KEYW_OBJ_SPRITE,
  381. KEYW_OBJ_SCENE,
  382. KEYW_RETURN,
  383. KEYW_IF,
  384. KEYW_ELSE,
  385. KEYW_TRUE,
  386. KEYW_FALSE,
  387. KEYW_QUERY,
  388. KEYW_FOR,
  389. KEYW_TO,
  390. KEYW_WITH,
  391. KEYW_FOREACH,
  392. KEYW_IN,
  393. KEYW_DO,
  394. KEYW_WHILE,
  395. KEYW_UNTIL,
  396. KEYW_BREAK,
  397. KEYW_CONTINUE,
  398. KEYW_RESTART,
  399. KEYW_REPEAT,
  400. KEYW_END,
  401. KEYW_REPLY,
  402. KEYW_STATE,
  403. KEYW_DEFAULT,
  404. KEYW_ALL,
  405. KEYW_ALL_OTHER,
  406. KEYW_THIS,
  407. KEYW_SOURCE,
  408. KEYW_NOTHING,
  409. KEYW_EXTEND,
  410. KEYW_IMPORT,
  411. KEYW_DEBUG,
  412. KEYW_IDLE,
  413. TOKEN_OPERATOR = 512,
  414. OPER_CONCAT,
  415. OPER_B_NOT, // twos complement (binary negation)
  416. OPER_L_NOT,
  417. OPER_MULT,
  418. OPER_DIV,
  419. OPER_PLUS, // or positive
  420. OPER_MINUS, // or negative
  421. OPER_MOD,
  422. OPER_LSHIFT,
  423. OPER_RSHIFT,
  424. OPER_B_AND,
  425. OPER_B_OR,
  426. OPER_B_XOR,
  427. OPER_LT,
  428. OPER_LE,
  429. OPER_GT,
  430. OPER_GE,
  431. OPER_EQ,
  432. OPER_NE,
  433. OPER_IS,
  434. OPER_AS,
  435. OPER_L_AND,
  436. OPER_L_OR,
  437. OPER_L_XOR,
  438. OPER_ASSIGN,
  439. OPER_MEMBER, // period .
  440. };
  441. #define WHITE_SPACE " \t"
  442. // Fonts
  443. enum {
  444. FONT_STANDARD = 0,
  445. FONT_MONO,
  446. FONT_WIDGET,
  447. FONT_TITLEBAR,
  448. FONT_TITLEBARWIDGET,
  449. FONT_TOOLTITLEBAR,
  450. FONT_TOOLTITLEBARWIDGET,
  451. FONT_TOOLTIP,
  452. FONT_MENU,
  453. FONT_COUNT,
  454. };
  455. struct FontInfo {
  456. const char* file;
  457. int size;
  458. TTF_Font* font;
  459. int height;
  460. int ascent;
  461. };
  462. extern FontInfo fonts[FONT_COUNT];
  463. #endif