Add a hover state for scrollpanel entries
This commit is contained in:
@@ -15,6 +15,7 @@ using OpenRA.Network;
|
|||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System;
|
using System;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets
|
namespace OpenRA.Mods.Cnc.Widgets
|
||||||
{
|
{
|
||||||
@@ -67,7 +68,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
var template = itemTemplate.Clone() as ContainerWidget;
|
var template = itemTemplate.Clone() as ContainerWidget;
|
||||||
template.GetBackground = () => ((Map == map) ? "panel-darkred" : null);
|
template.GetBackground = () => (template.RenderBounds.Contains(Viewport.LastMousePos) ? "button-hover" : (Map == map) ? "button-pressed" : null);
|
||||||
template.OnMouseDown = mi => { if (mi.Button != MouseButton.Left) return false; Map = map; return true; };
|
template.OnMouseDown = mi => { if (mi.Button != MouseButton.Left) return false; Map = map; return true; };
|
||||||
template.IsVisible = () => true;
|
template.IsVisible = () => true;
|
||||||
template.GetWidget<LabelWidget>("TITLE").GetText = () => map.Title;
|
template.GetWidget<LabelWidget>("TITLE").GetText = () => map.Title;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ using OpenRA.FileFormats;
|
|||||||
using OpenRA.Network;
|
using OpenRA.Network;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
using OpenRA.Mods.RA.Widgets.Delegates;
|
using OpenRA.Mods.RA.Widgets.Delegates;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets
|
namespace OpenRA.Mods.Cnc.Widgets
|
||||||
{
|
{
|
||||||
@@ -101,7 +102,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
var entry = template.Clone() as ContainerWidget;
|
var entry = template.Clone() as ContainerWidget;
|
||||||
var f = Path.GetFileName(filename);
|
var f = Path.GetFileName(filename);
|
||||||
entry.GetWidget<LabelWidget>("TITLE").GetText = () => f;
|
entry.GetWidget<LabelWidget>("TITLE").GetText = () => f;
|
||||||
entry.GetBackground = () => (CurrentReplay == filename) ? "panel-darkred" : null;
|
entry.GetBackground = () => (entry.RenderBounds.Contains(Viewport.LastMousePos) ? "button-hover" : (CurrentReplay == filename) ? "button-pressed" : null);
|
||||||
entry.OnMouseDown = mi => { if (mi.Button != MouseButton.Left) return false; CurrentReplay = filename; return true; };
|
entry.OnMouseDown = mi => { if (mi.Button != MouseButton.Left) return false; CurrentReplay = filename; return true; };
|
||||||
entry.IsVisible = () => true;
|
entry.IsVisible = () => true;
|
||||||
list.AddChild(entry);
|
list.AddChild(entry);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using OpenRA.FileFormats;
|
|||||||
using OpenRA.Server;
|
using OpenRA.Server;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
using OpenRA.Mods.RA.Widgets.Delegates;
|
using OpenRA.Mods.RA.Widgets.Delegates;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets
|
namespace OpenRA.Mods.Cnc.Widgets
|
||||||
{
|
{
|
||||||
@@ -164,7 +165,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
var game = loop;
|
var game = loop;
|
||||||
|
|
||||||
var template = serverTemplate.Clone() as ContainerWidget;
|
var template = serverTemplate.Clone() as ContainerWidget;
|
||||||
template.GetBackground = () => (currentServer == game) ? "panel-darkred" : null;
|
template.GetBackground = () => (template.RenderBounds.Contains(Viewport.LastMousePos) ? "button-hover" : (currentServer == game) ? "button-pressed" : null);
|
||||||
template.OnMouseDown = mi => { if (mi.Button != MouseButton.Left) return false; currentServer = game; return true; };
|
template.OnMouseDown = mi => { if (mi.Button != MouseButton.Left) return false; currentServer = game; return true; };
|
||||||
template.IsVisible = () => true;
|
template.IsVisible = () => true;
|
||||||
template.GetWidget<LabelWidget>("TITLE").GetText = () => game.Name;
|
template.GetWidget<LabelWidget>("TITLE").GetText = () => game.Name;
|
||||||
|
|||||||
Reference in New Issue
Block a user