diff options
author | Piotr Dziwinski <piotrdz@gmail.com> | 2013-06-24 21:37:15 +0200 |
---|---|---|
committer | Piotr Dziwinski <piotrdz@gmail.com> | 2013-06-24 21:37:15 +0200 |
commit | 7c2e955e1552a9c4e412ea2c936be61fc78ba010 (patch) | |
tree | ee506dfbec54f998d10c385bde3a1c3fa04e66b2 /src/common | |
parent | e218dcfdf2c58f8841e7ebd220527d08e870a6d5 (diff) | |
parent | b376486fd74fa02b0297ceef6d0f977b32358e5e (diff) | |
download | colobot-7c2e955e1552a9c4e412ea2c936be61fc78ba010.tar.gz colobot-7c2e955e1552a9c4e412ea2c936be61fc78ba010.tar.bz2 colobot-7c2e955e1552a9c4e412ea2c936be61fc78ba010.zip |
Colobot Gold 0.1.0-alpha
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/.gitignore | 2 | ||||
-rw-r--r-- | src/common/README.txt | 1 | ||||
-rw-r--r-- | src/common/config.h.cmake | 1 | ||||
-rw-r--r-- | src/common/event.cpp | 536 | ||||
-rw-r--r-- | src/common/event.h | 48 | ||||
-rw-r--r-- | src/common/global.h | 5 | ||||
-rw-r--r-- | src/common/image.cpp | 33 | ||||
-rw-r--r-- | src/common/image.h | 4 | ||||
-rw-r--r-- | src/common/iman.cpp | 1 | ||||
-rw-r--r-- | src/common/iman.h | 1 | ||||
-rw-r--r-- | src/common/ioutils.h | 1 | ||||
-rw-r--r-- | src/common/key.h | 1 | ||||
-rw-r--r-- | src/common/logger.cpp | 32 | ||||
-rw-r--r-- | src/common/logger.h | 10 | ||||
-rw-r--r-- | src/common/misc.h | 1 | ||||
-rw-r--r-- | src/common/profile.cpp | 82 | ||||
-rw-r--r-- | src/common/profile.h | 183 | ||||
-rw-r--r-- | src/common/restext.cpp | 17 | ||||
-rw-r--r-- | src/common/restext.h | 5 | ||||
-rw-r--r-- | src/common/singleton.h | 1 | ||||
-rw-r--r-- | src/common/stringutils.cpp | 1 | ||||
-rw-r--r-- | src/common/stringutils.h | 1 |
22 files changed, 794 insertions, 173 deletions
diff --git a/src/common/.gitignore b/src/common/.gitignore new file mode 100644 index 0000000..a13f82d --- /dev/null +++ b/src/common/.gitignore @@ -0,0 +1,2 @@ +# CMake config header +config.h diff --git a/src/common/README.txt b/src/common/README.txt index 25c9fbf..1fc21f1 100644 --- a/src/common/README.txt +++ b/src/common/README.txt @@ -2,3 +2,4 @@ * \dir src/common * \brief Structs and utils shared throughout the application */ + diff --git a/src/common/config.h.cmake b/src/common/config.h.cmake index d5a03b4..76b37b5 100644 --- a/src/common/config.h.cmake +++ b/src/common/config.h.cmake @@ -23,3 +23,4 @@ #define COLOBOT_DEFAULT_DATADIR "@COLOBOT_INSTALL_DATA_DIR@" #define COLOBOT_I18N_DIR "@COLOBOT_INSTALL_I18N_DIR@" + diff --git a/src/common/event.cpp b/src/common/event.cpp index ff3fbc7..7acac77 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -19,15 +19,541 @@ #include "common/logger.h" -static EventType g_uniqueEventType = EVENT_USER; +namespace +{ +static EventType UNIQUE_EVENT_TYPE = EVENT_USER; +const char* EVENT_TYPE_TEXT[EVENT_STD_MAX]; +} +EventType GetUniqueEventType() +{ + int i = static_cast<int>(UNIQUE_EVENT_TYPE+1); + UNIQUE_EVENT_TYPE = static_cast<EventType>(i); + return UNIQUE_EVENT_TYPE; +} +void InitializeEventTypeTexts() +{ + for (int i = 0; i < EVENT_STD_MAX; ++i) + EVENT_TYPE_TEXT[i] = ""; -EventType GetUniqueEventType() + EVENT_TYPE_TEXT[EVENT_NULL] = "EVENT_NULL"; + + EVENT_TYPE_TEXT[EVENT_QUIT] = "EVENT_QUIT"; + + EVENT_TYPE_TEXT[EVENT_FRAME] = "EVENT_FRAME"; + + EVENT_TYPE_TEXT[EVENT_MOUSE_BUTTON_DOWN] = "EVENT_MOUSE_BUTTON_DOWN"; + EVENT_TYPE_TEXT[EVENT_MOUSE_BUTTON_UP] = "EVENT_MOUSE_BUTTON_UP"; + EVENT_TYPE_TEXT[EVENT_MOUSE_WHEEL] = "EVENT_MOUSE_WHEEL"; + EVENT_TYPE_TEXT[EVENT_MOUSE_MOVE] = "EVENT_MOUSE_MOVE"; + EVENT_TYPE_TEXT[EVENT_KEY_DOWN] = "EVENT_KEY_DOWN"; + EVENT_TYPE_TEXT[EVENT_KEY_UP] = "EVENT_KEY_UP"; + + EVENT_TYPE_TEXT[EVENT_ACTIVE] = "EVENT_ACTIVE"; + + EVENT_TYPE_TEXT[EVENT_JOY_AXIS] = "EVENT_JOY_AXIS"; + EVENT_TYPE_TEXT[EVENT_JOY_BUTTON_DOWN] = "EVENT_JOY_BUTTON_DOWN"; + EVENT_TYPE_TEXT[EVENT_JOY_BUTTON_UP] = "EVENT_JOY_BUTTON_UP"; + + + EVENT_TYPE_TEXT[EVENT_UPDINTERFACE] = "EVENT_UPDINTERFACE"; + EVENT_TYPE_TEXT[EVENT_WIN] = "EVENT_WIN"; + EVENT_TYPE_TEXT[EVENT_LOST] = "EVENT_LOST"; + + EVENT_TYPE_TEXT[EVENT_FOCUS] = "EVENT_FOCUS"; + + EVENT_TYPE_TEXT[EVENT_BUTTON_OK] = "EVENT_BUTTON_OK"; + EVENT_TYPE_TEXT[EVENT_BUTTON_CANCEL] = "EVENT_BUTTON_CANCEL"; + EVENT_TYPE_TEXT[EVENT_BUTTON_NEXT] = "EVENT_BUTTON_NEXT"; + EVENT_TYPE_TEXT[EVENT_BUTTON_PREV] = "EVENT_BUTTON_PREV"; + EVENT_TYPE_TEXT[EVENT_BUTTON_QUIT] = "EVENT_BUTTON_QUIT"; + + EVENT_TYPE_TEXT[EVENT_BUTTON0] = "EVENT_BUTTON0"; + EVENT_TYPE_TEXT[EVENT_BUTTON1] = "EVENT_BUTTON1"; + EVENT_TYPE_TEXT[EVENT_BUTTON2] = "EVENT_BUTTON2"; + EVENT_TYPE_TEXT[EVENT_BUTTON3] = "EVENT_BUTTON3"; + EVENT_TYPE_TEXT[EVENT_BUTTON4] = "EVENT_BUTTON4"; + EVENT_TYPE_TEXT[EVENT_BUTTON5] = "EVENT_BUTTON5"; + EVENT_TYPE_TEXT[EVENT_BUTTON6] = "EVENT_BUTTON6"; + EVENT_TYPE_TEXT[EVENT_BUTTON7] = "EVENT_BUTTON7"; + EVENT_TYPE_TEXT[EVENT_BUTTON8] = "EVENT_BUTTON8"; + EVENT_TYPE_TEXT[EVENT_BUTTON9] = "EVENT_BUTTON9"; + EVENT_TYPE_TEXT[EVENT_BUTTON10] = "EVENT_BUTTON10"; + EVENT_TYPE_TEXT[EVENT_BUTTON11] = "EVENT_BUTTON11"; + EVENT_TYPE_TEXT[EVENT_BUTTON12] = "EVENT_BUTTON12"; + EVENT_TYPE_TEXT[EVENT_BUTTON13] = "EVENT_BUTTON13"; + EVENT_TYPE_TEXT[EVENT_BUTTON14] = "EVENT_BUTTON14"; + EVENT_TYPE_TEXT[EVENT_BUTTON15] = "EVENT_BUTTON15"; + EVENT_TYPE_TEXT[EVENT_BUTTON16] = "EVENT_BUTTON16"; + EVENT_TYPE_TEXT[EVENT_BUTTON17] = "EVENT_BUTTON17"; + EVENT_TYPE_TEXT[EVENT_BUTTON18] = "EVENT_BUTTON18"; + EVENT_TYPE_TEXT[EVENT_BUTTON19] = "EVENT_BUTTON19"; + + EVENT_TYPE_TEXT[EVENT_EDIT0] = "EVENT_EDIT0"; + EVENT_TYPE_TEXT[EVENT_EDIT1] = "EVENT_EDIT1"; + EVENT_TYPE_TEXT[EVENT_EDIT2] = "EVENT_EDIT2"; + EVENT_TYPE_TEXT[EVENT_EDIT3] = "EVENT_EDIT3"; + EVENT_TYPE_TEXT[EVENT_EDIT4] = "EVENT_EDIT4"; + EVENT_TYPE_TEXT[EVENT_EDIT5] = "EVENT_EDIT5"; + EVENT_TYPE_TEXT[EVENT_EDIT6] = "EVENT_EDIT6"; + EVENT_TYPE_TEXT[EVENT_EDIT7] = "EVENT_EDIT7"; + EVENT_TYPE_TEXT[EVENT_EDIT8] = "EVENT_EDIT8"; + EVENT_TYPE_TEXT[EVENT_EDIT9] = "EVENT_EDIT9"; + + EVENT_TYPE_TEXT[EVENT_WINDOW0] = "EVENT_WINDOW0"; + EVENT_TYPE_TEXT[EVENT_WINDOW1] = "EVENT_WINDOW1"; + EVENT_TYPE_TEXT[EVENT_WINDOW2] = "EVENT_WINDOW2"; + EVENT_TYPE_TEXT[EVENT_WINDOW3] = "EVENT_WINDOW3"; + EVENT_TYPE_TEXT[EVENT_WINDOW4] = "EVENT_WINDOW4"; + EVENT_TYPE_TEXT[EVENT_WINDOW5] = "EVENT_WINDOW5"; + EVENT_TYPE_TEXT[EVENT_WINDOW6] = "EVENT_WINDOW6"; + EVENT_TYPE_TEXT[EVENT_WINDOW7] = "EVENT_WINDOW7"; + EVENT_TYPE_TEXT[EVENT_WINDOW8] = "EVENT_WINDOW8"; + EVENT_TYPE_TEXT[EVENT_WINDOW9] = "EVENT_WINDOW9"; + + EVENT_TYPE_TEXT[EVENT_LABEL0] = "EVENT_LABEL0"; + EVENT_TYPE_TEXT[EVENT_LABEL1] = "EVENT_LABEL1"; + EVENT_TYPE_TEXT[EVENT_LABEL2] = "EVENT_LABEL2"; + EVENT_TYPE_TEXT[EVENT_LABEL3] = "EVENT_LABEL3"; + EVENT_TYPE_TEXT[EVENT_LABEL4] = "EVENT_LABEL4"; + EVENT_TYPE_TEXT[EVENT_LABEL5] = "EVENT_LABEL5"; + EVENT_TYPE_TEXT[EVENT_LABEL6] = "EVENT_LABEL6"; + EVENT_TYPE_TEXT[EVENT_LABEL7] = "EVENT_LABEL7"; + EVENT_TYPE_TEXT[EVENT_LABEL8] = "EVENT_LABEL8"; + EVENT_TYPE_TEXT[EVENT_LABEL9] = "EVENT_LABEL9"; + EVENT_TYPE_TEXT[EVENT_LABEL10] = "EVENT_LABEL10"; + EVENT_TYPE_TEXT[EVENT_LABEL11] = "EVENT_LABEL11"; + EVENT_TYPE_TEXT[EVENT_LABEL12] = "EVENT_LABEL12"; + EVENT_TYPE_TEXT[EVENT_LABEL13] = "EVENT_LABEL13"; + EVENT_TYPE_TEXT[EVENT_LABEL14] = "EVENT_LABEL14"; + EVENT_TYPE_TEXT[EVENT_LABEL15] = "EVENT_LABEL15"; + EVENT_TYPE_TEXT[EVENT_LABEL16] = "EVENT_LABEL16"; + EVENT_TYPE_TEXT[EVENT_LABEL17] = "EVENT_LABEL17"; + EVENT_TYPE_TEXT[EVENT_LABEL18] = "EVENT_LABEL18"; + EVENT_TYPE_TEXT[EVENT_LABEL19] = "EVENT_LABEL19"; + + EVENT_TYPE_TEXT[EVENT_LIST0] = "EVENT_LIST0"; + EVENT_TYPE_TEXT[EVENT_LIST1] = "EVENT_LIST1"; + EVENT_TYPE_TEXT[EVENT_LIST2] = "EVENT_LIST2"; + EVENT_TYPE_TEXT[EVENT_LIST3] = "EVENT_LIST3"; + EVENT_TYPE_TEXT[EVENT_LIST4] = "EVENT_LIST4"; + EVENT_TYPE_TEXT[EVENT_LIST5] = "EVENT_LIST5"; + EVENT_TYPE_TEXT[EVENT_LIST6] = "EVENT_LIST6"; + EVENT_TYPE_TEXT[EVENT_LIST7] = "EVENT_LIST7"; + EVENT_TYPE_TEXT[EVENT_LIST8] = "EVENT_LIST8"; + EVENT_TYPE_TEXT[EVENT_LIST9] = "EVENT_LIST9"; + + EVENT_TYPE_TEXT[EVENT_TOOLTIP] = "EVENT_TOOLTIP"; + + EVENT_TYPE_TEXT[EVENT_DIALOG_OK] = "EVENT_DIALOG_OK"; + EVENT_TYPE_TEXT[EVENT_DIALOG_CANCEL] = "EVENT_DIALOG_CANCEL"; + EVENT_TYPE_TEXT[EVENT_DIALOG_LABEL] = "EVENT_DIALOG_LABEL"; + EVENT_TYPE_TEXT[EVENT_DIALOG_LABEL1] = "EVENT_DIALOG_LABEL1"; + EVENT_TYPE_TEXT[EVENT_DIALOG_LABEL2] = "EVENT_DIALOG_LABEL2"; + EVENT_TYPE_TEXT[EVENT_DIALOG_LABEL3] = "EVENT_DIALOG_LABEL3"; + EVENT_TYPE_TEXT[EVENT_DIALOG_LIST] = "EVENT_DIALOG_LIST"; + EVENT_TYPE_TEXT[EVENT_DIALOG_EDIT] = "EVENT_DIALOG_EDIT"; + EVENT_TYPE_TEXT[EVENT_DIALOG_CHECK1] = "EVENT_DIALOG_CHECK1"; + EVENT_TYPE_TEXT[EVENT_DIALOG_CHECK2] = "EVENT_DIALOG_CHECK2"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_TRAINER] = "EVENT_INTERFACE_TRAINER"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_DEFI] = "EVENT_INTERFACE_DEFI"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_MISSION] = "EVENT_INTERFACE_MISSION"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_FREE] = "EVENT_INTERFACE_FREE"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PROTO] = "EVENT_INTERFACE_PROTO"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_NAME] = "EVENT_INTERFACE_NAME"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SETUP] = "EVENT_INTERFACE_SETUP"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_QUIT] = "EVENT_INTERFACE_QUIT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_BACK] = "EVENT_INTERFACE_BACK"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_AGAIN] = "EVENT_INTERFACE_AGAIN"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_WRITE] = "EVENT_INTERFACE_WRITE"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_READ] = "EVENT_INTERFACE_READ"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_ABORT] = "EVENT_INTERFACE_ABORT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_USER] = "EVENT_INTERFACE_USER"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_TEEN] = "EVENT_INTERFACE_TEEN"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_CHAP] = "EVENT_INTERFACE_CHAP"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_LIST] = "EVENT_INTERFACE_LIST"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_RESUME] = "EVENT_INTERFACE_RESUME"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PLAY] = "EVENT_INTERFACE_PLAY"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_SETUPd] = "EVENT_INTERFACE_SETUPd"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SETUPg] = "EVENT_INTERFACE_SETUPg"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SETUPp] = "EVENT_INTERFACE_SETUPp"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SETUPc] = "EVENT_INTERFACE_SETUPc"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SETUPs] = "EVENT_INTERFACE_SETUPs"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_DEVICE] = "EVENT_INTERFACE_DEVICE"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_RESOL] = "EVENT_INTERFACE_RESOL"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_FULL] = "EVENT_INTERFACE_FULL"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_APPLY] = "EVENT_INTERFACE_APPLY"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_TOTO] = "EVENT_INTERFACE_TOTO"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SHADOW] = "EVENT_INTERFACE_SHADOW"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_DIRTY] = "EVENT_INTERFACE_DIRTY"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_LENS] = "EVENT_INTERFACE_LENS"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SKY] = "EVENT_INTERFACE_SKY"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PLANET] = "EVENT_INTERFACE_PLANET"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_LIGHT] = "EVENT_INTERFACE_LIGHT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PARTI] = "EVENT_INTERFACE_PARTI"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_CLIP] = "EVENT_INTERFACE_CLIP"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_DETAIL] = "EVENT_INTERFACE_DETAIL"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_TEXTURE] = "EVENT_INTERFACE_TEXTURE"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_RAIN] = "EVENT_INTERFACE_RAIN"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_GLINT] = "EVENT_INTERFACE_GLINT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_TOOLTIP] = "EVENT_INTERFACE_TOOLTIP"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_MOVIES] = "EVENT_INTERFACE_MOVIES"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_NICERST] = "EVENT_INTERFACE_NICERST"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SCROLL] = "EVENT_INTERFACE_SCROLL"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_INVERTX] = "EVENT_INTERFACE_INVERTX"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_INVERTY] = "EVENT_INTERFACE_INVERTY"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_EFFECT] = "EVENT_INTERFACE_EFFECT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_MOUSE] = "EVENT_INTERFACE_MOUSE"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_GROUND] = "EVENT_INTERFACE_GROUND"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_GADGET] = "EVENT_INTERFACE_GADGET"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_FOG] = "EVENT_INTERFACE_FOG"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_HIMSELF] = "EVENT_INTERFACE_HIMSELF"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_EDITMODE]= "EVENT_INTERFACE_EDITMODE"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_EDITVALUE]= "EVENT_INTERFACE_EDITVALUE"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SOLUCE4] = "EVENT_INTERFACE_SOLUCE4"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_KINFO1] = "EVENT_INTERFACE_KINFO1"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KINFO2] = "EVENT_INTERFACE_KINFO2"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KGROUP] = "EVENT_INTERFACE_KGROUP"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KSCROLL] = "EVENT_INTERFACE_KSCROLL"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KDEF] = "EVENT_INTERFACE_KDEF"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KLEFT] = "EVENT_INTERFACE_KLEFT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KRIGHT] = "EVENT_INTERFACE_KRIGHT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KUP] = "EVENT_INTERFACE_KUP"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KDOWN] = "EVENT_INTERFACE_KDOWN"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KGUP] = "EVENT_INTERFACE_KGUP"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KGDOWN] = "EVENT_INTERFACE_KGDOWN"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KCAMERA] = "EVENT_INTERFACE_KCAMERA"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KDESEL] = "EVENT_INTERFACE_KDESEL"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KACTION] = "EVENT_INTERFACE_KACTION"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KNEAR] = "EVENT_INTERFACE_KNEAR"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KAWAY] = "EVENT_INTERFACE_KAWAY"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KNEXT] = "EVENT_INTERFACE_KNEXT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KHUMAN] = "EVENT_INTERFACE_KHUMAN"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KQUIT] = "EVENT_INTERFACE_KQUIT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KHELP] = "EVENT_INTERFACE_KHELP"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KPROG] = "EVENT_INTERFACE_KPROG"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KCBOT] = "EVENT_INTERFACE_KCBOT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KVISIT] = "EVENT_INTERFACE_KVISIT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KSPEED10]= "EVENT_INTERFACE_KSPEED10"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KSPEED15]= "EVENT_INTERFACE_KSPEED15"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KSPEED20]= "EVENT_INTERFACE_KSPEED20"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KSPEED30]= "EVENT_INTERFACE_KSPEED30"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_VOLSOUND]= "EVENT_INTERFACE_VOLSOUND"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_VOLMUSIC]= "EVENT_INTERFACE_VOLMUSIC"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SOUND3D] = "EVENT_INTERFACE_SOUND3D"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_MIN] = "EVENT_INTERFACE_MIN"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_NORM] = "EVENT_INTERFACE_NORM"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_MAX] = "EVENT_INTERFACE_MAX"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_SILENT] = "EVENT_INTERFACE_SILENT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_NOISY] = "EVENT_INTERFACE_NOISY"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_JOYSTICK]= "EVENT_INTERFACE_JOYSTICK"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SOLUCE] = "EVENT_INTERFACE_SOLUCE"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_GLINTl] = "EVENT_INTERFACE_GLINTl"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_GLINTr] = "EVENT_INTERFACE_GLINTr"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_GLINTu] = "EVENT_INTERFACE_GLINTu"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_GLINTb] = "EVENT_INTERFACE_GLINTb"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_NEDIT] = "EVENT_INTERFACE_NEDIT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_NLIST] = "EVENT_INTERFACE_NLIST"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_NOK] = "EVENT_INTERFACE_NOK"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_NCANCEL] = "EVENT_INTERFACE_NCANCEL"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_NDELETE] = "EVENT_INTERFACE_NDELETE"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_NLABEL] = "EVENT_INTERFACE_NLABEL"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_IOWRITE] = "EVENT_INTERFACE_IOWRITE"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_IOREAD] = "EVENT_INTERFACE_IOREAD"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_IOLIST] = "EVENT_INTERFACE_IOLIST"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_IONAME] = "EVENT_INTERFACE_IONAME"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_IOLABEL] = "EVENT_INTERFACE_IOLABEL"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_IOIMAGE] = "EVENT_INTERFACE_IOIMAGE"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_IODELETE]= "EVENT_INTERFACE_IODELETE"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_PERSO] = "EVENT_INTERFACE_PERSO"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_POK] = "EVENT_INTERFACE_POK"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PCANCEL] = "EVENT_INTERFACE_PCANCEL"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PDEF] = "EVENT_INTERFACE_PDEF"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PHEAD] = "EVENT_INTERFACE_PHEAD"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PBODY] = "EVENT_INTERFACE_PBODY"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PLROT] = "EVENT_INTERFACE_PLROT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PRROT] = "EVENT_INTERFACE_PRROT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC0a] = "EVENT_INTERFACE_PC0a"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC1a] = "EVENT_INTERFACE_PC1a"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC2a] = "EVENT_INTERFACE_PC2a"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC3a] = "EVENT_INTERFACE_PC3a"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC4a] = "EVENT_INTERFACE_PC4a"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC5a] = "EVENT_INTERFACE_PC5a"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC6a] = "EVENT_INTERFACE_PC6a"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC7a] = "EVENT_INTERFACE_PC7a"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC8a] = "EVENT_INTERFACE_PC8a"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC9a] = "EVENT_INTERFACE_PC9a"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PCRa] = "EVENT_INTERFACE_PCRa"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PCGa] = "EVENT_INTERFACE_PCGa"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PCBa] = "EVENT_INTERFACE_PCBa"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC0b] = "EVENT_INTERFACE_PC0b"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC1b] = "EVENT_INTERFACE_PC1b"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC2b] = "EVENT_INTERFACE_PC2b"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC3b] = "EVENT_INTERFACE_PC3b"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC4b] = "EVENT_INTERFACE_PC4b"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC5b] = "EVENT_INTERFACE_PC5b"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC6b] = "EVENT_INTERFACE_PC6b"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC7b] = "EVENT_INTERFACE_PC7b"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC8b] = "EVENT_INTERFACE_PC8b"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC9b] = "EVENT_INTERFACE_PC9b"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PCRb] = "EVENT_INTERFACE_PCRb"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PCGb] = "EVENT_INTERFACE_PCGb"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PCBb] = "EVENT_INTERFACE_PCBb"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PFACE1] = "EVENT_INTERFACE_PFACE1"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PFACE2] = "EVENT_INTERFACE_PFACE2"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PFACE3] = "EVENT_INTERFACE_PFACE3"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PFACE4] = "EVENT_INTERFACE_PFACE4"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS0] = "EVENT_INTERFACE_PGLASS0"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS1] = "EVENT_INTERFACE_PGLASS1"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS2] = "EVENT_INTERFACE_PGLASS2"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS3] = "EVENT_INTERFACE_PGLASS3"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS4] = "EVENT_INTERFACE_PGLASS4"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS5] = "EVENT_INTERFACE_PGLASS5"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS6] = "EVENT_INTERFACE_PGLASS6"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS7] = "EVENT_INTERFACE_PGLASS7"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS8] = "EVENT_INTERFACE_PGLASS8"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS9] = "EVENT_INTERFACE_PGLASS9"; + + EVENT_TYPE_TEXT[EVENT_DT_GROUP0] = "EVENT_DT_GROUP0"; + EVENT_TYPE_TEXT[EVENT_DT_GROUP1] = "EVENT_DT_GROUP1"; + EVENT_TYPE_TEXT[EVENT_DT_GROUP2] = "EVENT_DT_GROUP2"; + EVENT_TYPE_TEXT[EVENT_DT_GROUP3] = "EVENT_DT_GROUP3"; + EVENT_TYPE_TEXT[EVENT_DT_GROUP4] = "EVENT_DT_GROUP4"; + EVENT_TYPE_TEXT[EVENT_DT_LABEL0] = "EVENT_DT_LABEL0"; + EVENT_TYPE_TEXT[EVENT_DT_LABEL1] = "EVENT_DT_LABEL1"; + EVENT_TYPE_TEXT[EVENT_DT_LABEL2] = "EVENT_DT_LABEL2"; + EVENT_TYPE_TEXT[EVENT_DT_LABEL3] = "EVENT_DT_LABEL3"; + EVENT_TYPE_TEXT[EVENT_DT_LABEL4] = "EVENT_DT_LABEL4"; + EVENT_TYPE_TEXT[EVENT_DT_VISIT0] = "EVENT_DT_VISIT0"; + EVENT_TYPE_TEXT[EVENT_DT_VISIT1] = "EVENT_DT_VISIT1"; + EVENT_TYPE_TEXT[EVENT_DT_VISIT2] = "EVENT_DT_VISIT2"; + EVENT_TYPE_TEXT[EVENT_DT_VISIT3] = "EVENT_DT_VISIT3"; + EVENT_TYPE_TEXT[EVENT_DT_VISIT4] = "EVENT_DT_VISIT4"; + EVENT_TYPE_TEXT[EVENT_DT_END] = "EVENT_DT_END"; + + EVENT_TYPE_TEXT[EVENT_CMD] = "EVENT_CMD"; + EVENT_TYPE_TEXT[EVENT_SPEED] = "EVENT_SPEED"; + + EVENT_TYPE_TEXT[EVENT_HYPER_PREV] = "EVENT_HYPER_PREV"; + EVENT_TYPE_TEXT[EVENT_HYPER_NEXT] = "EVENT_HYPER_NEXT"; + EVENT_TYPE_TEXT[EVENT_HYPER_HOME] = "EVENT_HYPER_HOME"; + EVENT_TYPE_TEXT[EVENT_HYPER_COPY] = "EVENT_HYPER_COPY"; + EVENT_TYPE_TEXT[EVENT_HYPER_SIZE1] = "EVENT_HYPER_SIZE1"; + EVENT_TYPE_TEXT[EVENT_HYPER_SIZE2] = "EVENT_HYPER_SIZE2"; + EVENT_TYPE_TEXT[EVENT_HYPER_SIZE3] = "EVENT_HYPER_SIZE3"; + EVENT_TYPE_TEXT[EVENT_HYPER_SIZE4] = "EVENT_HYPER_SIZE4"; + EVENT_TYPE_TEXT[EVENT_HYPER_SIZE5] = "EVENT_HYPER_SIZE5"; + + EVENT_TYPE_TEXT[EVENT_SATCOM_HUSTON] = "EVENT_SATCOM_HUSTON"; + EVENT_TYPE_TEXT[EVENT_SATCOM_SAT] = "EVENT_SATCOM_SAT"; + EVENT_TYPE_TEXT[EVENT_SATCOM_LOADING] = "EVENT_SATCOM_LOADING"; + EVENT_TYPE_TEXT[EVENT_SATCOM_OBJECT] = "EVENT_SATCOM_OBJECT"; + EVENT_TYPE_TEXT[EVENT_SATCOM_PROG] = "EVENT_SATCOM_PROG"; + EVENT_TYPE_TEXT[EVENT_SATCOM_SOLUCE] = "EVENT_SATCOM_SOLUCE"; + + EVENT_TYPE_TEXT[EVENT_OBJECT_DESELECT] = "EVENT_OBJECT_DESELECT"; + EVENT_TYPE_TEXT[EVENT_OBJECT_LEFT] = "EVENT_OBJECT_LEFT"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RIGHT] = "EVENT_OBJECT_RIGHT"; + EVENT_TYPE_TEXT[EVENT_OBJECT_UP] = "EVENT_OBJECT_UP"; + EVENT_TYPE_TEXT[EVENT_OBJECT_DOWN] = "EVENT_OBJECT_DOWN"; + EVENT_TYPE_TEXT[EVENT_OBJECT_GASUP] = "EVENT_OBJECT_GASUP"; + EVENT_TYPE_TEXT[EVENT_OBJECT_GASDOWN] = "EVENT_OBJECT_GASDOWN"; + EVENT_TYPE_TEXT[EVENT_OBJECT_HTAKE] = "EVENT_OBJECT_HTAKE"; + EVENT_TYPE_TEXT[EVENT_OBJECT_MTAKE] = "EVENT_OBJECT_MTAKE"; + EVENT_TYPE_TEXT[EVENT_OBJECT_MFRONT] = "EVENT_OBJECT_MFRONT"; + EVENT_TYPE_TEXT[EVENT_OBJECT_MBACK] = "EVENT_OBJECT_MBACK"; + EVENT_TYPE_TEXT[EVENT_OBJECT_MPOWER] = "EVENT_OBJECT_MPOWER"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BHELP] = "EVENT_OBJECT_BHELP"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BTAKEOFF] = "EVENT_OBJECT_BTAKEOFF"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BDESTROY] = "EVENT_OBJECT_BDESTROY"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BDERRICK] = "EVENT_OBJECT_BDERRICK"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BSTATION] = "EVENT_OBJECT_BSTATION"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BFACTORY] = "EVENT_OBJECT_BFACTORY"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BCONVERT] = "EVENT_OBJECT_BCONVERT"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BTOWER] = "EVENT_OBJECT_BTOWER"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BREPAIR] = "EVENT_OBJECT_BREPAIR"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BRESEARCH] = "EVENT_OBJECT_BRESEARCH"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BRADAR] = "EVENT_OBJECT_BRADAR"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BENERGY] = "EVENT_OBJECT_BENERGY"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BLABO] = "EVENT_OBJECT_BLABO"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BNUCLEAR] = "EVENT_OBJECT_BNUCLEAR"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BPARA] = "EVENT_OBJECT_BPARA"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BINFO] = "EVENT_OBJECT_BINFO"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BDESTROYER] = "EVENT_OBJECT_BDESTROYER"; + EVENT_TYPE_TEXT[EVENT_OBJECT_GFLAT] = "EVENT_OBJECT_GFLAT"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FCREATE] = "EVENT_OBJECT_FCREATE"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FDELETE] = "EVENT_OBJECT_FDELETE"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FCOLORb] = "EVENT_OBJECT_FCOLORb"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FCOLORr] = "EVENT_OBJECT_FCOLORr"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FCOLORg] = "EVENT_OBJECT_FCOLORg"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FCOLORy] = "EVENT_OBJECT_FCOLORy"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FCOLORv] = "EVENT_OBJECT_FCOLORv"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYwa] = "EVENT_OBJECT_FACTORYwa"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYta] = "EVENT_OBJECT_FACTORYta"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYfa] = "EVENT_OBJECT_FACTORYfa"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYia] = "EVENT_OBJECT_FACTORYia"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYwc] = "EVENT_OBJECT_FACTORYwc"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYtc] = "EVENT_OBJECT_FACTORYtc"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYfc] = "EVENT_OBJECT_FACTORYfc"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYic] = "EVENT_OBJECT_FACTORYic"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYwi] = "EVENT_OBJECT_FACTORYwi"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYti] = "EVENT_OBJECT_FACTORYti"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYfi] = "EVENT_OBJECT_FACTORYfi"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYii] = "EVENT_OBJECT_FACTORYii"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYws] = "EVENT_OBJECT_FACTORYws"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYts] = "EVENT_OBJECT_FACTORYts"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYfs] = "EVENT_OBJECT_FACTORYfs"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYis] = "EVENT_OBJECT_FACTORYis"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYrt] = "EVENT_OBJECT_FACTORYrt"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYrc] = "EVENT_OBJECT_FACTORYrc"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYrr] = "EVENT_OBJECT_FACTORYrr"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYrs] = "EVENT_OBJECT_FACTORYrs"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYsa] = "EVENT_OBJECT_FACTORYsa"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SEARCH] = "EVENT_OBJECT_SEARCH"; + EVENT_TYPE_TEXT[EVENT_OBJECT_TERRAFORM] = "EVENT_OBJECT_TERRAFORM"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FIRE] = "EVENT_OBJECT_FIRE"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FIREANT] = "EVENT_OBJECT_FIREANT"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SPIDEREXPLO]= "EVENT_OBJECT_SPIDEREXPLO"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RECOVER] = "EVENT_OBJECT_RECOVER"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BEGSHIELD] = "EVENT_OBJECT_BEGSHIELD"; + EVENT_TYPE_TEXT[EVENT_OBJECT_ENDSHIELD] = "EVENT_OBJECT_ENDSHIELD"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RTANK] = "EVENT_OBJECT_RTANK"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RFLY] = "EVENT_OBJECT_RFLY"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RTHUMP] = "EVENT_OBJECT_RTHUMP"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RCANON] = "EVENT_OBJECT_RCANON"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RTOWER] = "EVENT_OBJECT_RTOWER"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RPHAZER] = "EVENT_OBJECT_RPHAZER"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RSHIELD] = "EVENT_OBJECT_RSHIELD"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RATOMIC] = "EVENT_OBJECT_RATOMIC"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RiPAW] = "EVENT_OBJECT_RiPAW"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RiGUN] = "EVENT_OBJECT_RiGUN"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RESET] = "EVENT_OBJECT_RESET"; + EVENT_TYPE_TEXT[EVENT_OBJECT_DIMSHIELD] = "EVENT_OBJECT_DIMSHIELD"; + EVENT_TYPE_TEXT[EVENT_OBJECT_TARGET] = "EVENT_OBJECT_TARGET"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PROGLIST] = "EVENT_OBJECT_PROGLIST"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PROGRUN] = "EVENT_OBJECT_PROGRUN"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PROGEDIT] = "EVENT_OBJECT_PROGEDIT"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PROGSTART] = "EVENT_OBJECT_PROGSTART"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PROGSTOP] = "EVENT_OBJECT_PROGSTOP"; + EVENT_TYPE_TEXT[EVENT_OBJECT_INFOOK] = "EVENT_OBJECT_INFOOK"; + EVENT_TYPE_TEXT[EVENT_OBJECT_DELETE] = "EVENT_OBJECT_DELETE"; + EVENT_TYPE_TEXT[EVENT_OBJECT_GENERGY] = "EVENT_OBJECT_GENERGY"; + EVENT_TYPE_TEXT[EVENT_OBJECT_GSHIELD] = "EVENT_OBJECT_GSHIELD"; + EVENT_TYPE_TEXT[EVENT_OBJECT_GRANGE] = "EVENT_OBJECT_GRANGE"; + EVENT_TYPE_TEXT[EVENT_OBJECT_COMPASS] = "EVENT_OBJECT_COMPASS"; + EVENT_TYPE_TEXT[EVENT_OBJECT_MAP] = "EVENT_OBJECT_MAP"; + EVENT_TYPE_TEXT[EVENT_OBJECT_MAPZOOM] = "EVENT_OBJECT_MAPZOOM"; + EVENT_TYPE_TEXT[EVENT_OBJECT_GPROGRESS] = "EVENT_OBJECT_GPROGRESS"; + EVENT_TYPE_TEXT[EVENT_OBJECT_GRADAR] = "EVENT_OBJECT_GRADAR"; + EVENT_TYPE_TEXT[EVENT_OBJECT_GINFO] = "EVENT_OBJECT_GINFO"; + EVENT_TYPE_TEXT[EVENT_OBJECT_TYPE] = "EVENT_OBJECT_TYPE"; + EVENT_TYPE_TEXT[EVENT_OBJECT_CROSSHAIR] = "EVENT_OBJECT_CROSSHAIR"; + EVENT_TYPE_TEXT[EVENT_OBJECT_CORNERul] = "EVENT_OBJECT_CORNERul"; + EVENT_TYPE_TEXT[EVENT_OBJECT_CORNERur] = "EVENT_OBJECT_CORNERur"; + EVENT_TYPE_TEXT[EVENT_OBJECT_CORNERdl] = "EVENT_OBJECT_CORNERdl"; + EVENT_TYPE_TEXT[EVENT_OBJECT_CORNERdr] = "EVENT_OBJECT_CORNERdr"; + EVENT_TYPE_TEXT[EVENT_OBJECT_MAPi] = "EVENT_OBJECT_MAPi"; + EVENT_TYPE_TEXT[EVENT_OBJECT_MAPg] = "EVENT_OBJECT_MAPg"; + EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERA] = "EVENT_OBJECT_CAMERA"; + EVENT_TYPE_TEXT[EVENT_OBJECT_HELP] = "EVENT_OBJECT_HELP"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SOLUCE] = "EVENT_OBJECT_SOLUCE"; + EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERAleft] = "EVENT_OBJECT_CAMERAleft"; + EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERAright]= "EVENT_OBJECT_CAMERAright"; + EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERAnear] = "EVENT_OBJECT_CAMERAnear"; + EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERAaway] = "EVENT_OBJECT_CAMERAaway"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT00] = "EVENT_OBJECT_SHORTCUT00"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT01] = "EVENT_OBJECT_SHORTCUT01"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT02] = "EVENT_OBJECT_SHORTCUT02"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT03] = "EVENT_OBJECT_SHORTCUT03"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT04] = "EVENT_OBJECT_SHORTCUT04"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT05] = "EVENT_OBJECT_SHORTCUT05"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT06] = "EVENT_OBJECT_SHORTCUT06"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT07] = "EVENT_OBJECT_SHORTCUT07"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT08] = "EVENT_OBJECT_SHORTCUT08"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT09] = "EVENT_OBJECT_SHORTCUT09"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT10] = "EVENT_OBJECT_SHORTCUT10"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT11] = "EVENT_OBJECT_SHORTCUT11"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT12] = "EVENT_OBJECT_SHORTCUT12"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT13] = "EVENT_OBJECT_SHORTCUT13"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT14] = "EVENT_OBJECT_SHORTCUT14"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT15] = "EVENT_OBJECT_SHORTCUT15"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT16] = "EVENT_OBJECT_SHORTCUT16"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT17] = "EVENT_OBJECT_SHORTCUT17"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT18] = "EVENT_OBJECT_SHORTCUT18"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT19] = "EVENT_OBJECT_SHORTCUT19"; + EVENT_TYPE_TEXT[EVENT_OBJECT_MOVIELOCK] = "EVENT_OBJECT_MOVIELOCK"; + EVENT_TYPE_TEXT[EVENT_OBJECT_EDITLOCK] = "EVENT_OBJECT_EDITLOCK"; + EVENT_TYPE_TEXT[EVENT_OBJECT_LIMIT] = "EVENT_OBJECT_LIMIT"; + + EVENT_TYPE_TEXT[EVENT_OBJECT_PEN0] = "EVENT_OBJECT_PEN0"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PEN1] = "EVENT_OBJECT_PEN1"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PEN2] = "EVENT_OBJECT_PEN2"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PEN3] = "EVENT_OBJECT_PEN3"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PEN4] = "EVENT_OBJECT_PEN4"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PEN5] = "EVENT_OBJECT_PEN5"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PEN6] = "EVENT_OBJECT_PEN6"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PEN7] = "EVENT_OBJECT_PEN7"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PEN8] = "EVENT_OBJECT_PEN8"; + EVENT_TYPE_TEXT[EVENT_OBJECT_REC] = "EVENT_OBJECT_REC"; + EVENT_TYPE_TEXT[EVENT_OBJECT_STOP] = "EVENT_OBJECT_STOP"; + + EVENT_TYPE_TEXT[EVENT_STUDIO_OK] = "EVENT_STUDIO_OK"; + EVENT_TYPE_TEXT[EVENT_STUDIO_CANCEL] = "EVENT_STUDIO_CANCEL"; + EVENT_TYPE_TEXT[EVENT_STUDIO_EDIT] = "EVENT_STUDIO_EDIT"; + EVENT_TYPE_TEXT[EVENT_STUDIO_LIST] = "EVENT_STUDIO_LIST"; + EVENT_TYPE_TEXT[EVENT_STUDIO_NEW] = "EVENT_STUDIO_NEW"; + EVENT_TYPE_TEXT[EVENT_STUDIO_OPEN] = "EVENT_STUDIO_OPEN"; + EVENT_TYPE_TEXT[EVENT_STUDIO_SAVE] = "EVENT_STUDIO_SAVE"; + EVENT_TYPE_TEXT[EVENT_STUDIO_UNDO] = "EVENT_STUDIO_UNDO"; + EVENT_TYPE_TEXT[EVENT_STUDIO_CUT] = "EVENT_STUDIO_CUT"; + EVENT_TYPE_TEXT[EVENT_STUDIO_COPY] = "EVENT_STUDIO_COPY"; + EVENT_TYPE_TEXT[EVENT_STUDIO_PASTE] = "EVENT_STUDIO_PASTE"; + EVENT_TYPE_TEXT[EVENT_STUDIO_SIZE] = "EVENT_STUDIO_SIZE"; + EVENT_TYPE_TEXT[EVENT_STUDIO_TOOL] = "EVENT_STUDIO_TOOL"; + EVENT_TYPE_TEXT[EVENT_STUDIO_HELP] = "EVENT_STUDIO_HELP"; + EVENT_TYPE_TEXT[EVENT_STUDIO_COMPILE] = "EVENT_STUDIO_COMPILE"; + EVENT_TYPE_TEXT[EVENT_STUDIO_RUN] = "EVENT_STUDIO_RUN"; + EVENT_TYPE_TEXT[EVENT_STUDIO_REALTIME] = "EVENT_STUDIO_REALTIME"; + EVENT_TYPE_TEXT[EVENT_STUDIO_STEP] = "EVENT_STUDIO_STEP"; +} + +std::string ParseEventType(EventType eventType) { - int i = static_cast<int>(g_uniqueEventType+1); - g_uniqueEventType = static_cast<EventType>(i); - return g_uniqueEventType; + auto Other = [&](const char* name) + { + std::stringstream str; + str << name << "(" << static_cast<int>(eventType) << ")"; + return str.str(); + }; + + if (eventType < EVENT_STD_MAX) + { + const char* stdEvent = EVENT_TYPE_TEXT[eventType]; + if (stdEvent[0] == 0) + return Other("STD_UNDEFINED"); + + return stdEvent; + } + + if (eventType >= EVENT_USER) + return Other("USER_EVENT"); + + return Other("UNDEFINED"); } diff --git a/src/common/event.h b/src/common/event.h index 153b732..9405660 100644 --- a/src/common/event.h +++ b/src/common/event.h @@ -40,8 +40,10 @@ enum EventType //! Invalid event / no event EVENT_NULL = 0, - //! Event sent on user or system quit request - EVENT_QUIT = 1, + // System events (originating in CApplication) + + //! Event sent on system quit request + EVENT_SYS_QUIT = 1, //! Frame update event EVENT_FRAME = 2, @@ -69,10 +71,15 @@ enum EventType //! Event sent after releasing a joystick button EVENT_JOY_BUTTON_UP = 14, + //!< Maximum value of system events + EVENT_SYS_MAX, + /* Events sent/received in game and user interface */ - EVENT_UPDINTERFACE = 20, + //! Event sent on user quit request + EVENT_QUIT = 20, + EVENT_UPDINTERFACE = 21, EVENT_WIN = 30, EVENT_LOST = 31, @@ -396,6 +403,7 @@ enum EventType EVENT_OBJECT_MPOWER = 1024, EVENT_OBJECT_BHELP = 1040, EVENT_OBJECT_BTAKEOFF = 1041, + EVENT_OBJECT_BDESTROY = 1042, EVENT_OBJECT_BDERRICK = 1050, EVENT_OBJECT_BSTATION = 1051, EVENT_OBJECT_BFACTORY = 1052, @@ -547,7 +555,8 @@ enum EventType EVENT_STUDIO_REALTIME = 2052, EVENT_STUDIO_STEP = 2053, - EVENT_STD_MAX, //! < maximum value of standard events + //! Maximum value of standard events + EVENT_STD_MAX, EVENT_USER = 10000, EVENT_FORCE_LONG = 0x7fffffff @@ -668,8 +677,8 @@ struct ActiveEventData * \struct Event * \brief Event sent by system, interface or game * - * Event is described by its type (EventType) and the union - * \a data contains additional data about the event. + * Event is described by its type (EventType) and anonymous union that + * contains additional data about the event. * Different members of the union are filled with different event types. * With some events, nothing is filled (it's zeroed out). * The union contains roughly the same information as SDL_Event struct @@ -680,9 +689,6 @@ struct Event //! Type of event EventType type; - //! If true, the event was produced by system in CApplication; else, it has come from game engine - bool systemEvent; - //! Relative time since last EVENT_FRAME //! Scope: only EVENT_FRAME events // TODO: gradually replace the usage of this with new CApplication's time functions @@ -729,22 +735,25 @@ struct Event ActiveEventData active; }; - Event(EventType type = EVENT_NULL) - { - this->type = type; - - systemEvent = false; - rTime = 0.0f; - mouseButtonsState = 0; - trackedKeysState = 0; - customParam = 0; - } + explicit Event(EventType _type = EVENT_NULL) + : type(_type) + , rTime(0.0f) + , kmodState(0) + , trackedKeysState(0) + , mouseButtonsState(0) + , customParam(0) + {} }; //! Returns an unique event type (above the standard IDs) EventType GetUniqueEventType(); +//! Initializes static array with event type strings +void InitializeEventTypeTexts(); + +//! Parses event type to string +std::string ParseEventType(EventType eventType); /** * \class CEventQueue @@ -778,3 +787,4 @@ protected: int m_tail; int m_total; }; + diff --git a/src/common/global.h b/src/common/global.h index 7a5fdfd..a322057 100644 --- a/src/common/global.h +++ b/src/common/global.h @@ -55,6 +55,8 @@ enum Error ERR_BUILD_BASE = 129, //! < too close to the rocket ERR_BUILD_NARROW = 130, //! < buildings too close ERR_BUILD_MOTOR = 131, //! < built: not possible in movement + ERR_BUILD_DISABLED = 132, //! < built: can not produce this object in this mission + ERR_BUILD_RESEARCH = 133, //! < built: can not produce not researched object ERR_SEARCH_FLY = 140, //! < not possible in flight ERR_SEARCH_VEH = 141, //! < inappropriate vehicle ERR_SEARCH_MOTOR = 142, //! < impossible in movement @@ -104,6 +106,8 @@ enum Error ERR_INFO_NULL = 390, //! < no information terminal ERR_VEH_VIRUS = 400, //! < vehicle infected by a virus ERR_BAT_VIRUS = 401, //! < building infected by a virus + ERR_DESTROY_NOTFOUND = 410, //! < not found anything to destroy + ERR_WRONG_OBJ = 420, //! < inappropriate vehicle ERR_VEH_POWER = 500, //! < no battery ERR_VEH_ENERGY = 501, //! < more energy ERR_FLAG_FLY = 510, //! < impossible in flight @@ -293,3 +297,4 @@ extern int g_build; // constructible buildings extern int g_researchDone; // research done extern long g_researchEnable; // research available extern float g_unit; // conversion factor + diff --git a/src/common/image.cpp b/src/common/image.cpp index db14797..a9587ef 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -17,6 +17,8 @@ #include "common/image.h" +#include "math/func.h" + #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -108,7 +110,8 @@ bool PNGSaveSurface(const char *filename, SDL_Surface *surf) return false; } - if (setjmp(png_jmpbuf(png_ptr))) { + if (setjmp(png_jmpbuf(png_ptr))) + { png_destroy_write_struct(&png_ptr, &info_ptr); fclose(fp); return false; @@ -200,6 +203,33 @@ void CImage::Fill(Gfx::IntColor color) } /** + * Image must be valid. + * + * The dimensions are increased to nearest even power of two values. + * If image is already in power-of-two format, nothing is done. + */ +void CImage::PadToNearestPowerOfTwo() +{ + assert(m_data != nullptr); + + if (Math::IsPowerOfTwo(m_data->surface->w) && Math::IsPowerOfTwo(m_data->surface->h)) + return; + + int w = Math::NextPowerOfTwo(m_data->surface->w); + int h = Math::NextPowerOfTwo(m_data->surface->h); + + m_data->surface->flags &= (~SDL_SRCALPHA); + SDL_Surface* resizedSurface = SDL_CreateRGBSurface(0, w, h, 32, 0x00ff0000, 0x0000ff00, + 0x000000ff, 0xff000000); + assert(resizedSurface != NULL); + SDL_BlitSurface(m_data->surface, NULL, resizedSurface, NULL); + + SDL_FreeSurface(m_data->surface); + + m_data->surface = resizedSurface; +} + +/** * Image must be valid and pixel coords in valid range. * * \param pixel pixel coords (range x: 0..width-1 y: 0..height-1) @@ -367,3 +397,4 @@ bool CImage::SavePNG(const std::string& fileName) return true; } + diff --git a/src/common/image.h b/src/common/image.h index d9da75b..44aedf1 100644 --- a/src/common/image.h +++ b/src/common/image.h @@ -94,6 +94,9 @@ public: //! Returns the precise color at given pixel Gfx::IntColor GetPixelInt(Math::IntPoint pixel); + //! Pads the image to nearest power of 2 dimensions + void PadToNearestPowerOfTwo(); + //! Loads an image from the specified file bool Load(const std::string &fileName); @@ -109,3 +112,4 @@ private: //! Image data ImageData* m_data; }; + diff --git a/src/common/iman.cpp b/src/common/iman.cpp index e1400fd..88fbb9b 100644 --- a/src/common/iman.cpp +++ b/src/common/iman.cpp @@ -111,3 +111,4 @@ void CInstanceManager::Compress(ManagedClassType classType) } m_table[classType].usedCount = j; } + diff --git a/src/common/iman.h b/src/common/iman.h index faabd0c..bfa2204 100644 --- a/src/common/iman.h +++ b/src/common/iman.h @@ -93,4 +93,3 @@ protected: ManagedClassInstances m_table[CLASS_MAX]; }; - diff --git a/src/common/ioutils.h b/src/common/ioutils.h index 9a94617..823b720 100644 --- a/src/common/ioutils.h +++ b/src/common/ioutils.h @@ -146,3 +146,4 @@ std::string ReadBinaryString(std::istream &istr) } }; // namespace IOUtils + diff --git a/src/common/key.h b/src/common/key.h index 84ee618..82b3fbd 100644 --- a/src/common/key.h +++ b/src/common/key.h @@ -61,3 +61,4 @@ enum VirtualKmod //! Special value for invalid key bindings const unsigned int KEY_INVALID = SDLK_LAST + 1000; + diff --git a/src/common/logger.cpp b/src/common/logger.cpp index 8bc4cef..a02854d 100644 --- a/src/common/logger.cpp +++ b/src/common/logger.cpp @@ -25,8 +25,8 @@ template<> CLogger* CSingleton<CLogger>::m_instance = nullptr; CLogger::CLogger() { - mFile = NULL; - mLogLevel = LOG_INFO; + m_file = NULL; + m_logLevel = LOG_INFO; } @@ -38,31 +38,31 @@ CLogger::~CLogger() void CLogger::Log(LogLevel type, const char* str, va_list args) { - if (type < mLogLevel) + if (type < m_logLevel) return; switch (type) { case LOG_TRACE: - fprintf(IsOpened() ? mFile : stderr, "[TRACE]: "); + fprintf(IsOpened() ? m_file : stderr, "[TRACE]: "); break; case LOG_DEBUG: - fprintf(IsOpened() ? mFile : stderr, "[DEBUG]: "); + fprintf(IsOpened() ? m_file : stderr, "[DEBUG]: "); break; case LOG_WARN: - fprintf(IsOpened() ? mFile : stderr, "[WARN]: "); + fprintf(IsOpened() ? m_file : stderr, "[WARN]: "); break; case LOG_INFO: - fprintf(IsOpened() ? mFile : stderr, "[INFO]: "); + fprintf(IsOpened() ? m_file : stderr, "[INFO]: "); break; case LOG_ERROR: - fprintf(IsOpened() ? mFile : stderr, "[ERROR]: "); + fprintf(IsOpened() ? m_file : stderr, "[ERROR]: "); break; default: break; } - vfprintf(IsOpened() ? mFile : stderr, str, args); + vfprintf(IsOpened() ? m_file : stderr, str, args); } @@ -122,36 +122,36 @@ void CLogger::Message(const char* str, ...) void CLogger::SetOutputFile(std::string filename) { - mFilename = filename; + m_filename = filename; Open(); } void CLogger::Open() { - mFile = fopen(mFilename.c_str(), "w"); + m_file = fopen(m_filename.c_str(), "w"); - if (mFile == NULL) - fprintf(stderr, "Could not create file %s\n", mFilename.c_str()); + if (m_file == NULL) + fprintf(stderr, "Could not create file %s\n", m_filename.c_str()); } void CLogger::Close() { if (IsOpened()) - fclose(mFile); + fclose(m_file); } bool CLogger::IsOpened() { - return mFile != NULL; + return m_file != NULL; } void CLogger::SetLogLevel(LogLevel type) { - mLogLevel = type; + m_logLevel = type; } diff --git a/src/common/logger.h b/src/common/logger.h index 769f548..1a5f3b9 100644 --- a/src/common/logger.h +++ b/src/common/logger.h @@ -113,9 +113,9 @@ public: static bool ParseLogLevel(const std::string& str, LogLevel& logLevel); private: - std::string mFilename; - FILE *mFile; - LogLevel mLogLevel; + std::string m_filename; + FILE *m_file; + LogLevel m_logLevel; void Open(); void Close(); @@ -125,6 +125,8 @@ private: //! Global function to get Logger instance -inline CLogger* GetLogger() { +inline CLogger* GetLogger() +{ return CLogger::GetInstancePointer(); } + diff --git a/src/common/misc.h b/src/common/misc.h index e2ddc44..bcebf76 100644 --- a/src/common/misc.h +++ b/src/common/misc.h @@ -31,3 +31,4 @@ extern void TimeToAscii(time_t time, char *buffer); extern bool CopyFileListToTemp(char* filename, int* list, int total); extern void AddExt(char* filename, const char* ext); + diff --git a/src/common/profile.cpp b/src/common/profile.cpp index 654648d..77c70c3 100644 --- a/src/common/profile.cpp +++ b/src/common/profile.cpp @@ -39,17 +39,7 @@ CProfile::CProfile() : CProfile::~CProfile() { - if (m_profileNeedSave) - { - try - { - bp::ini_parser::write_ini(GetSystemUtils()->profileFileLocation(), m_propertyTree); - } - catch (std::exception & e) - { - GetLogger()->Info("Error on storing profile: %s\n", e.what()); - } - } + SaveCurrentDirectory(); } @@ -57,17 +47,40 @@ bool CProfile::InitCurrentDirectory() { try { - bp::ini_parser::read_ini(GetSystemUtils()->profileFileLocation(), m_propertyTree); + #if DEV_BUILD + bp::ini_parser::read_ini("colobot.ini", m_propertyTree); + #else + bp::ini_parser::read_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree); + #endif } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + GetLogger()->Error("Error on parsing profile: %s\n", e.what()); return false; } return true; } - +bool CProfile::SaveCurrentDirectory() +{ + if (m_profileNeedSave) + { + try + { + #if DEV_BUILD + bp::ini_parser::write_ini("colobot.ini", m_propertyTree); + #else + bp::ini_parser::write_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree); + #endif + } + catch (std::exception & e) + { + GetLogger()->Error("Error on storing profile: %s\n", e.what()); + return false; + } + } + return true; +} bool CProfile::SetLocalProfileString(std::string section, std::string key, std::string value) { @@ -78,7 +91,7 @@ bool CProfile::SetLocalProfileString(std::string section, std::string key, std:: } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + GetLogger()->Error("Error on parsing profile: %s\n", e.what()); return false; } return true; @@ -93,7 +106,7 @@ bool CProfile::GetLocalProfileString(std::string section, std::string key, std:: } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + GetLogger()->Error("Error on parsing profile: %s\n", e.what()); return false; } return true; @@ -109,7 +122,7 @@ bool CProfile::SetLocalProfileInt(std::string section, std::string key, int valu } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + GetLogger()->Error("Error on parsing profile: %s\n", e.what()); return false; } return true; @@ -124,7 +137,7 @@ bool CProfile::GetLocalProfileInt(std::string section, std::string key, int &val } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + GetLogger()->Error("Error on parsing profile: %s\n", e.what()); return false; } return true; @@ -140,7 +153,7 @@ bool CProfile::SetLocalProfileFloat(std::string section, std::string key, float } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + GetLogger()->Error("Error on parsing profile: %s\n", e.what()); return false; } return true; @@ -155,7 +168,7 @@ bool CProfile::GetLocalProfileFloat(std::string section, std::string key, float } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + GetLogger()->Error("Error on parsing profile: %s\n", e.what()); return false; } return true; @@ -179,7 +192,7 @@ std::vector< std::string > CProfile::GetLocalProfileSection(std::string section, } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + GetLogger()->Error("Error on parsing profile: %s\n", e.what()); } return ret_list; @@ -196,34 +209,39 @@ std::string CProfile::GetUserBasedPath(std::string dir, std::string default_dir) { std::string path = dir; boost::replace_all(path, "\\", "/"); - if (dir.find("/") == std::string::npos) { + if (dir.find("/") == std::string::npos) + { path = default_dir + "/" + dir; } - - if (m_userDirectory.length() > 0) { + + if (m_userDirectory.length() > 0) + { boost::replace_all(path, "%user%", m_userDirectory); - } else { + } + else + { boost::replace_all(path, "%user%", default_dir); } - + return fs::path(path).make_preferred().string(); } - - + + bool CProfile::CopyFileToTemp(std::string filename) { std::string src, dst; std::string tmp_user_dir = m_userDirectory; - + src = GetUserBasedPath(filename, "textures"); SetUserDir("temp"); dst = GetUserBasedPath(filename, "textures"); SetUserDir(tmp_user_dir); - + fs::create_directory(fs::path(dst).parent_path().make_preferred().string()); fs::copy_file(src, dst, fs::copy_option::overwrite_if_exists); - if (fs::exists(dst)) { - return true; + if (fs::exists(dst)) + { + return true; } return false; diff --git a/src/common/profile.h b/src/common/profile.h index 7f99d81..f084ece 100644 --- a/src/common/profile.h +++ b/src/common/profile.h @@ -41,96 +41,103 @@ namespace fs = boost::filesystem; */ class CProfile : public CSingleton<CProfile> { - public: - CProfile(); - ~CProfile(); - - /** Loads colobot.ini from current directory - * \return return true on success - */ - bool InitCurrentDirectory(); - - /** Sets string value in section under specified key - * \param section - * \param key - * \param value - * \return return true on success - */ - bool SetLocalProfileString(std::string section, std::string key, std::string value); - - /** Gets string value in section under specified key - * \param section - * \param key - * \param buffer - * \return return true on success - */ - bool GetLocalProfileString(std::string section, std::string key, std::string& buffer); - - /** Sets int value in section under specified key - * \param section - * \param key - * \param value - * \return return true on success - */ - bool SetLocalProfileInt(std::string section, std::string key, int value); - - /** Gets int value in section under specified key - * \param section - * \param key - * \param value - * \return return true on success - */ - bool GetLocalProfileInt(std::string section, std::string key, int &value); - - /** Sets float value in section under specified key - * \param section - * \param key - * \param value - * \return return true on success - */ - bool SetLocalProfileFloat(std::string section, std::string key, float value); - - /** Gets float value in section under specified key - * \param section - * \param key - * \param value - * \return return true on success - */ - bool GetLocalProfileFloat(std::string section, std::string key, float &value); - - /** Gets all values in section under specified key - * \param section - * \param key - * \return vector of values - */ - std::vector< std::string > GetLocalProfileSection(std::string section, std::string key); - - /** Sets current user directory - * \param dir - */ - void SetUserDir(std::string dir); - - /** Returns path based on current user. Replaces %user% in path with current user dir or - * uses default_dir param if no user dir is specified - * \param dir - * \param default_dir - * \return path - */ - std::string GetUserBasedPath(std::string dir, std::string default_dir); - - /** opy a file into the temporary folder. - * \param filename - * \return true on success - */ - bool CopyFileToTemp(std::string filename); - - private: - boost::property_tree::ptree m_propertyTree; - bool m_profileNeedSave; - std::string m_userDirectory; +public: + CProfile(); + virtual ~CProfile(); + + /** Loads colobot.ini from current directory + * \return return true on success + */ + bool InitCurrentDirectory(); + + /** Saves colobot.ini to current directory + * \return return true on success + */ + bool SaveCurrentDirectory(); + + /** Sets string value in section under specified key + * \param section + * \param key + * \param value + * \return return true on success + */ + bool SetLocalProfileString(std::string section, std::string key, std::string value); + + /** Gets string value in section under specified key + * \param section + * \param key + * \param buffer + * \return return true on success + */ + bool GetLocalProfileString(std::string section, std::string key, std::string& buffer); + + /** Sets int value in section under specified key + * \param section + * \param key + * \param value + * \return return true on success + */ + bool SetLocalProfileInt(std::string section, std::string key, int value); + + /** Gets int value in section under specified key + * \param section + * \param key + * \param value + * \return return true on success + */ + bool GetLocalProfileInt(std::string section, std::string key, int &value); + + /** Sets float value in section under specified key + * \param section + * \param key + * \param value + * \return return true on success + */ + bool SetLocalProfileFloat(std::string section, std::string key, float value); + + /** Gets float value in section under specified key + * \param section + * \param key + * \param value + * \return return true on success + */ + bool GetLocalProfileFloat(std::string section, std::string key, float &value); + + /** Gets all values in section under specified key + * \param section + * \param key + * \return vector of values + */ + std::vector< std::string > GetLocalProfileSection(std::string section, std::string key); + + /** Sets current user directory + * \param dir + */ + void SetUserDir(std::string dir); + + /** Returns path based on current user. Replaces %user% in path with current user dir or + * uses default_dir param if no user dir is specified + * \param dir + * \param default_dir + * \return path + */ + std::string GetUserBasedPath(std::string dir, std::string default_dir); + + /** opy a file into the temporary folder. + * \param filename + * \return true on success + */ + bool CopyFileToTemp(std::string filename); + +private: + boost::property_tree::ptree m_propertyTree; + bool m_profileNeedSave; + std::string m_userDirectory; }; //! Global function to get profile instance -inline CProfile & GetProfile() { +inline CProfile & GetProfile() +{ return *CProfile::GetInstancePointer(); } + diff --git a/src/common/restext.cpp b/src/common/restext.cpp index 729a883..d61fa63 100644 --- a/src/common/restext.cpp +++ b/src/common/restext.cpp @@ -295,6 +295,7 @@ void InitializeRestext() stringsEvent[EVENT_OBJECT_MPOWER] = "..power cell"; stringsEvent[EVENT_OBJECT_BHELP] = "Instructions for the mission (\\key help;)"; stringsEvent[EVENT_OBJECT_BTAKEOFF] = "Take off to finish the mission"; + stringsEvent[EVENT_OBJECT_BDESTROY] = "Destroy"; stringsEvent[EVENT_OBJECT_BDERRICK] = "Build a derrick"; stringsEvent[EVENT_OBJECT_BSTATION] = "Build a power station"; stringsEvent[EVENT_OBJECT_BFACTORY] = "Build a bot factory"; @@ -539,6 +540,7 @@ void InitializeRestext() + stringsErr[ERR_GENERIC] = "Internal error - tell the developers"; stringsErr[ERR_CMD] = "Unknown command"; stringsErr[ERR_MANIP_VEH] = "Inappropriate bot"; stringsErr[ERR_MANIP_FLY] = "Impossible when flying"; @@ -563,6 +565,8 @@ void InitializeRestext() stringsErr[ERR_BUILD_NARROW] = "Too close to a building"; stringsErr[ERR_BUILD_MOTOR] = "Impossible when moving"; stringsErr[ERR_SEARCH_FLY] = "Impossible when flying"; + stringsErr[ERR_BUILD_DISABLED] = "Can not produce this object in this mission"; + stringsErr[ERR_BUILD_RESEARCH] = "Can not produce not researched object"; stringsErr[ERR_SEARCH_VEH] = "Inappropriate bot"; stringsErr[ERR_SEARCH_MOTOR] = "Impossible when moving"; stringsErr[ERR_TERRA_VEH] = "Inappropriate bot"; @@ -620,6 +624,8 @@ void InitializeRestext() stringsErr[ERR_FLAG_CREATE] = "Too many flags of this color (maximum 5)"; stringsErr[ERR_FLAG_PROXY] = "Too close to an existing flag"; stringsErr[ERR_FLAG_DELETE] = "No flag nearby"; + stringsErr[ERR_DESTROY_NOTFOUND]= "Not found anything to destroy"; + stringsErr[ERR_WRONG_OBJ] = "Inappropriate object"; stringsErr[ERR_MISSION_NOTERM] = "The mission is not accomplished yet (press \\key help; for more details)"; stringsErr[ERR_DELETEMOBILE] = "Bot destroyed"; stringsErr[ERR_DELETEBUILDING] = "Building destroyed"; @@ -729,9 +735,9 @@ void InitializeRestext() static char g_gamerName[100]; -void SetGlobalGamerName(char *name) +void SetGlobalGamerName(std::string name) { - strcpy(g_gamerName, name); + strcpy(g_gamerName, name.c_str()); } @@ -842,10 +848,8 @@ static const char* GetResourceBase(ResType type, int num) case RES_EVENT: if (num >= EVENT_STD_MAX) - { - GetLogger()->Trace("GetResource event num out of range: %d\n", num); // TODO: fix later - return ""; - } + return ""; // can be safely ignored (user events) + str = stringsEvent[num]; break; @@ -914,3 +918,4 @@ bool GetResource(ResType type, int num, char* text) PutKeyName(text, tmpl); return true; } + diff --git a/src/common/restext.h b/src/common/restext.h index 8199f9f..e4659e2 100644 --- a/src/common/restext.h +++ b/src/common/restext.h @@ -24,6 +24,8 @@ #include "common/global.h" +#include <string> + /** * \enum ResType @@ -153,6 +155,7 @@ enum ResTextType void InitializeRestext(); -void SetGlobalGamerName(char *name); +void SetGlobalGamerName(std::string name); bool SearchKey(const char *cmd, InputSlot& slot); bool GetResource(ResType type, int num, char* text); + diff --git a/src/common/singleton.h b/src/common/singleton.h index 25e1648..841759d 100644 --- a/src/common/singleton.h +++ b/src/common/singleton.h @@ -74,3 +74,4 @@ private: CSingleton& operator=(const CSingleton<T> &); CSingleton(const CSingleton<T> &); }; + diff --git a/src/common/stringutils.cpp b/src/common/stringutils.cpp index db486f0..953abba 100644 --- a/src/common/stringutils.cpp +++ b/src/common/stringutils.cpp @@ -142,3 +142,4 @@ size_t StrUtils::Utf8StringLength(const std::string &str) } return result; } + diff --git a/src/common/stringutils.h b/src/common/stringutils.h index 064351d..c60bfb0 100644 --- a/src/common/stringutils.h +++ b/src/common/stringutils.h @@ -78,3 +78,4 @@ int Utf8CharSizeAt(const std::string &str, unsigned int pos); size_t Utf8StringLength(const std::string &str); }; // namespace StrUtil + |