Add a theme resource, which applies fonts/styles to all Control elements

This commit is contained in:
Sebastian Morr 2020-09-21 17:00:00 +02:00
parent 3cfd6ec710
commit 24f194872b
12 changed files with 300 additions and 75 deletions

View file

@ -1,6 +1,6 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[ext_resource path="res://fonts/iosevka-regular.ttf" type="DynamicFontData" id=1]
[ext_resource path="res://fonts/cabin-bold.ttf" type="DynamicFontData" id=1]
[resource]
size = 40

BIN
fonts/cabin-bold.ttf Normal file

Binary file not shown.

BIN
fonts/cabin-regular.ttf Normal file

Binary file not shown.

View file

@ -1,6 +1,6 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[ext_resource path="res://fonts/iosevka-regular.ttf" type="DynamicFontData" id=1]
[ext_resource path="res://fonts/cabin-regular.ttf" type="DynamicFontData" id=1]
[resource]
size = 20

7
fonts/monospace.tres Normal file
View file

@ -0,0 +1,7 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[ext_resource path="res://fonts/iosevka-regular.ttf" type="DynamicFontData" id=1]
[resource]
size = 20
font_data = ExtResource( 1 )

View file

@ -34,8 +34,6 @@ func _ready():
var options = level_select.get_popup()
repopulate_levels()
options.connect("id_pressed", self, "load_level")
level_select.theme = Theme.new()
level_select.theme.default_font = load("res://fonts/default.tres")
# Load first level.
load_level(0)

View file

@ -4,12 +4,16 @@
[ext_resource path="res://main.gd" type="Script" id=2]
[ext_resource path="res://repository.tscn" type="PackedScene" id=3]
[ext_resource path="res://styles/alert_button.tres" type="StyleBox" id=4]
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=5]
[ext_resource path="res://styles/theme.tres" type="Theme" id=6]
[ext_resource path="res://fonts/big.tres" type="DynamicFont" id=7]
[ext_resource path="res://tcp_server.gd" type="Script" id=8]
[ext_resource path="res://test.gd" type="Script" id=9]
[sub_resource type="StyleBoxFlat" id=1]
content_margin_left = 10.0
content_margin_right = 10.0
content_margin_top = 5.0
content_margin_bottom = 5.0
bg_color = Color( 0.847059, 0.0666667, 0.0666667, 1 )
corner_radius_top_left = 3
corner_radius_top_right = 3
@ -19,6 +23,7 @@ corner_radius_bottom_left = 3
[node name="Main" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
theme = ExtResource( 6 )
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
@ -44,13 +49,17 @@ __meta__ = {
[node name="HBoxContainer" type="HBoxContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 5.0
margin_top = 5.0
margin_right = -5.0
margin_bottom = -5.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Repositories" type="HBoxContainer" parent="HBoxContainer"]
margin_right = 1277.0
margin_bottom = 1080.0
margin_right = 1270.0
margin_bottom = 1070.0
mouse_filter = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 2.0
@ -64,8 +73,8 @@ anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 0.0
margin_top = 0.0
margin_right = 638.0
margin_bottom = 1080.0
margin_right = 635.0
margin_bottom = 1070.0
size_flags_horizontal = 3
size_flags_vertical = 3
label = "Goal"
@ -73,28 +82,27 @@ label = "Goal"
[node name="ActiveRepository" parent="HBoxContainer/Repositories" instance=ExtResource( 3 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 638.0
margin_left = 635.0
margin_top = 0.0
margin_right = 1277.0
margin_bottom = 1080.0
margin_right = 1270.0
margin_bottom = 1070.0
size_flags_horizontal = 3
size_flags_vertical = 3
label = "Your repository"
[node name="RightSide" type="VBoxContainer" parent="HBoxContainer"]
margin_left = 1281.0
margin_right = 1920.0
margin_bottom = 1080.0
margin_left = 1274.0
margin_right = 1910.0
margin_bottom = 1070.0
size_flags_horizontal = 3
[node name="Menu" type="HBoxContainer" parent="HBoxContainer/RightSide"]
margin_right = 639.0
margin_bottom = 32.0
margin_right = 636.0
margin_bottom = 35.0
[node name="LevelSelect" type="MenuButton" parent="HBoxContainer/RightSide/Menu"]
margin_right = 162.0
margin_bottom = 32.0
custom_fonts/font = ExtResource( 5 )
margin_right = 130.0
margin_bottom = 35.0
text = "Select level..."
flat = false
__meta__ = {
@ -102,35 +110,33 @@ __meta__ = {
}
[node name="ReloadButton" type="Button" parent="HBoxContainer/RightSide/Menu"]
margin_left = 166.0
margin_right = 238.0
margin_bottom = 32.0
custom_fonts/font = ExtResource( 5 )
margin_left = 134.0
margin_right = 213.0
margin_bottom = 35.0
text = "Reload"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="NextLevelButton" type="Button" parent="HBoxContainer/RightSide/Menu"]
margin_left = 242.0
margin_right = 342.0
margin_bottom = 32.0
margin_left = 217.0
margin_right = 327.0
margin_bottom = 35.0
custom_styles/hover = SubResource( 1 )
custom_styles/normal = ExtResource( 4 )
custom_fonts/font = ExtResource( 5 )
text = "Next Level"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="LevelPanel" type="VBoxContainer" parent="HBoxContainer/RightSide"]
margin_top = 36.0
margin_right = 639.0
margin_bottom = 556.0
margin_top = 39.0
margin_right = 636.0
margin_bottom = 552.0
size_flags_vertical = 3
[node name="LevelName" type="RichTextLabel" parent="HBoxContainer/RightSide/LevelPanel"]
margin_right = 639.0
margin_right = 636.0
margin_bottom = 60.0
rect_min_size = Vector2( 0, 60 )
custom_fonts/normal_font = ExtResource( 7 )
@ -141,15 +147,14 @@ __meta__ = {
[node name="Text" type="Control" parent="HBoxContainer/RightSide/LevelPanel"]
margin_top = 64.0
margin_right = 639.0
margin_bottom = 520.0
margin_right = 636.0
margin_bottom = 513.0
size_flags_vertical = 3
[node name="LevelDescription" type="RichTextLabel" parent="HBoxContainer/RightSide/LevelPanel/Text"]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_vertical = 3
custom_fonts/normal_font = ExtResource( 5 )
bbcode_enabled = true
bbcode_text = "Level description here!"
text = "Level description here!"
@ -162,7 +167,6 @@ visible = false
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_vertical = 3
custom_fonts/normal_font = ExtResource( 5 )
bbcode_enabled = true
bbcode_text = "Level description here!"
text = "Level description here!"
@ -173,9 +177,9 @@ __meta__ = {
[node name="Terminal" parent="HBoxContainer/RightSide" instance=ExtResource( 1 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 560.0
margin_right = 639.0
margin_bottom = 1080.0
margin_top = 556.0
margin_right = 636.0
margin_bottom = 1070.0
size_flags_vertical = 3
repository_path = NodePath("../../Repositories/ActiveRepository")

View file

@ -32,7 +32,7 @@ game="*res://game.gd"
window/size/width=1920
window/size/height=1080
window/stretch/mode="2d"
window/stretch/aspect="keep"
window/stretch/aspect="expand"
[input]

View file

@ -1,7 +1,7 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://repository.gd" type="Script" id=1]
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=2]
[ext_resource path="res://styles/theme.tres" type="Theme" id=2]
[ext_resource path="res://fonts/big.tres" type="DynamicFont" id=3]
[node name="Repository" type="Container"]
@ -12,6 +12,7 @@ margin_top = 3.0
margin_right = -6.0
margin_bottom = -4.0
mouse_filter = 2
theme = ExtResource( 2 )
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
@ -22,7 +23,8 @@ margin_left = 24.0
margin_top = 80.0
margin_right = 375.079
margin_bottom = 1044.0
custom_fonts/font = ExtResource( 2 )
text = "entry1
entry2"
__meta__ = {
"_edit_use_anchors_": false
}
@ -60,7 +62,6 @@ anchor_top = 0.968
anchor_bottom = 0.968
margin_right = 24.0
margin_bottom = 24.0
custom_fonts/font = ExtResource( 2 )
text = "Hide trees and blobs"
[node name="Nodes" type="Control" parent="."]

View file

@ -1,6 +1,10 @@
[gd_resource type="StyleBoxFlat" format=2]
[resource]
content_margin_left = 10.0
content_margin_right = 10.0
content_margin_top = 5.0
content_margin_bottom = 5.0
bg_color = Color( 0.717647, 0.160784, 0.160784, 1 )
corner_radius_top_left = 3
corner_radius_top_right = 3

228
styles/theme.tres Normal file
View file

@ -0,0 +1,228 @@
[gd_resource type="Theme" load_steps=21 format=2]
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=1]
[ext_resource path="res://fonts/monospace.tres" type="DynamicFont" id=2]
[sub_resource type="StyleBoxFlat" id=2]
bg_color = Color( 0.223529, 0.223529, 0.223529, 1 )
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="StyleBoxFlat" id=3]
bg_color = Color( 0.207843, 0.207843, 0.207843, 1 )
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
border_color = Color( 0.45098, 0.466667, 0.996078, 1 )
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="StyleBoxFlat" id=4]
bg_color = Color( 0.278431, 0.278431, 0.278431, 1 )
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="StyleBoxFlat" id=1]
content_margin_left = 10.0
content_margin_right = 10.0
content_margin_top = 5.0
content_margin_bottom = 5.0
bg_color = Color( 0.227451, 0.227451, 0.227451, 1 )
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="StyleBoxFlat" id=5]
bg_color = Color( 0.333333, 0.333333, 0.333333, 1 )
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="StyleBoxEmpty" id=10]
[sub_resource type="StyleBoxEmpty" id=11]
[sub_resource type="StyleBoxEmpty" id=12]
[sub_resource type="StyleBoxEmpty" id=13]
[sub_resource type="StyleBoxEmpty" id=14]
[sub_resource type="StyleBoxEmpty" id=15]
[sub_resource type="StyleBoxFlat" id=9]
bg_color = Color( 0, 0, 0, 1 )
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
border_color = Color( 0.490196, 0.494118, 0.929412, 1 )
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="StyleBoxFlat" id=7]
content_margin_left = 7.0
content_margin_right = 7.0
content_margin_top = 5.0
content_margin_bottom = 3.0
bg_color = Color( 0, 0, 0, 1 )
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="StyleBoxFlat" id=8]
content_margin_left = 7.0
content_margin_right = 7.0
content_margin_top = 5.0
content_margin_bottom = 3.0
bg_color = Color( 0, 0, 0, 1 )
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="StyleBoxFlat" id=18]
bg_color = Color( 0.294118, 0.294118, 0.294118, 1 )
[sub_resource type="StyleBoxFlat" id=19]
bg_color = Color( 0.172549, 0.172549, 0.172549, 1 )
[sub_resource type="StyleBoxFlat" id=16]
content_margin_left = 5.0
content_margin_right = 5.0
content_margin_top = 5.0
content_margin_bottom = 5.0
bg_color = Color( 0, 0, 0, 1 )
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
border_color = Color( 0.529412, 0.384314, 1, 1 )
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
[sub_resource type="StyleBoxFlat" id=17]
content_margin_left = 5.0
content_margin_right = 5.0
content_margin_top = 5.0
content_margin_bottom = 5.0
bg_color = Color( 0, 0, 0, 1 )
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[resource]
default_font = ExtResource( 1 )
Button/colors/font_color = Color( 1, 1, 1, 1 )
Button/colors/font_color_disabled = Color( 0.9, 0.9, 0.9, 0.2 )
Button/colors/font_color_hover = Color( 0.94, 0.94, 0.94, 1 )
Button/colors/font_color_pressed = Color( 1, 1, 1, 1 )
Button/constants/hseparation = 2
Button/fonts/font = null
Button/styles/disabled = SubResource( 2 )
Button/styles/focus = SubResource( 3 )
Button/styles/hover = SubResource( 4 )
Button/styles/normal = SubResource( 1 )
Button/styles/pressed = SubResource( 5 )
CheckBox/colors/font_color = Color( 0.88, 0.88, 0.88, 1 )
CheckBox/colors/font_color_disabled = Color( 0.9, 0.9, 0.9, 0.2 )
CheckBox/colors/font_color_hover = Color( 0.94, 0.94, 0.94, 1 )
CheckBox/colors/font_color_hover_pressed = Color( 1, 1, 1, 1 )
CheckBox/colors/font_color_pressed = Color( 1, 1, 1, 1 )
CheckBox/constants/check_vadjust = 0
CheckBox/constants/hseparation = 4
CheckBox/fonts/font = null
CheckBox/icons/checked = null
CheckBox/icons/radio_checked = null
CheckBox/icons/radio_unchecked = null
CheckBox/icons/unchecked = null
CheckBox/styles/disabled = SubResource( 10 )
CheckBox/styles/focus = SubResource( 11 )
CheckBox/styles/hover = SubResource( 12 )
CheckBox/styles/hover_pressed = SubResource( 13 )
CheckBox/styles/normal = SubResource( 14 )
CheckBox/styles/pressed = SubResource( 15 )
LineEdit/colors/clear_button_color = Color( 0.878431, 0.878431, 0.878431, 1 )
LineEdit/colors/clear_button_color_pressed = Color( 1, 1, 1, 1 )
LineEdit/colors/cursor_color = Color( 0.94, 0.94, 0.94, 1 )
LineEdit/colors/font_color = Color( 1, 1, 1, 1 )
LineEdit/colors/font_color_selected = Color( 1, 1, 1, 1 )
LineEdit/colors/font_color_uneditable = Color( 0.88, 0.88, 0.88, 0.5 )
LineEdit/colors/selection_color = Color( 0.584314, 0.415686, 0.972549, 0.462745 )
LineEdit/constants/minimum_spaces = 12
LineEdit/fonts/font = ExtResource( 2 )
LineEdit/icons/clear = null
LineEdit/styles/focus = SubResource( 9 )
LineEdit/styles/normal = SubResource( 7 )
LineEdit/styles/read_only = SubResource( 8 )
PopupMenu/colors/font_color = Color( 0.88, 0.88, 0.88, 1 )
PopupMenu/colors/font_color_accel = Color( 0.7, 0.7, 0.7, 0.8 )
PopupMenu/colors/font_color_disabled = Color( 0.4, 0.4, 0.4, 0.8 )
PopupMenu/colors/font_color_hover = Color( 0.88, 0.88, 0.88, 1 )
PopupMenu/constants/hseparation = 4
PopupMenu/constants/vseparation = 4
PopupMenu/fonts/font = null
PopupMenu/icons/checked = null
PopupMenu/icons/radio_checked = null
PopupMenu/icons/radio_unchecked = null
PopupMenu/icons/submenu = null
PopupMenu/icons/unchecked = null
PopupMenu/styles/hover = SubResource( 18 )
PopupMenu/styles/labeled_separator_left = null
PopupMenu/styles/labeled_separator_right = null
PopupMenu/styles/panel = SubResource( 19 )
PopupMenu/styles/panel_disabled = null
PopupMenu/styles/separator = null
TextEdit/colors/background_color = Color( 0, 0, 0, 0 )
TextEdit/colors/bookmark_color = Color( 0.08, 0.49, 0.98, 1 )
TextEdit/colors/brace_mismatch_color = Color( 1, 0.2, 0.2, 1 )
TextEdit/colors/breakpoint_color = Color( 0.8, 0.8, 0.4, 0.2 )
TextEdit/colors/caret_background_color = Color( 0, 0, 0, 1 )
TextEdit/colors/caret_color = Color( 0.88, 0.88, 0.88, 1 )
TextEdit/colors/code_folding_color = Color( 0.8, 0.8, 0.8, 0.8 )
TextEdit/colors/completion_background_color = Color( 0.17, 0.16, 0.2, 1 )
TextEdit/colors/completion_existing_color = Color( 0.87, 0.87, 0.87, 0.13 )
TextEdit/colors/completion_font_color = Color( 0.67, 0.67, 0.67, 1 )
TextEdit/colors/completion_scroll_color = Color( 1, 1, 1, 1 )
TextEdit/colors/completion_selected_color = Color( 0.26, 0.26, 0.27, 1 )
TextEdit/colors/current_line_color = Color( 0.25, 0.25, 0.26, 0.8 )
TextEdit/colors/executing_line_color = Color( 0.2, 0.8, 0.2, 0.4 )
TextEdit/colors/font_color = Color( 0.88, 0.88, 0.88, 1 )
TextEdit/colors/font_color_readonly = Color( 0.88, 0.88, 0.88, 0.5 )
TextEdit/colors/font_color_selected = Color( 0, 0, 0, 1 )
TextEdit/colors/function_color = Color( 0.4, 0.64, 0.81, 1 )
TextEdit/colors/line_number_color = Color( 0.67, 0.67, 0.67, 0.4 )
TextEdit/colors/mark_color = Color( 1, 0.4, 0.4, 0.4 )
TextEdit/colors/member_variable_color = Color( 0.9, 0.31, 0.35, 1 )
TextEdit/colors/number_color = Color( 0.92, 0.58, 0.2, 1 )
TextEdit/colors/safe_line_number_color = Color( 0.67, 0.78, 0.67, 0.6 )
TextEdit/colors/selection_color = Color( 0.49, 0.49, 0.49, 1 )
TextEdit/colors/symbol_color = Color( 0.94, 0.94, 0.94, 1 )
TextEdit/colors/word_highlighted_color = Color( 0.8, 0.9, 0.9, 0.15 )
TextEdit/constants/completion_lines = 7
TextEdit/constants/completion_max_width = 50
TextEdit/constants/completion_scroll_width = 3
TextEdit/constants/line_spacing = 4
TextEdit/fonts/font = ExtResource( 2 )
TextEdit/icons/fold = null
TextEdit/icons/folded = null
TextEdit/icons/space = null
TextEdit/icons/tab = null
TextEdit/styles/completion = null
TextEdit/styles/focus = SubResource( 16 )
TextEdit/styles/normal = SubResource( 17 )
TextEdit/styles/read_only = null

View file

@ -1,20 +1,20 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=6 format=2]
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=1]
[ext_resource path="res://terminal.gd" type="Script" id=2]
[ext_resource path="res://styles/terminal_input.tres" type="StyleBox" id=3]
[ext_resource path="res://text_editor.gd" type="Script" id=4]
[ext_resource path="res://text_editor.tscn" type="PackedScene" id=5]
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0, 0, 0, 1 )
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
border_color = Color( 0.145098, 0.388235, 0.937255, 1 )
[sub_resource type="StyleBoxFlat" id=2]
content_margin_left = 10.0
content_margin_right = 10.0
content_margin_top = 10.0
content_margin_bottom = 10.0
bg_color = Color( 0, 0, 0, 1 )
border_color = Color( 0.415686, 0.333333, 1, 1 )
[node name="Terminal" type="Container"]
anchor_right = 1.0
@ -34,38 +34,30 @@ __meta__ = {
[node name="Output" type="RichTextLabel" parent="Control"]
margin_right = 1920.0
margin_bottom = 1039.0
focus_mode = 2
margin_bottom = 1049.0
size_flags_vertical = 3
custom_styles/focus = SubResource( 1 )
custom_styles/normal = SubResource( 2 )
custom_fonts/normal_font = ExtResource( 1 )
custom_colors/selection_color = Color( 0.14902, 0.368627, 0.168627, 0.690196 )
scroll_following = true
selection_enabled = true
[node name="InputLine" type="HBoxContainer" parent="Control"]
margin_top = 1039.0
margin_top = 1049.0
margin_right = 1920.0
margin_bottom = 1080.0
[node name="Input" type="LineEdit" parent="Control/InputLine"]
margin_right = 1874.0
margin_bottom = 41.0
margin_right = 1892.0
margin_bottom = 31.0
size_flags_horizontal = 3
custom_styles/read_only = ExtResource( 3 )
custom_styles/focus = ExtResource( 3 )
custom_styles/normal = ExtResource( 3 )
custom_fonts/font = ExtResource( 1 )
caret_blink = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="CommandDropdown" type="MenuButton" parent="Control/InputLine"]
margin_left = 1878.0
margin_left = 1896.0
margin_right = 1920.0
margin_bottom = 41.0
margin_bottom = 31.0
custom_fonts/font = ExtResource( 1 )
text = "..."
flat = false
@ -80,17 +72,8 @@ margin_right = -10.0
custom_fonts/font = ExtResource( 1 )
text = "Clear"
[node name="TextEditor" type="TextEdit" parent="." instance=ExtResource( 5 )]
[node name="TextEditor" parent="." instance=ExtResource( 5 )]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
custom_fonts/font = ExtResource( 1 )
custom_colors/background_color = Color( 0, 0, 0, 1 )
text = "Text here"
syntax_highlighting = true
script = ExtResource( 4 )
__meta__ = {
"_edit_use_anchors_": false
}
syntax_highlighting = false
[connection signal="text_entered" from="Control/InputLine/Input" to="." method="send_command"]
[connection signal="pressed" from="ClearButton" to="." method="clear"]