From 6478ddb987b434096a98c42db3cbfecc2bc4b7c5 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 31 Dec 2015 23:15:40 +1100 Subject: [PATCH] Allow using scroll wheel in 'colour scheme' in launcher, other minor touchups. --- ClassicalSharp/2D/Screens/ErrorScreen.cs | 2 +- ClassicalSharp/2D/Screens/HotkeyScreen.cs | 16 ++++++++-------- .../2D/Screens/Menu/MenuInputScreen.cs | 2 +- ClassicalSharp/Game/Game.cs | 2 +- ClassicalSharp/Particles/ParticleManager.cs | 6 +++--- .../Gui/Screens/ClassiCubeServersScreen.cs | 4 +--- Launcher2/Gui/Screens/ColoursScreen.cs | 18 ++++++++++++++++++ Launcher2/Gui/Screens/LauncherInputScreen.cs | 5 +++++ 8 files changed, 38 insertions(+), 17 deletions(-) diff --git a/ClassicalSharp/2D/Screens/ErrorScreen.cs b/ClassicalSharp/2D/Screens/ErrorScreen.cs index 115b94df0..f385cb01c 100644 --- a/ClassicalSharp/2D/Screens/ErrorScreen.cs +++ b/ClassicalSharp/2D/Screens/ErrorScreen.cs @@ -54,7 +54,7 @@ namespace ClassicalSharp { void ReconnectClick( Game g, Widget w ) { string connectString = "Connecting to " + game.IPAddress + ":" + game.Port + ".."; - game.SetNewScreen( new LoadingMapScreen( game, connectString, "Reticulating splines" ) ); + game.SetNewScreen( new LoadingMapScreen( game, connectString, "Waiting for handshake" ) ); game.Network.Connect( game.IPAddress, game.Port ); } diff --git a/ClassicalSharp/2D/Screens/HotkeyScreen.cs b/ClassicalSharp/2D/Screens/HotkeyScreen.cs index ce701be9a..9dcb4f4b0 100644 --- a/ClassicalSharp/2D/Screens/HotkeyScreen.cs +++ b/ClassicalSharp/2D/Screens/HotkeyScreen.cs @@ -187,16 +187,16 @@ namespace ClassicalSharp { void CreateEditingWidgets() { DisposeEditingWidgets(); - buttons[8] = Make( -140, 60, "Key: " + curHotkey.BaseKey, - 250, 30, textFont, BaseKeyClick ); - buttons[9] = Make( 140, 60, "Modifiers: " + MakeFlagsString( curHotkey.Flags ), - 250, 30, textFont, ModifiersClick ); + buttons[8] = Make( -140, 55, "Key: " + curHotkey.BaseKey, + 250, 35, textFont, BaseKeyClick ); + buttons[9] = Make( 140, 55, "Modifiers: " + MakeFlagsString( curHotkey.Flags ), + 250, 35, textFont, ModifiersClick ); buttons[10] = Make( -10, 120, curHotkey.MoreInput ? "yes" : "no", 50, 25, textFont, LeaveOpenClick ); - buttons[11] = Make( -100, 160, "Save changes", - 160, 30, textFont, SaveChangesClick ); - buttons[12] = Make( 100, 160, "Remove hotkey", - 160, 30, textFont, RemoveHotkeyClick ); + buttons[11] = Make( -120, 160, "Save changes", + 180, 35, textFont, SaveChangesClick ); + buttons[12] = Make( 120, 160, "Remove hotkey", + 180, 35, textFont, RemoveHotkeyClick ); currentAction = MenuInputWidget.Create( game, 0, 90, 600, 25, "", Anchor.Centre, Anchor.Centre, diff --git a/ClassicalSharp/2D/Screens/Menu/MenuInputScreen.cs b/ClassicalSharp/2D/Screens/Menu/MenuInputScreen.cs index 1a63f12fb..0490cecd4 100644 --- a/ClassicalSharp/2D/Screens/Menu/MenuInputScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/MenuInputScreen.cs @@ -125,7 +125,7 @@ namespace ClassicalSharp { targetWidget = selectedWidget; inputWidget = MenuInputWidget.Create( game, 0, 150, 400, 25, button.GetValue( game ), Anchor.Centre, Anchor.Centre, regularFont, titleFont, validator ); - buttons[okayIndex] = ButtonWidget.Create( game, 240, 150, 30, 30, "OK", + buttons[okayIndex] = ButtonWidget.Create( game, 240, 150, 40, 30, "OK", Anchor.Centre, Anchor.Centre, titleFont, OnWidgetClick ); InputOpened(); UpdateDescription( targetWidget ); diff --git a/ClassicalSharp/Game/Game.cs b/ClassicalSharp/Game/Game.cs index 40f825494..e14b84645 100644 --- a/ClassicalSharp/Game/Game.cs +++ b/ClassicalSharp/Game/Game.cs @@ -131,7 +131,7 @@ namespace ClassicalSharp { LoadIcon(); string connectString = "Connecting to " + IPAddress + ":" + Port + ".."; Graphics.WarnIfNecessary( Chat ); - SetNewScreen( new LoadingMapScreen( this, connectString, "Reticulating splines" ) ); + SetNewScreen( new LoadingMapScreen( this, connectString, "Waiting for handshake" ) ); Network.Connect( IPAddress, Port ); } diff --git a/ClassicalSharp/Particles/ParticleManager.cs b/ClassicalSharp/Particles/ParticleManager.cs index 5483f6eb6..b3ecf3478 100644 --- a/ClassicalSharp/Particles/ParticleManager.cs +++ b/ClassicalSharp/Particles/ParticleManager.cs @@ -88,12 +88,12 @@ namespace ClassicalSharp.Particles { Vector3 maxBB = game.BlockInfo.MaxBB[block]; int minU = Math.Min( (int)(minBB.X * 16), (int)(minBB.Z * 16) ); int maxU = Math.Min( (int)(maxBB.X * 16), (int)(maxBB.Z * 16) ); - int minV = (int)(minBB.Y * 16), maxV = (int)(maxBB.Y * 16); + int minV = (int)(16 - maxBB.Y * 16), maxV = (int)(16 - minBB.Y * 16); // This way we can avoid creating particles which outside the bounds and need to be clamped if( minU < 13 && maxU > 13 ) maxU = 13; if( minV < 13 && maxV > 13 ) maxV = 13; - for( int i = 0; i < 25; i++ ) { + for( int i = 0; i < 30; i++ ) { double velX = rnd.NextDouble() * 0.8 - 0.4; // [-0.4, 0.4] double velZ = rnd.NextDouble() * 0.8 - 0.4; double velY = rnd.NextDouble() + 0.2; @@ -110,7 +110,7 @@ namespace ClassicalSharp.Particles { rec.V1 = baseRec.V1 + rnd.Next( minV, maxV ) * uvScale; rec.U2 = Math.Min( baseRec.U1 + maxU * uvScale, rec.U1 + elemSize ); rec.V2 = Math.Min( baseRec.V1 + maxV * uvScale, rec.V1 + elemSize ); - double life = 1.5 - rnd.NextDouble(); + double life = 0.3 + rnd.NextDouble() * 0.7; TerrainParticle p = AddParticle( terrainParticles, ref terrainCount, false ); p.ResetState( pos, velocity, life ); diff --git a/Launcher2/Gui/Screens/ClassiCubeServersScreen.cs b/Launcher2/Gui/Screens/ClassiCubeServersScreen.cs index 366671526..659f82e22 100644 --- a/Launcher2/Gui/Screens/ClassiCubeServersScreen.cs +++ b/Launcher2/Gui/Screens/ClassiCubeServersScreen.cs @@ -75,7 +75,6 @@ namespace Launcher2 { public override void Init() { base.Init(); - game.Window.Mouse.WheelChanged += MouseWheelChanged; game.Window.Mouse.ButtonUp += MouseButtonUp; Resize(); @@ -159,7 +158,7 @@ namespace Launcher2 { game.ConnectToServer( table.servers, Get( hashIndex ) ); } - void MouseWheelChanged( object sender, MouseWheelEventArgs e ) { + protected override void MouseWheelChanged( object sender, MouseWheelEventArgs e ) { LauncherTableWidget table = (LauncherTableWidget)widgets[tableIndex]; table.CurrentIndex -= e.Delta; table.ClampIndex(); @@ -183,7 +182,6 @@ namespace Launcher2 { public override void Dispose() { base.Dispose(); tableFont.Dispose(); - game.Window.Mouse.WheelChanged -= MouseWheelChanged; LauncherTableWidget table = widgets[tableIndex] as LauncherTableWidget; if( table != null ) { diff --git a/Launcher2/Gui/Screens/ColoursScreen.cs b/Launcher2/Gui/Screens/ColoursScreen.cs index 2c453f0ad..a47e93cbd 100644 --- a/Launcher2/Gui/Screens/ColoursScreen.cs +++ b/Launcher2/Gui/Screens/ColoursScreen.cs @@ -1,6 +1,7 @@ using System; using System.Drawing; using ClassicalSharp; +using OpenTK.Input; namespace Launcher2 { @@ -53,6 +54,23 @@ namespace Launcher2 { } } + protected override void MouseWheelChanged( object sender, MouseWheelEventArgs e ) { + if( lastInput == null ) return; + int index = Array.IndexOf( widgets, lastInput ); + if( index >= 15 ) return; + + byte col; + if( !Byte.TryParse( lastInput.Text, out col ) ) + return; + int newCol = col + e.Delta; + + Utils.Clamp( ref newCol, 0, 255 ); + lastInput.Text = newCol.ToString(); + if( lastInput.CaretPos >= lastInput.Text.Length ) + lastInput.CaretPos = -1; + TextChanged( lastInput ); + } + void MakeAllRGBTriplets( bool force ) { MakeRGBTriplet( LauncherSkin.BackgroundCol, force, -100 ); MakeRGBTriplet( LauncherSkin.ButtonBorderCol, force, -60 ); diff --git a/Launcher2/Gui/Screens/LauncherInputScreen.cs b/Launcher2/Gui/Screens/LauncherInputScreen.cs index fd721d133..96c744e3a 100644 --- a/Launcher2/Gui/Screens/LauncherInputScreen.cs +++ b/Launcher2/Gui/Screens/LauncherInputScreen.cs @@ -21,6 +21,7 @@ namespace Launcher2 { buttonFont = titleFont; game.Window.Mouse.Move += MouseMove; game.Window.Mouse.ButtonDown += MouseButtonDown; + game.Window.Mouse.WheelChanged += MouseWheelChanged; game.Window.KeyPress += KeyPress; game.Window.Keyboard.KeyDown += KeyDown; @@ -138,6 +139,9 @@ namespace Launcher2 { .Redraw( drawer, text, inputFont, inputHintFont ); } + protected virtual void MouseWheelChanged( object sender, MouseWheelEventArgs e ) { + } + protected LauncherInputWidget lastInput; protected virtual void InputClick( int mouseX, int mouseY ) { LauncherInputWidget input = (LauncherInputWidget)selectedWidget; @@ -197,6 +201,7 @@ namespace Launcher2 { public override void Dispose() { game.Window.Mouse.Move -= MouseMove; game.Window.Mouse.ButtonDown -= MouseButtonDown; + game.Window.Mouse.WheelChanged -= MouseWheelChanged; game.Window.KeyPress -= KeyPress; game.Window.Keyboard.KeyDown -= KeyDown;