void save_auto_pickup(bool bCharacter) { std::ofstream fout; std::string sFile = "data/auto_pickup.txt"; if (bCharacter) { sFile = "save/" + base64_encode(g->u.name) + ".apu.txt"; std::ifstream fin; fin.open(("save/" + base64_encode(g->u.name) + ".sav").c_str()); if(!fin.is_open()) { return; } fin.close(); } fout.open(sFile.c_str()); if(!fout.is_open()) { return; } fout << auto_pickup_header(bCharacter) << std::endl; for(int i = 0; i < vAutoPickupRules[(bCharacter) ? 2 : 1].size(); i++) { fout << vAutoPickupRules[(bCharacter) ? 2 : 1][i].sRule << ";"; fout << (vAutoPickupRules[(bCharacter) ? 2 : 1][i].bActive ? "T" : "F") << ";"; fout << (vAutoPickupRules[(bCharacter) ? 2 : 1][i].bExclude ? "T" : "F"); fout << "\n"; } if (!bCharacter) { merge_vector(); createPickupRules(); } }
void auto_pickup::load(const bool bCharacter) { bChar = bCharacter; std::ifstream fin; std::string sFile = FILENAMES["autopickup"]; if (bCharacter) { sFile = world_generator->active_world->world_path + "/" + base64_encode(g->u.name) + ".apu.json"; } fin.open(sFile.c_str(), std::ifstream::in | std::ifstream::binary); if( !fin.good() ) { if (load_legacy(bCharacter)) { if (save(bCharacter)) { remove_file(sFile); } } } else { try { JsonIn jsin(fin); deserialize(jsin); } catch( const JsonError &e ) { DebugLog(D_ERROR, DC_ALL) << "auto_pickup::load: " << e; } } fin.close(); merge_vector(); create_rules(); }
bool auto_pickup::save(const bool bCharacter) { bChar = bCharacter; auto savefile = FILENAMES["autopickup"]; if (bCharacter) { savefile = world_generator->active_world->world_path + "/" + base64_encode(g->u.name) + ".apu.json"; std::ifstream fin; fin.open((world_generator->active_world->world_path + "/" + base64_encode(g->u.name) + ".sav").c_str()); if(!fin.is_open()) { return true; //Character not saved yet. } fin.close(); } return write_to_file( savefile, [&]( std::ostream &fout ) { JsonOut jout( fout, true ); serialize(jout); if(!bCharacter) { merge_vector(); create_rules(); } }, _( "autopickup configuration" ) ); }
void removePickupRule(std::string sRule) { for (int i = 0; i < vAutoPickupRules[2].size(); i++) { if (sRule.length() == (vAutoPickupRules[2][i].sRule).length() && ci_find_substr(sRule, vAutoPickupRules[2][i].sRule) != -1) { vAutoPickupRules[2].erase(vAutoPickupRules[2].begin() + i); merge_vector(); createPickupRules(); break; } } }
void addPickupRule(std::string sRule) { vAutoPickupRules[2].push_back(cPickupRules(sRule, true, false)); merge_vector(); createPickupRules(); if (!OPTIONS["AUTO_PICKUP"] && query_yn(_("Autopickup is not enabled in the options. Enable it now?")) ) { OPTIONS["AUTO_PICKUP"].setNext(); save_options(true); } }
void auto_pickup::add_rule(const std::string &sRule) { vRules[CHARACTER].push_back(cRules(sRule, true, false)); merge_vector(); create_rules(); if (!OPTIONS["AUTO_PICKUP"] && query_yn(_("Autopickup is not enabled in the options. Enable it now?")) ) { OPTIONS["AUTO_PICKUP"].setNext(); get_options().save(); } }
void removePickupRule(std::string sRule) { for (std::vector<cPickupRules>::iterator it = vAutoPickupRules[APU_CHARACTER].begin(); it != vAutoPickupRules[APU_CHARACTER].end(); ++it) { if (sRule.length() == it->sRule.length() && ci_find_substr(sRule, it->sRule) != -1) { vAutoPickupRules[APU_CHARACTER].erase(it); merge_vector(); createPickupRules(); break; } } }
void save_reset_changes(bool bReset) { for (int i=1; i <= 2; i++) { //Loop through global 1 and character 2 vAutoPickupRules[i + ((bReset) ? 0: 2)].clear(); for (int j=0; j < vAutoPickupRules[i + ((bReset) ? 2: 0)].size(); j++) { if (vAutoPickupRules[i + ((bReset) ? 2: 0)][j].sRule != "") { vAutoPickupRules[i + ((bReset) ? 0: 2)].push_back(cPickupRules(vAutoPickupRules[i + ((bReset) ? 2: 0)][j].sRule, vAutoPickupRules[i + ((bReset) ? 2: 0)][j].bActive, vAutoPickupRules[i + ((bReset) ? 2: 0)][j].bExclude)); } } } merge_vector(); }
void auto_pickup::remove_rule(const std::string &sRule) { for (auto it = vRules[CHARACTER].begin(); it != vRules[CHARACTER].end(); ++it) { if (sRule.length() == it->sRule.length() && ci_find_substr(sRule, it->sRule) != -1) { vRules[CHARACTER].erase(it); merge_vector(); create_rules(); break; } } }
void save_reset_changes(bool bReset) { for (int i = APU_GLOBAL; i <= APU_CHARACTER; i++) { //Loop through global 1 and character 2 vAutoPickupRules[i + ((bReset) ? 0 : 2)].clear(); for (std::vector<cPickupRules>::iterator it = vAutoPickupRules[i + ((bReset) ? 2 : 0)].begin(); it != vAutoPickupRules[i + ((bReset) ? 2 : 0)].end(); ++it) { if (it->sRule != "") { vAutoPickupRules[i + ((bReset) ? 0 : 2)].push_back(cPickupRules( it->sRule, it->bActive, it->bExclude)); } } } merge_vector(); }
/** * Stores or retrieves the current ruleset from temporary storage. * Used to implement the "cancel changes" capability ("[N]o, don't save") of the * auto-pickup interface. * * @param bReset false to store, true to retrieve. */ void auto_pickup::save_reset_changes(const bool bReset) { for (int i = GLOBAL; i <= CHARACTER; i++) { //Loop through global 1 and character 2 int destination = i + ((bReset) ? 0 : 2); // if reset, copy to vRules[1,2] int source = i + ((bReset) ? 2 : 0); // if reset, copy from vRules[3,4] // (temp storage from when bReset was false) vRules[destination].clear(); for (auto it = vRules[source].begin(); it != vRules[source].end(); ++it) { if (it->sRule != "") { vRules[destination].push_back(*it); } } } merge_vector(); }
void auto_pickup::deserialize(JsonIn &jsin) { vRules[(bChar) ? CHARACTER : GLOBAL].clear(); jsin.start_array(); while (!jsin.end_array()) { JsonObject jo = jsin.get_object(); const std::string sRule = jo.get_string("rule"); const bool bActive = jo.get_bool("active"); const bool bExclude = jo.get_bool("exclude"); vRules[(bChar) ? CHARACTER : GLOBAL].push_back(cRules(sRule, bActive, bExclude)); } merge_vector(); create_rules(); }
bool save_auto_pickup(bool bCharacter) { std::ofstream fout; std::string sFile = FILENAMES["autopickup"]; if (bCharacter) { sFile = world_generator->active_world->world_path + "/" + base64_encode(g->u.name) + ".apu.txt"; std::ifstream fin; fin.open((world_generator->active_world->world_path + "/" + base64_encode(g->u.name) + ".sav").c_str()); if(!fin.is_open()) { return true; } fin.close(); } fout.exceptions(std::ios::badbit | std::ios::failbit); try { assure_dir_exist(FILENAMES["config_dir"]); fout.open(sFile.c_str()); fout << auto_pickup_header(bCharacter) << std::endl; for (std::vector<cPickupRules>::iterator it = vAutoPickupRules[(bCharacter) ? APU_CHARACTER : APU_GLOBAL].begin(); it != vAutoPickupRules[(bCharacter) ? APU_CHARACTER : APU_GLOBAL].end(); ++it) { fout << it->sRule << ";"; fout << (it->bActive ? "T" : "F") << ";"; fout << (it->bExclude ? "T" : "F"); fout << "\n"; } if (!bCharacter) { merge_vector(); createPickupRules(); } fout.close(); return true; } catch(std::ios::failure &) { popup(_("Failed to write autopickup rules to %s"), sFile.c_str()); return false; } }
bool save_auto_pickup(bool bCharacter) { std::ofstream fout; std::string sFile = "data/auto_pickup.txt"; if (bCharacter) { sFile = world_generator->active_world->world_path + "/" + base64_encode(g->u.name) + ".apu.txt"; std::ifstream fin; fin.open((world_generator->active_world->world_path + "/" + base64_encode(g->u.name) + ".sav").c_str()); if(!fin.is_open()) { return true; } fin.close(); } fout.exceptions(std::ios::badbit | std::ios::failbit); try { fout.open(sFile.c_str()); fout << auto_pickup_header(bCharacter) << std::endl; for (unsigned i = 0; i < vAutoPickupRules[(bCharacter) ? 2 : 1].size(); i++) { fout << vAutoPickupRules[(bCharacter) ? 2 : 1][i].sRule << ";"; fout << (vAutoPickupRules[(bCharacter) ? 2 : 1][i].bActive ? "T" : "F") << ";"; fout << (vAutoPickupRules[(bCharacter) ? 2 : 1][i].bExclude ? "T" : "F"); fout << "\n"; } if (!bCharacter) { merge_vector(); createPickupRules(); } fout.close(); return true; } catch(std::ios::failure &) { popup(_("Failed to write autopickup rules to %s"), sFile.c_str()); return false; } }
void addPickupRule(std::string sRule) { vAutoPickupRules[2].push_back(cPickupRules(sRule, true, false)); merge_vector(); createPickupRules(); }
void load_auto_pickup(bool bCharacter) { std::ifstream fin; std::string sFile = "data/auto_pickup.txt"; if (bCharacter) { sFile = "save/" + base64_encode(g->u.name) + ".apu.txt"; } fin.open(sFile.c_str()); if(!fin.is_open()) { fin.close(); create_default_auto_pickup(bCharacter); fin.open(sFile.c_str()); if(!fin.is_open()) { DebugLog() << "Could neither read nor create " << sFile << "\n"; return; } } vAutoPickupRules[(bCharacter) ? 2 : 1].clear(); std::string sLine; while(!fin.eof()) { getline(fin, sLine); if(sLine != "" && sLine[0] != '#') { int iNum = std::count(sLine.begin(), sLine.end(), ';'); if(iNum != 2) { /*int iNum = std::count(sLine.begin(), sLine.end(), ' '); if(iNum == 1) { //its an option! hurray } else {*/ DebugLog() << "Bad Rule: " << sLine << "\n"; //} } else { std::string sRule = ""; bool bActive = true; bool bExclude = false; size_t iPos = 0; int iCol = 1; do { iPos = sLine.find(";"); std::string sTemp = (iPos == std::string::npos) ? sLine : sLine.substr(0, iPos); if (iCol == 1) { sRule = sTemp; } else if (iCol == 2) { bActive = (sTemp == "T" || sTemp == "True") ? true : false; } else if (iCol == 3) { bExclude = (sTemp == "T" || sTemp == "True") ? true : false; } iCol++; if (iPos != std::string::npos) { sLine = sLine.substr(iPos+1, sLine.size()); } } while(iPos != std::string::npos); vAutoPickupRules[(bCharacter) ? 2 : 1].push_back(cPickupRules(sRule, bActive, bExclude)); } } } fin.close(); merge_vector(); createPickupRules(); }
void load_auto_pickup(bool bCharacter) { std::ifstream fin; std::string sFile = FILENAMES["autopickup"]; if (bCharacter) { sFile = world_generator->active_world->world_path + "/" + base64_encode(g->u.name) + ".apu.txt"; } bool legacy_autopickup_loaded = false; fin.open(sFile.c_str()); if(!fin.is_open()) { if( !bCharacter ) { fin.open(FILENAMES["legacy_autopickup"].c_str()); } if( !fin.is_open() ) { assure_dir_exist(FILENAMES["config_dir"]); create_default_auto_pickup(bCharacter); fin.open(sFile.c_str()); } else { legacy_autopickup_loaded = true; } if(!fin.is_open()) { DebugLog( D_ERROR, DC_ALL ) << "Could neither read nor create " << sFile; return; } } vAutoPickupRules[(bCharacter) ? APU_CHARACTER : APU_GLOBAL].clear(); std::string sLine; while(!fin.eof()) { getline(fin, sLine); if(sLine != "" && sLine[0] != '#') { int iNum = std::count(sLine.begin(), sLine.end(), ';'); if(iNum != 2) { DebugLog( D_ERROR, DC_ALL ) << "Bad Rule: " << sLine; } else { std::string sRule = ""; bool bActive = true; bool bExclude = false; size_t iPos = 0; int iCol = 1; do { iPos = sLine.find(";"); std::string sTemp = (iPos == std::string::npos) ? sLine : sLine.substr(0, iPos); if (iCol == 1) { sRule = sTemp; } else if (iCol == 2) { bActive = (sTemp == "T" || sTemp == "True") ? true : false; } else if (iCol == 3) { bExclude = (sTemp == "T" || sTemp == "True") ? true : false; } iCol++; if (iPos != std::string::npos) { sLine = sLine.substr(iPos + 1, sLine.size()); } } while(iPos != std::string::npos); vAutoPickupRules[(bCharacter) ? APU_CHARACTER : APU_GLOBAL].push_back(cPickupRules(sRule, bActive, bExclude)); } } } fin.close(); merge_vector(); createPickupRules(); if( legacy_autopickup_loaded ) { assure_dir_exist(FILENAMES["config_dir"]); save_auto_pickup( bCharacter ); } }
void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) { save_reset_changes(false); const int iHeaderHeight = 4; const int iContentHeight = FULL_SCREEN_HEIGHT - 2 - iHeaderHeight; const int iOffsetX = (TERMX > FULL_SCREEN_WIDTH) ? (TERMX - FULL_SCREEN_WIDTH) / 2 : 0; const int iOffsetY = (TERMY > FULL_SCREEN_HEIGHT) ? (TERMY - FULL_SCREEN_HEIGHT) / 2 : 0; std::map<int, bool> mapLines; mapLines[4] = true; mapLines[50] = true; mapLines[54] = true; const int iTotalCols = mapLines.size() - 1; WINDOW *w_help = newwin((FULL_SCREEN_HEIGHT / 2) - 2, FULL_SCREEN_WIDTH * 3 / 4, 7 + iOffsetY + (FULL_SCREEN_HEIGHT / 2) / 2, iOffsetX + 19 / 2); WINDOW_PTR w_helpptr( w_help ); WINDOW *w_border = newwin(FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH, iOffsetY, iOffsetX); WINDOW_PTR w_borderptr( w_border ); WINDOW *w_header = newwin(iHeaderHeight, FULL_SCREEN_WIDTH - 2, 1 + iOffsetY, 1 + iOffsetX); WINDOW_PTR w_headerptr( w_header ); WINDOW *w = newwin(iContentHeight, FULL_SCREEN_WIDTH - 2, iHeaderHeight + 1 + iOffsetY, 1 + iOffsetX); WINDOW_PTR wptr( w ); draw_border(w_border); mvwputch(w_border, 3, 0, c_ltgray, LINE_XXXO); // |- mvwputch(w_border, 3, 79, c_ltgray, LINE_XOXX); // -| for( auto &mapLine : mapLines ) { mvwputch( w_border, FULL_SCREEN_HEIGHT - 1, mapLine.first + 1, c_ltgray, LINE_XXOX ); // _|_ } mvwprintz(w_border, 0, 29, c_ltred, custom_name.c_str() ); wrefresh(w_border); int tmpx = 0; tmpx += shortcut_print(w_header, 0, tmpx, c_white, c_ltgreen, _("<A>dd")) + 2; tmpx += shortcut_print(w_header, 0, tmpx, c_white, c_ltgreen, _("<R>emove")) + 2; tmpx += shortcut_print(w_header, 0, tmpx, c_white, c_ltgreen, _("<C>opy")) + 2; tmpx += shortcut_print(w_header, 0, tmpx, c_white, c_ltgreen, _("<M>ove")) + 2; tmpx += shortcut_print(w_header, 0, tmpx, c_white, c_ltgreen, _("<E>nable")) + 2; tmpx += shortcut_print(w_header, 0, tmpx, c_white, c_ltgreen, _("<D>isable")) + 2; shortcut_print(w_header, 0, tmpx, c_white, c_ltgreen, _("<T>est")); tmpx = 0; tmpx += shortcut_print(w_header, 1, tmpx, c_white, c_ltgreen, _("<+-> Move up/down")) + 2; tmpx += shortcut_print(w_header, 1, tmpx, c_white, c_ltgreen, _("<Enter>-Edit")) + 2; shortcut_print(w_header, 1, tmpx, c_white, c_ltgreen, _("<Tab>-Switch Page")); for (int i = 0; i < 78; i++) { if (mapLines[i]) { mvwputch(w_header, 2, i, c_ltgray, LINE_OXXX); mvwputch(w_header, 3, i, c_ltgray, LINE_XOXO); } else { mvwputch(w_header, 2, i, c_ltgray, LINE_OXOX); // Draw line under header } } mvwprintz(w_header, 3, 1, c_white, "#"); mvwprintz(w_header, 3, 8, c_white, _("Rules")); mvwprintz(w_header, 3, 51, c_white, _("I/E")); wrefresh(w_header); int iCurrentPage = 1; int iCurrentLine = 0; int iCurrentCol = 1; int iStartPos = 0; bool bStuffChanged = false; input_context ctxt("AUTO_PICKUP"); ctxt.register_cardinal(); ctxt.register_action("CONFIRM"); ctxt.register_action("QUIT"); ctxt.register_action("NEXT_TAB"); ctxt.register_action("PREV_TAB"); ctxt.register_action("ADD_RULE"); ctxt.register_action("REMOVE_RULE"); ctxt.register_action("COPY_RULE"); ctxt.register_action("ENABLE_RULE"); ctxt.register_action("DISABLE_RULE"); ctxt.register_action("MOVE_RULE_UP"); ctxt.register_action("MOVE_RULE_DOWN"); ctxt.register_action("TEST_RULE"); ctxt.register_action("HELP_KEYBINDINGS"); if( is_autopickup ) { ctxt.register_action("SWITCH_AUTO_PICKUP_OPTION"); ctxt.register_action("SWAP_RULE_GLOBAL_CHAR"); } std::ostringstream sTemp; while(true) { int locx = 17; locx += shortcut_print(w_header, 2, locx, c_white, (iCurrentPage == 1) ? hilite(c_white) : c_white, _("[<Global>]")) + 1; shortcut_print(w_header, 2, locx, c_white, (iCurrentPage == 2) ? hilite(c_white) : c_white, _("[<Character>]")); locx = 55; mvwprintz(w_header, 0, locx, c_white, _("Auto pickup enabled:")); locx += shortcut_print(w_header, 1, locx, ((OPTIONS["AUTO_PICKUP"]) ? c_ltgreen : c_ltred), c_white, ((OPTIONS["AUTO_PICKUP"]) ? _("True") : _("False"))); locx += shortcut_print(w_header, 1, locx, c_white, c_ltgreen, " "); locx += shortcut_print(w_header, 1, locx, c_white, c_ltgreen, _("<S>witch")); shortcut_print(w_header, 1, locx, c_white, c_ltgreen, " "); wrefresh(w_header); // Clear the lines for (int i = 0; i < iContentHeight; i++) { for (int j = 0; j < 79; j++) { if (mapLines[j]) { mvwputch(w, i, j, c_ltgray, LINE_XOXO); } else { mvwputch(w, i, j, c_black, ' '); } } } const bool currentPageNonEmpty = !vRules[iCurrentPage].empty(); if (iCurrentPage == 2 && g->u.name == "") { vRules[2].clear(); mvwprintz(w, 8, 15, c_white, _("Please load a character first to use this page!")); } draw_scrollbar(w_border, iCurrentLine, iContentHeight, vRules[iCurrentPage].size(), 5); wrefresh(w_border); calcStartPos(iStartPos, iCurrentLine, iContentHeight, vRules[iCurrentPage].size()); // display auto pickup for (int i = iStartPos; i < (int)vRules[iCurrentPage].size(); i++) { if (i >= iStartPos && i < iStartPos + ((iContentHeight > (int)vRules[iCurrentPage].size()) ? (int)vRules[iCurrentPage].size() : iContentHeight)) { nc_color cLineColor = (vRules[iCurrentPage][i].bActive) ? c_white : c_ltgray; sTemp.str(""); sTemp << i + 1; mvwprintz(w, i - iStartPos, 1, cLineColor, "%s", sTemp.str().c_str()); mvwprintz(w, i - iStartPos, 5, cLineColor, ""); if (iCurrentLine == i) { wprintz(w, c_yellow, ">> "); } else { wprintz(w, c_yellow, " "); } wprintz(w, (iCurrentLine == i && iCurrentCol == 1) ? hilite(cLineColor) : cLineColor, "%s", ((vRules[iCurrentPage][i].sRule == "") ? _("<empty rule>") : vRules[iCurrentPage][i].sRule).c_str()); mvwprintz(w, i - iStartPos, 52, (iCurrentLine == i && iCurrentCol == 2) ? hilite(cLineColor) : cLineColor, "%s", ((vRules[iCurrentPage][i].bExclude) ? rm_prefix(_("<Exclude>E")).c_str() : rm_prefix( _("<Include>I")).c_str())); } } wrefresh(w); const std::string action = ctxt.handle_input(); if (action == "NEXT_TAB") { iCurrentPage++; if (iCurrentPage > 2) { iCurrentPage = 1; iCurrentLine = 0; } } else if (action == "PREV_TAB") { iCurrentPage--; if (iCurrentPage < 1) { iCurrentPage = 2; iCurrentLine = 0; } } else if (action == "QUIT") { break; } else if (iCurrentPage == 2 && g->u.name.empty()) { //Only allow loaded games to use the char sheet } else if (action == "DOWN") { iCurrentLine++; iCurrentCol = 1; if (iCurrentLine >= (int)vRules[iCurrentPage].size()) { iCurrentLine = 0; } } else if (action == "UP") { iCurrentLine--; iCurrentCol = 1; if (iCurrentLine < 0) { iCurrentLine = vRules[iCurrentPage].size() - 1; } } else if (action == "ADD_RULE") { bStuffChanged = true; vRules[iCurrentPage].push_back(cRules("", true, false)); iCurrentLine = vRules[iCurrentPage].size() - 1; } else if (action == "REMOVE_RULE" && currentPageNonEmpty) { bStuffChanged = true; vRules[iCurrentPage].erase(vRules[iCurrentPage].begin() + iCurrentLine); if (iCurrentLine > (int)vRules[iCurrentPage].size() - 1) { iCurrentLine--; } if(iCurrentLine < 0){ iCurrentLine = 0; } } else if (action == "COPY_RULE" && currentPageNonEmpty) { bStuffChanged = true; vRules[iCurrentPage].push_back(cRules( vRules[iCurrentPage][iCurrentLine].sRule, vRules[iCurrentPage][iCurrentLine].bActive, vRules[iCurrentPage][iCurrentLine].bExclude)); iCurrentLine = vRules[iCurrentPage].size() - 1; } else if (action == "SWAP_RULE_GLOBAL_CHAR" && currentPageNonEmpty) { if ((iCurrentPage == 1 && g->u.name != "") || iCurrentPage == 2) { bStuffChanged = true; //copy over vRules[(iCurrentPage == 1) ? 2 : 1].push_back(cRules( vRules[iCurrentPage][iCurrentLine].sRule, vRules[iCurrentPage][iCurrentLine].bActive, vRules[iCurrentPage][iCurrentLine].bExclude)); //remove old vRules[iCurrentPage].erase(vRules[iCurrentPage].begin() + iCurrentLine); iCurrentLine = vRules[(iCurrentPage == 1) ? 2 : 1].size() - 1; iCurrentPage = (iCurrentPage == 1) ? 2 : 1; } } else if (action == "CONFIRM" && currentPageNonEmpty) { bStuffChanged = true; if (iCurrentCol == 1) { fold_and_print(w_help, 1, 1, 999, c_white, _( "* is used as a Wildcard. A few Examples:\n" "\n" "wooden arrow matches the itemname exactly\n" "wooden ar* matches items beginning with wood ar\n" "*rrow matches items ending with rrow\n" "*avy fle*fi*arrow multiple * are allowed\n" "heAVY*woOD*arrOW case insensitive search\n" "") ); draw_border(w_help); wrefresh(w_help); vRules[iCurrentPage][iCurrentLine].sRule = trim_rule(string_input_popup(_("Pickup Rule:"), 30, vRules[iCurrentPage][iCurrentLine].sRule)); } else if (iCurrentCol == 2) { vRules[iCurrentPage][iCurrentLine].bExclude = !vRules[iCurrentPage][iCurrentLine].bExclude; } } else if (action == "ENABLE_RULE" && currentPageNonEmpty) { bStuffChanged = true; vRules[iCurrentPage][iCurrentLine].bActive = true; } else if (action == "DISABLE_RULE" && currentPageNonEmpty) { bStuffChanged = true; vRules[iCurrentPage][iCurrentLine].bActive = false; } else if (action == "LEFT") { iCurrentCol--; if (iCurrentCol < 1) { iCurrentCol = iTotalCols; } } else if (action == "RIGHT") { iCurrentCol++; if (iCurrentCol > iTotalCols) { iCurrentCol = 1; } } else if (action == "MOVE_RULE_UP" && currentPageNonEmpty) { bStuffChanged = true; if (iCurrentLine < (int)vRules[iCurrentPage].size() - 1) { std::swap(vRules[iCurrentPage][iCurrentLine], vRules[iCurrentPage][iCurrentLine + 1]); iCurrentLine++; iCurrentCol = 1; } } else if (action == "MOVE_RULE_DOWN" && currentPageNonEmpty) { bStuffChanged = true; if (iCurrentLine > 0) { std::swap(vRules[iCurrentPage][iCurrentLine], vRules[iCurrentPage][iCurrentLine - 1]); iCurrentLine--; iCurrentCol = 1; } } else if (action == "TEST_RULE" && currentPageNonEmpty) { test_pattern(iCurrentPage, iCurrentLine); } else if (action == "SWITCH_OPTION") { // @todo Now that NPCs use this function, it could be used for them too OPTIONS["AUTO_PICKUP"].setNext(); get_options().save(); } } if( !bStuffChanged ) { return; } if( query_yn( _("Save changes?") ) ) { // NPC pickup rules don't need to be saved explicitly if( is_autopickup ) { save( false ); if( g->u.name != "" ) { save(true); } } else { merge_vector(); create_rules(); } } else { save_reset_changes( true ); } }