* Use images for PSP buttons.
* Um not tested. I don't have my PSP on me
This commit is contained in:
jean.chalard
2010-02-19 06:42:47 +00:00
parent 72e395d1e1
commit b63e9f9847
2 changed files with 39 additions and 6 deletions

View File

@@ -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);
}

View File

@@ -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<const LocalKeySym, KeyRep const*>::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<const LocalKeySym, KeyRep const*>::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<const LocalKeySym, KeyRep const*>::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) {