diff --git a/OpenRA.Game/GameRules/Settings.cs b/OpenRA.Game/GameRules/Settings.cs index 4bbc9cdb19..1c1bf93213 100644 --- a/OpenRA.Game/GameRules/Settings.cs +++ b/OpenRA.Game/GameRules/Settings.cs @@ -19,6 +19,9 @@ using OpenRA.Server; namespace OpenRA.GameRules { + public enum MouseScrollType { Disabled, Standard, Inverted } + public enum SoundCashTicks { Disabled, Normal, Extreme } + public class ServerSettings { public string Name = "OpenRA Game"; @@ -77,6 +80,8 @@ namespace OpenRA.GameRules public bool Repeat = false; public bool ShellmapMusic = true; public string Engine = "AL"; + + public SoundCashTicks SoundCashTickType = SoundCashTicks.Extreme; } public class PlayerSettings @@ -86,8 +91,6 @@ namespace OpenRA.GameRules public string LastServer = "localhost:1234"; } - public enum MouseScrollType { Disabled, Standard, Inverted } - public class GameSettings { public string[] Mods = { "ra" }; diff --git a/OpenRA.Game/Traits/Player/PlayerResources.cs b/OpenRA.Game/Traits/Player/PlayerResources.cs index 4aa24f15ea..ec01cf9531 100644 --- a/OpenRA.Game/Traits/Player/PlayerResources.cs +++ b/OpenRA.Game/Traits/Player/PlayerResources.cs @@ -10,6 +10,7 @@ using System; using System.Linq; +using OpenRA.GameRules; namespace OpenRA.Traits { @@ -62,6 +63,8 @@ namespace OpenRA.Traits { readonly Player Owner; int AdviceInterval; + + int tickermod = 0; public PlayerResources(Actor self, PlayerResourcesInfo info) { @@ -134,7 +137,8 @@ namespace OpenRA.Traits public void Tick(Actor self) { var eva = self.World.WorldActor.Info.Traits.Get(); - + tickermod = (tickermod + 1) % 3; + OreCapacity = self.World.ActorsWithTrait() .Where(a => a.Actor.Owner == Owner) .Sum(a => a.Trait.Capacity); @@ -158,12 +162,12 @@ namespace OpenRA.Traits if (DisplayCash < Cash) { DisplayCash += move; - Sound.PlayToPlayer(self.Owner, eva.CashTickUp); + playCashTickUp(self); } else if (DisplayCash > Cash) { DisplayCash -= move; - Sound.PlayToPlayer(self.Owner, eva.CashTickDown); + playCashTickDown(self); } diff = Math.Abs(Ore - DisplayOre); @@ -173,13 +177,35 @@ namespace OpenRA.Traits if (DisplayOre < Ore) { DisplayOre += move; - Sound.PlayToPlayer(self.Owner, eva.CashTickUp); + playCashTickUp(self); } else if (DisplayOre > Ore) { DisplayOre -= move; + playCashTickDown(self); + } + } + + + public void playCashTickUp(Actor self) + { + var eva = self.World.WorldActor.Info.Traits.Get(); + if (Game.Settings.Sound.SoundCashTickType != SoundCashTicks.Disabled) + { + Sound.PlayToPlayer(self.Owner, eva.CashTickUp); + } + } + + public void playCashTickDown(Actor self) + { + var eva = self.World.WorldActor.Info.Traits.Get(); + if ( + Game.Settings.Sound.SoundCashTickType == SoundCashTicks.Extreme || + (Game.Settings.Sound.SoundCashTickType == SoundCashTicks.Normal && tickermod == 0) + ) { Sound.PlayToPlayer(self.Owner, eva.CashTickDown); } + } } } diff --git a/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs index 89eff81fb6..74cf654580 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs @@ -71,6 +71,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic // Audio var audio = bg.Get("AUDIO_PANE"); + var soundSettings = Game.Settings.Sound; var soundslider = audio.Get("SOUND_VOLUME"); soundslider.OnChange += x => Sound.SoundVolume = x; @@ -80,6 +81,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic musicslider.OnChange += x => Sound.MusicVolume = x; musicslider.Value = Sound.MusicVolume; + var cashticksdropdown = audio.Get("CASH_TICK_TYPE"); + cashticksdropdown.OnMouseDown = _ => ShowSoundTickDropdown(cashticksdropdown, soundSettings); + cashticksdropdown.GetText = () => soundSettings.SoundCashTickType == SoundCashTicks.Extreme ? + "Extreme" : soundSettings.SoundCashTickType == SoundCashTicks.Normal ? "Normal" : "Disabled"; + + // Display var display = bg.Get("DISPLAY_PANE"); var gs = Game.Settings.Graphics; @@ -138,6 +145,29 @@ namespace OpenRA.Mods.RA.Widgets.Logic return true; } + + public static bool ShowSoundTickDropdown(DropDownButtonWidget dropdown, SoundSettings audio) + { + var options = new Dictionary() + { + { "Extreme", SoundCashTicks.Extreme }, + { "Normal", SoundCashTicks.Normal }, + { "Disabled", SoundCashTicks.Disabled }, + }; + + Func setupItem = (o, itemTemplate) => + { + var item = ScrollItemWidget.Setup(itemTemplate, + () => audio.SoundCashTickType == options[o], + () => audio.SoundCashTickType = options[o]); + item.Get("LABEL").GetText = () => o; + return item; + }; + + dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem); + return true; + } + public static bool ShowWindowModeDropdown(DropDownButtonWidget dropdown, GraphicSettings s) { var options = new Dictionary() diff --git a/mods/ra/chrome/settings.yaml b/mods/ra/chrome/settings.yaml index 0b122a18c3..f31aa1ae9a 100644 --- a/mods/ra/chrome/settings.yaml +++ b/mods/ra/chrome/settings.yaml @@ -136,6 +136,17 @@ Background@SETTINGS_MENU: Width:250 Height:20 Ticks:5 + Label@SOUND_TICK_TYPE_LABEL: + X:0 + Y:70 + Text: Cash ticks + DropDownButton@CASH_TICK_TYPE: + X:100 + Y:60 + Width:250 + Height:20 + Font:Regular + Text:Extreme Container@DISPLAY_PANE: X:37 Y:100