mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 19:45:23 -04:00
Separate ChooseModeScreen into ChooseModeScreen and ChooseModeView.
This commit is contained in:
parent
acc8823a01
commit
d0f88ab5e1
@ -8,22 +8,31 @@ using OpenTK.Input;
|
|||||||
|
|
||||||
namespace Launcher {
|
namespace Launcher {
|
||||||
|
|
||||||
public abstract class ChooseModeScreen : LauncherScreen {
|
public sealed class ChooseModeScreen : LauncherScreen {
|
||||||
|
|
||||||
protected Font titleFont, infoFont;
|
ChooseModeView view;
|
||||||
public ChooseModeScreen( LauncherWindow game ) : base( game ) {
|
public ChooseModeScreen( LauncherWindow game, bool firstTime ) : base( game ) {
|
||||||
game.Window.Mouse.Move += MouseMove;
|
game.Window.Mouse.Move += MouseMove;
|
||||||
game.Window.Mouse.ButtonDown += MouseButtonDown;
|
game.Window.Mouse.ButtonDown += MouseButtonDown;
|
||||||
|
|
||||||
titleFont = new Font( game.FontName, 16, FontStyle.Bold );
|
view = new ChooseModeView( game );
|
||||||
infoFont = new Font( game.FontName, 14, FontStyle.Regular );
|
view.FirstTime = firstTime;
|
||||||
buttonFont = titleFont;
|
widgets = view.widgets;
|
||||||
widgets = new LauncherWidget[14];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Init() {
|
public override void Init() {
|
||||||
game.Window.Keyboard.KeyDown += KeyDown;
|
game.Window.Keyboard.KeyDown += KeyDown;
|
||||||
game.Window.Keyboard.KeyUp += KeyUp;
|
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();
|
Resize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,50 +54,10 @@ namespace Launcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void Resize() {
|
public override void Resize() {
|
||||||
MakeWidgets();
|
view.DrawAll();
|
||||||
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 );
|
|
||||||
}
|
|
||||||
Dirty = true;
|
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 ) {
|
void ModeClick( bool classic, bool classicHacks ) {
|
||||||
game.ClassicBackground = classic;
|
game.ClassicBackground = classic;
|
||||||
Options.Load();
|
Options.Load();
|
||||||
@ -113,29 +82,7 @@ namespace Launcher {
|
|||||||
game.Window.Keyboard.KeyUp -= KeyUp;
|
game.Window.Keyboard.KeyUp -= KeyUp;
|
||||||
game.Window.Mouse.Move -= MouseMove;
|
game.Window.Mouse.Move -= MouseMove;
|
||||||
game.Window.Mouse.ButtonDown -= MouseButtonDown;
|
game.Window.Mouse.ButtonDown -= MouseButtonDown;
|
||||||
|
view.Dispose();
|
||||||
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 );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,11 @@ namespace Launcher {
|
|||||||
Dirty = true;
|
Dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Dispose() {
|
||||||
|
view.Dispose();
|
||||||
|
base.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
protected override void MouseWheelChanged( object sender, MouseWheelEventArgs e ) {
|
protected override void MouseWheelChanged( object sender, MouseWheelEventArgs e ) {
|
||||||
AdjustSelectedColour( e.Delta );
|
AdjustSelectedColour( e.Delta );
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ namespace Launcher {
|
|||||||
(x, y) => game.SetScreen( new UpdatesScreen( game ) ) );
|
(x, y) => game.SetScreen( new UpdatesScreen( game ) ) );
|
||||||
MakeButtonAt( "Choose mode", 200, buttonHeight, buttonFont,
|
MakeButtonAt( "Choose mode", 200, buttonHeight, buttonFont,
|
||||||
Anchor.Centre, Anchor.BottomOrRight, 0, -10,
|
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,
|
MakeLabelAt( updateText, updateFont, Anchor.BottomOrRight,
|
||||||
Anchor.BottomOrRight, -10, -50 );
|
Anchor.BottomOrRight, -10, -50 );
|
||||||
|
@ -146,7 +146,7 @@ namespace Launcher {
|
|||||||
if( File.Exists( "options.txt" ) )
|
if( File.Exists( "options.txt" ) )
|
||||||
game.SetScreen( new MainScreen( game ) );
|
game.SetScreen( new MainScreen( game ) );
|
||||||
else
|
else
|
||||||
game.SetScreen( new ChooseModeFirstTimeScreen( game ) );
|
game.SetScreen( new ChooseModeScreen( game, true ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetStatus( string text ) {
|
void SetStatus( string text ) {
|
||||||
|
76
Launcher2/Gui/Views/ChooseModeView.cs
Normal file
76
Launcher2/Gui/Views/ChooseModeView.cs
Normal file
@ -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 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -25,7 +25,9 @@ namespace Launcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void Init() {
|
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();
|
UpdateWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,20 +21,16 @@ namespace Launcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Function called to setup the widgets and other data for this view. </summary>
|
/// <summary> Function called to setup the widgets and other data for this view. </summary>
|
||||||
public virtual void Init() {
|
public abstract 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 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Function called to redraw all widgets in this view. </summary>
|
/// <summary> Function called to redraw all widgets in this view. </summary>
|
||||||
public abstract void DrawAll();
|
public abstract void DrawAll();
|
||||||
|
|
||||||
/// <summary> Cleans up all native resources held by this view. </summary>
|
/// <summary> Cleans up all native resources held by this view. </summary>
|
||||||
public virtual void Dispose() {
|
public virtual void Dispose() {
|
||||||
titleFont.Dispose();
|
if( titleFont != null ) titleFont.Dispose();
|
||||||
inputFont.Dispose();
|
if( inputFont != null ) inputFont.Dispose();
|
||||||
inputHintFont.Dispose();
|
if( inputHintFont != null ) inputHintFont.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void RedrawAllButtonBackgrounds() {
|
protected void RedrawAllButtonBackgrounds() {
|
||||||
|
@ -73,6 +73,7 @@
|
|||||||
<Compile Include="Gui\TableWidget\LauncherTableWidget.cs" />
|
<Compile Include="Gui\TableWidget\LauncherTableWidget.cs" />
|
||||||
<Compile Include="Gui\TableWidget\LauncherTableWidget.Drawing.cs" />
|
<Compile Include="Gui\TableWidget\LauncherTableWidget.Drawing.cs" />
|
||||||
<Compile Include="Gui\TableWidget\LauncherTableWidget.Input.cs" />
|
<Compile Include="Gui\TableWidget\LauncherTableWidget.Input.cs" />
|
||||||
|
<Compile Include="Gui\Views\ChooseModeView.cs" />
|
||||||
<Compile Include="Gui\Views\ColoursView.cs" />
|
<Compile Include="Gui\Views\ColoursView.cs" />
|
||||||
<Compile Include="Gui\Views\IView.cs" />
|
<Compile Include="Gui\Views\IView.cs" />
|
||||||
<Compile Include="Gui\Widgets\LauncherBooleanWidget.cs" />
|
<Compile Include="Gui\Widgets\LauncherBooleanWidget.cs" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user