"Create Server" submenu
This commit is contained in:
@@ -93,9 +93,6 @@ namespace OpenRA
|
||||
Sprite mapChooserSprite;
|
||||
int mapOffset = 0;
|
||||
|
||||
|
||||
Widget rootWidget;
|
||||
|
||||
public Chrome(Renderer r)
|
||||
{
|
||||
this.renderer = r;
|
||||
@@ -136,7 +133,7 @@ namespace OpenRA
|
||||
var widgetYaml = MiniYaml.FromFile("mods/cnc/menus.yaml");
|
||||
// Hack around a bug in MiniYaml
|
||||
widgetYaml.Values.FirstOrDefault().Value = widgetYaml.Keys.FirstOrDefault();
|
||||
rootWidget = WidgetLoader.LoadWidget(widgetYaml.Values.FirstOrDefault());
|
||||
WidgetLoader.rootWidget = WidgetLoader.LoadWidget(widgetYaml.Values.FirstOrDefault());
|
||||
}
|
||||
|
||||
List<string> visibleTabs = new List<string>();
|
||||
@@ -427,7 +424,7 @@ namespace OpenRA
|
||||
|
||||
public void DrawMainMenu( World world )
|
||||
{
|
||||
rootWidget.Draw(rgbaRenderer,renderer);
|
||||
WidgetLoader.rootWidget.Draw(rgbaRenderer,renderer);
|
||||
}
|
||||
|
||||
public void DrawLobby( World world )
|
||||
@@ -1051,7 +1048,7 @@ namespace OpenRA
|
||||
int2 lastMousePos;
|
||||
public bool HandleInput(World world, MouseInput mi)
|
||||
{
|
||||
if (rootWidget.HandleInput(mi))
|
||||
if (WidgetLoader.rootWidget.HandleInput(mi))
|
||||
return true;
|
||||
|
||||
if (mi.Event == MouseInputEvent.Move)
|
||||
|
||||
@@ -7,6 +7,8 @@ namespace OpenRA.Widgets
|
||||
class BackgroundWidget : Widget
|
||||
{
|
||||
public override void Draw(SpriteRenderer rgbaRenderer, Renderer renderer)
|
||||
{
|
||||
if (Visible)
|
||||
{
|
||||
string collection = "dialog";
|
||||
|
||||
@@ -40,6 +42,7 @@ namespace OpenRA.Widgets
|
||||
rgbaRenderer.Flush();
|
||||
|
||||
renderer.Device.DisableScissor();
|
||||
}
|
||||
|
||||
base.Draw(rgbaRenderer,renderer);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
class ButtonWidget : Widget
|
||||
{
|
||||
public readonly string Text = null;
|
||||
public readonly string Text = "";
|
||||
public readonly string Action = null;
|
||||
|
||||
public override bool HandleInput(MouseInput mi)
|
||||
@@ -28,6 +28,8 @@ namespace OpenRA.Widgets
|
||||
}
|
||||
|
||||
public override void Draw(SpriteRenderer rgbaRenderer, Renderer renderer)
|
||||
{
|
||||
if (Visible)
|
||||
{
|
||||
string collection = "dialog2";
|
||||
|
||||
@@ -63,6 +65,7 @@ namespace OpenRA.Widgets
|
||||
renderer.BoldFont.DrawText(rgbaRenderer, Text, new int2(X+Width/2, Y+Height/2) - new int2(renderer.BoldFont.Measure(Text).X / 2, renderer.BoldFont.Measure(Text).Y/2), Color.White);
|
||||
|
||||
renderer.Device.DisableScissor();
|
||||
}
|
||||
|
||||
base.Draw(rgbaRenderer,renderer);
|
||||
}
|
||||
|
||||
@@ -7,13 +7,25 @@ namespace OpenRA.Widgets
|
||||
class LabelWidget : Widget
|
||||
{
|
||||
public readonly string Text = null;
|
||||
public readonly string Align = "Left";
|
||||
|
||||
public override void Draw(SpriteRenderer rgbaRenderer, Renderer renderer)
|
||||
{
|
||||
if (Visible)
|
||||
{
|
||||
Rectangle r = Bounds;
|
||||
renderer.Device.EnableScissor(r.Left, r.Top, r.Width, r.Height);
|
||||
renderer.BoldFont.DrawText(rgbaRenderer, Text, new int2(X+Width/2, Y+Height/2) - new int2(renderer.BoldFont.Measure(Text).X / 2, renderer.BoldFont.Measure(Text).Y/2), Color.White);
|
||||
|
||||
int2 bounds = renderer.BoldFont.Measure(Text);
|
||||
int2 position = new int2(X,Y);
|
||||
|
||||
if (Align == "Center")
|
||||
position = new int2(X+Width/2, Y+Height/2) - new int2(bounds.X / 2, bounds.Y/2);
|
||||
|
||||
|
||||
renderer.BoldFont.DrawText(rgbaRenderer, Text, position, Color.White);
|
||||
renderer.Device.DisableScissor();
|
||||
}
|
||||
base.Draw(rgbaRenderer,renderer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace OpenRA.Widgets
|
||||
public readonly int Y = 0;
|
||||
public readonly int Width = 0;
|
||||
public readonly int Height = 0;
|
||||
|
||||
public bool Visible = true;
|
||||
public readonly List<Widget> Children = new List<Widget>();
|
||||
public Rectangle Bounds
|
||||
{
|
||||
@@ -32,12 +32,16 @@ namespace OpenRA.Widgets
|
||||
|
||||
public virtual void Draw(SpriteRenderer rgbaRenderer, Renderer renderer)
|
||||
{
|
||||
if (Visible)
|
||||
foreach (var child in Children)
|
||||
child.Draw(rgbaRenderer, renderer);
|
||||
}
|
||||
|
||||
public virtual bool HandleInput(MouseInput mi)
|
||||
{
|
||||
if (!Visible)
|
||||
return false;
|
||||
|
||||
bool caught = false;
|
||||
if (ClickRect.Contains(mi.Location.X,mi.Location.Y))
|
||||
{
|
||||
@@ -56,6 +60,19 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
Children.Add( child );
|
||||
}
|
||||
|
||||
public Widget GetWidget(string id)
|
||||
{
|
||||
if (this.Id == id)
|
||||
return this;
|
||||
|
||||
foreach (var child in Children)
|
||||
if (child.GetWidget(id) != null)
|
||||
return child;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
class ContainerWidget : Widget { }
|
||||
}
|
||||
@@ -25,7 +25,27 @@ namespace OpenRA.Widgets.Actions
|
||||
}
|
||||
}
|
||||
|
||||
public class CreateServerButtonAction : IWidgetAction
|
||||
public class OpenCreateServerMenuButtonAction : IWidgetAction
|
||||
{
|
||||
public bool OnClick(MouseInput mi)
|
||||
{
|
||||
WidgetLoader.rootWidget.GetWidget("MAINMENU_BG").Visible = false;
|
||||
WidgetLoader.rootWidget.GetWidget("CREATESERVER_BG").Visible = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class CloseCreateServerMenuButtonAction : IWidgetAction
|
||||
{
|
||||
public bool OnClick(MouseInput mi)
|
||||
{
|
||||
WidgetLoader.rootWidget.GetWidget("MAINMENU_BG").Visible = true;
|
||||
WidgetLoader.rootWidget.GetWidget("CREATESERVER_BG").Visible = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class CreateServerMenuButtonAction : IWidgetAction
|
||||
{
|
||||
public bool OnClick(MouseInput mi)
|
||||
{
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace OpenRA
|
||||
WidgetActionAssemblies = asms.ToArray();
|
||||
}
|
||||
|
||||
public static Widget rootWidget;
|
||||
public static Widget LoadWidget( MiniYaml node )
|
||||
{
|
||||
var widget = NewWidget( node.Value );
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
Background:
|
||||
Container:
|
||||
Children:
|
||||
Background@MAINMENU_BG:
|
||||
Id:MAINMENU_BG
|
||||
X:400
|
||||
Y:200
|
||||
@@ -12,6 +14,7 @@ Background:
|
||||
Width:160
|
||||
Height:25
|
||||
Text:OpenRA Main Menu
|
||||
Align:Center
|
||||
Button@MAINMENU_BUTTON_JOIN:
|
||||
Id:MAINMENU_BUTTON_JOIN
|
||||
X:445
|
||||
@@ -27,7 +30,7 @@ Background:
|
||||
Width:160
|
||||
Height:25
|
||||
Text:Create Game
|
||||
Action:CreateServerButtonAction
|
||||
Action:OpenCreateServerMenuButtonAction
|
||||
Button@MAINMENU_BUTTON_QUIT:
|
||||
Id:MAINMENU_BUTTON_QUIT
|
||||
X:445
|
||||
@@ -36,3 +39,48 @@ Background:
|
||||
Height:25
|
||||
Text:Quit
|
||||
Action:QuitButtonAction
|
||||
Background@CREATESERVER_BG:
|
||||
Id:CREATESERVER_BG
|
||||
X:300
|
||||
Y:200
|
||||
Width:450
|
||||
Height:145
|
||||
Visible:false
|
||||
Children:
|
||||
Label@CREATESERVER_LABEL_TITLE:
|
||||
Id:CREATESERVER_LABEL_TITLE
|
||||
X:445
|
||||
Y:220
|
||||
Width:160
|
||||
Height:25
|
||||
Text:Create Server
|
||||
Align:Center
|
||||
Button@CREATESERVER_CHECKBOX_HIDDEN:
|
||||
Id:CREATESERVER_CHECKBOX_HIDDEN
|
||||
X:400
|
||||
Y:260
|
||||
Width:20
|
||||
Height:20
|
||||
Label@CREATESERVER_LABEL_HIDDENGAME:
|
||||
Id:CREATESERVER_LABEL_HIDDENGAME
|
||||
X:435
|
||||
Y:260
|
||||
Width:300
|
||||
Height:25
|
||||
Text:Hide from Server Browser
|
||||
Button@CREATESERVER_BUTTON_CANCEL:
|
||||
Id:CREATESERVER_BUTTON_CANCEL
|
||||
X:400
|
||||
Y:300
|
||||
Width:160
|
||||
Height:25
|
||||
Text:Cancel
|
||||
Action:CloseCreateServerMenuButtonAction
|
||||
Button@CREATESERVER_BUTTON_START:
|
||||
Id:CREATESERVER_BUTTON_START
|
||||
X:570
|
||||
Y:300
|
||||
Width:160
|
||||
Height:25
|
||||
Text:Create
|
||||
Action:CreateServerMenuButtonAction
|
||||
Reference in New Issue
Block a user