J :
* The key bindings now display (semi-)correctly.
- Here, "semi-" means the local keys display as a string under X and
a number everywhere else. The number is all but helpful and will
have to be replaced before it is usable, but at the moment, the
code is stable afaik.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/CardPrimitive.o objs/CardSelector.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DeckDataWrapper.o objs/DeckMetaData.o objs/DeckStats.o objs/DuelLayers.o objs/Effects.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameState.o objs/GameStateAwards.o objs/GameStateDeckViewer.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GameStateTransitions.o objs/GuiAvatars.o objs/GuiBackground.o objs/GuiCardsController.o objs/GuiCombat.o objs/GuiFrame.o objs/GuiHand.o objs/GuiLayers.o objs/GuiMana.o objs/GuiPhaseBar.o objs/GuiPlay.o objs/GuiStatic.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGPack.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/Pos.o objs/PriceList.o objs/ReplacementEffects.o objs/Rules.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/SimplePad.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/Token.o objs/Translate.o objs/Trash.o objs/utils.o objs/WEvent.o objs/WResourceManager.o objs/WCachedResource.o objs/WDataSrc.o objs/WGui.o objs/WFilter.o objs/Tasks.o
|
||||
OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/CardPrimitive.o objs/CardSelector.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DeckDataWrapper.o objs/DeckMetaData.o objs/DeckStats.o objs/DuelLayers.o objs/Effects.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameState.o objs/GameStateAwards.o objs/GameStateDeckViewer.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GameStateTransitions.o objs/GuiAvatars.o objs/GuiBackground.o objs/GuiCardsController.o objs/GuiCombat.o objs/GuiFrame.o objs/GuiHand.o objs/GuiLayers.o objs/GuiMana.o objs/GuiPhaseBar.o objs/GuiPlay.o objs/GuiStatic.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGPack.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/Pos.o objs/PriceList.o objs/ReplacementEffects.o objs/Rules.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/SimplePad.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/Token.o objs/Translate.o objs/TranslateKeys.o objs/Trash.o objs/utils.o objs/WEvent.o objs/WResourceManager.o objs/WCachedResource.o objs/WDataSrc.o objs/WGui.o objs/WFilter.o objs/Tasks.o
|
||||
DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS))
|
||||
|
||||
RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache)
|
||||
|
||||
@@ -131,4 +131,12 @@ private:
|
||||
string preview;
|
||||
size_t initialValue;
|
||||
};
|
||||
|
||||
class OptionKey : public WGuiItem {
|
||||
public:
|
||||
OptionKey(LocalKeySym, JButton);
|
||||
LocalKeySym from;
|
||||
JButton to;
|
||||
virtual void Render();
|
||||
};
|
||||
#endif
|
||||
|
||||
18
projects/mtg/include/TranslateKeys.h
Normal file
18
projects/mtg/include/TranslateKeys.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef _TRANSLATEKEYS_H_
|
||||
#define _TRANSLATEKEYS_H_
|
||||
|
||||
#include <string>
|
||||
#include "JGE.h"
|
||||
|
||||
struct KeyRep
|
||||
{
|
||||
KeyRep(JQuad*, std::string);
|
||||
JQuad* icon;
|
||||
std::string text;
|
||||
};
|
||||
|
||||
|
||||
const KeyRep& translateKey(LocalKeySym);
|
||||
const KeyRep& translateKey(JButton);
|
||||
|
||||
#endif
|
||||
@@ -484,10 +484,9 @@ struct WLFiltersSort{
|
||||
bool operator()(const WGuiBase*l, const WGuiBase*r);
|
||||
};
|
||||
|
||||
class WGuiKeyBinder : public WGuiItem {
|
||||
class WGuiKeyBinder : public WGuiList {
|
||||
public:
|
||||
WGuiKeyBinder();
|
||||
virtual void Render();
|
||||
WGuiKeyBinder(string name);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -80,8 +80,7 @@ void GameStateOptions::Start()
|
||||
optionsList->Add(oGra);
|
||||
optionsTabs->Add(optionsList);
|
||||
|
||||
optionsList = NEW WGuiList("Key Bindings");
|
||||
optionsList->Add(NEW WGuiKeyBinder());
|
||||
optionsList = NEW WGuiKeyBinder("Key Bindings");
|
||||
optionsTabs->Add(optionsList);
|
||||
|
||||
optionsList = NEW WGuiList("Credits");
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "../include/PlayerData.h"
|
||||
#include "../include/Translate.h"
|
||||
#include "../include/Subtypes.h"
|
||||
#include "../include/TranslateKeys.h"
|
||||
#include <dirent.h>
|
||||
#include <stdlib.h>
|
||||
#include <algorithm>
|
||||
@@ -428,3 +429,18 @@ void OptionTheme::confirmChange(bool confirmed){
|
||||
prior_value = value;
|
||||
}
|
||||
}
|
||||
|
||||
OptionKey::OptionKey(LocalKeySym from, JButton to) : WGuiItem(""), from(from), to(to){}
|
||||
|
||||
void OptionKey::Render(){
|
||||
JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT);
|
||||
mFont->SetColor(getColor(WGuiColor::TEXT));
|
||||
JRenderer * renderer = JRenderer::GetInstance();
|
||||
|
||||
const KeyRep& rep = translateKey(from);
|
||||
if (NULL == rep.icon)
|
||||
mFont->DrawString(rep.text, x + 4, y + 2, JGETEXT_LEFT);
|
||||
const KeyRep& rep2 = translateKey(to);
|
||||
if (NULL == rep2.icon)
|
||||
mFont->DrawString(rep2.text, width - 4, y + 2, JGETEXT_RIGHT);
|
||||
}
|
||||
|
||||
70
projects/mtg/src/TranslateKeys.cpp
Normal file
70
projects/mtg/src/TranslateKeys.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
#include <map>
|
||||
#include "../include/Translate.h"
|
||||
#include "../include/TranslateKeys.h"
|
||||
|
||||
using std::string;
|
||||
using std::map;
|
||||
|
||||
static map<const LocalKeySym, KeyRep const*> fattable;
|
||||
static map<const JButton, KeyRep const*> slimtable;
|
||||
|
||||
KeyRep::KeyRep(JQuad* icon, string text) : icon(icon), text(text) {}
|
||||
|
||||
#ifdef LINUX
|
||||
const KeyRep& translateKey(LocalKeySym key) {
|
||||
{
|
||||
map<const LocalKeySym, KeyRep const*>::iterator res;
|
||||
if ((res = fattable.find(key)) != fattable.end())
|
||||
return *(res->second);
|
||||
}
|
||||
char* str = XKeysymToString(key);
|
||||
if (!str)
|
||||
{
|
||||
str = new char[11];
|
||||
sprintf(str, "%lu", key);
|
||||
}
|
||||
KeyRep* k = new KeyRep(NULL, str);
|
||||
fattable[key] = k;
|
||||
return *k;
|
||||
}
|
||||
#else
|
||||
const KeyRep& translateKey(LocalKeySym key) {
|
||||
{
|
||||
map<const LocalKeySym, KeyRep const*>::iterator res;
|
||||
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
|
||||
|
||||
const KeyRep& translateKey(JButton key) {
|
||||
{
|
||||
map<const JButton, KeyRep const*>::iterator res;
|
||||
if ((res = slimtable.find(key)) != slimtable.end())
|
||||
return *(res->second);
|
||||
}
|
||||
|
||||
slimtable[JGE_BTN_NONE] = new KeyRep(NULL, _("None"));
|
||||
slimtable[JGE_BTN_QUIT] = new KeyRep(NULL, _("Quit"));
|
||||
slimtable[JGE_BTN_MENU] = new KeyRep(NULL, _("Menu"));
|
||||
slimtable[JGE_BTN_CTRL] = new KeyRep(NULL, _("Control"));
|
||||
slimtable[JGE_BTN_POWER] = new KeyRep(NULL, _("Power"));
|
||||
slimtable[JGE_BTN_SOUND] = new KeyRep(NULL, _("Sound"));
|
||||
slimtable[JGE_BTN_RIGHT] = new KeyRep(NULL, _("Right"));
|
||||
slimtable[JGE_BTN_LEFT] = new KeyRep(NULL, _("Left"));
|
||||
slimtable[JGE_BTN_UP] = new KeyRep(NULL, _("Up"));
|
||||
slimtable[JGE_BTN_DOWN] = new KeyRep(NULL, _("Down"));
|
||||
slimtable[JGE_BTN_OK] = new KeyRep(NULL, _("Ok"));
|
||||
slimtable[JGE_BTN_CANCEL] = new KeyRep(NULL, _("Cancel"));
|
||||
slimtable[JGE_BTN_PRI] = new KeyRep(NULL, _("Primary"));
|
||||
slimtable[JGE_BTN_SEC] = new KeyRep(NULL, _("Secondary"));
|
||||
slimtable[JGE_BTN_PREV] = new KeyRep(NULL, _("Previous"));
|
||||
slimtable[JGE_BTN_NEXT] = new KeyRep(NULL, _("Next"));
|
||||
|
||||
return *slimtable[key];
|
||||
}
|
||||
@@ -1732,26 +1732,14 @@ string WGuiFilterItem::getCode(){
|
||||
return mCode;
|
||||
}
|
||||
|
||||
WGuiKeyBinder::WGuiKeyBinder() : WGuiItem("KB", 0) {}
|
||||
void WGuiKeyBinder::Render()
|
||||
WGuiKeyBinder::WGuiKeyBinder(string name) : WGuiList(name)
|
||||
{
|
||||
JRenderer* renderer = JRenderer::GetInstance();
|
||||
JGE* j = JGE::GetInstance();
|
||||
JGE::keybindings_it start = j->KeyBindings_begin(), end = j->KeyBindings_end();
|
||||
JLBFont * font = resources.GetJLBFont(Constants::OPTION_FONT);
|
||||
font->SetColor(getColor(WGuiColor::TEXT_BODY));
|
||||
|
||||
u32 y = 40;
|
||||
for (JGE::keybindings_it it = start; it != end; ++it)
|
||||
{
|
||||
// renderer->FillRoundRect(2, y, SCREEN_WIDTH - 4, 23, 2, getColor(WGuiColor::BACK));
|
||||
char tmp[11];
|
||||
sprintf(tmp, "%lu", it->first);
|
||||
font->DrawString(tmp, 4, y+2, JGETEXT_LEFT);
|
||||
sprintf(tmp, "%i", it->second);
|
||||
font->DrawString(tmp, SCREEN_WIDTH - 4, y+2, JGETEXT_RIGHT);
|
||||
|
||||
y += 25;
|
||||
// cout << it->first << " > " << it->second << endl;
|
||||
Add(NEW OptionKey(it->first, it->second));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user