Better listbox rows
This commit is contained in:
@@ -34,7 +34,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
var r = Chrome.rootWidget;
|
var r = Chrome.rootWidget;
|
||||||
var bg = r.GetWidget("MAP_CHOOSER");
|
var bg = r.GetWidget("MAP_CHOOSER");
|
||||||
bg.SpecialOneArg = (map) => RefreshMapList(map);
|
bg.SpecialOneArg = (map) => RefreshMapList(map);
|
||||||
var ml = bg.GetWidget("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 = () => {return Map;};
|
||||||
bg.GetWidget<LabelWidget>("CURMAP_TITLE").GetText = () => {return Map.Title;};
|
bg.GetWidget<LabelWidget>("CURMAP_TITLE").GetText = () => {return Map.Title;};
|
||||||
@@ -53,7 +53,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
var itemTemplate = ml.GetWidget<ButtonWidget>("MAP_TEMPLATE");
|
var itemTemplate = ml.GetWidget<LabelWidget>("MAP_TEMPLATE");
|
||||||
int offset = itemTemplate.Bounds.Y;
|
int offset = itemTemplate.Bounds.Y;
|
||||||
foreach (var kv in Game.AvailableMaps)
|
foreach (var kv in Game.AvailableMaps)
|
||||||
{
|
{
|
||||||
@@ -61,10 +61,11 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
if (!map.Selectable)
|
if (!map.Selectable)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var template = itemTemplate.Clone() as ButtonWidget;
|
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.OnMouseUp = mi => {Map = map; return true;};
|
template.GetBackground = () => ((Map == map) ? "dialog2" : null);
|
||||||
|
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);
|
||||||
@@ -72,6 +73,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
ml.AddChild(template);
|
ml.AddChild(template);
|
||||||
|
|
||||||
offset += template.Bounds.Height;
|
offset += template.Bounds.Height;
|
||||||
|
ml.ContentHeight += template.Bounds.Height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,15 +32,18 @@ namespace OpenRA.Widgets
|
|||||||
Right
|
Right
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Text = "";
|
public string Text = null;
|
||||||
|
public string Background = null;
|
||||||
public TextAlign Align = TextAlign.Left;
|
public TextAlign Align = TextAlign.Left;
|
||||||
public bool Bold = false;
|
public bool Bold = false;
|
||||||
public Func<string> GetText;
|
public Func<string> GetText;
|
||||||
|
public Func<string> GetBackground;
|
||||||
|
|
||||||
public LabelWidget()
|
public LabelWidget()
|
||||||
: base()
|
: base()
|
||||||
{
|
{
|
||||||
GetText = () => { return Text; };
|
GetText = () => { return Text; };
|
||||||
|
GetBackground = () => { return Background; };
|
||||||
}
|
}
|
||||||
|
|
||||||
public LabelWidget(Widget other)
|
public LabelWidget(Widget other)
|
||||||
@@ -50,10 +53,16 @@ namespace OpenRA.Widgets
|
|||||||
Align = (other as LabelWidget).Align;
|
Align = (other as LabelWidget).Align;
|
||||||
Bold = (other as LabelWidget).Bold;
|
Bold = (other as LabelWidget).Bold;
|
||||||
GetText = (other as LabelWidget).GetText;
|
GetText = (other as LabelWidget).GetText;
|
||||||
|
GetBackground = (other as LabelWidget).GetBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DrawInner(World world)
|
public override void DrawInner(World world)
|
||||||
{
|
{
|
||||||
|
var bg = GetBackground();
|
||||||
|
|
||||||
|
if (bg != null)
|
||||||
|
WidgetUtils.DrawPanel(bg, RenderBounds );
|
||||||
|
|
||||||
var font = (Bold) ? Game.chrome.renderer.BoldFont : Game.chrome.renderer.RegularFont;
|
var font = (Bold) ? Game.chrome.renderer.BoldFont : Game.chrome.renderer.RegularFont;
|
||||||
var text = GetText();
|
var text = GetText();
|
||||||
if (text == null)
|
if (text == null)
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ namespace OpenRA.Widgets
|
|||||||
public readonly float ScrollVelocity = 4f;
|
public readonly float ScrollVelocity = 4f;
|
||||||
public readonly int HeaderHeight = 25;
|
public readonly int HeaderHeight = 25;
|
||||||
|
|
||||||
|
|
||||||
|
public int ContentHeight = 0;
|
||||||
float ListOffset = 0;
|
float ListOffset = 0;
|
||||||
bool UpPressed = false;
|
bool UpPressed = false;
|
||||||
bool DownPressed = false;
|
bool DownPressed = false;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace OpenRA.Widgets
|
|||||||
public string Width = "0";
|
public string Width = "0";
|
||||||
public string Height = "0";
|
public string Height = "0";
|
||||||
public string Delegate = null;
|
public string Delegate = null;
|
||||||
public bool ClickThrough = false;
|
public bool ClickThrough = true;
|
||||||
public bool Visible = true;
|
public bool Visible = true;
|
||||||
public readonly List<Widget> Children = new List<Widget>();
|
public readonly List<Widget> Children = new List<Widget>();
|
||||||
|
|
||||||
@@ -173,7 +173,7 @@ namespace OpenRA.Widgets
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool HandleInput(MouseInput mi) { return false; }
|
public virtual bool HandleInput(MouseInput mi) { return !ClickThrough; }
|
||||||
public bool HandleMouseInputOuter(MouseInput mi)
|
public bool HandleMouseInputOuter(MouseInput mi)
|
||||||
{
|
{
|
||||||
// Are we able to handle this event?
|
// Are we able to handle this event?
|
||||||
|
|||||||
@@ -1,14 +1,5 @@
|
|||||||
Container:
|
Container:
|
||||||
ClickThrough:true
|
|
||||||
Children:
|
Children:
|
||||||
PostGame@POSTGAME_TEXT:
|
|
||||||
Id:POSTGAME_TEXT
|
|
||||||
X:0
|
|
||||||
Y:0
|
|
||||||
Width: WINDOW_RIGHT
|
|
||||||
Height: WINDOW_BOTTOM
|
|
||||||
ClickThrough: true
|
|
||||||
Visible: true
|
|
||||||
Background@MAINMENU_BG:
|
Background@MAINMENU_BG:
|
||||||
Id:MAINMENU_BG
|
Id:MAINMENU_BG
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
@@ -776,10 +767,11 @@ Container:
|
|||||||
Width:500
|
Width:500
|
||||||
Height:480
|
Height:480
|
||||||
Children:
|
Children:
|
||||||
Button@MAP_TEMPLATE:
|
Label@MAP_TEMPLATE:
|
||||||
Id:MAP_TEMPLATE
|
Id:MAP_TEMPLATE
|
||||||
Width:PARENT_RIGHT-28
|
Width:PARENT_RIGHT-28
|
||||||
Height:25
|
Height:25
|
||||||
|
ClickThrough:false
|
||||||
X:2
|
X:2
|
||||||
Y:25
|
Y:25
|
||||||
Visible:false
|
Visible:false
|
||||||
@@ -881,6 +873,12 @@ Container:
|
|||||||
Delegate:IngameChromeDelegate
|
Delegate:IngameChromeDelegate
|
||||||
Visible:false
|
Visible:false
|
||||||
Children:
|
Children:
|
||||||
|
PostGame@POSTGAME_TEXT:
|
||||||
|
Id:POSTGAME_TEXT
|
||||||
|
X:0
|
||||||
|
Y:0
|
||||||
|
Width: WINDOW_RIGHT
|
||||||
|
Height: WINDOW_BOTTOM
|
||||||
SpecialPowerBin@INGAME_POWERS_BIN:
|
SpecialPowerBin@INGAME_POWERS_BIN:
|
||||||
Id:INGAME_POWERS_BIN
|
Id:INGAME_POWERS_BIN
|
||||||
X:0
|
X:0
|
||||||
@@ -1006,14 +1004,12 @@ Container:
|
|||||||
Height: 250
|
Height: 250
|
||||||
Children:
|
Children:
|
||||||
PerfGraph@GRAPH:
|
PerfGraph@GRAPH:
|
||||||
ClickThrough:true
|
|
||||||
Id:GRAPH
|
Id:GRAPH
|
||||||
X:5
|
X:5
|
||||||
Y:5
|
Y:5
|
||||||
Width:200
|
Width:200
|
||||||
Height:200
|
Height:200
|
||||||
Label@TEXT:
|
Label@TEXT:
|
||||||
ClickThrough:true
|
|
||||||
Id:TEXT
|
Id:TEXT
|
||||||
Bold: false
|
Bold: false
|
||||||
X:20
|
X:20
|
||||||
|
|||||||
@@ -1,14 +1,5 @@
|
|||||||
Container:
|
Container:
|
||||||
ClickThrough:true
|
|
||||||
Children:
|
Children:
|
||||||
PostGame@POSTGAME_TEXT:
|
|
||||||
Id:POSTGAME_TEXT
|
|
||||||
X:0
|
|
||||||
Y:0
|
|
||||||
Width: WINDOW_RIGHT
|
|
||||||
Height: WINDOW_BOTTOM
|
|
||||||
ClickThrough: true
|
|
||||||
Visible: true
|
|
||||||
Background@MAINMENU_BG:
|
Background@MAINMENU_BG:
|
||||||
Id:MAINMENU_BG
|
Id:MAINMENU_BG
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
@@ -776,10 +767,11 @@ Container:
|
|||||||
Width:500
|
Width:500
|
||||||
Height:480
|
Height:480
|
||||||
Children:
|
Children:
|
||||||
Button@MAP_TEMPLATE:
|
Label@MAP_TEMPLATE:
|
||||||
Id:MAP_TEMPLATE
|
Id:MAP_TEMPLATE
|
||||||
Width:PARENT_RIGHT-28
|
Width:PARENT_RIGHT-28
|
||||||
Height:25
|
Height:25
|
||||||
|
ClickThrough:false
|
||||||
X:2
|
X:2
|
||||||
Y:25
|
Y:25
|
||||||
Visible:false
|
Visible:false
|
||||||
@@ -881,6 +873,12 @@ Container:
|
|||||||
Delegate:IngameChromeDelegate
|
Delegate:IngameChromeDelegate
|
||||||
Visible:false
|
Visible:false
|
||||||
Children:
|
Children:
|
||||||
|
PostGame@POSTGAME_TEXT:
|
||||||
|
Id:POSTGAME_TEXT
|
||||||
|
X:0
|
||||||
|
Y:0
|
||||||
|
Width: WINDOW_RIGHT
|
||||||
|
Height: WINDOW_BOTTOM
|
||||||
SpecialPowerBin@INGAME_POWERS_BIN:
|
SpecialPowerBin@INGAME_POWERS_BIN:
|
||||||
Id:INGAME_POWERS_BIN
|
Id:INGAME_POWERS_BIN
|
||||||
X:0
|
X:0
|
||||||
@@ -1006,14 +1004,12 @@ Container:
|
|||||||
Height: 250
|
Height: 250
|
||||||
Children:
|
Children:
|
||||||
PerfGraph@GRAPH:
|
PerfGraph@GRAPH:
|
||||||
ClickThrough:true
|
|
||||||
Id:GRAPH
|
Id:GRAPH
|
||||||
X:5
|
X:5
|
||||||
Y:5
|
Y:5
|
||||||
Width:200
|
Width:200
|
||||||
Height:200
|
Height:200
|
||||||
Label@TEXT:
|
Label@TEXT:
|
||||||
ClickThrough:true
|
|
||||||
Id:TEXT
|
Id:TEXT
|
||||||
Bold: false
|
Bold: false
|
||||||
X:20
|
X:20
|
||||||
@@ -1104,4 +1100,6 @@ Container:
|
|||||||
Width:25
|
Width:25
|
||||||
Height:25
|
Height:25
|
||||||
ImageCollection:music
|
ImageCollection:music
|
||||||
ImageName:prev
|
ImageName:prev
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user