本文整理汇总了C++中common::UString::truncate方法的典型用法代码示例。如果您正苦于以下问题:C++ UString::truncate方法的具体用法?C++ UString::truncate怎么用?C++ UString::truncate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::UString
的用法示例。
在下文中一共展示了UString::truncate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadTalkTables
void Game::loadTalkTables(const Common::UString &dir, uint32 priority, ChangeList &res,
Aurora::Language language) {
if (EventMan.quitRequested())
return;
const Common::UString tlkDir =
Common::FilePath::findSubDirectory(ResMan.getDataBase(), dir + "/data/talktables", true);
Common::FileList files(tlkDir, 0);
files.sort(true);
files.relativize(tlkDir);
const Common::UString languageTLK = DragonAge2Engine::getLanguageString(language) + ".tlk";
const Common::UString languageTLKP = DragonAge2Engine::getLanguageString(language) + "_p.tlk";
for (Common::FileList::const_iterator f = files.begin(); f != files.end(); ++f) {
if (f->toLower().endsWith(languageTLK)) {
Common::UString tlk = *f;
tlk.truncate(tlk.size() - languageTLK.size());
loadTalkTable(tlk, "", language, priority++, res);
} else if (f->toLower().endsWith(languageTLKP)) {
Common::UString tlk = *f;
tlk.truncate(tlk.size() - languageTLKP.size());
loadTalkTable(tlk, "_p", language, priority++, res);
}
}
}
示例2: executeScript
void Functions::executeScript(Aurora::NWScript::FunctionContext &ctx) {
Common::UString script = ctx.getParams()[0].getString();
// Max resource name length is 16, and ExecuteScript should truncate accordingly
script.truncate(16);
if (!ResMan.hasResource(script, Aurora::kFileTypeNCS))
return;
Aurora::NWScript::Object *object = getParamObject(ctx, 1);
try {
Aurora::NWScript::NCSFile ncs(script);
// Let the child script inherit the environment of this parent script
Aurora::NWScript::VariableContainer *env = ctx.getCurrentEnvironment();
if (env)
ncs.setEnvironment(*env);
ncs.run(object);
} catch (Common::Exception &e) {
e.add("Failed ExecuteScript(\"%s\", %s)", script.c_str(), Aurora::NWScript::formatTag(object).c_str());
Common::printException(e, "WARNING: ");
}
}
示例3: recalcCursor
void ConsoleWindow::recalcCursor() {
Common::UString input = _inputText;
input.truncate(_cursorPosition);
const float cursorX = _x + _prompt->getWidth() + _font.getFont().getWidth(input) - 1.0;
_cursor->setPosition(cursorX, _y, -1002.0);
const float cursorWidth = 1.0 + (_overwrite ? _font.getFont().getWidth(' ') : 0.0);
_cursor->setWidth(cursorWidth);
}
示例4: updateCampaigns
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);
}
示例5: executeScript
void Functions::executeScript(Aurora::NWScript::FunctionContext &ctx) {
Common::UString script = ctx.getParams()[1].getString();
// Max resource name length is 16, and ExecuteScript should truncate accordingly
script.truncate(16);
if (!ResMan.hasResource(script, Aurora::kFileTypeNCS))
return;
Aurora::NWScript::Object *object = getParamObject(ctx, 0);
try {
Aurora::NWScript::NCSFile ncs(script);
ncs.run(object);
} catch (Common::Exception &e) {
e.add("Failed ExecuteScript(\"%s\", %s)", script.c_str(), formatTag(object).c_str());
Common::printException(e, "WARNING: ");
}
}
示例6: printList
void Console::printList(const std::list<Common::UString> &list, uint32 maxSize) {
const uint32 columns = getColumns();
if (maxSize > 0)
maxSize = MAX<uint32>(maxSize, 3);
uint32 lineSize = 1;
if (maxSize >= (columns - 2))
maxSize = columns;
else if (maxSize > 0)
lineSize = columns / (maxSize + 2);
std::list<Common::UString>::const_iterator l = list.begin();
while (l != list.end()) {
Common::UString line;
for (uint32 i = 0; (i < lineSize) && (l != list.end()); i++, ++l) {
Common::UString item = *l;
uint32 itemSize = item.size();
if (itemSize > maxSize) {
item.truncate(maxSize - 3);
item += "...";
itemSize = maxSize;
}
uint32 pad = (maxSize + 2) - itemSize;
while (pad-- > 0)
item += ' ';
line += item;
}
print(line);
}
}
示例7: getModules
void Game::getModules(std::vector<Common::UString> &modules) {
modules.clear();
Common::UString moduleDir = ConfigMan.getString("KOTOR_moduleDir");
if (moduleDir.empty())
return;
Common::FileList mods;
mods.addDirectory(moduleDir);
for (Common::FileList::const_iterator m = mods.begin(); m != mods.end(); ++m) {
Common::UString file = m->toLower();
if (!file.endsWith("_s.rim"))
continue;
file = Common::FilePath::getStem(file);
file.truncate(file.size() - Common::UString("_s").size());
modules.push_back(file);
}
std::sort(modules.begin(), modules.end(), Common::UString::iless());
}