simple button behaviour
This commit is contained in:
parent
f59723e43f
commit
4f6832b658
@ -3,10 +3,27 @@ using System;
|
|||||||
|
|
||||||
public partial class Controller : Window
|
public partial class Controller : Window
|
||||||
{
|
{
|
||||||
|
private double _closeTime = 0;
|
||||||
|
private bool _screenReady = true;
|
||||||
|
|
||||||
|
private Button _btnScene1;
|
||||||
|
private Button _btnScene2;
|
||||||
|
private Button _btnScene3;
|
||||||
|
private Button _btnScene4;
|
||||||
|
private Button _btnScreen;
|
||||||
|
private Button _btnClose;
|
||||||
|
|
||||||
|
|
||||||
// Called when the node enters the scene tree for the first time.
|
// Called when the node enters the scene tree for the first time.
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
|
this._btnScene1 = this.GetNode<Button>("BtnScene1");
|
||||||
|
this._btnScene2 = this.GetNode<Button>("BtnScene2");
|
||||||
|
this._btnScene3 = this.GetNode<Button>("BtnScene3");
|
||||||
|
this._btnScene4 = this.GetNode<Button>("BtnScene4");
|
||||||
|
|
||||||
|
this._btnScreen = this.GetNode<Button>("BtnScreen");
|
||||||
|
this._btnClose = this.GetNode<Button>("BtnClose");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,27 +34,35 @@ public partial class Controller : Window
|
|||||||
Vector2 rasterSize = this.Size / 4;
|
Vector2 rasterSize = this.Size / 4;
|
||||||
Vector2 btnSize = rasterSize - 2 * border;
|
Vector2 btnSize = rasterSize - 2 * border;
|
||||||
|
|
||||||
Button btnScene1 = this.GetNode<Button>("BtnScene1");
|
this._btnScene1.Position = border + (new Vector2(0, 0)*rasterSize);
|
||||||
Button btnScene2 = this.GetNode<Button>("BtnScene2");
|
this._btnScene2.Position = border + (new Vector2(1, 0)*rasterSize);
|
||||||
Button btnScene3 = this.GetNode<Button>("BtnScene3");
|
this._btnScene3.Position = border + (new Vector2(2, 0)*rasterSize);
|
||||||
Button btnScene4 = this.GetNode<Button>("BtnScene4");
|
this._btnScene4.Position = border + (new Vector2(3, 0)*rasterSize);
|
||||||
|
this._btnScene1.Size = btnSize;
|
||||||
|
this._btnScene2.Size = btnSize;
|
||||||
|
this._btnScene3.Size = btnSize;
|
||||||
|
this._btnScene4.Size = btnSize;
|
||||||
|
|
||||||
|
this._btnScreen.Size = btnSize;
|
||||||
|
this._btnScreen.Position = border + (new Vector2(3, 3)*rasterSize);
|
||||||
|
|
||||||
|
this._btnClose.Size = btnSize * new Vector2(3, 1) + border * new Vector2(4, 0);
|
||||||
|
this._btnClose.Position = border + (new Vector2(0, 3)*rasterSize);
|
||||||
|
|
||||||
|
// handle close button
|
||||||
|
if (this._btnClose.IsPressed())
|
||||||
|
this._closeTime += delta;
|
||||||
|
else
|
||||||
|
this._closeTime = 0;
|
||||||
|
|
||||||
Button btnScreen = this.GetNode<Button>("BtnScreen");
|
this._btnClose.AddThemeColorOverride("font_pressed_color", new Color((float)this._closeTime, 0, 0));
|
||||||
Button btnClose = this.GetNode<Button>("BtnClose");
|
if (this._closeTime > 1) this.GetTree().Quit();
|
||||||
|
|
||||||
btnScene1.Position = border + (new Vector2(0, 0)*rasterSize);
|
if (this._btnScreen.IsPressed() && this._screenReady)
|
||||||
btnScene2.Position = border + (new Vector2(1, 0)*rasterSize);
|
{
|
||||||
btnScene3.Position = border + (new Vector2(2, 0)*rasterSize);
|
this.GetTree().GetRoot().GetNode<MainScript>("Main").SetFullScreen();
|
||||||
btnScene4.Position = border + (new Vector2(3, 0)*rasterSize);
|
this._screenReady = false;
|
||||||
btnScene1.Size = btnSize;
|
}
|
||||||
btnScene2.Size = btnSize;
|
else this._screenReady = true;
|
||||||
btnScene3.Size = btnSize;
|
|
||||||
btnScene4.Size = btnSize;
|
|
||||||
|
|
||||||
btnScreen.Size = btnSize;
|
|
||||||
btnScreen.Position = border + (new Vector2(3, 3)*rasterSize);
|
|
||||||
|
|
||||||
btnClose.Size = btnSize * new Vector2(3, 1) + border * new Vector2(4, 0);
|
|
||||||
btnClose.Position = border + (new Vector2(0, 3)*rasterSize);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public partial class Main : Node2D
|
public partial class MainScript : Node2D
|
||||||
{
|
{
|
||||||
|
|
||||||
// Called when the node enters the scene tree for the first time.
|
// Called when the node enters the scene tree for the first time.
|
||||||
@ -13,4 +13,12 @@ public partial class Main : Node2D
|
|||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void SetFullScreen()
|
||||||
|
{
|
||||||
|
Window window = this.GetTree().GetRoot().GetNode<Window>("Main.Projection");
|
||||||
|
window.SetCurrentScreen(1);
|
||||||
|
window.Borderless = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -11,6 +11,6 @@ public partial class Projection : Window
|
|||||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
GD.Print("Projection process");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
[ext_resource type="Script" uid="uid://dg0qtnm4epowu" path="res://Controller.cs" id="1_wtcfe"]
|
[ext_resource type="Script" uid="uid://dg0qtnm4epowu" path="res://Controller.cs" id="1_wtcfe"]
|
||||||
[ext_resource type="Script" uid="uid://criv4i3x63akl" path="res://Projection.cs" id="2_0e48y"]
|
[ext_resource type="Script" uid="uid://criv4i3x63akl" path="res://Projection.cs" id="2_0e48y"]
|
||||||
|
|
||||||
[node name="Node2D" type="Node2D"]
|
[node name="Main" type="Node2D"]
|
||||||
script = ExtResource("1_0e48y")
|
script = ExtResource("1_0e48y")
|
||||||
|
|
||||||
[node name="Controller" type="Window" parent="."]
|
[node name="Controller" type="Window" parent="."]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user