Add ability to disable the shellmap

This commit is contained in:
Tirili
2011-10-23 13:13:43 +13:00
committed by Chris Forbes
parent 6174ccc882
commit 4f505eb6a1
7 changed files with 30 additions and 6 deletions

View File

@@ -205,13 +205,13 @@ namespace OpenRA
} }
public static event Action BeforeGameStart = () => {}; public static event Action BeforeGameStart = () => {};
internal static void StartGame(string mapUID) internal static void StartGame(string mapUID, bool isShellmap)
{ {
BeforeGameStart(); BeforeGameStart();
var map = modData.PrepareMap(mapUID); var map = modData.PrepareMap(mapUID);
viewport = new Viewport(new int2(Renderer.Resolution), map.Bounds, Renderer); viewport = new Viewport(new int2(Renderer.Resolution), map.Bounds, Renderer);
orderManager.world = new World(modData.Manifest, map, orderManager); orderManager.world = new World(modData.Manifest, map, orderManager) { IsShellmap = isShellmap };
worldRenderer = new WorldRenderer(orderManager.world); worldRenderer = new WorldRenderer(orderManager.world);
if (orderManager.GameStarted) return; if (orderManager.GameStarted) return;
@@ -306,7 +306,7 @@ namespace OpenRA
public static void LoadShellMap() public static void LoadShellMap()
{ {
StartGame(ChooseShellmap()); StartGame(ChooseShellmap(), true);
} }
static string ChooseShellmap() static string ChooseShellmap()

1
OpenRA.Game/GameRules/Settings.cs Executable file → Normal file
View File

@@ -90,6 +90,7 @@ namespace OpenRA.GameRules
public string[] Mods = { "ra" }; public string[] Mods = { "ra" };
public bool TeamChatToggle = false; public bool TeamChatToggle = false;
public bool ShowShellmap = true;
public bool ViewportEdgeScroll = true; public bool ViewportEdgeScroll = true;
public MouseScrollType MouseScroll = MouseScrollType.Standard; public MouseScrollType MouseScroll = MouseScrollType.Standard;

View File

@@ -67,6 +67,10 @@ namespace OpenRA.Graphics
public void Draw() public void Draw()
{ {
RefreshPalette(); RefreshPalette();
if (world.IsShellmap && !Game.Settings.Game.ShowShellmap)
return;
var bounds = Game.viewport.ViewBounds(world); var bounds = Game.viewport.ViewBounds(world);
Game.Renderer.EnableScissor(bounds.Left, bounds.Top, bounds.Width, bounds.Height); Game.Renderer.EnableScissor(bounds.Left, bounds.Top, bounds.Width, bounds.Height);

View File

@@ -94,7 +94,7 @@ namespace OpenRA.Network
case "StartGame": case "StartGame":
{ {
Game.AddChatLine(Color.White, "Server", "The game has started."); Game.AddChatLine(Color.White, "Server", "The game has started.");
Game.StartGame(orderManager.LobbyInfo.GlobalSettings.Map); Game.StartGame(orderManager.LobbyInfo.GlobalSettings.Map, false);
break; break;
} }

View File

@@ -151,11 +151,18 @@ namespace OpenRA
// Will do bad things in multiplayer games // Will do bad things in multiplayer games
public bool EnableTick = true; public bool EnableTick = true;
public bool IsShellmap = false;
bool ShouldTick()
{
if (!EnableTick) return false;
return !IsShellmap || Game.Settings.Game.ShowShellmap;
}
public void Tick() public void Tick()
{ {
// Todo: Expose this as an order so it can be synced // Todo: Expose this as an order so it can be synced
if (EnableTick) if (ShouldTick())
{ {
using( new PerfSample("tick_idle") ) using( new PerfSample("tick_idle") )
foreach( var ni in ActorsWithTrait<INotifyIdle>() ) foreach( var ni in ActorsWithTrait<INotifyIdle>() )
@@ -171,7 +178,8 @@ namespace OpenRA
x.Trait.Tick( x.Actor ); x.Trait.Tick( x.Actor );
}, "[{2}] Trait: {0} ({1:0.000} ms)", Game.Settings.Debug.LongTickThreshold ); }, "[{2}] Trait: {0} ({1:0.000} ms)", Game.Settings.Debug.LongTickThreshold );
effects.DoTimed( e => e.Tick( this ), "[{2}] Effect: {0} ({1:0.000} ms)", Game.Settings.Debug.LongTickThreshold ); effects.DoTimed( e => e.Tick( this ), "[{2}] Effect: {0} ({1:0.000} ms)",
Game.Settings.Debug.LongTickThreshold );
} }
while (frameEndActions.Count != 0) while (frameEndActions.Count != 0)

View File

@@ -65,6 +65,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
teamchatCheckbox.IsChecked = () => Game.Settings.Game.TeamChatToggle; teamchatCheckbox.IsChecked = () => Game.Settings.Game.TeamChatToggle;
teamchatCheckbox.OnClick = () => Game.Settings.Game.TeamChatToggle ^= true; teamchatCheckbox.OnClick = () => Game.Settings.Game.TeamChatToggle ^= true;
var showShellmapCheckbox = general.GetWidget<CheckboxWidget>("SHOW_SHELLMAP");
showShellmapCheckbox.IsChecked = () => Game.Settings.Game.ShowShellmap;
showShellmapCheckbox.OnClick = () => Game.Settings.Game.ShowShellmap ^= true;
// Audio // Audio
var audio = bg.GetWidget("AUDIO_PANE"); var audio = bg.GetWidget("AUDIO_PANE");

View File

@@ -119,6 +119,13 @@ Background@SETTINGS_MENU:
Width:200 Width:200
Height:20 Height:20
Text: Shift-Enter Toggles Team Chat Text: Shift-Enter Toggles Team Chat
Checkbox@SHOW_SHELLMAP:
Id:SHOW_SHELLMAP
X:0
Y:150
Width:200
Height:20
Text: Show Shellmap
Container@AUDIO_PANE: Container@AUDIO_PANE:
Id:AUDIO_PANE Id:AUDIO_PANE
X:37 X:37