diff --git a/clock.gd b/clock.gd index 95f87ab..04db82f 100644 --- a/clock.gd +++ b/clock.gd @@ -4,23 +4,32 @@ var taskbar_height : int = 50 @export var bar: TextureProgressBar @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. func _ready() -> void: - position.y = 0 - 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 + setup_window() - #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. func _process(delta: float) -> void: @@ -38,7 +47,7 @@ func _process(delta: float) -> void: if (bar.value >= 0.50): bar.modulate = Color.RED - else: + else: bar.modulate = Color.DODGER_BLUE #var screen_size : Vector2i = DisplayServer.screen_get_size() diff --git a/main.tscn b/main.tscn index 5f3925b..1ba5847 100644 --- a/main.tscn +++ b/main.tscn @@ -27,6 +27,7 @@ grow_vertical = 0 script = ExtResource("1_h2yge") bar = NodePath("VBoxContainer/MainContent/bar") label = NodePath("VBoxContainer/MainContent/Label") +bar_position = 1 [node name="Background" type="ColorRect" parent="." unique_id=641703216] layout_mode = 1