Check CursorVisible in the game property instead of manually getting it beforehand. (Less error prone)

This commit is contained in:
UnknownShadow200 2016-03-31 16:33:36 +11:00
parent 1e19178b88
commit 27ff9d3e44
5 changed files with 15 additions and 15 deletions

View File

@ -246,7 +246,6 @@ namespace ClassicalSharp.Gui {
public override void Dispose() {
if( HandlesAllInput ) {
game.chatInInputBuffer = textInput.chatInputText.ToString();
if( game.CursorVisible )
game.CursorVisible = false;
} else {
game.chatInInputBuffer = null;
@ -316,7 +315,6 @@ namespace ClassicalSharp.Gui {
}
public void OpenTextInputBar( string initialText ) {
if( !game.CursorVisible )
game.CursorVisible = true;
suppressNextPress = true;
HandlesAllInput = true;
@ -339,7 +337,6 @@ 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.Camera.RegrabMouse();
game.Keyboard.KeyRepeat = false;

View File

@ -66,7 +66,6 @@ namespace ClassicalSharp.Gui {
}
public void GainFocus() {
if( game.CursorVisible )
game.CursorVisible = false;
game.Camera.RegrabMouse();
}
@ -74,7 +73,6 @@ namespace ClassicalSharp.Gui {
public void LoseFocus() {
if( playerList != null )
playerList.Dispose();
if( !game.CursorVisible )
game.CursorVisible = true;
}

View File

@ -69,7 +69,6 @@ namespace ClassicalSharp.Gui {
game.activeScreen = game.WarningScreens[0];
} else {
game.activeScreen = lastScreen;
if( game.CursorVisible != wasCursorVisible )
game.CursorVisible = wasCursorVisible;
if( game.activeScreen == null && game.CursorVisible )
game.CursorVisible = false;

View File

@ -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 {

View File

@ -399,7 +399,7 @@ namespace ClassicalSharp {
activeScreen = screen;
screen.wasCursorVisible = CursorVisible;
if( !CursorVisible ) CursorVisible = true;
CursorVisible = true;
} else {
screen.wasCursorVisible = WarningScreens[0].wasCursorVisible;
}