From fe8c80aca62da3ba3dce71f4c38915260fe28ee9 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 27 Sep 2013 18:14:44 +1200 Subject: [PATCH] Add Game.Zoom for remaining engine stuff. --- OpenRA.Game/Game.cs | 5 +++++ OpenRA.Game/Graphics/LineRenderer.cs | 2 +- OpenRA.Game/Sound.cs | 5 +++-- OpenRA.Mods.Cnc/Widgets/Logic/CncSettingsLogic.cs | 2 +- OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index b56ccfd9a6..68b42e39a2 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -33,6 +33,11 @@ namespace OpenRA public static ModData modData; static WorldRenderer worldRenderer; + public static float Zoom + { + get { return worldRenderer.Viewport.Zoom; } + set { worldRenderer.Viewport.Zoom = value; } + } public static Viewport viewport; public static Settings Settings; diff --git a/OpenRA.Game/Graphics/LineRenderer.cs b/OpenRA.Game/Graphics/LineRenderer.cs index d5533e2e3b..c84c83486e 100644 --- a/OpenRA.Game/Graphics/LineRenderer.cs +++ b/OpenRA.Game/Graphics/LineRenderer.cs @@ -39,7 +39,7 @@ namespace OpenRA.Graphics { var vb = renderer.GetTempVertexBuffer(); vb.SetData(vertices, nv); - renderer.SetLineWidth(LineWidth * Game.viewport.Zoom); + renderer.SetLineWidth(LineWidth * Game.Zoom); renderer.DrawBatch(vb, 0, nv, PrimitiveType.LineList); }); renderer.Device.SetBlendMode(BlendMode.None); diff --git a/OpenRA.Game/Sound.cs b/OpenRA.Game/Sound.cs index 87bd17a828..20ef61450a 100644 --- a/OpenRA.Game/Sound.cs +++ b/OpenRA.Game/Sound.cs @@ -682,8 +682,9 @@ namespace OpenRA Al.alSourcei(source, Al.AL_LOOPING, looping ? Al.AL_TRUE : Al.AL_FALSE); Al.alSourcei(source, Al.AL_SOURCE_RELATIVE, relative ? 1 : 0); - Al.alSourcef(source, Al.AL_REFERENCE_DISTANCE, Game.viewport.WorldRect.Width / 8); - Al.alSourcef(source, Al.AL_MAX_DISTANCE, 2*Game.viewport.WorldRect.Width); + var width = Game.Renderer.Resolution.Width / (Game.Zoom * Game.CellSize); + Al.alSourcef(source, Al.AL_REFERENCE_DISTANCE, width / 8); + Al.alSourcef(source, Al.AL_MAX_DISTANCE, 2 * width); Al.alSourcePlay(source); } diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncSettingsLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncSettingsLogic.cs index dbd2cf87f5..709bf66136 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncSettingsLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncSettingsLogic.cs @@ -90,7 +90,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic pixelDoubleCheckbox.OnClick = () => { graphicsSettings.PixelDouble ^= true; - Game.viewport.Zoom = graphicsSettings.PixelDouble ? 2 : 1; + Game.Zoom = graphicsSettings.PixelDouble ? 2 : 1; }; var showShellmapCheckbox = generalPane.Get("SHOW_SHELLMAP"); diff --git a/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs index 7c7bd10f41..9e42300687 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs @@ -132,7 +132,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic pixelDoubleCheckbox.OnClick = () => { gs.PixelDouble ^= true; - Game.viewport.Zoom = gs.PixelDouble ? 2 : 1; + Game.Zoom = gs.PixelDouble ? 2 : 1; }; var capFrameRateCheckbox = display.Get("CAPFRAMERATE_CHECKBOX");