Merge pull request #9255 from pchote/gamespeed
Add a game speed dropdown to the lobby options.
This commit is contained in:
@@ -147,7 +147,7 @@ namespace OpenRA
|
||||
using (new PerfTimer("PrepareMap"))
|
||||
map = ModData.PrepareMap(mapUID);
|
||||
using (new PerfTimer("NewWorld"))
|
||||
OrderManager.World = new World(map, OrderManager, type) { Timestep = Timestep };
|
||||
OrderManager.World = new World(map, OrderManager, type);
|
||||
|
||||
worldRenderer = new WorldRenderer(OrderManager.World);
|
||||
|
||||
|
||||
40
OpenRA.Game/GameSpeed.cs
Normal file
40
OpenRA.Game/GameSpeed.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
|
||||
namespace OpenRA
|
||||
{
|
||||
public class GameSpeed
|
||||
{
|
||||
[Translate]
|
||||
public readonly string Name = "Default";
|
||||
public readonly int Timestep = 40;
|
||||
public readonly int OrderLatency = 3;
|
||||
}
|
||||
|
||||
public class GameSpeeds : IGlobalModData
|
||||
{
|
||||
[FieldLoader.LoadUsing("LoadSpeeds")]
|
||||
public readonly Dictionary<string, GameSpeed> Speeds;
|
||||
|
||||
static object LoadSpeeds(MiniYaml y)
|
||||
{
|
||||
var ret = new Dictionary<string, GameSpeed>();
|
||||
foreach (var node in y.Nodes)
|
||||
ret.Add(node.Key, FieldLoader.Load<GameSpeed>(node.Value));
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,6 +172,7 @@ namespace OpenRA.Network
|
||||
{
|
||||
public string ServerName;
|
||||
public string Map;
|
||||
public int Timestep = 40;
|
||||
public int OrderLatency = 3; // net tick frames (x 120 = ms)
|
||||
public int RandomSeed = 0;
|
||||
public bool FragileAlliances = false; // Allow diplomatic stance changes after game start.
|
||||
@@ -187,6 +188,7 @@ namespace OpenRA.Network
|
||||
public int StartingCash = 5000;
|
||||
public string TechLevel = "none";
|
||||
public string StartingUnitsClass = "none";
|
||||
public string GameSpeedType = "default";
|
||||
public bool ShortGame = true;
|
||||
public bool AllowVersionMismatch;
|
||||
public string GameUid;
|
||||
|
||||
@@ -243,6 +243,7 @@
|
||||
<Compile Include="Map\MapCoordsRegion.cs" />
|
||||
<Compile Include="Renderer.cs" />
|
||||
<Compile Include="Platform.cs" />
|
||||
<Compile Include="GameSpeed.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="FileSystem\D2kSoundResources.cs" />
|
||||
|
||||
@@ -158,14 +158,14 @@ namespace OpenRA.Widgets
|
||||
DrawRGBA(cornerBottomRight, new float2(bounds.Right - cornerBottomRight.Size.X, bounds.Bottom - cornerBottomRight.Size.Y));
|
||||
}
|
||||
|
||||
public static string FormatTime(int ticks)
|
||||
public static string FormatTime(int ticks, int timestep)
|
||||
{
|
||||
return FormatTime(ticks, true);
|
||||
return FormatTime(ticks, true, timestep);
|
||||
}
|
||||
|
||||
public static string FormatTime(int ticks, bool leadingMinuteZero)
|
||||
public static string FormatTime(int ticks, bool leadingMinuteZero, int timestep)
|
||||
{
|
||||
var seconds = (int)Math.Ceiling(ticks / 25f);
|
||||
var seconds = (int)Math.Ceiling(ticks * timestep / 1000f);
|
||||
return FormatTimeSeconds(seconds, leadingMinuteZero);
|
||||
}
|
||||
|
||||
|
||||
@@ -144,6 +144,7 @@ namespace OpenRA
|
||||
OrderManager = orderManager;
|
||||
orderGenerator = new UnitOrderGenerator();
|
||||
Map = map;
|
||||
Timestep = orderManager.LobbyInfo.GlobalSettings.Timestep;
|
||||
|
||||
TileSet = map.Rules.TileSets[Map.Tileset];
|
||||
SharedRandom = new MersenneTwister(orderManager.LobbyInfo.GlobalSettings.RandomSeed);
|
||||
|
||||
Reference in New Issue
Block a user