// alias for readability, both turn right | left inline bool areSameSide(const RouteStep &lhs, const RouteStep &rhs) { const auto is_left = [](const RouteStep &step) { return hasModifier(step, DirectionModifier::Straight) || hasLeftModifier(step.maneuver.instruction); }; const auto is_right = [](const RouteStep &step) { return hasModifier(step, DirectionModifier::Straight) || hasRightModifier(step.maneuver.instruction); }; return (is_left(lhs) && is_left(rhs)) || (is_right(lhs) && is_right(rhs)); }
double EU3Country::getBadboyLimit() const { double badboyLimit = 30.0; // gov effects if (government == "despotic_monarchy" || government == "tribal_despotism") badboyLimit += 10.0; // modifier effects if (hasModifier("the_licensing_of_the_press_act")) badboyLimit -= 3.0; if (hasModifier("the_witchcraft_act")) badboyLimit -= 2.0; if (hasModifier("the_education_act")) badboyLimit -= 2.0; if (hasModifier("revocation_of_restraint_of_appeals")) badboyLimit -= 2.0; if (hasModifier("colonial_expansions")) badboyLimit -= 3.0; if (hasModifier("hire_privateers")) badboyLimit -= 3.0; if (hasModifier("the_anti_piracy_act")) badboyLimit -= 3.0; // ruler effects (DIP, tribal MIL) not taken into account - assume the best (DIP 8/MIL 8) badboyLimit += 8.0; // legitimacy effect (-5 at 0, +5 at 100) badboyLimit += 10 * (legitimacy - 0.5); return badboyLimit; }
wxString KeyboardShortcut::shortcutMenuItemString(const wxString& name) const { if (!hasKey()) return name; wxString result; result << name << "\t"; if (hasModifier()) result << modifierMenuString() << "+"; result << keyMenuString(); return result; }
vector<string> ViewObject::getLegend() const { vector<string> ret { description }; if (getAttribute(Attribute::LEVEL) > -1) ret[0] = ret[0] + ", level " + getAttributeString(Attribute::LEVEL); if (getAttribute(Attribute::EFFICIENCY) > -1) ret[0] = ret[0] + ", efficiency " + getAttributeString(Attribute::EFFICIENCY); if (getAttribute(Attribute::ATTACK) > -1) ret.push_back("Attack " + getAttributeString(Attribute::ATTACK) + " defense " + getAttributeString(Attribute::DEFENSE)); if (hasModifier(Modifier::PLANNED)) ret.push_back("Planned"); if (hasModifier(Modifier::SLEEPING)) ret.push_back("Sleeping"); if (position.x > -1) ret.push_back(toString(position.x) + ", " + toString(position.y)); #ifndef RELEASE ret.push_back("Morale " + getAttributeString(Attribute::MORALE)); #endif append(ret, adjectives); return ret; }
bool KeyboardShortcut::alwaysShowModifier() const { switch (m_key) { case WXK_BACK: case WXK_TAB: case WXK_RETURN: case WXK_ESCAPE: case WXK_SPACE: case WXK_DELETE: case WXK_END: case WXK_HOME: case WXK_LEFT: case WXK_UP: case WXK_RIGHT: case WXK_DOWN: case WXK_INSERT: case WXK_PAGEUP: case WXK_PAGEDOWN: return false; case WXK_F1: case WXK_F2: case WXK_F3: case WXK_F4: case WXK_F5: case WXK_F6: case WXK_F7: case WXK_F8: case WXK_F9: case WXK_F10: case WXK_F11: case WXK_F12: case WXK_F13: case WXK_F14: case WXK_F15: case WXK_F16: case WXK_F17: case WXK_F18: case WXK_F19: case WXK_F20: case WXK_F21: case WXK_F22: case WXK_F23: case WXK_F24: return true; default: if (!hasModifier()) return false; if (m_modifier1 == WXK_SHIFT && m_modifier2 == WXK_NONE) return false; return true; } }
wxString KeyboardShortcut::asJsonString() const { wxString str; str << "{ key:" << key() << ", modifiers: ["; bool hadModifier = false; for (size_t i = 0; i < 3; ++i) { if (hasModifier(i)) { if (hadModifier) str << ", "; str << modifier(i); hadModifier = true; } else { hadModifier = false; } } str << "] }"; return str; }
bool UserInputMapper::addInputChannel(Action action, const Input& input, const Input& modifier, float scale) { // Check that the device is registered if (!getDeviceProxy(input)) { qDebug() << "UserInputMapper::addInputChannel: The input comes from a device #" << input.getDevice() << "is unknown. no inputChannel mapped."; return false; } auto inputChannel = InputChannel(input, modifier, action, scale); // Insert or replace the input to modifiers if (inputChannel.hasModifier()) { auto& modifiers = _inputToModifiersMap[input.getID()]; modifiers.push_back(inputChannel._modifier); std::sort(modifiers.begin(), modifiers.end()); } // Now update the action To Inputs side of things _actionToInputsMap.insert(ActionToInputsMap::value_type(action, inputChannel)); return true; }
void disposition::addModifier(const string& modifier) { if (!hasModifier(modifier)) m_modifiers.push_back(utility::stringUtils::toLower(modifier)); }