This is an automated email from the git hooks/post-receive script. odyx pushed a commit to branch upstream/latest in repository colobot.
commit 601a58ea3123e666f696e3867c69c7c5d4aacb15 Author: krzys-h <krzy...@interia.pl> Date: Thu Dec 11 19:48:06 2014 +0100 Nicer formatting of key names --- src/common/restext.cpp | 68 ++++++++++++++++++++++++++------------------------ src/ui/key.cpp | 2 +- 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/src/common/restext.cpp b/src/common/restext.cpp index 8756c62..8e5c172 100644 --- a/src/common/restext.cpp +++ b/src/common/restext.cpp @@ -36,6 +36,7 @@ #include <libintl.h> #include <SDL_keyboard.h> +#include <boost/regex.hpp> const char* stringsText[RT_MAX] = { nullptr }; const char* stringsEvent[EVENT_STD_MAX] = { nullptr }; @@ -814,31 +815,6 @@ static const char* GetResourceBase(ResType type, int num) str = stringsCbot[num]; break; - case RES_KEY: - - if (static_cast<unsigned int>(num) == KEY_INVALID) - return ""; - else if (num == VIRTUAL_KMOD_CTRL) - return "Ctrl"; - else if (num == VIRTUAL_KMOD_SHIFT) - return "Shift"; - else if (num == VIRTUAL_KMOD_ALT) - return "Alt"; - else if (num == VIRTUAL_KMOD_META) - return "Win"; - else if (num > VIRTUAL_JOY(0)) - { - // TODO: temporary fix - static std::string sstr; - sstr = gettext("Button %1"); - sstr = StrUtils::Replace(sstr, "%1", StrUtils::ToString<int>(1 + num - VIRTUAL_JOY(0))); - return sstr.c_str(); - } - else - str = SDL_GetKeyName(static_cast<SDLKey>(num)); - - break; - default: assert(false); } @@ -850,15 +826,43 @@ static const char* GetResourceBase(ResType type, int num) bool GetResource(ResType type, int num, std::string& text) { - const char *tmpl = GetResourceBase(type, num); + if(type != RES_KEY) + { + const char *tmpl = GetResourceBase(type, num); + + if (!tmpl) + { + text.clear(); + return false; + } - if (!tmpl) + PutKeyName(text, tmpl); + return true; + } + else { - text.clear(); - return false; + if (static_cast<unsigned int>(num) == KEY_INVALID) + text.clear(); + else if (num == VIRTUAL_KMOD_CTRL) + text = "Ctrl"; + else if (num == VIRTUAL_KMOD_SHIFT) + text = "Shift"; + else if (num == VIRTUAL_KMOD_ALT) + text = "Alt"; + else if (num == VIRTUAL_KMOD_META) + text = "Win"; + else if (num > VIRTUAL_JOY(0)) + { + text = gettext("Button %1"); + text = StrUtils::Replace(text, "%1", StrUtils::ToString<int>(1 + num - VIRTUAL_JOY(0))); + } + else + { + text = SDL_GetKeyName(static_cast<SDLKey>(num)); + text = boost::regex_replace(text, boost::regex("\\[(.*)\\]"), "\\1"); + text[0] = toupper(text[0]); + } + return true; } - - PutKeyName(text, tmpl); - return true; } diff --git a/src/ui/key.cpp b/src/ui/key.cpp index 8b59bb1..9243825 100644 --- a/src/ui/key.cpp +++ b/src/ui/key.cpp @@ -101,7 +101,7 @@ bool CKey::EventProcess(const Event &event) bool CKey::TestKey(unsigned int key) { - if (key == KEY(PAUSE) || key == KEY(PRINT) || key == KEY(ESCAPE)) return true; // blocked key + if (key == KEY(PAUSE) || key == KEY(PRINT)) return true; // blocked key for (int i = 0; i < INPUT_SLOT_MAX; i++) { -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git _______________________________________________ Pkg-games-commits mailing list Pkg-games-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits