Implement "Game Saved" / "Game Loaded" notifications in RA and D2k.

This commit is contained in:
Paul Chote
2019-04-20 10:35:20 +00:00
committed by reaperrr
parent 492b5aec82
commit d5588c51ed
5 changed files with 27 additions and 4 deletions

View File

@@ -19,10 +19,16 @@ namespace OpenRA.Mods.Common.Traits
[NotificationReference("Speech")] [NotificationReference("Speech")]
public readonly string Notification = "StartGame"; public readonly string Notification = "StartGame";
[NotificationReference("Speech")]
public readonly string LoadedNotification = "GameLoaded";
[NotificationReference("Speech")]
public readonly string SavedNotification = "GameSaved";
public object Create(ActorInitializer init) { return new StartGameNotification(this); } public object Create(ActorInitializer init) { return new StartGameNotification(this); }
} }
class StartGameNotification : IWorldLoaded class StartGameNotification : IWorldLoaded, INotifyGameLoaded, INotifyGameSaved
{ {
StartGameNotificationInfo info; StartGameNotificationInfo info;
public StartGameNotification(StartGameNotificationInfo info) public StartGameNotification(StartGameNotificationInfo info)
@@ -35,5 +41,17 @@ namespace OpenRA.Mods.Common.Traits
if (!world.IsLoadingGameSave) if (!world.IsLoadingGameSave)
Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", info.Notification, world.RenderPlayer == null ? null : world.RenderPlayer.Faction.InternalName); Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", info.Notification, world.RenderPlayer == null ? null : world.RenderPlayer.Faction.InternalName);
} }
void INotifyGameLoaded.GameLoaded(World world)
{
if (!world.IsReplay)
Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", info.LoadedNotification, world.RenderPlayer == null ? null : world.RenderPlayer.Faction.InternalName);
}
void INotifyGameSaved.GameSaved(World world)
{
if (!world.IsReplay)
Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", info.SavedNotification, world.RenderPlayer == null ? null : world.RenderPlayer.Faction.InternalName);
}
} }
} }

View File

@@ -39,7 +39,9 @@ Speech:
Repairing: repair1 Repairing: repair1
SelectTarget: select1 SelectTarget: select1
SilosNeeded: silos1 SilosNeeded: silos1
StartGame: StartGame:
GameLoaded:
GameSaved: scold1
Training: bldging1 Training: bldging1
UnitDestroyed: dead1 UnitDestroyed: dead1
UnitLost: unitlost UnitLost: unitlost

View File

@@ -233,6 +233,7 @@ World:
PanelName: SKIRMISH_STATS PanelName: SKIRMISH_STATS
LoadWidgetAtGameStart: LoadWidgetAtGameStart:
ScriptTriggers: ScriptTriggers:
StartGameNotification:
EditorWorld: EditorWorld:
Inherits: ^BaseWorld Inherits: ^BaseWorld

View File

@@ -53,8 +53,6 @@ Speech:
MercenaryRescued: mercr1 MercenaryRescued: mercr1
MissionAccomplished: misnwon1 MissionAccomplished: misnwon1
MissionFailed: misnlst1 MissionFailed: misnlst1
MissionLoaded: load1
MissionSaved: save1
MissionTimerInitialised: mtimein1 MissionTimerInitialised: mtimein1
NavalUnitLost: navylst1 NavalUnitLost: navylst1
NewOptions: newopt1 NewOptions: newopt1
@@ -85,6 +83,8 @@ Speech:
SovietReinforcementsArrived: sovrein1 SovietReinforcementsArrived: sovrein1
SpyPlaneReady: spypln1 SpyPlaneReady: spypln1
StartGame: bctrinit StartGame: bctrinit
GameLoaded: load1
GameSaved: save1
StructureDestroyed: strckil1 StructureDestroyed: strckil1
StructureSold: strusld1 StructureSold: strusld1
TanyaFreed: tanyaf1 TanyaFreed: tanyaf1

View File

@@ -64,6 +64,8 @@ Speech:
SpyKilledMissionFailed: 01-n284 SpyKilledMissionFailed: 01-n284
SpyLostMissionFailed: 01-n210 SpyLostMissionFailed: 01-n210
StartGame: 00-i200 StartGame: 00-i200
GameLoaded: 00-i200
GameSaved:
StructureSold: 00-i228 StructureSold: 00-i228
SubterraneanUnitDetected: 00-i174 SubterraneanUnitDetected: 00-i174
TertiaryObjectiveAchieved: 00-i104 TertiaryObjectiveAchieved: 00-i104