mirror of
https://github.com/Relintai/pandemonium_paint_experimental.git
synced 2024-11-07 16:52:10 +01:00
Class design mockup. I think this will fix every issue with the current paint module. It's main downside will be that it will depend on the editor a lot more, so it will need to have more code if it needs to run in-app (not that much more code though, and mostly copy paste level stuff).
This commit is contained in:
parent
9e66142af8
commit
6058ab8b49
@ -1,3 +0,0 @@
|
|||||||
[gd_scene format=2]
|
|
||||||
|
|
||||||
[node name="Node2D" type="Node2D"]
|
|
21
game/PaintCanvas.gd
Normal file
21
game/PaintCanvas.gd
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
extends Node2D
|
||||||
|
|
||||||
|
# Canvas that can be used to draw on
|
||||||
|
|
||||||
|
# Should probably store it's actual data in an lz4 compressed poolvector property
|
||||||
|
# like what voxelman does
|
||||||
|
|
||||||
|
# Undo history should be handled by the editor itself
|
||||||
|
|
||||||
|
# It could use the paint module's actions for manipulation
|
||||||
|
|
||||||
|
# it could have a drag and drop image property so things can be dropped into it
|
||||||
|
|
||||||
|
# could be "infinite", so ti does not need to mess with resizes -> needs chunks though
|
||||||
|
# if needed this should likely be an another class, like an InifinePaintCanvas or ChunkedPaintCanvas
|
||||||
|
|
||||||
|
# better for now:
|
||||||
|
# it could have it's own size -> when added to the tree it should copy the size of it's
|
||||||
|
# parent paint project
|
||||||
|
# then it should have a resize button with properties, ot it's sidebar module should have a button
|
||||||
|
# + popup to handle resizes
|
11
game/PaintCurve.gd
Normal file
11
game/PaintCurve.gd
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
extends Path2D
|
||||||
|
|
||||||
|
export(int, "append,union,sub,simdiff,etc...") var operation : int = 0
|
||||||
|
|
||||||
|
# The renderer should process each child one by one in tree order
|
||||||
|
# A render needs to start with a curve with an append operation
|
||||||
|
# apply all non append curves to the last append curve
|
||||||
|
# render it when out of children or when the next append curve is reached
|
||||||
|
|
||||||
|
# It could just render only one append curves aswell, it could warn if you have more than one
|
||||||
|
# This will need testing
|
7
game/PaintGroup.gd
Normal file
7
game/PaintGroup.gd
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
extends Node2D
|
||||||
|
|
||||||
|
# Collects all child PaintNodes and renders them to it's texture
|
||||||
|
# updates tex when a child changes
|
||||||
|
# PaintNodes will need to signal their parents when they changed
|
||||||
|
|
||||||
|
# update should run in process to save potential cycles
|
8
game/PaintNode.gd
Normal file
8
game/PaintNode.gd
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
extends Node
|
||||||
|
# PaintNode
|
||||||
|
# base class for paint related classes
|
||||||
|
|
||||||
|
# should inherit either Node2D or CanvasItem directly
|
||||||
|
# Node2D is probably better
|
||||||
|
|
||||||
|
#
|
27
game/PaintProject.gd
Normal file
27
game/PaintProject.gd
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
tool
|
||||||
|
extends Node2D #PaintNode
|
||||||
|
|
||||||
|
export(Vector2i) var image_size : Vector2i = Vector2i(64, 64)
|
||||||
|
|
||||||
|
export(String) var image_file_name : String
|
||||||
|
export(int, "png") var image_type : int
|
||||||
|
|
||||||
|
# manages Grid, and BG's size
|
||||||
|
# also lets you hide them, so custom ones can be created
|
||||||
|
# could have an api to register backgorund layers and then it will resize them
|
||||||
|
|
||||||
|
# Image size will only affect rendering at the end when saving the image
|
||||||
|
|
||||||
|
func save_image() -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
func _get_property_list() -> Array:
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"type": TYPE_NIL,
|
||||||
|
"name": "save_image",
|
||||||
|
"hint": PROPERTY_HINT_BUTTON,
|
||||||
|
"hint_string": "save_image:Save/EditorIcons"
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
96
game/PaintProjectMockup.tscn
Normal file
96
game/PaintProjectMockup.tscn
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
[gd_scene load_steps=8 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://PaintProject.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://PaintCanvas.gd" type="Script" id=2]
|
||||||
|
[ext_resource path="res://PaintRenderer.gd" type="Script" id=3]
|
||||||
|
[ext_resource path="res://PaintCurve.gd" type="Script" id=4]
|
||||||
|
[ext_resource path="res://PaintGroup.gd" type="Script" id=5]
|
||||||
|
[ext_resource path="res://Paintfilter.gd" type="Script" id=6]
|
||||||
|
|
||||||
|
[sub_resource type="Curve2D" id=1]
|
||||||
|
_data = {
|
||||||
|
"points": PoolVector2Array( -126.479, 82.1171, 126.479, -82.1171, 239, 28, 0, 0, 0, 0, 461, 58, 0, 0, 0, 0, 491, 198, 0, 0, 0, 0, 494, 346, 0, 0, 0, 0, 107, 431, 0, 0, 0, 0, 43, 257, 0, 0, 0, 0, 201, 99, 0, 0, 0, 0, 242, 75, 0, 0, 0, 0, 214, 282, 0, 0, 0, 0, 329, 186, 0, 0, 0, 0, 368, 121, 0, 0, 0, 0, 338, 82, 0, 0, 0, 0, 284, 62, 0, 0, 0, 0, 239, 28 )
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="PaintProject (PaintNode)" type="Node2D"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
save_image = null
|
||||||
|
|
||||||
|
[node name="Grid (hidden)" type="Node" parent="."]
|
||||||
|
|
||||||
|
[node name="BG (hidden)" type="Node" parent="."]
|
||||||
|
|
||||||
|
[node name="PaintCanvas" type="Node2D" parent="."]
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="PaintCanvas2" type="Node2D" parent="."]
|
||||||
|
|
||||||
|
[node name="PaintGroup" type="Node2D" parent="."]
|
||||||
|
|
||||||
|
[node name="PaintCanvas3" type="Node2D" parent="PaintGroup"]
|
||||||
|
|
||||||
|
[node name="PaintCanvas4" type="Node2D" parent="PaintGroup"]
|
||||||
|
|
||||||
|
[node name="PaintGroup" type="Node2D" parent="PaintGroup"]
|
||||||
|
script = ExtResource( 5 )
|
||||||
|
|
||||||
|
[node name="PaintCurveRender" type="Node2D" parent="PaintGroup/PaintGroup"]
|
||||||
|
__meta__ = {
|
||||||
|
"_editor_description_": "I'm hoping to use the built in svg renderer to rasterize curves. If it works, it will be a huge timesave. Should foreach children and apply them one by one based on their operation setting."
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="PaintCurve" type="Path2D" parent="PaintGroup/PaintGroup/PaintCurveRender"]
|
||||||
|
curve = SubResource( 1 )
|
||||||
|
script = ExtResource( 4 )
|
||||||
|
__meta__ = {
|
||||||
|
"_editor_description_": ""
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="PaintPathObject" type="Node2D" parent="PaintGroup/PaintGroup"]
|
||||||
|
__meta__ = {
|
||||||
|
"_editor_description_": "Maybe"
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="PaintCurveRender2" type="Node2D" parent="PaintGroup/PaintGroup"]
|
||||||
|
|
||||||
|
[node name="PaintCurve" type="Path2D" parent="PaintGroup/PaintGroup/PaintCurveRender2"]
|
||||||
|
curve = SubResource( 1 )
|
||||||
|
script = ExtResource( 4 )
|
||||||
|
__meta__ = {
|
||||||
|
"_editor_description_": ""
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="PaintCurve1" type="Path2D" parent="PaintGroup/PaintGroup/PaintCurveRender2"]
|
||||||
|
curve = SubResource( 1 )
|
||||||
|
script = ExtResource( 4 )
|
||||||
|
__meta__ = {
|
||||||
|
"_editor_description_": ""
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="PaintCurve2" type="Path2D" parent="PaintGroup/PaintGroup/PaintCurveRender2"]
|
||||||
|
curve = SubResource( 1 )
|
||||||
|
script = ExtResource( 4 )
|
||||||
|
__meta__ = {
|
||||||
|
"_editor_description_": "Union'd with PaintCurve1."
|
||||||
|
}
|
||||||
|
operation = 1
|
||||||
|
|
||||||
|
[node name="PaintGroup" type="Node2D" parent="PaintGroup/PaintGroup"]
|
||||||
|
|
||||||
|
[node name="PaintCanvas6" type="Node2D" parent="PaintGroup/PaintGroup/PaintGroup"]
|
||||||
|
|
||||||
|
[node name="PaintCanvas7" type="Node2D" parent="PaintGroup/PaintGroup/PaintGroup"]
|
||||||
|
|
||||||
|
[node name="PaintCanvas7" type="Node2D" parent="PaintGroup"]
|
||||||
|
|
||||||
|
[node name="PaintRenderer" type="Node2D" parent="PaintGroup"]
|
||||||
|
script = ExtResource( 3 )
|
||||||
|
|
||||||
|
[node name="PaintFilter" type="Node2D" parent="PaintGroup"]
|
||||||
|
script = ExtResource( 6 )
|
||||||
|
|
||||||
|
[node name="PaintCanvas8" type="Node2D" parent="PaintGroup/PaintFilter"]
|
||||||
|
|
||||||
|
[node name="PaintCanvas9" type="Node2D" parent="PaintGroup/PaintFilter"]
|
||||||
|
|
||||||
|
[node name="PaintCanvas10" type="Node2D" parent="PaintGroup/PaintFilter"]
|
9
game/PaintRenderer.gd
Normal file
9
game/PaintRenderer.gd
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
extends Node2D
|
||||||
|
|
||||||
|
# inherith from PaintNode
|
||||||
|
|
||||||
|
# could be a thin base class for things that just render something
|
||||||
|
# like noises etc
|
||||||
|
# could have one for MMMaterial interp
|
||||||
|
|
||||||
|
# over PaintNode they would just store and remember their parent PaintProject's size
|
7
game/Paintfilter.gd
Normal file
7
game/Paintfilter.gd
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
extends Node2D
|
||||||
|
|
||||||
|
# inherits from PaintGroup
|
||||||
|
# Same as PaintGroup except applies a filter to it's output
|
||||||
|
# good for non destructive editing
|
||||||
|
|
||||||
|
# Could also do resampling, resizing, shringking etc
|
18
game/editor.gd
Normal file
18
game/editor.gd
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
# Paint editor module
|
||||||
|
|
||||||
|
# Sidebar
|
||||||
|
|
||||||
|
# 1 class
|
||||||
|
# by default it should have the color grid, and a color chooser, and module support
|
||||||
|
# modules could be added for paintnode derived classes
|
||||||
|
# it just forwards the currect selction to hem so they can
|
||||||
|
# handle whether they want to be shown for a particular class
|
||||||
|
|
||||||
|
# should have customizable location (left / right) Voxelman has the code
|
||||||
|
|
||||||
|
# Other
|
||||||
|
|
||||||
|
# the top file new etc menu is not needed, as now all of that are going to be handled via nodes and
|
||||||
|
# the editor's functionality
|
Loading…
Reference in New Issue
Block a user