Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental Scaling Approach #708

Draft
wants to merge 25 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
71b8be9
Adjust Add Node panel size and font size
Jowan-Spooner Aug 16, 2024
225c272
Implement better filtering and sorting in library search
Jowan-Spooner Aug 16, 2024
7701d92
Library Panel: Improve scroll to section
Jowan-Spooner Aug 16, 2024
0c694af
Initial Commit of better PreviewPanel menus
Jowan-Spooner Aug 20, 2024
326cac4
Implement new PixelMenuBar and remove old Context Menu
Jowan-Spooner Aug 20, 2024
265af53
Improvements to Pixel Menu Bar
Jowan-Spooner Aug 20, 2024
0c2954e
Implement new splines menu
Jowan-Spooner Aug 20, 2024
72be5d8
Small fixes
Jowan-Spooner Aug 20, 2024
52c7419
Implement new Lattice Menu Bar
Jowan-Spooner Aug 22, 2024
0b6a619
Improve Theming of MenuBar (and VSeparators)
Jowan-Spooner Aug 22, 2024
1a634f7
Try to improve theme once more...
Jowan-Spooner Aug 22, 2024
3ced8af
Improve Export menu
Jowan-Spooner Aug 22, 2024
8b4212d
Small fixes to preview 2D panel scene
Jowan-Spooner Aug 22, 2024
debd7d0
Fix PixelEdit in popup view
Jowan-Spooner Aug 22, 2024
433cff4
Implement Preview Lock Button and new Icons
Jowan-Spooner Sep 4, 2024
c205b70
Small cleanup/fixes
Jowan-Spooner Sep 4, 2024
0d51535
Cleanup + Small fixes
Jowan-Spooner Sep 4, 2024
9381486
Fix merge conflicts
Jowan-Spooner Sep 4, 2024
05f50e1
Fix Lock Icon
Jowan-Spooner Sep 4, 2024
621d4aa
Initial version of enhanced theme
Jowan-Spooner Sep 4, 2024
526a3f9
Huge Improvements
Jowan-Spooner Sep 4, 2024
424fc3d
More icon changes
Jowan-Spooner Sep 4, 2024
8442513
Fix export target file list
Jowan-Spooner Sep 5, 2024
b69f4c0
Add mouse icons
Jowan-Spooner Sep 5, 2024
81b7bd3
Fix icons in exported version
Jowan-Spooner Sep 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/flexible_layout/flexible_tab.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ var updating : bool = false


func _ready():
$Container/Close.texture_normal = get_theme_icon("close", "TabBar")
update()


func _notification(what):
match what:
NOTIFICATION_THEME_CHANGED:
Expand Down
17 changes: 8 additions & 9 deletions addons/flexible_layout/flexible_tab.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
[gd_scene load_steps=4 format=3 uid="uid://e06xegp2tp3f"]
[gd_scene load_steps=3 format=3 uid="uid://e06xegp2tp3f"]

[ext_resource type="Script" path="res://addons/flexible_layout/flexible_tab.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://xuy6dfh1rsne" path="res://addons/flexible_layout/undock.png" id="2_nx0qp"]

[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_bok24"]
size = Vector2(16, 16)
[ext_resource type="Script" path="res://material_maker/widgets/button_with_icon.gd" id="2_6yi0e"]

[node name="Tab" type="PanelContainer"]
offset_right = 41.0
Expand All @@ -26,19 +23,21 @@ layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 0

[node name="Undock" type="TextureButton" parent="Container"]
[node name="Undock" type="Button" parent="Container"]
visible = false
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
texture_normal = ExtResource("2_nx0qp")
script = ExtResource("2_6yi0e")
mm_icon = "Undock"

[node name="Close" type="TextureButton" parent="Container"]
[node name="Close" type="Button" parent="Container"]
visible = false
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
texture_normal = SubResource("PlaceholderTexture2D_bok24")
script = ExtResource("2_6yi0e")
mm_icon = "Cross"

[connection signal="pressed" from="Container/Undock" to="." method="_on_undock_pressed"]
[connection signal="pressed" from="Container/Close" to="." method="_on_close_pressed"]
4 changes: 2 additions & 2 deletions addons/material_maker/engine/nodes/gen_base.gd
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ func _ready() -> void:

static func get_default_generated_shader() -> ShaderCode:
var rv : ShaderCode = ShaderCode.new()
rv.output_type = "f"
rv.output_type = "rgba"
rv.output_values.f = "0.0"
rv.output_values.rgb = "vec3(0.0)"
rv.output_values.rgba = "vec4(0.0, 0.0, 0.0, 1.0)"
rv.output_values.rgba = "vec4(0.0, 0.0, 0.0, 0.0)"
return rv

func _post_load() -> void:
Expand Down
8 changes: 4 additions & 4 deletions export_presets.cfg

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions material_maker/globals.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ extends Node
# warning-ignore:unused_class_variable
var main_window

var ui_scale := 0.0

var config : ConfigFile = ConfigFile.new()
const DEFAULT_CONFIG : Dictionary = {
locale = "",
Expand Down
9 changes: 7 additions & 2 deletions material_maker/main_window.gd
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,10 @@ func on_config_changed() -> void:
# If scale is set to 0 (auto), scale everything if the display requires it (crude hiDPI support).
# This prevents UI elements from being too small on hiDPI displays.
ui_scale = 2 if DisplayServer.screen_get_dpi() >= 192 and DisplayServer.screen_get_size().x >= 2048 else 1
get_viewport().content_scale_factor = ui_scale
mm_globals.ui_scale = ui_scale
theme.scale = ui_scale
theme.update(self)
#get_viewport().content_scale_factor = ui_scale
#ProjectSettings.set_setting("display/window/stretch/scale", scale)

# Clamp to reasonable values to avoid crashes on startup.
Expand Down Expand Up @@ -470,7 +473,8 @@ func create_menu_set_theme(menu : MMMenuManager.MenuBase) -> void:
menu.connect_id_pressed(self._on_SetTheme_id_pressed)

func change_theme(theme_name) -> void:
theme = load("res://material_maker/theme/"+theme_name+".tres")
theme.base_theme = load("res://material_maker/theme/"+theme_name+".tres")
theme.update(self)
$NodeFactory.on_theme_changed()

func _on_SetTheme_id_pressed(id) -> void:
Expand Down Expand Up @@ -995,6 +999,7 @@ func update_preview_2d() -> void:
var generator : MMGenBase = null
var output_index : int = -1
if preview == null or not is_instance_valid(preview.generator):
previews[i].clear()
continue
generator = preview.generator
output_index = preview.output_index
Expand Down
25 changes: 16 additions & 9 deletions material_maker/main_window.tscn
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
[gd_scene load_steps=20 format=3 uid="uid://cgfeik04a5qqs"]
[gd_scene load_steps=22 format=3 uid="uid://cgfeik04a5qqs"]

[ext_resource type="Script" path="res://material_maker/main_window.gd" id="1"]
[ext_resource type="Script" path="res://material_maker/main_window_layout.gd" id="2"]
[ext_resource type="Script" path="res://material_maker/theme/enhanced_theme_system/enhanced_theme.gd" id="2_k42x1"]
[ext_resource type="PackedScene" uid="uid://eiq3i53x72m2" path="res://addons/flexible_layout/flexible_layout.tscn" id="6_ygla4"]
[ext_resource type="PackedScene" uid="uid://clw8sb0p8webl" path="res://material_maker/windows/add_node_popup/add_node_popup.tscn" id="7"]
[ext_resource type="PackedScene" uid="uid://bnqq3vhwmudkw" path="res://material_maker/projects_panel.tscn" id="7_ih0ps"]
[ext_resource type="Texture2D" uid="uid://c0j4px4n72di5" path="res://material_maker/icons/icons.tres" id="8"]
[ext_resource type="Script" path="res://material_maker/console.gd" id="8_1tb00"]
[ext_resource type="Script" path="res://material_maker/node_factory.gd" id="9"]
[ext_resource type="Theme" uid="uid://3f6cl7v1oyqo" path="res://material_maker/theme/default.tres" id="10"]
[ext_resource type="Script" path="res://material_maker/widgets/button_with_icon.gd" id="9_bj0xb"]
[ext_resource type="PackedScene" uid="uid://cp2mbbfmrv6sf" path="res://material_maker/widgets/render_counter/render_counter.tscn" id="11"]
[ext_resource type="PackedScene" uid="uid://dnttargjmhjh8" path="res://material_maker/tools/share/share_button.tscn" id="12"]
[ext_resource type="PackedScene" uid="uid://dmyq6xxfx88m0" path="res://material_maker/tools/environment_manager/environment_manager.tscn" id="13"]
[ext_resource type="Script" path="res://material_maker/tools/library_manager/library_manager.gd" id="14"]
[ext_resource type="Texture2D" path="res://material_maker/icons/paste_none.tres" id="15"]

[sub_resource type="Theme" id="Theme_iekvw"]
script = ExtResource("2_k42x1")
scale = 1.0
icon_color_swaps = []

[sub_resource type="GDScript" id="6"]
script/source = "extends Label

Expand Down Expand Up @@ -59,10 +65,6 @@ _data = {
"show": SubResource("7")
}

[sub_resource type="AtlasTexture" id="8"]
atlas = ExtResource("8")
region = Rect2(96, 128, 16, 16)

[sub_resource type="GDScript" id="9"]
script/source = "extends HBoxContainer

Expand Down Expand Up @@ -92,6 +94,10 @@ func _on_Timer_timeout():
tooltip_text = hint
"

[sub_resource type="AtlasTexture" id="8"]
atlas = ExtResource("8")
region = Rect2(96, 128, 16, 16)

[node name="MainWindow" type="PanelContainer" groups=["preview"]]
anchors_preset = 15
anchor_right = 1.0
Expand All @@ -104,7 +110,7 @@ grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
theme = ExtResource("10")
theme = SubResource("Theme_iekvw")
theme_type_variation = &"MM_MainBackground"
script = ExtResource("1")

Expand Down Expand Up @@ -205,12 +211,13 @@ libraries = {
"": SubResource("AnimationLibrary_kxf7t")
}

[node name="ConsoleButton" type="TextureButton" parent="VBoxContainer/StatusBar/HBox"]
[node name="ConsoleButton" type="Button" parent="VBoxContainer/StatusBar/HBox"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
tooltip_text = "Show console"
texture_normal = SubResource("8")
script = ExtResource("9_bj0xb")
mm_icon = "Console"

[node name="VSeparator1" type="VSeparator" parent="VBoxContainer/StatusBar/HBox"]
layout_mode = 2
Expand Down
8 changes: 4 additions & 4 deletions material_maker/main_window_layout.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ extends HBoxContainer

const PANELS = [
{ name="Library", scene=preload("res://material_maker/panels/library/library.tscn"), position="TopLeft" },
{ name="Preview2D", scene=preload("res://material_maker/panels/preview_2d/preview_2d_panel.tscn"), position="TopRight" },
{ name="Preview2D", scene=preload("res://material_maker/panels/preview_2d/preview_2d_panel.tscn"), position="TopRight" , parameters={preview_mode=1} },
{ name="Preview3D", scene=preload("res://material_maker/panels/preview_3d/preview_3d_panel.tscn"), position="BottomLeft" },
{ name="Preview2D (2)", scene=preload("res://material_maker/panels/preview_2d/preview_2d_panel.tscn"), position="BottomRight", parameters={ config_var_suffix="_2" } },
{ name="Preview2D (2)", scene=preload("res://material_maker/panels/preview_2d/preview_2d_panel.tscn"), position="BottomRight", parameters={preview_mode=2} },
{ name="Histogram", scene=preload("res://material_maker/widgets/histogram/histogram.tscn"), position="BottomRight" },
{ name="Hierarchy", scene=preload("res://material_maker/panels/hierarchy/hierarchy_panel.tscn"), position="TopRight" },
{ name="Reference", scene=preload("res://material_maker/panels/reference/reference_panel.tscn"), position="BottomLeft" },
{ name="Hierarchy", scene=preload("res://material_maker/panels/hierarchy/hierarchy_panel.tscn"), position="TopRight"},
{ name="Reference", scene=preload("res://material_maker/panels/reference/reference_panel.tscn"), position="BottomLeft"},
{ name="Brushes", scene=preload("res://material_maker/panels/brushes/brushes.tscn"), position="TopLeft" },
{ name="Layers", scene=preload("res://material_maker/panels/layers/layers.tscn"), position="BottomRight" },
{ name="Parameters", scene=preload("res://material_maker/panels/parameters/parameters.tscn"), position="TopRight" },
Expand Down
5 changes: 5 additions & 0 deletions material_maker/main_window_projects_panel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ extends Control
func get_projects():
return projects

func _notification(what: int) -> void:
if what == NOTIFICATION_THEME_CHANGED:
_on_projects_panel_resized()

func _on_projects_panel_resized():
$Projects/TabBar.size.y = 0
var preview_position : Vector2 = Vector2(0.0, 0.0)
var preview_size : Vector2 = size
preview_position.y += $Projects/TabBar.size.y
Expand Down
37 changes: 21 additions & 16 deletions material_maker/nodes/base.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ extends MMGraphNodeMinimal
class_name MMGraphNodeBase


var minimize_button : TextureButton
var randomness_button : TextureButton
var buffer_button : TextureButton
var minimize_button : Button
var randomness_button : Button
var buffer_button : Button

var show_inputs : bool = false
var show_outputs : bool = false


const MINIMIZE_ICON : Texture2D = preload("res://material_maker/icons/minimize.tres")
const RANDOMNESS_ICON : Texture2D = preload("res://material_maker/icons/randomness_unlocked.tres")
const RANDOMNESS_LOCKED_ICON : Texture2D = preload("res://material_maker/icons/randomness_locked.tres")
const BUFFER_ICON : Texture2D = preload("res://material_maker/icons/buffer.tres")
const BUFFER_PAUSED_ICON : Texture2D = preload("res://material_maker/icons/buffer_paused.tres")
const CUSTOM_ICON : Texture2D = preload("res://material_maker/icons/custom.png")
const PREVIEW_ICON : Texture2D = preload("res://material_maker/icons/preview.png")
const PREVIEW_LOCKED_ICON : Texture2D = preload("res://material_maker/icons/preview_locked.png")
const MINIMIZE_ICON := "Minimize"# = preload("res://material_maker/icons/minimize.tres")
const RANDOMNESS_ICON := "Dice" # Texture2D = preload("res://material_maker/icons/randomness_unlocked.tres")
const RANDOMNESS_LOCKED_ICON := "DiceLocked" # Texture2D = preload("res://material_maker/icons/randomness_locked.tres")
const BUFFER_ICON := "Buffer" # preload("res://material_maker/icons/buffer.tres")
const BUFFER_PAUSED_ICON := "BufferPaused" # preload("res://material_maker/icons/buffer_paused.tres")
const CUSTOM_ICON := "Dice" # preload("res://material_maker/icons/custom.png")
#const PREVIEW_ICON := "Dice" # preload("res://material_maker/icons/preview.png")
#const PREVIEW_LOCKED_ICON := "Dice" # preload("res://material_maker/icons/preview_locked.png")

const MENU_PROPAGATE_CHANGES : int = 1000
const MENU_SHARE_NODE : int = 1001
Expand Down Expand Up @@ -51,10 +51,11 @@ static func wrap_string(s : String, l : int = 50) -> String:

func _ready() -> void:
super._ready()
_notification(NOTIFICATION_THEME_CHANGED)
#_notification(NOTIFICATION_THEME_CHANGED)
gui_input.connect(self._on_gui_input)
update.call_deferred()


func init_buttons():
super.init_buttons()
minimize_button = add_button(MINIMIZE_ICON, on_minimize_pressed)
Expand All @@ -65,6 +66,8 @@ func init_buttons():
buffer_button = add_button(BUFFER_ICON, null, buffer_button_create_popup)
buffer_button.visible = false



func on_minimize_pressed():
generator.minimized = !generator.minimized
var hier_name = generator.get_hier_name()
Expand Down Expand Up @@ -114,18 +117,20 @@ func get_rendering_time_color(rendering_time : int) -> Color:
else:
return TIME_COLOR_BAD


func update():
super.update()
if generator != null and generator.has_randomness():
randomness_button.visible = true
randomness_button.texture_normal = RANDOMNESS_LOCKED_ICON if generator.is_seed_locked() else RANDOMNESS_ICON
randomness_button.mm_icon = RANDOMNESS_LOCKED_ICON if generator.is_seed_locked() else RANDOMNESS_ICON
else:
randomness_button.visible = false
buffer_button.visible = ! generator.get_buffers().is_empty()
if buffer_button.visible:
buffer_button.texture_normal = BUFFER_ICON if generator.get_buffers(MMGenBase.BUFFERS_PAUSED).is_empty() else BUFFER_PAUSED_ICON
buffer_button.mm_icon = BUFFER_ICON if generator.get_buffers(MMGenBase.BUFFERS_PAUSED).is_empty() else BUFFER_PAUSED_ICON
buffer_button.tooltip_text = tr("%d buffer(s), %d paused") % [ generator.get_buffers().size(), generator.get_buffers(MMGenBase.BUFFERS_PAUSED).size() ]


func _notification(what : int) -> void:
if what == NOTIFICATION_THEME_CHANGED:
on_theme_changed()
Expand Down Expand Up @@ -163,7 +168,7 @@ func _draw_port(slot_index: int, position: Vector2i, left: bool, color: Color):
var conn_pos1 = get_output_port_position(slot_index)
var conn_pos2 = get_output_port_position(min(slot_index+outputs[slot_index].group_size-1, outputs.size()-1))
draw_portgroup_stylebox(conn_pos1, conn_pos2)
draw_circle(position, 5, color, true, -1, true)
draw_circle(position, 5*mm_globals.ui_scale, color, true, -1, true)


func _draw() -> void:
Expand All @@ -172,7 +177,7 @@ func _draw() -> void:
var inputs = generator.get_input_defs()
var font : Font = get_theme_font("default_font")
if generator != null and generator.model == null and (generator is MMGenShader or generator is MMGenGraph):
draw_texture_rect(CUSTOM_ICON, Rect2(3, 8, 7, 7), false, color)
draw_texture_rect(get_theme_icon(CUSTOM_ICON, "MM_Icons"), Rect2(3, 8, 7, 7), false, color)
for i in range(inputs.size()):
if show_inputs:
var string : String = TranslationServer.translate(inputs[i].shortdesc) if inputs[i].has("shortdesc") else TranslationServer.translate(inputs[i].name)
Expand Down
34 changes: 13 additions & 21 deletions material_maker/nodes/edit_buttons.tscn
Original file line number Diff line number Diff line change
@@ -1,37 +1,29 @@
[gd_scene load_steps=6 format=3 uid="uid://cit68cso5187c"]
[gd_scene load_steps=3 format=3 uid="uid://cit68cso5187c"]

[ext_resource type="Script" path="res://material_maker/nodes/edit_buttons.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://c0j4px4n72di5" path="res://material_maker/icons/icons.tres" id="2"]

[sub_resource type="AtlasTexture" id="1"]
atlas = ExtResource("2")
region = Rect2(16, 16, 16, 16)
filter_clip = true

[sub_resource type="AtlasTexture" id="2"]
atlas = ExtResource("2")
region = Rect2(48, 16, 16, 16)

[sub_resource type="AtlasTexture" id="3"]
atlas = ExtResource("2")
region = Rect2(32, 16, 16, 16)
[ext_resource type="Script" path="res://material_maker/widgets/button_with_icon.gd" id="2_wosi8"]

[node name="NodeEditButtons" type="HBoxContainer"]
offset_right = 65.0
offset_bottom = 22.0
size_flags_horizontal = 3
alignment = 2
script = ExtResource("1")

[node name="Edit" type="Button" parent="."]
layout_mode = 2
icon = SubResource("1")
flat = true
tooltip_text = "Edit"
script = ExtResource("2_wosi8")
mm_icon = "Edit"

[node name="Load" type="Button" parent="."]
layout_mode = 2
icon = SubResource("2")
flat = true
tooltip_text = "Load"
script = ExtResource("2_wosi8")
mm_icon = "Folder"

[node name="Save" type="Button" parent="."]
layout_mode = 2
icon = SubResource("3")
flat = true
tooltip_text = "Save"
script = ExtResource("2_wosi8")
mm_icon = "Save"
Loading