Silence autosave audio notification

This commit is contained in:
Gustas
2026-02-22 15:45:22 +02:00
committed by Paul Chote
parent 413aa00ce6
commit 5c51f458f2
8 changed files with 17 additions and 9 deletions

View File

@@ -269,6 +269,11 @@ namespace OpenRA
return new Order(order, null, false) { IsImmediate = isImmediate, TargetString = targetString }; return new Order(order, null, false) { IsImmediate = isImmediate, TargetString = targetString };
} }
public static Order FromTargetString(string order, string targetString, bool isImmediate, uint extraData)
{
return new Order(order, null, false) { IsImmediate = isImmediate, TargetString = targetString, ExtraData = extraData };
}
public static Order FromGroupedOrder(Order grouped, Actor subject) public static Order FromGroupedOrder(Order grouped, Actor subject)
{ {
return new Order( return new Order(

View File

@@ -211,7 +211,7 @@ namespace OpenRA.Network
case "GameSaved": case "GameSaved":
foreach (var nsr in orderManager.World.WorldActor.TraitsImplementing<INotifyGameSaved>()) foreach (var nsr in orderManager.World.WorldActor.TraitsImplementing<INotifyGameSaved>())
nsr.GameSaved(orderManager.World); nsr.GameSaved(orderManager.World, order.ExtraData != 0);
break; break;
case "PauseGame": case "PauseGame":

View File

@@ -1056,7 +1056,7 @@ namespace OpenRA.Server
Directory.CreateDirectory(baseSavePath); Directory.CreateDirectory(baseSavePath);
GameSave.Save(Path.Combine(baseSavePath, filename)); GameSave.Save(Path.Combine(baseSavePath, filename));
DispatchServerOrdersToClients(Order.FromTargetString("GameSaved", filename, true)); DispatchServerOrdersToClients(Order.FromTargetString("GameSaved", filename, true, o.ExtraData));
} }
break; break;

View File

@@ -373,7 +373,7 @@ namespace OpenRA.Traits
public interface IPostWorldLoaded { void PostWorldLoaded(World w, WorldRenderer wr); } public interface IPostWorldLoaded { void PostWorldLoaded(World w, WorldRenderer wr); }
public interface INotifyGameLoading { void GameLoading(World w); } public interface INotifyGameLoading { void GameLoading(World w); }
public interface INotifyGameLoaded { void GameLoaded(World w); } public interface INotifyGameLoaded { void GameLoaded(World w); }
public interface INotifyGameSaved { void GameSaved(World w); } public interface INotifyGameSaved { void GameSaved(World w, bool isAutoSave); }
public interface IGameSaveTraitData public interface IGameSaveTraitData
{ {

View File

@@ -562,7 +562,7 @@ namespace OpenRA
} }
} }
public void RequestGameSave(string filename) public void RequestGameSave(string filename, bool isAutosave)
{ {
// Allow traits to save arbitrary data that will be passed back via IGameSaveTraitData.ResolveTraitData // Allow traits to save arbitrary data that will be passed back via IGameSaveTraitData.ResolveTraitData
// at the end of the save restoration // at the end of the save restoration
@@ -580,7 +580,8 @@ namespace OpenRA
i++; i++;
} }
IssueOrder(Order.FromTargetString("CreateGameSave", filename, true)); var extraData = isAutosave ? 1u : 0u;
IssueOrder(Order.FromTargetString("CreateGameSave", filename, true, extraData));
} }
public bool Disposing; public bool Disposing;

View File

@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Traits
var dateTime = DateTime.UtcNow.ToString("yyyy-MM-ddTHHmmssZ", CultureInfo.InvariantCulture); var dateTime = DateTime.UtcNow.ToString("yyyy-MM-ddTHHmmssZ", CultureInfo.InvariantCulture);
var fileName = $"{AutoSavePattern}{dateTime}{SaveFileExtension}"; var fileName = $"{AutoSavePattern}{dateTime}{SaveFileExtension}";
self.World.RequestGameSave(fileName); self.World.RequestGameSave(fileName, true);
ticksUntilAutoSave = GetTicksBetweenAutosaves(self); ticksUntilAutoSave = GetTicksBetweenAutosaves(self);
} }

View File

@@ -64,11 +64,13 @@ namespace OpenRA.Mods.Common.Traits
} }
} }
void INotifyGameSaved.GameSaved(World world) void INotifyGameSaved.GameSaved(World world, bool isAutosave)
{ {
if (!world.IsReplay) if (!world.IsReplay)
{ {
Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", info.SavedNotification, world.RenderPlayer?.Faction.InternalName); if (!isAutosave)
Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", info.SavedNotification, world.RenderPlayer?.Faction.InternalName);
TextNotificationsManager.AddTransientLine(null, info.SavedTextNotification); TextNotificationsManager.AddTransientLine(null, info.SavedTextNotification);
} }
} }

View File

@@ -377,7 +377,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
void Inner() void Inner()
{ {
world.RequestGameSave(filename); world.RequestGameSave(filename, false);
Ui.CloseWindow(); Ui.CloseWindow();
onExit(); onExit();
} }