Skip to content

Commit

Permalink
Change: Default to true for PlayOnShow / PlayOnHide
Browse files Browse the repository at this point in the history
  • Loading branch information
leezer3 committed Jan 24, 2025
1 parent 6fd6c67 commit cba2e84
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
8 changes: 7 additions & 1 deletion source/Plugins/Formats.OpenBve/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ public virtual bool TryGetValue(T2 key, ref string value)
return false;
}

/// <summary>Unconditionally reads the specified Vector2 from the block</summary>
/// <summary>Reads the specified bool from the block, preserving the prior value if not present</summary>
public virtual bool TryGetValue(T2 key, ref bool boolValue)
{
return false;
}

/// <summary>Unconditionally reads the specified Vector2 from the block</summary>
public virtual bool GetVector2(T2 key, char separator, out Vector2 value)
{
value = Vector2.Null;
Expand Down
14 changes: 14 additions & 0 deletions source/Plugins/Formats.OpenBve/CFG/ConfigFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,20 @@ public override bool TryGetValue(T2 key, ref string stringValue)
return false;
}

public override bool TryGetValue(T2 key, ref bool boolValue)
{
if (keyValuePairs.TryRemove(key, out var s))
{
var ss = s.Value.ToLowerInvariant().Trim();
if (ss == "1" || ss == "true")
{
boolValue = true;
return true;
}
}
return false;
}

public override bool GetValue(T2 key, out string stringValue)
{
if (keyValuePairs.TryRemove(key, out var value))
Expand Down
5 changes: 3 additions & 2 deletions source/Plugins/Object.Animated/Plugin.Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,9 @@ private static AnimatedObjectCollection ReadObject(string FileName, System.Text.
Block.TryGetValue(AnimatedKey.Pitch, ref pitch);
Block.TryGetValue(AnimatedKey.Volume, ref volume);
Block.TryGetValue(AnimatedKey.Radius, ref radius);
Block.GetValue(AnimatedKey.PlayOnShow, out bool playOnShow);
Block.GetValue(AnimatedKey.PlayOnHide, out bool playOnHide);
bool playOnShow = true, playOnHide = true;
Block.TryGetValue(AnimatedKey.PlayOnShow, ref playOnShow);
Block.TryGetValue(AnimatedKey.PlayOnHide, ref playOnHide);

if (ObjectCount > 0)
{
Expand Down

0 comments on commit cba2e84

Please sign in to comment.