From b63e9f9847ec413e16771a15f9600040b2f28292 Mon Sep 17 00:00:00 2001 From: "jean.chalard" Date: Fri, 19 Feb 2010 06:42:47 +0000 Subject: [PATCH] J : * Use images for PSP buttons. * Um not tested. I don't have my PSP on me --- projects/mtg/src/OptionItem.cpp | 4 +-- projects/mtg/src/TranslateKeys.cpp | 41 +++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/projects/mtg/src/OptionItem.cpp b/projects/mtg/src/OptionItem.cpp index fd837c623..c46532449 100644 --- a/projects/mtg/src/OptionItem.cpp +++ b/projects/mtg/src/OptionItem.cpp @@ -447,12 +447,12 @@ void OptionKey::Render() { { const KeyRep& rep = translateKey(from); if (rep.icon) - renderer->RenderQuad(rep.icon, x + 2, y + 2); + renderer->RenderQuad(rep.icon, x + 4, y + 2); else mFont->DrawString(rep.text, x + 4, y + 2, JGETEXT_LEFT); const KeyRep& rep2 = translateKey(to); if (rep2.icon) - renderer->RenderQuad(rep2.icon, x + 2, y + 2); + renderer->RenderQuad(rep2.icon, x + 4, y + 2); else mFont->DrawString(rep2.text, width - 4, y + 2, JGETEXT_RIGHT); } diff --git a/projects/mtg/src/TranslateKeys.cpp b/projects/mtg/src/TranslateKeys.cpp index c28189dd6..1ca97439e 100644 --- a/projects/mtg/src/TranslateKeys.cpp +++ b/projects/mtg/src/TranslateKeys.cpp @@ -18,7 +18,8 @@ const KeyRep& translateKey(LocalKeySym key) { if ((res = fattable.find(key)) != fattable.end()) return *(res->second); } - char* str = XKeysymToString(key); + + char* str = XKeysymToString(key); if (!str) { str = new char[11]; @@ -29,6 +30,7 @@ const KeyRep& translateKey(LocalKeySym key) { return *k; } #else +#ifdef WIN32 const KeyRep& translateKey(LocalKeySym key) { { map::iterator res; @@ -36,15 +38,46 @@ const KeyRep& translateKey(LocalKeySym key) { return *(res->second); } - // Here goes PSP button-to-image code : - // k->icon = resources.RetrieveQuad("iconspsp.png", (float)4*32, 0, 32, 32, "", RETRIEVE_NORMAL); - char* str = new char[11]; sprintf(str, "%d", key); KeyRep* k = new KeyRep(NULL, str); fattable[key] = k; return *k; } +#else // PSP + +const KeyRep& translateKey(LocalKeySym key) { + map::iterator res; + if ((res = fattable.find(key)) != fattable.end()) + return *(res->second); + + if (fattable.end() == fattable.find(PSP_CTRL_SELECT)) + { + fattable[PSP_CTRL_SELECT] = new KeyRep(resources.RetrieveQuad("iconspsp.png", (float)10*32, 0, 64, 32, "PSP_CTRL_SELECT", RETRIEVE_NORMAL), _("Select")); + fattable[PSP_CTRL_START] = new KeyRep(resources.RetrieveQuad("iconspsp.png", (float)8*32, 0, 64, 32, "PSP_CTRL_START", RETRIEVE_NORMAL), _("Start")); + fattable[PSP_CTRL_UP] = new KeyRep(resources.RetrieveQuad("iconspsp.png", (float)0*32, 0, 32, 32, "PSP_CTRL_UP", RETRIEVE_NORMAL), _("Up")); + fattable[PSP_CTRL_RIGHT] = new KeyRep(resources.RetrieveQuad("iconspsp.png", (float)3*32, 0, 32, 32, "PSP_CTRL_RIGHT", RETRIEVE_NORMAL), _("Right")); + fattable[PSP_CTRL_DOWN] = new KeyRep(resources.RetrieveQuad("iconspsp.png", (float)1*32, 0, 32, 32, "PSP_CTRL_DOWN", RETRIEVE_NORMAL), _("Down")); + fattable[PSP_CTRL_LEFT] = new KeyRep(resources.RetrieveQuad("iconspsp.png", (float)2*32, 0, 32, 32, "PSP_CTRL_LEFT", RETRIEVE_NORMAL), _("Left")); + fattable[PSP_CTRL_LTRIGGER] = new KeyRep(resources.RetrieveQuad("iconspsp.png", (float)14*32, 0, 64, 32, "PSP_CTRL_LTRIGGER", RETRIEVE_NORMAL), _("Left trigger")); + fattable[PSP_CTRL_RTRIGGER] = new KeyRep(resources.RetrieveQuad("iconspsp.png", (float)16*32, 0, 64, 32, "PSP_CTRL_RTRIGGER", RETRIEVE_NORMAL), _("Right trigger")); + fattable[PSP_CTRL_TRIANGLE] = new KeyRep(resources.RetrieveQuad("iconspsp.png", (float)5*32, 0, 32, 32, "PSP_CTRL_TRIANGLE", RETRIEVE_NORMAL), _("Triangle")); + fattable[PSP_CTRL_CIRCLE] = new KeyRep(resources.RetrieveQuad("iconspsp.png", (float)4*32, 0, 32, 32, "PSP_CTRL_CIRCLE", RETRIEVE_NORMAL), _("Circle")); + fattable[PSP_CTRL_CROSS] = new KeyRep(resources.RetrieveQuad("iconspsp.png", (float)7*32, 0, 32, 32, "PSP_CTRL_CROSS", RETRIEVE_NORMAL), _("Cross")); + fattable[PSP_CTRL_SQUARE] = new KeyRep(resources.RetrieveQuad("iconspsp.png", (float)6*32, 0, 32, 32, "PSP_CTRL_SQUARE", RETRIEVE_NORMAL), _("Square")); + fattable[PSP_CTRL_HOLD] = new KeyRep(resources.RetrieveQuad("iconspsp.png", (float)4*32, 0, 32, 32, "PSP_CTRL_HOLD", RETRIEVE_NORMAL), _("Hold")); + for (map::iterator it = fattable.begin(); it != fattable.end(); ++it) + if (it->second->icon) { it->second->icon->mWidth /= 2; it->second->icon->mHeight /= 2; } + } + if ((res = fattable.find(key)) != fattable.end()) + return *(res->second); + char* str = new char[11]; + sprintf(str, "%d", key); + KeyRep* k = new KeyRep(NULL, str); + fattable[key] = k; + return *k; +} +#endif #endif const KeyRep& translateKey(JButton key) {