mirror of
https://github.com/Relintai/material-maker.git
synced 2024-12-23 21:16:54 +01:00
Added a menu to select UI theme, with 3 themes (that must be cleaned up)
This commit is contained in:
parent
4c361505c1
commit
6a8696b2fb
File diff suppressed because one or more lines are too long
@ -18,6 +18,8 @@ onready var preview_3d = $VBoxContainer/HBoxContainer/VBoxContainer/Preview/Prev
|
||||
|
||||
const RECENT_FILES_COUNT = 15
|
||||
|
||||
const THEMES = [ "Dark", "Default", "Light" ]
|
||||
|
||||
const MENU = [
|
||||
{ menu="File", command="new_material", description="New material" },
|
||||
{ menu="File", command="load_material", shortcut="Control+O", description="Load material" },
|
||||
@ -36,6 +38,8 @@ const MENU = [
|
||||
{ menu="Edit", command="edit_copy", shortcut="Control+C", description="Copy" },
|
||||
{ menu="Edit", command="edit_paste", shortcut="Control+V", description="Paste" },
|
||||
{ menu="Edit", command="edit_duplicate", shortcut="Control+D", description="Duplicate" },
|
||||
{ menu="Edit" },
|
||||
{ menu="Edit", submenu="set_theme", description="Set theme" },
|
||||
|
||||
{ menu="View", command="view_center", shortcut="C", description="Center view" },
|
||||
{ menu="View", command="view_reset_zoom", shortcut="Control+0", description="Reset zoom" },
|
||||
@ -61,19 +65,22 @@ var is_mac = false
|
||||
func _ready() -> void:
|
||||
# Restore the window position/size if values are present in the configuration cache
|
||||
config_cache.load("user://cache.ini")
|
||||
if Engine.editor_hint:
|
||||
set_process_input(false)
|
||||
else:
|
||||
if config_cache.has_section_key("window", "screen"):
|
||||
OS.current_screen = config_cache.get_value("window", "screen")
|
||||
if config_cache.has_section_key("window", "maximized"):
|
||||
OS.window_maximized = config_cache.get_value("window", "maximized")
|
||||
if config_cache.has_section_key("window", "screen"):
|
||||
OS.current_screen = config_cache.get_value("window", "screen")
|
||||
if config_cache.has_section_key("window", "maximized"):
|
||||
OS.window_maximized = config_cache.get_value("window", "maximized")
|
||||
|
||||
if !OS.window_maximized:
|
||||
if config_cache.has_section_key("window", "position"):
|
||||
OS.window_position = config_cache.get_value("window", "position")
|
||||
if config_cache.has_section_key("window", "size"):
|
||||
OS.window_size = config_cache.get_value("window", "size")
|
||||
|
||||
if !OS.window_maximized:
|
||||
if config_cache.has_section_key("window", "position"):
|
||||
OS.window_position = config_cache.get_value("window", "position")
|
||||
if config_cache.has_section_key("window", "size"):
|
||||
OS.window_size = config_cache.get_value("window", "size")
|
||||
# Restore the theme
|
||||
var theme_name : String = "default"
|
||||
if config_cache.has_section_key("window", "theme"):
|
||||
theme_name = config_cache.get_value("window", "theme")
|
||||
set_theme(theme_name)
|
||||
|
||||
if OS.get_name() == "OSX":
|
||||
is_mac = true
|
||||
@ -103,8 +110,7 @@ func _ready() -> void:
|
||||
# This property is only available in 3.2alpha or later, so use `set()` to fail gracefully if it doesn't exist.
|
||||
OS.set("min_window_size", Vector2(1024, 600))
|
||||
|
||||
if !Engine.editor_hint:
|
||||
OS.set_window_title(ProjectSettings.get_setting("application/config/name")+" v"+ProjectSettings.get_setting("application/config/release"))
|
||||
OS.set_window_title(ProjectSettings.get_setting("application/config/name")+" v"+ProjectSettings.get_setting("application/config/release"))
|
||||
load_recents()
|
||||
for m in $VBoxContainer/Menu.get_children():
|
||||
var menu = m.get_popup()
|
||||
@ -194,6 +200,21 @@ func add_recent(path) -> void:
|
||||
f.store_string(to_json(recent_files))
|
||||
f.close()
|
||||
|
||||
func create_menu_set_theme(menu) -> void:
|
||||
menu.clear()
|
||||
for t in THEMES:
|
||||
menu.add_item(t)
|
||||
if !menu.is_connected("id_pressed", self, "_on_SetTheme_id_pressed"):
|
||||
menu.connect("id_pressed", self, "_on_SetTheme_id_pressed")
|
||||
|
||||
func set_theme(theme_name) -> void:
|
||||
theme = load("res://material_maker/theme/"+theme_name+".tres")
|
||||
|
||||
func _on_SetTheme_id_pressed(id) -> void:
|
||||
var theme_name : String = THEMES[id].to_lower()
|
||||
set_theme(theme_name)
|
||||
config_cache.set_value("window", "theme", theme_name)
|
||||
|
||||
func create_menu_create(menu) -> void:
|
||||
var gens = MMGenLoader.get_generator_list()
|
||||
menu.clear()
|
||||
@ -295,11 +316,8 @@ func export_material_is_disabled() -> bool:
|
||||
return graph_edit == null or graph_edit.save_path == null
|
||||
|
||||
func quit() -> void:
|
||||
if Engine.editor_hint:
|
||||
emit_signal("quit")
|
||||
else:
|
||||
dim_window()
|
||||
get_tree().quit()
|
||||
dim_window()
|
||||
get_tree().quit()
|
||||
|
||||
func edit_cut() -> void:
|
||||
var graph_edit : MMGraphEdit = get_current_graph_edit()
|
||||
@ -521,17 +539,15 @@ func _on_Projects_tab_changed(tab) -> void:
|
||||
|
||||
func _exit_tree() -> void:
|
||||
# Save the window position and size to remember it when restarting the application
|
||||
if !Engine.editor_hint:
|
||||
config_cache.set_value("window", "screen", OS.current_screen)
|
||||
config_cache.set_value("window", "maximized", OS.window_maximized || OS.window_fullscreen)
|
||||
config_cache.set_value("window", "position", OS.window_position)
|
||||
config_cache.set_value("window", "size", OS.window_size)
|
||||
config_cache.save("user://cache.ini")
|
||||
config_cache.set_value("window", "screen", OS.current_screen)
|
||||
config_cache.set_value("window", "maximized", OS.window_maximized || OS.window_fullscreen)
|
||||
config_cache.set_value("window", "position", OS.window_position)
|
||||
config_cache.set_value("window", "size", OS.window_size)
|
||||
config_cache.save("user://cache.ini")
|
||||
|
||||
func _notification(what : int) -> void:
|
||||
if !Engine.editor_hint:
|
||||
if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST:
|
||||
dim_window()
|
||||
if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST:
|
||||
dim_window()
|
||||
|
||||
func dim_window() -> void:
|
||||
# Darken the UI to denote that the application is currently exiting
|
||||
|
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=12 format=2]
|
||||
[gd_scene load_steps=13 format=2]
|
||||
|
||||
[ext_resource path="res://material_maker/main_window.gd" type="Script" id=1]
|
||||
[ext_resource path="res://material_maker/library.tscn" type="PackedScene" id=2]
|
||||
@ -9,6 +9,7 @@
|
||||
[ext_resource path="res://material_maker/widgets/add_node_popup.tscn" type="PackedScene" id=7]
|
||||
[ext_resource path="res://material_maker/icons/icons.svg" type="Texture" id=8]
|
||||
[ext_resource path="res://material_maker/node_factory.gd" type="Script" id=9]
|
||||
[ext_resource path="res://material_maker/theme/default.tres" type="Theme" id=10]
|
||||
|
||||
[sub_resource type="AtlasTexture" id=1]
|
||||
flags = 4
|
||||
@ -25,6 +26,7 @@ anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme = ExtResource( 10 )
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
@ -39,14 +41,17 @@ margin_right = -6.0
|
||||
margin_bottom = -6.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Menu" type="HBoxContainer" parent="VBoxContainer"]
|
||||
margin_right = 1268.0
|
||||
margin_bottom = 20.0
|
||||
margin_bottom = 22.0
|
||||
|
||||
[node name="File" type="MenuButton" parent="VBoxContainer/Menu"]
|
||||
margin_right = 35.0
|
||||
margin_bottom = 20.0
|
||||
margin_bottom = 22.0
|
||||
text = "File"
|
||||
items = [ "New material", null, 0, false, false, 0, 0, null, "", false, "Load material", null, 0, false, false, 1, 268435535, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Save material", null, 0, false, false, 4, 268435539, null, "", false, "Save material as...", null, 0, false, false, 5, 301989971, null, "", false, "Save all materials...", null, 0, false, false, 6, 0, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Export material", null, 0, false, false, 8, 268435525, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Close material", null, 0, false, false, 10, 0, null, "", false, "Quit", null, 0, false, false, 11, 268435537, null, "", false ]
|
||||
switch_on_hover = true
|
||||
@ -54,7 +59,7 @@ switch_on_hover = true
|
||||
[node name="Edit" type="MenuButton" parent="VBoxContainer/Menu"]
|
||||
margin_left = 39.0
|
||||
margin_right = 75.0
|
||||
margin_bottom = 20.0
|
||||
margin_bottom = 22.0
|
||||
text = "Edit"
|
||||
items = [ "Cut", null, 0, false, false, 12, 268435544, null, "", false, "Copy", null, 0, false, false, 13, 268435523, null, "", false, "Paste", null, 0, false, false, 14, 268435542, null, "", false, "Duplicate", null, 0, false, false, 15, 268435524, null, "", false ]
|
||||
switch_on_hover = true
|
||||
@ -62,7 +67,7 @@ switch_on_hover = true
|
||||
[node name="View" type="MenuButton" parent="VBoxContainer/Menu"]
|
||||
margin_left = 79.0
|
||||
margin_right = 121.0
|
||||
margin_bottom = 20.0
|
||||
margin_bottom = 22.0
|
||||
text = "View"
|
||||
items = [ "Center view", null, 0, false, false, 16, 67, null, "", false, "Reset zoom", null, 0, false, false, 17, 268435504, null, "", false ]
|
||||
switch_on_hover = true
|
||||
@ -70,7 +75,7 @@ switch_on_hover = true
|
||||
[node name="Tools" type="MenuButton" parent="VBoxContainer/Menu"]
|
||||
margin_left = 125.0
|
||||
margin_right = 171.0
|
||||
margin_bottom = 20.0
|
||||
margin_bottom = 22.0
|
||||
text = "Tools"
|
||||
items = [ "Create", null, 0, false, false, 0, 0, null, "PopupMenu", false, "Create group", null, 0, false, false, 19, 268435527, null, "", false, "Make selected nodes editable", null, 0, false, false, 20, 268435543, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Add selected node to user library", null, 0, false, false, 22, 0, null, "", false, "Export the nodes library", null, 0, false, false, 23, 0, null, "", false ]
|
||||
switch_on_hover = true
|
||||
@ -78,51 +83,55 @@ switch_on_hover = true
|
||||
[node name="Help" type="MenuButton" parent="VBoxContainer/Menu"]
|
||||
margin_left = 175.0
|
||||
margin_right = 217.0
|
||||
margin_bottom = 20.0
|
||||
margin_bottom = 22.0
|
||||
text = "Help"
|
||||
items = [ "User manual", null, 0, false, false, 24, 16777244, null, "", false, "Show selected library item documentation", null, 0, false, false, 25, 285212700, null, "", false, "Report a bug", null, 0, false, false, 26, 0, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "About", null, 0, false, false, 28, 0, null, "", false ]
|
||||
switch_on_hover = true
|
||||
|
||||
[node name="HBoxContainer" type="HSplitContainer" parent="VBoxContainer"]
|
||||
margin_top = 24.0
|
||||
margin_top = 26.0
|
||||
margin_right = 1268.0
|
||||
margin_bottom = 708.0
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="VBoxContainer" type="VSplitContainer" parent="VBoxContainer/HBoxContainer"]
|
||||
margin_right = 311.0
|
||||
margin_bottom = 684.0
|
||||
margin_right = 313.0
|
||||
margin_bottom = 682.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Library" parent="VBoxContainer/HBoxContainer/VBoxContainer" instance=ExtResource( 2 )]
|
||||
margin_right = 311.0
|
||||
margin_bottom = 386.0
|
||||
margin_right = 313.0
|
||||
margin_bottom = 390.0
|
||||
size_flags_vertical = 3
|
||||
size_flags_stretch_ratio = 1.5
|
||||
|
||||
[node name="Preview" type="TabContainer" parent="VBoxContainer/HBoxContainer/VBoxContainer"]
|
||||
margin_top = 398.0
|
||||
margin_right = 311.0
|
||||
margin_bottom = 684.0
|
||||
margin_right = 313.0
|
||||
margin_bottom = 682.0
|
||||
tab_align = 0
|
||||
|
||||
[node name="Preview2D" parent="VBoxContainer/HBoxContainer/VBoxContainer/Preview" instance=ExtResource( 3 )]
|
||||
margin_left = 4.0
|
||||
margin_top = 32.0
|
||||
margin_right = -4.0
|
||||
margin_bottom = -4.0
|
||||
margin_left = 5.0
|
||||
margin_top = 29.0
|
||||
margin_right = -5.0
|
||||
margin_bottom = -5.0
|
||||
rect_min_size = Vector2( 250, 250 )
|
||||
|
||||
[node name="Preview3D" parent="VBoxContainer/HBoxContainer/VBoxContainer/Preview" instance=ExtResource( 4 )]
|
||||
margin_left = 5.0
|
||||
margin_top = 29.0
|
||||
margin_right = -5.0
|
||||
margin_bottom = -5.0
|
||||
rect_min_size = Vector2( 250, 250 )
|
||||
|
||||
[node name="Preview3DUI" parent="VBoxContainer/HBoxContainer/VBoxContainer/Preview/Preview3D" instance=ExtResource( 5 )]
|
||||
|
||||
[node name="ProjectsPane" type="Control" parent="VBoxContainer/HBoxContainer"]
|
||||
margin_left = 323.0
|
||||
margin_left = 321.0
|
||||
margin_right = 1268.0
|
||||
margin_bottom = 684.0
|
||||
margin_bottom = 682.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
size_flags_stretch_ratio = 3.0
|
||||
@ -166,7 +175,7 @@ custom_constants/separation = 7
|
||||
|
||||
[node name="Button" type="Button" parent="VBoxContainer/HBoxContainer/ProjectsPane/HBoxContainer"]
|
||||
margin_right = 44.0
|
||||
margin_bottom = 38.0
|
||||
margin_bottom = 40.0
|
||||
hint_tooltip = "Show 3D preview"
|
||||
toggle_mode = true
|
||||
icon = SubResource( 1 )
|
||||
|
12358
material_maker/theme/dark.tres
Normal file
12358
material_maker/theme/dark.tres
Normal file
File diff suppressed because one or more lines are too long
12225
material_maker/theme/default.tres
Normal file
12225
material_maker/theme/default.tres
Normal file
File diff suppressed because one or more lines are too long
12366
material_maker/theme/light.tres
Normal file
12366
material_maker/theme/light.tres
Normal file
File diff suppressed because one or more lines are too long
@ -48,7 +48,7 @@ func item_selected(index) -> void:
|
||||
add_node(data[index])
|
||||
hide()
|
||||
|
||||
func hide()->void:
|
||||
func hide() -> void:
|
||||
.hide()
|
||||
|
||||
# clearing the quick connect data after hiding to prevent unintended autoconnection
|
||||
|
@ -177,6 +177,7 @@ _global_script_class_icons={
|
||||
[application]
|
||||
|
||||
config/name="Material Maker"
|
||||
config/description="An open source, extensible procedural material generation tool"
|
||||
run/main_scene="res://material_maker/main_window.tscn"
|
||||
config/use_custom_user_dir=true
|
||||
config/custom_user_dir_name="material_maker"
|
||||
@ -184,7 +185,6 @@ boot_splash/image="res://rodz_labs_logo.png"
|
||||
boot_splash/fullsize=false
|
||||
boot_splash/bg_color=Color( 0.0901961, 0.0941176, 0.141176, 1 )
|
||||
config/icon="res://icon.png"
|
||||
config/description="An open source, extensible procedural material generation tool"
|
||||
config/release="0.8"
|
||||
|
||||
[autoload]
|
||||
|
Loading…
Reference in New Issue
Block a user