Refactoring to remove static Rules & SequenceProvider
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2014 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,
|
||||
@@ -11,6 +11,8 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Network;
|
||||
|
||||
namespace OpenRA.Widgets
|
||||
{
|
||||
@@ -53,8 +55,13 @@ namespace OpenRA.Widgets
|
||||
public Action OnDoubleClick = () => {};
|
||||
public Action<KeyInput> OnKeyPress = _ => {};
|
||||
|
||||
public ButtonWidget()
|
||||
readonly MapRuleset rules;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public ButtonWidget(MapRuleset rules)
|
||||
{
|
||||
this.rules = rules;
|
||||
|
||||
GetText = () => { return Text; };
|
||||
GetColor = () => TextColor;
|
||||
GetColorDisabled = () => TextColorDisabled;
|
||||
@@ -70,6 +77,8 @@ namespace OpenRA.Widgets
|
||||
protected ButtonWidget(ButtonWidget other)
|
||||
: base(other)
|
||||
{
|
||||
this.rules = other.rules;
|
||||
|
||||
Text = other.Text;
|
||||
Font = other.Font;
|
||||
TextColor = other.TextColor;
|
||||
@@ -113,10 +122,10 @@ namespace OpenRA.Widgets
|
||||
if (!IsDisabled())
|
||||
{
|
||||
OnKeyPress(e);
|
||||
Sound.PlayNotification(null, "Sounds", "ClickSound", null);
|
||||
Sound.PlayNotification(rules, null, "Sounds", "ClickSound", null);
|
||||
}
|
||||
else
|
||||
Sound.PlayNotification(null, "Sounds", "ClickDisabledSound", null);
|
||||
Sound.PlayNotification(rules, null, "Sounds", "ClickDisabledSound", null);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -153,12 +162,12 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
OnMouseDown(mi);
|
||||
Depressed = true;
|
||||
Sound.PlayNotification(null, "Sounds", "ClickSound", null);
|
||||
Sound.PlayNotification(rules, null, "Sounds", "ClickSound", null);
|
||||
}
|
||||
else
|
||||
{
|
||||
YieldMouseFocus(mi);
|
||||
Sound.PlayNotification(null, "Sounds", "ClickDisabledSound", null);
|
||||
Sound.PlayNotification(rules, null, "Sounds", "ClickDisabledSound", null);
|
||||
}
|
||||
}
|
||||
else if (mi.Event == MouseInputEvent.Move && HasMouseFocus)
|
||||
|
||||
Reference in New Issue
Block a user