refactored setup code, working on right bar
This commit is contained in:
parent
5cab4e0ab9
commit
e714542dc4
2 changed files with 24 additions and 14 deletions
37
clock.gd
37
clock.gd
|
|
@ -4,23 +4,32 @@ var taskbar_height : int = 50
|
||||||
@export var bar: TextureProgressBar
|
@export var bar: TextureProgressBar
|
||||||
@export var label: Label
|
@export var label: Label
|
||||||
|
|
||||||
|
@export var bar_position : Position
|
||||||
|
|
||||||
|
enum Position {
|
||||||
|
Bottom,
|
||||||
|
Right,
|
||||||
|
Top,
|
||||||
|
Left,
|
||||||
|
}
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
position.y = 0
|
setup_window()
|
||||||
var screen_size : Vector2i = DisplayServer.screen_get_size()
|
|
||||||
#DisplayServer.window_set_size(Vector2i(screen_size.x, 10))
|
|
||||||
#size.x = screen_size.x
|
|
||||||
#size.y = 10
|
|
||||||
#DisplayServer.window_set_min_size(Vector2i(1,1))
|
|
||||||
get_window().min_size = Vector2i(1,1)
|
|
||||||
get_window().size = Vector2i(screen_size.x, 10)
|
|
||||||
DisplayServer.window_set_position(Vector2i(0,screen_size.y-10-taskbar_height))
|
|
||||||
position.y = 0
|
|
||||||
|
|
||||||
#position = Vector2i(0,screen_size.y-10-taskbar_height)
|
|
||||||
#get_window().size = Vector2i(screen_size.x, 10)
|
|
||||||
pass # Replace with function body.
|
|
||||||
|
|
||||||
|
func setup_window():
|
||||||
|
var screen_size : Vector2i = DisplayServer.screen_get_size() # get current screen size
|
||||||
|
var screen_pos : Vector2i = DisplayServer.screen_get_position(DisplayServer.SCREEN_OF_MAIN_WINDOW) # get the posiiton of the window on the virtual display
|
||||||
|
get_window().min_size = Vector2i(1,1) # weird godot bug where the min screen size is 64x64 unless set in code
|
||||||
|
if bar_position == Position.Bottom:
|
||||||
|
get_window().size = Vector2i(screen_size.x, 10) # set window size to be 10 high and screen width wide
|
||||||
|
DisplayServer.window_set_position(screen_pos + Vector2i(0,screen_size.y-10-taskbar_height)) # set position of window to be just above the taskbar
|
||||||
|
position.y = 0 # set position of bar to be where it should be (moves when we change the window size)
|
||||||
|
if bar_position == Position.Right:
|
||||||
|
get_window().size = Vector2i(10, screen_size.y) # set window size to be 10 high and screen width wide
|
||||||
|
DisplayServer.window_set_position(screen_pos + Vector2i(screen_size.x-10,0)) # set position of window to be just above the taskbar
|
||||||
|
position.y = 0 # set position of bar to be where it should be (moves when we change the window size)
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
|
|
@ -38,7 +47,7 @@ func _process(delta: float) -> void:
|
||||||
|
|
||||||
if (bar.value >= 0.50):
|
if (bar.value >= 0.50):
|
||||||
bar.modulate = Color.RED
|
bar.modulate = Color.RED
|
||||||
else:
|
else:
|
||||||
bar.modulate = Color.DODGER_BLUE
|
bar.modulate = Color.DODGER_BLUE
|
||||||
|
|
||||||
#var screen_size : Vector2i = DisplayServer.screen_get_size()
|
#var screen_size : Vector2i = DisplayServer.screen_get_size()
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ grow_vertical = 0
|
||||||
script = ExtResource("1_h2yge")
|
script = ExtResource("1_h2yge")
|
||||||
bar = NodePath("VBoxContainer/MainContent/bar")
|
bar = NodePath("VBoxContainer/MainContent/bar")
|
||||||
label = NodePath("VBoxContainer/MainContent/Label")
|
label = NodePath("VBoxContainer/MainContent/Label")
|
||||||
|
bar_position = 1
|
||||||
|
|
||||||
[node name="Background" type="ColorRect" parent="." unique_id=641703216]
|
[node name="Background" type="ColorRect" parent="." unique_id=641703216]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue