mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 12:05:14 -04:00
Check CursorVisible in the game property instead of manually getting it beforehand. (Less error prone)
This commit is contained in:
parent
1e19178b88
commit
27ff9d3e44
@ -246,8 +246,7 @@ namespace ClassicalSharp.Gui {
|
||||
public override void Dispose() {
|
||||
if( HandlesAllInput ) {
|
||||
game.chatInInputBuffer = textInput.chatInputText.ToString();
|
||||
if( game.CursorVisible )
|
||||
game.CursorVisible = false;
|
||||
game.CursorVisible = false;
|
||||
} else {
|
||||
game.chatInInputBuffer = null;
|
||||
}
|
||||
@ -316,8 +315,7 @@ namespace ClassicalSharp.Gui {
|
||||
}
|
||||
|
||||
public void OpenTextInputBar( string initialText ) {
|
||||
if( !game.CursorVisible )
|
||||
game.CursorVisible = true;
|
||||
game.CursorVisible = true;
|
||||
suppressNextPress = true;
|
||||
HandlesAllInput = true;
|
||||
game.Keyboard.KeyRepeat = true;
|
||||
@ -339,8 +337,7 @@ namespace ClassicalSharp.Gui {
|
||||
if( key == game.Mapping( KeyBinding.SendChat ) || key == Key.KeypadEnter
|
||||
|| key == game.Mapping( KeyBinding.PauseOrExit ) ) {
|
||||
HandlesAllInput = false;
|
||||
if( game.CursorVisible )
|
||||
game.CursorVisible = false;
|
||||
game.CursorVisible = false;
|
||||
game.Camera.RegrabMouse();
|
||||
game.Keyboard.KeyRepeat = false;
|
||||
|
||||
|
@ -66,16 +66,14 @@ namespace ClassicalSharp.Gui {
|
||||
}
|
||||
|
||||
public void GainFocus() {
|
||||
if( game.CursorVisible )
|
||||
game.CursorVisible = false;
|
||||
game.CursorVisible = false;
|
||||
game.Camera.RegrabMouse();
|
||||
}
|
||||
|
||||
public void LoseFocus() {
|
||||
if( playerList != null )
|
||||
playerList.Dispose();
|
||||
if( !game.CursorVisible )
|
||||
game.CursorVisible = true;
|
||||
game.CursorVisible = true;
|
||||
}
|
||||
|
||||
public override void OnResize( int oldWidth, int oldHeight, int width, int height ) {
|
||||
|
@ -69,8 +69,7 @@ namespace ClassicalSharp.Gui {
|
||||
game.activeScreen = game.WarningScreens[0];
|
||||
} else {
|
||||
game.activeScreen = lastScreen;
|
||||
if( game.CursorVisible != wasCursorVisible )
|
||||
game.CursorVisible = wasCursorVisible;
|
||||
game.CursorVisible = wasCursorVisible;
|
||||
if( game.activeScreen == null && game.CursorVisible )
|
||||
game.CursorVisible = false;
|
||||
}
|
||||
|
@ -213,9 +213,15 @@ namespace ClassicalSharp {
|
||||
set { window.VSync = value; }
|
||||
}
|
||||
|
||||
bool visible = true;
|
||||
public bool CursorVisible {
|
||||
get { return window.CursorVisible; }
|
||||
set { window.CursorVisible = value; }
|
||||
get { return visible; }
|
||||
set {
|
||||
// Only set the value when it has changes.
|
||||
if( visible == value ) return;
|
||||
window.CursorVisible = value;
|
||||
visible = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Point DesktopCursorPos {
|
||||
|
@ -399,7 +399,7 @@ namespace ClassicalSharp {
|
||||
activeScreen = screen;
|
||||
|
||||
screen.wasCursorVisible = CursorVisible;
|
||||
if( !CursorVisible ) CursorVisible = true;
|
||||
CursorVisible = true;
|
||||
} else {
|
||||
screen.wasCursorVisible = WarningScreens[0].wasCursorVisible;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user