Skip to content

Commit 1255cc1

Browse files
VisssarionAThousandShipsaaronfranke
committed
Add Multiple Windows Demo
Co-Authored-By: A Thousand Ships <[email protected]> Co-Authored-By: Aaron Franke <[email protected]>
1 parent 6d5ded3 commit 1255cc1

38 files changed

+1099
-0
lines changed

misc/multiple_windows/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Window Management
2+
3+
A demo showing all [`Window`](https://docs.godotengine.org/en/stable/classes/class_window.html) classes and their use within the main window.
4+
5+
It includes:
6+
- Embedding/unembedding subwindows.
7+
- Using a transparent window.
8+
- Adding physical objects to new windows.
9+
- Showcase of all Dialog Windows.
10+
- Showcase of all Popup Windows.
11+
- Adding elements to a Popup Menu.
12+
- Adding an icon to the system tray.
13+
14+
Language: GDScript
15+
16+
Renderer: Compatbility
17+
18+
## Screenshots
19+
20+
![Screenshot](screenshots/screenshot.webp)

misc/multiple_windows/icon.webp

414 Bytes
Loading
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://cehd300ehf1vw"
6+
path="res://.godot/imported/icon.webp-e94f9a68b0f625a567a797079e4d325f.ctex"
7+
metadata={
8+
"vram_texture": false
9+
}
10+
11+
[deps]
12+
13+
source_file="res://icon.webp"
14+
dest_files=["res://.godot/imported/icon.webp-e94f9a68b0f625a567a797079e4d325f.ctex"]
15+
16+
[params]
17+
18+
compress/mode=0
19+
compress/high_quality=false
20+
compress/lossy_quality=0.7
21+
compress/uastc_level=0
22+
compress/rdo_quality_loss=0.0
23+
compress/hdr_compression=1
24+
compress/normal_map=0
25+
compress/channel_pack=0
26+
mipmaps/generate=false
27+
mipmaps/limit=-1
28+
roughness/mode=0
29+
roughness/src_normal=""
30+
process/channel_remap/red=0
31+
process/channel_remap/green=1
32+
process/channel_remap/blue=2
33+
process/channel_remap/alpha=3
34+
process/fix_alpha_border=true
35+
process/premult_alpha=false
36+
process/normal_map_invert_y=false
37+
process/hdr_as_srgb=false
38+
process/hdr_clamp_exposure=false
39+
process/size_limit=0
40+
detect_3d/compress_to=1
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
; Engine configuration file.
2+
; It's best edited using the editor UI and not directly,
3+
; since the parameters that go here are not all obvious.
4+
;
5+
; Format:
6+
; [section] ; section goes between []
7+
; param=value ; assign values to parameters
8+
9+
config_version=5
10+
11+
[application]
12+
13+
config/name="Multiple Windows Demo"
14+
config/description="A demo showing all Window classes and their use within the main window."
15+
run/main_scene="res://scenes/main_scene.tscn"
16+
config/features=PackedStringArray("4.5", "GL Compatibility")
17+
run/low_processor_mode=true
18+
config/icon="res://icon.webp"
19+
20+
[display]
21+
22+
window/size/viewport_width=650
23+
window/size/viewport_height=650
24+
window/stretch/mode="canvas_items"
25+
window/stretch/aspect="expand"
26+
window/per_pixel_transparency/allowed=true
27+
28+
[rendering]
29+
30+
renderer/rendering_method="gl_compatibility"
31+
renderer/rendering_method.mobile="gl_compatibility"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[gd_scene format=3 uid="uid://cudrukovmha7p"]
2+
3+
[node name="AcceptDialog" type="AcceptDialog"]
4+
initial_position = 2
5+
size = Vector2i(277, 100)
6+
visible = true
7+
dialog_text = "This is an AcceptDialog window"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[gd_scene format=3 uid="uid://1nswovajdv3n"]
2+
3+
[node name="ConfirmationDialog" type="ConfirmationDialog"]
4+
initial_position = 2
5+
size = Vector2i(310, 100)
6+
visible = true
7+
dialog_text = "This is a ConfimationDialog window"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
extends BaseButton
2+
3+
@export var others: Array[BaseButton] = []
4+
5+
enum Behavior {
6+
ENABLE_OTHERS_WHEN_ENABLED,
7+
ENABLE_OTHERS_WHEN_DISABLED,
8+
}
9+
10+
@export var behavior: Behavior = Behavior.ENABLE_OTHERS_WHEN_ENABLED
11+
12+
func _ready() -> void:
13+
var others_disabled: bool
14+
if behavior == Behavior.ENABLE_OTHERS_WHEN_ENABLED:
15+
others_disabled = not button_pressed
16+
else:
17+
others_disabled = button_pressed
18+
for other in others:
19+
other.disabled = others_disabled
20+
21+
22+
func _toggled(toggled_on: bool) -> void:
23+
if behavior == Behavior.ENABLE_OTHERS_WHEN_ENABLED:
24+
for other in others:
25+
other.disabled = not toggled_on
26+
else:
27+
for other in others:
28+
other.disabled = toggled_on
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://b4ngyw7e2c75u
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
extends Area2D
2+
3+
var window_delta: Vector2i
4+
5+
var held_down: bool = false
6+
7+
func _input_event(_viewport, event, _shape_idx):
8+
if event is InputEventMouseButton:
9+
held_down = event.pressed
10+
if event.pressed:
11+
window_delta = get_window().position - DisplayServer.mouse_get_position()
12+
13+
14+
func _process(_delta):
15+
if held_down:
16+
get_window().position = DisplayServer.mouse_get_position() + window_delta
17+
var mouse_state = DisplayServer.mouse_get_button_state()
18+
if mouse_state & MOUSE_BUTTON_MASK_LEFT == 0:
19+
held_down = false
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://d1nq2ipicit18

0 commit comments

Comments
 (0)