void Console::execute(const Common::UString &line) { if (line.empty()) return; // Add the line to console _console->print(Common::UString(kPrompt) + " " + line); // Split command from redirect target Common::UString command; Common::UString redirect; line.split(line.findFirst('>'), command, redirect, true); command.trim(); redirect.trim(); // Split command from arguments CommandLine cl; command.split(command.findFirst(' '), cl.cmd, cl.args, true); cl.cmd.trim(); cl.args.trim(); // Find the command CommandMap::iterator cmd = _commands.find(cl.cmd); if (cmd == _commands.end()) { printf("Unknown command \"%s\". Type 'help' for a list of available commands.", cl.cmd.c_str()); return; } // Set redirect if (!_console->setRedirect(redirect)) return; // Execute _console->hidePrompt(); cmd->second.callback(cl); _console->showPrompt(); // Reset redirect _console->setRedirect(); }
void Console::updateCampaigns() { _campaigns.clear(); _campaignModules.clear(); // Base game for (int i = 0; i < 5; i++) { Common::UString name = TalkMan.getString(kCampaignNames[i]); name.truncate(name.findFirst('\n')); name.trim(); _campaigns.push_back(name); _campaignModules.insert(std::make_pair(name, i)); } // XP1 if (ConfigMan.getBool("NWN_hasXP1")) { for (int i = 5; i < 8; i++) { Common::UString name = "XP1: " + TalkMan.getString(kCampaignNames[i]); name.truncate(name.findFirst('\n')); name.trim(); _campaigns.push_back(name); _campaignModules.insert(std::make_pair(name, i)); } } // XP2 if (ConfigMan.getBool("NWN_hasXP2")) { for (int i = 8; i < 11; i++) { Common::UString name = "XP2: " + TalkMan.getString(kCampaignNames[i]); name.truncate(name.findFirst('\n')); name.trim(); _campaigns.push_back(name); _campaignModules.insert(std::make_pair(name, i)); } } setArguments("loadcampaign", _campaigns); }
static bool tagToString(uint32 tag, bool trim, Common::UString &str) { tag = TO_BE_32(tag); const char *tS = (const char *) &tag; if (!std::isprint(tS[0]) || !std::isprint(tS[1]) || !std::isprint(tS[2]) || !std::isprint(tS[3])) return false; str = UString::sprintf("%c%c%c%c", tS[0], tS[1], tS[2], tS[3]); if (trim) str.trim(); return true; }
void Creature::getPCListInfo(const Common::UString &bic, bool local, Common::UString &name, Common::UString &classes, Common::UString &portrait) { Aurora::GFF3File *gff = openPC(bic, local); try { const Aurora::GFF3Struct &top = gff->getTopLevel(); // Reading name const Common::UString firstName = top.getString("FirstName"); const Common::UString lastName = top.getString("LastName"); name = firstName + " " + lastName; name.trim(); // Reading portrait (failure non-fatal) try { loadPortrait(top, portrait); } catch (...) { portrait.clear(); Common::exceptionDispatcherWarning("Can't read portrait for PC \"%s\"", bic.c_str()); } // Reading classes std::vector<Class> classLevels; uint8 hitDice; loadClasses(top, classLevels, hitDice); getClassString(classLevels, classes); classes = "(" + classes + ")"; } catch (...) { delete gff; throw; } delete gff; }