diff --git a/Launcher2/Gui/Screens/ChooseModeScreen.cs b/Launcher2/Gui/Screens/ChooseModeScreen.cs
index 5f89e8af0..c386a7e9f 100644
--- a/Launcher2/Gui/Screens/ChooseModeScreen.cs
+++ b/Launcher2/Gui/Screens/ChooseModeScreen.cs
@@ -8,22 +8,31 @@ using OpenTK.Input;
namespace Launcher {
- public abstract class ChooseModeScreen : LauncherScreen {
+ public sealed class ChooseModeScreen : LauncherScreen {
- protected Font titleFont, infoFont;
- public ChooseModeScreen( LauncherWindow game ) : base( game ) {
+ ChooseModeView view;
+ public ChooseModeScreen( LauncherWindow game, bool firstTime ) : base( game ) {
game.Window.Mouse.Move += MouseMove;
game.Window.Mouse.ButtonDown += MouseButtonDown;
- titleFont = new Font( game.FontName, 16, FontStyle.Bold );
- infoFont = new Font( game.FontName, 14, FontStyle.Regular );
- buttonFont = titleFont;
- widgets = new LauncherWidget[14];
+ view = new ChooseModeView( game );
+ view.FirstTime = firstTime;
+ widgets = view.widgets;
}
public override void Init() {
game.Window.Keyboard.KeyDown += KeyDown;
game.Window.Keyboard.KeyUp += KeyUp;
+ view.Init();
+
+ widgets[view.nIndex].OnClick = (x, y) => ModeClick( false, false );
+ widgets[view.clIndex ].OnClick = (x, y) => ModeClick( true, false );
+ widgets[view.clHaxIndex].OnClick = (x, y) => ModeClick( true, true );
+
+ if( view.backIndex >= 0 ) {
+ widgets[view.backIndex].OnClick = (x, y)
+ => game.SetScreen( new MainScreen( game ) );
+ }
Resize();
}
@@ -45,50 +54,10 @@ namespace Launcher {
}
public override void Resize() {
- MakeWidgets();
- RedrawAllButtonBackgrounds();
-
- using( drawer ) {
- drawer.SetBitmap( game.Framebuffer );
- RedrawAll();
- FastColour col = LauncherSkin.ButtonBorderCol;
- int middle = game.Height / 2;
- game.Drawer.DrawRect( col, game.Width / 2 - 250, middle - 35, 490, 1 );
- game.Drawer.DrawRect( col, game.Width / 2 - 250, middle + 35, 490, 1 );
- }
+ view.DrawAll();
Dirty = true;
}
- void MakeWidgets() {
- widgetIndex = 0;
- int middle = game.Width / 2;
- MakeLabelAt("&fChoose game mode", titleFont, Anchor.Centre, Anchor.Centre, 0, -135 );
-
- MakeButtonAt( "Normal", 145, 35, titleFont, Anchor.LeftOrTop, Anchor.Centre, middle - 250, -72,
- (x, y) => ModeClick( false, false ) );
- MakeLabelAt( "&eEnables custom blocks, env settings,",
- infoFont, Anchor.LeftOrTop, Anchor.Centre, middle - 85, -72 - 12 );
- MakeLabelAt( "&elonger messages, and more",
- infoFont, Anchor.LeftOrTop, Anchor.Centre, middle - 85, -72 + 12 );
-
- MakeButtonAt( "Classic", 145, 35, titleFont, Anchor.LeftOrTop, Anchor.Centre, middle - 250, 0,
- (x, y) => ModeClick( true, false ) );
- MakeLabelAt( "&eOnly uses blocks and features from",
- infoFont, Anchor.LeftOrTop, Anchor.Centre, middle - 85, 0 - 12 );
- MakeLabelAt( "ðe original minecraft classic",
- infoFont, Anchor.LeftOrTop, Anchor.Centre, middle - 85, 0 + 12 );
-
- MakeButtonAt( "Classic +hax", 145, 35, titleFont, Anchor.LeftOrTop, Anchor.Centre, middle - 250, 72,
- (x, y) => ModeClick( true, true ) );
- MakeLabelAt( "&eSame as Classic mode, except that",
- infoFont, Anchor.LeftOrTop, Anchor.Centre, middle - 85, 72 - 12 );
- MakeLabelAt( "&ehacks (noclip/fly/speed) are enabled",
- infoFont, Anchor.LeftOrTop, Anchor.Centre, middle - 85, 72 + 12 );
- MakeOtherWidgets();
- }
-
- protected virtual void MakeOtherWidgets() { }
-
void ModeClick( bool classic, bool classicHacks ) {
game.ClassicBackground = classic;
Options.Load();
@@ -113,29 +82,7 @@ namespace Launcher {
game.Window.Keyboard.KeyUp -= KeyUp;
game.Window.Mouse.Move -= MouseMove;
game.Window.Mouse.ButtonDown -= MouseButtonDown;
-
- titleFont.Dispose();
- infoFont.Dispose();
- }
- }
-
- public sealed class ChooseModeNormalScreen : ChooseModeScreen {
-
- public ChooseModeNormalScreen( LauncherWindow game ) : base( game ) { }
-
- protected override void MakeOtherWidgets() {
- MakeButtonAt( "Back", 80, 35, titleFont, Anchor.Centre,
- 0, 175, (x, y) => game.SetScreen( new MainScreen( game ) ) );
- }
- }
-
- public sealed class ChooseModeFirstTimeScreen : ChooseModeScreen {
-
- public ChooseModeFirstTimeScreen( LauncherWindow game ) : base( game ) { }
-
- protected override void MakeOtherWidgets() {
- MakeLabelAt( "&eClick &fNormal &eif you are unsure which mode to choose.",
- infoFont, Anchor.Centre, Anchor.Centre, 0, 160 );
+ view.Dispose();
}
}
}
diff --git a/Launcher2/Gui/Screens/ColoursScreen.cs b/Launcher2/Gui/Screens/ColoursScreen.cs
index fa674d3c4..f6bf13d8c 100644
--- a/Launcher2/Gui/Screens/ColoursScreen.cs
+++ b/Launcher2/Gui/Screens/ColoursScreen.cs
@@ -35,6 +35,11 @@ namespace Launcher {
Dirty = true;
}
+ public override void Dispose() {
+ view.Dispose();
+ base.Dispose();
+ }
+
protected override void MouseWheelChanged( object sender, MouseWheelEventArgs e ) {
AdjustSelectedColour( e.Delta );
}
diff --git a/Launcher2/Gui/Screens/MainScreen.cs b/Launcher2/Gui/Screens/MainScreen.cs
index ed16e9143..f99ff6a2f 100644
--- a/Launcher2/Gui/Screens/MainScreen.cs
+++ b/Launcher2/Gui/Screens/MainScreen.cs
@@ -83,7 +83,7 @@ namespace Launcher {
(x, y) => game.SetScreen( new UpdatesScreen( game ) ) );
MakeButtonAt( "Choose mode", 200, buttonHeight, buttonFont,
Anchor.Centre, Anchor.BottomOrRight, 0, -10,
- (x, y) => game.SetScreen( new ChooseModeNormalScreen( game ) ) );
+ (x, y) => game.SetScreen( new ChooseModeScreen( game, false ) ) );
MakeLabelAt( updateText, updateFont, Anchor.BottomOrRight,
Anchor.BottomOrRight, -10, -50 );
diff --git a/Launcher2/Gui/Screens/ResourcesScreen.cs b/Launcher2/Gui/Screens/ResourcesScreen.cs
index 242aa11da..a4c393811 100644
--- a/Launcher2/Gui/Screens/ResourcesScreen.cs
+++ b/Launcher2/Gui/Screens/ResourcesScreen.cs
@@ -146,7 +146,7 @@ namespace Launcher {
if( File.Exists( "options.txt" ) )
game.SetScreen( new MainScreen( game ) );
else
- game.SetScreen( new ChooseModeFirstTimeScreen( game ) );
+ game.SetScreen( new ChooseModeScreen( game, true ) );
}
void SetStatus( string text ) {
diff --git a/Launcher2/Gui/Views/ChooseModeView.cs b/Launcher2/Gui/Views/ChooseModeView.cs
new file mode 100644
index 000000000..ab3be4e5e
--- /dev/null
+++ b/Launcher2/Gui/Views/ChooseModeView.cs
@@ -0,0 +1,76 @@
+// ClassicalSharp copyright 2014-2016 UnknownShadow200 | Licensed under MIT
+using System;
+using System.Drawing;
+using System.IO;
+using ClassicalSharp;
+using Launcher.Updater;
+using OpenTK.Input;
+
+namespace Launcher {
+
+ public sealed class ChooseModeView : IView {
+
+ public bool FirstTime = true;
+ internal int backIndex = -1, nIndex, clIndex, clHaxIndex;
+
+ public ChooseModeView( LauncherWindow game ) : base( game ) {
+ widgets = new LauncherWidget[14];
+ }
+
+ public override void Init() {
+ titleFont = new Font( game.FontName, 16, FontStyle.Bold );
+ inputFont = new Font( game.FontName, 14, FontStyle.Regular );
+ UpdateWidgets();
+ }
+
+ public override void DrawAll() {
+ UpdateWidgets();
+ RedrawAllButtonBackgrounds();
+
+ using( drawer ) {
+ drawer.SetBitmap( game.Framebuffer );
+ RedrawAll();
+ FastColour col = LauncherSkin.ButtonBorderCol;
+ int middle = game.Height / 2;
+ game.Drawer.DrawRect( col, game.Width / 2 - 250, middle - 35, 490, 1 );
+ game.Drawer.DrawRect( col, game.Width / 2 - 250, middle + 35, 490, 1 );
+ }
+ }
+
+ void UpdateWidgets() {
+ widgetIndex = 0;
+ int middle = game.Width / 2;
+ MakeLabelAt( "&fChoose game mode", titleFont, Anchor.Centre, Anchor.Centre, 0, -135 );
+
+ nIndex = widgetIndex;
+ MakeButtonAt( "Normal", 145, 35, titleFont, Anchor.LeftOrTop, Anchor.Centre, middle - 250, -72 );
+ MakeLabelAt( "&eEnables custom blocks, env settings,",
+ inputFont, Anchor.LeftOrTop, Anchor.Centre, middle - 85, -72 - 12 );
+ MakeLabelAt( "&elonger messages, and more",
+ inputFont, Anchor.LeftOrTop, Anchor.Centre, middle - 85, -72 + 12 );
+
+ clIndex = widgetIndex;
+ MakeButtonAt( "Classic", 145, 35, titleFont, Anchor.LeftOrTop, Anchor.Centre, middle - 250, 0 );
+ MakeLabelAt( "&eOnly uses blocks and features from",
+ inputFont, Anchor.LeftOrTop, Anchor.Centre, middle - 85, 0 - 12 );
+ MakeLabelAt( "ðe original minecraft classic",
+ inputFont, Anchor.LeftOrTop, Anchor.Centre, middle - 85, 0 + 12 );
+
+ clHaxIndex = widgetIndex;
+ MakeButtonAt( "Classic +hax", 145, 35, titleFont, Anchor.LeftOrTop, Anchor.Centre, middle - 250, 72 );
+ MakeLabelAt( "&eSame as Classic mode, except that",
+ inputFont, Anchor.LeftOrTop, Anchor.Centre, middle - 85, 72 - 12 );
+ MakeLabelAt( "&ehacks (noclip/fly/speed) are enabled",
+ inputFont, Anchor.LeftOrTop, Anchor.Centre, middle - 85, 72 + 12 );
+
+ if( FirstTime ) {
+ backIndex = -1;
+ MakeLabelAt( "&eClick &fNormal &eif you are unsure which mode to choose.",
+ inputFont, Anchor.Centre, Anchor.Centre, 0, 160 );
+ } else {
+ backIndex = widgetIndex;
+ MakeButtonAt( "Back", 80, 35, titleFont, Anchor.Centre, 0, 175 );
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Launcher2/Gui/Views/ColoursView.cs b/Launcher2/Gui/Views/ColoursView.cs
index b32d7ddfc..adf046f82 100644
--- a/Launcher2/Gui/Views/ColoursView.cs
+++ b/Launcher2/Gui/Views/ColoursView.cs
@@ -25,7 +25,9 @@ namespace Launcher {
}
public override void Init() {
- base.Init();
+ titleFont = new Font( game.FontName, 15, FontStyle.Bold );
+ inputFont = new Font( game.FontName, 14, FontStyle.Regular );
+ inputHintFont = new Font( game.FontName, 12, FontStyle.Italic );
UpdateWidgets();
}
diff --git a/Launcher2/Gui/Views/IView.cs b/Launcher2/Gui/Views/IView.cs
index d88cf7cf5..83c096314 100644
--- a/Launcher2/Gui/Views/IView.cs
+++ b/Launcher2/Gui/Views/IView.cs
@@ -21,20 +21,16 @@ namespace Launcher {
}
/// Function called to setup the widgets and other data for this view.
- public virtual void Init() {
- titleFont = new Font( game.FontName, 15, FontStyle.Bold );
- inputFont = new Font( game.FontName, 14, FontStyle.Regular );
- inputHintFont = new Font( game.FontName, 12, FontStyle.Italic );
- }
+ public abstract void Init();
/// Function called to redraw all widgets in this view.
public abstract void DrawAll();
/// Cleans up all native resources held by this view.
public virtual void Dispose() {
- titleFont.Dispose();
- inputFont.Dispose();
- inputHintFont.Dispose();
+ if( titleFont != null ) titleFont.Dispose();
+ if( inputFont != null ) inputFont.Dispose();
+ if( inputHintFont != null ) inputHintFont.Dispose();
}
protected void RedrawAllButtonBackgrounds() {
diff --git a/Launcher2/Launcher2.csproj b/Launcher2/Launcher2.csproj
index 92f5b67eb..5b2fe8ea5 100644
--- a/Launcher2/Launcher2.csproj
+++ b/Launcher2/Launcher2.csproj
@@ -73,6 +73,7 @@
+