Exemplo n.º 1
0
CharSpells::CharSpells(CharGenChoices &choices, Console *console) : CharGenBase(console) {
	_choices = &choices;
	load("cg_spells");

	_currentSpellLevel = SIZE_MAX;
	_abilityLimit = 0;

	_spellHelp = new CharHelp("cg_spellinfo", console);

	// TODO: Recommend button in the spell selection for the character generator.
	getWidget("RecommendButton", true)->setDisabled(true);
	// TODO: Reset button in the spell selection for the character generator.
	getWidget("ResetButton", true)->setDisabled(true);

	_availListBox = getListBox("AvailBox", true);
	_availListBox->setMode(WidgetListBox::kModeSelectable);
	_knownListBox = getListBox("KnownBox", true);
	_knownListBox->setMode(WidgetListBox::kModeSelectable);

	for (uint32 lvl = 0; lvl < 10; ++lvl) {
		WidgetButton *spellLvlButton = getButton("SpellLevel" + Common::composeString<uint32>(lvl), true);
		spellLvlButton->setTooltip(TalkMan.getString(68674 + lvl));
		spellLvlButton->setTooltipPosition(20.f, -40.f, -100.f);

		// TODO: The button should be render properly when pressed.
		spellLvlButton->setMode(WidgetButton::kModeUnchanged);
		spellLvlButton->setPressed(false);
	}

	makeSpellsList();
}
Exemplo n.º 2
0
PartyLeader::PartyLeader(Module &module) : _module(&module),
	_currentHP(1), _maxHP(1) {

	// The panel

	WidgetPanel *playerPanel = new WidgetPanel(*this, "LeaderPanel", "pnl_party_bar");

	playerPanel->setPosition(- playerPanel->getWidth(), 0.0, 0.0);

	addWidget(playerPanel);


	// Buttons

	float buttonsX = - playerPanel->getWidth () +  4.0;
	float buttonsY = - playerPanel->getHeight() + 57.0;

	for (int i = 0; i < 8; i++) {
		WidgetButton *button = new WidgetButton(*this, kButtonTags[i], kButtonModels[i]);

		button->setTooltip(TalkMan.getString(kButtonTooltips[i]));
		button->setTooltipPosition(0.0, -10.0, -1.0);

		const float x = buttonsX + ((i / 4) * 36.0);
		const float y = buttonsY - ((i % 4) * 18.0);
		const float z = -100.0;

		button->setPosition(x, y, z);

		addWidget(button);
	}

	getWidget("ButtonPlayers", true)->setDisabled(true);


	// Portrait

	_portrait =
		new PortraitWidget(*this, "LeaderPortrait", "gui_po_nwnlogo_", Portrait::kSizeMedium);

	_portrait->setPosition(-67.0, -103.0, -100.0);
	_portrait->setTooltipPosition(-50.0, 50.0, -1.0);

	addWidget(_portrait);


	// Health bar

	_health = new QuadWidget(*this, "LeaderHealthbar", "", 0.0, 0.0, 6.0, 100.0);

	_health->setColor(1.0, 0.0, 0.0, 1.0);
	_health->setPosition(-76.0, -103.0, -100.0);

	addWidget(_health);


	updatePortraitTooltip();
	notifyResized(0, 0, GfxMan.getScreenWidth(), GfxMan.getScreenHeight());
}
Exemplo n.º 3
0
void CharSpells::makeSpellsList() {
	// Compute the maximum spell level.
	const Aurora::TwoDAFile &twodaClasses = TwoDAReg.get2DA("classes");
	const Aurora::TwoDARow &classRow = twodaClasses.getRow(_choices->getClass());
	const Common::UString gainTable = classRow.getString("SpellGainTable");
	const Aurora::TwoDAFile &twodaSpellGain = TwoDAReg.get2DA(gainTable);
	const Aurora::TwoDARow &spellLevelRow = twodaSpellGain.getRow(_choices->getCharacter().getHitDice());

	for (size_t lvl = 2; lvl < twodaSpellGain.getColumnCount(); ++lvl) {
		if (spellLevelRow.empty(lvl)) {
			_maxLevel = lvl - 3UL;
			break;
		}
	}

	_knownSpells.resize(_maxLevel + 1);
	_availSpells.resize(_maxLevel + 1);
	_remainingSpells.resize(_maxLevel + 1);

	computeRemainingSpells(classRow);

	// We need to know the spellCaster type. We can get it from the spellGain table.
	Common::UString casterName;
	if (gainTable == "CLS_SPGN_BARD") {
		casterName = "Bard";
	} else if (gainTable == "CLS_SPGN_CLER") {
		casterName = "Cleric";
	} else if (gainTable == "CLS_SPGN_DRUI") {
		casterName = "Druid";
	} else if (gainTable == "CLS_SPGN_PAL") {
		casterName = "Paladin";
	} else if (gainTable == "CLS_SPGN_RANG") {
		casterName = "Ranger";
	} else if (gainTable == "CLS_SPGN_WIZ" || gainTable == "CLS_SPGN_SORC") {
		casterName = "Wiz_Sorc";
	} else {
		error("Unknown caster name when building spells list: %s", gainTable.c_str());
	}

	Common::UString oppositeSchool = "";
	if (_choices->getSpellSchool() < UINT8_MAX) {
		const Aurora::TwoDAFile &twodaSpellsSchool = TwoDAReg.get2DA("spellschools");
		const Aurora::TwoDARow &rowSchool = twodaSpellsSchool.getRow(_choices->getSpellSchool());
		const Aurora::TwoDARow &rowOppSchool = twodaSpellsSchool.getRow(rowSchool.getInt("Opposition"));
		oppositeSchool = rowOppSchool.getString("Letter");
	}

	// Add spells to available and known list.
	const Aurora::TwoDAFile &twodaSpells = TwoDAReg.get2DA("spells");
	for (size_t sp = 0; sp < twodaSpells.getRowCount(); ++sp) {
		// TODO: Check if character already own the spell.
		const Aurora::TwoDARow &spellRow = twodaSpells.getRow(sp);

		if (spellRow.empty("Name"))
			continue;

		if (spellRow.empty(casterName))
			continue;

		// Check spell level.
		uint32 spellLevel = static_cast<uint32>(spellRow.getInt(casterName));
		if (spellLevel > _maxLevel)
			continue;

		// Check spell school.
		if (spellRow.getString("School") == oppositeSchool)
			continue;

		// The wizard knows all the level 0 spells.
		if (gainTable == "CLS_SPGN_WIZ" && spellLevel == 0) {
			Spell spell;
			spell.spellID = sp;
			spell.name = TalkMan.getString(spellRow.getInt("Name"));
			spell.icon = spellRow.getString("IconResRef");
			spell.desc = TalkMan.getString(spellRow.getInt("SpellDesc"));
			_knownSpells[spellLevel].push_back(spell);
			continue;
		}

		Spell spell;
		spell.spellID = sp;
		spell.name = TalkMan.getString(spellRow.getInt("Name"));
		spell.icon = spellRow.getString("IconResRef");
		spell.desc = TalkMan.getString(spellRow.getInt("SpellDesc"));
		_availSpells[spellLevel].push_back(spell);
	}

	// Add icon to spells levels.
	for (uint32 lvl = 0; lvl <= _maxLevel; ++lvl) {
		WidgetButton *spellLvlButton = getButton("SpellLevel" + Common::composeString<uint32>(lvl), true);

		Common::UString lvlStr = Common::composeString<uint32>(lvl);
		Common::UString iconName;
		if (lvl == 0) {
			iconName = "ir_cantrips";
		} else if (lvl > 0 && lvl < 7) {
			iconName = "ir_level" + lvlStr;
		} else {
			iconName = "ir_level789";
		}

		const std::vector<Common::UString> texture(1, iconName);
		spellLvlButton->getNode("Plane64")->setTextures(texture);
	}

	// Compute spell level limit due to ability.
	Common::UString abilityStr = classRow.getString("PrimaryAbil");
	const Aurora::TwoDAFile &twodaAbilities = TwoDAReg.get2DA("iprp_abilities");
	for (size_t ab = 0; ab < twodaAbilities.getRowCount(); ++ab) {
		const Aurora::TwoDARow &abilityRow = twodaAbilities.getRow(ab);
		if (abilityStr.toLower() == abilityRow.getString("Label").toLower()) {
			_abilityLimit = _choices->getTotalAbility(ab) - 10U;
			break;
		}
	}

	// Show the first spells level that has a level to choose.
	size_t lvlToShow = 0;
	for (size_t lvl = _maxLevel; lvl == 0UL; --lvl)
		if (_remainingSpells[lvl] > 0)
			lvlToShow = lvl;

	showSpellLevel(lvlToShow);
	updateRemainLabel();
}