Refactor and comment gui, make tab list higher up and more solid.

This commit is contained in:
UnknownShadow200 2015-10-09 16:47:39 +11:00
parent 1f54263749
commit e9c190c28c
27 changed files with 280 additions and 314 deletions

View File

@ -0,0 +1,70 @@
using System;
using ClassicalSharp.GraphicsAPI;
using OpenTK.Input;
namespace ClassicalSharp {
public abstract class GuiElement : IDisposable {
protected Game game;
protected IGraphicsApi graphicsApi;
public GuiElement( Game game ) {
this.game = game;
graphicsApi = game.Graphics;
}
public abstract void Init();
public abstract void Render( double delta );
public abstract void Dispose();
/// <summary> Called when the game window is resized. </summary>
public abstract void OnResize( int oldWidth, int oldHeight, int width, int height );
public virtual bool HandlesKeyDown( Key key ) {
return false;
}
public virtual bool HandlesKeyPress( char key ) {
return false;
}
public virtual bool HandlesKeyUp( Key key ) {
return false;
}
public virtual bool HandlesMouseClick( int mouseX, int mouseY, MouseButton button ) {
return false;
}
public virtual bool HandlesMouseMove( int mouseX, int mouseY ) {
return false;
}
public virtual bool HandlesMouseScroll( int delta ) {
return false;
}
public virtual bool HandlesMouseUp( int mouseX, int mouseY, MouseButton button ) {
return false;
}
protected static int CalcDelta( int newVal, int oldVal, Anchor mode ) {
return CalcOffset( newVal, oldVal, 0, mode );
}
protected static int CalcOffset( int axisSize, int elemSize, int offset, Anchor mode ) {
if( mode == Anchor.LeftOrTop ) return offset;
if( mode == Anchor.BottomOrRight) return axisSize - elemSize - offset;
return (axisSize - elemSize) / 2 + offset;
}
}
public enum Anchor {
LeftOrTop = 0,
Centre = 1,
BottomOrRight = 2,
}
}

View File

@ -56,19 +56,19 @@ namespace ClassicalSharp {
textInput = new TextInputWidget( game, chatFont, chatInputFont ); textInput = new TextInputWidget( game, chatFont, chatInputFont );
textInput.YOffset = ChatInputYOffset; textInput.YOffset = ChatInputYOffset;
status = new TextGroupWidget( game, 3, chatFont ); status = new TextGroupWidget( game, 3, chatFont );
status.VerticalDocking = Docking.LeftOrTop; status.VerticalAnchor = Anchor.LeftOrTop;
status.HorizontalDocking = Docking.BottomOrRight; status.HorizontalAnchor = Anchor.BottomOrRight;
status.Init(); status.Init();
bottomRight = new TextGroupWidget( game, 3, chatFont ); bottomRight = new TextGroupWidget( game, 3, chatFont );
bottomRight.VerticalDocking = Docking.BottomOrRight; bottomRight.VerticalAnchor = Anchor.BottomOrRight;
bottomRight.HorizontalDocking = Docking.BottomOrRight; bottomRight.HorizontalAnchor = Anchor.BottomOrRight;
bottomRight.YOffset = ChatInputYOffset; bottomRight.YOffset = ChatInputYOffset;
bottomRight.Init(); bottomRight.Init();
normalChat = new TextGroupWidget( game, chatLines, chatFont ); normalChat = new TextGroupWidget( game, chatLines, chatFont );
normalChat.XOffset = 10; normalChat.XOffset = 10;
normalChat.YOffset = ChatLogYOffset; normalChat.YOffset = ChatLogYOffset;
normalChat.HorizontalDocking = Docking.LeftOrTop; normalChat.HorizontalAnchor = Anchor.LeftOrTop;
normalChat.VerticalDocking = Docking.BottomOrRight; normalChat.VerticalAnchor = Anchor.BottomOrRight;
normalChat.Init(); normalChat.Init();
ChatLog chat = game.Chat; ChatLog chat = game.Chat;

View File

@ -25,8 +25,8 @@ namespace ClassicalSharp {
public override void Init() { public override void Init() {
graphicsApi.ClearColour( new FastColour( 65, 31, 31 ) ); graphicsApi.ClearColour( new FastColour( 65, 31, 31 ) );
titleWidget = TextWidget.Create( game, 0, -30, title, Docking.Centre, Docking.Centre, titleFont ); titleWidget = TextWidget.Create( game, 0, -30, title, Anchor.Centre, Anchor.Centre, titleFont );
messageWidget = TextWidget.Create( game, 0, 10, message, Docking.Centre, Docking.Centre, messageFont ); messageWidget = TextWidget.Create( game, 0, 10, message, Anchor.Centre, Anchor.Centre, messageFont );
} }
public override void Dispose() { public override void Dispose() {

View File

@ -73,6 +73,9 @@ namespace ClassicalSharp {
graphicsApi.DeleteTexture( ref posTexture ); graphicsApi.DeleteTexture( ref posTexture );
} }
public override void OnResize( int oldWidth, int oldHeight, int width, int height ) {
}
void DrawPosition() { void DrawPosition() {
int index = 0; int index = 0;
TextureRec xy = new TextureRec( 0, posTexture.Y1, baseWidth, posTexture.Height ); TextureRec xy = new TextureRec( 0, posTexture.Y1, baseWidth, posTexture.Height );

View File

@ -31,8 +31,8 @@ namespace ClassicalSharp {
public override void Init() { public override void Init() {
graphicsApi.Fog = false; graphicsApi.Fog = false;
titleWidget = TextWidget.Create( game, 0, 30, serverName, Docking.Centre, Docking.LeftOrTop, font ); titleWidget = TextWidget.Create( game, 0, 30, serverName, Anchor.Centre, Anchor.LeftOrTop, font );
messageWidget = TextWidget.Create( game, 0, 60, serverMotd, Docking.Centre, Docking.LeftOrTop, font ); messageWidget = TextWidget.Create( game, 0, 60, serverMotd, Anchor.Centre, Anchor.LeftOrTop, font );
progX = game.Width / 2f - progWidth / 2f; progX = game.Width / 2f - progWidth / 2f;
Size size = new Size( progWidth, progHeight ); Size size = new Size( progWidth, progHeight );

View File

@ -13,46 +13,46 @@ namespace ClassicalSharp {
base.Init(); base.Init();
buttons = new ButtonWidget[] { buttons = new ButtonWidget[] {
Make( -140, -150, "Clouds colour", Docking.Centre, OnWidgetClick, Make( -140, -150, "Clouds colour", Anchor.Centre, OnWidgetClick,
g => g.Map.CloudsCol.ToRGBHexString(), g => g.Map.CloudsCol.ToRGBHexString(),
(g, v) => g.Map.SetCloudsColour( FastColour.Parse( v ) ) ), (g, v) => g.Map.SetCloudsColour( FastColour.Parse( v ) ) ),
Make( -140, -100, "Sky colour", Docking.Centre, OnWidgetClick, Make( -140, -100, "Sky colour", Anchor.Centre, OnWidgetClick,
g => g.Map.SkyCol.ToRGBHexString(), g => g.Map.SkyCol.ToRGBHexString(),
(g, v) => g.Map.SetSkyColour( FastColour.Parse( v ) ) ), (g, v) => g.Map.SetSkyColour( FastColour.Parse( v ) ) ),
Make( -140, -50, "Fog colour", Docking.Centre, OnWidgetClick, Make( -140, -50, "Fog colour", Anchor.Centre, OnWidgetClick,
g => g.Map.FogCol.ToRGBHexString(), g => g.Map.FogCol.ToRGBHexString(),
(g, v) => g.Map.SetFogColour( FastColour.Parse( v ) ) ), (g, v) => g.Map.SetFogColour( FastColour.Parse( v ) ) ),
Make( -140, 0, "Clouds speed", Docking.Centre, OnWidgetClick, Make( -140, 0, "Clouds speed", Anchor.Centre, OnWidgetClick,
g => { StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer; g => { StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer;
return env == null ? "(not active)" : env.CloudsSpeed.ToString(); }, return env == null ? "(not active)" : env.CloudsSpeed.ToString(); },
(g, v) => { StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer; (g, v) => { StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer;
if( env != null ) if( env != null )
env.CloudsSpeed = Single.Parse( v ); } ), env.CloudsSpeed = Single.Parse( v ); } ),
Make( -140, 50, "Clouds offset", Docking.Centre, OnWidgetClick, Make( -140, 50, "Clouds offset", Anchor.Centre, OnWidgetClick,
g => (g.Map.CloudHeight - g.Map.Height).ToString(), g => (g.Map.CloudHeight - g.Map.Height).ToString(),
(g, v) => g.Map.SetCloudsLevel( g.Map.Height + Int32.Parse( v ) ) ), (g, v) => g.Map.SetCloudsLevel( g.Map.Height + Int32.Parse( v ) ) ),
Make( 140, -150, "Sunlight colour", Docking.Centre, OnWidgetClick, Make( 140, -150, "Sunlight colour", Anchor.Centre, OnWidgetClick,
g => g.Map.Sunlight.ToRGBHexString(), g => g.Map.Sunlight.ToRGBHexString(),
(g, v) => g.Map.SetSunlight( FastColour.Parse( v ) ) ), (g, v) => g.Map.SetSunlight( FastColour.Parse( v ) ) ),
Make( 140, -100, "Shadow colour", Docking.Centre, OnWidgetClick, Make( 140, -100, "Shadow colour", Anchor.Centre, OnWidgetClick,
g => g.Map.Shadowlight.ToRGBHexString(), g => g.Map.Shadowlight.ToRGBHexString(),
(g, v) => g.Map.SetShadowlight( FastColour.Parse( v ) ) ), (g, v) => g.Map.SetShadowlight( FastColour.Parse( v ) ) ),
Make( 140, -50, "Weather", Docking.Centre, OnWidgetClick, Make( 140, -50, "Weather", Anchor.Centre, OnWidgetClick,
g => ((int)g.Map.Weather).ToString(), g => ((int)g.Map.Weather).ToString(),
(g, v) => g.Map.SetWeather( (Weather)Int32.Parse( v ) ) ), (g, v) => g.Map.SetWeather( (Weather)Int32.Parse( v ) ) ),
Make( 140, 0, "Water level", Docking.Centre, OnWidgetClick, Make( 140, 0, "Water level", Anchor.Centre, OnWidgetClick,
g => g.Map.WaterHeight.ToString(), g => g.Map.WaterHeight.ToString(),
(g, v) => g.Map.SetWaterLevel( Int32.Parse( v ) ) ), (g, v) => g.Map.SetWaterLevel( Int32.Parse( v ) ) ),
Make( 0, 5, "Back to menu", Docking.BottomOrRight, Make( 0, 5, "Back to menu", Anchor.BottomOrRight,
(g, w) => g.SetNewScreen( new PauseScreen( g ) ), null, null ), (g, w) => g.SetNewScreen( new PauseScreen( g ) ), null, null ),
null, null,
}; };
@ -71,9 +71,9 @@ namespace ClassicalSharp {
okayIndex = buttons.Length - 1; okayIndex = buttons.Length - 1;
} }
ButtonWidget Make( int x, int y, string text, Docking vDocking, Action<Game, ButtonWidget> onClick, ButtonWidget Make( int x, int y, string text, Anchor vDocking, Action<Game, ButtonWidget> onClick,
Func<Game, string> getter, Action<Game, string> setter ) { Func<Game, string> getter, Action<Game, string> setter ) {
ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Docking.Centre, vDocking, titleFont, onClick ); ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre, vDocking, titleFont, onClick );
widget.GetValue = getter; widget.GetValue = getter;
widget.SetValue = setter; widget.SetValue = setter;
return widget; return widget;

View File

@ -35,8 +35,8 @@ namespace ClassicalSharp {
MakeKeys( 0, 11, -140 ); MakeKeys( 0, 11, -140 );
MakeKeys( 11, 11, 140 ); MakeKeys( 11, 11, 140 );
buttons[index] = Make( 0, 5, "Back to menu", Docking.BottomOrRight, (g, w) => g.SetNewScreen( new PauseScreen( g ) ) ); buttons[index] = Make( 0, 5, "Back to menu", Anchor.BottomOrRight, (g, w) => g.SetNewScreen( new PauseScreen( g ) ) );
statusWidget = TextWidget.Create( game, 0, 150, "", Docking.Centre, Docking.Centre, regularFont ); statusWidget = TextWidget.Create( game, 0, 150, "", Anchor.Centre, Anchor.Centre, regularFont );
} }
int index; int index;
@ -47,7 +47,7 @@ namespace ClassicalSharp {
string text = descriptions[start + i] + ": " + keyNames[(int)game.Keys[mapping]]; string text = descriptions[start + i] + ": " + keyNames[(int)game.Keys[mapping]];
buttons[index++] = ButtonWidget.Create( game, x, y, 240, 25, text, buttons[index++] = ButtonWidget.Create( game, x, y, 240, 25, text,
Docking.Centre, Docking.Centre, keyFont, OnWidgetClick ); Anchor.Centre, Anchor.Centre, keyFont, OnWidgetClick );
y += 30; y += 30;
} }
} }
@ -59,7 +59,7 @@ namespace ClassicalSharp {
statusWidget.Dispose(); statusWidget.Dispose();
string text = "Press new key binding for " + descriptions[index] + ":"; string text = "Press new key binding for " + descriptions[index] + ":";
statusWidget = TextWidget.Create( game, 0, 150, text, Docking.Centre, Docking.Centre, regularFont ); statusWidget = TextWidget.Create( game, 0, 150, text, Anchor.Centre, Anchor.Centre, regularFont );
} }
public override bool HandlesKeyDown( Key key ) { public override bool HandlesKeyDown( Key key ) {
@ -86,8 +86,8 @@ namespace ClassicalSharp {
return true; return true;
} }
ButtonWidget Make( int x, int y, string text, Docking vDocking, Action<Game, ButtonWidget> onClick ) { ButtonWidget Make( int x, int y, string text, Anchor vDocking, Action<Game, ButtonWidget> onClick ) {
return ButtonWidget.Create( game, x, y, 240, 35, text, Docking.Centre, vDocking, keyFont, onClick ); return ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre, vDocking, keyFont, onClick );
} }
public override void Dispose() { public override void Dispose() {

View File

@ -89,7 +89,7 @@ namespace ClassicalSharp {
descWidget.Dispose(); descWidget.Dispose();
string text = widget.Text + ": " + widget.GetValue( game ); string text = widget.Text + ": " + widget.GetValue( game );
descWidget = TextWidget.Create( game, 0, 100, text, Docking.Centre, Docking.Centre, regularFont ); descWidget = TextWidget.Create( game, 0, 100, text, Anchor.Centre, Anchor.Centre, regularFont );
} }
protected void OnWidgetClick( Game game, ButtonWidget widget ) { protected void OnWidgetClick( Game game, ButtonWidget widget ) {
@ -112,10 +112,10 @@ namespace ClassicalSharp {
targetWidget = selectedWidget; targetWidget = selectedWidget;
inputWidget = MenuInputWidget.Create( game, 0, 150, 400, 25, widget.GetValue( game ), inputWidget = MenuInputWidget.Create( game, 0, 150, 400, 25, widget.GetValue( game ),
Docking.Centre, Docking.Centre, regularFont, titleFont, Anchor.Centre, Anchor.Centre, regularFont, titleFont,
hintFont, validator ); hintFont, validator );
buttons[okayIndex] = ButtonWidget.Create( game, 240, 150, 30, 30, "OK", buttons[okayIndex] = ButtonWidget.Create( game, 240, 150, 30, 30, "OK",
Docking.Centre, Docking.Centre, titleFont, OnWidgetClick ); Anchor.Centre, Anchor.Centre, titleFont, OnWidgetClick );
UpdateDescription( targetWidget ); UpdateDescription( targetWidget );
} }

View File

@ -47,7 +47,7 @@ namespace ClassicalSharp {
if( button != MouseButton.Left ) return false; if( button != MouseButton.Left ) return false;
for( int i = 0; i < buttons.Length; i++ ) { for( int i = 0; i < buttons.Length; i++ ) {
ButtonWidget widget = buttons[i]; ButtonWidget widget = buttons[i];
if( widget != null && widget.ContainsPoint( mouseX, mouseY ) ) { if( widget != null && widget.Bounds.Contains( mouseX, mouseY ) ) {
if( widget.OnClick != null ) if( widget.OnClick != null )
widget.OnClick( game, widget ); widget.OnClick( game, widget );
return true; return true;
@ -64,7 +64,7 @@ namespace ClassicalSharp {
for( int i = 0; i < buttons.Length; i++ ) { for( int i = 0; i < buttons.Length; i++ ) {
ButtonWidget widget = buttons[i]; ButtonWidget widget = buttons[i];
if( widget != null && widget.ContainsPoint( mouseX, mouseY ) ) { if( widget != null && widget.Bounds.Contains( mouseX, mouseY ) ) {
widget.Active = true; widget.Active = true;
WidgetSelected( widget ); WidgetSelected( widget );
return true; return true;

View File

@ -14,34 +14,34 @@ namespace ClassicalSharp {
INetworkProcessor network = game.Network; INetworkProcessor network = game.Network;
buttons = new ButtonWidget[] { buttons = new ButtonWidget[] {
Make( -140, -50, "Show FPS", Docking.Centre, OnWidgetClick, Make( -140, -50, "Show FPS", Anchor.Centre, OnWidgetClick,
g => g.ShowFPS ? "yes" : "no", g => g.ShowFPS ? "yes" : "no",
(g, v) => g.ShowFPS = v == "yes" ), (g, v) => g.ShowFPS = v == "yes" ),
Make( -140, 0, "View distance", Docking.Centre, OnWidgetClick, Make( -140, 0, "View distance", Anchor.Centre, OnWidgetClick,
g => g.ViewDistance.ToString(), g => g.ViewDistance.ToString(),
(g, v) => g.SetViewDistance( Int32.Parse( v ) ) ), (g, v) => g.SetViewDistance( Int32.Parse( v ) ) ),
Make( -140, 50, "VSync active", Docking.Centre, OnWidgetClick, Make( -140, 50, "VSync active", Anchor.Centre, OnWidgetClick,
g => g.VSync ? "yes" : "no", g => g.VSync ? "yes" : "no",
(g, v) => g.Graphics.SetVSync( g, v == "yes" ) ), (g, v) => g.Graphics.SetVSync( g, v == "yes" ) ),
Make( 140, -50, "Mouse sensitivity", Docking.Centre, OnWidgetClick, Make( 140, -50, "Mouse sensitivity", Anchor.Centre, OnWidgetClick,
g => g.MouseSensitivity.ToString(), g => g.MouseSensitivity.ToString(),
(g, v) => { g.MouseSensitivity = Int32.Parse( v ); (g, v) => { g.MouseSensitivity = Int32.Parse( v );
Options.Set( OptionsKey.Sensitivity, v ); } ), Options.Set( OptionsKey.Sensitivity, v ); } ),
Make( 140, 0, "Chat font size", Docking.Centre, OnWidgetClick, Make( 140, 0, "Chat font size", Anchor.Centre, OnWidgetClick,
g => g.Chat.FontSize.ToString(), g => g.Chat.FontSize.ToString(),
(g, v) => { g.Chat.FontSize = Int32.Parse( v ); (g, v) => { g.Chat.FontSize = Int32.Parse( v );
Options.Set( OptionsKey.FontSize, v ); } ), Options.Set( OptionsKey.FontSize, v ); } ),
!network.IsSinglePlayer ? null : !network.IsSinglePlayer ? null :
Make( 140, 50, "Singleplayer physics", Docking.Centre, OnWidgetClick, Make( 140, 50, "Singleplayer physics", Anchor.Centre, OnWidgetClick,
g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no", g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no",
(g, v) => ((SinglePlayerServer)network).physics.Enabled = (v == "yes") ), (g, v) => ((SinglePlayerServer)network).physics.Enabled = (v == "yes") ),
Make( 0, 5, "Back to menu", Docking.BottomOrRight, Make( 0, 5, "Back to menu", Anchor.BottomOrRight,
(g, w) => g.SetNewScreen( new PauseScreen( g ) ), null, null ), (g, w) => g.SetNewScreen( new PauseScreen( g ) ), null, null ),
null, null,
}; };
@ -56,9 +56,9 @@ namespace ClassicalSharp {
okayIndex = buttons.Length - 1; okayIndex = buttons.Length - 1;
} }
ButtonWidget Make( int x, int y, string text, Docking vDocking, Action<Game, ButtonWidget> onClick, ButtonWidget Make( int x, int y, string text, Anchor vDocking, Action<Game, ButtonWidget> onClick,
Func<Game, string> getter, Action<Game, string> setter ) { Func<Game, string> getter, Action<Game, string> setter ) {
ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Docking.Centre, vDocking, titleFont, onClick ); ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre, vDocking, titleFont, onClick );
widget.GetValue = getter; widget.GetValue = getter;
widget.SetValue = setter; widget.SetValue = setter;
return widget; return widget;

View File

@ -19,18 +19,18 @@ namespace ClassicalSharp {
public override void Init() { public override void Init() {
titleFont = new Font( "Arial", 16, FontStyle.Bold ); titleFont = new Font( "Arial", 16, FontStyle.Bold );
buttons = new ButtonWidget[] { buttons = new ButtonWidget[] {
Make( 0, -100, "Options", Docking.Centre, (g, w) => g.SetNewScreen( new OptionsScreen( g ) ) ), Make( 0, -100, "Options", Anchor.Centre, (g, w) => g.SetNewScreen( new OptionsScreen( g ) ) ),
Make( 0, -50, "Environment settings", Docking.Centre, (g, w) => g.SetNewScreen( new EnvSettingsScreen( g ) ) ), Make( 0, -50, "Environment settings", Anchor.Centre, (g, w) => g.SetNewScreen( new EnvSettingsScreen( g ) ) ),
Make( 0, 0, "Key mappings", Docking.Centre, (g, w) => g.SetNewScreen( new KeyMappingsScreen( g ) ) ), Make( 0, 0, "Key mappings", Anchor.Centre, (g, w) => g.SetNewScreen( new KeyMappingsScreen( g ) ) ),
Make( 0, 50, "Save level", Docking.Centre, (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ), Make( 0, 50, "Save level", Anchor.Centre, (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ),
// TODO: singleplayer Make( 0, 50, "Load/Save/Gen level", Docking.Centre, (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ), // TODO: singleplayer Make( 0, 50, "Load/Save/Gen level", Docking.Centre, (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ),
Make( 0, 55, "Back to game", Docking.BottomOrRight, (g, w) => g.SetNewScreen( new NormalScreen( g ) ) ), Make( 0, 55, "Back to game", Anchor.BottomOrRight, (g, w) => g.SetNewScreen( new NormalScreen( g ) ) ),
Make( 0, 5, "Quit game", Docking.BottomOrRight, (g, w) => g.Exit() ), Make( 0, 5, "Quit game", Anchor.BottomOrRight, (g, w) => g.Exit() ),
}; };
} }
ButtonWidget Make( int x, int y, string text, Docking vDocking, Action<Game, ButtonWidget> onClick ) { ButtonWidget Make( int x, int y, string text, Anchor vDocking, Action<Game, ButtonWidget> onClick ) {
return ButtonWidget.Create( game, x, y, 240, 35, text, Docking.Centre, vDocking, titleFont, onClick ); return ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre, vDocking, titleFont, onClick );
} }
public override bool HandlesKeyDown( Key key ) { public override bool HandlesKeyDown( Key key ) {

View File

@ -52,13 +52,13 @@ namespace ClassicalSharp {
hintFont = new Font( "Arial", 14, FontStyle.Italic ); hintFont = new Font( "Arial", 14, FontStyle.Italic );
inputWidget = MenuInputWidget.Create( inputWidget = MenuInputWidget.Create(
game, -30, 50, 500, 25, "", Docking.Centre, Docking.Centre, game, -30, 50, 500, 25, "", Anchor.Centre, Anchor.Centre,
regularFont, titleFont, hintFont, new PathValidator() ); regularFont, titleFont, hintFont, new PathValidator() );
buttons = new [] { buttons = new [] {
ButtonWidget.Create( game, 260, 50, 60, 30, "Save", Docking.Centre, ButtonWidget.Create( game, 260, 50, 60, 30, "Save", Anchor.Centre,
Docking.Centre, titleFont, OkButtonClick ), Anchor.Centre, titleFont, OkButtonClick ),
ButtonWidget.Create( game, 0, 5, 240, 35, "Back to menu", Docking.Centre, Docking.BottomOrRight, ButtonWidget.Create( game, 0, 5, 240, 35, "Back to menu", Anchor.Centre, Anchor.BottomOrRight,
titleFont, (g, w) => g.SetNewScreen( new PauseScreen( g ) ) ), titleFont, (g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
}; };
} }
@ -110,9 +110,9 @@ namespace ClassicalSharp {
game.SetNewScreen( new PauseScreen( game ) ); game.SetNewScreen( new PauseScreen( game ) );
} }
void MakeDescWidget( string text) { void MakeDescWidget( string text ) {
DisposeDescWidget(); DisposeDescWidget();
descWidget = TextWidget.Create( game, 0, 90, text, Docking.Centre, Docking.Centre, regularFont ); descWidget = TextWidget.Create( game, 0, 90, text, Anchor.Centre, Anchor.Centre, regularFont );
} }
void DisposeDescWidget() { void DisposeDescWidget() {

View File

@ -67,7 +67,8 @@ namespace ClassicalSharp {
chat.OnResize( oldWidth, oldHeight, width, height ); chat.OnResize( oldWidth, oldHeight, width, height );
hotbar.OnResize( oldWidth, oldHeight, width, height ); hotbar.OnResize( oldWidth, oldHeight, width, height );
if( playerList != null ) { if( playerList != null ) {
playerList.OnResize( oldWidth, oldHeight, width, height ); int deltaX = CalcDelta( width, oldWidth, Anchor.Centre );
playerList.MoveTo( playerList.X + deltaX, height / 4 );
} }
} }
@ -102,6 +103,7 @@ namespace ClassicalSharp {
playerList = new NormalPlayerListWidget( game, playerFont ); playerList = new NormalPlayerListWidget( game, playerFont );
} }
playerList.Init(); playerList.Init();
playerList.MoveTo( playerList.X, game.Height / 4 );
} }
} }
if( chat.HandlesKeyDown( key ) ) { if( chat.HandlesKeyDown( key ) ) {

View File

@ -1,59 +1,19 @@
using System; using System;
using ClassicalSharp.GraphicsAPI;
using OpenTK.Input;
namespace ClassicalSharp { namespace ClassicalSharp {
public abstract class Screen : IDisposable { /// <summary> Represents a container of widgets and other 2D elements. </summary>
/// <remarks> May cover the entire game window. </remarks>
public abstract class Screen : GuiElement {
protected Game game; public Screen( Game game ) : base( game ) {
protected IGraphicsApi graphicsApi;
public Screen( Game game ) {
this.game = game;
graphicsApi = game.Graphics;
} }
/// <summary> Whether this screen handles all mouse and keyboard input. </summary>
/// <remarks> This prevents the client from interacting with the world. </remarks>
public virtual bool HandlesAllInput { get; protected set; } public virtual bool HandlesAllInput { get; protected set; }
public abstract void Init(); /// <summary> Whether this screen completely and opaquely covers the game world behind it. </summary>
public abstract void Render( double delta );
public abstract void Dispose();
public virtual void OnResize( int oldWidth, int oldHeight, int width, int height ) {
}
public virtual bool HandlesKeyDown( Key key ) {
return false;
}
public virtual bool HandlesKeyPress( char key ) {
return false;
}
public virtual bool HandlesKeyUp( Key key ) {
return false;
}
public virtual bool HandlesMouseClick( int mouseX, int mouseY, MouseButton button ) {
return false;
}
public virtual bool HandlesMouseMove( int mouseX, int mouseY ) {
return false;
}
public virtual bool HandlesMouseScroll( int delta ) {
return false;
}
public virtual bool HandlesMouseUp( int mouseX, int mouseY, MouseButton button ) {
return false;
}
/// <summary> Whether the screen completely covers the world behind it. </summary>
public virtual bool BlocksWorld { public virtual bool BlocksWorld {
get { return false; } get { return false; }
} }

View File

@ -8,8 +8,8 @@ namespace ClassicalSharp {
public sealed class BlockHotbarWidget : Widget { public sealed class BlockHotbarWidget : Widget {
public BlockHotbarWidget( Game game ) : base( game ) { public BlockHotbarWidget( Game game ) : base( game ) {
HorizontalDocking = Docking.Centre; HorizontalAnchor = Anchor.Centre;
VerticalDocking = Docking.BottomOrRight; VerticalAnchor = Anchor.BottomOrRight;
hotbarCount = game.Inventory.Hotbar.Length; hotbarCount = game.Inventory.Hotbar.Length;
} }

View File

@ -10,12 +10,12 @@ namespace ClassicalSharp {
this.font = font; this.font = font;
} }
public static ButtonWidget Create( Game game, int x, int y, int width, int height, string text, Docking horizontal, public static ButtonWidget Create( Game game, int x, int y, int width, int height, string text, Anchor horizontal,
Docking vertical, Font font, Action<Game, ButtonWidget> onClick ) { Anchor vertical, Font font, Action<Game, ButtonWidget> onClick ) {
ButtonWidget widget = new ButtonWidget( game, font ); ButtonWidget widget = new ButtonWidget( game, font );
widget.Init(); widget.Init();
widget.HorizontalDocking = horizontal; widget.HorizontalAnchor = horizontal;
widget.VerticalDocking = vertical; widget.VerticalAnchor = vertical;
widget.XOffset = x; widget.XOffset = x;
widget.YOffset = y; widget.YOffset = y;
widget.DesiredMaxWidth = width; widget.DesiredMaxWidth = width;
@ -47,8 +47,8 @@ namespace ClassicalSharp {
Height = defaultHeight; Height = defaultHeight;
} else { } else {
MakeTexture( text ); MakeTexture( text );
X = texture.X1 = CalcOffset( game.Width, texture.Width, XOffset, HorizontalDocking ); X = texture.X1 = CalcOffset( game.Width, texture.Width, XOffset, HorizontalAnchor );
Y = texture.Y1 = CalcOffset( game.Height, texture.Height, YOffset, VerticalDocking ); Y = texture.Y1 = CalcOffset( game.Height, texture.Height, YOffset, VerticalAnchor );
Height = texture.Height; Height = texture.Height;
} }
Width = texture.Width; Width = texture.Width;

View File

@ -83,7 +83,7 @@ namespace ClassicalSharp {
RemoveItemAt( textures, i ); RemoveItemAt( textures, i );
RemoveItemAt( info, i ); RemoveItemAt( info, i );
namesCount--; namesCount--;
columns = (int)Math.Ceiling( (double)namesCount / namesPerColumn ); columns = Utils.CeilDiv( namesCount, namesPerColumn );
SortPlayerInfo(); SortPlayerInfo();
return; return;
} }
@ -92,7 +92,7 @@ namespace ClassicalSharp {
void PlayerListInfoAdded( object sender, IdEventArgs e ) { void PlayerListInfoAdded( object sender, IdEventArgs e ) {
AddPlayerInfo( game.CpePlayersList[e.Id], -1 ); AddPlayerInfo( game.CpePlayersList[e.Id], -1 );
columns = (int)Math.Ceiling( (double)namesCount / namesPerColumn ); columns = Utils.CeilDiv( namesCount, namesPerColumn );
SortPlayerInfo(); SortPlayerInfo();
} }

View File

@ -7,20 +7,20 @@ namespace ClassicalSharp {
public sealed class MenuInputWidget : Widget { public sealed class MenuInputWidget : Widget {
public MenuInputWidget( Game game, Font font, Font boldFont, Font hintFont ) : base( game ) { public MenuInputWidget( Game game, Font font, Font boldFont, Font hintFont ) : base( game ) {
HorizontalDocking = Docking.LeftOrTop; HorizontalAnchor = Anchor.LeftOrTop;
VerticalDocking = Docking.BottomOrRight; VerticalAnchor = Anchor.BottomOrRight;
this.font = font; this.font = font;
this.boldFont = boldFont; this.boldFont = boldFont;
this.hintFont = hintFont; this.hintFont = hintFont;
chatInputText = new StringBuffer( 64 ); chatInputText = new StringBuffer( 64 );
} }
public static MenuInputWidget Create( Game game, int x, int y, int width, int height, string text, Docking horizontal, public static MenuInputWidget Create( Game game, int x, int y, int width, int height, string text, Anchor horizontal,
Docking vertical, Font font, Font tildeFont, Font hintFont, MenuInputValidator validator ) { Anchor vertical, Font font, Font tildeFont, Font hintFont, MenuInputValidator validator ) {
MenuInputWidget widget = new MenuInputWidget( game, font, tildeFont, hintFont ); MenuInputWidget widget = new MenuInputWidget( game, font, tildeFont, hintFont );
widget.HorizontalDocking = horizontal; widget.HorizontalAnchor = horizontal;
widget.VerticalDocking = vertical; widget.VerticalAnchor = vertical;
widget.XOffset = x; widget.XOffset = x;
widget.YOffset = y; widget.YOffset = y;
widget.DesiredMaxWidth = width; widget.DesiredMaxWidth = width;
@ -76,8 +76,8 @@ namespace ClassicalSharp {
} }
} }
X = CalcOffset( game.Width, size.Width, XOffset, HorizontalDocking ); X = CalcOffset( game.Width, size.Width, XOffset, HorizontalAnchor );
Y = CalcOffset( game.Height, size.Height, YOffset, VerticalDocking ); Y = CalcOffset( game.Height, size.Height, YOffset, VerticalAnchor );
chatCaretTexture.X1 = chatInputTexture.X1 = X; chatCaretTexture.X1 = chatInputTexture.X1 = X;
chatCaretTexture.X1 += textSize.Width; chatCaretTexture.X1 += textSize.Width;
chatCaretTexture.Y1 = chatInputTexture.Y1 = Y; chatCaretTexture.Y1 = chatInputTexture.Y1 = Y;

View File

@ -36,7 +36,7 @@ namespace ClassicalSharp {
void PlayerSpawned( object sender, IdEventArgs e ) { void PlayerSpawned( object sender, IdEventArgs e ) {
Player player = game.Players[e.Id]; Player player = game.Players[e.Id];
AddPlayerInfo( player ); AddPlayerInfo( player );
columns = (int)Math.Ceiling( (double)namesCount / namesPerColumn ); columns = Utils.CeilDiv( namesCount, namesPerColumn );
SortPlayerInfo(); SortPlayerInfo();
} }
@ -66,7 +66,7 @@ namespace ClassicalSharp {
RemoveItemAt( info, i ); RemoveItemAt( info, i );
RemoveItemAt( textures, i ); RemoveItemAt( textures, i );
namesCount--; namesCount--;
columns = (int)Math.Ceiling( (double)namesCount / namesPerColumn ); columns = Utils.CeilDiv( namesCount, namesPerColumn );
SortPlayerInfo(); SortPlayerInfo();
return; return;
} }

View File

@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Drawing; using System.Drawing;
namespace ClassicalSharp { namespace ClassicalSharp {
@ -8,8 +7,8 @@ namespace ClassicalSharp {
protected readonly Font font; protected readonly Font font;
public PlayerListWidget( Game game, Font font ) : base( game ) { public PlayerListWidget( Game game, Font font ) : base( game ) {
HorizontalDocking = Docking.Centre; HorizontalAnchor = Anchor.Centre;
VerticalDocking = Docking.Centre; VerticalAnchor = Anchor.Centre;
this.font = font; this.font = font;
} }
@ -19,11 +18,11 @@ namespace ClassicalSharp {
protected Texture[] textures = new Texture[256]; protected Texture[] textures = new Texture[256];
protected int columns; protected int columns;
protected int xMin, xMax, yHeight; protected int xMin, xMax, yHeight;
protected static FastColour tableCol = new FastColour( 100, 100, 100, 80 ); protected static FastColour tableCol = new FastColour( 20, 20, 20, 220 );
public override void Init() { public override void Init() {
CreateInitialPlayerInfo(); CreateInitialPlayerInfo();
columns = (int)Math.Ceiling( (double)namesCount / namesPerColumn ); columns = Utils.CeilDiv( namesCount, namesPerColumn );
SortPlayerInfo(); SortPlayerInfo();
} }
@ -67,9 +66,8 @@ namespace ClassicalSharp {
int maxWidth = 0; int maxWidth = 0;
int maxIndex = Math.Min( namesCount, i + namesPerColumn ); int maxIndex = Math.Min( namesCount, i + namesPerColumn );
for( ; i < maxIndex; i++ ) { for( ; i < maxIndex; i++ )
maxWidth = Math.Max( maxWidth, textures[i].Width ); maxWidth = Math.Max( maxWidth, textures[i].Width );
}
return maxWidth; return maxWidth;
} }
@ -78,9 +76,8 @@ namespace ClassicalSharp {
int total = 0; int total = 0;
int maxIndex = Math.Min( namesCount, i + namesPerColumn ); int maxIndex = Math.Min( namesCount, i + namesPerColumn );
for( ; i < maxIndex; i++ ) { for( ; i < maxIndex; i++ )
total += textures[i].Height; total += textures[i].Height;
}
return total; return total;
} }
@ -90,24 +87,19 @@ namespace ClassicalSharp {
for( ; i < maxIndex; i++ ) { for( ; i < maxIndex; i++ ) {
Texture tex = textures[i]; Texture tex = textures[i];
tex.X1 = x; tex.X1 = x; tex.Y1 = y;
tex.Y1 = y;
y += tex.Height; y += tex.Height;
textures[i] = tex; textures[i] = tex;
} }
} }
public override void MoveTo( int newX, int newY ) { public override void MoveTo( int newX, int newY ) {
int deltaX = newX - X; int diffX = newX - X; int diffY = newY - Y;
int deltaY = newY - Y;
for( int i = 0; i < namesCount; i++ ) { for( int i = 0; i < namesCount; i++ ) {
Texture tex = textures[i]; textures[i].X1 += diffX;
tex.X1 += deltaX; textures[i].Y1 += diffY;
tex.Y1 += deltaY;
textures[i] = tex;
} }
X = newX; X = newX; Y = newY;
Y = newY;
} }
protected abstract void CreateInitialPlayerInfo(); protected abstract void CreateInitialPlayerInfo();
@ -131,7 +123,7 @@ namespace ClassicalSharp {
int offset = 0; int offset = 0;
if( columns % 2 != 0 ) { if( columns % 2 != 0 ) {
// For an odd number of columns, the middle column is centred. // For an odd number of columns, the middle column is centred.
offset = ( GetColumnWidth( midCol ) + 1 ) / 2; // ceiling divide by 2 offset = Utils.CeilDiv( GetColumnWidth( midCol ), 2 );
} }
int x = centreX - offset; int x = centreX - offset;

View File

@ -31,7 +31,7 @@ namespace ClassicalSharp {
if( !String.IsNullOrEmpty( text ) ) { if( !String.IsNullOrEmpty( text ) ) {
DrawTextArgs args = new DrawTextArgs( text, true ); DrawTextArgs args = new DrawTextArgs( text, true );
Texture tex = game.Drawer2D.MakeTextTexture( font, 0, 0, ref args ); Texture tex = game.Drawer2D.MakeTextTexture( font, 0, 0, ref args );
tex.X1 = CalcOffset( game.Width, tex.Width, XOffset, HorizontalDocking ); tex.X1 = CalcOffset( game.Width, tex.Width, XOffset, HorizontalAnchor );
tex.Y1 = CalcY( index, tex.Height ); tex.Y1 = CalcY( index, tex.Height );
textures[index] = tex; textures[index] = tex;
} else { } else {
@ -56,7 +56,7 @@ namespace ClassicalSharp {
int y = 0; int y = 0;
int deltaY = newHeight - textures[index].Height; int deltaY = newHeight - textures[index].Height;
if( VerticalDocking == Docking.LeftOrTop ) { if( VerticalAnchor == Anchor.LeftOrTop ) {
y = Y; y = Y;
for( int i = 0; i < index; i++ ) { for( int i = 0; i < index; i++ ) {
y += textures[i].Height; y += textures[i].Height;
@ -91,7 +91,7 @@ namespace ClassicalSharp {
for( int i = 0; i < textures.Length; i++ ) { for( int i = 0; i < textures.Length; i++ ) {
Height += textures[i].Height; Height += textures[i].Height;
} }
Y = CalcOffset( game.Height, Height, YOffset, VerticalDocking ); Y = CalcOffset( game.Height, Height, YOffset, VerticalAnchor );
Width = 0; Width = 0;
for( int i = 0; i < textures.Length; i++ ) { for( int i = 0; i < textures.Length; i++ ) {
@ -100,7 +100,7 @@ namespace ClassicalSharp {
Width = width; Width = width;
} }
} }
X = CalcOffset( game.Width, Width, XOffset, HorizontalDocking ); X = CalcOffset( game.Width, Width, XOffset, HorizontalAnchor );
} }
public override void Render( double delta ) { public override void Render( double delta ) {

View File

@ -8,8 +8,8 @@ namespace ClassicalSharp {
public sealed class TextInputWidget : Widget { public sealed class TextInputWidget : Widget {
public TextInputWidget( Game game, Font font, Font boldFont ) : base( game ) { public TextInputWidget( Game game, Font font, Font boldFont ) : base( game ) {
HorizontalDocking = Docking.LeftOrTop; HorizontalAnchor = Anchor.LeftOrTop;
VerticalDocking = Docking.BottomOrRight; VerticalAnchor = Anchor.BottomOrRight;
typingLogPos = game.Chat.InputLog.Count; // Index of newest entry + 1. typingLogPos = game.Chat.InputLog.Count; // Index of newest entry + 1.
this.font = font; this.font = font;
this.boldFont = boldFont; this.boldFont = boldFont;

View File

@ -10,11 +10,11 @@ namespace ClassicalSharp {
this.font = font; this.font = font;
} }
public static TextWidget Create( Game game, int x, int y, string text, Docking horizontal, Docking vertical, Font font ) { public static TextWidget Create( Game game, int x, int y, string text, Anchor horizontal, Anchor vertical, Font font ) {
TextWidget widget = new TextWidget( game, font ); TextWidget widget = new TextWidget( game, font );
widget.Init(); widget.Init();
widget.HorizontalDocking = horizontal; widget.HorizontalAnchor = horizontal;
widget.VerticalDocking = vertical; widget.VerticalAnchor = vertical;
widget.XOffset = x; widget.XOffset = x;
widget.YOffset = y; widget.YOffset = y;
widget.SetText( text ); widget.SetText( text );
@ -39,8 +39,8 @@ namespace ClassicalSharp {
} else { } else {
DrawTextArgs args = new DrawTextArgs( text, true ); DrawTextArgs args = new DrawTextArgs( text, true );
texture = game.Drawer2D.MakeTextTexture( font, 0, 0, ref args ); texture = game.Drawer2D.MakeTextTexture( font, 0, 0, ref args );
X = texture.X1 = CalcOffset( game.Width, texture.Width, XOffset, HorizontalDocking ); X = texture.X1 = CalcOffset( game.Width, texture.Width, XOffset, HorizontalAnchor );
Y = texture.Y1 = CalcOffset( game.Height, texture.Height, YOffset, VerticalDocking ); Y = texture.Y1 = CalcOffset( game.Height, texture.Height, YOffset, VerticalAnchor );
Height = texture.Height; Height = texture.Height;
} }
Width = texture.Width; Width = texture.Width;

View File

@ -1,125 +1,63 @@
using System; using System;
using System.Drawing; using System.Drawing;
using ClassicalSharp.GraphicsAPI;
using OpenTK.Input;
namespace ClassicalSharp { namespace ClassicalSharp {
public abstract class Widget : IDisposable { /// <summary> Represents an individual 2D gui component. </summary>
public abstract class Widget : GuiElement {
protected internal Game game; public Widget( Game game ) : base( game ) {
protected IGraphicsApi graphicsApi; HorizontalAnchor = Anchor.LeftOrTop;
VerticalAnchor = Anchor.LeftOrTop;
public Widget( Game game ) {
this.game = game;
graphicsApi = game.Graphics;
HorizontalDocking = Docking.LeftOrTop;
VerticalDocking = Docking.LeftOrTop;
} }
public int X { get; set; } /// <summary> Horizontal coordinate of top left corner in window space. </summary>
public int X;
public int Y { get; set; } /// <summary> Vertical coordinate of top left corner in window space. </summary>
public int Y;
public int Width { get; set; } /// <summary> Horizontal length of widget's bounds in window space. </summary>
public int Width;
public int Height { get; set; } /// <summary> Vertical length of widget's bounds in window space. </summary>
public int Height;
public Docking HorizontalDocking { get; set; } /// <summary> Specifies the horizontal reference point for when the widget is resized. </summary>
public Anchor HorizontalAnchor;
public Docking VerticalDocking { get; set; } /// <summary> Specifies the vertical reference point for when the widget is resized. </summary>
public Anchor VerticalAnchor;
/// <summary> Width and height of widget in window space. </summary>
public Size Size { public Size Size {
get { return new Size( Width, Height ); } get { return new Size( Width, Height ); }
} }
/// <summary> Coordinate of top left corner of widget's bounds in window space. </summary>
public Point TopLeft { public Point TopLeft {
get { return new Point( X, Y ); } get { return new Point( X, Y ); }
} }
/// <summary> Coordinate of bottom right corner of widget's bounds in window space. </summary>
public Point BottomRight { public Point BottomRight {
get { return new Point( X + Width, Y + Height ); } get { return new Point( X + Width, Y + Height ); }
} }
/// <summary> Specifies the boundaries of the widget in window space. </summary>
public Rectangle Bounds { public Rectangle Bounds {
get { return new Rectangle( X, Y, Width, Height ); } get { return new Rectangle( X, Y, Width, Height ); }
} }
public bool ContainsPoint( int x, int y ) { /// <summary> Moves the widget to the specified window space coordinates. </summary>
return Bounds.Contains( x, y );
}
public bool ContainsPoint( Point point ) {
return Bounds.Contains( point );
}
public bool ContainsRectangle( Rectangle rect ) {
return Bounds.Contains( rect );
}
public bool IntersectsRectangle( Rectangle rect ) {
return Bounds.IntersectsWith( rect );
}
public virtual bool HandlesKeyDown( Key key ) {
return false;
}
public virtual bool HandlesKeyPress( char key ) {
return false;
}
public virtual bool HandlesKeyUp( Key key ) {
return false;
}
public virtual bool HandleMouseClick( int mouseX, int mouseY ) {
return false;
}
public virtual bool HandleMouseHover( int mouseX, int mouseY ) {
return false;
}
public virtual bool HandleMouseLeave( int mouseX, int mouseY ) {
return false;
}
public virtual bool HandleMouseDeClick( int mouseX, int mouseY ) {
return false;
}
public abstract void Init();
public abstract void Render( double delta );
public abstract void Dispose();
public virtual void MoveTo( int newX, int newY ) { public virtual void MoveTo( int newX, int newY ) {
X = newX; X = newX; Y = newY;
Y = newY;
} }
public virtual void OnResize( int oldWidth, int oldHeight, int width, int height ) { public override void OnResize( int oldWidth, int oldHeight, int width, int height ) {
int deltaX = CalcDelta( width, oldWidth, HorizontalDocking ); int deltaX = CalcDelta( width, oldWidth, HorizontalAnchor );
int deltaY = CalcDelta( height, oldHeight, VerticalDocking ); int deltaY = CalcDelta( height, oldHeight, VerticalAnchor );
MoveTo( X + deltaX, Y + deltaY ); MoveTo( X + deltaX, Y + deltaY );
} }
protected static int CalcDelta( int newVal, int oldVal, Docking mode ) {
return CalcOffset( newVal, oldVal, 0, mode );
}
protected static int CalcOffset( int axisSize, int elemSize, int offset, Docking mode ) {
if( mode == Docking.LeftOrTop ) return offset;
if( mode == Docking.BottomOrRight) return axisSize - elemSize - offset;
return ( axisSize - elemSize ) / 2 + offset;
}
}
public enum Docking {
LeftOrTop = 0,
Centre = 1,
BottomOrRight = 2,
} }
} }

View File

@ -65,6 +65,7 @@
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="2D\GuiElement.cs" />
<Compile Include="2D\IsometricBlockDrawer.cs" /> <Compile Include="2D\IsometricBlockDrawer.cs" />
<Compile Include="2D\Drawing\DrawTextArgs.cs" /> <Compile Include="2D\Drawing\DrawTextArgs.cs" />
<Compile Include="2D\Drawing\GdiPlusDrawer2D.cs" /> <Compile Include="2D\Drawing\GdiPlusDrawer2D.cs" />

View File

@ -194,7 +194,7 @@ namespace ClassicalSharp {
imageCheckAccumulator += e.Time; imageCheckAccumulator += e.Time;
ticksAccumulator += e.Time; ticksAccumulator += e.Time;
Vertices = 0; Vertices = 0;
if( !Focused && ( activeScreen == null || !activeScreen.HandlesAllInput ) ) { if( !Focused && (activeScreen == null || !activeScreen.HandlesAllInput) ) {
SetNewScreen( new PauseScreen( this ) ); SetNewScreen( new PauseScreen( this ) );
} }

View File

@ -53,6 +53,8 @@ namespace Launcher
this.txtCCSearch = new System.Windows.Forms.TextBox(); this.txtCCSearch = new System.Windows.Forms.TextBox();
this.lblCCSearch = new System.Windows.Forms.Label(); this.lblCCSearch = new System.Windows.Forms.Label();
this.tabMinecraftNet = new System.Windows.Forms.TabPage(); this.tabMinecraftNet = new System.Windows.Forms.TabPage();
this.lblMCdead2 = new System.Windows.Forms.Label();
this.lblMCdead = new System.Windows.Forms.Label();
this.tabDC = new System.Windows.Forms.TabPage(); this.tabDC = new System.Windows.Forms.TabPage();
this.lblDChint = new System.Windows.Forms.Label(); this.lblDChint = new System.Windows.Forms.Label();
this.txtDCmppass = new System.Windows.Forms.TextBox(); this.txtDCmppass = new System.Windows.Forms.TextBox();
@ -66,8 +68,6 @@ namespace Launcher
this.lblDCaddress = new System.Windows.Forms.Label(); this.lblDCaddress = new System.Windows.Forms.Label();
this.lblDCuser = new System.Windows.Forms.Label(); this.lblDCuser = new System.Windows.Forms.Label();
this.tabs = new System.Windows.Forms.TabControl(); this.tabs = new System.Windows.Forms.TabControl();
this.lblMCdead = new System.Windows.Forms.Label();
this.lblMCdead2 = new System.Windows.Forms.Label();
this.tabClassicubeNet.SuspendLayout(); this.tabClassicubeNet.SuspendLayout();
this.tabCC.SuspendLayout(); this.tabCC.SuspendLayout();
this.tabCCSignIn.SuspendLayout(); this.tabCCSignIn.SuspendLayout();
@ -318,6 +318,24 @@ namespace Launcher
this.tabMinecraftNet.Text = "minecraft.net"; this.tabMinecraftNet.Text = "minecraft.net";
this.tabMinecraftNet.UseVisualStyleBackColor = true; this.tabMinecraftNet.UseVisualStyleBackColor = true;
// //
// lblMCdead2
//
this.lblMCdead2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblMCdead2.Location = new System.Drawing.Point(20, 62);
this.lblMCdead2.Name = "lblMCdead2";
this.lblMCdead2.Size = new System.Drawing.Size(300, 41);
this.lblMCdead2.TabIndex = 1;
this.lblMCdead2.Text = "But don\'t despair! You can sign up for an account at classicube.net.";
//
// lblMCdead
//
this.lblMCdead.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblMCdead.Location = new System.Drawing.Point(20, 20);
this.lblMCdead.Name = "lblMCdead";
this.lblMCdead.Size = new System.Drawing.Size(380, 23);
this.lblMCdead.TabIndex = 0;
this.lblMCdead.Text = "Classic has been removed from minecraft.net.";
//
// tabDC // tabDC
// //
this.tabDC.Controls.Add(this.lblDChint); this.tabDC.Controls.Add(this.lblDChint);
@ -450,24 +468,6 @@ namespace Launcher
this.tabs.Size = new System.Drawing.Size(482, 466); this.tabs.Size = new System.Drawing.Size(482, 466);
this.tabs.TabIndex = 0; this.tabs.TabIndex = 0;
// //
// lblMCdead
//
this.lblMCdead.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblMCdead.Location = new System.Drawing.Point(20, 20);
this.lblMCdead.Name = "lblMCdead";
this.lblMCdead.Size = new System.Drawing.Size(380, 23);
this.lblMCdead.TabIndex = 0;
this.lblMCdead.Text = "Classic has been removed from minecraft.net.";
//
// lblMCdead2
//
this.lblMCdead2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblMCdead2.Location = new System.Drawing.Point(20, 62);
this.lblMCdead2.Name = "lblMCdead2";
this.lblMCdead2.Size = new System.Drawing.Size(300, 41);
this.lblMCdead2.TabIndex = 1;
this.lblMCdead2.Text = "But don\'t despair! You can sign up for an account at classicube.net.";
//
// MainForm // MainForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);