Skip to content

Commit 1c3d87b

Browse files
committed
Merge branch 'includePrimeStateInSavedLayout' of https://github.com/fenyo1/OpenXcom into fenyo1-includePrimeStateInSavedLayout
2 parents c81a27b + 6be5ada commit 1c3d87b

9 files changed

Lines changed: 28 additions & 6 deletions

File tree

bin/data/Language/en-GB.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,3 +1310,5 @@ en-GB:
13101310
STR_DISPLAY_OPTIONS_CONFIRM: "Do you want to keep the current display options?"
13111311
STR_DISPLAY_OPTIONS_REVERT: "Reverting in 0:{0}"
13121312
STR_MISSING_CONTENT_PROMPT: "WARNING:{SMALLLINE}This save relies on mods that are unavailable. Missing content will be removed, and it may fail to load.{NEWLINE}Continue?"
1313+
STR_INCLUDE_PRIMESTATE_IN_SAVED_LAYOUT: "Include prime-state in the saved equipment-layout"
1314+
STR_INCLUDE_PRIMESTATE_IN_SAVED_LAYOUT_DESC: "Save and load back the prime-states of the grenades in the equipment-layouts along with the items."

bin/data/Language/en-US.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,3 +1310,5 @@ en-US:
13101310
STR_DISPLAY_OPTIONS_CONFIRM: "Do you want to keep the current display options?"
13111311
STR_DISPLAY_OPTIONS_REVERT: "Reverting in 0:{0}"
13121312
STR_MISSING_CONTENT_PROMPT: "WARNING:{SMALLLINE}This save relies on mods that are unavailable. Missing content will be removed, and it may fail to load.{NEWLINE}Continue?"
1313+
STR_INCLUDE_PRIMESTATE_IN_SAVED_LAYOUT: "Include prime-state in the saved equipment-layout"
1314+
STR_INCLUDE_PRIMESTATE_IN_SAVED_LAYOUT_DESC: "Save and load back the prime-states of the grenades in the equipment-layouts along with the items."

src/Battlescape/BattlescapeGenerator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,7 @@ bool BattlescapeGenerator::placeItemByLayout(BattleItem *item)
884884
item->setSlot(_game->getRuleset()->getInventory((*j)->getSlot()));
885885
item->setSlotX((*j)->getSlotX());
886886
item->setSlotY((*j)->getSlotY());
887+
if (Options::includePrimeStateInSavedLayout) item->setFuseTimer((*j)->getFuseTimer());
887888
_save->getItems()->push_back(item);
888889
return true;
889890
}

src/Battlescape/Inventory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ void Inventory::mouseClick(Action *action, State *state)
682682
{
683683
if (_selItem == 0)
684684
{
685-
if (!_base)
685+
if (!_base || Options::includePrimeStateInSavedLayout)
686686
{
687687
if (!_tu)
688688
{

src/Battlescape/InventoryState.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@ void InventoryState::saveEquipmentLayout()
340340
(*j)->getSlot()->getId(),
341341
(*j)->getSlotX(),
342342
(*j)->getSlotY(),
343-
ammo
343+
ammo,
344+
(*j)->getFuseTimer()
344345
));
345346
}
346347
}

src/Engine/Options.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ void create()
127127
_info.push_back(OptionInfo("globeScrollDragButton", &globeScrollDragButton, SDL_BUTTON_MIDDLE));
128128

129129
// advanced options
130+
_info.push_back(OptionInfo("includePrimeStateInSavedLayout", &includePrimeStateInSavedLayout, false, "STR_INCLUDE_PRIMESTATE_IN_SAVED_LAYOUT", "STR_BATTLESCAPE"));
130131
_info.push_back(OptionInfo("playIntro", &playIntro, true, "STR_PLAYINTRO", "STR_GENERAL"));
131132
_info.push_back(OptionInfo("autosave", &autosave, 0, "STR_AUTOSAVE", "STR_GENERAL"));
132133
_info.push_back(OptionInfo("newSeedOnLoad", &newSeedOnLoad, false, "STR_NEWSEEDONLOAD", "STR_GENERAL"));

src/Engine/Options.inc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ OPT SDLKey keyOk, keyCancel, keyScreenshot, keyFps, keyQuickLoad, keyQuickSave;
1616

1717
// Geoscape options
1818
OPT int geoClockSpeed, dogfightSpeed, globeScrollSpeed, globeScrollDragButton;
19-
OPT bool anytimePsiTraining, weaponSelfDestruction, spendResearchedItems, craftLaunchAlways, globeSeasons, globeDetail, globeRadarLines, globeFlightPaths, globeAllRadarsOnBaseBuild,
19+
OPT bool includePrimeStateInSavedLayout, anytimePsiTraining, weaponSelfDestruction, spendResearchedItems, craftLaunchAlways, globeSeasons, globeDetail, globeRadarLines, globeFlightPaths, globeAllRadarsOnBaseBuild,
2020
alienContainmentLimitEnforced, canSellLiveAliens, canTransferCraftsWhileAirborne, canManufactureMoreItemsPerHour, customInitialBase, aggressiveRetaliation,
2121
allowBuildingQueue, allowAutoSellProduction, showFundsOnGeoscape, psiStrengthEval;
2222
OPT SDLKey keyGeoLeft, keyGeoRight, keyGeoUp, keyGeoDown, keyGeoZoomIn, keyGeoZoomOut, keyGeoSpeed1, keyGeoSpeed2, keyGeoSpeed3, keyGeoSpeed4, keyGeoSpeed5, keyGeoSpeed6,

src/Savegame/EquipmentLayoutItem.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ namespace OpenXcom
2727
*/
2828
EquipmentLayoutItem::EquipmentLayoutItem(const YAML::Node &node)
2929
{
30+
_fuseTimer = -1; // for compatibility
3031
load(node);
3132
}
3233

@@ -37,9 +38,9 @@ EquipmentLayoutItem::EquipmentLayoutItem(const YAML::Node &node)
3738
* @param slotX Position-X in the occupied slot.
3839
* @param slotY Position-Y in the occupied slot.
3940
* @param ammoItem The ammo has to be loaded into the item. (it's type)
40-
* @param explodeTurn The turn when the item explodes. (if it's an activated grenade-type)
41+
* @param fuseTimer The turn until explosion of the item. (if it's an activated grenade-type)
4142
*/
42-
EquipmentLayoutItem::EquipmentLayoutItem(std::string itemType, std::string slot, int slotX, int slotY, std::string ammoItem) : _itemType(itemType), _slot(slot), _slotX(slotX), _slotY(slotY), _ammoItem(ammoItem)
43+
EquipmentLayoutItem::EquipmentLayoutItem(std::string itemType, std::string slot, int slotX, int slotY, std::string ammoItem, int fuseTimer) : _itemType(itemType), _slot(slot), _slotX(slotX), _slotY(slotY), _ammoItem(ammoItem), _fuseTimer(fuseTimer)
4344
{
4445
}
4546

@@ -95,6 +96,15 @@ std::string EquipmentLayoutItem::getAmmoItem() const
9596
return _ammoItem;
9697
}
9798

99+
/**
100+
* Returns the turn until explosion of the item. (if it's an activated grenade-type)
101+
* @return turn count.
102+
*/
103+
int EquipmentLayoutItem::getFuseTimer() const
104+
{
105+
return _fuseTimer;
106+
}
107+
98108
/**
99109
* Loads the soldier-equipment layout item from a YAML file.
100110
* @param node YAML node.
@@ -106,6 +116,7 @@ void EquipmentLayoutItem::load(const YAML::Node &node)
106116
_slotX = node["slotX"].as<int>(_slotX);
107117
_slotY = node["slotY"].as<int>(_slotY);
108118
_ammoItem = node["ammoItem"].as<std::string>(_ammoItem);
119+
_fuseTimer = node["fuseTimer"].as<int>(_fuseTimer);
109120
}
110121

111122
/**
@@ -120,6 +131,7 @@ YAML::Node EquipmentLayoutItem::save() const
120131
node["slotX"] = _slotX;
121132
node["slotY"] = _slotY;
122133
node["ammoItem"] = _ammoItem;
134+
node["fuseTimer"] = _fuseTimer;
123135
return node;
124136
}
125137

src/Savegame/EquipmentLayoutItem.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ class EquipmentLayoutItem
3636
std::string _slot;
3737
int _slotX, _slotY;
3838
std::string _ammoItem;
39+
int _fuseTimer;
3940
public:
4041
/// Creates a new soldier-equipment layout item and loads its contents from YAML.
4142
EquipmentLayoutItem(const YAML::Node& node);
4243
/// Creates a new soldier-equipment layout item.
43-
EquipmentLayoutItem(std::string itemType, std::string slot, int slotX, int slotY, std::string ammoItem);
44+
EquipmentLayoutItem(std::string itemType, std::string slot, int slotX, int slotY, std::string ammoItem, int fuseTimer);
4445
/// Cleans up the soldier-equipment layout item.
4546
~EquipmentLayoutItem();
4647
/// Gets the item's type which has to be in a slot
@@ -53,6 +54,8 @@ class EquipmentLayoutItem
5354
int getSlotY() const;
5455
/// Gets the ammo item
5556
std::string getAmmoItem() const;
57+
/// Gets the turn until explosion
58+
int getFuseTimer() const;
5659
/// Loads the soldier-equipment layout item from YAML.
5760
void load(const YAML::Node& node);
5861
/// Saves the soldier-equipment layout item to YAML.

0 commit comments

Comments
 (0)