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
a2981f55
Commit
a2981f55
authored
Dec 15, 2017
by
sersoong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enhanced changeType menu in Scene Tree Dock
parent
e3fd61b6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
55 deletions
+58
-55
scene_tree_dock.cpp
editor/scene_tree_dock.cpp
+58
-55
No files found.
editor/scene_tree_dock.cpp
View file @
a2981f55
...
...
@@ -1373,77 +1373,81 @@ void SceneTreeDock::_create() {
}
}
else
if
(
current_option
==
TOOL_REPLACE
)
{
Node
*
n
=
scene_tree
->
get_selected
();
ERR_FAIL_COND
(
!
n
);
List
<
Node
*>
selection
=
editor_selection
->
get_selected_node_list
();
ERR_FAIL_COND
(
selection
.
size
()
<=
0
);
for
(
List
<
Node
*>::
Element
*
E
=
selection
.
front
();
E
;
E
=
E
->
next
())
{
Node
*
n
=
E
->
get
();
ERR_FAIL_COND
(
!
n
);
Object
*
c
=
create_dialog
->
instance_selected
();
Object
*
c
=
create_dialog
->
instance_selected
();
ERR_FAIL_COND
(
!
c
);
Node
*
newnode
=
Object
::
cast_to
<
Node
>
(
c
);
ERR_FAIL_COND
(
!
newnode
);
ERR_FAIL_COND
(
!
c
);
Node
*
newnode
=
Object
::
cast_to
<
Node
>
(
c
);
ERR_FAIL_COND
(
!
newnode
);
List
<
PropertyInfo
>
pinfo
;
n
->
get_property_list
(
&
pinfo
);
List
<
PropertyInfo
>
pinfo
;
n
->
get_property_list
(
&
pinfo
);
for
(
List
<
PropertyInfo
>::
Element
*
E
=
pinfo
.
front
();
E
;
E
=
E
->
next
())
{
if
(
!
(
E
->
get
().
usage
&
PROPERTY_USAGE_STORAGE
))
continue
;
if
(
E
->
get
().
name
==
"__meta__"
)
continue
;
newnode
->
set
(
E
->
get
().
name
,
n
->
get
(
E
->
get
().
name
));
}
for
(
List
<
PropertyInfo
>::
Element
*
E
=
pinfo
.
front
();
E
;
E
=
E
->
next
())
{
if
(
!
(
E
->
get
().
usage
&
PROPERTY_USAGE_STORAGE
))
continue
;
if
(
E
->
get
().
name
==
"__meta__"
)
continue
;
newnode
->
set
(
E
->
get
().
name
,
n
->
get
(
E
->
get
().
name
));
}
editor
->
push_item
(
NULL
);
editor
->
push_item
(
NULL
);
//reconnect signals
List
<
MethodInfo
>
sl
;
//reconnect signals
List
<
MethodInfo
>
sl
;
n
->
get_signal_list
(
&
sl
);
for
(
List
<
MethodInfo
>::
Element
*
E
=
sl
.
front
();
E
;
E
=
E
->
next
())
{
n
->
get_signal_list
(
&
sl
);
for
(
List
<
MethodInfo
>::
Element
*
E
=
sl
.
front
();
E
;
E
=
E
->
next
())
{
List
<
Object
::
Connection
>
cl
;
n
->
get_signal_connection_list
(
E
->
get
().
name
,
&
cl
);
List
<
Object
::
Connection
>
cl
;
n
->
get_signal_connection_list
(
E
->
get
().
name
,
&
cl
);
for
(
List
<
Object
::
Connection
>::
Element
*
F
=
cl
.
front
();
F
;
F
=
F
->
next
())
{
for
(
List
<
Object
::
Connection
>::
Element
*
F
=
cl
.
front
();
F
;
F
=
F
->
next
())
{
Object
::
Connection
&
c
=
F
->
get
();
if
(
!
(
c
.
flags
&
Object
::
CONNECT_PERSIST
))
continue
;
newnode
->
connect
(
c
.
signal
,
c
.
target
,
c
.
method
,
varray
(),
Object
::
CONNECT_PERSIST
);
Object
::
Connection
&
c
=
F
->
get
();
if
(
!
(
c
.
flags
&
Object
::
CONNECT_PERSIST
))
continue
;
newnode
->
connect
(
c
.
signal
,
c
.
target
,
c
.
method
,
varray
(),
Object
::
CONNECT_PERSIST
);
}
}
}
String
newname
=
n
->
get_name
();
String
newname
=
n
->
get_name
();
List
<
Node
*>
to_erase
;
for
(
int
i
=
0
;
i
<
n
->
get_child_count
();
i
++
)
{
if
(
n
->
get_child
(
i
)
->
get_owner
()
==
NULL
&&
n
->
is_owned_by_parent
())
{
to_erase
.
push_back
(
n
->
get_child
(
i
));
List
<
Node
*>
to_erase
;
for
(
int
i
=
0
;
i
<
n
->
get_child_count
();
i
++
)
{
if
(
n
->
get_child
(
i
)
->
get_owner
()
==
NULL
&&
n
->
is_owned_by_parent
())
{
to_erase
.
push_back
(
n
->
get_child
(
i
));
}
}
}
n
->
replace_by
(
newnode
,
true
);
n
->
replace_by
(
newnode
,
true
);
if
(
n
==
edited_scene
)
{
edited_scene
=
newnode
;
editor
->
set_edited_scene
(
newnode
);
newnode
->
set_editable_instances
(
n
->
get_editable_instances
());
}
if
(
n
==
edited_scene
)
{
edited_scene
=
newnode
;
editor
->
set_edited_scene
(
newnode
);
newnode
->
set_editable_instances
(
n
->
get_editable_instances
());
}
//small hack to make collisionshapes and other kind of nodes to work
for
(
int
i
=
0
;
i
<
newnode
->
get_child_count
();
i
++
)
{
Node
*
c
=
newnode
->
get_child
(
i
);
c
->
call
(
"set_transform"
,
c
->
call
(
"get_transform"
));
}
editor_data
->
get_undo_redo
().
clear_history
();
newnode
->
set_name
(
newname
);
//small hack to make collisionshapes and other kind of nodes to work
for
(
int
i
=
0
;
i
<
newnode
->
get_child_count
();
i
++
)
{
Node
*
c
=
newnode
->
get_child
(
i
);
c
->
call
(
"set_transform"
,
c
->
call
(
"get_transform"
));
}
editor_data
->
get_undo_redo
().
clear_history
();
newnode
->
set_name
(
newname
);
editor
->
push_item
(
newnode
);
editor
->
push_item
(
newnode
);
memdelete
(
n
);
memdelete
(
n
);
while
(
to_erase
.
front
())
{
memdelete
(
to_erase
.
front
()
->
get
());
to_erase
.
pop_front
();
while
(
to_erase
.
front
())
{
memdelete
(
to_erase
.
front
()
->
get
());
to_erase
.
pop_front
();
}
}
}
}
...
...
@@ -1737,13 +1741,12 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
menu
->
add_icon_shortcut
(
get_icon
(
"Add"
,
"EditorIcons"
),
ED_GET_SHORTCUT
(
"scene_tree/add_child_node"
),
TOOL_NEW
);
menu
->
add_icon_shortcut
(
get_icon
(
"Instance"
,
"EditorIcons"
),
ED_GET_SHORTCUT
(
"scene_tree/instance_scene"
),
TOOL_INSTANCE
);
menu
->
add_separator
();
menu
->
add_icon_shortcut
(
get_icon
(
"Reload"
,
"EditorIcons"
),
ED_GET_SHORTCUT
(
"scene_tree/change_node_type"
),
TOOL_REPLACE
);
menu
->
add_separator
();
menu
->
add_icon_shortcut
(
get_icon
(
"ScriptCreate"
,
"EditorIcons"
),
ED_GET_SHORTCUT
(
"scene_tree/attach_script"
),
TOOL_ATTACH_SCRIPT
);
menu
->
add_icon_shortcut
(
get_icon
(
"ScriptRemove"
,
"EditorIcons"
),
ED_GET_SHORTCUT
(
"scene_tree/clear_script"
),
TOOL_CLEAR_SCRIPT
);
menu
->
add_separator
();
}
menu
->
add_icon_shortcut
(
get_icon
(
"Reload"
,
"EditorIcons"
),
ED_GET_SHORTCUT
(
"scene_tree/change_node_type"
),
TOOL_REPLACE
);
menu
->
add_separator
();
menu
->
add_icon_shortcut
(
get_icon
(
"MoveUp"
,
"EditorIcons"
),
ED_GET_SHORTCUT
(
"scene_tree/move_up"
),
TOOL_MOVE_UP
);
menu
->
add_icon_shortcut
(
get_icon
(
"MoveDown"
,
"EditorIcons"
),
ED_GET_SHORTCUT
(
"scene_tree/move_down"
),
TOOL_MOVE_DOWN
);
menu
->
add_icon_shortcut
(
get_icon
(
"Duplicate"
,
"EditorIcons"
),
ED_GET_SHORTCUT
(
"scene_tree/duplicate"
),
TOOL_DUPLICATE
);
...
...
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