Fixed compiling by using new EditorUndoRedoManager.
Not sure if a global replacement is the right approach in any cases, there doesn't seem to be any documentation yet about this class.master
parent
c5d58f6d9d
commit
637862640c
|
@ -189,7 +189,7 @@ void VoxelGraphEditor::set_graph(Ref<VoxelGeneratorGraph> graph) {
|
|||
schedule_preview_update();
|
||||
}
|
||||
|
||||
void VoxelGraphEditor::set_undo_redo(UndoRedo *undo_redo) {
|
||||
void VoxelGraphEditor::set_undo_redo(Ref<EditorUndoRedoManager> undo_redo) {
|
||||
_undo_redo = undo_redo;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define VOXEL_GRAPH_EDITOR_H
|
||||
|
||||
#include "../voxel_debug.h"
|
||||
#include <editor/editor_undo_redo_manager.h>
|
||||
#include <scene/gui/control.h>
|
||||
|
||||
class GraphEdit;
|
||||
|
@ -34,7 +35,7 @@ public:
|
|||
return _graph;
|
||||
}
|
||||
|
||||
void set_undo_redo(UndoRedo *undo_redo);
|
||||
void set_undo_redo(Ref<EditorUndoRedoManager> undo_redo);
|
||||
void set_voxel_node(VoxelNode *node);
|
||||
|
||||
// To be called when the number of inputs in a node changes.
|
||||
|
@ -93,7 +94,10 @@ private:
|
|||
Label *_profile_label = nullptr;
|
||||
Label *_compile_result_label = nullptr;
|
||||
VoxelRangeAnalysisDialog *_range_analysis_dialog = nullptr;
|
||||
UndoRedo *_undo_redo = nullptr;
|
||||
// TODO Not sure if using `EditorUndoRedoManager` directly is the right thing to do?
|
||||
// VisualShader did it that way when this manager got introduced in place of the old global UndoRedo...
|
||||
// there doesn't seem to be any documentation yet for this class
|
||||
Ref<EditorUndoRedoManager> _undo_redo = nullptr;
|
||||
Vector2 _click_position;
|
||||
bool _nothing_selected_check_scheduled = false;
|
||||
float _time_before_preview_update = 0.f;
|
||||
|
|
|
@ -106,7 +106,7 @@ void VoxelGraphEditorPlugin::edit(Object *p_object) {
|
|||
}
|
||||
}
|
||||
Ref<VoxelGeneratorGraph> graph(graph_ptr);
|
||||
_graph_editor->set_undo_redo(&get_undo_redo()); // UndoRedo isn't available in constructor
|
||||
_graph_editor->set_undo_redo(get_undo_redo()); // UndoRedo isn't available in constructor
|
||||
_graph_editor->set_graph(graph);
|
||||
|
||||
VoxelNode *voxel_node = nullptr;
|
||||
|
@ -171,7 +171,7 @@ void VoxelGraphEditorPlugin::_hide_deferred() {
|
|||
void VoxelGraphEditorPlugin::_on_graph_editor_node_selected(uint32_t node_id) {
|
||||
Ref<VoxelGraphNodeInspectorWrapper> wrapper;
|
||||
wrapper.instantiate();
|
||||
wrapper->setup(_graph_editor->get_graph(), node_id, &get_undo_redo(), _graph_editor);
|
||||
wrapper->setup(_graph_editor->get_graph(), node_id, get_undo_redo(), _graph_editor);
|
||||
// Note: it's neither explicit nor documented, but the reference will stay alive due to EditorHistory::_add_object
|
||||
get_editor_interface()->inspect_object(*wrapper);
|
||||
// TODO Absurd situation here...
|
||||
|
|
|
@ -14,7 +14,7 @@ const char *AUTOCONNECT_PROPERY_NAME = "autoconnect_default_inputs";
|
|||
}
|
||||
|
||||
void VoxelGraphNodeInspectorWrapper::setup(
|
||||
Ref<VoxelGeneratorGraph> p_graph, uint32_t p_node_id, UndoRedo *ur, VoxelGraphEditor *ed) {
|
||||
Ref<VoxelGeneratorGraph> p_graph, uint32_t p_node_id, Ref<EditorUndoRedoManager> ur, VoxelGraphEditor *ed) {
|
||||
_graph = p_graph;
|
||||
_node_id = p_node_id;
|
||||
_undo_redo = ur;
|
||||
|
@ -89,8 +89,8 @@ void VoxelGraphNodeInspectorWrapper::_get_property_list(List<PropertyInfo> *p_li
|
|||
// Contrary to VisualScript (for which this has to be done manually to the user), submitting the text field containing
|
||||
// the expression's code also changes dynamic inputs of the node and reconnects existing connections, all as one
|
||||
// UndoRedo action.
|
||||
static void update_expression_inputs(
|
||||
VoxelGeneratorGraph &generator, uint32_t node_id, String code, UndoRedo &ur, VoxelGraphEditor &graph_editor) {
|
||||
static void update_expression_inputs(VoxelGeneratorGraph &generator, uint32_t node_id, String code,
|
||||
EditorUndoRedoManager &ur, VoxelGraphEditor &graph_editor) {
|
||||
//
|
||||
const CharString code_utf8 = code.utf8();
|
||||
std::vector<std::string_view> new_input_names;
|
||||
|
@ -168,7 +168,7 @@ bool VoxelGraphNodeInspectorWrapper::_set(const StringName &p_name, const Varian
|
|||
ERR_FAIL_COND_V(graph.is_null(), false);
|
||||
|
||||
ERR_FAIL_COND_V(_undo_redo == nullptr, false);
|
||||
UndoRedo &ur = *_undo_redo;
|
||||
EditorUndoRedoManager &ur = **_undo_redo;
|
||||
|
||||
if (p_name == "name") {
|
||||
String previous_name = graph->get_node_name(_node_id);
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
|
||||
#include "../../generators/graph/voxel_generator_graph.h"
|
||||
#include <core/object/ref_counted.h>
|
||||
|
||||
class UndoRedo;
|
||||
#include <editor/editor_undo_redo_manager.h>
|
||||
|
||||
namespace zylann::voxel {
|
||||
|
||||
|
@ -16,7 +15,8 @@ class VoxelGraphEditor;
|
|||
class VoxelGraphNodeInspectorWrapper : public RefCounted {
|
||||
GDCLASS(VoxelGraphNodeInspectorWrapper, RefCounted)
|
||||
public:
|
||||
void setup(Ref<VoxelGeneratorGraph> p_graph, uint32_t p_node_id, UndoRedo *ur, VoxelGraphEditor *ed);
|
||||
void setup(
|
||||
Ref<VoxelGeneratorGraph> p_graph, uint32_t p_node_id, Ref<EditorUndoRedoManager> ur, VoxelGraphEditor *ed);
|
||||
inline Ref<VoxelGeneratorGraph> get_graph() const {
|
||||
return _graph;
|
||||
}
|
||||
|
@ -32,7 +32,10 @@ private:
|
|||
|
||||
Ref<VoxelGeneratorGraph> _graph;
|
||||
uint32_t _node_id = ProgramGraph::NULL_ID;
|
||||
UndoRedo *_undo_redo = nullptr;
|
||||
// TODO Not sure if using `EditorUndoRedoManager` directly is the right thing to do?
|
||||
// DictionaryPropertyEdit kept using this manager when it got introduced in place of the old global UndoRedo...
|
||||
// there doesn't seem to be any documentation yet for this class
|
||||
Ref<EditorUndoRedoManager> _undo_redo;
|
||||
VoxelGraphEditor *_graph_editor = nullptr;
|
||||
};
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ void VoxelInstanceLibraryEditorPlugin::_on_button_pressed(int id) {
|
|||
|
||||
const int item_id = _library->get_next_available_id();
|
||||
|
||||
UndoRedo &ur = get_undo_redo();
|
||||
EditorUndoRedoManager &ur = **get_undo_redo();
|
||||
ur.create_action("Add multimesh item");
|
||||
ur.add_do_method(*_library, "add_item", item_id, item);
|
||||
ur.add_undo_method(*_library, "remove_item", item_id);
|
||||
|
@ -133,7 +133,7 @@ void VoxelInstanceLibraryEditorPlugin::_on_remove_item_confirmed() {
|
|||
|
||||
Ref<VoxelInstanceLibraryItem> item = _library->get_item(_item_id_to_remove);
|
||||
|
||||
UndoRedo &ur = get_undo_redo();
|
||||
EditorUndoRedoManager &ur = **get_undo_redo();
|
||||
ur.create_action("Remove item");
|
||||
ur.add_do_method(*_library, "remove_item", _item_id_to_remove);
|
||||
ur.add_undo_method(*_library, "add_item", _item_id_to_remove, item);
|
||||
|
@ -172,7 +172,7 @@ void VoxelInstanceLibraryEditorPlugin::add_scene_item(String fpath) {
|
|||
|
||||
const int item_id = _library->get_next_available_id();
|
||||
|
||||
UndoRedo &ur = get_undo_redo();
|
||||
EditorUndoRedoManager &ur = **get_undo_redo();
|
||||
ur.create_action("Add scene item");
|
||||
ur.add_do_method(_library.ptr(), "add_item", item_id, item);
|
||||
ur.add_undo_method(_library.ptr(), "remove_item", item_id);
|
||||
|
|
|
@ -58,7 +58,7 @@ void VoxelInstanceLibraryMultiMeshItemEditorPlugin::_on_update_from_scene_button
|
|||
}
|
||||
|
||||
static void update_multimesh_item_from_scene(
|
||||
VoxelInstanceLibraryMultiMeshItem &item, String scene_file_path, UndoRedo &ur) {
|
||||
VoxelInstanceLibraryMultiMeshItem &item, String scene_file_path, EditorUndoRedoManager &ur) {
|
||||
Ref<PackedScene> scene = ResourceLoader::load(scene_file_path);
|
||||
ERR_FAIL_COND(scene.is_null());
|
||||
|
||||
|
@ -79,7 +79,7 @@ static void update_multimesh_item_from_scene(
|
|||
|
||||
void VoxelInstanceLibraryMultiMeshItemEditorPlugin::_on_open_scene_dialog_file_selected(String fpath) {
|
||||
ERR_FAIL_COND(_item.is_null());
|
||||
update_multimesh_item_from_scene(**_item, fpath, get_undo_redo());
|
||||
update_multimesh_item_from_scene(**_item, fpath, **get_undo_redo());
|
||||
// We are done with this item
|
||||
_item.unref();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue