* Some interface for key bindings
This commit is contained in:
jean.chalard
2010-02-15 14:32:56 +00:00
parent 16abaa249c
commit 16ca1a929f
4 changed files with 33 additions and 1 deletions

View File

@@ -484,4 +484,10 @@ struct WLFiltersSort{
bool operator()(const WGuiBase*l, const WGuiBase*r);
};
class WGuiKeyBinder : public WGuiItem {
public:
WGuiKeyBinder();
virtual void Render();
};
#endif

View File

@@ -903,11 +903,12 @@ bool GameOptionKeyBindings::read(string input){
}
if (assoc.empty()) return false;
JGE* j = JGE::GetInstance();
j->ClearBindings();
for (vector< pair<LocalKeySym, JButton> >::const_iterator it = assoc.begin(); it != assoc.end(); ++it)
j->BindKey(it->first, it->second);
return true;
}

View File

@@ -81,6 +81,7 @@ void GameStateOptions::Start()
optionsTabs->Add(optionsList);
optionsList = NEW WGuiList("Key Bindings");
optionsList->Add(NEW WGuiKeyBinder());
optionsTabs->Add(optionsList);
optionsList = NEW WGuiList("Credits");

View File

@@ -1731,3 +1731,27 @@ string WGuiFilterItem::getCode(){
return "";
return mCode;
}
WGuiKeyBinder::WGuiKeyBinder() : WGuiItem("KB", 0) {}
void WGuiKeyBinder::Render()
{
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;
}
}