本文整理汇总了C++中common::UString类的典型用法代码示例。如果您正苦于以下问题:C++ UString类的具体用法?C++ UString怎么用?C++ UString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
void Placeable::load(const Aurora::GFF3Struct &placeable) {
Common::UString temp = placeable.getString("TemplateResRef");
Aurora::GFF3File *utp = 0;
if (!temp.empty()) {
try {
utp = new Aurora::GFF3File(temp, Aurora::kFileTypeUTP, MKTAG('U', 'T', 'P', ' '));
} catch (...) {
}
}
Situated::load(placeable, utp ? &utp->getTopLevel() : 0);
delete utp;
}
示例2: load
void Waypoint::load(const Aurora::GFF3Struct &waypoint) {
Common::UString temp = waypoint.getString("TemplateResRef");
Aurora::GFF3File *utw = 0;
if (!temp.empty()) {
try {
utw = new Aurora::GFF3File(temp, Aurora::kFileTypeUTW, MKTAG('U', 'T', 'W', ' '));
} catch (...) {
}
}
load(waypoint, utw ? &utw->getTopLevel() : 0);
delete utw;
}
示例3: load
void Walkmesh::load(const Common::UString &resRef) {
clear();
Common::ScopedPtr<Common::SeekableReadStream> wok(ResMan.getResource(resRef, ::Aurora::kFileTypeWOK));
if (wok) {
try {
appendFromStream(*wok);
} catch (Common::Exception &e) {
warning("Walkmesh load failed: %s %s", resRef.c_str(), e.what());
}
} else
warning("Walkmesh file not found: %s", resRef.c_str());
refreshIndexGroups();
}
示例4: loadModel
void Creature::loadModel() {
if (!_modelParts.empty())
return;
if (_appearanceID == Aurora::kFieldIDInvalid) {
warning("Creature \"%s\" has no appearance", _tag.c_str());
return;
}
Common::UString body = getBaseModel("NWN2_Model_Body");
if (body.empty()) {
warning("Creature \"%s\" has no body", _tag.c_str());
return;
}
// Main body model
loadArmorModel(body, "BODY", _armorVisualType, _armorVariation);
const Aurora::TwoDARow &appearance = TwoDAReg.get2DA("appearance").getRow(_appearanceID);
if (appearance.getInt("BodyType") == 1) {
// Creature with more part models than just the body
loadHeadModel(_appearanceHead);
loadHairModel(_appearanceMHair);
loadHairModel(_appearanceFHair);
loadArmorModel(body, "BOOTS" , _bootsVisualType, _bootsVariation);
if (!loadArmorModel(body, "GLOVES", 10, 0))
loadArmorModel(body, "GLOVES", 0, 0);
}
// Positioning
float x, y, z, angle;
getPosition(x, y, z);
setPosition(x, y, z);
getOrientation(x, y, z, angle);
setOrientation(x, y, z, angle);
for (std::list<Graphics::Aurora::Model *>::iterator m = _modelParts.begin(); m != _modelParts.end(); ++m) {
(*m)->setTag(_tag);
(*m)->setClickable(isClickable());
_ids.push_back((*m)->getID());
}
}
示例5: tokenize
void TwoDAFile::readHeaders2b(Common::SeekableReadStream &twoda) {
/* Read the column headers of a binary 2DA file. */
Common::StreamTokenizer tokenize(Common::StreamTokenizer::kRuleHeed);
// Individual column headers a separated by either a tab or a NUL
tokenize.addSeparator('\t');
tokenize.addSeparator('\0');
Common::UString header = tokenize.getToken(twoda);
while (!header.empty()) {
_headers.push_back(header);
header = tokenize.getToken(twoda);
}
}
示例6: loadArmorModel
bool Creature::loadArmorModel(const Common::UString &body,
const Common::UString &armor, uint8 visualType, uint8 variation) {
const Aurora::TwoDARow &armorVisual = TwoDAReg.get2DA("armorvisualdata").getRow(visualType);
Common::UString armorPrefix = armorVisual.getString("Prefix");
Common::UString modelFile;
modelFile = Common::UString::format("%s_%s_%s%02d",
body.c_str(), armorPrefix.c_str(), armor.c_str(), variation + 1);
Graphics::Aurora::Model *model = loadModelObject(modelFile);
if (model)
_modelParts.push_back(model);
return model != 0;
}
示例7: playSound
Sound::ChannelHandle playSound(const Common::UString &sound, Sound::SoundType soundType,
bool loop, float volume, bool pitchVariance) {
Aurora::ResourceType resType =
(soundType == Sound::kSoundTypeMusic) ? Aurora::kResourceMusic : Aurora::kResourceSound;
Sound::ChannelHandle channel;
try {
Common::SeekableReadStream *soundStream = ResMan.getResource(resType, sound);
if (!soundStream)
return channel;
channel = SoundMan.playSoundFile(soundStream, soundType, loop);
debugC(Common::kDebugEngineSound, 1, "Playing sound \"%s\" in %s",
sound.c_str(), SoundMan.formatChannel(channel).c_str());
SoundMan.setChannelGain(channel, volume);
if (pitchVariance) {
const float pitch = 1.0f + ((((std::rand() % 1001) / 1000.0f) / 5.0f) - 0.1f);
SoundMan.setChannelPitch(channel, pitch);
}
SoundMan.startChannel(channel);
} catch (...) {
Common::exceptionDispatcherWarning();
}
return channel;
}
示例8: loadTexture
void AreaBackground::loadTexture(const Common::UString &name) {
Common::SeekableReadStream *cbgt = 0, *pal = 0, *twoda = 0;
Graphics::CBGT *image = 0;
try {
if (!(cbgt = ResMan.getResource(name, Aurora::kFileTypeCBGT)))
throw Common::Exception("No such CBGT");
if (!(pal = ResMan.getResource(name, Aurora::kFileTypePAL)))
throw Common::Exception("No such PAL");
if (!(twoda = ResMan.getResource(name, Aurora::kFileType2DA)))
throw Common::Exception("No such 2DA");
image = new Graphics::CBGT(*cbgt, *pal, *twoda);
_texture = TextureMan.add(Graphics::Aurora::Texture::create(image, Aurora::kFileTypeCBGT), name);
} catch (Common::Exception &e) {
delete image;
delete cbgt;
delete pal;
delete twoda;
e.add("Failed loading area background \"%s\"", name.c_str());
throw;
}
delete cbgt;
delete pal;
delete twoda;
}
示例9: loadModule
void Module::loadModule(const Common::UString &module, const Common::UString &entryLocation,
ObjectType entryLocationType) {
unload(false);
_module = module;
_entryLocation = entryLocation;
_entryLocationType = entryLocationType;
try {
load();
} catch (Common::Exception &e) {
_module.clear();
e.add("Failed loading module \"%s\"", module.c_str());
throw e;
}
_newModule.clear();
_hasModule = true;
}
示例10: getObjectLocation
bool Module::getObjectLocation(const Common::UString &object, ObjectType location,
float &entryX, float &entryY, float &entryZ, float &entryAngle) {
if (object.empty())
return false;
Aurora::NWScript::ObjectSearch *search = findObjectsByTag(object);
KotOR::Object *kotorObject = 0;
while (!kotorObject && search->get()) {
kotorObject = KotOR::ObjectContainer::toObject(search->next());
if (!kotorObject || !(kotorObject->getType() & location))
kotorObject = 0;
}
delete search;
if (!kotorObject)
return false;
// TODO: Entry orientation
kotorObject->getPosition(entryX, entryY, entryZ);
entryAngle = 0.0f;
return true;
}
示例11: load
void VideoPlayer::load(const Common::UString &name) {
delete _video;
_video = 0;
::Aurora::FileType type;
Common::SeekableReadStream *video = ResMan.getResource(::Aurora::kResourceVideo, name, &type);
if (!video)
throw Common::Exception("No such video resource \"%s\"", name.c_str());
// Loading the different image formats
switch (type) {
case ::Aurora::kFileTypeBIK:
_video = new Bink(video);
break;
case ::Aurora::kFileTypeMOV:
_video = new QuickTimeDecoder(video);
break;
case ::Aurora::kFileTypeXMV:
_video = new XboxMediaVideo(video);
break;
case ::Aurora::kFileTypeVX:
_video = new ActimagineDecoder(video);
break;
default:
delete video;
throw Common::Exception("Unsupported video resource type %d", (int) type);
}
_video->setScale(VideoDecoder::kScaleUpDown);
}
示例12: printUsage
void printUsage(FILE *stream, const Common::UString &name) {
std::fprintf(stream, "XML to BioWare TLK converter\n\n");
std::fprintf(stream, "Usage: %s [<options>] [<input file>] <output file>\n", name.c_str());
std::fprintf(stream, " -h --help This help text\n");
std::fprintf(stream, " --version Display version information\n");
std::fprintf(stream, " -3 --version30 Write a V3.0 TLK file\n");
std::fprintf(stream, " -4 --version40 Write a V4.0 TLK file\n");
std::fprintf(stream, " -l <id> --language <id> Override the TLK language ID\n\n");
std::fprintf(stream, " --cp1250 Write TLK strings as Windows CP-1250\n");
std::fprintf(stream, " --cp1251 Write TLK strings as Windows CP-1251\n");
std::fprintf(stream, " --cp1252 Write TLK strings as Windows CP-1252\n");
std::fprintf(stream, " --cp932 Write TLK strings as Windows CP-932\n");
std::fprintf(stream, " --cp936 Write TLK strings as Windows CP-936\n");
std::fprintf(stream, " --cp949 Write TLK strings as Windows CP-949\n");
std::fprintf(stream, " --cp950 Write TLK strings as Windows CP-950\n");
std::fprintf(stream, " --utf8 Write TLK strings as UTF-8\n");
std::fprintf(stream, " --utf16le Write TLK strings as little-endian UTF-16\n");
std::fprintf(stream, " --utf16be Write TLK strings as big-endian UTF-16\n\n");
std::fprintf(stream, " --nwn Use Neverwinter Nights encodings\n");
std::fprintf(stream, " --nwn2 Use Neverwinter Nights 2 encodings\n");
std::fprintf(stream, " --kotor Use Knights of the Old Republic encodings\n");
std::fprintf(stream, " --kotor2 Use Knights of the Old Republic II encodings\n");
std::fprintf(stream, " --jade Use Jade Empire encodings\n");
std::fprintf(stream, " --witcher Use The Witcher encodings\n");
std::fprintf(stream, " --dragonage Use Dragon Age encodings\n");
std::fprintf(stream, " --dragonage2 Use Dragon Age II encodings\n\n");
std::fprintf(stream, "If no input file is given, the input is read from stdin.\n\n");
std::fprintf(stream, "One of --version* to specify the version of TLK to write is mandatory,\n");
std::fprintf(stream, "as is one of the flags for the encoding. If the XML file provides a\n");
std::fprintf(stream, "language ID, the --language flag is optional.\n\n");
std::fprintf(stream, "There is no way to autodetect the encoding of strings in TLK files,\n");
std::fprintf(stream, "so an encoding must be specified. Alternatively, the game this TLK\n");
std::fprintf(stream, "is from can be given, and an appropriate encoding according to that\n");
std::fprintf(stream, "game and the language ID is used.\n");
}
示例13: printUsage
void printUsage(FILE *stream, const Common::UString &name) {
std::fprintf(stream, "BioWare TLK to XML converter\n\n");
std::fprintf(stream, "Usage: %s [<options>] <input file> [<output file>]\n", name.c_str());
std::fprintf(stream, " -h --help This help text\n");
std::fprintf(stream, " --version Display version information\n\n");
std::fprintf(stream, " --cp1250 Read TLK strings as Windows CP-1250\n");
std::fprintf(stream, " --cp1251 Read TLK strings as Windows CP-1251\n");
std::fprintf(stream, " --cp1252 Read TLK strings as Windows CP-1252\n");
std::fprintf(stream, " --cp932 Read TLK strings as Windows CP-932\n");
std::fprintf(stream, " --cp936 Read TLK strings as Windows CP-936\n");
std::fprintf(stream, " --cp949 Read TLK strings as Windows CP-949\n");
std::fprintf(stream, " --cp950 Read TLK strings as Windows CP-950\n");
std::fprintf(stream, " --utf8 Read TLK strings as UTF-8\n");
std::fprintf(stream, " --utf16le Read TLK strings as little-endian UTF-16\n");
std::fprintf(stream, " --utf16be Read TLK strings as big-endian UTF-16\n\n");
std::fprintf(stream, " --nwn Use Neverwinter Nights encodings\n");
std::fprintf(stream, " --nwn2 Use Neverwinter Nights 2 encodings\n");
std::fprintf(stream, " --kotor Use Knights of the Old Republic encodings\n");
std::fprintf(stream, " --kotor2 Use Knights of the Old Republic II encodings\n");
std::fprintf(stream, " --jade Use Jade Empire encodings\n");
std::fprintf(stream, " --witcher Use The Witcher encodings\n");
std::fprintf(stream, " --dragonage Use Dragon Age encodings\n");
std::fprintf(stream, " --dragonage2 Use Dragon Age II encodings\n\n");
std::fprintf(stream, "If no output file is given, the output is written to stdout.\n\n");
std::fprintf(stream, "There is no way to autodetect the encoding of strings in TLK files,\n");
std::fprintf(stream, "so an encoding must be specified. Alternatively, the game this TLK\n");
std::fprintf(stream, "is from can be given, and an appropriate encoding according to that\n");
std::fprintf(stream, "game and the language ID found in the TLK is used.\n");
}
示例14: setEntry
void DialogBox::setEntry(const Common::UString &entry) {
GfxMan.lockFrame();
clearEntry();
if (entry.empty()) {
GfxMan.unlockFrame();
return;
}
_entry = TokenMan.parse(entry);
// TODO: Check entry length, scrollbars
const float maxWidth = _width - 2.0f - 2.0f - _portrait->getWidth() - 5.0f;
std::vector<Common::UString> lines;
_font.getFont().split(_entry, lines, maxWidth);
for (std::vector<Common::UString>::iterator l = lines.begin(); l != lines.end(); ++l)
_entryLines.push_back(new Graphics::Aurora::Text(_font, *l));
setPosition(_x, _y, _z);
if (isVisible())
showEntry();
GfxMan.unlockFrame();
}
示例15: addLine
void Tooltip::addLine(const Common::UString &text, float r, float g, float b, float a) {
hide();
if (text.empty())
return;
std::vector<Common::UString> lines;
Common::UString::split(text, '\n', lines);
for (std::vector<Common::UString>::const_iterator l = lines.begin();
l != lines.end(); ++l) {
_lines.push_back(Line());
_lines.back().r = r;
_lines.back().g = g;
_lines.back().b = b;
_lines.back().a = a;
_lines.back().line = *l;
_lines.back().text = new Graphics::Aurora::Text(FontMan.get(getFontName()), *l, r, g, b, a);
_lines.back().text->setTag("Tooltip#Text");
}
redoLayout();
}