diff --git a/projects/mtg/include/WGui.h b/projects/mtg/include/WGui.h index 078307890..131707282 100644 --- a/projects/mtg/include/WGui.h +++ b/projects/mtg/include/WGui.h @@ -484,4 +484,10 @@ struct WLFiltersSort{ bool operator()(const WGuiBase*l, const WGuiBase*r); }; +class WGuiKeyBinder : public WGuiItem { + public: + WGuiKeyBinder(); + virtual void Render(); +}; + #endif diff --git a/projects/mtg/src/GameOptions.cpp b/projects/mtg/src/GameOptions.cpp index 7cd966c24..9b5cac473 100644 --- a/projects/mtg/src/GameOptions.cpp +++ b/projects/mtg/src/GameOptions.cpp @@ -903,11 +903,12 @@ bool GameOptionKeyBindings::read(string input){ } if (assoc.empty()) return false; + JGE* j = JGE::GetInstance(); j->ClearBindings(); for (vector< pair >::const_iterator it = assoc.begin(); it != assoc.end(); ++it) j->BindKey(it->first, it->second); - + return true; } diff --git a/projects/mtg/src/GameStateOptions.cpp b/projects/mtg/src/GameStateOptions.cpp index 7efc6bf50..04618de50 100644 --- a/projects/mtg/src/GameStateOptions.cpp +++ b/projects/mtg/src/GameStateOptions.cpp @@ -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"); diff --git a/projects/mtg/src/WGui.cpp b/projects/mtg/src/WGui.cpp index d342e3f7d..42e12f5d4 100644 --- a/projects/mtg/src/WGui.cpp +++ b/projects/mtg/src/WGui.cpp @@ -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; + } +}