Merge DropDownButtons
This commit is contained in:
@@ -184,6 +184,7 @@
|
|||||||
<Compile Include="Traits\Waypoint.cs" />
|
<Compile Include="Traits\Waypoint.cs" />
|
||||||
<Compile Include="Traits\Activities\Activity.cs" />
|
<Compile Include="Traits\Activities\Activity.cs" />
|
||||||
<Compile Include="Widgets\ScrollItem.cs" />
|
<Compile Include="Widgets\ScrollItem.cs" />
|
||||||
|
<Compile Include="Widgets\DropDownButtonWidget.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||||
|
|||||||
@@ -122,97 +122,4 @@ namespace OpenRA.Widgets
|
|||||||
WidgetUtils.DrawPanel(state, rect);
|
WidgetUtils.DrawPanel(state, rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DropDownButtonWidget : ButtonWidget
|
|
||||||
{
|
|
||||||
public DropDownButtonWidget()
|
|
||||||
: base()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected DropDownButtonWidget(DropDownButtonWidget widget)
|
|
||||||
: base(widget)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void DrawInner()
|
|
||||||
{
|
|
||||||
base.DrawInner();
|
|
||||||
var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0);
|
|
||||||
|
|
||||||
var image = ChromeProvider.GetImage("scrollbar", "down_arrow");
|
|
||||||
var rb = RenderBounds;
|
|
||||||
|
|
||||||
WidgetUtils.DrawRGBA( image,
|
|
||||||
stateOffset + new float2( rb.Right - rb.Height + 4,
|
|
||||||
rb.Top + (rb.Height - image.bounds.Height) / 2 ));
|
|
||||||
|
|
||||||
WidgetUtils.FillRectWithColor(new Rectangle(stateOffset.X + rb.Right - rb.Height,
|
|
||||||
stateOffset.Y + rb.Top + 3, 1, rb.Height - 6),
|
|
||||||
Color.White);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Widget Clone() { return new DropDownButtonWidget(this); }
|
|
||||||
public override int UsableWidth { get { return Bounds.Width - Bounds.Height; } } /* space for button */
|
|
||||||
|
|
||||||
public static void ShowDropPanel(Widget w, Widget panel, IEnumerable<Widget> dismissAfter, Func<bool> onDismiss)
|
|
||||||
{
|
|
||||||
// Mask to prevent any clicks from being sent to other widgets
|
|
||||||
var fullscreenMask = new ContainerWidget();
|
|
||||||
fullscreenMask.Bounds = new Rectangle(0, 0, Game.viewport.Width, Game.viewport.Height);
|
|
||||||
Widget.RootWidget.AddChild(fullscreenMask);
|
|
||||||
|
|
||||||
Action HideDropDown = () =>
|
|
||||||
{
|
|
||||||
Widget.RootWidget.RemoveChild(fullscreenMask);
|
|
||||||
Widget.RootWidget.RemoveChild(panel);
|
|
||||||
};
|
|
||||||
|
|
||||||
HideDropDown += () => Game.BeforeGameStart -= HideDropDown;
|
|
||||||
Game.BeforeGameStart += HideDropDown;
|
|
||||||
|
|
||||||
fullscreenMask.OnMouseDown = mi =>
|
|
||||||
{
|
|
||||||
if (onDismiss()) HideDropDown();
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
fullscreenMask.OnMouseUp = mi => true;
|
|
||||||
|
|
||||||
var oldBounds = panel.Bounds;
|
|
||||||
panel.Bounds = new Rectangle(w.RenderOrigin.X, w.RenderOrigin.Y + w.Bounds.Height, oldBounds.Width, oldBounds.Height);
|
|
||||||
panel.OnMouseUp = mi => true;
|
|
||||||
|
|
||||||
foreach (var ww in dismissAfter)
|
|
||||||
{
|
|
||||||
var origMouseUp = ww.OnMouseUp;
|
|
||||||
ww.OnMouseUp = mi => { var result = origMouseUp(mi); if (onDismiss()) HideDropDown(); return result; };
|
|
||||||
}
|
|
||||||
Widget.RootWidget.AddChild(panel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ShowDropDown<T>(Widget w, IEnumerable<T> ts, Func<T, int, LabelWidget> ft)
|
|
||||||
{
|
|
||||||
var dropDown = new ScrollPanelWidget();
|
|
||||||
dropDown.Bounds = new Rectangle(w.RenderOrigin.X, w.RenderOrigin.Y + w.Bounds.Height, w.Bounds.Width, 100);
|
|
||||||
dropDown.ItemSpacing = 1;
|
|
||||||
|
|
||||||
List<LabelWidget> items = new List<LabelWidget>();
|
|
||||||
List<Widget> dismissAfter = new List<Widget>();
|
|
||||||
foreach (var t in ts)
|
|
||||||
{
|
|
||||||
var ww = ft(t, dropDown.Bounds.Width - dropDown.ScrollbarWidth);
|
|
||||||
dismissAfter.Add(ww);
|
|
||||||
ww.OnMouseMove = mi => items.Do(lw =>
|
|
||||||
{
|
|
||||||
lw.Background = null; ww.Background = "dialog2";
|
|
||||||
});
|
|
||||||
|
|
||||||
dropDown.AddChild(ww);
|
|
||||||
items.Add(ww);
|
|
||||||
}
|
|
||||||
|
|
||||||
dropDown.Bounds.Height = Math.Min(150, dropDown.ContentHeight);
|
|
||||||
ShowDropPanel(w, dropDown, dismissAfter, () => true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
147
OpenRA.Game/Widgets/DropDownButtonWidget.cs
Normal file
147
OpenRA.Game/Widgets/DropDownButtonWidget.cs
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation. For more information,
|
||||||
|
* see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
|
||||||
|
namespace OpenRA.Widgets
|
||||||
|
{
|
||||||
|
public class DropDownButtonWidget : ButtonWidget
|
||||||
|
{
|
||||||
|
Widget panel;
|
||||||
|
Widget fullscreenMask;
|
||||||
|
|
||||||
|
public DropDownButtonWidget()
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DropDownButtonWidget(DropDownButtonWidget widget)
|
||||||
|
: base(widget)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DrawInner()
|
||||||
|
{
|
||||||
|
base.DrawInner();
|
||||||
|
var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0);
|
||||||
|
|
||||||
|
var image = ChromeProvider.GetImage("scrollbar", "down_arrow");
|
||||||
|
var rb = RenderBounds;
|
||||||
|
|
||||||
|
WidgetUtils.DrawRGBA( image,
|
||||||
|
stateOffset + new float2( rb.Right - rb.Height + 4,
|
||||||
|
rb.Top + (rb.Height - image.bounds.Height) / 2 ));
|
||||||
|
|
||||||
|
WidgetUtils.FillRectWithColor(new Rectangle(stateOffset.X + rb.Right - rb.Height,
|
||||||
|
stateOffset.Y + rb.Top + 3, 1, rb.Height - 6),
|
||||||
|
Color.White);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Widget Clone() { return new DropDownButtonWidget(this); }
|
||||||
|
|
||||||
|
// This is crap
|
||||||
|
public override int UsableWidth { get { return Bounds.Width - Bounds.Height; } } /* space for button */
|
||||||
|
|
||||||
|
public void RemovePanel()
|
||||||
|
{
|
||||||
|
Widget.RootWidget.RemoveChild(fullscreenMask);
|
||||||
|
Widget.RootWidget.RemoveChild(panel);
|
||||||
|
Game.BeforeGameStart -= RemovePanel;
|
||||||
|
panel = fullscreenMask = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AttachPanel(Widget p)
|
||||||
|
{
|
||||||
|
if (panel != null)
|
||||||
|
throw new InvalidOperationException("Attempted to attach a panel to an open dropdown");
|
||||||
|
panel = p;
|
||||||
|
|
||||||
|
// Mask to prevent any clicks from being sent to other widgets
|
||||||
|
fullscreenMask = new ContainerWidget();
|
||||||
|
fullscreenMask.Bounds = new Rectangle(0, 0, Game.viewport.Width, Game.viewport.Height);
|
||||||
|
Widget.RootWidget.AddChild(fullscreenMask);
|
||||||
|
Game.BeforeGameStart += RemovePanel;
|
||||||
|
|
||||||
|
fullscreenMask.OnMouseDown = mi =>
|
||||||
|
{
|
||||||
|
RemovePanel();
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
fullscreenMask.OnMouseUp = mi => true;
|
||||||
|
|
||||||
|
var oldBounds = panel.Bounds;
|
||||||
|
panel.Bounds = new Rectangle(RenderOrigin.X, RenderOrigin.Y + Bounds.Height, oldBounds.Width, oldBounds.Height);
|
||||||
|
Widget.RootWidget.AddChild(panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Obsolete] public static void ShowDropPanel(Widget w, Widget panel, IEnumerable<Widget> dismissAfter, Func<bool> onDismiss)
|
||||||
|
{
|
||||||
|
// Mask to prevent any clicks from being sent to other widgets
|
||||||
|
var fullscreenMask = new ContainerWidget();
|
||||||
|
fullscreenMask.Bounds = new Rectangle(0, 0, Game.viewport.Width, Game.viewport.Height);
|
||||||
|
Widget.RootWidget.AddChild(fullscreenMask);
|
||||||
|
|
||||||
|
Action HideDropDown = () =>
|
||||||
|
{
|
||||||
|
Widget.RootWidget.RemoveChild(fullscreenMask);
|
||||||
|
Widget.RootWidget.RemoveChild(panel);
|
||||||
|
};
|
||||||
|
|
||||||
|
HideDropDown += () => Game.BeforeGameStart -= HideDropDown;
|
||||||
|
Game.BeforeGameStart += HideDropDown;
|
||||||
|
|
||||||
|
fullscreenMask.OnMouseDown = mi =>
|
||||||
|
{
|
||||||
|
if (onDismiss()) HideDropDown();
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
fullscreenMask.OnMouseUp = mi => true;
|
||||||
|
|
||||||
|
var oldBounds = panel.Bounds;
|
||||||
|
panel.Bounds = new Rectangle(w.RenderOrigin.X, w.RenderOrigin.Y + w.Bounds.Height, oldBounds.Width, oldBounds.Height);
|
||||||
|
panel.OnMouseUp = mi => true;
|
||||||
|
|
||||||
|
foreach (var ww in dismissAfter)
|
||||||
|
{
|
||||||
|
var origMouseUp = ww.OnMouseUp;
|
||||||
|
ww.OnMouseUp = mi => { var result = origMouseUp(mi); if (onDismiss()) HideDropDown(); return result; };
|
||||||
|
}
|
||||||
|
Widget.RootWidget.AddChild(panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Obsolete] public static void ShowDropDown<T>(Widget w, IEnumerable<T> ts, Func<T, int, LabelWidget> ft)
|
||||||
|
{
|
||||||
|
var dropDown = new ScrollPanelWidget();
|
||||||
|
dropDown.Bounds = new Rectangle(w.RenderOrigin.X, w.RenderOrigin.Y + w.Bounds.Height, w.Bounds.Width, 100);
|
||||||
|
dropDown.ItemSpacing = 1;
|
||||||
|
|
||||||
|
List<LabelWidget> items = new List<LabelWidget>();
|
||||||
|
List<Widget> dismissAfter = new List<Widget>();
|
||||||
|
foreach (var t in ts)
|
||||||
|
{
|
||||||
|
var ww = ft(t, dropDown.Bounds.Width - dropDown.ScrollbarWidth);
|
||||||
|
dismissAfter.Add(ww);
|
||||||
|
ww.OnMouseMove = mi => items.Do(lw =>
|
||||||
|
{
|
||||||
|
lw.Background = null; ww.Background = "dialog2";
|
||||||
|
});
|
||||||
|
|
||||||
|
dropDown.AddChild(ww);
|
||||||
|
items.Add(ww);
|
||||||
|
}
|
||||||
|
|
||||||
|
dropDown.Bounds.Height = Math.Min(150, dropDown.ContentHeight);
|
||||||
|
ShowDropPanel(w, dropDown, dismissAfter, () => true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -72,7 +72,6 @@
|
|||||||
<Compile Include="SpawnViceroid.cs" />
|
<Compile Include="SpawnViceroid.cs" />
|
||||||
<Compile Include="Widgets\CncMenuLogic.cs" />
|
<Compile Include="Widgets\CncMenuLogic.cs" />
|
||||||
<Compile Include="Widgets\CncServerBrowserLogic.cs" />
|
<Compile Include="Widgets\CncServerBrowserLogic.cs" />
|
||||||
<Compile Include="Widgets\CncMenuButton.cs" />
|
|
||||||
<Compile Include="Widgets\CncLobbyLogic.cs" />
|
<Compile Include="Widgets\CncLobbyLogic.cs" />
|
||||||
<Compile Include="Widgets\CncReplayBrowserLogic.cs" />
|
<Compile Include="Widgets\CncReplayBrowserLogic.cs" />
|
||||||
<Compile Include="Widgets\CncServerCreationLogic.cs" />
|
<Compile Include="Widgets\CncServerCreationLogic.cs" />
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShowSlotDropDown(CncDropDownButtonWidget dropdown, Session.Slot slot, bool showBotOptions)
|
bool ShowSlotDropDown(DropDownButtonWidget dropdown, Session.Slot slot, bool showBotOptions)
|
||||||
{
|
{
|
||||||
var substitutions = new Dictionary<string,int>() {{ "DROPDOWN_WIDTH", dropdown.Bounds.Width }};
|
var substitutions = new Dictionary<string,int>() {{ "DROPDOWN_WIDTH", dropdown.Bounds.Width }};
|
||||||
var panel = (ScrollPanelWidget)Widget.LoadWidget("LABEL_DROPDOWN_TEMPLATE", null, new WidgetArgs()
|
var panel = (ScrollPanelWidget)Widget.LoadWidget("LABEL_DROPDOWN_TEMPLATE", null, new WidgetArgs()
|
||||||
@@ -360,7 +360,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShowRaceDropDown(CncDropDownButtonWidget dropdown, Session.Slot slot)
|
bool ShowRaceDropDown(DropDownButtonWidget dropdown, Session.Slot slot)
|
||||||
{
|
{
|
||||||
if (Map.Players[slot.MapPlayer].LockRace)
|
if (Map.Players[slot.MapPlayer].LockRace)
|
||||||
return false;
|
return false;
|
||||||
@@ -394,7 +394,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShowTeamDropDown(CncDropDownButtonWidget dropdown, Session.Slot slot)
|
bool ShowTeamDropDown(DropDownButtonWidget dropdown, Session.Slot slot)
|
||||||
{
|
{
|
||||||
var substitutions = new Dictionary<string,int>() {{ "DROPDOWN_WIDTH", dropdown.Bounds.Width }};
|
var substitutions = new Dictionary<string,int>() {{ "DROPDOWN_WIDTH", dropdown.Bounds.Width }};
|
||||||
var panel = (ScrollPanelWidget)Widget.LoadWidget("TEAM_DROPDOWN_TEMPLATE", null, new WidgetArgs()
|
var panel = (ScrollPanelWidget)Widget.LoadWidget("TEAM_DROPDOWN_TEMPLATE", null, new WidgetArgs()
|
||||||
@@ -422,7 +422,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShowColorDropDown(Session.Slot s, CncDropDownButtonWidget color)
|
bool ShowColorDropDown(DropDownButtonWidget color, Session.Slot s)
|
||||||
{
|
{
|
||||||
if (Map.Players[s.MapPlayer].LockColor)
|
if (Map.Players[s.MapPlayer].LockColor)
|
||||||
return true;
|
return true;
|
||||||
@@ -470,7 +470,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
if (slot.Spectator)
|
if (slot.Spectator)
|
||||||
{
|
{
|
||||||
template = EmptySlotTemplateHost.Clone();
|
template = EmptySlotTemplateHost.Clone();
|
||||||
var name = template.GetWidget<CncDropDownButtonWidget>("NAME");
|
var name = template.GetWidget<DropDownButtonWidget>("NAME");
|
||||||
name.GetText = () => s.Closed ? "Closed" : "Open";
|
name.GetText = () => s.Closed ? "Closed" : "Open";
|
||||||
name.OnMouseDown = _ => ShowSlotDropDown(name, s, false);
|
name.OnMouseDown = _ => ShowSlotDropDown(name, s, false);
|
||||||
var btn = template.GetWidget<ButtonWidget>("JOIN");
|
var btn = template.GetWidget<ButtonWidget>("JOIN");
|
||||||
@@ -479,7 +479,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
template = EmptySlotTemplateHost.Clone();
|
template = EmptySlotTemplateHost.Clone();
|
||||||
var name = template.GetWidget<CncDropDownButtonWidget>("NAME");
|
var name = template.GetWidget<DropDownButtonWidget>("NAME");
|
||||||
name.GetText = () => s.Closed ? "Closed" : (s.Bot == null) ? "Open" : s.Bot;
|
name.GetText = () => s.Closed ? "Closed" : (s.Bot == null) ? "Open" : s.Bot;
|
||||||
name.OnMouseDown = _ => ShowSlotDropDown(name, s, Map.Players[ s.MapPlayer ].AllowBots);
|
name.OnMouseDown = _ => ShowSlotDropDown(name, s, Map.Players[ s.MapPlayer ].AllowBots);
|
||||||
}
|
}
|
||||||
@@ -530,13 +530,13 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
};
|
};
|
||||||
name.OnLoseFocus = () => name.OnEnterKey();
|
name.OnLoseFocus = () => name.OnEnterKey();
|
||||||
|
|
||||||
var color = template.GetWidget<CncDropDownButtonWidget>("COLOR");
|
var color = template.GetWidget<DropDownButtonWidget>("COLOR");
|
||||||
color.OnMouseDown = _ => ShowColorDropDown(s, color);
|
color.OnMouseDown = _ => ShowColorDropDown(color, s);
|
||||||
|
|
||||||
var colorBlock = color.GetWidget<ColorBlockWidget>("COLORBLOCK");
|
var colorBlock = color.GetWidget<ColorBlockWidget>("COLORBLOCK");
|
||||||
colorBlock.GetColor = () => c.ColorRamp.GetColor(0);
|
colorBlock.GetColor = () => c.ColorRamp.GetColor(0);
|
||||||
|
|
||||||
var faction = template.GetWidget<CncDropDownButtonWidget>("FACTION");
|
var faction = template.GetWidget<DropDownButtonWidget>("FACTION");
|
||||||
faction.OnMouseDown = _ => ShowRaceDropDown(faction, s);
|
faction.OnMouseDown = _ => ShowRaceDropDown(faction, s);
|
||||||
|
|
||||||
var factionname = faction.GetWidget<LabelWidget>("FACTIONNAME");
|
var factionname = faction.GetWidget<LabelWidget>("FACTIONNAME");
|
||||||
@@ -545,7 +545,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
factionflag.GetImageName = () => c.Country;
|
factionflag.GetImageName = () => c.Country;
|
||||||
factionflag.GetImageCollection = () => "flags";
|
factionflag.GetImageCollection = () => "flags";
|
||||||
|
|
||||||
var team = template.GetWidget<CncDropDownButtonWidget>("TEAM");
|
var team = template.GetWidget<DropDownButtonWidget>("TEAM");
|
||||||
team.OnMouseDown = _ => ShowTeamDropDown(team, s);
|
team.OnMouseDown = _ => ShowTeamDropDown(team, s);
|
||||||
team.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString();
|
team.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString();
|
||||||
|
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
|
||||||
* available to you under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation. For more information,
|
|
||||||
* see COPYING.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using OpenRA.Graphics;
|
|
||||||
using OpenRA.Widgets;
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets
|
|
||||||
{
|
|
||||||
public class CncDropDownButtonWidget : DropDownButtonWidget
|
|
||||||
{
|
|
||||||
public CncDropDownButtonWidget() : base() { }
|
|
||||||
protected CncDropDownButtonWidget(CncDropDownButtonWidget other) : base(other) { }
|
|
||||||
public override Widget Clone() { return new CncDropDownButtonWidget(this); }
|
|
||||||
|
|
||||||
Widget panel;
|
|
||||||
Widget fullscreenMask;
|
|
||||||
|
|
||||||
public void RemovePanel()
|
|
||||||
{
|
|
||||||
Widget.RootWidget.RemoveChild(fullscreenMask);
|
|
||||||
Widget.RootWidget.RemoveChild(panel);
|
|
||||||
Game.BeforeGameStart -= RemovePanel;
|
|
||||||
panel = fullscreenMask = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AttachPanel(Widget p)
|
|
||||||
{
|
|
||||||
if (panel != null)
|
|
||||||
throw new InvalidOperationException("Attempted to attach a panel to an open dropdown");
|
|
||||||
panel = p;
|
|
||||||
|
|
||||||
// Mask to prevent any clicks from being sent to other widgets
|
|
||||||
fullscreenMask = new ContainerWidget();
|
|
||||||
fullscreenMask.Bounds = new Rectangle(0, 0, Game.viewport.Width, Game.viewport.Height);
|
|
||||||
Widget.RootWidget.AddChild(fullscreenMask);
|
|
||||||
Game.BeforeGameStart += RemovePanel;
|
|
||||||
|
|
||||||
fullscreenMask.OnMouseDown = mi =>
|
|
||||||
{
|
|
||||||
RemovePanel();
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
fullscreenMask.OnMouseUp = mi => true;
|
|
||||||
|
|
||||||
var oldBounds = panel.Bounds;
|
|
||||||
panel.Bounds = new Rectangle(RenderOrigin.X, RenderOrigin.Y + Bounds.Height, oldBounds.Width, oldBounds.Height);
|
|
||||||
Widget.RootWidget.AddChild(panel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
playerPalettePreview = world.WorldActor.Trait<CncColorPickerPaletteModifier>();
|
playerPalettePreview = world.WorldActor.Trait<CncColorPickerPaletteModifier>();
|
||||||
playerPalettePreview.Ramp = playerColor;
|
playerPalettePreview.Ramp = playerColor;
|
||||||
|
|
||||||
var colorDropdown = generalPane.GetWidget<CncDropDownButtonWidget>("COLOR_DROPDOWN");
|
var colorDropdown = generalPane.GetWidget<DropDownButtonWidget>("COLOR_DROPDOWN");
|
||||||
colorDropdown.OnMouseDown = _ => ShowColorPicker(colorDropdown);
|
colorDropdown.OnMouseDown = _ => ShowColorPicker(colorDropdown);
|
||||||
colorDropdown.GetWidget<ColorBlockWidget>("COLORBLOCK").GetColor = () => playerColor.GetColor(0);
|
colorDropdown.GetWidget<ColorBlockWidget>("COLORBLOCK").GetColor = () => playerColor.GetColor(0);
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
|
|
||||||
// Video
|
// Video
|
||||||
windowMode = Game.Settings.Graphics.Mode;
|
windowMode = Game.Settings.Graphics.Mode;
|
||||||
var windowModeDropdown = generalPane.GetWidget<CncDropDownButtonWidget>("MODE_DROPDOWN");
|
var windowModeDropdown = generalPane.GetWidget<DropDownButtonWidget>("MODE_DROPDOWN");
|
||||||
windowModeDropdown.OnMouseDown = _ => ShowWindowModeDropdown(windowModeDropdown);
|
windowModeDropdown.OnMouseDown = _ => ShowWindowModeDropdown(windowModeDropdown);
|
||||||
windowModeDropdown.GetText = () => windowMode == WindowMode.Windowed ? "Windowed" : windowMode == WindowMode.Fullscreen ? "Fullscreen" : "Pseudo-Fullscreen";
|
windowModeDropdown.GetText = () => windowMode == WindowMode.Windowed ? "Windowed" : windowMode == WindowMode.Fullscreen ? "Fullscreen" : "Pseudo-Fullscreen";
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
edgescrollCheckbox.OnClick = () => edgescroll ^= true;
|
edgescrollCheckbox.OnClick = () => edgescroll ^= true;
|
||||||
|
|
||||||
mouseScroll = Game.Settings.Game.MouseScroll;
|
mouseScroll = Game.Settings.Game.MouseScroll;
|
||||||
var mouseScrollDropdown = inputPane.GetWidget<CncDropDownButtonWidget>("MOUSE_SCROLL");
|
var mouseScrollDropdown = inputPane.GetWidget<DropDownButtonWidget>("MOUSE_SCROLL");
|
||||||
mouseScrollDropdown.OnMouseDown = _ => ShowMouseScrollDropdown(mouseScrollDropdown);
|
mouseScrollDropdown.OnMouseDown = _ => ShowMouseScrollDropdown(mouseScrollDropdown);
|
||||||
mouseScrollDropdown.GetText = () => mouseScroll.ToString();
|
mouseScrollDropdown.GetText = () => mouseScroll.ToString();
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
teamchatCheckbox.OnClick = () => teamchat ^= true;
|
teamchatCheckbox.OnClick = () => teamchat ^= true;
|
||||||
|
|
||||||
groupAddModifier = Game.Settings.Keyboard.ControlGroupModifier;
|
groupAddModifier = Game.Settings.Keyboard.ControlGroupModifier;
|
||||||
var groupModifierDropdown = inputPane.GetWidget<CncDropDownButtonWidget>("GROUPADD_MODIFIER");
|
var groupModifierDropdown = inputPane.GetWidget<DropDownButtonWidget>("GROUPADD_MODIFIER");
|
||||||
groupModifierDropdown.OnMouseDown = _ => ShowGroupModifierDropdown(groupModifierDropdown);
|
groupModifierDropdown.OnMouseDown = _ => ShowGroupModifierDropdown(groupModifierDropdown);
|
||||||
groupModifierDropdown.GetText = () => groupAddModifier.ToString();
|
groupModifierDropdown.GetText = () => groupAddModifier.ToString();
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShowColorPicker(CncDropDownButtonWidget color)
|
bool ShowColorPicker(DropDownButtonWidget color)
|
||||||
{
|
{
|
||||||
Action<ColorRamp> onSelect = c =>
|
Action<ColorRamp> onSelect = c =>
|
||||||
{
|
{
|
||||||
@@ -218,7 +218,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShowGroupModifierDropdown(CncDropDownButtonWidget dropdown)
|
bool ShowGroupModifierDropdown(DropDownButtonWidget dropdown)
|
||||||
{
|
{
|
||||||
var substitutions = new Dictionary<string,int>() {{ "DROPDOWN_WIDTH", dropdown.Bounds.Width }};
|
var substitutions = new Dictionary<string,int>() {{ "DROPDOWN_WIDTH", dropdown.Bounds.Width }};
|
||||||
var panel = (ScrollPanelWidget)Game.LoadWidget(world, "LABEL_DROPDOWN_TEMPLATE", null, new WidgetArgs()
|
var panel = (ScrollPanelWidget)Game.LoadWidget(world, "LABEL_DROPDOWN_TEMPLATE", null, new WidgetArgs()
|
||||||
@@ -248,7 +248,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShowWindowModeDropdown(CncDropDownButtonWidget dropdown)
|
bool ShowWindowModeDropdown(DropDownButtonWidget dropdown)
|
||||||
{
|
{
|
||||||
var substitutions = new Dictionary<string,int>() {{ "DROPDOWN_WIDTH", dropdown.Bounds.Width }};
|
var substitutions = new Dictionary<string,int>() {{ "DROPDOWN_WIDTH", dropdown.Bounds.Width }};
|
||||||
var panel = (ScrollPanelWidget)Game.LoadWidget(world, "LABEL_DROPDOWN_TEMPLATE", null, new WidgetArgs()
|
var panel = (ScrollPanelWidget)Game.LoadWidget(world, "LABEL_DROPDOWN_TEMPLATE", null, new WidgetArgs()
|
||||||
@@ -278,7 +278,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ShowMouseScrollDropdown(CncDropDownButtonWidget dropdown)
|
bool ShowMouseScrollDropdown(DropDownButtonWidget dropdown)
|
||||||
{
|
{
|
||||||
var substitutions = new Dictionary<string,int>() {{ "DROPDOWN_WIDTH", dropdown.Bounds.Width }};
|
var substitutions = new Dictionary<string,int>() {{ "DROPDOWN_WIDTH", dropdown.Bounds.Width }};
|
||||||
var panel = (ScrollPanelWidget)Game.LoadWidget(world, "LABEL_DROPDOWN_TEMPLATE", null, new WidgetArgs()
|
var panel = (ScrollPanelWidget)Game.LoadWidget(world, "LABEL_DROPDOWN_TEMPLATE", null, new WidgetArgs()
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ Container@SERVER_LOBBY:
|
|||||||
Width:150
|
Width:150
|
||||||
Height:25
|
Height:25
|
||||||
MaxLength:16
|
MaxLength:16
|
||||||
CncDropDownButton@COLOR:
|
DropDownButton@COLOR:
|
||||||
Id:COLOR
|
Id:COLOR
|
||||||
Width:80
|
Width:80
|
||||||
Height:25
|
Height:25
|
||||||
@@ -80,7 +80,7 @@ Container@SERVER_LOBBY:
|
|||||||
Y:6
|
Y:6
|
||||||
Width:PARENT_RIGHT-35
|
Width:PARENT_RIGHT-35
|
||||||
Height:PARENT_BOTTOM-12
|
Height:PARENT_BOTTOM-12
|
||||||
CncDropDownButton@FACTION:
|
DropDownButton@FACTION:
|
||||||
Id:FACTION
|
Id:FACTION
|
||||||
Width:130
|
Width:130
|
||||||
Height:25
|
Height:25
|
||||||
@@ -100,7 +100,7 @@ Container@SERVER_LOBBY:
|
|||||||
Height:25
|
Height:25
|
||||||
X:40
|
X:40
|
||||||
Y:0
|
Y:0
|
||||||
CncDropDownButton@TEAM:
|
DropDownButton@TEAM:
|
||||||
Id:TEAM
|
Id:TEAM
|
||||||
Text:Team
|
Text:Team
|
||||||
Width:48
|
Width:48
|
||||||
@@ -234,7 +234,7 @@ Container@SERVER_LOBBY:
|
|||||||
Height:25
|
Height:25
|
||||||
Visible:false
|
Visible:false
|
||||||
Children:
|
Children:
|
||||||
CncDropDownButton@NAME:
|
DropDownButton@NAME:
|
||||||
Id:NAME
|
Id:NAME
|
||||||
Text:Name
|
Text:Name
|
||||||
Width:150
|
Width:150
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ Container@SETTINGS_PANEL:
|
|||||||
Width:205
|
Width:205
|
||||||
Height:25
|
Height:25
|
||||||
MaxLength:16
|
MaxLength:16
|
||||||
CncDropDownButton@COLOR:
|
DropDownButton@COLOR:
|
||||||
Id:COLOR_DROPDOWN
|
Id:COLOR_DROPDOWN
|
||||||
X:275
|
X:275
|
||||||
Y:40
|
Y:40
|
||||||
@@ -106,7 +106,7 @@ Container@SETTINGS_PANEL:
|
|||||||
Height:25
|
Height:25
|
||||||
Align:Right
|
Align:Right
|
||||||
Text:Mode:
|
Text:Mode:
|
||||||
CncDropDownButton@MODE_DROPDOWN:
|
DropDownButton@MODE_DROPDOWN:
|
||||||
Id:MODE_DROPDOWN
|
Id:MODE_DROPDOWN
|
||||||
X:425
|
X:425
|
||||||
Y:40
|
Y:40
|
||||||
@@ -256,7 +256,7 @@ Container@SETTINGS_PANEL:
|
|||||||
Font:Regular
|
Font:Regular
|
||||||
Text:Middle-Mouse Scrolling:
|
Text:Middle-Mouse Scrolling:
|
||||||
Align:Right
|
Align:Right
|
||||||
CncDropDownButton@MOUSE_SCROLL:
|
DropDownButton@MOUSE_SCROLL:
|
||||||
Id:MOUSE_SCROLL
|
Id:MOUSE_SCROLL
|
||||||
X:180
|
X:180
|
||||||
Y:180
|
Y:180
|
||||||
@@ -272,7 +272,7 @@ Container@SETTINGS_PANEL:
|
|||||||
# Font:Regular
|
# Font:Regular
|
||||||
# Text:Multitouch Scrolling:
|
# Text:Multitouch Scrolling:
|
||||||
# Align:Right
|
# Align:Right
|
||||||
# CncDropDownButton@MULTITOUCH_SCROLL:
|
# DropDownButton@MULTITOUCH_SCROLL:
|
||||||
# Id:MULTITOUCH_SCROLL
|
# Id:MULTITOUCH_SCROLL
|
||||||
# X:180
|
# X:180
|
||||||
# Y:210
|
# Y:210
|
||||||
@@ -303,7 +303,7 @@ Container@SETTINGS_PANEL:
|
|||||||
Font:Regular
|
Font:Regular
|
||||||
Text:Group Addition Modifier:
|
Text:Group Addition Modifier:
|
||||||
Align:Right
|
Align:Right
|
||||||
CncDropDownButton@GROUPADD_MODIFIER:
|
DropDownButton@GROUPADD_MODIFIER:
|
||||||
Id:GROUPADD_MODIFIER
|
Id:GROUPADD_MODIFIER
|
||||||
X:540
|
X:540
|
||||||
Y:65
|
Y:65
|
||||||
|
|||||||
Reference in New Issue
Block a user