1
0
Fork 0

Merge pull request 'main' (#1) from under/ExampleProject:main into main

Reviewed-on: https://git.jamcloud.ftp.sh/LGDG/ExampleProject/pulls/1
This commit is contained in:
jamosdev 2024-03-22 11:37:56 +00:00
commit bb784ad6f1
6 changed files with 429 additions and 343 deletions

View File

@ -1,29 +1,29 @@
extends Node extends Node
# 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(): func _ready():
#InputMap.action_get_events() #InputMap.action_get_events()
var hotkey = ProjectSettings.get_setting("input/HotKey_ToggleFullscreen") var hotkey = ProjectSettings.get_setting("input/HotKey_ToggleFullscreen")
print(InputMap.action_get_events("character_forwards")) #print(InputMap.action_get_events("character_forwards"))
print(InputMap.action_get_events("HotKey_ToggleFullscreen")) #print(InputMap.action_get_events("HotKey_ToggleFullscreen"))
if hotkey == null: if hotkey == null:
print("PLEASE GO Project->Project Settings... , Input Map, and add HotKey_ToggleFullscreen") print("PLEASE GO Project->Project Settings... , Input Map, and add HotKey_ToggleFullscreen")
InputMap.add_action("HotKey_ToggleFullscreen") InputMap.add_action("HotKey_ToggleFullscreen")
#InputMap.action_add_event() #InputMap.action_add_event()
print(hotkey) #print(hotkey)
var temporarl_deadzone : float = 0 var temporal_deadzone : float = 0
# 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): func _process(delta):
if temporal_deadzone > 0.0:
temporal_deadzone -= delta
func _input(event: InputEvent) -> void:
#Returns true when the user has started pressing the action event in the current frame or physics tick. It will only return true on the frame or tick that the user pressed down the button. #Returns true when the user has started pressing the action event in the current frame or physics tick. It will only return true on the frame or tick that the user pressed down the button.
#This is useful for code that needs to run only once when an action is pressed, instead of every frame while it's pressed. #This is useful for code that needs to run only once when an action is pressed, instead of every frame while it's pressed.
if Input.is_action_just_pressed("HotKey_ToggleFullscreen") and temporarl_deadzone <= 0.0: if event.is_action_pressed("HotKey_ToggleFullscreen") and temporal_deadzone <= 0.0:
if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN: if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED) DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
else: else:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN) DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
temporarl_deadzone = 0.5 temporal_deadzone = 0.5
if temporarl_deadzone > 0.0:
temporarl_deadzone -= delta

View File

@ -4,18 +4,6 @@ extends Control
@export var the_game: Control # TheGame @export var the_game: Control # TheGame
var current_window: Control = the_game # current window var current_window: Control = the_game # current window
func _process(_delta): func _ready() -> void:
#get_window().grab_focus() DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_BORDERLESS, true)
pass
func _input(event: InputEvent):
if event.is_action_pressed("HotKey_ToggleFullscreen"):
# we can't maximize because godot considers borderless maximized to be fullscreen
if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
else:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)

View File

@ -7,26 +7,62 @@ extends Control
var windowed_rect: Rect2 var windowed_rect: Rect2
func _input(event: InputEvent): func get_descendants(node: Node) -> Array[Node]:
var nodes: Array[Node] = []
for child in node.get_children():
if child.get_child_count() > 0:
nodes.append(child)
nodes.append_array(get_descendants(child))
else:
nodes.append(child)
return nodes
func _ready() -> void:
for descendant in get_descendants(self):
descendant.gui_input.connect(_gui_input)
func _gui_input(event: InputEvent) -> void:
if event is InputEventMouseButton: if event is InputEventMouseButton:
if event.pressed: if event.pressed:
if get_global_rect().has_point(get_global_mouse_position()): if get_global_rect().has_point(get_global_mouse_position()):
desktop.current_window = self desktop.current_window = self
elif event is InputEventKey: get_parent().move_child(self, get_parent().get_child_count())
func _input(event: InputEvent):
if event is InputEventKey:
if event.keycode == KEY_F11: if event.keycode == KEY_F11:
if event.pressed: if event.pressed:
if desktop.current_window == self: if desktop.current_window == self:
toggle_maximized() toggle_maximized()
elif event.alt_pressed and event.keycode == KEY_UP:
if event.pressed:
if desktop.current_window == self:
if not visible:
visible = true
elif not anchors_preset == Control.PRESET_FULL_RECT:
windowed_rect = get_global_rect()
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
elif event.alt_pressed and event.keycode == KEY_DOWN:
if event.pressed:
if desktop.current_window == self:
if anchors_preset == Control.PRESET_FULL_RECT:
set_anchors_and_offsets_preset(Control.PRESET_TOP_LEFT)
position = windowed_rect.position
size = windowed_rect.size
elif visible:
visible = false
# toggle maximized # toggle maximized
func toggle_maximized(): func toggle_maximized():
if get_parent() == maximized_windows: if anchors_preset == Control.PRESET_FULL_RECT:
set_anchors_and_offsets_preset(Control.PRESET_TOP_LEFT)
position = windowed_rect.position position = windowed_rect.position
size = windowed_rect.size size = windowed_rect.size
reparent(desktop)
else: else:
windowed_rect = get_global_rect() windowed_rect = get_global_rect()
reparent(maximized_windows) set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
func close(): func close():
visible = false visible = false

View File

@ -0,0 +1,344 @@
[gd_scene load_steps=19 format=3 uid="uid://bedj3x7821sbp"]
[ext_resource type="Script" path="res://RetroWindowsGUI/DesktopWindow.gd" id="1_1566a"]
[ext_resource type="Theme" uid="uid://c23xui480a6b6" path="res://RetroWindowsGUI/RetroWindowsTheme.tres" id="1_clavd"]
[ext_resource type="Script" path="res://RetroWindowsGUI/RetroWindow.gd" id="2_5apeq"]
[ext_resource type="Texture2D" uid="uid://byysuusmylpjo" path="res://RetroWindowsGUI/Images/Window_Header_Inner.png" id="3_o2go2"]
[ext_resource type="Texture2D" uid="uid://f572ckglau50" path="res://RetroWindowsGUI/Images/Windows_Icon_Minimize.png" id="4_p55hd"]
[ext_resource type="Texture2D" uid="uid://bir5p8cnwtwrn" path="res://RetroWindowsGUI/Images/Windows_Icon_Maximize.png" id="5_6yn4a"]
[ext_resource type="Texture2D" uid="uid://lfo3fn4qyl3g" path="res://RetroWindowsGUI/Images/Windows_Icon_Question.png" id="6_0uvav"]
[ext_resource type="Texture2D" uid="uid://bluatk0bspn3x" path="res://RetroWindowsGUI/Images/Windows_Icon_Close.png" id="7_r5i4b"]
[ext_resource type="Texture2D" uid="uid://dxtjm7ivsy8s1" path="res://RetroWindowsGUI/Images/Windows_Inner_Frame_Inverted.png" id="8_lxvf8"]
[ext_resource type="Script" path="res://RetroWindowsGUI/ResizeHandle.gd" id="9_b570p"]
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_gihe0"]
texture = ExtResource("3_o2go2")
[sub_resource type="GDScript" id="GDScript_ly7j8"]
script/source = "extends PanelContainer
@export var window: DesktopWindow
var dragging: bool = false
var begmosposi: Vector2i # beginning mouse position integer
var begwndpos: Vector2i # beginning window position
# get windows mouse position integer
func getmosposi() -> Vector2i:
var mospos := get_global_mouse_position()
return Vector2i(floori(mospos.x), floori(mospos.y))
func _input(event: InputEvent):
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT:
if event.is_released():
dragging = false
# snap within game window
var rect = window.get_global_rect()
if rect.position.x < 0:
rect.position.x = 0
if rect.position.y < 0:
rect.position.y = 0
window.position = rect.position
elif event is InputEventMouseMotion:
if dragging:
window.global_position = begwndpos + getmosposi() - begmosposi
func _gui_input(event: InputEvent):
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT:
if event.double_click:
if get_global_rect().has_point(get_global_mouse_position()):
window.toggle_maximized()
elif event.pressed:
if get_global_rect().has_point(get_global_mouse_position()):
dragging = true
begmosposi = getmosposi()
begwndpos = window.get_global_rect().position
"
[sub_resource type="GDScript" id="GDScript_fvsxv"]
script/source = "extends Button
@export var window: DesktopWindow
func _ready():
pressed.connect(_on_pressed)
func _on_pressed():
window.minimize()
"
[sub_resource type="GDScript" id="GDScript_orv1v"]
script/source = "extends Button
@export var window: DesktopWindow
func _ready():
pressed.connect(_on_pressed)
func _on_pressed():
window.toggle_maximized()
"
[sub_resource type="GDScript" id="GDScript_go6nd"]
script/source = "extends Button
@export var window: DesktopWindow
func _ready():
pressed.connect(_on_pressed)
func _on_pressed():
window.close()
"
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_yu144"]
bg_color = Color(0.831373, 0.815686, 0.784314, 1)
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_eejdr"]
content_margin_left = 2.0
content_margin_top = 2.0
content_margin_right = 2.0
content_margin_bottom = 2.0
texture = ExtResource("8_lxvf8")
texture_margin_left = 3.0
texture_margin_top = 3.0
texture_margin_right = 3.0
texture_margin_bottom = 3.0
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_sn8k8"]
texture = ExtResource("8_lxvf8")
texture_margin_left = 3.0
texture_margin_top = 3.0
texture_margin_right = 3.0
texture_margin_bottom = 3.0
[node name="DesktopWindow" type="Control"]
layout_mode = 3
anchors_preset = 0
offset_right = 161.0
offset_bottom = 137.0
size_flags_vertical = 3
theme = ExtResource("1_clavd")
script = ExtResource("1_1566a")
[node name="PanelContainer" type="PanelContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("2_5apeq")
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"]
layout_mode = 2
theme_override_constants/separation = 2
[node name="PanelContainer (Header)" type="PanelContainer" parent="PanelContainer/VBoxContainer" node_paths=PackedStringArray("window")]
custom_minimum_size = Vector2(0, 25)
layout_mode = 2
theme_type_variation = &"HeaderPanelContainer"
theme_override_styles/panel = SubResource("StyleBoxTexture_gihe0")
script = SubResource("GDScript_ly7j8")
window = NodePath("../../..")
[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer/VBoxContainer/PanelContainer (Header)"]
custom_minimum_size = Vector2(0, 26)
layout_mode = 2
theme_override_constants/separation = 0
[node name="MarginContainer (Title)" type="MarginContainer" parent="PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/margin_left = 5
theme_override_constants/margin_right = 5
[node name="Label" type="Label" parent="PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer/MarginContainer (Title)"]
layout_mode = 2
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_font_sizes/font_size = 16
text = "Inventory"
[node name="MarginContainer (Minimize)" type="MarginContainer" parent="PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer"]
layout_mode = 2
theme_override_constants/margin_top = 6
[node name="Button" type="Button" parent="PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer/MarginContainer (Minimize)" node_paths=PackedStringArray("window")]
custom_minimum_size = Vector2(15, 15)
layout_mode = 2
size_flags_vertical = 0
expand_icon = true
script = SubResource("GDScript_fvsxv")
window = NodePath("../../../../../..")
[node name="TextureRect" type="TextureRect" parent="PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer/MarginContainer (Minimize)"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 0
mouse_filter = 2
texture = ExtResource("4_p55hd")
[node name="MarginContainer (Maximize)" type="MarginContainer" parent="PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer"]
layout_mode = 2
theme_override_constants/margin_top = 6
[node name="Button" type="Button" parent="PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer/MarginContainer (Maximize)" node_paths=PackedStringArray("window")]
custom_minimum_size = Vector2(15, 15)
layout_mode = 2
size_flags_vertical = 0
expand_icon = true
script = SubResource("GDScript_orv1v")
window = NodePath("../../../../../..")
[node name="TextureRect" type="TextureRect" parent="PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer/MarginContainer (Maximize)"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 0
mouse_filter = 2
texture = ExtResource("5_6yn4a")
[node name="MarginContainer (Help)" type="MarginContainer" parent="PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer"]
layout_mode = 2
theme_override_constants/margin_top = 6
[node name="Button" type="Button" parent="PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer/MarginContainer (Help)"]
custom_minimum_size = Vector2(15, 15)
layout_mode = 2
size_flags_vertical = 0
expand_icon = true
[node name="TextureRect" type="TextureRect" parent="PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer/MarginContainer (Help)"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 0
mouse_filter = 2
texture = ExtResource("6_0uvav")
[node name="MarginContainer (Close)" type="MarginContainer" parent="PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 2
theme_override_constants/margin_top = 6
theme_override_constants/margin_right = 2
[node name="Button" type="Button" parent="PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer/MarginContainer (Close)" node_paths=PackedStringArray("window")]
custom_minimum_size = Vector2(15, 15)
layout_mode = 2
size_flags_vertical = 0
expand_icon = true
script = SubResource("GDScript_go6nd")
window = NodePath("../../../../../..")
[node name="TextureRect" type="TextureRect" parent="PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer/MarginContainer (Close)"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 0
mouse_filter = 2
texture = ExtResource("7_r5i4b")
[node name="PanelContainer (Menu Bar)" type="PanelContainer" parent="PanelContainer/VBoxContainer"]
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_yu144")
[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer/VBoxContainer/PanelContainer (Menu Bar)"]
custom_minimum_size = Vector2(0, 16)
layout_mode = 2
theme_override_constants/separation = 0
[node name="Button" type="Button" parent="PanelContainer/VBoxContainer/PanelContainer (Menu Bar)/HBoxContainer"]
layout_mode = 2
theme_type_variation = &"FlatButton"
theme_override_colors/font_color = Color(0, 0, 0, 0)
theme_override_colors/font_pressed_color = Color(0, 0, 0, 0)
theme_override_colors/font_hover_color = Color(0, 0, 0, 0)
theme_override_colors/font_focus_color = Color(0, 0, 0, 0)
theme_override_colors/font_hover_pressed_color = Color(0, 0, 0, 0)
theme_override_colors/font_disabled_color = Color(0, 0, 0, 0)
theme_override_colors/font_outline_color = Color(0, 0, 0, 0)
text = "File"
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer/VBoxContainer/PanelContainer (Menu Bar)/HBoxContainer/Button"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_top = 0
[node name="CenterContainer" type="CenterContainer" parent="PanelContainer/VBoxContainer/PanelContainer (Menu Bar)/HBoxContainer/Button/MarginContainer"]
layout_mode = 2
[node name="RichTextLabel" type="RichTextLabel" parent="PanelContainer/VBoxContainer/PanelContainer (Menu Bar)/HBoxContainer/Button/MarginContainer/CenterContainer"]
layout_mode = 2
size_flags_vertical = 8
mouse_filter = 2
bbcode_enabled = true
text = "[u]F[/u]ile"
fit_content = true
autowrap_mode = 0
[node name="PanelContainer (Body)" type="PanelContainer" parent="PanelContainer/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
theme_type_variation = &"InvertedInnerPanelContainer"
theme_override_styles/panel = SubResource("StyleBoxTexture_eejdr")
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/VBoxContainer/PanelContainer (Body)"]
layout_mode = 2
theme_override_constants/separation = 0
[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer/VBoxContainer/PanelContainer (Body)/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/separation = 0
[node name="MarginContainer (Content)" type="MarginContainer" parent="PanelContainer/VBoxContainer/PanelContainer (Body)/VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="VScrollBar" type="VScrollBar" parent="PanelContainer/VBoxContainer/PanelContainer (Body)/VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 1
size_flags_vertical = 3
page = 100.0
[node name="HBoxContainer2" type="HBoxContainer" parent="PanelContainer/VBoxContainer/PanelContainer (Body)/VBoxContainer"]
custom_minimum_size = Vector2(0, 15)
layout_mode = 2
theme_override_constants/separation = 0
[node name="HScrollBar" type="HScrollBar" parent="PanelContainer/VBoxContainer/PanelContainer (Body)/VBoxContainer/HBoxContainer2"]
custom_minimum_size = Vector2(16, 16)
layout_mode = 2
size_flags_horizontal = 3
page = 100.0
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer/VBoxContainer/PanelContainer (Body)/VBoxContainer/HBoxContainer2"]
custom_minimum_size = Vector2(16, 0)
layout_mode = 2
[node name="PanelContainer (Status Bar)" type="PanelContainer" parent="PanelContainer/VBoxContainer"]
custom_minimum_size = Vector2(0, 16)
layout_mode = 2
size_flags_vertical = 8
theme_override_styles/panel = SubResource("StyleBoxTexture_sn8k8")
[node name="Button (Resize Handle)" type="Button" parent="."]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -17.0
offset_top = -18.0
offset_right = -5.0
offset_bottom = -6.0
grow_horizontal = 0
grow_vertical = 0
theme_type_variation = &"ResizeButton"
action_mode = 0
keep_pressed_outside = true
script = ExtResource("9_b570p")

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=28 format=3 uid="uid://bvc6sgiglgspt"] [gd_scene load_steps=23 format=3 uid="uid://bvc6sgiglgspt"]
[ext_resource type="Theme" uid="uid://c23xui480a6b6" path="res://RetroWindowsGUI/RetroWindowsTheme.tres" id="1_2cwqu"] [ext_resource type="Theme" uid="uid://c23xui480a6b6" path="res://RetroWindowsGUI/RetroWindowsTheme.tres" id="1_2cwqu"]
[ext_resource type="Script" path="res://RetroWindowsGUI/Desktop.gd" id="2_1wlr7"] [ext_resource type="Script" path="res://RetroWindowsGUI/Desktop.gd" id="2_1wlr7"]
@ -10,9 +10,8 @@
[ext_resource type="Texture2D" uid="uid://lfo3fn4qyl3g" path="res://RetroWindowsGUI/Images/Windows_Icon_Question.png" id="6_byeim"] [ext_resource type="Texture2D" uid="uid://lfo3fn4qyl3g" path="res://RetroWindowsGUI/Images/Windows_Icon_Question.png" id="6_byeim"]
[ext_resource type="Texture2D" uid="uid://dxtjm7ivsy8s1" path="res://RetroWindowsGUI/Images/Windows_Inner_Frame_Inverted.png" id="8_75uw4"] [ext_resource type="Texture2D" uid="uid://dxtjm7ivsy8s1" path="res://RetroWindowsGUI/Images/Windows_Inner_Frame_Inverted.png" id="8_75uw4"]
[ext_resource type="PackedScene" uid="uid://dviuoownyvrke" path="res://thirdPerson.tscn" id="9_o80ae"] [ext_resource type="PackedScene" uid="uid://dviuoownyvrke" path="res://thirdPerson.tscn" id="9_o80ae"]
[ext_resource type="Script" path="res://RetroWindowsGUI/DesktopWindow.gd" id="11_7veoj"] [ext_resource type="PackedScene" uid="uid://bedj3x7821sbp" path="res://RetroWindowsGUI/DesktopWindow.tscn" id="11_m0w0q"]
[ext_resource type="AudioStream" uid="uid://c51m7ngf7kjdq" path="res://RetroWindowsGUI/me.ogg" id="12_16brn"] [ext_resource type="AudioStream" uid="uid://c51m7ngf7kjdq" path="res://RetroWindowsGUI/me.ogg" id="12_16brn"]
[ext_resource type="Script" path="res://RetroWindowsGUI/ResizeHandle.gd" id="12_k07jd"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_74f3x"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_74f3x"]
bg_color = Color(0, 0, 0, 0.47451) bg_color = Color(0, 0, 0, 0.47451)
@ -38,6 +37,14 @@ func getwinmosposi() -> Vector2i:
return DisplayServer.window_get_position() + Vector2i(floori(mospos.x), floori(mospos.y)) return DisplayServer.window_get_position() + Vector2i(floori(mospos.x), floori(mospos.y))
func _input(event: InputEvent): func _input(event: InputEvent):
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT:
if event.is_released():
dragging = false
elif dragging and event is InputEventMouseMotion:
DisplayServer.window_set_position(begwinpos + getwinmosposi() - begwinmosposi)
func _gui_input(event: InputEvent):
if event is InputEventMouseButton: if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT: if event.button_index == MOUSE_BUTTON_LEFT:
if event.double_click: if event.double_click:
@ -51,11 +58,6 @@ func _input(event: InputEvent):
dragging = true dragging = true
begwinmosposi = getwinmosposi() begwinmosposi = getwinmosposi()
begwinpos = DisplayServer.window_get_position() begwinpos = DisplayServer.window_get_position()
elif event.is_released():
dragging = false
elif dragging and event is InputEventMouseMotion:
DisplayServer.window_set_position(begwinpos + getwinmosposi() - begwinmosposi)
" "
[sub_resource type="GDScript" id="GDScript_2514r"] [sub_resource type="GDScript" id="GDScript_2514r"]
@ -125,81 +127,7 @@ func _on_pressed():
invwin.visible = true invwin.visible = true
" "
[sub_resource type="GDScript" id="GDScript_ly7j8"] [node name="Desktop" type="Control" node_paths=PackedStringArray("the_game")]
script/source = "extends PanelContainer
@export var window: DesktopWindow
var dragging: bool = false
var begmosposi: Vector2i # beginning mouse position integer
var begwndpos: Vector2i # beginning window position
# get windows mouse position integer
func getmosposi() -> Vector2i:
var mospos := get_global_mouse_position()
return Vector2i(floori(mospos.x), floori(mospos.y))
func _input(event: InputEvent):
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT:
if event.double_click:
if get_global_rect().has_point(get_global_mouse_position()):
window.toggle_maximized()
elif event.pressed:
if get_global_rect().has_point(get_global_mouse_position()):
dragging = true
begmosposi = getmosposi()
begwndpos = window.get_global_rect().position
elif event.is_released():
dragging = false
# snap within game window
var rect = window.get_global_rect()
if rect.position.x < 0:
rect.position.x = 0
if rect.position.y < 0:
rect.position.y = 0
window.position = rect.position
elif event is InputEventMouseMotion:
if dragging:
window.global_position = begwndpos + getmosposi() - begmosposi
"
[sub_resource type="GDScript" id="GDScript_fvsxv"]
script/source = "extends Button
@export var window: DesktopWindow
func _ready():
pressed.connect(_on_pressed)
func _on_pressed():
window.minimize()
"
[sub_resource type="GDScript" id="GDScript_orv1v"]
script/source = "extends Button
@export var window: DesktopWindow
func _ready():
pressed.connect(_on_pressed)
func _on_pressed():
window.toggle_maximized()
"
[sub_resource type="GDScript" id="GDScript_go6nd"]
script/source = "extends Button
@export var window: DesktopWindow
func _ready():
pressed.connect(_on_pressed)
func _on_pressed():
window.close()
"
[node name="Desktop" type="Control"]
texture_filter = 1 texture_filter = 1
layout_mode = 3 layout_mode = 3
anchors_preset = 15 anchors_preset = 15
@ -209,6 +137,7 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
theme = ExtResource("1_2cwqu") theme = ExtResource("1_2cwqu")
script = ExtResource("2_1wlr7") script = ExtResource("2_1wlr7")
the_game = NodePath("VBoxContainer/MaximizedWindows/TheGame")
metadata/_edit_lock_ = true metadata/_edit_lock_ = true
[node name="BrightnessFilter" type="Panel" parent="."] [node name="BrightnessFilter" type="Panel" parent="."]
@ -481,246 +410,39 @@ text = "Start"
layout_mode = 2 layout_mode = 2
text = "The Game" text = "The Game"
[node name="Button (Inventory)" type="Button" parent="VBoxContainer/TaskBar/HBoxContainer" node_paths=PackedStringArray("invwin")] [node name="Button (Inventory)" type="Button" parent="VBoxContainer/TaskBar/HBoxContainer"]
layout_mode = 2 layout_mode = 2
text = "Inventory text = "Inventory
" "
script = SubResource("GDScript_2vlp5") script = SubResource("GDScript_2vlp5")
invwin = NodePath("../../../../Inventory")
[node name="Inventory" type="Control" parent="." node_paths=PackedStringArray("desktop", "maximized_windows", "taskbar")] [node name="Windows" type="Control" parent="."]
layout_mode = 2
anchors_preset = 0
offset_left = 100.0
offset_top = 100.0
offset_right = 261.0
offset_bottom = 282.0
size_flags_vertical = 3
script = ExtResource("11_7veoj")
desktop = NodePath("..")
maximized_windows = NodePath("../VBoxContainer/MaximizedWindows")
taskbar = NodePath("../VBoxContainer/TaskBar")
[node name="PanelContainer" type="PanelContainer" parent="Inventory"]
layout_mode = 1 layout_mode = 1
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
script = ExtResource("2_5t0g8")
[node name="VBoxContainer" type="VBoxContainer" parent="Inventory/PanelContainer"]
layout_mode = 2
theme_override_constants/separation = 2
[node name="PanelContainer (Header)" type="PanelContainer" parent="Inventory/PanelContainer/VBoxContainer" node_paths=PackedStringArray("window")]
custom_minimum_size = Vector2(0, 25)
layout_mode = 2
theme_type_variation = &"HeaderPanelContainer"
theme_override_styles/panel = SubResource("StyleBoxTexture_gihe0")
script = SubResource("GDScript_ly7j8")
window = NodePath("../../..")
[node name="HBoxContainer" type="HBoxContainer" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Header)"]
custom_minimum_size = Vector2(0, 26)
layout_mode = 2
theme_override_constants/separation = 0
[node name="MarginContainer (Title)" type="MarginContainer" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/margin_left = 5
theme_override_constants/margin_right = 5
[node name="Label" type="Label" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer/MarginContainer (Title)"]
layout_mode = 2
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_font_sizes/font_size = 16
text = "Inventory"
[node name="MarginContainer (Minimize)" type="MarginContainer" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer"]
layout_mode = 2
theme_override_constants/margin_top = 6
[node name="Button" type="Button" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer/MarginContainer (Minimize)" node_paths=PackedStringArray("window")]
custom_minimum_size = Vector2(15, 15)
layout_mode = 2
size_flags_vertical = 0
expand_icon = true
script = SubResource("GDScript_fvsxv")
window = NodePath("../../../../../..")
[node name="TextureRect" type="TextureRect" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer/MarginContainer (Minimize)"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 0
mouse_filter = 2 mouse_filter = 2
texture = ExtResource("2_2k613") metadata/_edit_lock_ = true
[node name="MarginContainer (Maximize)" type="MarginContainer" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer"] [node name="DesktopWindow" parent="Windows" node_paths=PackedStringArray("desktop", "maximized_windows", "taskbar") instance=ExtResource("11_m0w0q")]
layout_mode = 2 offset_left = 132.0
theme_override_constants/margin_top = 6 offset_top = 185.0
offset_right = 293.0
offset_bottom = 320.0
desktop = NodePath("../..")
maximized_windows = NodePath("../../VBoxContainer/MaximizedWindows")
taskbar = NodePath("../../VBoxContainer/TaskBar")
[node name="Button" type="Button" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer/MarginContainer (Maximize)" node_paths=PackedStringArray("window")] [node name="DesktopWindow2" parent="Windows" node_paths=PackedStringArray("desktop", "maximized_windows", "taskbar") instance=ExtResource("11_m0w0q")]
custom_minimum_size = Vector2(15, 15) offset_left = 190.0
layout_mode = 2 offset_top = 197.0
size_flags_vertical = 0 offset_right = 351.0
expand_icon = true offset_bottom = 332.0
script = SubResource("GDScript_orv1v") desktop = NodePath("../..")
window = NodePath("../../../../../..") maximized_windows = NodePath("../../VBoxContainer/MaximizedWindows")
taskbar = NodePath("../../VBoxContainer/TaskBar")
[node name="TextureRect" type="TextureRect" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer/MarginContainer (Maximize)"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 0
mouse_filter = 2
texture = ExtResource("3_6tl28")
[node name="MarginContainer (Help)" type="MarginContainer" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer"]
layout_mode = 2
theme_override_constants/margin_top = 6
[node name="Button" type="Button" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer/MarginContainer (Help)"]
custom_minimum_size = Vector2(15, 15)
layout_mode = 2
size_flags_vertical = 0
expand_icon = true
[node name="TextureRect" type="TextureRect" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer/MarginContainer (Help)"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 0
mouse_filter = 2
texture = ExtResource("6_byeim")
[node name="MarginContainer (Close)" type="MarginContainer" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 2
theme_override_constants/margin_top = 6
theme_override_constants/margin_right = 2
[node name="Button" type="Button" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer/MarginContainer (Close)" node_paths=PackedStringArray("window")]
custom_minimum_size = Vector2(15, 15)
layout_mode = 2
size_flags_vertical = 0
expand_icon = true
script = SubResource("GDScript_go6nd")
window = NodePath("../../../../../..")
[node name="TextureRect" type="TextureRect" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Header)/HBoxContainer/MarginContainer (Close)"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 0
mouse_filter = 2
texture = ExtResource("4_b1wjg")
[node name="PanelContainer (Menu Bar)" type="PanelContainer" parent="Inventory/PanelContainer/VBoxContainer"]
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_yu144")
[node name="HBoxContainer" type="HBoxContainer" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Menu Bar)"]
custom_minimum_size = Vector2(0, 16)
layout_mode = 2
theme_override_constants/separation = 0
[node name="Button" type="Button" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Menu Bar)/HBoxContainer"]
layout_mode = 2
theme_type_variation = &"FlatButton"
theme_override_colors/font_color = Color(0, 0, 0, 0)
theme_override_colors/font_pressed_color = Color(0, 0, 0, 0)
theme_override_colors/font_hover_color = Color(0, 0, 0, 0)
theme_override_colors/font_focus_color = Color(0, 0, 0, 0)
theme_override_colors/font_hover_pressed_color = Color(0, 0, 0, 0)
theme_override_colors/font_disabled_color = Color(0, 0, 0, 0)
theme_override_colors/font_outline_color = Color(0, 0, 0, 0)
text = "File"
[node name="MarginContainer" type="MarginContainer" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Menu Bar)/HBoxContainer/Button"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_top = 0
[node name="CenterContainer" type="CenterContainer" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Menu Bar)/HBoxContainer/Button/MarginContainer"]
layout_mode = 2
[node name="RichTextLabel" type="RichTextLabel" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Menu Bar)/HBoxContainer/Button/MarginContainer/CenterContainer"]
layout_mode = 2
size_flags_vertical = 8
mouse_filter = 2
bbcode_enabled = true
text = "[u]F[/u]ile"
fit_content = true
autowrap_mode = 0
[node name="PanelContainer (Body)" type="PanelContainer" parent="Inventory/PanelContainer/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
theme_type_variation = &"InvertedInnerPanelContainer"
theme_override_styles/panel = SubResource("StyleBoxTexture_eejdr")
[node name="VBoxContainer" type="VBoxContainer" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Body)"]
layout_mode = 2
theme_override_constants/separation = 0
[node name="HBoxContainer" type="HBoxContainer" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Body)/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/separation = 0
[node name="MarginContainer (Content)" type="MarginContainer" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Body)/VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="VScrollBar" type="VScrollBar" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Body)/VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 1
size_flags_vertical = 3
page = 100.0
[node name="HBoxContainer2" type="HBoxContainer" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Body)/VBoxContainer"]
custom_minimum_size = Vector2(0, 15)
layout_mode = 2
theme_override_constants/separation = 0
[node name="HScrollBar" type="HScrollBar" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Body)/VBoxContainer/HBoxContainer2"]
custom_minimum_size = Vector2(16, 16)
layout_mode = 2
size_flags_horizontal = 3
page = 100.0
[node name="MarginContainer" type="MarginContainer" parent="Inventory/PanelContainer/VBoxContainer/PanelContainer (Body)/VBoxContainer/HBoxContainer2"]
custom_minimum_size = Vector2(16, 0)
layout_mode = 2
[node name="PanelContainer (Status Bar)" type="PanelContainer" parent="Inventory/PanelContainer/VBoxContainer"]
custom_minimum_size = Vector2(0, 16)
layout_mode = 2
size_flags_vertical = 8
theme_override_styles/panel = SubResource("StyleBoxTexture_sn8k8")
[node name="Button (Resize Handle)" type="Button" parent="Inventory"]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -17.0
offset_top = -18.0
offset_right = -5.0
offset_bottom = -6.0
grow_horizontal = 0
grow_vertical = 0
theme_type_variation = &"ResizeButton"
action_mode = 0
keep_pressed_outside = true
script = ExtResource("12_k07jd")
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] [node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource("12_16brn") stream = ExtResource("12_16brn")

View File

@ -11,15 +11,11 @@ config_version=5
[application] [application]
config/name="LgdgExampleProject" config/name="LgdgExampleProject"
run/main_scene="res://RetroWindowsGUI/Window.tscn" run/main_scene="res://thirdPerson.tscn"
config/features=PackedStringArray("4.2", "GL Compatibility") config/features=PackedStringArray("4.2", "GL Compatibility")
config/icon="res://icon.svg" config/icon="res://icon.svg"
run/size/borderless=false run/size/borderless=false
[display]
window/size/borderless=true
[input] [input]
ui_accept={ ui_accept={