Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
2f57249c
Commit
2f57249c
authored
Oct 14, 2016
by
Rémi Verschelde
Committed by
GitHub
Oct 14, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6793 from volzhs/save-branch
Replace a node with saved branch scene instance
parents
44e0071d
cc33c528
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletion
+30
-1
scene_tree_dock.cpp
tools/editor/scene_tree_dock.cpp
+29
-1
scene_tree_dock.h
tools/editor/scene_tree_dock.h
+1
-0
No files found.
tools/editor/scene_tree_dock.cpp
View file @
2f57249c
...
...
@@ -238,6 +238,34 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String>& p_files,Node*
}
void
SceneTreeDock
::
_replace_with_branch_scene
(
const
String
&
p_file
,
Node
*
base
)
{
Ref
<
PackedScene
>
sdata
=
ResourceLoader
::
load
(
p_file
);
if
(
!
sdata
.
is_valid
())
{
accept
->
get_ok
()
->
set_text
(
TTR
(
"Ugh"
));
accept
->
set_text
(
vformat
(
TTR
(
"Error loading scene from %s"
),
p_file
));
accept
->
popup_centered_minsize
();
return
;
}
Node
*
instanced_scene
=
sdata
->
instance
(
true
);
if
(
!
instanced_scene
)
{
accept
->
get_ok
()
->
set_text
(
TTR
(
"Ugh"
));
accept
->
set_text
(
vformat
(
TTR
(
"Error instancing scene from %s"
),
p_file
));
accept
->
popup_centered_minsize
();
return
;
}
Node
*
parent
=
base
->
get_parent
();
int
pos
=
base
->
get_index
();
memdelete
(
base
);
parent
->
add_child
(
instanced_scene
);
parent
->
move_child
(
instanced_scene
,
pos
);
instanced_scene
->
set_owner
(
edited_scene
);
editor_selection
->
clear
();
editor_selection
->
add_node
(
instanced_scene
);
scene_tree
->
set_selected
(
instanced_scene
);
}
bool
SceneTreeDock
::
_cyclical_dependency_exists
(
const
String
&
p_target_scene_path
,
Node
*
p_desired_node
)
{
int
childCount
=
p_desired_node
->
get_child_count
();
...
...
@@ -1513,7 +1541,7 @@ void SceneTreeDock::_new_scene_from(String p_file) {
accept
->
popup_centered_minsize
();
return
;
}
_replace_with_branch_scene
(
p_file
,
base
);
}
else
{
accept
->
get_ok
()
->
set_text
(
TTR
(
"I see.."
));
accept
->
set_text
(
TTR
(
"Error duplicating scene to save it."
));
...
...
tools/editor/scene_tree_dock.h
View file @
2f57249c
...
...
@@ -153,6 +153,7 @@ class SceneTreeDock : public VBoxContainer {
void
_filter_changed
(
const
String
&
p_filter
);
void
_perform_instance_scenes
(
const
Vector
<
String
>&
p_files
,
Node
*
parent
,
int
p_pos
);
void
_replace_with_branch_scene
(
const
String
&
p_file
,
Node
*
base
);
protected
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment