Merge DropDownButtons
This commit is contained in:
@@ -72,7 +72,6 @@
|
||||
<Compile Include="SpawnViceroid.cs" />
|
||||
<Compile Include="Widgets\CncMenuLogic.cs" />
|
||||
<Compile Include="Widgets\CncServerBrowserLogic.cs" />
|
||||
<Compile Include="Widgets\CncMenuButton.cs" />
|
||||
<Compile Include="Widgets\CncLobbyLogic.cs" />
|
||||
<Compile Include="Widgets\CncReplayBrowserLogic.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 panel = (ScrollPanelWidget)Widget.LoadWidget("LABEL_DROPDOWN_TEMPLATE", null, new WidgetArgs()
|
||||
@@ -360,7 +360,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ShowRaceDropDown(CncDropDownButtonWidget dropdown, Session.Slot slot)
|
||||
bool ShowRaceDropDown(DropDownButtonWidget dropdown, Session.Slot slot)
|
||||
{
|
||||
if (Map.Players[slot.MapPlayer].LockRace)
|
||||
return false;
|
||||
@@ -394,7 +394,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
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 panel = (ScrollPanelWidget)Widget.LoadWidget("TEAM_DROPDOWN_TEMPLATE", null, new WidgetArgs()
|
||||
@@ -422,7 +422,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ShowColorDropDown(Session.Slot s, CncDropDownButtonWidget color)
|
||||
bool ShowColorDropDown(DropDownButtonWidget color, Session.Slot s)
|
||||
{
|
||||
if (Map.Players[s.MapPlayer].LockColor)
|
||||
return true;
|
||||
@@ -470,7 +470,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
if (slot.Spectator)
|
||||
{
|
||||
template = EmptySlotTemplateHost.Clone();
|
||||
var name = template.GetWidget<CncDropDownButtonWidget>("NAME");
|
||||
var name = template.GetWidget<DropDownButtonWidget>("NAME");
|
||||
name.GetText = () => s.Closed ? "Closed" : "Open";
|
||||
name.OnMouseDown = _ => ShowSlotDropDown(name, s, false);
|
||||
var btn = template.GetWidget<ButtonWidget>("JOIN");
|
||||
@@ -479,7 +479,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
else
|
||||
{
|
||||
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.OnMouseDown = _ => ShowSlotDropDown(name, s, Map.Players[ s.MapPlayer ].AllowBots);
|
||||
}
|
||||
@@ -530,13 +530,13 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
};
|
||||
name.OnLoseFocus = () => name.OnEnterKey();
|
||||
|
||||
var color = template.GetWidget<CncDropDownButtonWidget>("COLOR");
|
||||
color.OnMouseDown = _ => ShowColorDropDown(s, color);
|
||||
var color = template.GetWidget<DropDownButtonWidget>("COLOR");
|
||||
color.OnMouseDown = _ => ShowColorDropDown(color, s);
|
||||
|
||||
var colorBlock = color.GetWidget<ColorBlockWidget>("COLORBLOCK");
|
||||
colorBlock.GetColor = () => c.ColorRamp.GetColor(0);
|
||||
|
||||
var faction = template.GetWidget<CncDropDownButtonWidget>("FACTION");
|
||||
var faction = template.GetWidget<DropDownButtonWidget>("FACTION");
|
||||
faction.OnMouseDown = _ => ShowRaceDropDown(faction, s);
|
||||
|
||||
var factionname = faction.GetWidget<LabelWidget>("FACTIONNAME");
|
||||
@@ -545,7 +545,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
factionflag.GetImageName = () => c.Country;
|
||||
factionflag.GetImageCollection = () => "flags";
|
||||
|
||||
var team = template.GetWidget<CncDropDownButtonWidget>("TEAM");
|
||||
var team = template.GetWidget<DropDownButtonWidget>("TEAM");
|
||||
team.OnMouseDown = _ => ShowTeamDropDown(team, s);
|
||||
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.Ramp = playerColor;
|
||||
|
||||
var colorDropdown = generalPane.GetWidget<CncDropDownButtonWidget>("COLOR_DROPDOWN");
|
||||
var colorDropdown = generalPane.GetWidget<DropDownButtonWidget>("COLOR_DROPDOWN");
|
||||
colorDropdown.OnMouseDown = _ => ShowColorPicker(colorDropdown);
|
||||
colorDropdown.GetWidget<ColorBlockWidget>("COLORBLOCK").GetColor = () => playerColor.GetColor(0);
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
|
||||
// Video
|
||||
windowMode = Game.Settings.Graphics.Mode;
|
||||
var windowModeDropdown = generalPane.GetWidget<CncDropDownButtonWidget>("MODE_DROPDOWN");
|
||||
var windowModeDropdown = generalPane.GetWidget<DropDownButtonWidget>("MODE_DROPDOWN");
|
||||
windowModeDropdown.OnMouseDown = _ => ShowWindowModeDropdown(windowModeDropdown);
|
||||
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;
|
||||
|
||||
mouseScroll = Game.Settings.Game.MouseScroll;
|
||||
var mouseScrollDropdown = inputPane.GetWidget<CncDropDownButtonWidget>("MOUSE_SCROLL");
|
||||
var mouseScrollDropdown = inputPane.GetWidget<DropDownButtonWidget>("MOUSE_SCROLL");
|
||||
mouseScrollDropdown.OnMouseDown = _ => ShowMouseScrollDropdown(mouseScrollDropdown);
|
||||
mouseScrollDropdown.GetText = () => mouseScroll.ToString();
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
teamchatCheckbox.OnClick = () => teamchat ^= true;
|
||||
|
||||
groupAddModifier = Game.Settings.Keyboard.ControlGroupModifier;
|
||||
var groupModifierDropdown = inputPane.GetWidget<CncDropDownButtonWidget>("GROUPADD_MODIFIER");
|
||||
var groupModifierDropdown = inputPane.GetWidget<DropDownButtonWidget>("GROUPADD_MODIFIER");
|
||||
groupModifierDropdown.OnMouseDown = _ => ShowGroupModifierDropdown(groupModifierDropdown);
|
||||
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 =>
|
||||
{
|
||||
@@ -218,7 +218,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ShowGroupModifierDropdown(CncDropDownButtonWidget dropdown)
|
||||
bool ShowGroupModifierDropdown(DropDownButtonWidget dropdown)
|
||||
{
|
||||
var substitutions = new Dictionary<string,int>() {{ "DROPDOWN_WIDTH", dropdown.Bounds.Width }};
|
||||
var panel = (ScrollPanelWidget)Game.LoadWidget(world, "LABEL_DROPDOWN_TEMPLATE", null, new WidgetArgs()
|
||||
@@ -248,7 +248,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ShowWindowModeDropdown(CncDropDownButtonWidget dropdown)
|
||||
bool ShowWindowModeDropdown(DropDownButtonWidget dropdown)
|
||||
{
|
||||
var substitutions = new Dictionary<string,int>() {{ "DROPDOWN_WIDTH", dropdown.Bounds.Width }};
|
||||
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 panel = (ScrollPanelWidget)Game.LoadWidget(world, "LABEL_DROPDOWN_TEMPLATE", null, new WidgetArgs()
|
||||
|
||||
Reference in New Issue
Block a user