Can get extended help/description by right clicking on certain buttons.

This commit is contained in:
UnknownShadow200 2016-01-20 14:14:56 +11:00
parent 2c30831c53
commit c1753b03b8
21 changed files with 202 additions and 83 deletions

View File

@ -4,6 +4,8 @@ using OpenTK.Input;
namespace ClassicalSharp {
public delegate void ClickHandler( Game g, Widget w, MouseButton btn );
public abstract class GuiElement : IDisposable {
protected Game game;
@ -76,6 +78,13 @@ namespace ClassicalSharp {
protected static bool Contains( int recX, int recY, int width, int height, int x, int y ) {
return x >= recX && y >= recY && x < recX + width && y < recY + height;
}
protected ClickHandler LeftOnly( Action<Game, Widget> action ) {
return (g, w, btn) => {
if( btn != MouseButton.Left ) return;
action( g, w );
};
}
}
public enum Anchor {

View File

@ -10,21 +10,22 @@ namespace ClassicalSharp {
}
protected bool HandleMouseClick( Widget[] widgets, int mouseX, int mouseY, MouseButton button ) {
if( button != MouseButton.Left ) return false;
// iterate backwards (because last elements rendered are shown over others)
for( int i = widgets.Length - 1; i >= 0; i-- ) {
Widget widget = widgets[i];
if( widget != null && widget.Bounds.Contains( mouseX, mouseY ) ) {
if( widget.OnClick != null && !widget.Disabled )
widget.OnClick( game, widget );
widget.OnClick( game, widget, button );
return true;
}
}
return false;
}
int lastX = -1, lastY = -1;
protected bool HandleMouseMove( Widget[] widgets, int mouseX, int mouseY ) {
if( lastX == mouseX && lastY == mouseY )
return true;
for( int i = 0; i < widgets.Length; i++ ) {
if( widgets[i] == null ) continue;
widgets[i].Active = false;
@ -34,10 +35,12 @@ namespace ClassicalSharp {
Widget widget = widgets[i];
if( widget != null && widget.Bounds.Contains( mouseX, mouseY ) ) {
widget.Active = true;
lastX = mouseX; lastY = mouseY;
WidgetSelected( widget );
return true;
}
}
lastX = mouseX; lastY = mouseY;
WidgetSelected( null );
return false;
}
@ -49,7 +52,7 @@ namespace ClassicalSharp {
string text = toGame ? "Back to game" : "Back to menu";
return ButtonWidget.Create(
game, 0, 5, 180, 35, text,
Anchor.Centre, Anchor.BottomOrRight, font, onClick );
Anchor.Centre, Anchor.BottomOrRight, font, LeftOnly( onClick ) );
}
}
}

View File

@ -52,7 +52,8 @@ namespace ClassicalSharp {
lastSecsLeft = delay;
}
void ReconnectClick( Game g, Widget w ) {
void ReconnectClick( Game g, Widget w, MouseButton mouseBtn ) {
if( mouseBtn != MouseButton.Left ) return;
string connectString = "Connecting to " + game.IPAddress + ":" + game.Port + "..";
game.SetNewScreen( new LoadingMapScreen( game, connectString, "Waiting for handshake" ) );
game.Network.Connect( game.IPAddress, game.Port );

View File

@ -58,10 +58,10 @@ namespace ClassicalSharp {
ButtonWidget Make( int x, int y, string text, Action<Game, Widget> onClick ) {
return ButtonWidget.Create( game, x, y, 40, 40, text,
Anchor.Centre, Anchor.Centre, arrowFont, onClick );
Anchor.Centre, Anchor.Centre, arrowFont, LeftOnly( onClick ) );
}
protected abstract void TextButtonClick( Game game, Widget widget );
protected abstract void TextButtonClick( Game game, Widget widget, MouseButton mouseBtn );
protected void PageClick( bool forward ) {
currentIndex += forward ? 5 : -5;

View File

@ -118,7 +118,7 @@ namespace ClassicalSharp {
ButtonWidget Make( int x, int y, string text, int width, int height,
Font font, Action<Game, Widget> onClick ) {
return ButtonWidget.Create( game, x, y, width, height, text,
Anchor.Centre, Anchor.Centre, font, onClick );
Anchor.Centre, Anchor.Centre, font, LeftOnly( onClick ) );
}
ButtonWidget MakeHotkey( int x, int y, int index ) {
@ -169,7 +169,8 @@ namespace ClassicalSharp {
Set( i );
}
void TextButtonClick( Game game, Widget widget ) {
void TextButtonClick( Game game, Widget widget, MouseButton mouseBtn ) {
if( mouseBtn != MouseButton.Left ) return;
LostFocus();
ButtonWidget button = (ButtonWidget)widget;

View File

@ -1,10 +1,11 @@
using System;
using System.Drawing;
using ClassicalSharp.Renderers;
using OpenTK.Input;
namespace ClassicalSharp {
public class EnvSettingsScreen : MenuInputScreen {
public class EnvSettingsScreen : MenuOptionsScreen {
string[] defaultValues;
int defaultIndex;
@ -99,7 +100,8 @@ namespace ClassicalSharp {
Anchor.Centre, titleFont, DefaultButtonClick );
}
void DefaultButtonClick( Game game, Widget widget ) {
void DefaultButtonClick( Game game, Widget widget, MouseButton mouseBtn ) {
if( mouseBtn != MouseButton.Left ) return;
int index = Array.IndexOf<ButtonWidget>( buttons, targetWidget );
string defValue = defaultValues[index];
inputWidget.SetText( defValue );

View File

@ -105,7 +105,8 @@ namespace ClassicalSharp {
base.Dispose();
}
void InputClick( Game game, Widget widget ) {
void InputClick( Game game, Widget widget, MouseButton mouseBtn ) {
if( mouseBtn != MouseButton.Left ) return;
if( selectedWidget != null )
selectedWidget.Active = false;
@ -113,11 +114,13 @@ namespace ClassicalSharp {
selectedWidget.Active = true;
}
void GenFlatgrassClick( Game game, Widget widget ) {
void GenFlatgrassClick( Game game, Widget widget, MouseButton mouseBtn ) {
if( mouseBtn != MouseButton.Left ) return;
GenerateMap( new FlatGrassGenerator() );
}
void GenNotchyClick( Game game, Widget widget ) {
void GenNotchyClick( Game game, Widget widget, MouseButton mouseBtn ) {
if( mouseBtn != MouseButton.Left ) return;
GenerateMap( new NotchyGenerator() );
}

View File

@ -2,7 +2,7 @@
namespace ClassicalSharp {
public class GuiOptionsScreen : MenuInputScreen {
public class GuiOptionsScreen : MenuOptionsScreen {
public GuiOptionsScreen( Game game ) : base( game ) {
}

View File

@ -4,7 +4,7 @@ using ClassicalSharp.Singleplayer;
namespace ClassicalSharp {
public class HacksSettingsScreen : MenuInputScreen {
public class HacksSettingsScreen : MenuOptionsScreen {
public HacksSettingsScreen( Game game ) : base( game ) {
}
@ -111,15 +111,21 @@ namespace ClassicalSharp {
void MakeDescriptions() {
descriptions = new string[buttons.Length][];
descriptions[5] = new [] {
"&fIf breaking liquids is set to true, then water/lava",
"&fcan be deleted the same way as any regular block.",
"&aLiquids breakable",
"&eIf breaking liquids is set to true, then water/lava",
"&ecan be deleted the same way as any regular block.",
};
descriptions[6] = new [] {
"&aDetermines whether pushback placing mode is active or not.",
"&fWhen this is active, placing blocks that intersect your own position",
"&f cause the block to be placed, and you to be moved out of the way.",
"&aDetermines whether pushback placing mode is active or not",
"&eWhen this is active, placing blocks that intersect your own position",
"&ecause the block to be placed, and you to be moved out of the way.",
"&fThis is mainly useful for quick pillaring/towering.",
};
descriptions[7] = new [] {
"&aDetermines whether noclip sliding is used or not.",
"&eIf sliding isn't used, you will immediately stop when",
"&eyou are in noclip mode and no movement keys are held down.",
};
}
}
}

View File

@ -47,7 +47,8 @@ namespace ClassicalSharp {
}
ButtonWidget curWidget;
void OnBindingClick( Game game, Widget realWidget ) {
void OnBindingClick( Game game, Widget realWidget, MouseButton mouseBtn ) {
if( mouseBtn != MouseButton.Left ) return;
this.curWidget = (ButtonWidget)realWidget;
int index = Array.IndexOf<ButtonWidget>( buttons, curWidget );
string text = "&ePress new key binding for " + descriptions[index] + ":";
@ -111,7 +112,8 @@ namespace ClassicalSharp {
Anchor.Centre, Anchor.Centre, titleFont, NextClick );
}
void NextClick( Game game, Widget widget ) {
void NextClick( Game game, Widget widget, MouseButton mouseBtn ) {
if( mouseBtn != MouseButton.Left ) return;
game.SetNewScreen( new AdvancedKeyBindingsScreen( game ) );
}
}
@ -139,7 +141,8 @@ namespace ClassicalSharp {
Anchor.Centre, Anchor.Centre, titleFont, NextClick );
}
void NextClick( Game game, Widget widget ) {
void NextClick( Game game, Widget widget, MouseButton mouseBtn ) {
if( mouseBtn != MouseButton.Left ) return;
game.SetNewScreen( new NormalKeyBindingsScreen( game ) );
}
}

View File

@ -1,5 +1,6 @@
using System;
using System.IO;
using OpenTK.Input;
namespace ClassicalSharp {
@ -25,7 +26,8 @@ namespace ClassicalSharp {
MakeBack( false, titleFont, (g, w) => g.SetNewScreen( new PauseScreen( g ) ) );
}
protected override void TextButtonClick( Game game, Widget widget ) {
protected override void TextButtonClick( Game game, Widget widget, MouseButton mouseBtn ) {
if( mouseBtn != MouseButton.Left ) return;
string path = Path.Combine( Program.AppDirectory, "maps" );
path = Path.Combine( path, ((ButtonWidget)widget).Text );
if( File.Exists( path ) )

View File

@ -4,9 +4,9 @@ using OpenTK.Input;
namespace ClassicalSharp {
public abstract class MenuInputScreen : MenuScreen {
public abstract class MenuOptionsScreen : MenuScreen {
public MenuInputScreen( Game game ) : base( game ) {
public MenuOptionsScreen( Game game ) : base( game ) {
}
protected MenuInputWidget inputWidget;
@ -14,21 +14,37 @@ namespace ClassicalSharp {
protected TextWidget descWidget;
protected int okayIndex;
protected string[][] descriptions;
protected ChatTextWidget[] extendedHelp;
Font extendedHelpFont;
public override void Render( double delta ) {
RenderMenuBounds();
if( extendedHelp != null ) {
int x = game.Width / 2 - tableWidth / 2 - 5;
int y = game.Height / 2 + extHelpY - 5;
graphicsApi.Draw2DQuad( x, y, tableWidth + 10, tableHeight + 10, tableCol );
}
graphicsApi.Texturing = true;
RenderMenuButtons( delta );
if( inputWidget != null )
inputWidget.Render( delta );
if( descWidget != null )
if( extendedHelp != null ) {
for( int i = 0; i < extendedHelp.Length; i++ )
extendedHelp[i].Render( delta );
} else if( descWidget != null ) {
descWidget.Render( delta );
}
graphicsApi.Texturing = false;
}
public override void Init() {
base.Init();
regularFont = new Font( "Arial", 16, FontStyle.Regular );
int size = game.Drawer2D.UseBitmappedChat ? 11 : 12;
extendedHelpFont = new Font( "Arial", size, FontStyle.Regular );
game.Keyboard.KeyRepeat = true;
}
@ -61,7 +77,11 @@ namespace ClassicalSharp {
descWidget.OnResize( oldWidth, oldHeight, width, height );
if( inputWidget != null )
inputWidget.OnResize( oldWidth, oldHeight, width, height );
base.OnResize( oldWidth, oldHeight, width, height );
if( extendedHelp == null ) return;
for( int i = 0; i < extendedHelp.Length; i++ )
extendedHelp[i].OnResize( oldWidth, oldHeight, width, height );
}
public override void Dispose() {
@ -70,11 +90,14 @@ namespace ClassicalSharp {
if( inputWidget != null )
inputWidget.Dispose();
game.Keyboard.KeyRepeat = false;
extendedHelpFont.Dispose();
DisposeExtendedHelp();
base.Dispose();
}
protected ButtonWidget selectedWidget, targetWidget;
protected override void WidgetSelected( Widget widget ) {
DisposeExtendedHelp();
ButtonWidget button = (ButtonWidget)widget;
if( selectedWidget == button || button == null ||
button == buttons[buttons.Length - 2] ) return;
@ -92,13 +115,80 @@ namespace ClassicalSharp {
string text = widget.Text + ": " + widget.GetValue( game );
descWidget = TextWidget.Create( game, 0, 100, text, Anchor.Centre, Anchor.Centre, regularFont );
}
protected void OnWidgetClick( Game game, Widget widget ) {
protected virtual void InputOpened() { }
protected virtual void InputClosed() { }
protected virtual ButtonWidget Make( int x, int y, string text, ClickHandler onClick,
Func<Game, string> getter, Action<Game, string> setter ) {
ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre,
Anchor.Centre, titleFont, onClick );
widget.GetValue = getter;
widget.SetValue = setter;
return widget;
}
void ShowExtendedHelp() {
bool canShow = inputWidget == null && selectedWidget != null && descriptions != null;
if( !canShow ) return;
int index = Array.IndexOf<Widget>( buttons, selectedWidget );
string[] desc = descriptions[index];
if( desc == null ) return;
MakeExtendedHelp( desc );
}
static FastColour tableCol = new FastColour( 20, 20, 20, 200 );
int tableWidth, tableHeight;
const int extHelpY = 90;
void MakeExtendedHelp( string[] desc ) {
extendedHelp = new ChatTextWidget[desc.Length];
int x = 0, y = extHelpY;
tableWidth = 0;
for( int i = 0; i < desc.Length; i++ ) {
extendedHelp[i] = ChatTextWidget.Create( game, 0, y,
desc[i], Anchor.Centre, Anchor.Centre, extendedHelpFont );
tableWidth = Math.Max( extendedHelp[i].Width, tableWidth );
y += extendedHelp[i].Height + 5;
}
tableHeight = y - extHelpY;
// Left align all body text.
int yOffset = 0;
for( int i = 0; i < desc.Length; i++ ) {
ChatTextWidget widget = extendedHelp[i];
if( i == 0 ) {
x = widget.X;
} else {
widget.XOffset = (widget.Width - tableWidth) / 2;
x = CalcOffset( game.Width, widget.Width, widget.XOffset, Anchor.Centre );
}
widget.YOffset = yOffset + extHelpY + extendedHelp[0].Height / 2;
y = CalcOffset( game.Height, widget.Height, widget.YOffset, Anchor.Centre );
yOffset += extendedHelp[i].Height + 5;
widget.MoveTo( x, y );
}
}
void DisposeExtendedHelp() {
if( extendedHelp == null ) return;
for( int i = 0; i < extendedHelp.Length; i++ )
extendedHelp[i].Dispose();
extendedHelp = null;
}
protected void OnWidgetClick( Game game, Widget widget, MouseButton mouseBtn ) {
if( mouseBtn == MouseButton.Right ) { ShowExtendedHelp(); return; }
if( mouseBtn != MouseButton.Left ) return;
if( widget == buttons[okayIndex] ) {
ChangeSetting();
return;
}
ButtonWidget button = (ButtonWidget)widget;
DisposeExtendedHelp();
int index = Array.IndexOf<ButtonWidget>( buttons, button );
MenuInputValidator validator = validators[index];
@ -108,16 +198,7 @@ namespace ClassicalSharp {
UpdateDescription( button );
return;
} else if( validator is EnumValidator ) {
string value = button.GetValue( game );
Type type = (Type)button.Metadata;
int enumValue = (int)Enum.Parse( type, value, true );
enumValue++;
// go back to first value
if( !Enum.IsDefined( type, enumValue ) )
enumValue = 0;
button.SetValue( game, Enum.GetName( type, enumValue ) );
UpdateDescription( button );
HandleEnumOption( button );
return;
}
@ -133,6 +214,18 @@ namespace ClassicalSharp {
UpdateDescription( targetWidget );
}
void HandleEnumOption( ButtonWidget button ) {
string value = button.GetValue( game );
Type type = (Type)button.Metadata;
int enumValue = (int)Enum.Parse( type, value, true );
enumValue++;
// go back to first value
if( !Enum.IsDefined( type, enumValue ) )
enumValue = 0;
button.SetValue( game, Enum.GetName( type, enumValue ) );
UpdateDescription( button );
}
void ChangeSetting() {
string text = inputWidget.GetText();
if( inputWidget.Validator.IsValidValue( text ) )
@ -146,18 +239,5 @@ namespace ClassicalSharp {
buttons[okayIndex] = null;
InputClosed();
}
protected virtual void InputOpened() { }
protected virtual void InputClosed() { }
protected virtual ButtonWidget Make( int x, int y, string text, Action<Game, Widget> onClick,
Func<Game, string> getter, Action<Game, string> setter ) {
ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre,
Anchor.Centre, titleFont, onClick );
widget.GetValue = getter;
widget.SetValue = setter;
return widget;
}
}
}

View File

@ -4,7 +4,7 @@ using ClassicalSharp.Singleplayer;
namespace ClassicalSharp {
public class MiscOptionsScreen : MenuInputScreen {
public class MiscOptionsScreen : MenuOptionsScreen {
public MiscOptionsScreen( Game game ) : base( game ) {
}
@ -108,23 +108,23 @@ namespace ClassicalSharp {
void MakeDescriptions() {
descriptions = new string[buttons.Length][];
descriptions[0] = new[] {
"&aControls how far away you can place/delete blocks.",
"&aControls how far away you can place/delete blocks",
"&eThe default click distance is 5 blocks.",
};
descriptions[2] = new[] {
"&aDetermines how the names of other players/entities are drawn.",
"&aDetermines how the names of other players are drawn",
"&eNoNames: &fNo player names are drawn.",
"&eHoveredOnly: &fThe name of the player you are looking at is drawn without depth testing.",
"&eAllNames: &fAll names are drawn without depth testing.",
"&eAllNamesAndHovered: &fThe name of the player you are looking at is drawn without depth testing,",
"&f all other player names are drawn with depth testing.",
"&eHoveredOnly: &fName of the targeted player is drawn see-through.",
"&eAllNames: &fAll player names are drawn normally.",
"&eAllNamesAndHovered: &fName of the targeted player is drawn see-through.",
"&f All other player names are drawn normally.",
};
descriptions[3] = new[] {
"&aDetermines the method used to limit the number of frames rendered each second.",
"&eVSync: &fNumber of frames rendered is equal to the refresh rate of the monitor.",
"&e30/60/120 FPS: &f30/60/120 frames are rendered at most each second.",
"&aDetermines the method used to limit the number of FPS",
"&eVSync: &fNumber of frames rendered is at most the monitor's refresh rate.",
"&e30/60/120 FPS: &f30/60/120 frames rendered at most each second.",
"&eNoLimit: &Renders as many frames as the GPU can handle each second.",
"&cUsing NoLimit mode is strongly discouraged for general usage.",
"&cUsing NoLimit mode is discouraged for general usage.",
};
}
}

View File

@ -4,7 +4,7 @@ using ClassicalSharp.Singleplayer;
namespace ClassicalSharp {
public sealed class NostalgiaScreen : MenuInputScreen {
public sealed class NostalgiaScreen : MenuOptionsScreen {
TextWidget infoWidget;
public NostalgiaScreen( Game game ) : base( game ) {

View File

@ -71,12 +71,12 @@ namespace ClassicalSharp {
ButtonWidget Make( int x, int y, string text, Anchor vDocking, Action<Game, Widget> onClick ) {
return ButtonWidget.Create( game, x, y, 240, 35, text,
Anchor.Centre, vDocking, titleFont, onClick );
Anchor.Centre, vDocking, titleFont, LeftOnly( onClick ) );
}
ButtonWidget MakeOther( int x, int y, int width, string text, Anchor hAnchor, Action<Game, Widget> onClick ) {
return ButtonWidget.Create( game, x, y, width, 35, text,
hAnchor, Anchor.BottomOrRight, titleFont, onClick );
hAnchor, Anchor.BottomOrRight, titleFont, LeftOnly( onClick ) );
}
public override bool HandlesKeyDown( Key key ) {

View File

@ -77,7 +77,8 @@ namespace ClassicalSharp {
base.Dispose();
}
void OkButtonClick( Game game, Widget widget ) {
void OkButtonClick( Game game, Widget widget, MouseButton mouseBtn ) {
if( mouseBtn != MouseButton.Left ) return;
string text = inputWidget.GetText();
if( text.Length == 0 ) {
MakeDescWidget( "Please enter a filename" );
@ -99,7 +100,8 @@ namespace ClassicalSharp {
}
}
void OverwriteButtonClick( Game game, Widget widget ) {
void OverwriteButtonClick( Game game, Widget widget, MouseButton mouseBtn ) {
if( mouseBtn != MouseButton.Left ) return;
string text = inputWidget.GetText();
string file = Path.ChangeExtension( text, ".cw" );
text = Path.Combine( Program.AppDirectory, "maps" );

View File

@ -23,7 +23,8 @@ namespace ClassicalSharp {
MakeBack( false, titleFont, (g, w) => g.SetNewScreen( new PauseScreen( g ) ) );
}
protected override void TextButtonClick( Game game, Widget widget ) {
protected override void TextButtonClick( Game game, Widget widget, MouseButton mouseBtn ) {
if( mouseBtn != MouseButton.Left ) return;
string file = ((ButtonWidget)widget).Text;
string dir = Path.Combine( Program.AppDirectory, TexturePackExtractor.Dir );
string path = Path.Combine( dir, file );

View File

@ -113,14 +113,16 @@ namespace ClassicalSharp {
}
Action<WarningScreen> yesClick, noClick, renderFrame;
void OnYesClick( Game g, Widget w ) {
void OnYesClick( Game g, Widget w, MouseButton mouseBtn ) {
if( mouseBtn != MouseButton.Left ) return;
if( yesClick != null )
yesClick( this );
Dispose();
CloseScreen();
}
void OnNoClick( Game g, Widget w ) {
void OnNoClick( Game g, Widget w, MouseButton mouseBtn ) {
if( mouseBtn != MouseButton.Left ) return;
if( confirmNo && !confirmMode ) {
InitConfirmButtons( false ); return;
}
@ -131,19 +133,21 @@ namespace ClassicalSharp {
CloseScreen();
}
void OnYesAlwaysClick( Game g, Widget w ) {
OnYesClick( g, w );
void OnYesAlwaysClick( Game g, Widget w, MouseButton mouseBtn ) {
if( mouseBtn != MouseButton.Left ) return;
OnYesClick( g, w, mouseBtn );
string url = ((string)Metadata).Substring( 3 );
if( !game.AcceptedUrls.HasUrl( url ) )
game.AcceptedUrls.AddUrl( url );
}
void OnNoAlwaysClick( Game g, Widget w ) {
void OnNoAlwaysClick( Game g, Widget w, MouseButton mouseBtn ) {
if( mouseBtn != MouseButton.Left ) return;
if( confirmNo && !confirmMode ) {
InitConfirmButtons( true ); return;
}
OnNoClick( g, w );
OnNoClick( g, w, mouseBtn );
string url = ((string)Metadata).Substring( 3 );
if( !game.DeniedUrls.HasUrl( url ) )
game.DeniedUrls.AddUrl( url );
@ -151,8 +155,7 @@ namespace ClassicalSharp {
void InitConfirmButtons( bool always ) {
Action<Game, Widget> noHandler = always ? (Action<Game, Widget>)OnNoAlwaysClick
: (Action<Game, Widget>)OnNoClick;
ClickHandler noHandler = always ? (ClickHandler)OnNoAlwaysClick: (ClickHandler)OnNoClick;
buttons = new ButtonWidget[] {
ButtonWidget.Create( game, -110, 30, 160, 35, "I'm sure", Anchor.Centre,
Anchor.Centre, titleFont, noHandler ),
@ -163,7 +166,8 @@ namespace ClassicalSharp {
SetText( lastTitle, lastBody );
}
void GoBackClick( Game g, Widget w ) {
void GoBackClick( Game g, Widget w, MouseButton mouseBtn ) {
if( mouseBtn != MouseButton.Left ) return;
InitStandardButtons();
confirmMode = false;
SetText( lastTitle, lastBody );

View File

@ -1,5 +1,6 @@
using System;
using System.Drawing;
using OpenTK.Input;
#if ANDROID
using Android.Graphics;
#endif
@ -13,7 +14,7 @@ namespace ClassicalSharp {
}
public static ButtonWidget Create( Game game, int x, int y, int width, int height, string text, Anchor horizontal,
Anchor vertical, Font font, Action<Game, Widget> onClick ) {
Anchor vertical, Font font, ClickHandler onClick ) {
ButtonWidget widget = new ButtonWidget( game, font );
widget.Init();
widget.HorizontalAnchor = horizontal;

View File

@ -1,5 +1,6 @@
using System;
using System.Drawing;
using OpenTK.Input;
namespace ClassicalSharp {
@ -17,8 +18,8 @@ namespace ClassicalSharp {
/// <summary> Whether this widget is prevented from being interacted with. </summary>
public bool Disabled;
/// <summary> Invoked when this widget is clicked on. Can be left null. </summary>
public Action<Game, Widget> OnClick;
/// <summary> Invoked when this widget is clicked on. Can be null. </summary>
public ClickHandler OnClick;
/// <summary> Horizontal coordinate of top left corner in window space. </summary>
public int X;

View File

@ -101,7 +101,7 @@
<Compile Include="2D\Screens\Menu\HacksSettingsScreen.cs" />
<Compile Include="2D\Screens\Menu\KeyBindingsScreen.cs" />
<Compile Include="2D\Screens\Menu\LoadLevelScreen.cs" />
<Compile Include="2D\Screens\Menu\MenuInputScreen.cs" />
<Compile Include="2D\Screens\Menu\MenuOptionsScreen.cs" />
<Compile Include="2D\Screens\Menu\MenuScreen.cs" />
<Compile Include="2D\Screens\Menu\NostalgiaScreen.cs" />
<Compile Include="2D\Screens\Menu\PauseScreen.cs" />