mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 19:45:23 -04:00
Make function keys reassignable, change view distance binding to default as F, make function keys only apply when a screen does not have input locked.
This commit is contained in:
parent
36d791e604
commit
d4a5bf9fff
@ -160,11 +160,14 @@ namespace ClassicalSharp {
|
|||||||
suppressNextPress = false;
|
suppressNextPress = false;
|
||||||
|
|
||||||
if( HandlesAllInput ) { // text input bar
|
if( HandlesAllInput ) { // text input bar
|
||||||
if( key == game.Keys[KeyMapping.SendChat] ) {
|
if( key == game.Keys[KeyMapping.SendChat] || key == game.Keys[KeyMapping.PauseOrExit] ) {
|
||||||
HandlesAllInput = false;
|
HandlesAllInput = false;
|
||||||
if( game.CursorVisible )
|
if( game.CursorVisible )
|
||||||
game.CursorVisible = false;
|
game.CursorVisible = false;
|
||||||
game.Camera.RegrabMouse();
|
game.Camera.RegrabMouse();
|
||||||
|
|
||||||
|
if( key == game.Keys[KeyMapping.PauseOrExit] )
|
||||||
|
textInput.chatInputText.Clear();
|
||||||
textInput.SendTextInBufferAndReset();
|
textInput.SendTextInBufferAndReset();
|
||||||
} else if( key == Key.PageUp ) {
|
} else if( key == Key.PageUp ) {
|
||||||
chatIndex -= chatLines;
|
chatIndex -= chatLines;
|
||||||
@ -177,6 +180,8 @@ namespace ClassicalSharp {
|
|||||||
if( chatIndex > game.ChatLog.Count - chatLines )
|
if( chatIndex > game.ChatLog.Count - chatLines )
|
||||||
chatIndex = game.ChatLog.Count - chatLines;
|
chatIndex = game.ChatLog.Count - chatLines;
|
||||||
ResetChat();
|
ResetChat();
|
||||||
|
} else if( key == game.Keys[KeyMapping.HideGui] ) {
|
||||||
|
game.HideGui = !game.HideGui;
|
||||||
} else {
|
} else {
|
||||||
textInput.HandlesKeyDown( key );
|
textInput.HandlesKeyDown( key );
|
||||||
}
|
}
|
||||||
@ -197,7 +202,7 @@ namespace ClassicalSharp {
|
|||||||
if( !HandlesAllInput ) return false;
|
if( !HandlesAllInput ) return false;
|
||||||
chatIndex += -delta;
|
chatIndex += -delta;
|
||||||
int maxIndex = game.ChatLog.Count - chatLines;
|
int maxIndex = game.ChatLog.Count - chatLines;
|
||||||
int minIndex = Math.Min( 0, maxIndex );
|
int minIndex = Math.Min( 0, maxIndex );
|
||||||
Utils.Clamp( ref chatIndex, minIndex, maxIndex );
|
Utils.Clamp( ref chatIndex, minIndex, maxIndex );
|
||||||
ResetChat();
|
ResetChat();
|
||||||
return true;
|
return true;
|
||||||
|
@ -175,7 +175,7 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
void SetWidgetToChange( KeyMapWidget widget ) {
|
void SetWidgetToChange( KeyMapWidget widget ) {
|
||||||
Key oldKey = game.Keys[widget.Mapping];
|
Key oldKey = game.Keys[widget.Mapping];
|
||||||
if( !game.Keys.IsLockedKey( oldKey ) ) {
|
if( oldKey != Key.Escape ) {
|
||||||
const string format = "&ePress new key for \"{0}\".";
|
const string format = "&ePress new key for \"{0}\".";
|
||||||
keyStatusWidget.SetText( String.Format( format, widget.Description ) );
|
keyStatusWidget.SetText( String.Format( format, widget.Description ) );
|
||||||
widgetToChange = widget;
|
widgetToChange = widget;
|
||||||
|
@ -90,7 +90,15 @@ namespace ClassicalSharp {
|
|||||||
Key key = e.Key;
|
Key key = e.Key;
|
||||||
if( key == Key.F4 && ( IsKeyDown( Key.AltLeft ) || IsKeyDown( Key.AltRight ) ) ) {
|
if( key == Key.F4 && ( IsKeyDown( Key.AltLeft ) || IsKeyDown( Key.AltRight ) ) ) {
|
||||||
Exit();
|
Exit();
|
||||||
} else if( key == Keys[KeyMapping.HideGui] ) {
|
} else if( activeScreen == null || !activeScreen.HandlesKeyDown( key ) ) {
|
||||||
|
if( !HandleBuiltinKey( key ) ) {
|
||||||
|
LocalPlayer.HandleKeyDown( key );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HandleBuiltinKey( Key key ) {
|
||||||
|
if( key == Keys[KeyMapping.HideGui] ) {
|
||||||
HideGui = !HideGui;
|
HideGui = !HideGui;
|
||||||
} else if( key == Keys[KeyMapping.Screenshot] ) {
|
} else if( key == Keys[KeyMapping.Screenshot] ) {
|
||||||
screenshotRequested = true;
|
screenshotRequested = true;
|
||||||
@ -110,7 +118,7 @@ namespace ClassicalSharp {
|
|||||||
int newDist = viewDistances[i];
|
int newDist = viewDistances[i];
|
||||||
if( newDist > ViewDistance ) {
|
if( newDist > ViewDistance ) {
|
||||||
SetViewDistance( newDist );
|
SetViewDistance( newDist );
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SetViewDistance( viewDistances[0] );
|
SetViewDistance( viewDistances[0] );
|
||||||
@ -120,13 +128,12 @@ namespace ClassicalSharp {
|
|||||||
} else {
|
} else {
|
||||||
SetNewScreen( new NormalScreen( this ) );
|
SetNewScreen( new NormalScreen( this ) );
|
||||||
}
|
}
|
||||||
} else if( activeScreen == null || !activeScreen.HandlesKeyDown( key ) ) {
|
} else if( key == Keys[KeyMapping.OpenInventory] ) {
|
||||||
if( key == Keys[KeyMapping.OpenInventory] ) {
|
SetNewScreen( new BlockSelectScreen( this ) );
|
||||||
SetNewScreen( new BlockSelectScreen( this ) );
|
} else {
|
||||||
} else {
|
return false;
|
||||||
LocalPlayer.HandleKeyDown( key );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DateTime lastClick = DateTime.MinValue;
|
DateTime lastClick = DateTime.MinValue;
|
||||||
@ -205,16 +212,12 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
Key[] Keys;
|
Key[] Keys;
|
||||||
bool IsReservedKey( Key key ) {
|
bool IsReservedKey( Key key ) {
|
||||||
return IsLockedKey( key ) || key == Key.Slash || key == Key.BackSpace ||
|
return key == Key.Escape || key == Key.Slash || key == Key.BackSpace ||
|
||||||
( key >= Key.Insert && key <= Key.End ) ||
|
( key >= Key.Insert && key <= Key.End ) ||
|
||||||
( key >= Key.Up && key <= Key.Right ) || // chat screen movement
|
( key >= Key.Up && key <= Key.Right ) || // chat screen movement
|
||||||
( key >= Key.Number0 && key <= Key.Number9 ); // block hotbar
|
( key >= Key.Number0 && key <= Key.Number9 ); // block hotbar
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsLockedKey( Key key ) {
|
|
||||||
return key == Key.Escape || ( key >= Key.F1 && key <= Key.F35 );
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsKeyOkay( Key key, out string reason ) {
|
public bool IsKeyOkay( Key key, out string reason ) {
|
||||||
if( IsReservedKey( key ) ) {
|
if( IsReservedKey( key ) ) {
|
||||||
reason = "Given key is reserved for gui";
|
reason = "Given key is reserved for gui";
|
||||||
@ -236,7 +239,7 @@ namespace ClassicalSharp {
|
|||||||
Keys = new Key[] {
|
Keys = new Key[] {
|
||||||
Key.W, Key.S, Key.A, Key.D, Key.Space, Key.R, Key.Y, Key.T,
|
Key.W, Key.S, Key.A, Key.D, Key.Space, Key.R, Key.Y, Key.T,
|
||||||
Key.Enter, Key.Escape, Key.B, Key.F12, Key.F11, Key.F7,
|
Key.Enter, Key.Escape, Key.B, Key.F12, Key.F11, Key.F7,
|
||||||
Key.F5, Key.F6, Key.Z, Key.ShiftLeft, Key.X, Key.Q,
|
Key.F5, Key.F, Key.Z, Key.ShiftLeft, Key.X, Key.Q,
|
||||||
Key.E, Key.Tab, Key.F1 };
|
Key.E, Key.Tab, Key.F1 };
|
||||||
#else
|
#else
|
||||||
Keys = new Key[23];
|
Keys = new Key[23];
|
||||||
@ -244,7 +247,7 @@ namespace ClassicalSharp {
|
|||||||
Keys[4] = Key.Space; Keys[5] = Key.R; Keys[6] = Key.Y; Keys[7] = Key.T;
|
Keys[4] = Key.Space; Keys[5] = Key.R; Keys[6] = Key.Y; Keys[7] = Key.T;
|
||||||
Keys[8] = Key.Enter; Keys[9] = Key.Escape; Keys[10] = Key.B;
|
Keys[8] = Key.Enter; Keys[9] = Key.Escape; Keys[10] = Key.B;
|
||||||
Keys[11] = Key.F12; Keys[12] = Key.F11; Keys[13] = Key.F7;
|
Keys[11] = Key.F12; Keys[12] = Key.F11; Keys[13] = Key.F7;
|
||||||
Keys[14] = Key.F5; Keys[15] = Key.F6; Keys[16] = Key.Z;
|
Keys[14] = Key.F5; Keys[15] = Key.F; Keys[16] = Key.Z;
|
||||||
Keys[17] = Key.ShiftLeft; Keys[18] = Key.X; Keys[19] = Key.Q;
|
Keys[17] = Key.ShiftLeft; Keys[18] = Key.X; Keys[19] = Key.Q;
|
||||||
Keys[20] = Key.E; Keys[21] = Key.Tab; Keys[22] = Key.F1;
|
Keys[20] = Key.E; Keys[21] = Key.Tab; Keys[22] = Key.F1;
|
||||||
#endif
|
#endif
|
||||||
|
@ -17,15 +17,6 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
|
|
||||||
public abstract bool Texturing { set; }
|
public abstract bool Texturing { set; }
|
||||||
|
|
||||||
public int CreateTexture( string path ) {
|
|
||||||
if( !File.Exists( path ) ) {
|
|
||||||
throw new FileNotFoundException( path + " not found" );
|
|
||||||
}
|
|
||||||
using( Bitmap bmp = new Bitmap( path ) ) {
|
|
||||||
return CreateTexture( bmp );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int CreateTexture( Bitmap bmp ) {
|
public int CreateTexture( Bitmap bmp ) {
|
||||||
Rectangle rec = new Rectangle( 0, 0, bmp.Width, bmp.Height );
|
Rectangle rec = new Rectangle( 0, 0, bmp.Width, bmp.Height );
|
||||||
BitmapData data = bmp.LockBits( rec, ImageLockMode.ReadOnly, bmp.PixelFormat );
|
BitmapData data = bmp.LockBits( rec, ImageLockMode.ReadOnly, bmp.PixelFormat );
|
||||||
|
@ -9,6 +9,7 @@ using System.IO.Compression;
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using ClassicalSharp.Network;
|
using ClassicalSharp.Network;
|
||||||
|
using ClassicalSharp.TexturePack;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
|
|
||||||
@ -602,8 +603,8 @@ namespace ClassicalSharp {
|
|||||||
game.Map.SetEdgeBlock( (Block)edgeBlock );
|
game.Map.SetEdgeBlock( (Block)edgeBlock );
|
||||||
game.Map.SetSidesBlock( (Block)sideBlock );
|
game.Map.SetSidesBlock( (Block)sideBlock );
|
||||||
if( url == String.Empty ) {
|
if( url == String.Empty ) {
|
||||||
Bitmap bmp = new Bitmap( "terrain.png" );
|
TexturePackExtractor extractor = new TexturePackExtractor();
|
||||||
game.ChangeTerrainAtlas( bmp );
|
extractor.Extract( game.defaultTexPack, game );
|
||||||
} else {
|
} else {
|
||||||
game.AsyncDownloader.DownloadImage( url, true, "terrain" );
|
game.AsyncDownloader.DownloadImage( url, true, "terrain" );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user