From efe4f0baddf10124581e4fcb88d55a52838b06a1 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 9 Sep 2012 17:51:10 +0200 Subject: Refactoring in src/common - refactored CInstanceManager and some headers - removed old headers --- src/common/restext.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'src/common/restext.cpp') diff --git a/src/common/restext.cpp b/src/common/restext.cpp index 487d1a6..e66c70e 100644 --- a/src/common/restext.cpp +++ b/src/common/restext.cpp @@ -14,29 +14,19 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/.// restext.cpp -#include -#include -#include "common/struct.h" -#include "common/language.h" -#include "common/misc.h" +#include "common/restext.h" + +#include "common/global.h" #include "common/event.h" -#include "object/object.h" #include "CBot/resource.h" -#include "common/restext.h" +#include "object/object.h" +#include +#include -// Gives the pointer to the engine. -static CD3DEngine* g_engine; static char g_gamerName[100]; -void SetEngine(CD3DEngine *engine) -{ - g_engine = engine; -} - -// Give the player's name. - void SetGlobalGamerName(char *name) { strcpy(g_gamerName, name); -- cgit v1.2.3-1-g7c22 From 6a0d150539897ec65ccc161305db48de10ea35ba Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 16 Sep 2012 10:38:08 +0200 Subject: Interface works - removed mock of CInterface and fixed event passing to CRobotMain - changed texture names from tga and bmp to png - UI now works but interaction is still broken --- src/common/restext.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/common/restext.cpp') diff --git a/src/common/restext.cpp b/src/common/restext.cpp index e66c70e..5a8e6ba 100644 --- a/src/common/restext.cpp +++ b/src/common/restext.cpp @@ -18,6 +18,7 @@ #include "common/global.h" #include "common/event.h" +#include "common/logger.h" #include "CBot/resource.h" #include "object/object.h" @@ -140,7 +141,12 @@ static const char* GetResourceBase(ResType type, int num) str = strings_text[num]; break; case RES_EVENT: - assert(num < strings_event_len); + // assert(num < strings_event_len); + if (num >= strings_event_len) + { + GetLogger()->Error("GetResource invalid event num: %d\n", num); + return ""; + } str = strings_event[num]; break; case RES_OBJECT: -- cgit v1.2.3-1-g7c22 From 51884cef8e015bccbe1fa96dc56dc2f32439ccc5 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Wed, 19 Sep 2012 18:32:18 +0200 Subject: Input bindings rewrite - moved input bindings to CRobotMain - added virtual keymod and joystick button key presses - fixed putenv error; other minor fixes --- src/common/restext.cpp | 61 +++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 30 deletions(-) (limited to 'src/common/restext.cpp') diff --git a/src/common/restext.cpp b/src/common/restext.cpp index 5a8e6ba..40d11b7 100644 --- a/src/common/restext.cpp +++ b/src/common/restext.cpp @@ -21,6 +21,7 @@ #include "common/logger.h" #include "CBot/resource.h" #include "object/object.h" +#include "object/robotmain.h" #include #include @@ -37,39 +38,38 @@ void SetGlobalGamerName(char *name) struct KeyDesc { - KeyRank key; + InputSlot key; char name[20]; }; static KeyDesc keyTable[22] = { - { KEYRANK_LEFT, "left;" }, - { KEYRANK_RIGHT, "right;" }, - { KEYRANK_UP, "up;" }, - { KEYRANK_DOWN, "down;" }, - { KEYRANK_GUP, "gup;" }, - { KEYRANK_GDOWN, "gdown;" }, - { KEYRANK_CAMERA, "camera;" }, - { KEYRANK_DESEL, "desel;" }, - { KEYRANK_ACTION, "action;" }, - { KEYRANK_NEAR, "near;" }, - { KEYRANK_AWAY, "away;" }, - { KEYRANK_NEXT, "next;" }, - { KEYRANK_HUMAN, "human;" }, - { KEYRANK_QUIT, "quit;" }, - { KEYRANK_HELP, "help;" }, - { KEYRANK_PROG, "prog;" }, - { KEYRANK_CBOT, "cbot;" }, - { KEYRANK_VISIT, "visit;" }, - { KEYRANK_SPEED10, "speed10;" }, - { KEYRANK_SPEED15, "speed15;" }, - { KEYRANK_SPEED20, "speed20;" }, - { KEYRANK_SPEED30, "speed30;" }, + { INPUT_SLOT_LEFT, "left;" }, + { INPUT_SLOT_RIGHT, "right;" }, + { INPUT_SLOT_UP, "up;" }, + { INPUT_SLOT_DOWN, "down;" }, + { INPUT_SLOT_GUP, "gup;" }, + { INPUT_SLOT_GDOWN, "gdown;" }, + { INPUT_SLOT_CAMERA, "camera;" }, + { INPUT_SLOT_DESEL, "desel;" }, + { INPUT_SLOT_ACTION, "action;" }, + { INPUT_SLOT_NEAR, "near;" }, + { INPUT_SLOT_AWAY, "away;" }, + { INPUT_SLOT_NEXT, "next;" }, + { INPUT_SLOT_HUMAN, "human;" }, + { INPUT_SLOT_QUIT, "quit;" }, + { INPUT_SLOT_HELP, "help;" }, + { INPUT_SLOT_PROG, "prog;" }, + { INPUT_SLOT_CBOT, "cbot;" }, + { INPUT_SLOT_VISIT, "visit;" }, + { INPUT_SLOT_SPEED10, "speed10;" }, + { INPUT_SLOT_SPEED15, "speed15;" }, + { INPUT_SLOT_SPEED20, "speed20;" } }; // Seeks a key. -bool SearchKey(const char *cmd, KeyRank &key) +bool SearchKey(const char *cmd, InputSlot &key) { int i; @@ -88,9 +88,10 @@ bool SearchKey(const char *cmd, KeyRank &key) static void PutKeyName(char* dst, const char* src) { - KeyRank key; + InputSlot key; char name[50]; - int s, d, n, res; + int s, d, n; + unsigned int res; s = d = 0; while ( src[s] != 0 ) @@ -103,9 +104,8 @@ static void PutKeyName(char* dst, const char* src) { if ( SearchKey(src+s+5, key) ) { - // FIXME: res = g_engine->RetKey(key, 0); - res = 0; - if ( res != 0 ) + res = CRobotMain::GetInstancePointer()->GetInputBinding(key).key; + if (res != KEY_INVALID) { if ( GetResource(RES_KEY, res, name) ) { @@ -144,7 +144,7 @@ static const char* GetResourceBase(ResType type, int num) // assert(num < strings_event_len); if (num >= strings_event_len) { - GetLogger()->Error("GetResource invalid event num: %d\n", num); + GetLogger()->Warn("GetResource invalid event num: %d\n", num); return ""; } str = strings_event[num]; @@ -165,6 +165,7 @@ static const char* GetResourceBase(ResType type, int num) break; case RES_KEY: assert(num < SDLK_LAST); + // TODO: virtual keys str = SDL_GetKeyName(static_cast(num)); break; default: -- cgit v1.2.3-1-g7c22