Skip to content

Commit

Permalink
some new features:
Browse files Browse the repository at this point in the history
- keyboard support & key remap (in develop)
- custom skin (in develop)

and fix some bugs
  • Loading branch information
ZeaS committed Jul 5, 2018
1 parent d395c50 commit 384e22f
Show file tree
Hide file tree
Showing 26 changed files with 1,027 additions and 390 deletions.
26 changes: 25 additions & 1 deletion src/core/environ/ConfigManager/GlobalConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ void iSysConfigManager::Initialize() {
CustomArguments.emplace_back(key, val);
}
}
for (tinyxml2::XMLElement *item = rootElement->FirstChildElement("KeyMap"); item; item = item->NextSiblingElement("KeyMap")) {
int key, val;
if (tinyxml2::XML_SUCCESS == item->QueryIntAttribute("key", &key) &&
tinyxml2::XML_SUCCESS == item->QueryIntAttribute("value", &val) &&
key && val) {
KeyMap.emplace(key, val);
}
}
}
}
if (fp) fclose(fp);
Expand All @@ -90,7 +98,14 @@ void iSysConfigManager::SaveToFile() {
item->SetAttribute("value", it->second.c_str());
rootElement->LinkEndChild(item);
}

for (auto &it : KeyMap) {
if (it.first && it.second) {
tinyxml2::XMLElement *item = doc.NewElement("KeyMap");
item->SetAttribute("key", it.first);
item->SetAttribute("value", it.second);
rootElement->LinkEndChild(item);
}
}
doc.LinkEndChild(rootElement);
XMLMemPrinter stream;
doc.Print(&stream);
Expand Down Expand Up @@ -162,6 +177,15 @@ void iSysConfigManager::SetValue(const std::string &name, const std::string & va
ConfigUpdated = true;
}

void iSysConfigManager::SetKeyMap(int k/* 0 means remove */, int v)
{
if (v == 0) {
KeyMap.erase(k);
} else {
KeyMap[k] = v;
}
}

std::vector<std::string> iSysConfigManager::GetCustomArgumentsForPush() {
std::vector<std::string> ret;
for (auto arg : CustomArguments) {
Expand Down
5 changes: 5 additions & 0 deletions src/core/environ/ConfigManager/GlobalConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
#include <unordered_map>
#include <string>
#include <vector>
#include <map>

class iSysConfigManager {
protected:
std::unordered_map<std::string, std::string> AllConfig;
std::vector<std::pair<std::string, std::string> > CustomArguments;
std::map<int, int> KeyMap;

bool ConfigUpdated;

Expand All @@ -31,6 +33,9 @@ class iSysConfigManager {
return CustomArguments;
}

const std::map<int, int>& GetKeyMap() { return KeyMap; }
void SetKeyMap(int k, int v/* 0 means remove */);

const std::vector<std::pair<std::string, std::string> > &GetCustomArguments() const { return CustomArguments; }

std::vector<std::string> GetCustomArgumentsForPush();
Expand Down
2 changes: 2 additions & 0 deletions src/core/environ/ConfigManager/LocaleConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ bool LocaleConfigManager::initText(cocos2d::ui::Text *ctrl, const std::string &t

std::string txt = GetText(tid);
if (txt.empty()) {
ctrl->setString(tid);
ctrl->setColor(cocos2d::Color3B::RED);
return false;
}
Expand All @@ -85,6 +86,7 @@ bool LocaleConfigManager::initText(cocos2d::ui::Button *ctrl, const std::string

std::string txt = GetText(tid);
if (txt.empty()) {
ctrl->setTitleText(tid);
ctrl->setTitleColor(cocos2d::Color3B::RED);
return false;
}
Expand Down
Loading

0 comments on commit 384e22f

Please sign in to comment.