bool cheat_entry::select_next_state() { bool changed = false; // if we're a oneshot, there is no next state if (is_oneshot()) ; // if we're on/off, toggle to running state else if (is_onoff()) changed = set_state(SCRIPT_STATE_RUN); // if we have a parameter, set the next state else if (m_parameter != NULL) { // if we're off, switch on to the minimum state if (m_state == SCRIPT_STATE_OFF) { changed = set_state(SCRIPT_STATE_RUN); m_parameter->set_minimum_state(); } // otherwise, switch to the next state else changed = m_parameter->set_next_state(); // if we changed, signal a state change if (changed && !is_oneshot_parameter()) execute_change_script(); } return changed; }
bool cheat_entry::select_previous_state() { bool changed = false; // if we're a oneshot, there is no previous state if (is_oneshot()) ; // if we're on/off, toggle to off else if (is_onoff()) changed = set_state(SCRIPT_STATE_OFF); // if we have a parameter, set the previous state else if (m_parameter != NULL) { // if we're at our minimum, turn off if (m_parameter->is_minimum()) changed = set_state(SCRIPT_STATE_OFF); else { // if we changed, ensure we are in the running state and signal state change changed = m_parameter->set_prev_state(); if (changed) { set_state(SCRIPT_STATE_RUN); if (!is_oneshot_parameter()) execute_change_script(); } } } return changed; }
void cheat_entry::menu_text(astring &description, astring &state, UINT32 &flags) { // description is standard description.cpy(m_description); state.reset(); flags = 0; // some cheat entries are just text for display if (is_text_only()) { if (description) { description.trimspace(); if (!description) description.cpy(MENU_SEPARATOR_ITEM); } flags = MENU_FLAG_DISABLE; } // if we have no parameter and no run or off script, it's a oneshot cheat else if (is_oneshot()) state.cpy("Set"); // if we have no parameter, it's just on/off else if (is_onoff()) { state.cpy((m_state == SCRIPT_STATE_RUN) ? "On" : "Off"); flags = (m_state != 0) ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW; } // if we have a value parameter, compute it else if (m_parameter != NULL) { if (m_state == SCRIPT_STATE_OFF) { state.cpy(is_oneshot_parameter() ? "Set" : "Off"); flags = MENU_FLAG_RIGHT_ARROW; } else { state.cpy(m_parameter->text()); flags = MENU_FLAG_LEFT_ARROW; if (!m_parameter->is_maximum()) flags |= MENU_FLAG_RIGHT_ARROW; } } }
void cheat_entry::menu_text(std::string &description, std::string &state, uint32_t &flags) { // description is standard description.assign(m_description); state.clear(); flags = 0; // some cheat entries are just text for display if (is_text_only()) { if (!description.empty()) { strtrimspace(description); if (description.empty()) description.assign(MENU_SEPARATOR_ITEM); } flags = ui::menu::FLAG_DISABLE; } // if we have no parameter and no run or off script, it's a oneshot cheat else if (is_oneshot()) state.assign("Set"); // if we have no parameter, it's just on/off else if (is_onoff()) { state.assign((m_state == SCRIPT_STATE_RUN) ? "On" : "Off"); flags = (m_state != 0) ? ui::menu::FLAG_LEFT_ARROW : ui::menu::FLAG_RIGHT_ARROW; } // if we have a value parameter, compute it else if (m_parameter != nullptr) { if (m_state == SCRIPT_STATE_OFF) { state.assign(is_oneshot_parameter() ? "Set" : "Off"); flags = ui::menu::FLAG_RIGHT_ARROW; } else { state.assign(m_parameter->text()); flags = ui::menu::FLAG_LEFT_ARROW; if (!m_parameter->is_maximum()) flags |= ui::menu::FLAG_RIGHT_ARROW; } } }
static void check_arguments(int line, char *args[], int count, mipv6_conf_item_t *item) { int i; for (i = 0; i < count; i++) { switch (item->params[i]) { case MIPV6_PARAM_T_INT: check_argument(is_int(args[i + 1]), "integer", args[0], i, line); break; case MIPV6_PARAM_T_BOOLEAN: check_argument(is_boolean(args[i + 1]), "boolean", args[0], i, line); break; case MIPV6_PARAM_T_ONOFF: check_argument(is_onoff(args[i + 1]), "on/off", args[0], i, line); break; case MIPV6_PARAM_T_IDENTIFIER: check_argument(is_identifier(args[i + 1]), "identifier", args[0], i, line); break; case MIPV6_PARAM_T_ADDRESS: check_argument(is_address(args[i + 1]), "address", args[0], i, line); break; case MIPV6_PARAM_T_PREFIX: check_argument(is_prefix(args[i + 1]), "prefix", args[0], i, line); break; case MIPV6_PARAM_T_DOMAIN: check_argument(is_domain(args[i + 1], 0), "domain name" " or address", args[0], i, line); break; case MIPV6_PARAM_T_NAI: check_argument(is_nai(args[i + 1]), "NAI", args[0], i, line); break; default: break; } } }