Prototype text dropdown
This commit is contained in:
@@ -420,7 +420,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
{ "initialRamp", orderManager.LocalClient.ColorRamp }
|
||||
});
|
||||
|
||||
color.DisplayPanel(colorChooser);
|
||||
color.AttachPanel(colorChooser);
|
||||
}
|
||||
|
||||
void UpdatePlayerList()
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
panel = fullscreenMask = null;
|
||||
}
|
||||
|
||||
public void DisplayPanel(Widget p)
|
||||
public void AttachPanel(Widget p)
|
||||
{
|
||||
if (panel != null)
|
||||
throw new InvalidOperationException("Attempted to attach a panel to an open dropdown");
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
|
||||
mouseScroll = Game.Settings.Game.MouseScroll;
|
||||
var mouseScrollDropdown = inputPane.GetWidget<CncDropDownButtonWidget>("MOUSE_SCROLL");
|
||||
mouseScrollDropdown.OnMouseUp = _ => ShowMouseScrollDropdown(mouseScrollDropdown);
|
||||
mouseScrollDropdown.OnClick = () => ShowMouseScrollDropdown(mouseScrollDropdown);
|
||||
mouseScrollDropdown.GetText = () => mouseScroll.ToString();
|
||||
|
||||
var teamchat = Game.Settings.Game.TeamChatToggle;
|
||||
@@ -147,7 +147,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
|
||||
groupAddModifier = Game.Settings.Keyboard.ControlGroupModifier;
|
||||
var groupModifierDropdown = inputPane.GetWidget<CncDropDownButtonWidget>("GROUPADD_MODIFIER");
|
||||
groupModifierDropdown.OnMouseUp = _ => ShowGroupModifierDropdown(groupModifierDropdown);
|
||||
groupModifierDropdown.OnClick = () => ShowGroupModifierDropdown(groupModifierDropdown);
|
||||
groupModifierDropdown.GetText = () => groupAddModifier.ToString();
|
||||
|
||||
|
||||
@@ -214,31 +214,32 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
{ "initialRamp", playerColor }
|
||||
});
|
||||
|
||||
color.DisplayPanel(colorChooser);
|
||||
color.AttachPanel(colorChooser);
|
||||
}
|
||||
|
||||
bool ShowGroupModifierDropdown(Widget dropdown)
|
||||
void ShowGroupModifierDropdown(CncDropDownButtonWidget dropdown)
|
||||
{
|
||||
var dropDownOptions = new List<Pair<string, Action>>()
|
||||
{
|
||||
Pair.New("Ctrl", new Action(() => groupAddModifier = Modifiers.Ctrl)),
|
||||
Pair.New("Alt", new Action(() => groupAddModifier = Modifiers.Alt)),
|
||||
Pair.New("Shift", new Action(() => groupAddModifier = Modifiers.Shift)),
|
||||
// TODO: Display this as Cmd on osx once we have platform detection
|
||||
Pair.New("Meta", new Action(() => groupAddModifier = Modifiers.Meta)),
|
||||
};
|
||||
var panel = Game.LoadWidget(world, "LABEL_DROPDOWN_TEMPLATE", null, new WidgetArgs()) as ScrollPanelWidget;
|
||||
var itemTemplate = panel.GetWidget<ScrollItemWidget>("TEMPLATE");
|
||||
|
||||
var options = new List<Pair<string, Modifiers>>()
|
||||
{
|
||||
Pair.New("Ctrl", Modifiers.Ctrl),
|
||||
Pair.New("Alt", Modifiers.Alt),
|
||||
Pair.New("Shift", Modifiers.Shift),
|
||||
// TODO: Display this as Cmd on osx once we have platform detection
|
||||
Pair.New("Meta", Modifiers.Meta)
|
||||
};
|
||||
|
||||
CncDropDownButtonWidget.ShowDropDown(dropdown,
|
||||
dropDownOptions,
|
||||
(ac, w) => new LabelWidget
|
||||
{
|
||||
Bounds = new Rectangle(0, 0, w, 24),
|
||||
Text = ac.First,
|
||||
Align = LabelWidget.TextAlign.Center,
|
||||
OnMouseUp = mi => { ac.Second(); return true; },
|
||||
});
|
||||
return true;
|
||||
foreach (var o in options)
|
||||
{
|
||||
var key = o;
|
||||
var item = ScrollItemWidget.Setup(itemTemplate, () => groupAddModifier == key.Second, () => { groupAddModifier = key.Second; dropdown.RemovePanel(); });
|
||||
item.GetWidget<LabelWidget>("LABEL").GetText = () => key.First;
|
||||
panel.AddChild(item);
|
||||
}
|
||||
panel.Bounds.Height = panel.ContentHeight;
|
||||
dropdown.AttachPanel(panel);
|
||||
}
|
||||
|
||||
bool ShowWindowModeDropdown(Widget dropdown)
|
||||
|
||||
91
mods/cnc/chrome/dropdowns.yaml
Normal file
91
mods/cnc/chrome/dropdowns.yaml
Normal file
@@ -0,0 +1,91 @@
|
||||
Background@COLOR_CHOOSER:
|
||||
Id:COLOR_CHOOSER
|
||||
Delegate:CncColorPickerLogic
|
||||
Background:panel-black
|
||||
Width:315
|
||||
Height:130
|
||||
Children:
|
||||
Button@SAVE_BUTTON:
|
||||
Id:SAVE_BUTTON
|
||||
X:210
|
||||
Y:90
|
||||
Width:90
|
||||
Height:25
|
||||
Text:Save
|
||||
Button@RANDOM_BUTTON:
|
||||
Id:RANDOM_BUTTON
|
||||
X:15
|
||||
Y:90
|
||||
Width:90
|
||||
Height:25
|
||||
Text:Random
|
||||
ShpImage@FACT:
|
||||
Id:FACT
|
||||
X:220
|
||||
Y:15
|
||||
Image:fact
|
||||
Palette:colorpicker
|
||||
Label@HUE_LABEL:
|
||||
X:5
|
||||
Y:5
|
||||
Width:40
|
||||
Height:20
|
||||
Align:Right
|
||||
Text:Hue:
|
||||
Font:Bold
|
||||
Slider@HUE:
|
||||
Id:HUE_SLIDER
|
||||
X:43
|
||||
Y:10
|
||||
Width:160
|
||||
Height:20
|
||||
Ticks:5
|
||||
Label@SAT_LABEL:
|
||||
X:5
|
||||
Y:30
|
||||
Width:40
|
||||
Height:20
|
||||
Align:Right
|
||||
Text:Sat:
|
||||
Font:Bold
|
||||
Slider@SAT:
|
||||
Id:SAT_SLIDER
|
||||
X:43
|
||||
Y:35
|
||||
Width:160
|
||||
Height:20
|
||||
Ticks:5
|
||||
Label@LUM_LABEL:
|
||||
X:5
|
||||
Y:55
|
||||
Width:40
|
||||
Height:20
|
||||
Align:Right
|
||||
Text:Lum:
|
||||
Font:Bold
|
||||
Slider@LUM:
|
||||
Id:LUM_SLIDER
|
||||
X:43
|
||||
Y:60
|
||||
Width:160
|
||||
Height:20
|
||||
Ticks:5
|
||||
Range:0.2,1
|
||||
|
||||
ScrollPanel@LABEL_DROPDOWN_TEMPLATE:
|
||||
Id:LABEL_DROPDOWN_TEMPLATE
|
||||
Width:100
|
||||
Children:
|
||||
ScrollItem@TEMPLATE:
|
||||
Id:TEMPLATE
|
||||
Width:PARENT_RIGHT-27
|
||||
Height:25
|
||||
X:2
|
||||
Y:0
|
||||
Visible:false
|
||||
Children:
|
||||
Label@LABEL:
|
||||
X:10
|
||||
Id:LABEL
|
||||
Width:PARENT_RIGHT-20
|
||||
Height:25
|
||||
@@ -380,77 +380,4 @@ Container@SERVER_LOBBY:
|
||||
Y:499
|
||||
Width:140
|
||||
Height:35
|
||||
Text:Start Game
|
||||
Background@COLOR_CHOOSER:
|
||||
Id:COLOR_CHOOSER
|
||||
Delegate:CncColorPickerLogic
|
||||
Background:panel-black
|
||||
Width:315
|
||||
Height:130
|
||||
Children:
|
||||
Button@SAVE_BUTTON:
|
||||
Id:SAVE_BUTTON
|
||||
X:210
|
||||
Y:90
|
||||
Width:90
|
||||
Height:25
|
||||
Text:Save
|
||||
Button@RANDOM_BUTTON:
|
||||
Id:RANDOM_BUTTON
|
||||
X:15
|
||||
Y:90
|
||||
Width:90
|
||||
Height:25
|
||||
Text:Random
|
||||
ShpImage@FACT:
|
||||
Id:FACT
|
||||
X:220
|
||||
Y:15
|
||||
Image:fact
|
||||
Palette:colorpicker
|
||||
Label@HUE_LABEL:
|
||||
X:5
|
||||
Y:5
|
||||
Width:40
|
||||
Height:20
|
||||
Align:Right
|
||||
Text:Hue:
|
||||
Font:Bold
|
||||
Slider@HUE:
|
||||
Id:HUE_SLIDER
|
||||
X:43
|
||||
Y:10
|
||||
Width:160
|
||||
Height:20
|
||||
Ticks:5
|
||||
Label@SAT_LABEL:
|
||||
X:5
|
||||
Y:30
|
||||
Width:40
|
||||
Height:20
|
||||
Align:Right
|
||||
Text:Sat:
|
||||
Font:Bold
|
||||
Slider@SAT:
|
||||
Id:SAT_SLIDER
|
||||
X:43
|
||||
Y:35
|
||||
Width:160
|
||||
Height:20
|
||||
Ticks:5
|
||||
Label@LUM_LABEL:
|
||||
X:5
|
||||
Y:55
|
||||
Width:40
|
||||
Height:20
|
||||
Align:Right
|
||||
Text:Lum:
|
||||
Font:Bold
|
||||
Slider@LUM:
|
||||
Id:LUM_SLIDER
|
||||
X:43
|
||||
Y:60
|
||||
Width:160
|
||||
Height:20
|
||||
Ticks:5
|
||||
Range:0.2,1
|
||||
Text:Start Game
|
||||
@@ -78,6 +78,7 @@ ChromeLayout:
|
||||
mods/cnc/chrome/modchooser.yaml
|
||||
mods/cnc/chrome/preferences.yaml
|
||||
mods/cnc/chrome/cheats.yaml
|
||||
mods/cnc/chrome/dropdowns.yaml
|
||||
|
||||
Weapons:
|
||||
mods/cnc/weapons.yaml
|
||||
|
||||
Reference in New Issue
Block a user