Skip to content

Commit

Permalink
Editor: hotfix for deprecated Room.SaveLoadEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-mogilko committed Oct 24, 2023
1 parent 2bc7631 commit fc5cec3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 25 deletions.
16 changes: 2 additions & 14 deletions Editor/AGS.Editor.Tests/Types/RoomTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,6 @@ public void GetsAndSetsBackgroundAnimationDelay(int backgroundAnimationDelay)
Assert.That(_room.BackgroundAnimationDelay, Is.EqualTo(backgroundAnimationDelay));
}

[TestCase(false)]
[TestCase(true)]
public void GetsAndSetsSaveLoadEnabled(bool saveLoadEnabled)
{
_room.SaveLoadEnabled = saveLoadEnabled;
Assert.That(_room.SaveLoadEnabled, Is.EqualTo(saveLoadEnabled));
}

[TestCase(false)]
[TestCase(true)]
public void GetsAndSetsShowPlayerCharacter(bool showPlayerCharacter)
Expand Down Expand Up @@ -186,7 +178,7 @@ public void GetsMaskScaleThrowsExceptionWithIllegalMask()
[TestCase(1, 2, 1174750494, 320, 240, 5, true, false, 1, 1, 2, 3, 4, 2, "description1")]
[TestCase(2, 1, 1174750495, 640, 480, 4, false, true, 0, 2, 3, 4, 5, 3, "description2")]
public void DeserializesFromXml(int maskResolution, int backgroundCount, int gameId, int width, int height,
int backgroundAnimationDelay, bool saveLoadEnabled, bool showPlayerCharacter,
int backgroundAnimationDelay, bool showPlayerCharacter,
int playerCharacterView, int leftEdgeX, int rightEdgeX,
int topEdgeY, int bottomEdgeY, int number, string description)
{
Expand All @@ -198,7 +190,6 @@ public void DeserializesFromXml(int maskResolution, int backgroundCount, int gam
<Width>{width}</Width>
<Height>{height}</Height>
<BackgroundAnimationDelay>{backgroundAnimationDelay}</BackgroundAnimationDelay>
<SaveLoadEnabled>{saveLoadEnabled}</SaveLoadEnabled>
<ShowPlayerCharacter>{showPlayerCharacter}</ShowPlayerCharacter>
<PlayerCharacterView>{playerCharacterView}</PlayerCharacterView>
<LeftEdgeX>{leftEdgeX}</LeftEdgeX>
Expand Down Expand Up @@ -239,7 +230,6 @@ public void DeserializesFromXml(int maskResolution, int backgroundCount, int gam
Assert.That(_room.Width, Is.EqualTo(width));
Assert.That(_room.Height, Is.EqualTo(height));
Assert.That(_room.BackgroundAnimationDelay, Is.EqualTo(backgroundAnimationDelay));
Assert.That(_room.SaveLoadEnabled, Is.EqualTo(saveLoadEnabled));
Assert.That(_room.ShowPlayerCharacter, Is.EqualTo(showPlayerCharacter));
Assert.That(_room.PlayerCharacterView, Is.EqualTo(playerCharacterView));
Assert.That(_room.LeftEdgeX, Is.EqualTo(leftEdgeX));
Expand All @@ -265,7 +255,7 @@ public void DeserializesFromXml(int maskResolution, int backgroundCount, int gam
[TestCase(1, 2, 1174750494, 320, 240, 5, true, false, 1, 1, 2, 3, 4, 2, "description1")]
[TestCase(2, 1, 1174750495, 640, 480, 4, false, true, 0, 2, 3, 4, 5, 3, "description2")]
public void SerializesToXml(int maskResolution, int backgroundCount, int gameId, int width, int height,
int backgroundAnimationDelay, bool saveLoadEnabled, bool showPlayerCharacter,
int backgroundAnimationDelay, bool showPlayerCharacter,
int playerCharacterView, int leftEdgeX, int rightEdgeX,
int topEdgeY, int bottomEdgeY, int number, string description)
{
Expand All @@ -275,7 +265,6 @@ public void SerializesToXml(int maskResolution, int backgroundCount, int gameId,
_room.Width = width;
_room.Height = height;
_room.BackgroundAnimationDelay = backgroundAnimationDelay;
_room.SaveLoadEnabled = saveLoadEnabled;
_room.ShowPlayerCharacter = showPlayerCharacter;
_room.PlayerCharacterView = playerCharacterView;
_room.LeftEdgeX = leftEdgeX;
Expand All @@ -296,7 +285,6 @@ public void SerializesToXml(int maskResolution, int backgroundCount, int gameId,
Assert.That(doc.SelectSingleNode("/Room/Width").InnerText, Is.EqualTo(width.ToString()));
Assert.That(doc.SelectSingleNode("/Room/Height").InnerText, Is.EqualTo(height.ToString()));
Assert.That(doc.SelectSingleNode("/Room/BackgroundAnimationDelay").InnerText, Is.EqualTo(backgroundAnimationDelay.ToString()));
Assert.That(doc.SelectSingleNode("/Room/SaveLoadEnabled").InnerText, Is.EqualTo(saveLoadEnabled.ToString()));
Assert.That(doc.SelectSingleNode("/Room/ShowPlayerCharacter").InnerText, Is.EqualTo(showPlayerCharacter.ToString()));
Assert.That(doc.SelectSingleNode("/Room/PlayerCharacterView").InnerText, Is.EqualTo(playerCharacterView.ToString()));
Assert.That(doc.SelectSingleNode("/Room/LeftEdgeX").InnerText, Is.EqualTo(leftEdgeX.ToString()));
Expand Down
11 changes: 1 addition & 10 deletions Editor/AGS.Editor/Components/RoomsComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -928,16 +928,7 @@ private bool HandleObsoleteSettings(Room room, CompileMessages errors)
{
#pragma warning disable 0612
bool scriptModified = false;
if (!room.SaveLoadEnabled)
{
// Simply add a warning in script comments, to let user know that something may be missing
room.Script.Text = string.Format("{0}{1}{2}{3}{4}{5}{6}{7}",
"// WARNING: this Room had a \"Save/Load disabled\" setting, which is now deprecated,", Environment.NewLine,
"// and so it was removed during upgrade. If you like to restore this behavior,", Environment.NewLine,
"// you would have to implement it in script. (This warning is safe to remove)", Environment.NewLine, Environment.NewLine,
room.Script.Text);
room.SaveLoadEnabled = true;
}
// Add operations here as necessary
return scriptModified;
#pragma warning restore 0612
}
Expand Down
2 changes: 1 addition & 1 deletion Editor/AGS.Types/Room.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public bool BackgroundAnimationEnabled

[Obsolete]
[Browsable(false)]
// NOTE: have to keep setter here because we load old rooms before upgrading them
// TODO: check if it's okay to adjust ILoadedRoom interface and let remove the setter here
public bool SaveLoadEnabled { get; set; }

[Description("Whether the player character is visible on this screen")]
Expand Down

0 comments on commit fc5cec3

Please sign in to comment.