예제 #1
0
파일: game.cpp 프로젝트: vincele/xoreos
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
0
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
0
파일: console.cpp 프로젝트: EffWun/xoreos
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
0
파일: console.cpp 프로젝트: Hellzed/xoreos
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
0
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
0
파일: console.cpp 프로젝트: EffWun/xoreos
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
0
파일: game.cpp 프로젝트: farmboy0/xoreos
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());
}