Skip to content

Commit

Permalink
XEEN: Create Resources class to encapsulate all the static resources
Browse files Browse the repository at this point in the history
This will make it easier later on to handle things like translations,
and if the other games have different values for some arrays
  • Loading branch information
dreammaster committed Sep 23, 2016
1 parent edaf645 commit 4515d7a
Show file tree
Hide file tree
Showing 29 changed files with 1,281 additions and 1,504 deletions.
199 changes: 98 additions & 101 deletions engines/xeen/character.cpp

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions engines/xeen/combat.cpp
Expand Up @@ -218,7 +218,7 @@ void Combat::giveCharDamage(int damage, DamageType attackType, int charIndex) {
// Draw the attack effect on the character sprite
sound.playFX(fx);
_powSprites.draw(screen, frame,
Common::Point(CHAR_FACES_X[selectedIndex1], 150));
Common::Point(Res.CHAR_FACES_X[selectedIndex1], 150));
screen._windows[33].update();

// Reduce damage if power shield active, and set it zero
Expand Down Expand Up @@ -317,7 +317,7 @@ void Combat::doCharDamage(Character &c, int charNum, int monsterDataIndex) {
}

sound.playFX(fx);
intf._charPowSprites.draw(screen, frame, Common::Point(CHAR_FACES_X[charNum], 150));
intf._charPowSprites.draw(screen, frame, Common::Point(Res.CHAR_FACES_X[charNum], 150));
screen._windows[33].update();

damage -= party._powerShield;
Expand Down Expand Up @@ -485,12 +485,12 @@ void Combat::moveMonsters() {
switch (party._mazeDirection) {
case DIR_NORTH:
case DIR_SOUTH:
if (monsterCanMove(pt, MONSTER_GRID_BITMASK[MONSTER_GRID_BITINDEX1[arrIndex]],
if (monsterCanMove(pt, Res.MONSTER_GRID_BITMASK[MONSTER_GRID_BITINDEX1[arrIndex]],
MONSTER_GRID_X[arrIndex], MONSTER_GRID_Y[arrIndex], idx)) {
// Move the monster
moveMonster(idx, Common::Point(MONSTER_GRID_X[arrIndex], MONSTER_GRID_Y[arrIndex]));
} else {
if (monsterCanMove(pt, MONSTER_GRID_BITMASK[MONSTER_GRID_BITINDEX2[arrIndex]],
if (monsterCanMove(pt, Res.MONSTER_GRID_BITMASK[MONSTER_GRID_BITINDEX2[arrIndex]],
arrIndex >= 21 && arrIndex <= 27 ? MONSTER_GRID3[arrIndex] : 0,
arrIndex >= 21 && arrIndex <= 27 ? 0 : MONSTER_GRID3[arrIndex],
idx)) {
Expand All @@ -505,7 +505,7 @@ void Combat::moveMonsters() {

case DIR_EAST:
case DIR_WEST:
if (monsterCanMove(pt, MONSTER_GRID_BITMASK[MONSTER_GRID_BITINDEX2[arrIndex]],
if (monsterCanMove(pt, Res.MONSTER_GRID_BITMASK[MONSTER_GRID_BITINDEX2[arrIndex]],
arrIndex >= 21 && arrIndex <= 27 ? MONSTER_GRID3[arrIndex] : 0,
arrIndex >= 21 && arrIndex <= 27 ? 0 : MONSTER_GRID3[arrIndex],
idx)) {
Expand All @@ -514,7 +514,7 @@ void Combat::moveMonsters() {
} else {
moveMonster(idx, Common::Point(0, MONSTER_GRID3[arrIndex]));
}
} else if (monsterCanMove(pt, MONSTER_GRID_BITMASK[MONSTER_GRID_BITINDEX1[arrIndex]],
} else if (monsterCanMove(pt, Res.MONSTER_GRID_BITMASK[MONSTER_GRID_BITINDEX1[arrIndex]],
MONSTER_GRID_X[arrIndex], MONSTER_GRID_Y[arrIndex], idx)) {
moveMonster(idx, Common::Point(MONSTER_GRID_X[arrIndex], MONSTER_GRID_Y[arrIndex]));
}
Expand Down Expand Up @@ -1162,7 +1162,7 @@ Common::String Combat::getMonsterDescriptions() {
_monsterIndex = 0;
}

return Common::String::format(COMBAT_DETAILS, lines[0].c_str(),
return Common::String::format(Res.COMBAT_DETAILS, lines[0].c_str(),
lines[1].c_str(), lines[2].c_str());
}

Expand Down Expand Up @@ -1575,7 +1575,7 @@ void Combat::quickFight() {
break;
case QUICK_SPELL:
if (c->_currentSpell != -1) {
spells.castSpell(c, (MagicSpell)SPELLS_ALLOWED[c->getClassCategory()][c->_currentSpell]);
spells.castSpell(c, (MagicSpell)Res.SPELLS_ALLOWED[c->getClassCategory()][c->_currentSpell]);
}
break;
case QUICK_BLOCK:
Expand Down Expand Up @@ -1673,15 +1673,15 @@ void Combat::getWeaponDamage(Character &c, RangeType rangeType) {
_attackWeapon = &c._weapons[idx];

if (c._weapons[idx]._material >= 37 && c._weapons[idx]._material < 59) {
_hitChanceBonus = METAL_DAMAGE_PERCENT[c._weapons[idx]._material - 37];
_weaponDamage = METAL_DAMAGE[c._weapons[idx]._material - 37];
_hitChanceBonus = Res.METAL_DAMAGE_PERCENT[c._weapons[idx]._material - 37];
_weaponDamage = Res.METAL_DAMAGE[c._weapons[idx]._material - 37];
}
}

_hitChanceBonus += party._heroism;
_attackWeaponId = c._weapons[idx]._id;
_weaponDice = WEAPON_DAMAGE_BASE[_attackWeaponId];
_weaponDie = WEAPON_DAMAGE_MULTIPLIER[_attackWeaponId];
_weaponDice = Res.WEAPON_DAMAGE_BASE[_attackWeaponId];
_weaponDie = Res.WEAPON_DAMAGE_MULTIPLIER[_attackWeaponId];

for (int diceIdx = 0; diceIdx < _weaponDice; ++diceIdx)
_weaponDamage += _vm->getRandomNumber(1, _weaponDie);
Expand Down Expand Up @@ -1744,7 +1744,7 @@ int Combat::getMonsterResistence(RangeType rangeType) {
}
} else {
int material = !_attackWeapon ? 0 : _attackWeapon->_material;
damage = ELEMENTAL_DAMAGE[material];
damage = Res.ELEMENTAL_DAMAGE[material];

if (material != 0) {
if (material < 9)
Expand Down
6 changes: 3 additions & 3 deletions engines/xeen/dialogs.cpp
Expand Up @@ -56,7 +56,7 @@ void ButtonContainer::addButton(const Common::Rect &bounds, int val) {

void ButtonContainer::addPartyButtons(XeenEngine *vm) {
for (uint idx = 0; idx < MAX_ACTIVE_PARTY; ++idx) {
addButton(Common::Rect(CHAR_FACES_X[idx], 150, CHAR_FACES_X[idx] + 32, 182),
addButton(Common::Rect(Res.CHAR_FACES_X[idx], 150, Res.CHAR_FACES_X[idx] + 32, 182),
Common::KEYCODE_F1 + idx);
}
}
Expand Down Expand Up @@ -143,7 +143,7 @@ void CreditsScreen::execute() {
screen._windows[GAME_WINDOW].close();

screen.loadBackground("marb.raw");
screen._windows[0].writeString(CREDITS);
screen._windows[0].writeString(Res.CREDITS);
doScroll(false, false);

events.setCursor(0);
Expand All @@ -163,7 +163,7 @@ void PleaseWait::show(XeenEngine *vm) {
if (vm->_mode != MODE_0) {
Window &w = vm->_screen->_windows[9];
w.open();
w.writeString(PLEASE_WAIT);
w.writeString(Res.PLEASE_WAIT);
w.update();
}
}
Expand Down
4 changes: 2 additions & 2 deletions engines/xeen/dialogs_automap.cpp
Expand Up @@ -411,9 +411,9 @@ void AutoMapDialog::execute() {
events.updateGameCounter();
}

screen._windows[5].writeString(Common::String::format(MAP_TEXT,
screen._windows[5].writeString(Common::String::format(Res.MAP_TEXT,
map._mazeName.c_str(), party._mazePosition.x,
party._mazePosition.y, DIRECTION_TEXT[party._mazeDirection]));
party._mazePosition.y, Res.DIRECTION_TEXT[party._mazeDirection]));
screen._windows[5].update();
screen._windows[3].update();

Expand Down
74 changes: 37 additions & 37 deletions engines/xeen/dialogs_char_info.cpp
Expand Up @@ -56,7 +56,7 @@ void CharacterInfo::execute(int charIndex) {
do {
if (redrawFlag) {
Common::String charDetails = loadCharacterDetails(*c);
w.writeString(Common::String::format(CHARACTER_TEMPLATE, charDetails.c_str()));
w.writeString(Common::String::format(Res.CHARACTER_TEMPLATE, charDetails.c_str()));
w.drawList(_drawList, 24);
w.update();
redrawFlag = false;
Expand Down Expand Up @@ -175,7 +175,7 @@ void CharacterInfo::execute(int charIndex) {

case Common::KEYCODE_e:
if (oldMode == MODE_COMBAT) {
ErrorScroll::show(_vm, EXCHANGING_IN_COMBAT, WT_FREEZE_WAIT);
ErrorScroll::show(_vm, Res.EXCHANGING_IN_COMBAT, WT_FREEZE_WAIT);
} else {
_vm->_mode = oldMode;
ExchangeDialog::show(_vm, c, charIndex);
Expand Down Expand Up @@ -285,9 +285,9 @@ Common::String CharacterInfo::loadCharacterDetails(const Character &c) {
c._energyResistence._permanent + c.itemScan(15) + c._energyResistence._temporary +
c._magicResistence._permanent + c.itemScan(16) + c._magicResistence._temporary;

return Common::String::format(CHARACTER_DETAILS,
PARTY_GOLD, c._name.c_str(), SEX_NAMES[c._sex],
RACE_NAMES[c._race], CLASS_NAMES[c._class],
return Common::String::format(Res.CHARACTER_DETAILS,
Res.PARTY_GOLD, c._name.c_str(), Res.SEX_NAMES[c._sex],
Res.RACE_NAMES[c._race], Res.CLASS_NAMES[c._class],
c.statColor(c.getStat(MIGHT), c.getStat(MIGHT, true)), c.getStat(MIGHT),
c.statColor(c.getStat(ACCURACY), c.getStat(ACCURACY, true)), c.getStat(ACCURACY),
c.statColor(c._currentHp, c.getMaxHP()), c._currentHp,
Expand All @@ -307,11 +307,11 @@ Common::String CharacterInfo::loadCharacterDetails(const Character &c) {
c.statColor(c.getStat(SPEED), c.getStat(SPEED, true)), c.getStat(SPEED),
c.statColor(c.getArmorClass(), c.getArmorClass(true)), c.getArmorClass(),
c.getNumAwards(),
CONDITION_COLORS[condition], CONDITION_NAMES[condition],
condition == NO_CONDITION && party._blessed ? PLUS_14 : "",
condition == NO_CONDITION && party._powerShield ? PLUS_14 : "",
condition == NO_CONDITION && party._holyBonus ? PLUS_14 : "",
condition == NO_CONDITION && party._heroism ? PLUS_14 : ""
Res.CONDITION_COLORS[condition], Res.CONDITION_NAMES[condition],
condition == NO_CONDITION && party._blessed ? Res.PLUS_14 : "",
condition == NO_CONDITION && party._powerShield ? Res.PLUS_14 : "",
condition == NO_CONDITION && party._holyBonus ? Res.PLUS_14 : "",
condition == NO_CONDITION && party._heroism ? Res.PLUS_14 : ""
);
}

Expand Down Expand Up @@ -356,18 +356,18 @@ bool CharacterInfo::expandStat(int attrib, const Character &c) {
stat1 = c.getStat((Attribute)attrib, false);
stat2 = c.getStat((Attribute)attrib, true);
idx = 0;
while (STAT_VALUES[idx] <= stat1)
while (Res.STAT_VALUES[idx] <= stat1)
++idx;

msg = Common::String::format(CURRENT_MAXIMUM_RATING_TEXT, STAT_NAMES[attrib],
stat1, stat2, RATING_TEXT[idx]);
msg = Common::String::format(Res.CURRENT_MAXIMUM_RATING_TEXT, Res.STAT_NAMES[attrib],
stat1, stat2, Res.RATING_TEXT[idx]);
break;

case 7:
// Age
stat1 = c.getAge(false);
stat2 = c.getAge(true);
msg = Common::String::format(AGE_TEXT, STAT_NAMES[attrib],
msg = Common::String::format(Res.AGE_TEXT, Res.STAT_NAMES[attrib],
stat1, stat2, c._birthDay, c._birthYear);
break;

Expand All @@ -376,7 +376,7 @@ bool CharacterInfo::expandStat(int attrib, const Character &c) {
const int CLASS_ATTACK_GAINS[10] = { 5, 6, 6, 7, 8, 6, 5, 4, 7, 6 };
idx = c.getCurrentLevel() / CLASS_ATTACK_GAINS[c._class] + 1;

msg = Common::String::format(LEVEL_TEXT, STAT_NAMES[attrib],
msg = Common::String::format(Res.LEVEL_TEXT, Res.STAT_NAMES[attrib],
c.getCurrentLevel(), c._level._permanent,
idx, idx > 1 ? "s" : "",
c._level._permanent);
Expand All @@ -387,7 +387,7 @@ bool CharacterInfo::expandStat(int attrib, const Character &c) {
// Armor Class
stat1 = c.getArmorClass(false);
stat2 = c.getArmorClass(true);
msg = Common::String::format(CURRENT_MAXIMUM_TEXT, STAT_NAMES[attrib],
msg = Common::String::format(Res.CURRENT_MAXIMUM_TEXT, Res.STAT_NAMES[attrib],
stat1, stat2);
bounds.setHeight(42);
break;
Expand All @@ -396,7 +396,7 @@ bool CharacterInfo::expandStat(int attrib, const Character &c) {
// Hit Points
stat1 = c._currentHp;
stat2 = c.getMaxHP();
msg = Common::String::format(CURRENT_MAXIMUM_TEXT, STAT_NAMES[attrib],
msg = Common::String::format(Res.CURRENT_MAXIMUM_TEXT, Res.STAT_NAMES[attrib],
stat1, stat2);
bounds.setHeight(42);
break;
Expand All @@ -405,14 +405,14 @@ bool CharacterInfo::expandStat(int attrib, const Character &c) {
// Spell Points
stat1 = c._currentSp;
stat2 = c.getMaxSP();
msg = Common::String::format(CURRENT_MAXIMUM_TEXT, STAT_NAMES[attrib],
msg = Common::String::format(Res.CURRENT_MAXIMUM_TEXT, Res.STAT_NAMES[attrib],
stat1, stat2);
bounds.setHeight(42);
break;

case 12:
// Resistences
msg = Common::String::format(RESISTENCES_TEXT, STAT_NAMES[attrib],
msg = Common::String::format(Res.RESISTENCES_TEXT, Res.STAT_NAMES[attrib],
c._fireResistence._permanent + c.itemScan(11) + c._fireResistence._temporary,
c._coldResistence._permanent + c.itemScan(13) + c._coldResistence._temporary,
c._electricityResistence._permanent + c.itemScan(12) + c._electricityResistence._temporary,
Expand All @@ -431,19 +431,19 @@ bool CharacterInfo::expandStat(int attrib, const Character &c) {
if (c._skills[skill]) {
if (skill == THIEVERY) {
lines[0] = Common::String::format("\n\t020%s%u",
SKILL_NAMES[THIEVERY], c.getThievery());
Res.SKILL_NAMES[THIEVERY], c.getThievery());
} else {
lines[skill] = Common::String::format("\n\t020%s", SKILL_NAMES[skill]);
lines[skill] = Common::String::format("\n\t020%s", Res.SKILL_NAMES[skill]);
}
}
}
} else {
lines[0] = NONE;
lines[0] = Res.NONE;
numLines = 1;
}

msg = Common::String::format("\x2\x3""c%s\x3l%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
STAT_NAMES[attrib], lines[0].c_str(), lines[1].c_str(),
Res.STAT_NAMES[attrib], lines[0].c_str(), lines[1].c_str(),
lines[2].c_str(), lines[3].c_str(), lines[4].c_str(), lines[5].c_str(),
lines[17].c_str(), lines[6].c_str(), lines[7].c_str(), lines[8].c_str(),
lines[9].c_str(), lines[10].c_str(), lines[11].c_str(), lines[12].c_str(),
Expand All @@ -465,31 +465,31 @@ bool CharacterInfo::expandStat(int attrib, const Character &c) {
// Experience
stat1 = c.getCurrentExperience();
stat2 = c.experienceToNextLevel();
msg = Common::String::format(EXPERIENCE_TEXT,
STAT_NAMES[attrib], stat1,
stat2 == 0 ? ELIGIBLE : Common::String::format("%d", stat2).c_str()
msg = Common::String::format(Res.EXPERIENCE_TEXT,
Res.STAT_NAMES[attrib], stat1,
stat2 == 0 ? Res.ELIGIBLE : Common::String::format("%d", stat2).c_str()
);
bounds.setHeight(43);
break;

case 16:
// Gold
msg = Common::String::format(IN_PARTY_IN_BANK, CONSUMABLE_NAMES[0],
msg = Common::String::format(Res.IN_PARTY_IN_BANK, Res.CONSUMABLE_NAMES[0],
party._gold, party._bankGold);
bounds.setHeight(43);
break;

case 17:
// Gems
msg = Common::String::format(IN_PARTY_IN_BANK, CONSUMABLE_NAMES[1],
msg = Common::String::format(Res.IN_PARTY_IN_BANK, Res.CONSUMABLE_NAMES[1],
party._gems, party._bankGems);
bounds.setHeight(43);
break;

case 18: {
// Food
int food = (party._food / party._activeParty.size()) / 3;
msg = Common::String::format(FOOD_TEXT, CONSUMABLE_NAMES[2],
msg = Common::String::format(Res.FOOD_TEXT, Res.CONSUMABLE_NAMES[2],
party._food, food, food != 1 ? "s" : "");
break;
}
Expand All @@ -502,10 +502,10 @@ bool CharacterInfo::expandStat(int attrib, const Character &c) {
if (c._conditions[condition]) {
if (condition >= UNCONSCIOUS) {
lines[condition] = Common::String::format("\n\t020%s",
CONDITION_NAMES[condition]);
Res.CONDITION_NAMES[condition]);
} else {
lines[condition] = Common::String::format("\n\t020%s\t095-%d",
CONDITION_NAMES[condition], c._conditions[condition]);
Res.CONDITION_NAMES[condition], c._conditions[condition]);
}

++total;
Expand All @@ -514,21 +514,21 @@ bool CharacterInfo::expandStat(int attrib, const Character &c) {

Condition condition = c.worstCondition();
if (condition == NO_CONDITION) {
lines[0] = Common::String::format("\n\t020%s", GOOD);
lines[0] = Common::String::format("\n\t020%s", Res.GOOD);
++total;
}

if (party._blessed)
lines[16] = Common::String::format(BLESSED, party._blessed);
lines[16] = Common::String::format(Res.BLESSED, party._blessed);
if (party._powerShield)
lines[17] = Common::String::format(POWER_SHIELD, party._powerShield);
lines[17] = Common::String::format(Res.POWER_SHIELD, party._powerShield);
if (party._holyBonus)
lines[18] = Common::String::format(HOLY_BONUS, party._holyBonus);
lines[18] = Common::String::format(Res.HOLY_BONUS, party._holyBonus);
if (party._heroism)
lines[19] = Common::String::format(HEROISM, party._heroism);
lines[19] = Common::String::format(Res.HEROISM, party._heroism);

msg = Common::String::format("\x2\x3""c%s\x3l%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\x1",
CONSUMABLE_NAMES[3], lines[0].c_str(), lines[1].c_str(),
Res.CONSUMABLE_NAMES[3], lines[0].c_str(), lines[1].c_str(),
lines[2].c_str(), lines[3].c_str(), lines[4].c_str(),
lines[5].c_str(), lines[6].c_str(), lines[7].c_str(),
lines[8].c_str(), lines[9].c_str(), lines[10].c_str(),
Expand Down
2 changes: 1 addition & 1 deletion engines/xeen/dialogs_dismiss.cpp
Expand Up @@ -68,7 +68,7 @@ void Dismiss::execute() {
if (_buttonValue < (int)party._activeParty.size()) {
if (party._activeParty.size() == 1) {
w.close();
ErrorScroll::show(_vm, CANT_DISMISS_LAST_CHAR, WT_NONFREEZED_WAIT);
ErrorScroll::show(_vm, Res.CANT_DISMISS_LAST_CHAR, WT_NONFREEZED_WAIT);
w.open();
} else {
// Remove the character from the party
Expand Down
4 changes: 2 additions & 2 deletions engines/xeen/dialogs_error.cpp
Expand Up @@ -100,8 +100,8 @@ void CantCast::execute(int spellId, int componentNum) {

sound.playFX(21);
w.open();
w.writeString(Common::String::format(NOT_ENOUGH_TO_CAST,
SPELL_CAST_COMPONENTS[componentNum - 1],
w.writeString(Common::String::format(Res.NOT_ENOUGH_TO_CAST,
Res.SPELL_CAST_COMPONENTS[componentNum - 1],
spells._spellNames[spellId].c_str()
));
w.update();
Expand Down
2 changes: 1 addition & 1 deletion engines/xeen/dialogs_exchange.cpp
Expand Up @@ -41,7 +41,7 @@ void ExchangeDialog::execute(Character *&c, int &charIndex) {

Window &w = screen._windows[31];
w.open();
w.writeString(EXCHANGE_WITH_WHOM);
w.writeString(Res.EXCHANGE_WITH_WHOM);
_iconSprites.draw(w, 0, Common::Point(225, 120));
w.update();

Expand Down

0 comments on commit 4515d7a

Please sign in to comment.