Also convert the leftover dialogs.

This commit is contained in:
Relintai 2022-04-15 20:05:56 +02:00
parent e70fb4a67e
commit 60048f3602
10 changed files with 385 additions and 140 deletions

View File

@ -1,28 +0,0 @@
extends AcceptDialog
tool
func _ready():
yield(owner, "ready")
find_node("GridValue").value = owner.paint_canvas.grid_size
find_node("BigGridValue").value = owner.paint_canvas.big_grid_size
func _on_ChangeGridSizeDialog_confirmed():
var grid_size = find_node("GridValue").value
var big_grid_size = find_node("BigGridValue").value
owner.paint_canvas.grid_size = grid_size
owner.paint_canvas.big_grid_size = big_grid_size
func _on_GridValue_value_changed(value):
var grid_size = value
owner.paint_canvas.grid_size = grid_size
func _on_BigGridValue_value_changed(value):
var big_grid_size = value
owner.paint_canvas.big_grid_size = big_grid_size
func _on_ChangeGridSizeDialog_visibility_changed():
pass # Replace with function body.

View File

@ -1,20 +0,0 @@
extends ConfirmationDialog
tool
func _ready():
yield(owner, "ready")
find_node("Width").value = owner.paint_canvas.canvas_width
find_node("Height").value = owner.paint_canvas.canvas_height
func _on_ConfirmationDialog_confirmed():
var width = find_node("Width").value
var height = find_node("Height").value
print("change canvas size: ", width, " ", height)
owner.paint_canvas.resize(width, height)
func _on_ChangeCanvasSize_visibility_changed():
if visible:
find_node("Width").value = owner.paint_canvas.canvas_width
find_node("Height").value = owner.paint_canvas.canvas_height

View File

@ -1,70 +0,0 @@
tool
extends FileDialog
var canvas: GECanvas
var file_path = ""
func _ready():
get_line_edit().connect("text_entered", self, "_on_LineEdit_text_entered")
invalidate()
clear_filters()
add_filter("*.png ; PNG Images")
func _on_LineEdit_text_entered(_text):
return
# print(_text)
#load_img()
# print("hsadfasd")
func _on_LoadFileDialog_file_selected(path):
file_path = path
#print("1ere")
load_img()
func _on_LoadFileDialog_confirmed():
return
#print("ere")
#load_img()
func load_img():
var image = Image.new()
if image.load(file_path) != OK:
print("couldn't load image!")
return
var image_data = image.get_data()
var layer: GELayer = owner.add_new_layer()
var width = image.get_width()
var height = image.get_height()
if owner.paint_canvas.canvas_width < width:
owner.paint_canvas.resize(width, owner.paint_canvas.canvas_height)
if owner.paint_canvas.canvas_height < height:
owner.paint_canvas.resize(owner.paint_canvas.canvas_width, height)
for i in range(image_data.size() / 4):
var color = Color(image_data[i*4] / 255.0, image_data[i*4+1] / 255.0, image_data[i*4+2] / 255.0, image_data[i*4+3] / 255.0)
var pos = GEUtils.to_2D(i, image.get_width())
if pos.x > layer.layer_width:
continue
layer.set_pixel(pos.x, pos.y, color)
layer.update_texture()
func _on_LoadFileDialog_about_to_show():
invalidate()
func _on_LoadFileDialog_visibility_changed():
invalidate()

View File

@ -1,22 +0,0 @@
[gd_scene load_steps=2 format=2]
[sub_resource type="GDScript" id=1]
script/source = "extends ConfirmationDialog
func _ready():
get_ok().connect(\"pressed\", self, \"hide\")
get_cancel().connect(\"pressed\", self, \"hide\")
"
[node name="LoadFileDialog" type="FileDialog"]
margin_right = 604.0
margin_bottom = 367.0
window_title = "Open a File"
mode = 0
access = 2
current_dir = "/Projects/BitBucket/GraphicsEditor"
current_path = "/Projects/BitBucket/GraphicsEditor/"
script = SubResource( 1 )

View File

@ -0,0 +1,57 @@
/*
Copyright (c) 2019 Flairieve
Copyright (c) 2020-2022 cobrapitz
Copyright (c) 2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "paint_canvas_dialog.h"
void PaintCanvasDialog::_ready() {
/*
yield(owner, "ready")
find_node("Width").value = owner.paint_canvas.canvas_width
find_node("Height").value = owner.paint_canvas.canvas_height
*/
}
void PaintCanvasDialog::_on_ConfirmationDialog_confirmed() {
/*
var width = find_node("Width").value
var height = find_node("Height").value
print("change canvas size: ", width, " ", height)
owner.paint_canvas.resize(width, height)
*/
}
void PaintCanvasDialog::_on_ChangeCanvasSize_visibility_changed() {
/*
if visible:
find_node("Width").value = owner.paint_canvas.canvas_width
find_node("Height").value = owner.paint_canvas.canvas_height
*/
}
PaintCanvasDialog::PaintCanvasDialog() {
}
PaintCanvasDialog::~PaintCanvasDialog() {
}
void PaintCanvasDialog::_bind_methods() {
}

View File

@ -0,0 +1,45 @@
#ifndef PAINT_CANVAS_DIALOG_H
#define PAINT_CANVAS_DIALOG_H
/*
Copyright (c) 2019 Flairieve
Copyright (c) 2020-2022 cobrapitz
Copyright (c) 2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "scene/gui/dialogs.h"
class PaintCanvasDialog : public ConfirmationDialog {
GDCLASS(PaintCanvasDialog, ConfirmationDialog);
public:
void _ready();
void _on_ConfirmationDialog_confirmed();
void _on_ChangeCanvasSize_visibility_changed();
PaintCanvasDialog();
~PaintCanvasDialog();
protected:
static void _bind_methods();
};
#endif

View File

@ -0,0 +1,63 @@
/*
Copyright (c) 2019 Flairieve
Copyright (c) 2020-2022 cobrapitz
Copyright (c) 2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "paint_change_grid_size_dialog.h"
void PaintChangeGridSizeDialog::_ready() {
/*
yield(owner, "ready")
find_node("GridValue").value = owner.paint_canvas.grid_size
find_node("BigGridValue").value = owner.paint_canvas.big_grid_size
*/
}
void PaintChangeGridSizeDialog::_on_ChangeGridSizeDialog_confirmed() {
/*
var grid_size = find_node("GridValue").value
var big_grid_size = find_node("BigGridValue").value
owner.paint_canvas.grid_size = grid_size
owner.paint_canvas.big_grid_size = big_grid_size
*/
}
void PaintChangeGridSizeDialog::_on_GridValue_value_changed(float value) {
/*
var grid_size = value
owner.paint_canvas.grid_size = grid_size
*/
}
void PaintChangeGridSizeDialog::_on_BigGridValue_value_changed(float value) {
/*
var big_grid_size = value
owner.paint_canvas.big_grid_size = big_grid_size
*/
}
PaintChangeGridSizeDialog::PaintChangeGridSizeDialog() {
}
PaintChangeGridSizeDialog::~PaintChangeGridSizeDialog() {
}
void PaintChangeGridSizeDialog::_bind_methods() {
}

View File

@ -0,0 +1,46 @@
#ifndef PAINT_CHANGE_GRID_SIZE_DIALOG_H
#define PAINT_CHANGE_GRID_SIZE_DIALOG_H
/*
Copyright (c) 2019 Flairieve
Copyright (c) 2020-2022 cobrapitz
Copyright (c) 2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "scene/gui/dialogs.h"
class PaintChangeGridSizeDialog : public AcceptDialog {
GDCLASS(PaintChangeGridSizeDialog, AcceptDialog);
public:
void _ready();
void _on_ChangeGridSizeDialog_confirmed();
void _on_GridValue_value_changed(float value);
void _on_BigGridValue_value_changed(float value);
PaintChangeGridSizeDialog();
~PaintChangeGridSizeDialog();
protected:
static void _bind_methods();
};
#endif

View File

@ -0,0 +1,124 @@
/*
Copyright (c) 2019 Flairieve
Copyright (c) 2020-2022 cobrapitz
Copyright (c) 2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "paint_load_file_dialog.h"
void PaintLoadFileDialog::_on_LoadFileDialog_file_selected(String path) {
/*
file_path = path
#print("1ere")
load_img()
*/
}
void PaintLoadFileDialog::_on_LoadFileDialog_confirmed() {
/*
return
#print("ere")
#load_img()
*/
}
void PaintLoadFileDialog::load_img() {
/*
var image = Image.new()
if image.load(file_path) != OK:
print("couldn't load image!")
return
var image_data = image.get_data()
var layer: GELayer = owner.add_new_layer()
var width = image.get_width()
var height = image.get_height()
if owner.paint_canvas.canvas_width < width:
owner.paint_canvas.resize(width, owner.paint_canvas.canvas_height)
if owner.paint_canvas.canvas_height < height:
owner.paint_canvas.resize(owner.paint_canvas.canvas_width, height)
for i in range(image_data.size() / 4):
var color = Color(image_data[i*4] / 255.0, image_data[i*4+1] / 255.0, image_data[i*4+2] / 255.0, image_data[i*4+3] / 255.0)
var pos = GEUtils.to_2D(i, image.get_width())
if pos.x > layer.layer_width:
continue
layer.set_pixel(pos.x, pos.y, color)
layer.update_texture()
*/
}
void PaintLoadFileDialog::_on_LoadFileDialog_about_to_show() {
/*
invalidate()
*/
}
void PaintLoadFileDialog::_on_LoadFileDialog_visibility_changed() {
/*
invalidate()
*/
}
PaintLoadFileDialog::PaintLoadFileDialog() {
//var file_path = ""
/*
get_line_edit().connect("text_entered", self, "_on_LineEdit_text_entered")
invalidate()
clear_filters()
add_filter("*.png ; PNG Images")
*/
/*
[gd_scene load_steps=2 format=2]
[sub_resource type="GDScript" id=1]
script/source = "extends ConfirmationDialog
func _ready():
get_ok().connect(\"pressed\", self, \"hide\")
get_cancel().connect(\"pressed\", self, \"hide\")
"
[node name="LoadFileDialog" type="FileDialog"]
margin_right = 604.0
margin_bottom = 367.0
window_title = "Open a File"
mode = 0
access = 2
current_dir = "/Projects/BitBucket/GraphicsEditor"
current_path = "/Projects/BitBucket/GraphicsEditor/"
script = SubResource( 1 )
*/
}
PaintLoadFileDialog::~PaintLoadFileDialog() {
}
void PaintLoadFileDialog::_bind_methods() {
}

View File

@ -0,0 +1,50 @@
#ifndef PAINT_LOAD_FILE_DIALOG_H
#define PAINT_LOAD_FILE_DIALOG_H
/*
Copyright (c) 2019 Flairieve
Copyright (c) 2020-2022 cobrapitz
Copyright (c) 2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "scene/gui/file_dialog.h"
class PaintLoadFileDialog : public FileDialog {
GDCLASS(PaintLoadFileDialog, FileDialog);
public:
void _on_LoadFileDialog_file_selected(String path);
void _on_LoadFileDialog_confirmed();
void load_img();
void _on_LoadFileDialog_about_to_show();
void _on_LoadFileDialog_visibility_changed();
PaintLoadFileDialog();
~PaintLoadFileDialog();
protected:
static void _bind_methods();
//var file_path = ""
//var canvas: GECanvas
};
#endif