mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-09 12:29:35 +01:00
Now PaintColorGrid sets the active project's color.
This commit is contained in:
parent
4a93e21660
commit
bfd80993f2
@ -29,8 +29,17 @@ SOFTWARE.
|
|||||||
#include "scene/gui/scroll_container.h"
|
#include "scene/gui/scroll_container.h"
|
||||||
#include "scene/resources/style_box.h"
|
#include "scene/resources/style_box.h"
|
||||||
|
|
||||||
|
#include "../../nodes/paint_node.h"
|
||||||
|
#include "../../nodes/paint_project.h"
|
||||||
|
|
||||||
void PaintColorGrid::change_color_to(const Color &color) {
|
void PaintColorGrid::change_color_to(const Color &color) {
|
||||||
emit_signal("color_change_request", color);
|
emit_signal("color_change_request", color);
|
||||||
|
|
||||||
|
PaintProject *proj = Object::cast_to<PaintProject>(ObjectDB::get_instance(_current_paint_project));
|
||||||
|
|
||||||
|
if (proj) {
|
||||||
|
proj->set_current_color(color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void PaintColorGrid::add_color_prefab(const Color &color) {
|
void PaintColorGrid::add_color_prefab(const Color &color) {
|
||||||
Button *button = memnew(Button);
|
Button *button = memnew(Button);
|
||||||
@ -54,7 +63,29 @@ void PaintColorGrid::add_color_prefab(const Color &color) {
|
|||||||
button->connect("pressed", this, "change_color_to", binds);
|
button->connect("pressed", this, "change_color_to", binds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PaintColorGrid::_on_paint_node_selected(Node *p_paint_node) {
|
||||||
|
PaintNode *paint_node = Object::cast_to<PaintNode>(p_paint_node);
|
||||||
|
|
||||||
|
_current_paint_node = 0;
|
||||||
|
_current_paint_project = 0;
|
||||||
|
|
||||||
|
if (!paint_node) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_current_paint_node = paint_node->get_instance_id();
|
||||||
|
|
||||||
|
PaintProject *proj = paint_node->get_paint_project();
|
||||||
|
|
||||||
|
if (proj) {
|
||||||
|
_current_paint_project = proj->get_instance_id();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PaintColorGrid::PaintColorGrid() {
|
PaintColorGrid::PaintColorGrid() {
|
||||||
|
_current_paint_node = 0;
|
||||||
|
_current_paint_project = 0;
|
||||||
|
|
||||||
ScrollContainer *scroll_container = memnew(ScrollContainer);
|
ScrollContainer *scroll_container = memnew(ScrollContainer);
|
||||||
scroll_container->set_custom_minimum_size(Size2(0, 145));
|
scroll_container->set_custom_minimum_size(Size2(0, 145));
|
||||||
scroll_container->set_enable_h_scroll(false);
|
scroll_container->set_enable_h_scroll(false);
|
||||||
|
@ -26,8 +26,11 @@ SOFTWARE.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../paint_sidebar_module.h"
|
#include "../paint_sidebar_module.h"
|
||||||
|
#include "core/object/object_id.h"
|
||||||
|
|
||||||
class GridContainer;
|
class GridContainer;
|
||||||
|
class PaintNode;
|
||||||
|
class PaintProject;
|
||||||
|
|
||||||
class PaintColorGrid : public PaintSidebarModule {
|
class PaintColorGrid : public PaintSidebarModule {
|
||||||
GDCLASS(PaintColorGrid, PaintSidebarModule);
|
GDCLASS(PaintColorGrid, PaintSidebarModule);
|
||||||
@ -41,6 +44,8 @@ public:
|
|||||||
void change_color_to(const Color &color);
|
void change_color_to(const Color &color);
|
||||||
void add_color_prefab(const Color &color);
|
void add_color_prefab(const Color &color);
|
||||||
|
|
||||||
|
void _on_paint_node_selected(Node *paint_node);
|
||||||
|
|
||||||
PaintColorGrid();
|
PaintColorGrid();
|
||||||
~PaintColorGrid();
|
~PaintColorGrid();
|
||||||
|
|
||||||
@ -48,6 +53,9 @@ protected:
|
|||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
GridContainer *_grid;
|
GridContainer *_grid;
|
||||||
|
|
||||||
|
ObjectID _current_paint_node;
|
||||||
|
ObjectID _current_paint_project;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user