Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions Core/GDCore/Extensions/Builtin/CommonInstructionsExtension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,47 @@ BuiltinExtensionsImplementer::ImplementsCommonInstructionsExtension(
.AddCondition(
"Or",
_("Or"),
_("Checks if at least one sub-condition is true. If no "
"sub-condition is specified, it will always be false. "
"This is rarely used — multiple events and sub-events are "
"usually a better approach."),
_("True if at least one sub-condition is true.\n\n"
"Picked objects: the action only sees objects picked by a "
"true branch. Objects mentioned only by false branches end "
"up with no selection.\n\n"
"Use this when the action acts on the specific object whose "
"condition was tested.\n"
"Example: \"Door collided with Player OR Coin collided with "
"Player\" → hide the touched object. (When the Door branch "
"fires, the Door and Player from that collision are picked; "
"the Coin is not selected, so an action on Coin does "
"nothing.)"),
_("If one of these conditions is true:"),
"",
"res/conditions/or24_black.png",
"res/conditions/or_black.png")
.SetCanHaveSubInstructions()
.MarkAsAdvanced();

extension
.AddCondition(
"OrDistributive",
_("Or (independent object picking)"),
_("True if at least one sub-condition is true.\n\n"
"Picked objects stay the same as before the Or, unless a "
"true branch explicitly filters them. A true branch that "
"does not reference an object leaves that object's "
"selection alone.\n\n"
"Use this when the action acts on an object that some "
"branches do not mention.\n"
"Example: \"Text input is submitted OR Submit button is "
"clicked\" → set a variable to the text input's value. "
"(The button branch doesn't pick the text input; with the "
"regular Or the input would no longer be selected.)"),
_("If one of these conditions is true (independent object "
"picking):"),
"",
"res/conditions/or24_black.png",
"res/conditions/or_black.png")
.SetCanHaveSubInstructions()
.MarkAsAdvanced();

extension
.AddCondition(
"And",
Expand Down
19 changes: 19 additions & 0 deletions Core/GDCore/Project/Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Project::Project()
projectUuid(""),
useDeprecatedZeroAsDefaultZOrder(false),
useDeprecatedZeroAsDefaultStringVariable(false),
useDeprecatedOrConditionPicking(false),
isPlayableWithKeyboard(false),
isPlayableWithGamepad(false),
isPlayableWithMobile(false),
Expand Down Expand Up @@ -803,6 +804,17 @@ void Project::UnserializeFrom(const SerializerElement& element) {
}
// end of compatibility code

// Compatibility with GD <= 5.6.268
if (VersionWrapper::IsOlderOrEqual(
gdMajorVersion, gdMinorVersion, gdBuildVersion, 0, 5, 6, 268, 0) &&
!propElement.HasAttribute("useDeprecatedOrConditionPicking")) {
useDeprecatedOrConditionPicking = true;
} else {
useDeprecatedOrConditionPicking = propElement.GetBoolAttribute(
"useDeprecatedOrConditionPicking", false);
}
// end of compatibility code

// Compatibility with GD <= 5.0.0-beta101
if (!propElement.HasAttribute("projectUuid") &&
!propElement.HasChild("projectUuid")) {
Expand Down Expand Up @@ -1174,6 +1186,12 @@ void Project::SerializeTo(SerializerElement& element) const {
}
// end of compatibility code

// Compatibility with GD <= 5.6.268
if (useDeprecatedOrConditionPicking) {
propElement.SetAttribute("useDeprecatedOrConditionPicking", true);
}
// end of compatibility code

extensionProperties.SerializeTo(propElement.AddChild("extensionProperties"));

SerializerElement& platformsElement = propElement.AddChild("platforms");
Expand Down Expand Up @@ -1305,6 +1323,7 @@ void Project::Init(const gd::Project& game) {
useDeprecatedZeroAsDefaultZOrder = game.useDeprecatedZeroAsDefaultZOrder;
useDeprecatedZeroAsDefaultStringVariable =
game.useDeprecatedZeroAsDefaultStringVariable;
useDeprecatedOrConditionPicking = game.useDeprecatedOrConditionPicking;

author = game.author;
authorIds = game.authorIds;
Expand Down
27 changes: 27 additions & 0 deletions Core/GDCore/Project/Project.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,25 @@ class GD_CORE_API Project {
useDeprecatedZeroAsDefaultStringVariable = enable;
}

/**
* \brief Check if the project should use the deprecated "Or" condition
* object-picking semantics (the pre-5.6.269 behavior, in which the Or
* unconditionally overwrote the parent event's picked object lists with
* the union of branch contributions, including when no branch actually
* contributed for a given object — wiping outside-Or picks).
*/
bool GetUseDeprecatedOrConditionPicking() const {
return useDeprecatedOrConditionPicking;
}

/**
* \brief Set whether the project should use the deprecated "Or" condition
* object-picking semantics (the pre-5.6.269 behavior).
*/
void SetUseDeprecatedOrConditionPicking(bool enable) {
useDeprecatedOrConditionPicking = enable;
}

/**
* \brief Change the project UUID.
*/
Expand Down Expand Up @@ -1147,6 +1166,14 @@ class GD_CORE_API Project {
///< no stored value default to "0"
///< at runtime (behavior before
///< 5.6.267).
bool useDeprecatedOrConditionPicking =
false; ///< If true, the "Or" condition uses
///< the pre-5.6.269 picking semantics
///< (always overwrite parent's picked
///< list with the union of branch
///< contributions, even when no branch
///< contributed for a given object —
///< wiping outside-Or picks).
std::vector<std::unique_ptr<gd::Layout> > scenes; ///< List of all scenes
gd::VariablesContainer variables; ///< Initial global variables
gd::ObjectsContainer objectsContainer;
Expand Down
Loading
Loading