static void interpret_text_settings(const ds::cfg::Settings &s, std::unordered_map<std::string, ds::cfg::Text>& out) { // Do the name first, because that determines whether an entry exists. s.forEachTextKey([&s, &out](const std::string& key) { std::string left, right; if (split_key(key, left, right) && right == "name") { std::string v = s.getText(key, 0, ds::EMPTY_SZ); if (!v.empty()) { if (out.empty()) { out[left] = ds::cfg::Text(v, left, 10.0f, 1.0f, ci::ColorA(1.0f, 1.0f, 1.0f, 1.0f)); } else { auto found = out.find(left); if (found != out.end()) { found->second.mFont = v; } else { out[left] = ds::cfg::Text(v, left, 10.0f, 1.0f, ci::ColorA(1.0f, 1.0f, 1.0f, 1.0f)); } } } } }); // Floats (size, leading) s.forEachFloatKey([&s, &out](const std::string& key) { std::string left, right; if (split_key(key, left, right) && !out.empty()) { auto found = out.find(left); if (found != out.end()) { if (right == "size") found->second.mSize = s.getFloat(key, 0, found->second.mSize); else if (right == "leading") found->second.mLeading = s.getFloat(key, 0, found->second.mLeading); } } }); // Color (color) s.forEachColorAKey([&s, &out](const std::string& key) { std::string left, right; if (split_key(key, left, right) && !out.empty()) { auto found = out.find(left); if (found != out.end()) { if (right == "color") found->second.mColor = s.getColorA(key, 0, found->second.mColor); } } }); // Text (alignment) s.forEachTextKey([&s, &out](const std::string& key) { std::string left, right; if (split_key(key, left, right) && !out.empty()) { auto found = out.find(left); if (found != out.end()) { if (right == "alignment") { found->second.mAlignment = ds::ui::Alignment::fromString(s.getText(key, 0, "")); } } } }); }
DrawTouchView::DrawTouchView(ds::ui::SpriteEngine& e, const ds::cfg::Settings &settings, ds::ui::TouchManager& tm) : ds::ui::Sprite(e) , mTouchTrailsUse(false) , mTouchTrailsLength(5) , mTouchTrailsIncrement(5.0f) { mTouchTrailsUse = settings.getBool("touch_overlay:trails:use", 0, mTouchTrailsUse); mTouchTrailsLength = settings.getInt("touch_overlay:trails:length", 0, mTouchTrailsLength); mTouchTrailsIncrement = settings.getFloat("touch_overlay:trails:increment", 0, mTouchTrailsIncrement); if(mTouchTrailsUse){ setTransparent(false); setColor(settings.getColor("touch_color", 0, ci::Color(1.0f, 1.0f, 1.0f))); } tm.setCapture(this); }