remove plenty of redundant junk
This commit is contained in:
@@ -67,7 +67,7 @@ namespace OpenRA.FileFormats
|
|||||||
}
|
}
|
||||||
|
|
||||||
Preview = Lazy.New(
|
Preview = Lazy.New(
|
||||||
() => { return new Bitmap(Package.GetContent("preview.png")); }
|
() => new Bitmap(Package.GetContent("preview.png"))
|
||||||
);
|
);
|
||||||
|
|
||||||
Uid = Package.GetContent("map.uid").ReadAllText();
|
Uid = Package.GetContent("map.uid").ReadAllText();
|
||||||
|
|||||||
@@ -18,11 +18,11 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.IO;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
||||||
namespace OpenRA
|
namespace OpenRA
|
||||||
|
|||||||
@@ -1,10 +1,29 @@
|
|||||||
using System;
|
#region Copyright & License Information
|
||||||
using System.Collections.Generic;
|
/*
|
||||||
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
|
* This file is part of OpenRA.
|
||||||
|
*
|
||||||
|
* OpenRA is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* OpenRA is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using OpenRA.FileFormats;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
|
|
||||||
namespace OpenRA.Server
|
namespace OpenRA.Server
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using System.Drawing;
|
|
||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
@@ -32,10 +31,10 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public BackgroundWidget() : base() { }
|
public BackgroundWidget() : base() { }
|
||||||
|
|
||||||
public BackgroundWidget(Widget other)
|
protected BackgroundWidget(BackgroundWidget other)
|
||||||
: base(other)
|
: base(other)
|
||||||
{
|
{
|
||||||
Background = (other as BackgroundWidget).Background;
|
Background = other.Background;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Widget Clone() { return new BackgroundWidget(this); }
|
public override Widget Clone() { return new BackgroundWidget(this); }
|
||||||
|
|||||||
@@ -18,15 +18,14 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using OpenRA;
|
|
||||||
using OpenRA.Traits;
|
|
||||||
using OpenRA.Graphics;
|
|
||||||
using OpenRA.FileFormats;
|
|
||||||
using OpenRA.Orders;
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Orders;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
namespace OpenRA.Widgets
|
||||||
{
|
{
|
||||||
@@ -53,14 +52,6 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public BuildPaletteWidget() : base() { }
|
public BuildPaletteWidget() : base() { }
|
||||||
|
|
||||||
public BuildPaletteWidget(Widget other)
|
|
||||||
: base(other)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException("Why are you Cloning BuildPalette?");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Widget Clone() { return new BuildPaletteWidget(this); }
|
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|||||||
@@ -18,8 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Drawing;
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
namespace OpenRA.Widgets
|
||||||
{
|
{
|
||||||
@@ -37,16 +37,16 @@ namespace OpenRA.Widgets
|
|||||||
GetText = () => { return Text; };
|
GetText = () => { return Text; };
|
||||||
}
|
}
|
||||||
|
|
||||||
public ButtonWidget(Widget widget)
|
protected ButtonWidget(ButtonWidget widget)
|
||||||
:base(widget)
|
: base(widget)
|
||||||
{
|
{
|
||||||
Text = (widget as ButtonWidget).Text;
|
Text = widget.Text;
|
||||||
Depressed = (widget as ButtonWidget).Depressed;
|
Depressed = widget.Depressed;
|
||||||
VisualHeight = (widget as ButtonWidget).VisualHeight;
|
VisualHeight = widget.VisualHeight;
|
||||||
GetText = (widget as ButtonWidget).GetText;
|
GetText = widget.GetText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool LoseFocus (MouseInput mi)
|
public override bool LoseFocus(MouseInput mi)
|
||||||
{
|
{
|
||||||
Depressed = false;
|
Depressed = false;
|
||||||
return base.LoseFocus(mi);
|
return base.LoseFocus(mi);
|
||||||
@@ -67,7 +67,7 @@ namespace OpenRA.Widgets
|
|||||||
if (mi.Event == MouseInputEvent.Down)
|
if (mi.Event == MouseInputEvent.Down)
|
||||||
Depressed = true;
|
Depressed = true;
|
||||||
else if (mi.Event == MouseInputEvent.Move && Focused)
|
else if (mi.Event == MouseInputEvent.Move && Focused)
|
||||||
Depressed = RenderBounds.Contains(mi.Location.X,mi.Location.Y);
|
Depressed = RenderBounds.Contains(mi.Location.X, mi.Location.Y);
|
||||||
|
|
||||||
return Depressed;
|
return Depressed;
|
||||||
}
|
}
|
||||||
@@ -76,19 +76,16 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
var font = (Bold) ? Game.chrome.renderer.BoldFont : Game.chrome.renderer.RegularFont;
|
var font = (Bold) ? Game.chrome.renderer.BoldFont : Game.chrome.renderer.RegularFont;
|
||||||
var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0);
|
var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0);
|
||||||
WidgetUtils.DrawPanel(Depressed ? "dialog3" : "dialog2", RenderBounds );
|
WidgetUtils.DrawPanel(Depressed ? "dialog3" : "dialog2", RenderBounds);
|
||||||
|
|
||||||
var text = GetText();
|
var text = GetText();
|
||||||
font.DrawText(text,
|
font.DrawText(text,
|
||||||
new int2( RenderOrigin.X + Bounds.Width / 2, RenderOrigin.Y + Bounds.Height / 2)
|
new int2(RenderOrigin.X + Bounds.Width / 2, RenderOrigin.Y + Bounds.Height / 2)
|
||||||
- new int2(font.Measure(text).X / 2,
|
- new int2(font.Measure(text).X / 2,
|
||||||
font.Measure(text).Y / 2) + stateOffset, Color.White);
|
font.Measure(text).Y / 2) + stateOffset, Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Widget Clone()
|
public override Widget Clone() { return new ButtonWidget(this); }
|
||||||
{
|
|
||||||
return new ButtonWidget(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,12 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using OpenRA.FileFormats;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
namespace OpenRA.Widgets
|
||||||
{
|
{
|
||||||
@@ -35,10 +32,10 @@ namespace OpenRA.Widgets
|
|||||||
public List<ChatLine> recentLines = new List<ChatLine>();
|
public List<ChatLine> recentLines = new List<ChatLine>();
|
||||||
|
|
||||||
public ChatDisplayWidget()
|
public ChatDisplayWidget()
|
||||||
: base() {}
|
: base() { }
|
||||||
|
|
||||||
public ChatDisplayWidget(Widget widget)
|
protected ChatDisplayWidget(Widget widget)
|
||||||
:base(widget) {}
|
: base(widget) { }
|
||||||
|
|
||||||
public override void DrawInner(World world)
|
public override void DrawInner(World world)
|
||||||
{
|
{
|
||||||
@@ -74,11 +71,13 @@ namespace OpenRA.Widgets
|
|||||||
while (recentLines.Count > logLength) recentLines.RemoveAt(0);
|
while (recentLines.Count > logLength) recentLines.RemoveAt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Widget Clone()
|
public override Widget Clone() { return new ChatDisplayWidget(this); }
|
||||||
{
|
|
||||||
return new ChatDisplayWidget(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
class ChatLine { public Color Color = Color.White; public string Owner, Text; public bool wrapped = false; }
|
|
||||||
|
|
||||||
|
class ChatLine
|
||||||
|
{
|
||||||
|
public Color Color = Color.White;
|
||||||
|
public string Owner, Text;
|
||||||
|
public bool wrapped = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -56,15 +56,16 @@ namespace OpenRA.Widgets
|
|||||||
Game.chrome.lineRenderer.Flush();
|
Game.chrome.lineRenderer.Flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandleInput(MouseInput mi) { return true; }
|
public override bool HandleInput(MouseInput mi) { return true; }
|
||||||
|
|
||||||
public CheckboxWidget() : base() { }
|
public CheckboxWidget() : base() { }
|
||||||
|
|
||||||
public CheckboxWidget(Widget other)
|
protected CheckboxWidget(CheckboxWidget other)
|
||||||
: base(other)
|
: base(other)
|
||||||
{
|
{
|
||||||
Text = (other as CheckboxWidget).Text;
|
Text = other.Text;
|
||||||
Checked = (other as CheckboxWidget).Checked;
|
Checked = other.Checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Widget Clone() { return new CheckboxWidget(this); }
|
public override Widget Clone() { return new CheckboxWidget(this); }
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ namespace OpenRA.Widgets
|
|||||||
GetColor = () => Color.White;
|
GetColor = () => Color.White;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ColorBlockWidget(Widget widget)
|
protected ColorBlockWidget(ColorBlockWidget widget)
|
||||||
:base(widget)
|
: base(widget)
|
||||||
{
|
{
|
||||||
GetColor = (widget as ColorBlockWidget).GetColor;
|
GetColor = widget.GetColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Widget Clone()
|
public override Widget Clone()
|
||||||
@@ -47,7 +47,8 @@ namespace OpenRA.Widgets
|
|||||||
public override void DrawInner(World world)
|
public override void DrawInner(World world)
|
||||||
{
|
{
|
||||||
var pos = RenderOrigin;
|
var pos = RenderOrigin;
|
||||||
var paletteRect = new RectangleF(pos.X + Game.viewport.Location.X, pos.Y + Game.viewport.Location.Y, Bounds.Width, Bounds.Height);
|
var paletteRect = new RectangleF(pos.X + Game.viewport.Location.X,
|
||||||
|
pos.Y + Game.viewport.Location.Y, Bounds.Width, Bounds.Height);
|
||||||
Game.chrome.lineRenderer.FillRect(paletteRect, GetColor());
|
Game.chrome.lineRenderer.FillRect(paletteRect, GetColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,27 @@
|
|||||||
|
#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.
|
||||||
|
*
|
||||||
|
* OpenRA is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* OpenRA is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Widgets.Delegates
|
namespace OpenRA.Widgets.Delegates
|
||||||
|
|||||||
@@ -17,9 +17,6 @@
|
|||||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
using System;
|
|
||||||
using OpenRA.FileFormats;
|
|
||||||
using OpenRA.Support;
|
|
||||||
|
|
||||||
namespace OpenRA.Widgets.Delegates
|
namespace OpenRA.Widgets.Delegates
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -30,7 +29,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
{
|
{
|
||||||
Widget Players, LocalPlayerTemplate, RemotePlayerTemplate;
|
Widget Players, LocalPlayerTemplate, RemotePlayerTemplate;
|
||||||
|
|
||||||
Dictionary<string,string> CountryNames;
|
Dictionary<string, string> CountryNames;
|
||||||
|
|
||||||
string MapUid;
|
string MapUid;
|
||||||
MapStub Map;
|
MapStub Map;
|
||||||
@@ -46,9 +45,9 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
RemotePlayerTemplate = Players.GetWidget("TEMPLATE_REMOTE");
|
RemotePlayerTemplate = Players.GetWidget("TEMPLATE_REMOTE");
|
||||||
|
|
||||||
|
|
||||||
var map = lobby.GetWidget<MapPreviewWidget>("LOBBY_MAP_PREVIEW");
|
var mapPreview = lobby.GetWidget<MapPreviewWidget>("LOBBY_MAP_PREVIEW");
|
||||||
map.Map = () => {return Map;};
|
mapPreview.Map = () => Map;
|
||||||
map.OnSpawnClick = sp =>
|
mapPreview.OnSpawnClick = sp =>
|
||||||
{
|
{
|
||||||
if (Game.LocalClient.State == Session.ClientState.Ready) return;
|
if (Game.LocalClient.State == Session.ClientState.Ready) return;
|
||||||
var owned = Game.LobbyInfo.Clients.Any(c => c.SpawnPoint == sp);
|
var owned = Game.LobbyInfo.Clients.Any(c => c.SpawnPoint == sp);
|
||||||
@@ -56,18 +55,18 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
Game.IssueOrder(Order.Command("spawn {0}".F(sp)));
|
Game.IssueOrder(Order.Command("spawn {0}".F(sp)));
|
||||||
};
|
};
|
||||||
|
|
||||||
map.SpawnColors = () =>
|
mapPreview.SpawnColors = () =>
|
||||||
{
|
{
|
||||||
var spawns = Map.SpawnPoints;
|
var spawns = Map.SpawnPoints;
|
||||||
var playerColors = Game.world.PlayerColors();
|
var playerColors = Game.world.PlayerColors();
|
||||||
var sc = new Dictionary<int2,Color>();
|
var sc = new Dictionary<int2, Color>();
|
||||||
|
|
||||||
for (int i = 1; i <= spawns.Count(); i++)
|
for (int i = 1; i <= spawns.Count(); i++)
|
||||||
{
|
{
|
||||||
var client = Game.LobbyInfo.Clients.FirstOrDefault(c => c.SpawnPoint == i);
|
var client = Game.LobbyInfo.Clients.FirstOrDefault(c => c.SpawnPoint == i);
|
||||||
if (client == null)
|
if (client == null)
|
||||||
continue;
|
continue;
|
||||||
sc.Add(spawns.ElementAt(i-1),playerColors[client.PaletteIndex % playerColors.Count()].Color);
|
sc.Add(spawns.ElementAt(i - 1), playerColors[client.PaletteIndex % playerColors.Count()].Color);
|
||||||
}
|
}
|
||||||
return sc;
|
return sc;
|
||||||
};
|
};
|
||||||
@@ -76,7 +75,8 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
CountryNames.Add("random", "Random");
|
CountryNames.Add("random", "Random");
|
||||||
|
|
||||||
var mapButton = lobby.GetWidget("CHANGEMAP_BUTTON");
|
var mapButton = lobby.GetWidget("CHANGEMAP_BUTTON");
|
||||||
mapButton.OnMouseUp = mi => {
|
mapButton.OnMouseUp = mi =>
|
||||||
|
{
|
||||||
r.GetWidget("MAP_CHOOSER").SpecialOneArg(MapUid);
|
r.GetWidget("MAP_CHOOSER").SpecialOneArg(MapUid);
|
||||||
r.OpenWindow("MAP_CHOOSER");
|
r.OpenWindow("MAP_CHOOSER");
|
||||||
return true;
|
return true;
|
||||||
@@ -85,7 +85,8 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
mapButton.IsVisible = () => mapButton.Visible && Game.IsHost;
|
mapButton.IsVisible = () => mapButton.Visible && Game.IsHost;
|
||||||
|
|
||||||
var disconnectButton = lobby.GetWidget("DISCONNECT_BUTTON");
|
var disconnectButton = lobby.GetWidget("DISCONNECT_BUTTON");
|
||||||
disconnectButton.OnMouseUp = mi => {
|
disconnectButton.OnMouseUp = mi =>
|
||||||
|
{
|
||||||
Game.Disconnect();
|
Game.Disconnect();
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@@ -102,7 +103,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
};
|
};
|
||||||
|
|
||||||
Game.LobbyInfoChanged += UpdatePlayerList;
|
Game.LobbyInfoChanged += UpdatePlayerList;
|
||||||
Game.AddChatLine += (c,n,s) => lobby.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").AddLine(c,n,s);
|
Game.AddChatLine += (c, n, s) => lobby.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").AddLine(c, n, s);
|
||||||
|
|
||||||
bool teamChat = false;
|
bool teamChat = false;
|
||||||
var chatLabel = lobby.GetWidget<LabelWidget>("LABEL_CHATTYPE");
|
var chatLabel = lobby.GetWidget<LabelWidget>("LABEL_CHATTYPE");
|
||||||
@@ -112,8 +113,8 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
if (chatTextField.Text.Length == 0)
|
if (chatTextField.Text.Length == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
var order = (teamChat) ? Order.TeamChat( chatTextField.Text ) : Order.Chat( chatTextField.Text );
|
var order = (teamChat) ? Order.TeamChat(chatTextField.Text) : Order.Chat(chatTextField.Text);
|
||||||
Game.IssueOrder( order );
|
Game.IssueOrder(order);
|
||||||
chatTextField.Text = "";
|
chatTextField.Text = "";
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@@ -131,7 +132,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
{
|
{
|
||||||
if (MapUid == Game.LobbyInfo.GlobalSettings.Map) return;
|
if (MapUid == Game.LobbyInfo.GlobalSettings.Map) return;
|
||||||
MapUid = Game.LobbyInfo.GlobalSettings.Map;
|
MapUid = Game.LobbyInfo.GlobalSettings.Map;
|
||||||
Map = Game.AvailableMaps[ MapUid ];
|
Map = Game.AvailableMaps[MapUid];
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdatePlayerList()
|
void UpdatePlayerList()
|
||||||
@@ -141,12 +142,12 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
Players.Children.Clear();
|
Players.Children.Clear();
|
||||||
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
foreach(var client in Game.LobbyInfo.Clients)
|
foreach (var client in Game.LobbyInfo.Clients)
|
||||||
{
|
{
|
||||||
var c = client;
|
var c = client;
|
||||||
Widget template;
|
Widget template;
|
||||||
|
|
||||||
if(client.Index == Game.LocalClient.Index && c.State != Session.ClientState.Ready)
|
if (client.Index == Game.LocalClient.Index && c.State != Session.ClientState.Ready)
|
||||||
{
|
{
|
||||||
template = LocalPlayerTemplate.Clone();
|
template = LocalPlayerTemplate.Clone();
|
||||||
var name = template.GetWidget<TextFieldWidget>("NAME");
|
var name = template.GetWidget<TextFieldWidget>("NAME");
|
||||||
@@ -161,7 +162,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
if (name.Text == c.Name)
|
if (name.Text == c.Name)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Game.IssueOrder(Order.Command( "name "+name.Text ));
|
Game.IssueOrder(Order.Command("name " + name.Text));
|
||||||
Game.Settings.PlayerName = name.Text;
|
Game.Settings.PlayerName = name.Text;
|
||||||
Game.Settings.Save();
|
Game.Settings.Save();
|
||||||
return true;
|
return true;
|
||||||
@@ -274,7 +275,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
{
|
{
|
||||||
var d = (mi.Button == MouseButton.Left) ? +1 : Game.world.Map.PlayerCount;
|
var d = (mi.Button == MouseButton.Left) ? +1 : Game.world.Map.PlayerCount;
|
||||||
|
|
||||||
var newIndex = (Game.LocalClient.Team + d) % (Game.world.Map.PlayerCount+1);
|
var newIndex = (Game.LocalClient.Team + d) % (Game.world.Map.PlayerCount + 1);
|
||||||
|
|
||||||
Game.IssueOrder(
|
Game.IssueOrder(
|
||||||
Order.Command("team " + newIndex));
|
Order.Command("team " + newIndex));
|
||||||
|
|||||||
@@ -17,8 +17,9 @@
|
|||||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
using System;
|
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
|
|
||||||
namespace OpenRA.Widgets.Delegates
|
namespace OpenRA.Widgets.Delegates
|
||||||
{
|
{
|
||||||
public class MainMenuButtonsDelegate : IWidgetDelegate
|
public class MainMenuButtonsDelegate : IWidgetDelegate
|
||||||
@@ -27,7 +28,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
{
|
{
|
||||||
// Main menu is the default window
|
// Main menu is the default window
|
||||||
Widget.WindowList.Push("MAINMENU_BG");
|
Widget.WindowList.Push("MAINMENU_BG");
|
||||||
Chrome.rootWidget.GetWidget("MAINMENU_BUTTON_QUIT").OnMouseUp = mi => {Game.Exit(); return true;};
|
Chrome.rootWidget.GetWidget("MAINMENU_BUTTON_QUIT").OnMouseUp = mi => { Game.Exit(); return true; };
|
||||||
|
|
||||||
var version = Chrome.rootWidget.GetWidget("MAINMENU_BG").GetWidget<LabelWidget>("VERSION_STRING");
|
var version = Chrome.rootWidget.GetWidget("MAINMENU_BG").GetWidget<LabelWidget>("VERSION_STRING");
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
@@ -36,19 +34,21 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
bg.SpecialOneArg = (map) => RefreshMapList(map);
|
bg.SpecialOneArg = (map) => RefreshMapList(map);
|
||||||
var ml = bg.GetWidget<ListBoxWidget>("MAP_LIST");
|
var ml = bg.GetWidget<ListBoxWidget>("MAP_LIST");
|
||||||
|
|
||||||
bg.GetWidget<MapPreviewWidget>("MAPCHOOSER_MAP_PREVIEW").Map = () => {return Map;};
|
bg.GetWidget<MapPreviewWidget>("MAPCHOOSER_MAP_PREVIEW").Map = () => Map;
|
||||||
bg.GetWidget<LabelWidget>("CURMAP_TITLE").GetText = () => {return Map.Title;};
|
bg.GetWidget<LabelWidget>("CURMAP_TITLE").GetText = () => Map.Title;
|
||||||
bg.GetWidget<LabelWidget>("CURMAP_SIZE").GetText = () => {return "{0}x{1}".F(Map.Width, Map.Height);};
|
bg.GetWidget<LabelWidget>("CURMAP_SIZE").GetText = () => "{0}x{1}".F(Map.Width, Map.Height);
|
||||||
bg.GetWidget<LabelWidget>("CURMAP_THEATER").GetText = () => {return Rules.TileSets[Map.Tileset].Name;};
|
bg.GetWidget<LabelWidget>("CURMAP_THEATER").GetText = () => Rules.TileSets[Map.Tileset].Name;
|
||||||
bg.GetWidget<LabelWidget>("CURMAP_PLAYERS").GetText = () => {return Map.PlayerCount.ToString();};
|
bg.GetWidget<LabelWidget>("CURMAP_PLAYERS").GetText = () => Map.PlayerCount.ToString();
|
||||||
|
|
||||||
bg.GetWidget("BUTTON_OK").OnMouseUp = mi => {
|
bg.GetWidget("BUTTON_OK").OnMouseUp = mi =>
|
||||||
|
{
|
||||||
Game.IssueOrder(Order.Command("map " + Map.Uid));
|
Game.IssueOrder(Order.Command("map " + Map.Uid));
|
||||||
r.CloseWindow();
|
r.CloseWindow();
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
bg.GetWidget("BUTTON_CANCEL").OnMouseUp = mi => {
|
bg.GetWidget("BUTTON_CANCEL").OnMouseUp = mi =>
|
||||||
|
{
|
||||||
r.CloseWindow();
|
r.CloseWindow();
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@@ -63,9 +63,9 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
|
|
||||||
var template = itemTemplate.Clone() as LabelWidget;
|
var template = itemTemplate.Clone() as LabelWidget;
|
||||||
template.Id = "MAP_{0}".F(map.Uid);
|
template.Id = "MAP_{0}".F(map.Uid);
|
||||||
template.GetText = () => " "+map.Title;
|
template.GetText = () => " " + map.Title;
|
||||||
template.GetBackground = () => ((Map == map) ? "dialog2" : null);
|
template.GetBackground = () => ((Map == map) ? "dialog2" : null);
|
||||||
template.OnMouseDown = mi => {Map = map; return true;};
|
template.OnMouseDown = mi => { Map = map; return true; };
|
||||||
template.Parent = ml;
|
template.Parent = ml;
|
||||||
|
|
||||||
template.Bounds = new Rectangle(template.Bounds.X, offset, template.Bounds.Width, template.Bounds.Height);
|
template.Bounds = new Rectangle(template.Bounds.X, offset, template.Bounds.Width, template.Bounds.Height);
|
||||||
@@ -82,7 +82,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
// Set the default selected map
|
// Set the default selected map
|
||||||
var uid = uidobj as string;
|
var uid = uidobj as string;
|
||||||
if (uid != null)
|
if (uid != null)
|
||||||
Map = Game.AvailableMaps[ uid ];
|
Map = Game.AvailableMaps[uid];
|
||||||
else
|
else
|
||||||
Map = Game.AvailableMaps.FirstOrDefault().Value;
|
Map = Game.AvailableMaps.FirstOrDefault().Value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
using System;
|
|
||||||
namespace OpenRA.Widgets.Delegates
|
namespace OpenRA.Widgets.Delegates
|
||||||
{
|
{
|
||||||
public class MusicPlayerDelegate : IWidgetDelegate
|
public class MusicPlayerDelegate : IWidgetDelegate
|
||||||
@@ -27,7 +27,8 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
var bg = Chrome.rootWidget.GetWidget("MUSIC_BG");
|
var bg = Chrome.rootWidget.GetWidget("MUSIC_BG");
|
||||||
bg.Visible = Game.Settings.MusicPlayer;
|
bg.Visible = Game.Settings.MusicPlayer;
|
||||||
|
|
||||||
bg.GetWidget("BUTTON_PLAY").OnMouseUp = mi => {
|
bg.GetWidget("BUTTON_PLAY").OnMouseUp = mi =>
|
||||||
|
{
|
||||||
if (Sound.MusicStopped)
|
if (Sound.MusicStopped)
|
||||||
Sound.PlayMusic(GetSong());
|
Sound.PlayMusic(GetSong());
|
||||||
Sound.MusicStopped = false;
|
Sound.MusicStopped = false;
|
||||||
@@ -36,19 +37,25 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
bg.GetWidget("BUTTON_PAUSE").Visible = true;
|
bg.GetWidget("BUTTON_PAUSE").Visible = true;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
bg.GetWidget("BUTTON_PAUSE").OnMouseUp = mi => {
|
|
||||||
|
bg.GetWidget("BUTTON_PAUSE").OnMouseUp = mi =>
|
||||||
|
{
|
||||||
Sound.MusicPaused = true;
|
Sound.MusicPaused = true;
|
||||||
bg.GetWidget("BUTTON_PAUSE").Visible = false;
|
bg.GetWidget("BUTTON_PAUSE").Visible = false;
|
||||||
bg.GetWidget("BUTTON_PLAY").Visible = true;
|
bg.GetWidget("BUTTON_PLAY").Visible = true;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
bg.GetWidget("BUTTON_STOP").OnMouseUp = mi => {
|
|
||||||
|
bg.GetWidget("BUTTON_STOP").OnMouseUp = mi =>
|
||||||
|
{
|
||||||
Sound.MusicStopped = true;
|
Sound.MusicStopped = true;
|
||||||
bg.GetWidget("BUTTON_PAUSE").Visible = false;
|
bg.GetWidget("BUTTON_PAUSE").Visible = false;
|
||||||
bg.GetWidget("BUTTON_PLAY").Visible = true;
|
bg.GetWidget("BUTTON_PLAY").Visible = true;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
bg.GetWidget("BUTTON_NEXT").OnMouseUp = mi => {
|
|
||||||
|
bg.GetWidget("BUTTON_NEXT").OnMouseUp = mi =>
|
||||||
|
{
|
||||||
Sound.PlayMusic(GetNextSong());
|
Sound.PlayMusic(GetNextSong());
|
||||||
Sound.MusicStopped = false;
|
Sound.MusicStopped = false;
|
||||||
Sound.MusicPaused = false;
|
Sound.MusicPaused = false;
|
||||||
@@ -56,7 +63,9 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
bg.GetWidget("BUTTON_PAUSE").Visible = true;
|
bg.GetWidget("BUTTON_PAUSE").Visible = true;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
bg.GetWidget("BUTTON_PREV").OnMouseUp = mi => {
|
|
||||||
|
bg.GetWidget("BUTTON_PREV").OnMouseUp = mi =>
|
||||||
|
{
|
||||||
Sound.PlayMusic(GetPrevSong());
|
Sound.PlayMusic(GetPrevSong());
|
||||||
Sound.MusicStopped = false;
|
Sound.MusicStopped = false;
|
||||||
Sound.MusicPaused = false;
|
Sound.MusicPaused = false;
|
||||||
@@ -71,11 +80,13 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
if (!Rules.Music.ContainsKey("allmusic")) return null;
|
if (!Rules.Music.ContainsKey("allmusic")) return null;
|
||||||
return Rules.Music["allmusic"].Pool.GetNext();
|
return Rules.Music["allmusic"].Pool.GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
string GetPrevSong()
|
string GetPrevSong()
|
||||||
{
|
{
|
||||||
if (!Rules.Music.ContainsKey("allmusic")) return null;
|
if (!Rules.Music.ContainsKey("allmusic")) return null;
|
||||||
return Rules.Music["allmusic"].Pool.GetPrev();
|
return Rules.Music["allmusic"].Pool.GetPrev();
|
||||||
}
|
}
|
||||||
|
|
||||||
string GetSong()
|
string GetSong()
|
||||||
{
|
{
|
||||||
if (!Rules.Music.ContainsKey("allmusic")) return null;
|
if (!Rules.Music.ContainsKey("allmusic")) return null;
|
||||||
|
|||||||
@@ -17,8 +17,7 @@
|
|||||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
using System;
|
|
||||||
using OpenRA.FileFormats;
|
|
||||||
using OpenRA.Support;
|
using OpenRA.Support;
|
||||||
|
|
||||||
namespace OpenRA.Widgets.Delegates
|
namespace OpenRA.Widgets.Delegates
|
||||||
@@ -29,19 +28,17 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
{
|
{
|
||||||
var r = Chrome.rootWidget;
|
var r = Chrome.rootWidget;
|
||||||
var perfRoot = r.GetWidget("PERF_BG");
|
var perfRoot = r.GetWidget("PERF_BG");
|
||||||
perfRoot.IsVisible = () => {return (perfRoot.Visible && Game.Settings.PerfDebug);};
|
perfRoot.IsVisible = () => perfRoot.Visible && Game.Settings.PerfDebug;
|
||||||
|
|
||||||
// Perf text
|
// Perf text
|
||||||
var perfText = perfRoot.GetWidget<LabelWidget>("TEXT");
|
var perfText = perfRoot.GetWidget<LabelWidget>("TEXT");
|
||||||
perfText.GetText = () => {
|
perfText.GetText = () => "Render {0} ({5}={2:F1} ms)\nTick {4} ({3:F1} ms)".F(
|
||||||
return "Render {0} ({5}={2:F1} ms)\nTick {4} ({3:F1} ms)".F(
|
|
||||||
Game.RenderFrame,
|
Game.RenderFrame,
|
||||||
Game.orderManager.FrameNumber,
|
Game.orderManager.FrameNumber,
|
||||||
PerfHistory.items["render"].LastValue,
|
PerfHistory.items["render"].LastValue,
|
||||||
PerfHistory.items["tick_time"].LastValue,
|
PerfHistory.items["tick_time"].LastValue,
|
||||||
Game.LocalTick,
|
Game.LocalTick,
|
||||||
PerfHistory.items["batches"].LastValue);
|
PerfHistory.items["batches"].LastValue);
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Server;
|
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using System;
|
using OpenRA.Server;
|
||||||
|
|
||||||
namespace OpenRA.Widgets.Delegates
|
namespace OpenRA.Widgets.Delegates
|
||||||
{
|
{
|
||||||
@@ -63,7 +62,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
preview.IsVisible = () => CurrentMap() != null;
|
preview.IsVisible = () => CurrentMap() != null;
|
||||||
|
|
||||||
bg.GetWidget<LabelWidget>("SERVER_IP").GetText = () => currentServer.Address;
|
bg.GetWidget<LabelWidget>("SERVER_IP").GetText = () => currentServer.Address;
|
||||||
bg.GetWidget<LabelWidget>("SERVER_MODS").GetText = () => string.Join( ",", currentServer.Mods );
|
bg.GetWidget<LabelWidget>("SERVER_MODS").GetText = () => string.Join(",", currentServer.Mods);
|
||||||
bg.GetWidget<LabelWidget>("MAP_TITLE").GetText = () => (CurrentMap() != null) ? CurrentMap().Title : "Unknown";
|
bg.GetWidget<LabelWidget>("MAP_TITLE").GetText = () => (CurrentMap() != null) ? CurrentMap().Title : "Unknown";
|
||||||
bg.GetWidget<LabelWidget>("MAP_PLAYERS").GetText = () =>
|
bg.GetWidget<LabelWidget>("MAP_PLAYERS").GetText = () =>
|
||||||
{
|
{
|
||||||
@@ -71,7 +70,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
return "";
|
return "";
|
||||||
string ret = currentServer.Players.ToString();
|
string ret = currentServer.Players.ToString();
|
||||||
if (CurrentMap() != null)
|
if (CurrentMap() != null)
|
||||||
ret += "/"+CurrentMap().PlayerCount.ToString();
|
ret += "/" + CurrentMap().PlayerCount.ToString();
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -137,7 +136,8 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Direct Connect
|
// Direct Connect
|
||||||
dc.GetWidget("JOIN_BUTTON").OnMouseUp = mi => {
|
dc.GetWidget("JOIN_BUTTON").OnMouseUp = mi =>
|
||||||
|
{
|
||||||
|
|
||||||
var address = dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text;
|
var address = dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text;
|
||||||
var cpts = address.Split(':').ToArray();
|
var cpts = address.Split(':').ToArray();
|
||||||
@@ -152,7 +152,8 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
dc.GetWidget("CANCEL_BUTTON").OnMouseUp = mi => {
|
dc.GetWidget("CANCEL_BUTTON").OnMouseUp = mi =>
|
||||||
|
{
|
||||||
r.CloseWindow();
|
r.CloseWindow();
|
||||||
return r.GetWidget("MAINMENU_BUTTON_JOIN").OnMouseUp(mi);
|
return r.GetWidget("MAINMENU_BUTTON_JOIN").OnMouseUp(mi);
|
||||||
};
|
};
|
||||||
@@ -160,7 +161,8 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
|
|
||||||
MapStub CurrentMap()
|
MapStub CurrentMap()
|
||||||
{
|
{
|
||||||
return (currentServer == null || !Game.AvailableMaps.ContainsKey(currentServer.Map)) ? null : Game.AvailableMaps[currentServer.Map];
|
return (currentServer == null || !Game.AvailableMaps.ContainsKey(currentServer.Map))
|
||||||
|
? null : Game.AvailableMaps[currentServer.Map];
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefreshServerList(IEnumerable<GameServer> games)
|
void RefreshServerList(IEnumerable<GameServer> games)
|
||||||
@@ -190,15 +192,15 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
|
|
||||||
int offset = ServerTemplate.Bounds.Y;
|
int offset = ServerTemplate.Bounds.Y;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var game in games.Where( g => g.State == 1 )) /* only "waiting for players" */
|
foreach (var game in games.Where(g => g.State == 1)) /* only "waiting for players" */
|
||||||
{
|
{
|
||||||
var template = ServerTemplate.Clone() as LabelWidget;
|
var template = ServerTemplate.Clone() as LabelWidget;
|
||||||
template.Id = "JOIN_GAME_{0}".F(i);
|
template.Id = "JOIN_GAME_{0}".F(i);
|
||||||
template.GetText = () => " {0} ({1})".F( /* /8 = hack */
|
template.GetText = () => " {0} ({1})".F( /* /8 = hack */
|
||||||
game.Name,
|
game.Name,
|
||||||
game.Address);
|
game.Address);
|
||||||
template.GetBackground = () => ((currentServer == game) ? "dialog2" : null);
|
template.GetBackground = () => (currentServer == game) ? "dialog2" : null;
|
||||||
template.OnMouseDown = mi => {currentServer = game; return true;};
|
template.OnMouseDown = mi => { currentServer = game; return true; };
|
||||||
template.Parent = sl;
|
template.Parent = sl;
|
||||||
|
|
||||||
template.Bounds = new Rectangle(template.Bounds.X, offset, template.Bounds.Width, template.Bounds.Height);
|
template.Bounds = new Rectangle(template.Bounds.X, offset, template.Bounds.Width, template.Bounds.Height);
|
||||||
|
|||||||
@@ -11,32 +11,31 @@ namespace OpenRA.Widgets
|
|||||||
public Func<string> GetImageName;
|
public Func<string> GetImageName;
|
||||||
public Func<string> GetImageCollection;
|
public Func<string> GetImageCollection;
|
||||||
|
|
||||||
public ImageWidget ()
|
public ImageWidget()
|
||||||
: base()
|
: base()
|
||||||
{
|
{
|
||||||
GetImageName = () => { return ImageName; };
|
GetImageName = () => { return ImageName; };
|
||||||
GetImageCollection = () => { return ImageCollection; };
|
GetImageCollection = () => { return ImageCollection; };
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageWidget(Widget other)
|
protected ImageWidget(ImageWidget other)
|
||||||
: base(other)
|
: base(other)
|
||||||
{
|
{
|
||||||
ImageName = (other as ImageWidget).ImageName;
|
ImageName = other.ImageName;
|
||||||
GetImageName = (other as ImageWidget).GetImageName;
|
GetImageName = other.GetImageName;
|
||||||
ImageCollection = (other as ImageWidget).ImageCollection;
|
ImageCollection = other.ImageCollection;
|
||||||
GetImageCollection = (other as ImageWidget).GetImageCollection;
|
GetImageCollection = other.GetImageCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Widget Clone()
|
public override Widget Clone() { return new ImageWidget(this); }
|
||||||
{
|
|
||||||
return new ImageWidget(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void DrawInner(World world)
|
public override void DrawInner(World world)
|
||||||
{
|
{
|
||||||
var name = GetImageName();
|
var name = GetImageName();
|
||||||
var collection = GetImageCollection();
|
var collection = GetImageCollection();
|
||||||
WidgetUtils.DrawRGBA(ChromeProvider.GetImage(Game.chrome.renderer, collection, name), RenderOrigin);
|
WidgetUtils.DrawRGBA(
|
||||||
|
ChromeProvider.GetImage(Game.chrome.renderer, collection, name),
|
||||||
|
RenderOrigin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,19 +18,14 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Drawing;
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
namespace OpenRA.Widgets
|
||||||
{
|
{
|
||||||
class LabelWidget : Widget
|
class LabelWidget : Widget
|
||||||
{
|
{
|
||||||
public enum TextAlign
|
public enum TextAlign { Left, Center, Right }
|
||||||
{
|
|
||||||
Left,
|
|
||||||
Center,
|
|
||||||
Right
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Text = null;
|
public string Text = null;
|
||||||
public string Background = null;
|
public string Background = null;
|
||||||
@@ -46,14 +41,14 @@ namespace OpenRA.Widgets
|
|||||||
GetBackground = () => { return Background; };
|
GetBackground = () => { return Background; };
|
||||||
}
|
}
|
||||||
|
|
||||||
public LabelWidget(Widget other)
|
protected LabelWidget(LabelWidget other)
|
||||||
: base(other)
|
: base(other)
|
||||||
{
|
{
|
||||||
Text = (other as LabelWidget).Text;
|
Text = other.Text;
|
||||||
Align = (other as LabelWidget).Align;
|
Align = other.Align;
|
||||||
Bold = (other as LabelWidget).Bold;
|
Bold = other.Bold;
|
||||||
GetText = (other as LabelWidget).GetText;
|
GetText = other.GetText;
|
||||||
GetBackground = (other as LabelWidget).GetBackground;
|
GetBackground = other.GetBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DrawInner(World world)
|
public override void DrawInner(World world)
|
||||||
@@ -80,9 +75,6 @@ namespace OpenRA.Widgets
|
|||||||
font.DrawText(text, position, Color.White);
|
font.DrawText(text, position, Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Widget Clone()
|
public override Widget Clone() { return new LabelWidget(this); }
|
||||||
{
|
|
||||||
return new LabelWidget(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
using System.Drawing;
|
|
||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
@@ -19,6 +18,8 @@ using System.Drawing;
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
namespace OpenRA.Widgets
|
||||||
{
|
{
|
||||||
class ListBoxWidget : Widget
|
class ListBoxWidget : Widget
|
||||||
@@ -39,17 +40,17 @@ namespace OpenRA.Widgets
|
|||||||
Rectangle scrollbarRect;
|
Rectangle scrollbarRect;
|
||||||
|
|
||||||
public ListBoxWidget() : base() {}
|
public ListBoxWidget() : base() {}
|
||||||
public ListBoxWidget(Widget other)
|
protected ListBoxWidget(ListBoxWidget other)
|
||||||
: base(other)
|
: base(other)
|
||||||
{
|
{
|
||||||
Background = (other as ListBoxWidget).Background;
|
Background = other.Background;
|
||||||
upButtonRect = (other as ListBoxWidget).upButtonRect;
|
upButtonRect = other.upButtonRect;
|
||||||
downButtonRect = (other as ListBoxWidget).downButtonRect;
|
downButtonRect = other.downButtonRect;
|
||||||
scrollbarRect = (other as ListBoxWidget).scrollbarRect;
|
scrollbarRect = other.scrollbarRect;
|
||||||
backgroundRect = (other as ListBoxWidget).backgroundRect;
|
backgroundRect = other.backgroundRect;
|
||||||
|
|
||||||
UpPressed = (other as ListBoxWidget).UpPressed;
|
UpPressed = other.UpPressed;
|
||||||
DownPressed = (other as ListBoxWidget).DownPressed;
|
DownPressed = other.DownPressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DrawInner(World world) {}
|
public override void DrawInner(World world) {}
|
||||||
@@ -61,27 +62,26 @@ namespace OpenRA.Widgets
|
|||||||
backgroundRect = new Rectangle(RenderBounds.X, RenderBounds.Y, RenderBounds.Width - ScrollbarWidth, RenderBounds.Height);
|
backgroundRect = new Rectangle(RenderBounds.X, RenderBounds.Y, RenderBounds.Width - ScrollbarWidth, RenderBounds.Height);
|
||||||
upButtonRect = new Rectangle(RenderBounds.Right - ScrollbarWidth, RenderBounds.Y, ScrollbarWidth, ScrollbarWidth);
|
upButtonRect = new Rectangle(RenderBounds.Right - ScrollbarWidth, RenderBounds.Y, ScrollbarWidth, ScrollbarWidth);
|
||||||
downButtonRect = new Rectangle(RenderBounds.Right - ScrollbarWidth, RenderBounds.Bottom - ScrollbarWidth, ScrollbarWidth, ScrollbarWidth);
|
downButtonRect = new Rectangle(RenderBounds.Right - ScrollbarWidth, RenderBounds.Bottom - ScrollbarWidth, ScrollbarWidth, ScrollbarWidth);
|
||||||
scrollbarRect = new Rectangle(RenderBounds.Right - ScrollbarWidth, RenderBounds.Y + ScrollbarWidth, ScrollbarWidth, RenderBounds.Height - 2*ScrollbarWidth);
|
scrollbarRect = new Rectangle(RenderBounds.Right - ScrollbarWidth, RenderBounds.Y + ScrollbarWidth, ScrollbarWidth, RenderBounds.Height - 2 * ScrollbarWidth);
|
||||||
|
|
||||||
string upButtonBg = (UpPressed) ? "dialog3" : "dialog2";
|
string upButtonBg = (UpPressed) ? "dialog3" : "dialog2";
|
||||||
string downButtonBg = (DownPressed) ? "dialog3" : "dialog2";
|
string downButtonBg = (DownPressed) ? "dialog3" : "dialog2";
|
||||||
string scrolbarBg = "dialog3";
|
string scrollbarBg = "dialog3";
|
||||||
string scrollbarButton = "dialog2";
|
|
||||||
|
|
||||||
WidgetUtils.DrawPanel(Background, backgroundRect);
|
WidgetUtils.DrawPanel(Background, backgroundRect);
|
||||||
WidgetUtils.DrawPanel(upButtonBg, upButtonRect);
|
WidgetUtils.DrawPanel(upButtonBg, upButtonRect);
|
||||||
WidgetUtils.DrawPanel(downButtonBg, downButtonRect);
|
WidgetUtils.DrawPanel(downButtonBg, downButtonRect);
|
||||||
WidgetUtils.DrawPanel(scrolbarBg, scrollbarRect);
|
WidgetUtils.DrawPanel(scrollbarBg, scrollbarRect);
|
||||||
|
|
||||||
|
|
||||||
Game.chrome.renderer.Device.EnableScissor(backgroundRect.X, backgroundRect.Y + HeaderHeight, backgroundRect.Width, backgroundRect.Height - HeaderHeight);
|
Game.chrome.renderer.Device.EnableScissor(backgroundRect.X, backgroundRect.Y + HeaderHeight, backgroundRect.Width, backgroundRect.Height - HeaderHeight);
|
||||||
|
|
||||||
foreach (var child in Children)
|
foreach (var child in Children)
|
||||||
child.Draw(world);
|
child.Draw(world);
|
||||||
|
|
||||||
Game.chrome.renderer.RgbaSpriteRenderer.Flush();
|
Game.chrome.renderer.RgbaSpriteRenderer.Flush();
|
||||||
Game.chrome.renderer.Device.DisableScissor();
|
Game.chrome.renderer.Device.DisableScissor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int2 ChildOrigin { get { return RenderOrigin + new int2(0, (int)ListOffset); } }
|
public override int2 ChildOrigin { get { return RenderOrigin + new int2(0, (int)ListOffset); } }
|
||||||
|
|
||||||
public override void Tick (World world)
|
public override void Tick (World world)
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using OpenRA.Graphics;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
namespace OpenRA.Widgets
|
||||||
{
|
{
|
||||||
@@ -15,24 +14,25 @@ namespace OpenRA.Widgets
|
|||||||
bool mapPreviewDirty = true;
|
bool mapPreviewDirty = true;
|
||||||
MapStub lastMap;
|
MapStub lastMap;
|
||||||
|
|
||||||
public Func<MapStub> Map = () => {return null;};
|
public Func<MapStub> Map = () => null;
|
||||||
public Action<int> OnSpawnClick = spawn => {};
|
public Action<int> OnSpawnClick = spawn => {};
|
||||||
public Func<Dictionary<int2,Color>> SpawnColors = () => {return new Dictionary<int2, Color>(); };
|
public Func<Dictionary<int2, Color>> SpawnColors = () => new Dictionary<int2, Color>();
|
||||||
|
|
||||||
public MapPreviewWidget() : base() { }
|
public MapPreviewWidget() : base() { }
|
||||||
|
|
||||||
public MapPreviewWidget(Widget other)
|
protected MapPreviewWidget(MapPreviewWidget other)
|
||||||
: base(other)
|
: base(other)
|
||||||
{
|
{
|
||||||
lastMap = (other as MapPreviewWidget).lastMap;
|
lastMap = other.lastMap;
|
||||||
Map = (other as MapPreviewWidget).Map;
|
Map = other.Map;
|
||||||
OnSpawnClick = (other as MapPreviewWidget).OnSpawnClick;
|
OnSpawnClick = other.OnSpawnClick;
|
||||||
SpawnColors = (other as MapPreviewWidget).SpawnColors;
|
SpawnColors = other.SpawnColors;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Sprite UnownedSpawn = null;
|
static Sprite UnownedSpawn = null;
|
||||||
static Sprite OwnedSpawn = null;
|
static Sprite OwnedSpawn = null;
|
||||||
const int closeEnough = 50;
|
const int closeEnough = 50;
|
||||||
|
|
||||||
public override bool HandleInput(MouseInput mi)
|
public override bool HandleInput(MouseInput mi)
|
||||||
{
|
{
|
||||||
var map = Map();
|
var map = Map();
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace OpenRA.Widgets
|
|||||||
void AddButton(Rectangle r, Action<MouseInput> b) { buttons.Add(Pair.New(r, b)); }
|
void AddButton(Rectangle r, Action<MouseInput> b) { buttons.Add(Pair.New(r, b)); }
|
||||||
|
|
||||||
public MoneyBinWidget() : base() { }
|
public MoneyBinWidget() : base() { }
|
||||||
public MoneyBinWidget(Widget other) : base(other) { }
|
protected MoneyBinWidget(Widget other) : base(other) { }
|
||||||
|
|
||||||
public override Widget Clone() { return new MoneyBinWidget(this); }
|
public override Widget Clone() { return new MoneyBinWidget(this); }
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Support;
|
using OpenRA.Support;
|
||||||
|
|
||||||
@@ -28,18 +28,14 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
public PerfGraphWidget() : base() { }
|
public PerfGraphWidget() : base() { }
|
||||||
|
|
||||||
public PerfGraphWidget(Widget other) : base(other) { }
|
|
||||||
|
|
||||||
public override Widget Clone() { return new PerfGraphWidget(this); }
|
|
||||||
|
|
||||||
public override void DrawInner(World world)
|
public override void DrawInner(World world)
|
||||||
{
|
{
|
||||||
var rect = RenderBounds;
|
var rect = RenderBounds;
|
||||||
float2 origin = Game.viewport.Location + new float2(rect.Right,rect.Bottom);
|
float2 origin = Game.viewport.Location + new float2(rect.Right, rect.Bottom);
|
||||||
float2 basis = new float2(-rect.Width/100,-rect.Height/100);
|
float2 basis = new float2(-rect.Width / 100, -rect.Height / 100);
|
||||||
|
|
||||||
Game.chrome.lineRenderer.DrawLine(origin, origin + new float2(100, 0) * basis, Color.White, Color.White);
|
Game.chrome.lineRenderer.DrawLine(origin, origin + new float2(100, 0) * basis, Color.White, Color.White);
|
||||||
Game.chrome.lineRenderer.DrawLine(origin + new float2(100,0) * basis, origin + new float2(100,100) * basis, Color.White, Color.White);
|
Game.chrome.lineRenderer.DrawLine(origin + new float2(100, 0) * basis, origin + new float2(100, 100) * basis, Color.White, Color.White);
|
||||||
|
|
||||||
foreach (var item in PerfHistory.items.Values)
|
foreach (var item in PerfHistory.items.Values)
|
||||||
{
|
{
|
||||||
@@ -48,7 +44,7 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
Game.chrome.lineRenderer.DrawLine(
|
Game.chrome.lineRenderer.DrawLine(
|
||||||
origin + new float2(n, (float)a) * basis,
|
origin + new float2(n, (float)a) * basis,
|
||||||
origin + new float2(n+1, (float)b) * basis,
|
origin + new float2(n + 1, (float)b) * basis,
|
||||||
item.c, item.c);
|
item.c, item.c);
|
||||||
++n;
|
++n;
|
||||||
return b;
|
return b;
|
||||||
|
|||||||
@@ -28,10 +28,6 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
public PostGameWidget() : base() { }
|
public PostGameWidget() : base() { }
|
||||||
|
|
||||||
public PostGameWidget(Widget other) : base(other) { }
|
|
||||||
|
|
||||||
public override Widget Clone() { return new PostGameWidget(this); }
|
|
||||||
|
|
||||||
bool AreMutualAllies(Player a, Player b) { return a.Stances[b] == Stance.Ally && b.Stances[a] == Stance.Ally; }
|
bool AreMutualAllies(Player a, Player b) { return a.Stances[b] == Stance.Ally && b.Stances[a] == Stance.Ally; }
|
||||||
|
|
||||||
// todo: all this shit needs to move, probably to Player.
|
// todo: all this shit needs to move, probably to Player.
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Widgets
|
namespace OpenRA.Widgets
|
||||||
{
|
{
|
||||||
|
|
||||||
public class PowerBinWidget : Widget
|
public class PowerBinWidget : Widget
|
||||||
{
|
{
|
||||||
// Power bar
|
// Power bar
|
||||||
@@ -35,8 +34,6 @@ namespace OpenRA.Widgets
|
|||||||
float? lastPowerDrainedPos;
|
float? lastPowerDrainedPos;
|
||||||
string powerCollection;
|
string powerCollection;
|
||||||
|
|
||||||
public override Widget Clone() { throw new NotImplementedException("Why are you Cloning PowerBin?"); }
|
|
||||||
|
|
||||||
public override void DrawInner(World world)
|
public override void DrawInner(World world)
|
||||||
{
|
{
|
||||||
powerCollection = "power-" + world.LocalPlayer.Country.Race;
|
powerCollection = "power-" + world.LocalPlayer.Country.Race;
|
||||||
|
|||||||
@@ -76,8 +76,6 @@ namespace OpenRA.Widgets
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Widget Clone() { throw new NotImplementedException("Why are you Cloning RadarBin?"); }
|
|
||||||
|
|
||||||
public override void DrawInner(World world)
|
public override void DrawInner(World world)
|
||||||
{
|
{
|
||||||
radarCollection = "radar-" + world.LocalPlayer.Country.Race;
|
radarCollection = "radar-" + world.LocalPlayer.Country.Race;
|
||||||
@@ -143,7 +141,7 @@ namespace OpenRA.Widgets
|
|||||||
radarMinimapHeight = float2.Lerp(0, 192, (radarAnimationFrame - radarSlideAnimationLength) * 1.0f / radarActivateAnimationLength);
|
radarMinimapHeight = float2.Lerp(0, 192, (radarAnimationFrame - radarSlideAnimationLength) * 1.0f / radarActivateAnimationLength);
|
||||||
|
|
||||||
// Animation is complete
|
// Animation is complete
|
||||||
if (radarAnimationFrame == (hasRadar ? radarSlideAnimationLength+radarActivateAnimationLength : 0))
|
if (radarAnimationFrame == (hasRadar ? radarSlideAnimationLength + radarActivateAnimationLength : 0))
|
||||||
radarAnimating = false;
|
radarAnimating = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,22 +14,23 @@ namespace OpenRA.Widgets
|
|||||||
int2 lastMouseLocation;
|
int2 lastMouseLocation;
|
||||||
bool isMoving = false;
|
bool isMoving = false;
|
||||||
|
|
||||||
public SliderWidget () : base()
|
public SliderWidget()
|
||||||
|
: base()
|
||||||
{
|
{
|
||||||
GetOffset = () => Offset;
|
GetOffset = () => Offset;
|
||||||
OnChange = x => Offset = x;
|
OnChange = x => Offset = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SliderWidget(Widget other)
|
public SliderWidget(SliderWidget other)
|
||||||
: base(other)
|
: base(other)
|
||||||
{
|
{
|
||||||
OnChange = (other as SliderWidget).OnChange;
|
OnChange = other.OnChange;
|
||||||
GetOffset = (other as SliderWidget).GetOffset;
|
GetOffset = other.GetOffset;
|
||||||
Offset = (other as SliderWidget).Offset;
|
Offset = other.Offset;
|
||||||
Ticks = (other as SliderWidget).Ticks;
|
Ticks = other.Ticks;
|
||||||
TrackHeight = (other as SliderWidget).TrackHeight;
|
TrackHeight = other.TrackHeight;
|
||||||
lastMouseLocation = (other as SliderWidget).lastMouseLocation;
|
lastMouseLocation = other.lastMouseLocation;
|
||||||
isMoving = (other as SliderWidget).isMoving;
|
isMoving = other.isMoving;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandleInput(MouseInput mi)
|
public override bool HandleInput(MouseInput mi)
|
||||||
@@ -43,17 +44,17 @@ namespace OpenRA.Widgets
|
|||||||
switch (mi.Event)
|
switch (mi.Event)
|
||||||
{
|
{
|
||||||
case MouseInputEvent.Up:
|
case MouseInputEvent.Up:
|
||||||
{
|
{
|
||||||
if (Focused)
|
if (Focused)
|
||||||
{
|
{
|
||||||
isMoving = false;
|
isMoving = false;
|
||||||
base.LoseFocus(mi);
|
base.LoseFocus(mi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MouseInputEvent.Down:
|
case MouseInputEvent.Down:
|
||||||
{
|
{
|
||||||
if (thumbRect.Contains(mi.Location.ToPoint()))
|
if (thumbRect.Contains(mi.Location.ToPoint()))
|
||||||
{
|
{
|
||||||
isMoving = true;
|
isMoving = true;
|
||||||
@@ -65,9 +66,9 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
// Offset slightly the direction we want to move so we don't get stuck on a tick
|
// Offset slightly the direction we want to move so we don't get stuck on a tick
|
||||||
var delta = 0.001;
|
var delta = 0.001;
|
||||||
var targetTick = (float)((mi.Location.X > thumbRect.Right) ? Math.Ceiling((pos+delta)*(Ticks-1))
|
var targetTick = (float)((mi.Location.X > thumbRect.Right) ? Math.Ceiling((pos + delta) * (Ticks - 1))
|
||||||
: Math.Floor((pos-delta)*(Ticks-1)));
|
: Math.Floor((pos - delta) * (Ticks - 1)));
|
||||||
OnChange(targetTick/(Ticks-1));
|
OnChange(targetTick / (Ticks - 1));
|
||||||
|
|
||||||
if (thumbRect.Contains(mi.Location.ToPoint()))
|
if (thumbRect.Contains(mi.Location.ToPoint()))
|
||||||
{
|
{
|
||||||
@@ -79,8 +80,8 @@ namespace OpenRA.Widgets
|
|||||||
else // No ticks; move to the mouse position
|
else // No ticks; move to the mouse position
|
||||||
{
|
{
|
||||||
var thumb = thumbRect;
|
var thumb = thumbRect;
|
||||||
var center = thumb.X + thumb.Width/2;
|
var center = thumb.X + thumb.Width / 2;
|
||||||
var newOffset = OffsetBy((mi.Location.X - center)*1f/(RenderBounds.Width-thumb.Width));
|
var newOffset = OffsetBy((mi.Location.X - center) * 1f / (RenderBounds.Width - thumb.Width));
|
||||||
if (newOffset != GetOffset())
|
if (newOffset != GetOffset())
|
||||||
{
|
{
|
||||||
OnChange(newOffset);
|
OnChange(newOffset);
|
||||||
@@ -93,25 +94,25 @@ namespace OpenRA.Widgets
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MouseInputEvent.Move:
|
case MouseInputEvent.Move:
|
||||||
{
|
|
||||||
if ((mi.Location.X != lastMouseLocation.X) && isMoving)
|
|
||||||
{
|
{
|
||||||
var newOffset = OffsetBy((mi.Location.X - lastMouseLocation.X)*1f/(RenderBounds.Width-thumbRect.Width));
|
if ((mi.Location.X != lastMouseLocation.X) && isMoving)
|
||||||
if (newOffset != Offset)
|
|
||||||
{
|
{
|
||||||
lastMouseLocation = mi.Location;
|
var newOffset = OffsetBy((mi.Location.X - lastMouseLocation.X) * 1f / (RenderBounds.Width - thumbRect.Width));
|
||||||
OnChange(newOffset);
|
if (newOffset != Offset)
|
||||||
|
{
|
||||||
|
lastMouseLocation = mi.Location;
|
||||||
|
OnChange(newOffset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return thumbRect.Contains(mi.Location.X,mi.Location.Y);
|
return thumbRect.Contains(mi.Location.X, mi.Location.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
float OffsetBy(float amount)
|
float OffsetBy(float amount)
|
||||||
@@ -125,26 +126,30 @@ namespace OpenRA.Widgets
|
|||||||
public override Widget Clone() { return new SliderWidget(this); }
|
public override Widget Clone() { return new SliderWidget(this); }
|
||||||
|
|
||||||
Rectangle thumbRect
|
Rectangle thumbRect
|
||||||
{ get {
|
{
|
||||||
var width = RenderBounds.Height;
|
get
|
||||||
var height = RenderBounds.Height;
|
{
|
||||||
var origin = (int)((RenderBounds.X + width/2) + GetOffset()*(RenderBounds.Width - width) - width/2f);
|
var width = RenderBounds.Height;
|
||||||
return new Rectangle(origin, RenderBounds.Y, width, height);
|
var height = RenderBounds.Height;
|
||||||
} }
|
var origin = (int)((RenderBounds.X + width / 2) + GetOffset() * (RenderBounds.Width - width) - width / 2f);
|
||||||
|
return new Rectangle(origin, RenderBounds.Y, width, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void DrawInner(World world) {
|
public override void DrawInner(World world)
|
||||||
|
{
|
||||||
if (!IsVisible())
|
if (!IsVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var trackWidth = RenderBounds.Width - thumbRect.Width;
|
var trackWidth = RenderBounds.Width - thumbRect.Width;
|
||||||
var trackOrigin = RenderBounds.X + thumbRect.Width/2;
|
var trackOrigin = RenderBounds.X + thumbRect.Width / 2;
|
||||||
var trackRect = new Rectangle(trackOrigin-1, RenderBounds.Y + (RenderBounds.Height - TrackHeight)/2, trackWidth+2, TrackHeight);
|
var trackRect = new Rectangle(trackOrigin - 1, RenderBounds.Y + (RenderBounds.Height - TrackHeight) / 2, trackWidth + 2, TrackHeight);
|
||||||
|
|
||||||
// Tickmarks (hacked until we have real art)
|
// Tickmarks (hacked until we have real art)
|
||||||
for (int i = 0; i < Ticks; i++)
|
for (int i = 0; i < Ticks; i++)
|
||||||
{
|
{
|
||||||
var tickRect = new Rectangle(trackOrigin -1 + (int)(i*trackWidth*1f/(Ticks-1)),
|
var tickRect = new Rectangle(trackOrigin - 1 + (int)(i * trackWidth * 1f / (Ticks - 1)),
|
||||||
RenderBounds.Y + RenderBounds.Height/2, 2, RenderBounds.Height/2);
|
RenderBounds.Y + RenderBounds.Height / 2, 2, RenderBounds.Height / 2);
|
||||||
WidgetUtils.DrawPanel("dialog2", tickRect);
|
WidgetUtils.DrawPanel("dialog2", tickRect);
|
||||||
}
|
}
|
||||||
// Track
|
// Track
|
||||||
|
|||||||
@@ -18,14 +18,14 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using OpenRA;
|
|
||||||
using OpenRA.Traits;
|
|
||||||
using OpenRA.Graphics;
|
|
||||||
using OpenRA.FileFormats;
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
namespace OpenRA.Widgets
|
||||||
{
|
{
|
||||||
class SpecialPowerBinWidget : Widget
|
class SpecialPowerBinWidget : Widget
|
||||||
@@ -37,16 +37,6 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public SpecialPowerBinWidget() : base() { }
|
public SpecialPowerBinWidget() : base() { }
|
||||||
|
|
||||||
public SpecialPowerBinWidget(Widget other)
|
|
||||||
: base(other)
|
|
||||||
{
|
|
||||||
ready = (other as SpecialPowerBinWidget).ready;
|
|
||||||
clock = (other as SpecialPowerBinWidget).clock;
|
|
||||||
buttons = (other as SpecialPowerBinWidget).buttons;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Widget Clone() { return new SpecialPowerBinWidget(this); }
|
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|||||||
@@ -18,8 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Drawing;
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
namespace OpenRA.Widgets
|
||||||
{
|
{
|
||||||
@@ -29,22 +29,22 @@ namespace OpenRA.Widgets
|
|||||||
public int MaxLength = 0;
|
public int MaxLength = 0;
|
||||||
public bool Bold = false;
|
public bool Bold = false;
|
||||||
public int VisualHeight = 1;
|
public int VisualHeight = 1;
|
||||||
public Func<bool> OnEnterKey = () => {return false;};
|
public Func<bool> OnEnterKey = () => false;
|
||||||
public Func<bool> OnTabKey = () => {return false;};
|
public Func<bool> OnTabKey = () => false;
|
||||||
public Action OnLoseFocus = () => {};
|
public Action OnLoseFocus = () => { };
|
||||||
|
|
||||||
public TextFieldWidget()
|
public TextFieldWidget()
|
||||||
: base()
|
: base()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextFieldWidget(Widget widget)
|
protected TextFieldWidget(TextFieldWidget widget)
|
||||||
:base(widget)
|
: base(widget)
|
||||||
{
|
{
|
||||||
Text = (widget as TextFieldWidget).Text;
|
Text = widget.Text;
|
||||||
MaxLength = (widget as TextFieldWidget).MaxLength;
|
MaxLength = widget.MaxLength;
|
||||||
Bold = (widget as TextFieldWidget).Bold;
|
Bold = widget.Bold;
|
||||||
VisualHeight = (widget as TextFieldWidget).VisualHeight;
|
VisualHeight = widget.VisualHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool LoseFocus(MouseInput mi)
|
public override bool LoseFocus(MouseInput mi)
|
||||||
@@ -60,7 +60,7 @@ namespace OpenRA.Widgets
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Lose focus if they click outside the box; return false so the next widget can grab this event
|
// Lose focus if they click outside the box; return false so the next widget can grab this event
|
||||||
if (mi.Event == MouseInputEvent.Down && !RenderBounds.Contains(mi.Location.X,mi.Location.Y) && LoseFocus(mi))
|
if (mi.Event == MouseInputEvent.Down && !RenderBounds.Contains(mi.Location.X, mi.Location.Y) && LoseFocus(mi))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (mi.Event == MouseInputEvent.Down && !TakeFocus(mi))
|
if (mi.Event == MouseInputEvent.Down && !TakeFocus(mi))
|
||||||
@@ -124,32 +124,29 @@ namespace OpenRA.Widgets
|
|||||||
var pos = RenderOrigin;
|
var pos = RenderOrigin;
|
||||||
|
|
||||||
WidgetUtils.DrawPanel("dialog3",
|
WidgetUtils.DrawPanel("dialog3",
|
||||||
new Rectangle(pos.X, pos.Y, Bounds.Width, Bounds.Height ) );
|
new Rectangle(pos.X, pos.Y, Bounds.Width, Bounds.Height));
|
||||||
|
|
||||||
// Inset text by the margin and center vertically
|
// Inset text by the margin and center vertically
|
||||||
var textPos = pos + new int2( margin, (Bounds.Height - textSize.Y)/2 - VisualHeight);
|
var textPos = pos + new int2(margin, (Bounds.Height - textSize.Y) / 2 - VisualHeight);
|
||||||
|
|
||||||
// Right align when editing and scissor when the text overflows
|
// Right align when editing and scissor when the text overflows
|
||||||
if (textSize.X > Bounds.Width - 2*margin)
|
if (textSize.X > Bounds.Width - 2 * margin)
|
||||||
{
|
{
|
||||||
if (Focused)
|
if (Focused)
|
||||||
textPos += new int2(Bounds.Width - 2*margin - textSize.X,0);
|
textPos += new int2(Bounds.Width - 2 * margin - textSize.X, 0);
|
||||||
|
|
||||||
Game.chrome.renderer.Device.EnableScissor(pos.X + margin, pos.Y, Bounds.Width - 2*margin, Bounds.Bottom);
|
Game.chrome.renderer.Device.EnableScissor(pos.X + margin, pos.Y, Bounds.Width - 2 * margin, Bounds.Bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
font.DrawText(Text + cursor, textPos, Color.White);
|
font.DrawText(Text + cursor, textPos, Color.White);
|
||||||
|
|
||||||
if (textSize.X > Bounds.Width - 2*margin)
|
if (textSize.X > Bounds.Width - 2 * margin)
|
||||||
{
|
{
|
||||||
Game.chrome.renderer.RgbaSpriteRenderer.Flush();
|
Game.chrome.renderer.RgbaSpriteRenderer.Flush();
|
||||||
Game.chrome.renderer.Device.DisableScissor();
|
Game.chrome.renderer.Device.DisableScissor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Widget Clone()
|
public override Widget Clone() { return new TextFieldWidget(this); }
|
||||||
{
|
|
||||||
return new TextFieldWidget(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,8 +22,8 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Windows.Forms;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Widgets.Delegates;
|
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
namespace OpenRA.Widgets
|
||||||
{
|
{
|
||||||
@@ -49,10 +49,10 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
// Common Funcs that most widgets will want
|
// Common Funcs that most widgets will want
|
||||||
public Action<object> SpecialOneArg = (arg) => {};
|
public Action<object> SpecialOneArg = (arg) => {};
|
||||||
public Func<MouseInput,bool> OnMouseDown = mi => {return false;};
|
public Func<MouseInput, bool> OnMouseDown = mi => false;
|
||||||
public Func<MouseInput,bool> OnMouseUp = mi => {return false;};
|
public Func<MouseInput, bool> OnMouseUp = mi => false;
|
||||||
public Func<MouseInput,bool> OnMouseMove = mi => {return false;};
|
public Func<MouseInput, bool> OnMouseMove = mi => false;
|
||||||
public Func<System.Windows.Forms.KeyPressEventArgs, Modifiers,bool> OnKeyPress = (e,modifiers) => {return false;};
|
public Func<KeyPressEventArgs, Modifiers, bool> OnKeyPress = (e, modifiers) => false;
|
||||||
|
|
||||||
public Func<bool> IsVisible;
|
public Func<bool> IsVisible;
|
||||||
|
|
||||||
@@ -83,32 +83,37 @@ namespace OpenRA.Widgets
|
|||||||
AddChild(child.Clone());
|
AddChild(child.Clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Widget Clone();
|
public virtual Widget Clone()
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Widget type `{0}` is not cloneable.".F(GetType().Name));
|
||||||
|
}
|
||||||
|
|
||||||
public virtual int2 RenderOrigin
|
public virtual int2 RenderOrigin
|
||||||
{
|
{
|
||||||
get {
|
get
|
||||||
|
{
|
||||||
var offset = (Parent == null) ? int2.Zero : Parent.ChildOrigin;
|
var offset = (Parent == null) ? int2.Zero : Parent.ChildOrigin;
|
||||||
return new int2(Bounds.X, Bounds.Y) + offset;
|
return new int2(Bounds.X, Bounds.Y) + offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual int2 ChildOrigin { get { return RenderOrigin; } }
|
public virtual int2 ChildOrigin { get { return RenderOrigin; } }
|
||||||
public virtual Rectangle RenderBounds { get { return new Rectangle(RenderOrigin.X, RenderOrigin.Y, Bounds.Width, Bounds.Height); } }
|
public virtual Rectangle RenderBounds { get { return new Rectangle(RenderOrigin.X, RenderOrigin.Y, Bounds.Width, Bounds.Height); } }
|
||||||
|
|
||||||
public virtual void Initialize()
|
public virtual void Initialize()
|
||||||
{
|
{
|
||||||
// Parse the YAML equations to find the widget bounds
|
// Parse the YAML equations to find the widget bounds
|
||||||
Rectangle parentBounds = (Parent == null)
|
var parentBounds = (Parent == null)
|
||||||
? new Rectangle(0,0,Game.viewport.Width,Game.viewport.Height)
|
? new Rectangle(0, 0, Game.viewport.Width, Game.viewport.Height)
|
||||||
: Parent.Bounds;
|
: Parent.Bounds;
|
||||||
|
|
||||||
Dictionary<string, int> substitutions = new Dictionary<string, int>();
|
var substitutions = new Dictionary<string, int>();
|
||||||
substitutions.Add("WINDOW_RIGHT", Game.viewport.Width);
|
substitutions.Add("WINDOW_RIGHT", Game.viewport.Width);
|
||||||
substitutions.Add("WINDOW_BOTTOM", Game.viewport.Height);
|
substitutions.Add("WINDOW_BOTTOM", Game.viewport.Height);
|
||||||
substitutions.Add("PARENT_RIGHT", parentBounds.Width);
|
substitutions.Add("PARENT_RIGHT", parentBounds.Width);
|
||||||
substitutions.Add("PARENT_LEFT", parentBounds.Left);
|
substitutions.Add("PARENT_LEFT", parentBounds.Left);
|
||||||
substitutions.Add("PARENT_TOP", parentBounds.Top);
|
substitutions.Add("PARENT_TOP", parentBounds.Top);
|
||||||
substitutions.Add("PARENT_BOTTOM", parentBounds.Height);
|
substitutions.Add("PARENT_BOTTOM", parentBounds.Height);
|
||||||
int width = Evaluator.Evaluate(Width, substitutions);
|
int width = Evaluator.Evaluate(Width, substitutions);
|
||||||
int height = Evaluator.Evaluate(Height, substitutions);
|
int height = Evaluator.Evaluate(Height, substitutions);
|
||||||
|
|
||||||
@@ -116,14 +121,14 @@ namespace OpenRA.Widgets
|
|||||||
substitutions.Add("HEIGHT", height);
|
substitutions.Add("HEIGHT", height);
|
||||||
|
|
||||||
Bounds = new Rectangle(Evaluator.Evaluate(X, substitutions),
|
Bounds = new Rectangle(Evaluator.Evaluate(X, substitutions),
|
||||||
Evaluator.Evaluate(Y, substitutions),
|
Evaluator.Evaluate(Y, substitutions),
|
||||||
width,
|
width,
|
||||||
height);
|
height);
|
||||||
|
|
||||||
// Non-static func definitions
|
// Non-static func definitions
|
||||||
|
|
||||||
if (Delegate != null && !Delegates.Contains(Delegate))
|
if (Delegate != null && !Delegates.Contains(Delegate))
|
||||||
Delegates.Add(Delegate);
|
Delegates.Add(Delegate);
|
||||||
|
|
||||||
foreach (var child in Children)
|
foreach (var child in Children)
|
||||||
child.Initialize();
|
child.Initialize();
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|||||||
@@ -18,12 +18,11 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Traits;
|
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
namespace OpenRA.Widgets
|
||||||
{
|
{
|
||||||
@@ -33,10 +32,6 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public WorldTooltipWidget() : base() { }
|
public WorldTooltipWidget() : base() { }
|
||||||
|
|
||||||
public WorldTooltipWidget(Widget other) : base(other) { }
|
|
||||||
|
|
||||||
public override Widget Clone() { return new WorldTooltipWidget(this); }
|
|
||||||
|
|
||||||
public override void DrawInner(World world)
|
public override void DrawInner(World world)
|
||||||
{
|
{
|
||||||
if (Game.chrome.ticksSinceLastMove < worldTooltipDelay || world == null || world.LocalPlayer == null)
|
if (Game.chrome.ticksSinceLastMove < worldTooltipDelay || world == null || world.LocalPlayer == null)
|
||||||
@@ -80,7 +75,9 @@ namespace OpenRA.Widgets
|
|||||||
renderer.RegularFont.DrawText(text3,
|
renderer.RegularFont.DrawText(text3,
|
||||||
new float2(Game.chrome.lastMousePos.X + 65 + sz2.X, Game.chrome.lastMousePos.Y + 50), Color.White);
|
new float2(Game.chrome.lastMousePos.X + 65 + sz2.X, Game.chrome.lastMousePos.Y + 50), Color.White);
|
||||||
|
|
||||||
WidgetUtils.DrawRGBA(ChromeProvider.GetImage(Game.chrome.renderer, "flags", actor.Owner.Country.Race), new float2(Game.chrome.lastMousePos.X + 30, Game.chrome.lastMousePos.Y + 50));
|
WidgetUtils.DrawRGBA(
|
||||||
|
ChromeProvider.GetImage(Game.chrome.renderer, "flags", actor.Owner.Country.Race),
|
||||||
|
new float2(Game.chrome.lastMousePos.X + 30, Game.chrome.lastMousePos.Y + 50));
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.RgbaSpriteRenderer.Flush();
|
renderer.RgbaSpriteRenderer.Flush();
|
||||||
|
|||||||
Reference in New Issue
Block a user