123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306 |
- /* GCSx
- ** DEFINE.CPP
- **
- ** General defines- arrays and functions for initializing basic data
- ** that is non-generic in nature (specific to GCSx) to keep other
- ** files more modular/generic
- */
- /*****************************************************************************
- ** Copyright (C) 2003-2006 Janson
- **
- ** This program is free software; you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation; either version 2 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program; if not, write to the Free Software
- ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
- *****************************************************************************/
- #include "all.h"
- // Init file extensions
- void initFileExtensions(vector<string>* fileExtensions) {
- fileExtensions[FILETYPE_WORLD].push_back("gcs");
- fileExtensions[FILETYPE_IMAGE].push_back("pcx");
- fileExtensions[FILETYPE_IMAGE].push_back("tga");
- fileExtensions[FILETYPE_IMAGE].push_back("gif");
- fileExtensions[FILETYPE_IMAGE].push_back("png");
- fileExtensions[FILETYPE_IMAGE].push_back("bmp");
- fileExtensions[FILETYPE_MODULE].push_back("mod");
- fileExtensions[FILETYPE_MODULE].push_back("gdm");
- fileExtensions[FILETYPE_MODULE].push_back("s3m");
- }
- // Init configuration defaults
- void initConfigDefaults(map<Uint16, Sint32>& configN) {
- configN[VIDEO_X] = 640;
- configN[VIDEO_Y] = 480;
- configN[VIDEO_BPP] = 32;
- configN[VIDEO_FULLSCREEN] = 0;
- configN[VIDEO_RESIZABLE] = 1;
- configN[TILEPAINT_ZOOM] = 5;
- configN[TILEPAINT_ANTIALIAS] = 1;
- configN[TILEPAINT_TOLERANCE] = 0;
- configN[TILEPAINT_GRID] = 1;
- configN[TILEPAINT_DOTS] = VIEW_DOTS_NONE;
-
- configN[LAYEREDIT_GRID] = 0;
-
- configN[ANIMEDIT_OUTLINE] = VIEW_OUTLINE_NORMAL;
- configN[RGBSELECT_METHOD] = 1;
-
- configN[WARN_GAMEMENU] = 1;
- configN[FRONTEND_ACTIVE_ALPHA] = 256;
- configN[FRONTEND_INACTIVE_ALPHA] = 192;
- configN[FRONTEND_ACTIVE_BKALPHA] = 64;
- configN[FRONTEND_INACTIVE_BKALPHA] = 0;
- configN[OGL_MIN_SIZE] = 1;
- configN[OGL_MAX_SIZE] = 1024;
- configN[OGL_POWER_OF_TWO] = 1;
- configN[OGL_FORCE_SINGLE] = 0;
- configN[OGL_PREFER_GROUPING] = 0;
- configN[LINKED_RETAIN] = 0;
- configN[LINKED_PREGENERATE] = 0;
- }
- // Default shortcut keys
- const defaultShortcut shortcutDefault[] = {
- { VIEW_CONSOLE, 0, SDLK_BACKQUOTE },
- { FILE_EXIT, KMOD_ALT, SDLK_F4 },
- { FILE_RETURNGAME, 0, SDLK_F12 },
- { FILE_RETURNGAME, 0, SDLK_ESCAPE },
- { VIEW_ZOOMIN, 0, '=' },
- { VIEW_ZOOMOUT, 0, '-' },
- { VIEW_PREV, 0, ',' },
- { VIEW_NEXT, 0, '.' },
- { EDIT_DELETE, 0, SDLK_DELETE },
- { EDIT_CUT, KMOD_CTRL, 'x' },
- { EDIT_CUT, KMOD_SHIFT, SDLK_DELETE },
- { EDIT_COPY, KMOD_CTRL, 'c' },
- { EDIT_COPY, KMOD_CTRL, SDLK_INSERT },
- { EDIT_PASTE, KMOD_CTRL, 'v' },
- { EDIT_PASTE, KMOD_SHIFT, SDLK_INSERT },
- { EDIT_UNDO, KMOD_CTRL, 'z' },
- { EDIT_UNDO, KMOD_ALT, SDLK_BACKSPACE },
- { EDIT_REDO, KMOD_CTRL, 'y' },
- { EDIT_REDO, KMOD_CTRL|KMOD_SHIFT, 'z' },
- { EDIT_REDO, KMOD_ALT|KMOD_SHIFT, SDLK_BACKSPACE },
- { EDIT_SELECTALL, KMOD_CTRL, 'a' },
- { EDIT_DESELECTALL, 0, SDLK_ESCAPE },
- { EDIT_SETGLYPHWIDTH, 0, 'w' },
- { EDIT_GRADIENT, 0, 'g' },
- { WINDOW_NEXT, KMOD_CTRL, SDLK_TAB },
- { WINDOW_NEXT, KMOD_CTRL, SDLK_F6 },
- { WINDOW_PREV, KMOD_CTRL|KMOD_SHIFT, SDLK_TAB },
- { WINDOW_PREV, KMOD_CTRL|KMOD_SHIFT, SDLK_F6 },
- { WINDOW_MIN, KMOD_CTRL, SDLK_F7 },
- { WINDOW_MAX, KMOD_CTRL, SDLK_F8 },
- { WINDOW_CLOSE, KMOD_CTRL, SDLK_F4 },
- { WINDOW_SWITCHPANEL, KMOD_CTRL, SDLK_F5 },
- { TOOLS_CHOOSE, 0, 't' },
- { TOOLS_PEN, 0, 'p' },
- { TOOLS_LINE, 0, 'l' },
- { TOOLS_RECT, KMOD_SHIFT, 'r' },
- { TOOLS_RECTFILL, 0, 'r' },
- { TOOLS_ELLIPSE, KMOD_SHIFT, 'c' },
- { TOOLS_ELLIPSEFILL, 0, 'c' },
- { TOOLS_FILL, 0, 'f' },
- { TOOLS_SELECT, 0, 's' },
- { TOOLS_SELECTELLIPSE, KMOD_SHIFT, 's' },
- { TOOLS_WAND, 0, 'm' },
- { TOOLS_DROPPER, 0, 'd' },
- { TOOLS_PLACEITEM, 0, 'o' },
- { TOOLS_PLACESERIES, KMOD_SHIFT, 'o' },
- { TOOLS_SELECTITEM, 0, 'z' },
- { TOOLS_NEXTCOLOR, 0, ']' },
- { TOOLS_PREVCOLOR, 0, '[' },
- { TOOLS_EDITCOLOR, 0, '\\' },
- { TOOLS_NEXTIMAGE, 0, '\'' },
- { TOOLS_PREVIMAGE, 0, ';' },
- { FILE_OPENEXIST, KMOD_CTRL, 'o' },
- { FILE_SAVE, KMOD_CTRL, 's' },
- { FILE_EDITOR, KMOD_CTRL, 'e' },
- { 0, 0, 0 }
- };
- // For debugging output
- const char* Tokenizer::debugText[] = {
- "NONE",
- "ENDLINE",
- "IDENTIFIER",
- "INTEGER",
- "HEX",
- "DECIMAL",
- "STRING",
- "STRINGTYPE",
- "CONFIG",
- "RESERVED",
- "UNKNOWN",
- "COMMENT_LINE",
- "COMMENT_BLOCK",
- "OPEN_BRACE",
- "CLOSE_BRACE",
- "OPEN_PAREN",
- "CLOSE_PAREN",
- "OPEN_BRACKET",
- "CLOSE_BRACKET",
- "COMMA",
- "NAMESPACE",
- "LABEL",
- };
- // Character sequences and tokens
- const Tokenizer::TokenStr Tokenizer::tokenStrings[] = {
- { TOKEN_ENDLINE, ";" },
- { TOKEN_COMMENT_LINE, "//" },
- { TOKEN_COMMENT_BLOCK, "/*" },
- { TOKEN_OPEN_BRACE, "{" },
- { TOKEN_CLOSE_BRACE, "}" },
- { TOKEN_OPEN_PAREN, "(" },
- { TOKEN_CLOSE_PAREN, ")" },
- { TOKEN_OPEN_BRACKET, "[" },
- { TOKEN_CLOSE_BRACKET, "]" },
- { TOKEN_COMMA, "," },
- { TOKEN_NAMESPACE, "::" },
- { TOKEN_LABEL, ":" },
- { KEYW_ARRAY, "array" },
- { KEYW_HASH, "hash" },
- { KEYW_STR, "str" },
- { KEYW_INT, "int" },
- { KEYW_FLOAT, "float" },
- { KEYW_VAR, "var" },
- { KEYW_GLOBAL, "global" },
- { KEYW_LOCAL, "local" },
- { KEYW_PRIVATE, "private" },
- { KEYW_PUBLIC, "public" },
- { KEYW_CONST, "const" },
- { KEYW_VOID, "void" },
- { KEYW_OBJ_ENTITY, "obj_entity" },
- { KEYW_OBJ_SPRITE, "obj_sprite" },
- { KEYW_OBJ_SCENE, "obj_scene" },
- { KEYW_RETURN, "return" },
- { KEYW_IF, "if" },
- { KEYW_ELSE, "else" },
- { KEYW_TRUE, "true" },
- { KEYW_FALSE, "false" },
- { KEYW_QUERY, "query" },
- { KEYW_FOR, "for" },
- { KEYW_TO, "to" },
- { KEYW_WITH, "with" },
- { KEYW_FOREACH, "foreach" },
- { KEYW_IN, "in" },
- { KEYW_DO, "do" },
- { KEYW_WHILE, "while" },
- { KEYW_UNTIL, "until" },
- { KEYW_BREAK, "break" },
- { KEYW_CONTINUE, "continue" },
- { KEYW_RESTART, "restart" },
- { KEYW_REPEAT, "repeat" },
- { KEYW_END, "end" },
- { KEYW_REPLY, "reply" },
- { KEYW_STATE, "state" },
- { KEYW_DEFAULT, "default" },
- { KEYW_ALL, "all" },
- { KEYW_ALL_OTHER, "all_other" },
- { KEYW_THIS, "this" },
- { KEYW_SOURCE, "source" },
- { KEYW_NOTHING, "nothing" },
- { KEYW_EXTEND, "extend" },
- { KEYW_IMPORT, "import" },
- { KEYW_DEBUG, "debug" },
- { KEYW_IDLE, "idle" },
- { OPER_CONCAT, "#" },
- { OPER_B_NOT, "~" },
- { OPER_L_NOT, "not" },
- { OPER_MULT, "*" },
- { OPER_DIV, "/" },
- { OPER_PLUS, "+" },
- { OPER_MINUS, "-" },
- { OPER_MOD, "%" },
- { OPER_LSHIFT, "<<" },
- { OPER_RSHIFT, ">>" },
- { OPER_B_AND, "&" },
- { OPER_B_OR, "|" },
- { OPER_B_XOR, "^" },
- { OPER_LT, "<" },
- { OPER_LE, "<=" },
- { OPER_GT, ">" },
- { OPER_GE, ">=" },
- { OPER_EQ, "==" },
- { OPER_NE, "!=" },
- { OPER_NE, "<>" },
- { OPER_IS, "is" },
- { OPER_AS, "as" },
- { OPER_L_AND, "and" },
- { OPER_L_OR, "or" },
- { OPER_L_XOR, "xor" },
- { OPER_ASSIGN, "=" },
- { OPER_MEMBER, "." },
- { TOKEN_RESERVED, "$" },
- { TOKEN_RESERVED, "@" },
- { TOKEN_RESERVED, "`" },
- { TOKEN_RESERVED, "\\" },
- { TOKEN_RESERVED, "?" },
- { TOKEN_RESERVED, "++" },
- { TOKEN_RESERVED, "--" },
- { TOKEN_RESERVED, "<-" },
- { TOKEN_RESERVED, "->" },
- { TOKEN_RESERVED, "&&" },
- { TOKEN_RESERVED, "||" },
- { TOKEN_RESERVED, "^^" },
- { TOKEN_RESERVED, ".." },
- { TOKEN_RESERVED, "#=" },
- { TOKEN_RESERVED, "*=" },
- { TOKEN_RESERVED, "/=" },
- { TOKEN_RESERVED, "+=" },
- { TOKEN_RESERVED, "-=" },
- { TOKEN_RESERVED, "%=" },
- { TOKEN_RESERVED, "<<=" },
- { TOKEN_RESERVED, ">>=" },
- { TOKEN_RESERVED, "&=" },
- { TOKEN_RESERVED, "|=" },
- { TOKEN_RESERVED, "^=" },
- { TOKEN_RESERVED, "case" },
- { TOKEN_RESERVED, "static" },
- { TOKEN_RESERVED, "switch" },
- { TOKEN_RESERVED, "watch" },
- { TOKEN_RESERVED, "breakpoint" },
- { TOKEN_RESERVED, "trace" },
- { TOKEN_NONE, NULL },
- };
- // Fonts
- FontInfo fonts[FONT_COUNT] = {
- { "vera.ttf", 11, NULL, 0, 0 },
- { "veramono.ttf", 11, NULL, 0, 0 },
- { "gcswidget.ttf", 13, NULL, 0, 0 },
- { "vera.ttf", 11, NULL, 0, 0 },
- { "gcswidget.ttf", 14, NULL, 0, 0 },
- { "vera.ttf", 8, NULL, 0, 0 },
- { "gcswidget.ttf", 8, NULL, 0, 0 },
- { "vera.ttf", 11, NULL, 0, 0 },
- { "vera.ttf", 11, NULL, 0, 0 },
- };
|