gcsx_define.cpp 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. /* GCSx
  2. ** DEFINE.CPP
  3. **
  4. ** General defines- arrays and functions for initializing basic data
  5. ** that is non-generic in nature (specific to GCSx) to keep other
  6. ** files more modular/generic
  7. */
  8. /*****************************************************************************
  9. ** Copyright (C) 2003-2006 Janson
  10. **
  11. ** This program is free software; you can redistribute it and/or modify
  12. ** it under the terms of the GNU General Public License as published by
  13. ** the Free Software Foundation; either version 2 of the License, or
  14. ** (at your option) any later version.
  15. **
  16. ** This program is distributed in the hope that it will be useful,
  17. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. ** GNU General Public License for more details.
  20. **
  21. ** You should have received a copy of the GNU General Public License
  22. ** along with this program; if not, write to the Free Software
  23. ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
  24. *****************************************************************************/
  25. #include "all.h"
  26. // Init file extensions
  27. void initFileExtensions(vector<string>* fileExtensions) {
  28. fileExtensions[FILETYPE_WORLD].push_back("gcs");
  29. fileExtensions[FILETYPE_IMAGE].push_back("pcx");
  30. fileExtensions[FILETYPE_IMAGE].push_back("tga");
  31. fileExtensions[FILETYPE_IMAGE].push_back("gif");
  32. fileExtensions[FILETYPE_IMAGE].push_back("png");
  33. fileExtensions[FILETYPE_IMAGE].push_back("bmp");
  34. fileExtensions[FILETYPE_MODULE].push_back("mod");
  35. fileExtensions[FILETYPE_MODULE].push_back("gdm");
  36. fileExtensions[FILETYPE_MODULE].push_back("s3m");
  37. }
  38. // Init configuration defaults
  39. void initConfigDefaults(map<Uint16, Sint32>& configN) {
  40. configN[VIDEO_X] = 640;
  41. configN[VIDEO_Y] = 480;
  42. configN[VIDEO_BPP] = 32;
  43. configN[VIDEO_FULLSCREEN] = 0;
  44. configN[VIDEO_RESIZABLE] = 1;
  45. configN[TILEPAINT_ZOOM] = 5;
  46. configN[TILEPAINT_ANTIALIAS] = 1;
  47. configN[TILEPAINT_TOLERANCE] = 0;
  48. configN[TILEPAINT_GRID] = 1;
  49. configN[TILEPAINT_DOTS] = VIEW_DOTS_NONE;
  50. configN[LAYEREDIT_GRID] = 0;
  51. configN[ANIMEDIT_OUTLINE] = VIEW_OUTLINE_NORMAL;
  52. configN[RGBSELECT_METHOD] = 1;
  53. configN[WARN_GAMEMENU] = 1;
  54. configN[FRONTEND_ACTIVE_ALPHA] = 256;
  55. configN[FRONTEND_INACTIVE_ALPHA] = 192;
  56. configN[FRONTEND_ACTIVE_BKALPHA] = 64;
  57. configN[FRONTEND_INACTIVE_BKALPHA] = 0;
  58. configN[OGL_MIN_SIZE] = 1;
  59. configN[OGL_MAX_SIZE] = 1024;
  60. configN[OGL_POWER_OF_TWO] = 1;
  61. configN[OGL_FORCE_SINGLE] = 0;
  62. configN[OGL_PREFER_GROUPING] = 0;
  63. configN[LINKED_RETAIN] = 0;
  64. configN[LINKED_PREGENERATE] = 0;
  65. }
  66. // Default shortcut keys
  67. const defaultShortcut shortcutDefault[] = {
  68. { VIEW_CONSOLE, 0, SDLK_BACKQUOTE },
  69. { FILE_EXIT, KMOD_ALT, SDLK_F4 },
  70. { FILE_RETURNGAME, 0, SDLK_F12 },
  71. { FILE_RETURNGAME, 0, SDLK_ESCAPE },
  72. { VIEW_ZOOMIN, 0, '=' },
  73. { VIEW_ZOOMOUT, 0, '-' },
  74. { VIEW_PREV, 0, ',' },
  75. { VIEW_NEXT, 0, '.' },
  76. { EDIT_DELETE, 0, SDLK_DELETE },
  77. { EDIT_CUT, KMOD_CTRL, 'x' },
  78. { EDIT_CUT, KMOD_SHIFT, SDLK_DELETE },
  79. { EDIT_COPY, KMOD_CTRL, 'c' },
  80. { EDIT_COPY, KMOD_CTRL, SDLK_INSERT },
  81. { EDIT_PASTE, KMOD_CTRL, 'v' },
  82. { EDIT_PASTE, KMOD_SHIFT, SDLK_INSERT },
  83. { EDIT_UNDO, KMOD_CTRL, 'z' },
  84. { EDIT_UNDO, KMOD_ALT, SDLK_BACKSPACE },
  85. { EDIT_REDO, KMOD_CTRL, 'y' },
  86. { EDIT_REDO, KMOD_CTRL|KMOD_SHIFT, 'z' },
  87. { EDIT_REDO, KMOD_ALT|KMOD_SHIFT, SDLK_BACKSPACE },
  88. { EDIT_SELECTALL, KMOD_CTRL, 'a' },
  89. { EDIT_DESELECTALL, 0, SDLK_ESCAPE },
  90. { EDIT_SETGLYPHWIDTH, 0, 'w' },
  91. { EDIT_GRADIENT, 0, 'g' },
  92. { WINDOW_NEXT, KMOD_CTRL, SDLK_TAB },
  93. { WINDOW_NEXT, KMOD_CTRL, SDLK_F6 },
  94. { WINDOW_PREV, KMOD_CTRL|KMOD_SHIFT, SDLK_TAB },
  95. { WINDOW_PREV, KMOD_CTRL|KMOD_SHIFT, SDLK_F6 },
  96. { WINDOW_MIN, KMOD_CTRL, SDLK_F7 },
  97. { WINDOW_MAX, KMOD_CTRL, SDLK_F8 },
  98. { WINDOW_CLOSE, KMOD_CTRL, SDLK_F4 },
  99. { WINDOW_SWITCHPANEL, KMOD_CTRL, SDLK_F5 },
  100. { TOOLS_CHOOSE, 0, 't' },
  101. { TOOLS_PEN, 0, 'p' },
  102. { TOOLS_LINE, 0, 'l' },
  103. { TOOLS_RECT, KMOD_SHIFT, 'r' },
  104. { TOOLS_RECTFILL, 0, 'r' },
  105. { TOOLS_ELLIPSE, KMOD_SHIFT, 'c' },
  106. { TOOLS_ELLIPSEFILL, 0, 'c' },
  107. { TOOLS_FILL, 0, 'f' },
  108. { TOOLS_SELECT, 0, 's' },
  109. { TOOLS_SELECTELLIPSE, KMOD_SHIFT, 's' },
  110. { TOOLS_WAND, 0, 'm' },
  111. { TOOLS_DROPPER, 0, 'd' },
  112. { TOOLS_PLACEITEM, 0, 'o' },
  113. { TOOLS_PLACESERIES, KMOD_SHIFT, 'o' },
  114. { TOOLS_SELECTITEM, 0, 'z' },
  115. { TOOLS_NEXTCOLOR, 0, ']' },
  116. { TOOLS_PREVCOLOR, 0, '[' },
  117. { TOOLS_EDITCOLOR, 0, '\\' },
  118. { TOOLS_NEXTIMAGE, 0, '\'' },
  119. { TOOLS_PREVIMAGE, 0, ';' },
  120. { FILE_OPENEXIST, KMOD_CTRL, 'o' },
  121. { FILE_SAVE, KMOD_CTRL, 's' },
  122. { FILE_EDITOR, KMOD_CTRL, 'e' },
  123. { 0, 0, 0 }
  124. };
  125. // For debugging output
  126. const char* Tokenizer::debugText[] = {
  127. "NONE",
  128. "ENDLINE",
  129. "IDENTIFIER",
  130. "INTEGER",
  131. "HEX",
  132. "DECIMAL",
  133. "STRING",
  134. "STRINGTYPE",
  135. "CONFIG",
  136. "RESERVED",
  137. "UNKNOWN",
  138. "COMMENT_LINE",
  139. "COMMENT_BLOCK",
  140. "OPEN_BRACE",
  141. "CLOSE_BRACE",
  142. "OPEN_PAREN",
  143. "CLOSE_PAREN",
  144. "OPEN_BRACKET",
  145. "CLOSE_BRACKET",
  146. "COMMA",
  147. "NAMESPACE",
  148. "LABEL",
  149. };
  150. // Character sequences and tokens
  151. const Tokenizer::TokenStr Tokenizer::tokenStrings[] = {
  152. { TOKEN_ENDLINE, ";" },
  153. { TOKEN_COMMENT_LINE, "//" },
  154. { TOKEN_COMMENT_BLOCK, "/*" },
  155. { TOKEN_OPEN_BRACE, "{" },
  156. { TOKEN_CLOSE_BRACE, "}" },
  157. { TOKEN_OPEN_PAREN, "(" },
  158. { TOKEN_CLOSE_PAREN, ")" },
  159. { TOKEN_OPEN_BRACKET, "[" },
  160. { TOKEN_CLOSE_BRACKET, "]" },
  161. { TOKEN_COMMA, "," },
  162. { TOKEN_NAMESPACE, "::" },
  163. { TOKEN_LABEL, ":" },
  164. { KEYW_ARRAY, "array" },
  165. { KEYW_HASH, "hash" },
  166. { KEYW_STR, "str" },
  167. { KEYW_INT, "int" },
  168. { KEYW_FLOAT, "float" },
  169. { KEYW_VAR, "var" },
  170. { KEYW_GLOBAL, "global" },
  171. { KEYW_LOCAL, "local" },
  172. { KEYW_PRIVATE, "private" },
  173. { KEYW_PUBLIC, "public" },
  174. { KEYW_CONST, "const" },
  175. { KEYW_VOID, "void" },
  176. { KEYW_OBJ_ENTITY, "obj_entity" },
  177. { KEYW_OBJ_SPRITE, "obj_sprite" },
  178. { KEYW_OBJ_SCENE, "obj_scene" },
  179. { KEYW_RETURN, "return" },
  180. { KEYW_IF, "if" },
  181. { KEYW_ELSE, "else" },
  182. { KEYW_TRUE, "true" },
  183. { KEYW_FALSE, "false" },
  184. { KEYW_QUERY, "query" },
  185. { KEYW_FOR, "for" },
  186. { KEYW_TO, "to" },
  187. { KEYW_WITH, "with" },
  188. { KEYW_FOREACH, "foreach" },
  189. { KEYW_IN, "in" },
  190. { KEYW_DO, "do" },
  191. { KEYW_WHILE, "while" },
  192. { KEYW_UNTIL, "until" },
  193. { KEYW_BREAK, "break" },
  194. { KEYW_CONTINUE, "continue" },
  195. { KEYW_RESTART, "restart" },
  196. { KEYW_REPEAT, "repeat" },
  197. { KEYW_END, "end" },
  198. { KEYW_REPLY, "reply" },
  199. { KEYW_STATE, "state" },
  200. { KEYW_DEFAULT, "default" },
  201. { KEYW_ALL, "all" },
  202. { KEYW_ALL_OTHER, "all_other" },
  203. { KEYW_THIS, "this" },
  204. { KEYW_SOURCE, "source" },
  205. { KEYW_NOTHING, "nothing" },
  206. { KEYW_EXTEND, "extend" },
  207. { KEYW_IMPORT, "import" },
  208. { KEYW_DEBUG, "debug" },
  209. { KEYW_IDLE, "idle" },
  210. { OPER_CONCAT, "#" },
  211. { OPER_B_NOT, "~" },
  212. { OPER_L_NOT, "not" },
  213. { OPER_MULT, "*" },
  214. { OPER_DIV, "/" },
  215. { OPER_PLUS, "+" },
  216. { OPER_MINUS, "-" },
  217. { OPER_MOD, "%" },
  218. { OPER_LSHIFT, "<<" },
  219. { OPER_RSHIFT, ">>" },
  220. { OPER_B_AND, "&" },
  221. { OPER_B_OR, "|" },
  222. { OPER_B_XOR, "^" },
  223. { OPER_LT, "<" },
  224. { OPER_LE, "<=" },
  225. { OPER_GT, ">" },
  226. { OPER_GE, ">=" },
  227. { OPER_EQ, "==" },
  228. { OPER_NE, "!=" },
  229. { OPER_NE, "<>" },
  230. { OPER_IS, "is" },
  231. { OPER_AS, "as" },
  232. { OPER_L_AND, "and" },
  233. { OPER_L_OR, "or" },
  234. { OPER_L_XOR, "xor" },
  235. { OPER_ASSIGN, "=" },
  236. { OPER_MEMBER, "." },
  237. { TOKEN_RESERVED, "$" },
  238. { TOKEN_RESERVED, "@" },
  239. { TOKEN_RESERVED, "`" },
  240. { TOKEN_RESERVED, "\\" },
  241. { TOKEN_RESERVED, "?" },
  242. { TOKEN_RESERVED, "++" },
  243. { TOKEN_RESERVED, "--" },
  244. { TOKEN_RESERVED, "<-" },
  245. { TOKEN_RESERVED, "->" },
  246. { TOKEN_RESERVED, "&&" },
  247. { TOKEN_RESERVED, "||" },
  248. { TOKEN_RESERVED, "^^" },
  249. { TOKEN_RESERVED, ".." },
  250. { TOKEN_RESERVED, "#=" },
  251. { TOKEN_RESERVED, "*=" },
  252. { TOKEN_RESERVED, "/=" },
  253. { TOKEN_RESERVED, "+=" },
  254. { TOKEN_RESERVED, "-=" },
  255. { TOKEN_RESERVED, "%=" },
  256. { TOKEN_RESERVED, "<<=" },
  257. { TOKEN_RESERVED, ">>=" },
  258. { TOKEN_RESERVED, "&=" },
  259. { TOKEN_RESERVED, "|=" },
  260. { TOKEN_RESERVED, "^=" },
  261. { TOKEN_RESERVED, "case" },
  262. { TOKEN_RESERVED, "static" },
  263. { TOKEN_RESERVED, "switch" },
  264. { TOKEN_RESERVED, "watch" },
  265. { TOKEN_RESERVED, "breakpoint" },
  266. { TOKEN_RESERVED, "trace" },
  267. { TOKEN_NONE, NULL },
  268. };
  269. // Fonts
  270. FontInfo fonts[FONT_COUNT] = {
  271. { "vera.ttf", 11, NULL, 0, 0 },
  272. { "veramono.ttf", 11, NULL, 0, 0 },
  273. { "gcswidget.ttf", 13, NULL, 0, 0 },
  274. { "vera.ttf", 11, NULL, 0, 0 },
  275. { "gcswidget.ttf", 14, NULL, 0, 0 },
  276. { "vera.ttf", 8, NULL, 0, 0 },
  277. { "gcswidget.ttf", 8, NULL, 0, 0 },
  278. { "vera.ttf", 11, NULL, 0, 0 },
  279. { "vera.ttf", 11, NULL, 0, 0 },
  280. };