Merge commit 'pchote/chrome' into replays2
This commit is contained in:
9
Makefile
9
Makefile
@@ -44,12 +44,6 @@ aftermath_KIND = library
|
||||
aftermath_DEPS = $(fileformats_TARGET) $(game_TARGET)
|
||||
aftermath_LIBS = $(COMMON_LIBS) $(aftermath_DEPS)
|
||||
|
||||
server_SRCS = $(shell find OpenRA.Server/ -iname '*.cs')
|
||||
server_TARGET = OpenRA.Server.exe
|
||||
server_KIND = winexe
|
||||
server_DEPS = $(fileformats_TARGET)
|
||||
server_LIBS = $(COMMON_LIBS) $(server_DEPS)
|
||||
|
||||
seqed_SRCS = $(shell find SequenceEditor/ -iname '*.cs')
|
||||
seqed_TARGET = SequenceEditor.exe
|
||||
seqed_KIND = winexe
|
||||
@@ -83,9 +77,8 @@ clean:
|
||||
@-rm *.exe *.dll *.mdb mods/**/*.dll mods/**/*.mdb
|
||||
|
||||
mods: $(ra_TARGET) $(cnc_TARGET) $(aftermath_TARGET)
|
||||
server: $(server_TARGET)
|
||||
seqed: $(seqed_TARGET)
|
||||
all: $(fileformats_TARGET) $(gl_TARGET) $(game_TARGET) $(ra_TARGET) $(cnc_TARGET) $(aftermath_TARGET) $(server_TARGET) $(seqed_TARGET)
|
||||
all: $(fileformats_TARGET) $(gl_TARGET) $(game_TARGET) $(ra_TARGET) $(cnc_TARGET) $(aftermath_TARGET) $(seqed_TARGET)
|
||||
|
||||
dist-osx:
|
||||
packaging/osx/package.sh
|
||||
|
||||
@@ -231,14 +231,30 @@ namespace OpenRA
|
||||
|
||||
public void DrawDialog(string text)
|
||||
{
|
||||
var w = renderer.BoldFont.Measure(text).X + 120;
|
||||
var h = 100;
|
||||
DrawDialog(text, null, _ => { }, null, _ => { });
|
||||
}
|
||||
|
||||
public void DrawDialog(string text, string button1String, Action<bool> button1Action, string button2String, Action<bool> button2Action)
|
||||
{
|
||||
var w = Math.Max(renderer.BoldFont.Measure(text).X + 120, 400);
|
||||
var h = (button1String == null) ? 100 : 140;
|
||||
var r = new Rectangle((Game.viewport.Width - w) / 2, (Game.viewport.Height - h) / 2, w, h);
|
||||
DrawDialogBackground(r, "dialog");
|
||||
DrawCentered(text, new int2(Game.viewport.Width / 2, Game.viewport.Height / 2 - 8), Color.White);
|
||||
DrawCentered(text, new int2(Game.viewport.Width / 2, Game.viewport.Height / 2 - ((button1String == null) ? 8 : 28)), Color.White);
|
||||
|
||||
// don't allow clicks through the dialog
|
||||
AddButton(r, _ => { });
|
||||
|
||||
if (button1String != null)
|
||||
{
|
||||
AddUiButton(new int2(r.Right - 300, r.Bottom - 40),button1String, button1Action);
|
||||
}
|
||||
|
||||
if (button2String != null)
|
||||
{
|
||||
AddUiButton(new int2(r.Right - 100, r.Bottom - 40),button2String, button2Action);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class MapInfo
|
||||
@@ -411,6 +427,35 @@ namespace OpenRA
|
||||
|
||||
}
|
||||
|
||||
public void DrawMainMenu( World world )
|
||||
{
|
||||
buttons.Clear();
|
||||
|
||||
var w = 250;
|
||||
var h = 200;
|
||||
var r = new Rectangle( (Game.viewport.Width - w) / 2, (Game.viewport.Height - h) / 2, w, h );
|
||||
DrawDialogBackground(r, "dialog");
|
||||
DrawCentered("OpenRA Main Menu", new int2(r.Left + w / 2, r.Top + 20), Color.White);
|
||||
|
||||
AddUiButton(new int2(r.Left + w/2, r.Top + 70), "Join Game",
|
||||
_ =>
|
||||
{
|
||||
Game.JoinServer(Game.Settings.NetworkHost, Game.Settings.NetworkPort);
|
||||
});
|
||||
|
||||
AddUiButton(new int2(r.Left + w/2, r.Top + 105), "Create Game",
|
||||
_ =>
|
||||
{
|
||||
Game.CreateServer();
|
||||
});
|
||||
|
||||
AddUiButton(new int2(r.Left + w/2, r.Top + 140), "Quit",
|
||||
_ =>
|
||||
{
|
||||
Game.Exit();
|
||||
});
|
||||
}
|
||||
|
||||
public void DrawLobby( World world )
|
||||
{
|
||||
buttons.Clear();
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using OpenRA.FileFormats;
|
||||
@@ -30,8 +32,8 @@ using OpenRA.Network;
|
||||
using OpenRA.Support;
|
||||
using OpenRA.Traits;
|
||||
using Timer = OpenRA.Support.Timer;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.IO;
|
||||
using OpenRA.Server;
|
||||
using System.Net;
|
||||
|
||||
namespace OpenRA
|
||||
{
|
||||
@@ -54,6 +56,8 @@ namespace OpenRA
|
||||
static string mapName;
|
||||
internal static Session LobbyInfo = new Session();
|
||||
static bool changePending;
|
||||
|
||||
|
||||
|
||||
public static void LoadModPackages(Manifest manifest)
|
||||
{
|
||||
@@ -125,20 +129,39 @@ namespace OpenRA
|
||||
PerfHistory.items["batches"].hasNormalTick = false;
|
||||
PerfHistory.items["text"].hasNormalTick = false;
|
||||
Game.controller = controller;
|
||||
|
||||
|
||||
ChangeMap(mapName);
|
||||
|
||||
if (Settings.Replay != "")
|
||||
throw new NotImplementedException();
|
||||
else
|
||||
{
|
||||
var connection = (string.IsNullOrEmpty(Settings.NetworkHost))
|
||||
? new EchoConnection()
|
||||
: new NetworkConnection( Settings.NetworkHost, Settings.NetworkPort );
|
||||
orderManager = new OrderManager(connection, "replay.rep");
|
||||
JoinLocal();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal static void JoinServer(string host, int port)
|
||||
{
|
||||
orderManager = new OrderManager(new NetworkConnection( host, port ), "replay.rep");
|
||||
}
|
||||
|
||||
internal static void JoinLocal()
|
||||
{
|
||||
orderManager = new OrderManager(new EchoConnection());
|
||||
}
|
||||
|
||||
internal static void CreateServer()
|
||||
{
|
||||
// todo: LobbyInfo is the wrong place for this.
|
||||
InprocServer.Start(Game.LobbyInfo.GlobalSettings.Mods);
|
||||
JoinServer(IPAddress.Loopback.ToString(), 1234);
|
||||
}
|
||||
|
||||
internal static void CloseServer()
|
||||
{
|
||||
InprocServer.Stop();
|
||||
}
|
||||
|
||||
static int lastTime = Environment.TickCount;
|
||||
|
||||
public static void ResetTimer()
|
||||
@@ -312,15 +335,6 @@ namespace OpenRA
|
||||
throw new InvalidOperationException( "Desync in DispatchMouseInput" );
|
||||
}
|
||||
|
||||
public static void HandleKeyDown( KeyEventArgs e )
|
||||
{
|
||||
//int sync = Game.world.SyncHash();
|
||||
|
||||
|
||||
//if( sync != Game.world.SyncHash() )
|
||||
// throw new InvalidOperationException( "Desync in OnKeyDown" );
|
||||
}
|
||||
|
||||
public static bool IsHost
|
||||
{
|
||||
get { return orderManager.Connection.LocalClientId == 0; }
|
||||
|
||||
@@ -85,11 +85,15 @@ namespace OpenRA.Graphics
|
||||
|
||||
switch( Game.orderManager.Connection.ConnectionState )
|
||||
{
|
||||
case ConnectionState.PreConnecting:
|
||||
Game.chrome.DrawMainMenu( world );
|
||||
break;
|
||||
case ConnectionState.Connecting:
|
||||
Game.chrome.DrawDialog("Connecting to {0}:{1}...".F( Game.Settings.NetworkHost, Game.Settings.NetworkPort ));
|
||||
break;
|
||||
case ConnectionState.NotConnected:
|
||||
Game.chrome.DrawDialog("Connection failed.");
|
||||
// Todo: Hook these up
|
||||
Game.chrome.DrawDialog("Connection failed.", "Retry", _ => {}, "Cancel",_ => {});
|
||||
break;
|
||||
case ConnectionState.Connected:
|
||||
Game.chrome.DrawLobby( world );
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#region Copyright & License Information
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
@@ -29,6 +29,7 @@ namespace OpenRA.Network
|
||||
{
|
||||
enum ConnectionState
|
||||
{
|
||||
PreConnecting,
|
||||
NotConnected,
|
||||
Connecting,
|
||||
Connected,
|
||||
@@ -58,7 +59,7 @@ namespace OpenRA.Network
|
||||
|
||||
public virtual ConnectionState ConnectionState
|
||||
{
|
||||
get { return ConnectionState.Connected; }
|
||||
get { return ConnectionState.PreConnecting; }
|
||||
}
|
||||
|
||||
public virtual void Send( byte[] packet )
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -102,6 +102,10 @@
|
||||
<Compile Include="PackageDownloader.cs" />
|
||||
<Compile Include="PathSearch.cs" />
|
||||
<Compile Include="Selection.cs" />
|
||||
<Compile Include="Server\Connection.cs" />
|
||||
<Compile Include="Server\Exts.cs" />
|
||||
<Compile Include="Server\Server.cs" />
|
||||
<Compile Include="Server\ServerOrder.cs" />
|
||||
<Compile Include="Shroud.cs" />
|
||||
<Compile Include="Smudge.cs" />
|
||||
<Compile Include="Sound.cs" />
|
||||
|
||||
0
OpenRA.Server/Exts.cs → OpenRA.Game/Server/Exts.cs
Executable file → Normal file
0
OpenRA.Server/Exts.cs → OpenRA.Game/Server/Exts.cs
Executable file → Normal file
@@ -27,6 +27,7 @@ using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Cryptography;
|
||||
using OpenRA.FileFormats;
|
||||
using System.Threading;
|
||||
|
||||
namespace OpenRA.Server
|
||||
{
|
||||
@@ -38,16 +39,17 @@ namespace OpenRA.Server
|
||||
= new Dictionary<int, List<Connection>>();
|
||||
static Session lobbyInfo;
|
||||
static bool GameStarted = false;
|
||||
static string[] defaultMods = new string[] { "ra" };
|
||||
static string[] initialMods;
|
||||
|
||||
const int DownloadChunkInterval = 20000;
|
||||
const int DownloadChunkSize = 16384;
|
||||
|
||||
public static int Main(string[] args)
|
||||
public static int ServerMain(string[] mods, AutoResetEvent e)
|
||||
{
|
||||
if (args.Length > 0) defaultMods = args;
|
||||
initialMods = mods;
|
||||
|
||||
lobbyInfo = new Session();
|
||||
lobbyInfo.GlobalSettings.Mods = defaultMods;
|
||||
lobbyInfo.GlobalSettings.Mods = mods;
|
||||
|
||||
Console.WriteLine("Initial mods: ");
|
||||
foreach( var m in lobbyInfo.GlobalSettings.Mods )
|
||||
@@ -63,6 +65,8 @@ namespace OpenRA.Server
|
||||
Console.WriteLine("Server failed to start.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
e.Set(); // we're done starting up
|
||||
|
||||
for (; ; )
|
||||
{
|
||||
@@ -510,7 +514,7 @@ namespace OpenRA.Server
|
||||
Console.WriteLine("Server emptied out; doing a bit of housekeeping to prepare for next game..");
|
||||
inFlightFrames.Clear();
|
||||
lobbyInfo = new Session();
|
||||
lobbyInfo.GlobalSettings.Mods = defaultMods;
|
||||
lobbyInfo.GlobalSettings.Mods = initialMods;
|
||||
GameStarted = false;
|
||||
}
|
||||
|
||||
@@ -538,4 +542,25 @@ namespace OpenRA.Server
|
||||
new ServerOrder("SyncInfo", clientData.WriteToString()).Serialize());
|
||||
}
|
||||
}
|
||||
|
||||
// temporary threaded inproc server wrapper.
|
||||
public static class InprocServer
|
||||
{
|
||||
static Thread t;
|
||||
|
||||
public static void Start( string[] mods )
|
||||
{
|
||||
var e = new AutoResetEvent(false);
|
||||
t = new Thread(() => Server.ServerMain(mods, e)) { IsBackground = true };
|
||||
|
||||
t.Start();
|
||||
e.WaitOne(); // when the event is signaled, the server is finished initializing
|
||||
}
|
||||
|
||||
public static void Stop()
|
||||
{
|
||||
if (t != null)
|
||||
t.Abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{76F621A1-3D8E-4A99-9F7E-B071EB657817}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>OpenRA.Server</RootNamespace>
|
||||
<AssemblyName>OpenRA.Server</AssemblyName>
|
||||
@@ -48,11 +48,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Connection.cs" />
|
||||
<Compile Include="Exts.cs" />
|
||||
<Compile Include="Server.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ServerOrder.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
@@ -68,4 +64,8 @@
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
10
OpenRA.sln
10
OpenRA.sln
@@ -7,8 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Game", "OpenRA.Game\
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SequenceEditor", "SequenceEditor\SequenceEditor.csproj", "{230F65CE-A6DE-4235-8B38-13A3D606C7F7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Server", "OpenRA.Server\OpenRA.Server.csproj", "{76F621A1-3D8E-4A99-9F7E-B071EB657817}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Mods.RA", "OpenRA.Mods.RA\OpenRA.Mods.RA.csproj", "{4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Mods.Aftermath", "OpenRA.Mods.Aftermath\OpenRA.Mods.Aftermath.csproj", "{2E1F8D8B-AEF5-4BCE-A95C-50223A0C7331}"
|
||||
@@ -48,14 +46,6 @@ Global
|
||||
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{76F621A1-3D8E-4A99-9F7E-B071EB657817}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{76F621A1-3D8E-4A99-9F7E-B071EB657817}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{76F621A1-3D8E-4A99-9F7E-B071EB657817}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{76F621A1-3D8E-4A99-9F7E-B071EB657817}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{76F621A1-3D8E-4A99-9F7E-B071EB657817}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{76F621A1-3D8E-4A99-9F7E-B071EB657817}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{76F621A1-3D8E-4A99-9F7E-B071EB657817}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{76F621A1-3D8E-4A99-9F7E-B071EB657817}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
|
||||
@@ -54,9 +54,6 @@ export AS="as -arch i386"
|
||||
export CC="gcc -arch i386 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk"
|
||||
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig/
|
||||
|
||||
# Package the server binary
|
||||
mkbundle --deps --static -z -o openra_server OpenRA.Server.exe OpenRA.FileFormats.dll thirdparty/Tao/Tao.Sdl.dll
|
||||
|
||||
# Package the game binary
|
||||
mkbundle --deps --static -z -o OpenRA OpenRA.Game.exe OpenRA.Gl.dll OpenRA.FileFormats.dll thirdparty/Tao/Tao.Cg.dll thirdparty/Tao/Tao.OpenGl.dll thirdparty/Tao/Tao.OpenAl.dll thirdparty/Tao/Tao.FreeType.dll thirdparty/Tao/Tao.Sdl.dll
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ title=OpenRA
|
||||
size=70m
|
||||
dmgName=OpenRA.dmg
|
||||
|
||||
mv openra_server ${source}
|
||||
mv OpenRA.app ${source}
|
||||
|
||||
hdiutil create -srcfolder "${source}" -volname "${title}" -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW -size ${size} temp.dmg
|
||||
@@ -23,7 +22,6 @@ echo '
|
||||
set background picture of theViewOptions to file ".background:bg.png"
|
||||
make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"}
|
||||
set position of item "OpenRA.app" of container window to {100, 90}
|
||||
set position of item "openra_server" of container window to {100, 210}
|
||||
set position of item "Applications" of container window to {375, 150}
|
||||
close
|
||||
open
|
||||
@@ -38,5 +36,4 @@ sync
|
||||
hdiutil detach ${device}
|
||||
hdiutil convert "./temp.dmg" -format UDZO -imagekey zlib-level=9 -o "${dmgName}"
|
||||
rm -f ./temp.dmg
|
||||
rm -rf ${source}OpenRA.app
|
||||
rm -f ${source}openra_server
|
||||
rm -rf ${source}OpenRA.app
|
||||
Reference in New Issue
Block a user