Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/oxce-plus' into oxce-plus
Browse files Browse the repository at this point in the history
  • Loading branch information
Xilmi committed Sep 24, 2024
2 parents af2bc0f + 8295f01 commit 9cc597b
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 19 deletions.
12 changes: 11 additions & 1 deletion src/Basescape/SoldierDiaryOverviewState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ namespace OpenXcom
* @param soldierId ID of the selected soldier.
* @param soldierInfoState Pointer to the Soldier Info screen.
*/
SoldierDiaryOverviewState::SoldierDiaryOverviewState(Base *base, size_t soldierId, SoldierInfoState *soldierInfoState) : _base(base), _soldierId(soldierId), _soldierInfoState(soldierInfoState)
SoldierDiaryOverviewState::SoldierDiaryOverviewState(Base *base, size_t soldierId, SoldierInfoState *soldierInfoState) :
_base(base), _soldierId(soldierId), _soldierInfoState(soldierInfoState), _doNotReset(false)
{
if (_base == 0)
{
Expand Down Expand Up @@ -175,6 +176,14 @@ SoldierDiaryOverviewState::~SoldierDiaryOverviewState()
void SoldierDiaryOverviewState::init()
{
State::init();

// coming back from SoldierDiaryMissionState
if (_doNotReset)
{
_doNotReset = false;
return;
}

if (_list->empty())
{
_game->popState();
Expand Down Expand Up @@ -328,6 +337,7 @@ void SoldierDiaryOverviewState::btnNextClick(Action *)
void SoldierDiaryOverviewState::lstDiaryInfoClick(Action *)
{
int absoluteRowEntry = _lstDiary->getSelectedRow();
_doNotReset = true;
_game->pushState(new SoldierDiaryMissionState(_soldier, absoluteRowEntry));
}

Expand Down
1 change: 1 addition & 0 deletions src/Basescape/SoldierDiaryOverviewState.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class SoldierDiaryOverviewState : public State
Window *_window;
Text *_txtTitle, *_txtMission, *_txtRating, *_txtDate, *_txtDeathTitle, *_txtDeathInfo, *_txtDeathDate;
TextList *_lstDiary;
bool _doNotReset;

public:
/// Creates the Soldier Diary state.
Expand Down
11 changes: 8 additions & 3 deletions src/Basescape/SoldierInfoState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ namespace OpenXcom
* @param base Pointer to the base to get info from. NULL to use the dead soldiers list.
* @param soldierId ID of the selected soldier.
*/
SoldierInfoState::SoldierInfoState(Base *base, size_t soldierId, bool forceLimits) : _base(base), _soldierId(soldierId), _forceLimits(forceLimits), _soldier(0)
SoldierInfoState::SoldierInfoState(Base *base, size_t soldierId, bool forceLimits, bool readOnly) :
_base(base), _soldierId(soldierId), _forceLimits(forceLimits), _readOnly(readOnly), _soldier(0)
{
if (_base == 0)
{
Expand Down Expand Up @@ -277,6 +278,10 @@ SoldierInfoState::SoldierInfoState(Base *base, size_t soldierId, bool forceLimit

_btnArmor->setText(tr("STR_ARMOR"));
_btnArmor->onMouseClick((ActionHandler)&SoldierInfoState::btnArmorClick);
if (_readOnly)
{
_btnArmor->setVisible(false);
}

_btnBonuses->setText(tr("STR_BONUSES_BUTTON")); // tiny button, default translation is " "
_btnBonuses->onMouseClick((ActionHandler)&SoldierInfoState::btnBonusesClick);
Expand All @@ -289,7 +294,7 @@ SoldierInfoState::SoldierInfoState(Base *base, size_t soldierId, bool forceLimit
{
_game->getSavedGame()->getAvailableTransformations(availableTransformations, _game->getMod(), _base);
}
if (availableTransformations.empty())
if (_readOnly || availableTransformations.empty())
{
_btnTransformations->setVisible(false);
}
Expand Down Expand Up @@ -477,7 +482,7 @@ void SoldierInfoState::init()

_btnArmor->setText(wsArmor);

_btnSack->setVisible(_game->getSavedGame()->getMonthsPassed() > -1 && !(_soldier->getCraft() && _soldier->getCraft()->getStatus() == "STR_OUT"));
_btnSack->setVisible(!_readOnly && _game->getSavedGame()->getMonthsPassed() > -1 && !(_soldier->getCraft() && _soldier->getCraft()->getStatus() == "STR_OUT"));

_txtRank->setText(tr("STR_RANK_").arg(tr(_soldier->getRankString())));

Expand Down
3 changes: 2 additions & 1 deletion src/Basescape/SoldierInfoState.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class SoldierInfoState : public State
Base *_base;
size_t _soldierId;
bool _forceLimits;
bool _readOnly;
Soldier *_soldier;
std::vector<Soldier*> *_list;

Expand All @@ -58,7 +59,7 @@ class SoldierInfoState : public State

public:
/// Creates the Soldier Info state.
SoldierInfoState(Base *base, size_t soldierId, bool forceLimits = true);
SoldierInfoState(Base *base, size_t soldierId, bool forceLimits = true, bool readOnly = false);
/// Cleans up the Soldier Info state.
~SoldierInfoState();
/// Updates the soldier info.
Expand Down
17 changes: 16 additions & 1 deletion src/Geoscape/AllocatePsiTrainingState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "../Engine/Options.h"
#include "../Interface/ComboBox.h"
#include "../Mod/RuleSoldier.h"
#include "../Basescape/SoldierInfoState.h"
#include "../Basescape/SoldierSortUtil.h"
#include <algorithm>
#include "../Engine/Unicode.h"
Expand All @@ -47,7 +48,7 @@ namespace OpenXcom
* @param game Pointer to the core game.
* @param base Pointer to the base to handle.
*/
AllocatePsiTrainingState::AllocatePsiTrainingState(Base *base) : _sel(0), _base(base), _origSoldierOrder(*_base->getSoldiers())
AllocatePsiTrainingState::AllocatePsiTrainingState(Base *base) : _sel(0), _base(base), _origSoldierOrder(*_base->getSoldiers()), _doNotReset(false)
{
// Create objects
_window = new Window(this, 320, 200, 0, 0);
Expand Down Expand Up @@ -178,6 +179,7 @@ AllocatePsiTrainingState::AllocatePsiTrainingState(Base *base) : _sel(0), _base(
_lstSoldiers->onLeftArrowClick((ActionHandler)&AllocatePsiTrainingState::lstItemsLeftArrowClick);
_lstSoldiers->onRightArrowClick((ActionHandler)&AllocatePsiTrainingState::lstItemsRightArrowClick);
_lstSoldiers->onMouseClick((ActionHandler)&AllocatePsiTrainingState::lstSoldiersClick);
_lstSoldiers->onMouseClick((ActionHandler)&AllocatePsiTrainingState::lstSoldiersClick, SDL_BUTTON_RIGHT);
_lstSoldiers->onMousePress((ActionHandler)&AllocatePsiTrainingState::lstSoldiersMousePress);
}
/**
Expand Down Expand Up @@ -284,6 +286,14 @@ void AllocatePsiTrainingState::btnPlusClick(Action *action)
void AllocatePsiTrainingState::init()
{
State::init();

// coming back from SoldierInfoState
if (_doNotReset)
{
_doNotReset = false;
return;
}

_base->prepareSoldierStatsWithBonuses(); // refresh stats for sorting
initList(0);
}
Expand Down Expand Up @@ -507,6 +517,11 @@ void AllocatePsiTrainingState::lstSoldiersClick(Action *action)
s->setPsiTraining(false);
}
}
else if (action->getDetails()->button.button == SDL_BUTTON_RIGHT)
{
_doNotReset = true;
_game->pushState(new SoldierInfoState(_base, _sel, true, true));
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Geoscape/AllocatePsiTrainingState.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class AllocatePsiTrainingState : public State
std::vector<Soldier *> _origSoldierOrder;
std::vector<SortFunctor *> _sortFunctors;
std::vector<SortFunctor *> _sortFunctorsPlus;
bool _doNotReset;

///initializes the display list based on the craft soldier's list and the position to display
void initList(size_t scrl);
public:
Expand Down
17 changes: 16 additions & 1 deletion src/Geoscape/AllocateTrainingState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "../Engine/Options.h"
#include "../Interface/ComboBox.h"
#include "../Mod/Mod.h"
#include "../Basescape/SoldierInfoState.h"
#include "../Basescape/SoldierSortUtil.h"
#include <algorithm>
#include "../Engine/Unicode.h"
Expand All @@ -47,7 +48,7 @@ namespace OpenXcom
* @param game Pointer to the core game.
* @param base Pointer to the base to handle.
*/
AllocateTrainingState::AllocateTrainingState(Base *base) : _sel(0), _base(base), _origSoldierOrder(*_base->getSoldiers())
AllocateTrainingState::AllocateTrainingState(Base *base) : _sel(0), _base(base), _origSoldierOrder(*_base->getSoldiers()), _doNotReset(false)
{
// Create objects
_window = new Window(this, 320, 200, 0, 0);
Expand Down Expand Up @@ -190,6 +191,7 @@ AllocateTrainingState::AllocateTrainingState(Base *base) : _sel(0), _base(base),
_lstSoldiers->onLeftArrowClick((ActionHandler)&AllocateTrainingState::lstItemsLeftArrowClick);
_lstSoldiers->onRightArrowClick((ActionHandler)&AllocateTrainingState::lstItemsRightArrowClick);
_lstSoldiers->onMouseClick((ActionHandler)&AllocateTrainingState::lstSoldiersClick);
_lstSoldiers->onMouseClick((ActionHandler)&AllocateTrainingState::lstSoldiersClick, SDL_BUTTON_RIGHT);
_lstSoldiers->onMousePress((ActionHandler)&AllocateTrainingState::lstSoldiersMousePress);
}

Expand Down Expand Up @@ -292,6 +294,14 @@ void AllocateTrainingState::btnPlusClick(Action *action)
void AllocateTrainingState::init()
{
State::init();

// coming back from SoldierInfoState
if (_doNotReset)
{
_doNotReset = false;
return;
}

_base->prepareSoldierStatsWithBonuses(); // refresh stats for sorting
initList(0);
}
Expand Down Expand Up @@ -521,6 +531,11 @@ void AllocateTrainingState::lstSoldiersClick(Action *action)
soldier->setReturnToTrainingWhenHealed(false);
}
}
else if (action->getDetails()->button.button == SDL_BUTTON_RIGHT)
{
_doNotReset = true;
_game->pushState(new SoldierInfoState(_base, _sel, true, true));
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Geoscape/AllocateTrainingState.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class AllocateTrainingState : public State
std::vector<Soldier *> _origSoldierOrder;
std::vector<SortFunctor *> _sortFunctors;
std::vector<SortFunctor *> _sortFunctorsPlus;
bool _doNotReset;

///initializes the display list
void initList(size_t scrl);
public:
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/AlienRace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace OpenXcom
* Creates a blank alien race.
* @param id String defining the id.
*/
AlienRace::AlienRace(const std::string &id) : _id(id), _retaliationAggression(0)
AlienRace::AlienRace(const std::string &id, int listOrder) : _id(id), _retaliationAggression(0), _listOrder(listOrder)
{
}

Expand Down Expand Up @@ -66,6 +66,7 @@ void AlienRace::load(const YAML::Node &node, const Mod* mod)
_retaliationMissionDistribution.push_back(std::make_pair(nn->first.as<size_t>(0), nw));
}
}
_listOrder = node["listOrder"].as<int>(_listOrder);
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/Mod/AlienRace.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ class AlienRace
std::vector<std::string> _members;
std::vector< std::vector<std::string> > _membersRandom;
int _retaliationAggression;
int _listOrder;
public:
/// Creates a blank alien race ruleset.
AlienRace(const std::string &id);
AlienRace(const std::string &id, int listOrder);
/// Cleans up the alien race ruleset.
~AlienRace();
/// Loads alien race data from YAML.
Expand All @@ -64,6 +65,8 @@ class AlienRace
int getRetaliationAggression() const;
/// Returns a list of retaliation missions based on the given month.
WeightedOptions* retaliationMissionWeights(const size_t monthsPassed) const;
/// Get the list weight for this alien race.
int getListOrder() const { return _listOrder; }
};

}
5 changes: 3 additions & 2 deletions src/Mod/Armor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const std::string Armor::NONE = "STR_NONE";
* type of armor.
* @param type String defining the type.
*/
Armor::Armor(const std::string &type) :
Armor::Armor(const std::string &type, int listOrder) :
_type(type), _infiniteSupply(false), _frontArmor(0), _sideArmor(0), _leftArmorDiff(0), _rearArmor(0), _underArmor(0),
_drawingRoutine(0), _drawBubbles(false), _movementType(MT_WALK), _specab(SPECAB_NONE), _turnBeforeFirstStep(false), _turnCost(1), _moveSound(-1), _size(1), _weight(0),
_visibilityAtDark(0), _visibilityAtDay(0),
Expand All @@ -45,7 +45,7 @@ Armor::Armor(const std::string &type) :
_overKill(0.5f), _meleeDodgeBackPenalty(0),
_allowsRunning(defBoolNullable), _allowsStrafing(defBoolNullable), _allowsSneaking(defBoolNullable), _allowsKneeling(defBoolNullable), _allowsMoving(1),
_isPilotArmor(false), _allowTwoMainWeapons(false), _instantWoundRecovery(false),
_standHeight(-1), _kneelHeight(-1), _floatHeight(-1)
_standHeight(-1), _kneelHeight(-1), _floatHeight(-1), _listOrder(listOrder)
{
for (int i=0; i < DAMAGE_TYPES; i++)
_damageModifier[i] = 1.0f;
Expand Down Expand Up @@ -246,6 +246,7 @@ void Armor::load(const YAML::Node &node, Mod *mod, const ModScript &parsers)
_standHeight = node["standHeight"].as<int>(_standHeight);
_kneelHeight = node["kneelHeight"].as<int>(_kneelHeight);
_floatHeight = node["floatHeight"].as<int>(_floatHeight);
_listOrder = node["listOrder"].as<int>(_listOrder);
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/Mod/Armor.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,10 @@ class Armor
bool _instantWoundRecovery;
bool _isAlwaysVisible = false;
int _standHeight, _kneelHeight, _floatHeight;
int _listOrder;
public:
/// Creates a blank armor ruleset.
Armor(const std::string &type);
Armor(const std::string &type, int listOrder);
/// Cleans up the armor ruleset.
~Armor();

Expand Down Expand Up @@ -452,6 +453,9 @@ class Armor
int getKneelHeight() const;
/// Gets a unit's float elevation while wearing this armor.
int getFloatHeight() const;

/// Get the list weight for this armor.
int getListOrder() const { return _listOrder; }
};

}
12 changes: 7 additions & 5 deletions src/Mod/Mod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ Mod::Mod() :
_tuRecoveryWakeUpNewTurn(100), _shortRadarRange(0), _buildTimeReductionScaling(100),
_defeatScore(0), _defeatFunds(0), _difficultyDemigod(false), _startingTime(6, 1, 1, 1999, 12, 0, 0), _startingDifficulty(0),
_baseDefenseMapFromLocation(0), _disableUnderwaterSounds(false), _enableUnitResponseSounds(false), _pediaReplaceCraftFuelWithRangeType(-1),
_facilityListOrder(0), _craftListOrder(0), _itemCategoryListOrder(0), _itemListOrder(0),
_facilityListOrder(0), _craftListOrder(0), _itemCategoryListOrder(0), _itemListOrder(0), _armorListOrder(0), _alienRaceListOrder(0),
_researchListOrder(0), _manufactureListOrder(0), _soldierBonusListOrder(0), _transformationListOrder(0), _ufopaediaListOrder(0), _invListOrder(0), _soldierListOrder(0),
_modCurrent(0), _statePalette(0)
{
Expand Down Expand Up @@ -2825,7 +2825,7 @@ void Mod::loadFile(const FileMap::FileRecord &filerec, ModScript &parsers)

for (YAML::const_iterator i : iterateRules("armors", "type"))
{
Armor *rule = loadRule(*i, &_armors, &_armorsIndex);
Armor *rule = loadRule(*i, &_armors, &_armorsIndex, "type", RuleListOrderedFactory<Armor>{ _armorListOrder, 100 });
if (rule != 0)
{
rule->load(*i, this, parsers);
Expand Down Expand Up @@ -2857,7 +2857,7 @@ void Mod::loadFile(const FileMap::FileRecord &filerec, ModScript &parsers)
}
for (YAML::const_iterator i : iterateRules("alienRaces", "id"))
{
AlienRace *rule = loadRule(*i, &_alienRaces, &_aliensIndex, "id");
AlienRace *rule = loadRule(*i, &_alienRaces, &_aliensIndex, "id", RuleListOrderedFactory<AlienRace>{ _alienRaceListOrder, 100 });
if (rule != 0)
{
rule->load(*i, this);
Expand Down Expand Up @@ -4858,13 +4858,14 @@ struct compareRule<Armor>
const RuleItem *rule1 = armor1->getStoreItem();
const RuleItem *rule2 = armor2->getStoreItem();
if (!rule1 && !rule2)
return (armor1 < armor2); // tiebreaker, don't care about order, pointers are as good as any
return (armor1->getListOrder() < armor2->getListOrder()); // tiebreaker
else if (!rule1)
return true;
else if (!rule2)
return false;
else
return (rule1->getListOrder() < rule2->getListOrder());
return (rule1->getListOrder() < rule2->getListOrder() ||
(rule1->getListOrder() == rule2->getListOrder() && armor1->getListOrder() < armor2->getListOrder()));
}
};

Expand Down Expand Up @@ -4948,6 +4949,7 @@ void Mod::sortLists()
std::sort(_ufopaediaIndex.begin(), _ufopaediaIndex.end(), compareRule<ArticleDefinition>(this));
std::sort(_ufopaediaCatIndex.begin(), _ufopaediaCatIndex.end(), compareSection(this));
std::sort(_soldiersIndex.begin(), _soldiersIndex.end(), compareRule<RuleSoldier>(this, (compareRule<RuleSoldier>::RuleLookup) & Mod::getSoldier));
std::sort(_aliensIndex.begin(), _aliensIndex.end(), compareRule<AlienRace>(this, (compareRule<AlienRace>::RuleLookup) & Mod::getAlienRace));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Mod.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class Mod
std::vector<std::string> _alienMissionsIndex, _terrainIndex, _customPalettesIndex, _arcScriptIndex, _eventScriptIndex, _eventIndex, _missionScriptIndex;
std::vector<std::vector<int> > _alienItemLevels;
std::vector<std::array<SDL_Color, TransparenciesOpacityLevels>> _transparencies;
int _facilityListOrder, _craftListOrder, _itemCategoryListOrder, _itemListOrder, _researchListOrder, _manufactureListOrder;
int _facilityListOrder, _craftListOrder, _itemCategoryListOrder, _itemListOrder, _armorListOrder, _alienRaceListOrder, _researchListOrder, _manufactureListOrder;
int _soldierBonusListOrder, _transformationListOrder, _ufopaediaListOrder, _invListOrder, _soldierListOrder;
std::vector<ModData> _modData;
ModData* _modCurrent;
Expand Down
1 change: 1 addition & 0 deletions src/Ufopaedia/StatsForNerdsState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2812,6 +2812,7 @@ void StatsForNerdsState::initArmorList()
addSection("{Naming}", "", _white);
addSingleString(ss, armorRule->getType(), "type");
addSingleString(ss, armorRule->getUfopediaType(), "ufopediaType");
addInteger(ss, armorRule->getListOrder(), "listOrder");
addRuleNamed(ss, armorRule->getRequiredResearch(), "requires");

addSection("{Recovery}", "", _white);
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
#define OPENXCOM_VERSION_NUMBER 7,14,2,0

#ifndef OPENXCOM_VERSION_GIT
#define OPENXCOM_VERSION_GIT " (v2024-09-22)"
#define OPENXCOM_VERSION_GIT " (v2024-09-23)"
#endif

0 comments on commit 9cc597b

Please sign in to comment.