fullscreen button works now

This commit is contained in:
Linus Vogel 2025-12-09 20:37:16 +01:00
parent 4f6832b658
commit d933b16d3d
2 changed files with 14 additions and 6 deletions

View File

@ -25,6 +25,7 @@ public partial class Controller : Window
this._btnScreen = this.GetNode<Button>("BtnScreen");
this._btnClose = this.GetNode<Button>("BtnClose");
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
@ -60,9 +61,13 @@ public partial class Controller : Window
if (this._btnScreen.IsPressed() && this._screenReady)
{
this.GetTree().GetRoot().GetNode<MainScript>("Main").SetFullScreen();
MainScript windowScript = (MainScript)this.GetTree().GetRoot().GetNode<MainScript>("Main");
windowScript.SetFullScreen();
this._screenReady = false;
}
else this._screenReady = true;
else if (!this._btnScreen.IsPressed() && !this._screenReady)
{
this._screenReady = true;
}
}
}

View File

@ -17,8 +17,11 @@ public partial class MainScript : Node2D
public void SetFullScreen()
{
Window window = this.GetTree().GetRoot().GetNode<Window>("Main.Projection");
Window window = GetNode<Window>("Projection");
GD.Print("Window: ", window);
window.SetCurrentScreen(1);
window.Borderless = true;
window.SetSize(new Vector2I(1920, 1080));
DisplayServer.WindowSetMode(DisplayServer.WindowMode.ExclusiveFullscreen, window.GetWindowId());
}
}