From 6ff4ea37171fd2d7d7d5a5957cc4fecd359ddb21 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 27 Dec 2009 21:54:37 +1300 Subject: [PATCH] using props in Sound rather than setter functions; no idea if it's right, because there's no way to test --- OpenRa.Game/Graphics/WorldRenderer.cs | 37 +++++++++++++------------ OpenRa.Game/Sound.cs | 39 ++++++++++++++++----------- 2 files changed, 44 insertions(+), 32 deletions(-) diff --git a/OpenRa.Game/Graphics/WorldRenderer.cs b/OpenRa.Game/Graphics/WorldRenderer.cs index 8eec1e4644..e155bbf7c4 100644 --- a/OpenRa.Game/Graphics/WorldRenderer.cs +++ b/OpenRa.Game/Graphics/WorldRenderer.cs @@ -82,21 +82,7 @@ namespace OpenRa.Game.Graphics spriteRenderer.Flush(); - var selbox = Game.controller.SelectionBox; - if (selbox != null) - { - var a = selbox.Value.First; - var b = new float2(selbox.Value.Second.X - a.X, 0); - var c = new float2(0, selbox.Value.Second.Y - a.Y); - - lineRenderer.DrawLine(a, a + b, Color.White, Color.White); - lineRenderer.DrawLine(a + b, a + b + c, Color.White, Color.White); - lineRenderer.DrawLine(a + b + c, a + c, Color.White, Color.White); - lineRenderer.DrawLine(a, a + c, Color.White, Color.White); - - foreach (var u in Game.SelectActorsInBox(selbox.Value.First, selbox.Value.Second)) - DrawSelectionBox(u, Color.Yellow, false); - } + DrawBandBox(); if (Game.controller.orderGenerator != null) Game.controller.orderGenerator.Render(); @@ -105,6 +91,24 @@ namespace OpenRa.Game.Graphics spriteRenderer.Flush(); } + void DrawBandBox() + { + var selbox = Game.controller.SelectionBox; + if (selbox == null) return; + + var a = selbox.Value.First; + var b = new float2(selbox.Value.Second.X - a.X, 0); + var c = new float2(0, selbox.Value.Second.Y - a.Y); + + lineRenderer.DrawLine(a, a + b, Color.White, Color.White); + lineRenderer.DrawLine(a + b, a + b + c, Color.White, Color.White); + lineRenderer.DrawLine(a + b + c, a + c, Color.White, Color.White); + lineRenderer.DrawLine(a, a + c, Color.White, Color.White); + + foreach (var u in Game.SelectActorsInBox(selbox.Value.First, selbox.Value.Second)) + DrawSelectionBox(u, Color.Yellow, false); + } + public void DrawSelectionBox(Actor selectedUnit, Color c, bool drawHealthBar) { var bounds = selectedUnit.Bounds; @@ -133,8 +137,7 @@ namespace OpenRa.Game.Graphics if (selectedUnit.Owner == Game.LocalPlayer) { DrawPips(selectedUnit, xY); - DrawTags(selectedUnit, - new float2(.5f * (bounds.Left + bounds.Right ), xy.Y)); + DrawTags(selectedUnit, new float2(.5f * (bounds.Left + bounds.Right ), xy.Y)); } } diff --git a/OpenRa.Game/Sound.cs b/OpenRa.Game/Sound.cs index 7e65d9c25a..537d4b59f6 100644 --- a/OpenRa.Game/Sound.cs +++ b/OpenRa.Game/Sound.cs @@ -10,10 +10,11 @@ namespace OpenRa.Game static ISoundEngine soundEngine; static Cache sounds; static ISound music; + //TODO: read these from somewhere? static float soundVolume; static float musicVolume; - + static bool paused; static ISoundSource LoadSound(string filename) { @@ -50,25 +51,33 @@ namespace OpenRa.Game music = soundEngine.Play2D(sound, true /* loop */, false, false); music.Volume = musicVolume; } - - public static void Pause(bool doPause) + + public static bool Paused { - soundEngine.SetAllSoundsPaused(doPause); + get { return paused; } + set { paused = value; soundEngine.SetAllSoundsPaused(paused); } + } + + public static float Volume + { + get { return soundVolume; } + set + { + soundVolume = value; + soundEngine.SoundVolume = value; + } } - public static void SetVolume(float vol) + public static float MusicVolume { - soundVolume = vol; - soundEngine.SoundVolume = vol; + get { return musicVolume; } + set { + musicVolume = value; + if (music != null) + music.Volume = value; + } } - - public static void SetMusicVolume(float vol) - { - musicVolume = vol; - if (music != null) - music.Volume = vol; - } - + public static void SeekMusic(uint delta) { if (music != null)