Skip to content

Commit

Permalink
Option to follow the wing leader or not
Browse files Browse the repository at this point in the history
  • Loading branch information
MeridianOXC committed Jan 14, 2024
1 parent 3e244b4 commit fe4f8cf
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions bin/common/Language/OXCE/en-GB.yml
Expand Up @@ -419,6 +419,7 @@ en-GB:
STR_STARTING_CONDITION_SOLDIER_TYPE_FORBIDDEN: "Some soldiers cannot participate in this mission.{NEWLINE}{NEWLINE}Forbidden soldier types: {0}"
STR_STARTING_CONDITION_ITEM: "This mission requires specific item(s):{NEWLINE}{NEWLINE}{0}"
STR_NOT_ENOUGH_FUEL_TO_REACH_TARGET: "NOT ENOUGH FUEL!{SMALLLINE}The destination is too far for the range of the craft."
STR_FOLLOW_WING_LEADER_QUESTION: "Follow wing leader?"
#CraftNotEnoughPilotsState.cpp
STR_ASSIGN_PILOTS: "Assign pilots..."
STR_NOT_ENOUGH_PILOTS: "Not enough pilots!{NEWLINE}Minimum: {0}"
Expand Down
1 change: 1 addition & 0 deletions bin/common/Language/OXCE/en-US.yml
Expand Up @@ -419,6 +419,7 @@ en-US:
STR_STARTING_CONDITION_SOLDIER_TYPE_FORBIDDEN: "Some soldiers cannot participate in this mission.{NEWLINE}{NEWLINE}Forbidden soldier types: {0}"
STR_STARTING_CONDITION_ITEM: "This mission requires specific item(s):{NEWLINE}{NEWLINE}{0}"
STR_NOT_ENOUGH_FUEL_TO_REACH_TARGET: "NOT ENOUGH FUEL!{SMALLLINE}The destination is too far for the range of the craft."
STR_FOLLOW_WING_LEADER_QUESTION: "Follow wing leader?"
#CraftNotEnoughPilotsState.cpp
STR_ASSIGN_PILOTS: "Assign pilots..."
STR_NOT_ENOUGH_PILOTS: "Not enough pilots!{NEWLINE}Minimum: {0}"
Expand Down
30 changes: 29 additions & 1 deletion src/Geoscape/ConfirmDestinationState.cpp
Expand Up @@ -33,6 +33,7 @@
#include "../Interface/Window.h"
#include "../Interface/Text.h"
#include "../Interface/TextButton.h"
#include "../Interface/ToggleTextButton.h"
#include "../Savegame/SavedGame.h"
#include "../Savegame/Craft.h"
#include "../Savegame/Target.h"
Expand Down Expand Up @@ -75,6 +76,7 @@ ConfirmDestinationState::ConfirmDestinationState(std::vector<Craft*> crafts, Tar
_btnOk = new TextButton(50, 12, btnOkX, 104);
_btnTransfer = new TextButton(82, 12, 87, 104);
_btnCancel = new TextButton(50, 12, btnCancelX, 104);
_btnFollowWingLeader = new ToggleTextButton(170, 16, 43, 138);
_txtTarget = new Text(232, 32, 12, 72);
_txtETA = new Text(232, 9, 12, 120);

Expand All @@ -85,6 +87,7 @@ ConfirmDestinationState::ConfirmDestinationState(std::vector<Craft*> crafts, Tar
add(_btnOk, "button", "confirmDestination");
add(_btnCancel, "button", "confirmDestination");
add(_btnTransfer, "button", "confirmDestination");
add(_btnFollowWingLeader, "button", "confirmDestination");
add(_txtTarget, "text", "confirmDestination");
add(_txtETA, "text", "confirmDestination");

Expand All @@ -105,6 +108,24 @@ ConfirmDestinationState::ConfirmDestinationState(std::vector<Craft*> crafts, Tar
_btnCancel->onMouseClick((ActionHandler)&ConfirmDestinationState::btnCancelClick);
_btnCancel->onKeyboardPress((ActionHandler)&ConfirmDestinationState::btnCancelClick, Options::keyCancel);

_btnFollowWingLeader->setText(tr("STR_FOLLOW_WING_LEADER_QUESTION"));
_btnFollowWingLeader->setVisible(false);

if (_crafts.size() > 1)
{
_btnFollowWingLeader->setVisible(true);

Ufo* u = dynamic_cast<Ufo*>(_target);
if (u && u->getStatus() == Ufo::FLYING)
{
_btnFollowWingLeader->setPressed(false); // everybody go for the UFO as quickly as possible
}
else
{
_btnFollowWingLeader->setPressed(true); // follow the wing leader please
}
}

_txtTarget->setBig();
_txtTarget->setAlign(ALIGN_CENTER);
_txtTarget->setVerticalAlign(ALIGN_MIDDLE);
Expand Down Expand Up @@ -341,7 +362,14 @@ void ConfirmDestinationState::btnOkClick(Action *)
{
if (craft != _crafts.front())
{
craft->setDestination(_crafts.front());
if (_btnFollowWingLeader->getPressed())
{
craft->setDestination(_crafts.front()); // follow the wing leader
}
else
{
craft->setDestination(_target); // go for the same target as the wing leader
}
}

if (craft->getRules()->canAutoPatrol())
Expand Down
2 changes: 2 additions & 0 deletions src/Geoscape/ConfirmDestinationState.h
Expand Up @@ -25,6 +25,7 @@ namespace OpenXcom
class Window;
class Text;
class TextButton;
class ToggleTextButton;
class Craft;
class Target;

Expand All @@ -41,6 +42,7 @@ class ConfirmDestinationState : public State
Text *_txtTarget;
Text *_txtETA;
TextButton *_btnOk, *_btnTransfer, *_btnCancel;
ToggleTextButton *_btnFollowWingLeader;
// Checks the starting condition
std::string checkStartingCondition();
public:
Expand Down

0 comments on commit fe4f8cf

Please sign in to comment.