move Game.world onto OrderManager. use call IssueOrder on world and/or on orderManager, not on Game

This commit is contained in:
Bob
2010-10-12 17:19:09 +13:00
parent 34fc207a6c
commit 20276291ce
19 changed files with 116 additions and 121 deletions

View File

@@ -10,6 +10,7 @@
using System.Drawing;
using OpenRA.Graphics;
using OpenRA.Network;
namespace OpenRA.Widgets
{
@@ -25,6 +26,13 @@ namespace OpenRA.Widgets
bool composing = false;
bool teamChat = false;
readonly OrderManager orderManager;
[ObjectCreator.UseCtor]
internal ChatEntryWidget( [ObjectCreator.Param] OrderManager orderManager )
{
this.orderManager = orderManager;
}
public override void DrawInner( WorldRenderer wr )
{
if (composing)
@@ -61,7 +69,7 @@ namespace OpenRA.Widgets
composing = false;
if (content != "")
Game.IssueOrder(teamChat
orderManager.IssueOrder(teamChat
? Order.TeamChat(content)
: Order.Chat(content));
content = "";

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Widgets.Delegates
() => world.LocalPlayer.PlayerActor.Trait<DeveloperMode>().DisableShroud;
devmodeBG.GetWidget<CheckboxWidget>("CHECKBOX_SHROUD").OnMouseDown = mi =>
{
Game.IssueOrder(new Order("DevShroud", world.LocalPlayer.PlayerActor));
world.IssueOrder(new Order("DevShroud", world.LocalPlayer.PlayerActor));
return true;
};
@@ -53,7 +53,7 @@ namespace OpenRA.Widgets.Delegates
() => Game.Settings.Debug.ShowCollisions;
devmodeBG.GetWidget("CHECKBOX_UNITDEBUG").OnMouseDown = mi =>
{
Game.IssueOrder(new Order("DevUnitDebug", world.LocalPlayer.PlayerActor));
world.IssueOrder(new Order("DevUnitDebug", world.LocalPlayer.PlayerActor));
return true;
};
@@ -61,13 +61,13 @@ namespace OpenRA.Widgets.Delegates
() => world.LocalPlayer.PlayerActor.Trait<DeveloperMode>().PathDebug;
devmodeBG.GetWidget("CHECKBOX_PATHDEBUG").OnMouseDown = mi =>
{
Game.IssueOrder(new Order("DevPathDebug", world.LocalPlayer.PlayerActor));
world.IssueOrder(new Order("DevPathDebug", world.LocalPlayer.PlayerActor));
return true;
};
devmodeBG.GetWidget<ButtonWidget>("GIVE_CASH").OnMouseUp = mi =>
{
Game.IssueOrder(new Order("DevGiveCash", world.LocalPlayer.PlayerActor));
world.IssueOrder(new Order("DevGiveCash", world.LocalPlayer.PlayerActor));
return true;
};
@@ -75,7 +75,7 @@ namespace OpenRA.Widgets.Delegates
() => world.LocalPlayer.PlayerActor.Trait<DeveloperMode>().FastBuild;
devmodeBG.GetWidget<CheckboxWidget>("INSTANT_BUILD").OnMouseDown = mi =>
{
Game.IssueOrder(new Order("DevFastBuild", world.LocalPlayer.PlayerActor));
world.IssueOrder(new Order("DevFastBuild", world.LocalPlayer.PlayerActor));
return true;
};
@@ -83,7 +83,7 @@ namespace OpenRA.Widgets.Delegates
() => world.LocalPlayer.PlayerActor.Trait<DeveloperMode>().FastCharge;
devmodeBG.GetWidget<CheckboxWidget>("INSTANT_CHARGE").OnMouseDown = mi =>
{
Game.IssueOrder(new Order("DevFastCharge", world.LocalPlayer.PlayerActor));
world.IssueOrder(new Order("DevFastCharge", world.LocalPlayer.PlayerActor));
return true;
};
@@ -91,13 +91,13 @@ namespace OpenRA.Widgets.Delegates
() => world.LocalPlayer.PlayerActor.Trait<DeveloperMode>().AllTech;
devmodeBG.GetWidget<CheckboxWidget>("ENABLE_TECH").OnMouseDown = mi =>
{
Game.IssueOrder(new Order("DevEnableTech", world.LocalPlayer.PlayerActor));
world.IssueOrder(new Order("DevEnableTech", world.LocalPlayer.PlayerActor));
return true;
};
devmodeBG.GetWidget<ButtonWidget>("GIVE_EXPLORATION").OnMouseUp = mi =>
{
Game.IssueOrder(new Order("DevGiveExploration", world.LocalPlayer.PlayerActor));
world.IssueOrder(new Order("DevGiveExploration", world.LocalPlayer.PlayerActor));
return true;
};

View File

@@ -138,7 +138,7 @@ namespace OpenRA.Widgets.Delegates
var nextStance = GetNextStance((Stance)Enum.Parse(typeof(Stance), bw.Text));
Game.IssueOrder(new Order("SetStance", world.LocalPlayer.PlayerActor,
world.IssueOrder(new Order("SetStance", world.LocalPlayer.PlayerActor,
new int2(p.Index, (int)nextStance)));
bw.Text = nextStance.ToString();

View File

@@ -52,7 +52,7 @@ namespace OpenRA.Widgets.Delegates
if (orderManager.LocalClient.State == Session.ClientState.Ready) return;
var owned = orderManager.LobbyInfo.Clients.Any(c => c.SpawnPoint == sp);
if (sp == 0 || !owned)
Game.IssueOrder(Order.Command("spawn {0}".F(sp)));
orderManager.IssueOrder(Order.Command("spawn {0}".F(sp)));
};
mapPreview.SpawnColors = () =>
@@ -95,7 +95,7 @@ namespace OpenRA.Widgets.Delegates
lockTeamsCheckbox.OnMouseDown = mi =>
{
if (Game.IsHost)
Game.IssueOrder(Order.Command(
orderManager.IssueOrder(Order.Command(
"lockteams {0}".F(!orderManager.LobbyInfo.GlobalSettings.LockTeams)));
return true;
};
@@ -106,7 +106,7 @@ namespace OpenRA.Widgets.Delegates
mapButton.Visible = false;
disconnectButton.Visible = false;
lockTeamsCheckbox.Visible = false;
Game.IssueOrder(Order.Command("startgame"));
orderManager.IssueOrder(Order.Command("startgame"));
return true;
};
startGameButton.IsVisible = () => Game.IsHost;
@@ -126,7 +126,7 @@ namespace OpenRA.Widgets.Delegates
return true;
var order = (teamChat) ? Order.TeamChat(chatTextField.Text) : Order.Chat(chatTextField.Text);
Game.IssueOrder(order);
orderManager.IssueOrder(order);
chatTextField.Text = "";
return true;
};
@@ -166,7 +166,7 @@ namespace OpenRA.Widgets.Delegates
Game.Settings.Player.Color1 = c1;
Game.Settings.Player.Color2 = c2;
Game.Settings.Save();
Game.IssueOrder(Order.Command("color {0},{1},{2},{3},{4},{5}".F(c1.R,c1.G,c1.B,c2.R,c2.G,c2.B)));
orderManager.IssueOrder(Order.Command("color {0},{1},{2},{3},{4},{5}".F(c1.R,c1.G,c1.B,c2.R,c2.G,c2.B)));
}
void UpdateColorPreview(float hf, float sf, float lf, float r)
@@ -190,13 +190,13 @@ namespace OpenRA.Widgets.Delegates
hasJoined = true;
if (orderManager.LocalClient.Name != Game.Settings.Player.Name)
Game.IssueOrder(Order.Command("name " + Game.Settings.Player.Name));
orderManager.IssueOrder(Order.Command("name " + Game.Settings.Player.Name));
var c1 = Game.Settings.Player.Color1;
var c2 = Game.Settings.Player.Color2;
if (orderManager.LocalClient.Color1 != c1 || orderManager.LocalClient.Color2 != c2)
Game.IssueOrder(Order.Command("color {0},{1},{2},{3},{4},{5}".F(c1.R,c1.G,c1.B,c2.R,c2.G,c2.B)));
orderManager.IssueOrder(Order.Command("color {0},{1},{2},{3},{4},{5}".F(c1.R,c1.G,c1.B,c2.R,c2.G,c2.B)));
}
void ResetConnectionState( OrderManager orderManager )
@@ -235,14 +235,14 @@ namespace OpenRA.Widgets.Delegates
if (s.Closed)
{
s.Bot = null;
Game.IssueOrder(Order.Command("slot_open " + s.Index));
orderManager.IssueOrder(Order.Command("slot_open " + s.Index));
}
else
{
if (s.Bot == null)
Game.IssueOrder(Order.Command("slot_bot {0} HackyAI".F(s.Index)));
orderManager.IssueOrder(Order.Command("slot_bot {0} HackyAI".F(s.Index)));
else
Game.IssueOrder(Order.Command("slot_close " + s.Index));
orderManager.IssueOrder(Order.Command("slot_close " + s.Index));
}
return true;
};
@@ -257,7 +257,7 @@ namespace OpenRA.Widgets.Delegates
var join = template.GetWidget<ButtonWidget>("JOIN");
if (join != null)
{
join.OnMouseUp = _ => { Game.IssueOrder(Order.Command("slot " + s.Index)); return true; };
join.OnMouseUp = _ => { orderManager.IssueOrder(Order.Command("slot " + s.Index)); return true; };
join.IsVisible = () => !s.Closed && s.Bot == null;
}
}
@@ -276,7 +276,7 @@ namespace OpenRA.Widgets.Delegates
if (name.Text == c.Name)
return true;
Game.IssueOrder(Order.Command("name " + name.Text));
orderManager.IssueOrder(Order.Command("name " + name.Text));
Game.Settings.Player.Name = name.Text;
Game.Settings.Save();
return true;
@@ -372,14 +372,14 @@ namespace OpenRA.Widgets.Delegates
if (nextCountry == null)
nextCountry = countries.First();
Game.IssueOrder(Order.Command("race " + nextCountry));
orderManager.IssueOrder(Order.Command("race " + nextCountry));
return true;
}
bool CycleReady(MouseInput mi)
{
Game.IssueOrder(Order.Command("ready"));
orderManager.IssueOrder(Order.Command("ready"));
return true;
}
@@ -388,7 +388,7 @@ namespace OpenRA.Widgets.Delegates
var d = (mi.Button == MouseButton.Left) ? +1 : Map.PlayerCount;
var newIndex = (orderManager.LocalClient.Team + d) % (Map.PlayerCount + 1);
Game.IssueOrder(
orderManager.IssueOrder(
Order.Command("team " + newIndex));
return true;
}

View File

@@ -11,6 +11,7 @@
using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Network;
namespace OpenRA.Widgets.Delegates
{
@@ -19,7 +20,7 @@ namespace OpenRA.Widgets.Delegates
MapStub Map = null;
[ObjectCreator.UseCtor]
public MapChooserDelegate( [ObjectCreator.Param( "widget" )] Widget bg )
internal MapChooserDelegate( [ObjectCreator.Param( "widget" )] Widget bg, [ObjectCreator.Param] OrderManager orderManager )
{
bg.SpecialOneArg = (map) => RefreshMapList(map);
var ml = bg.GetWidget<ListBoxWidget>("MAP_LIST");
@@ -32,7 +33,7 @@ namespace OpenRA.Widgets.Delegates
bg.GetWidget("BUTTON_OK").OnMouseUp = mi =>
{
Game.IssueOrder(Order.Command("map " + Map.Uid));
orderManager.IssueOrder(Order.Command("map " + Map.Uid));
Widget.CloseWindow();
return true;
};

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Widgets.Delegates
var perfText = perfRoot.GetWidget<LabelWidget>("TEXT");
perfText.GetText = () => "Render {0} ({5}={2:F1} ms)\nTick {4} ({3:F1} ms)".F(
Game.RenderFrame,
Game.orderManager.FrameNumber,
Game.orderManager.NetFrameNumber,
PerfHistory.items["render"].LastValue,
PerfHistory.items["tick_time"].LastValue,
Game.LocalTick,

View File

@@ -90,8 +90,8 @@ namespace OpenRA.Widgets
{
if (world.OrderGenerator == null) return;
var orders = world.OrderGenerator.Order(world, xy.ToInt2(), mi).ToArray();
Game.orderManager.IssueOrders( orders );
var orders = world.OrderGenerator.Order(world, xy.ToInt2(), mi).ToArray();
orders.Do( o => world.IssueOrder( o ) );
// Find an actor with a phrase to say
var done = false;
@@ -113,9 +113,6 @@ namespace OpenRA.Widgets
{
return Sync.CheckSyncUnchanged( world, () =>
{
if (!world.GameHasStarted)
return "default";
var mi = new MouseInput
{
Location = pos,