Last active
December 30, 2018 08:28
-
-
Save ZodmanPerth/72e45974a579cbca22255e40169f4f28 to your computer and use it in GitHub Desktop.
Godot Dynamic Menu for Capability Tests. Blog post at http://www.redperegrine.net/2018/09/26/menu-all-gui/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Node | |
func _ready(): | |
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN) | |
var appInstance = load("res://game/menu/Main.tscn").instance() | |
add_child(appInstance) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[gd_scene load_steps=2 format=2] | |
[ext_resource path="res://game.gd" type="Script" id=1] | |
[node name="game" type="Node"] | |
script = ExtResource( 1 ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is the script for the menu scene "Main.tscn" | |
extends Node | |
onready var MenuContainer = $menuContainer | |
onready var SceneButtonGrid = $menuContainer/VBoxContainer/MarginContainer/SceneButtonGrid | |
var Apps = [ | |
{ | |
name = "Touch Manipulation", | |
thumbnail = "res://game/menu/thumbnails/ManipulationTest.png", | |
path = "res://touchInput/touchInput.tscn", | |
}, | |
{ | |
name = "Accelerometer", | |
thumbnail = "res://game/menu/thumbnails/AccelerometerTest.png", | |
path = "res://sensorInput/sensorInput.tscn", | |
}, | |
] | |
func _ready(): | |
for app in Apps: | |
var sceneButton = load("res://game/menu/SceneButton.tscn").instance() | |
sceneButton.Initialise(app.name, app.thumbnail, app.path) | |
sceneButton.connect("pressed", self, "OnButtonPressed") | |
SceneButtonGrid.add_child(sceneButton) | |
func OnButtonPressed(scenePath): | |
var appInstance = load(scenePath).instance() | |
add_child(appInstance) | |
remove_child(MenuContainer) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[gd_scene load_steps=4 format=2] | |
[ext_resource path="res://game/menu/Main.gd" type="Script" id=1] | |
[ext_resource path="res://test/uiLayout/theme.tres" type="Theme" id=2] | |
[ext_resource path="res://test/uiLayout/TitleFont.tres" type="DynamicFont" id=3] | |
[node name="Main" type="Node"] | |
script = ExtResource( 1 ) | |
[node name="menuContainer" type="MarginContainer" parent="." index="0"] | |
anchor_left = 0.0 | |
anchor_top = 0.0 | |
anchor_right = 1.0 | |
anchor_bottom = 1.0 | |
rect_pivot_offset = Vector2( 0, 0 ) | |
rect_clip_content = false | |
mouse_filter = 0 | |
mouse_default_cursor_shape = 0 | |
size_flags_horizontal = 1 | |
size_flags_vertical = 1 | |
theme = ExtResource( 2 ) | |
custom_constants/margin_right = 120 | |
custom_constants/margin_top = 100 | |
custom_constants/margin_left = 120 | |
custom_constants/margin_bottom = 100 | |
_sections_unfolded = [ "Margin", "Theme", "custom_constants" ] | |
[node name="VBoxContainer" type="VBoxContainer" parent="menuContainer" index="0"] | |
anchor_left = 0.0 | |
anchor_top = 0.0 | |
anchor_right = 0.0 | |
anchor_bottom = 0.0 | |
margin_left = 120.0 | |
margin_top = 100.0 | |
margin_right = 1928.0 | |
margin_bottom = 1052.0 | |
rect_pivot_offset = Vector2( 0, 0 ) | |
rect_clip_content = false | |
mouse_filter = 1 | |
mouse_default_cursor_shape = 0 | |
size_flags_horizontal = 1 | |
size_flags_vertical = 1 | |
alignment = 0 | |
[node name="Label" type="Label" parent="menuContainer/VBoxContainer" index="0"] | |
anchor_left = 0.0 | |
anchor_top = 0.0 | |
anchor_right = 0.0 | |
anchor_bottom = 0.0 | |
margin_right = 1808.0 | |
margin_bottom = 72.0 | |
rect_pivot_offset = Vector2( 0, 0 ) | |
rect_clip_content = false | |
mouse_filter = 2 | |
mouse_default_cursor_shape = 0 | |
size_flags_horizontal = 1 | |
size_flags_vertical = 4 | |
theme = ExtResource( 2 ) | |
custom_fonts/font = ExtResource( 3 ) | |
text = "CAPABILITY TESTS" | |
percent_visible = 1.0 | |
lines_skipped = 0 | |
max_lines_visible = -1 | |
_sections_unfolded = [ "Theme", "custom_fonts" ] | |
[node name="MarginContainer" type="MarginContainer" parent="menuContainer/VBoxContainer" index="1"] | |
anchor_left = 0.0 | |
anchor_top = 0.0 | |
anchor_right = 0.0 | |
anchor_bottom = 0.0 | |
margin_top = 76.0 | |
margin_right = 1808.0 | |
margin_bottom = 952.0 | |
rect_pivot_offset = Vector2( 0, 0 ) | |
rect_clip_content = false | |
mouse_filter = 0 | |
mouse_default_cursor_shape = 0 | |
size_flags_horizontal = 1 | |
size_flags_vertical = 3 | |
custom_constants/margin_top = 60 | |
_sections_unfolded = [ "Size Flags", "custom_constants" ] | |
[node name="SceneButtonGrid" type="GridContainer" parent="menuContainer/VBoxContainer/MarginContainer" index="0"] | |
anchor_left = 0.0 | |
anchor_top = 0.0 | |
anchor_right = 0.0 | |
anchor_bottom = 0.0 | |
margin_top = 60.0 | |
margin_bottom = 60.0 | |
rect_pivot_offset = Vector2( 0, 0 ) | |
rect_clip_content = false | |
mouse_filter = 1 | |
mouse_default_cursor_shape = 0 | |
size_flags_horizontal = 2 | |
size_flags_vertical = 2 | |
custom_constants/vseparation = 30 | |
custom_constants/hseparation = 40 | |
columns = 5 | |
_sections_unfolded = [ "Margin", "Rect", "Size Flags", "custom_constants" ] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment