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
6f404efd
Unverified
Commit
6f404efd
authored
Mar 16, 2019
by
Rémi Verschelde
Committed by
GitHub
Mar 16, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #26309 from bojidar-bg/21536-resize-gridmap-previews
Add search box and size slider to GridMap (similar to TileMap's)
parents
43f147b5
a9ac4c01
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
7 deletions
+59
-7
grid_map_editor_plugin.cpp
modules/gridmap/grid_map_editor_plugin.cpp
+52
-7
grid_map_editor_plugin.h
modules/gridmap/grid_map_editor_plugin.h
+7
-0
No files found.
modules/gridmap/grid_map_editor_plugin.cpp
View file @
6f404efd
...
...
@@ -717,6 +717,26 @@ void GridMapEditor::_set_display_mode(int p_mode) {
update_palette
();
}
void
GridMapEditor
::
_text_changed
(
const
String
&
p_text
)
{
update_palette
();
}
void
GridMapEditor
::
_sbox_input
(
const
Ref
<
InputEvent
>
&
p_ie
)
{
Ref
<
InputEventKey
>
k
=
p_ie
;
if
(
k
.
is_valid
()
&&
(
k
->
get_scancode
()
==
KEY_UP
||
k
->
get_scancode
()
==
KEY_DOWN
||
k
->
get_scancode
()
==
KEY_PAGEUP
||
k
->
get_scancode
()
==
KEY_PAGEDOWN
))
{
mesh_library_palette
->
call
(
"_gui_input"
,
k
);
search_box
->
accept_event
();
}
}
void
GridMapEditor
::
_icon_size_changed
(
float
p_value
)
{
mesh_library_palette
->
set_icon_scale
(
p_value
);
update_palette
();
}
void
GridMapEditor
::
update_palette
()
{
int
selected
=
mesh_library_palette
->
get_current
();
...
...
@@ -730,8 +750,9 @@ void GridMapEditor::update_palette() {
}
float
min_size
=
EDITOR_DEF
(
"editors/grid_map/preview_size"
,
64
);
min_size
*=
EDSCALE
;
mesh_library_palette
->
set_fixed_icon_size
(
Size2
(
min_size
,
min_size
));
mesh_library_palette
->
set_fixed_column_width
(
min_size
*
3
/
2
);
mesh_library_palette
->
set_fixed_column_width
(
min_size
*
MAX
(
size_slider
->
get_value
(),
1.5
)
);
mesh_library_palette
->
set_max_text_lines
(
2
);
Ref
<
MeshLibrary
>
mesh_library
=
node
->
get_mesh_library
();
...
...
@@ -754,23 +775,28 @@ void GridMapEditor::update_palette() {
}
il
.
sort
();
String
filter
=
search_box
->
get_text
().
strip_edges
();
int
item
=
0
;
for
(
List
<
_CGMEItemSort
>::
Element
*
E
=
il
.
front
();
E
;
E
=
E
->
next
())
{
int
id
=
E
->
get
().
id
;
mesh_library_palette
->
add_item
(
""
);
String
name
=
mesh_library
->
get_item_name
(
id
);
Ref
<
Texture
>
preview
=
mesh_library
->
get_item_preview
(
id
);
if
(
name
==
""
)
{
name
=
"#"
+
itos
(
id
);
}
if
(
filter
!=
""
&&
!
filter
.
is_subsequence_ofi
(
name
))
continue
;
mesh_library_palette
->
add_item
(
""
);
if
(
!
preview
.
is_null
())
{
mesh_library_palette
->
set_item_icon
(
item
,
preview
);
mesh_library_palette
->
set_item_tooltip
(
item
,
name
);
}
if
(
name
!=
""
)
{
mesh_library_palette
->
set_item_text
(
item
,
name
);
}
mesh_library_palette
->
set_item_text
(
item
,
name
);
mesh_library_palette
->
set_item_metadata
(
item
,
id
);
item
++
;
...
...
@@ -985,6 +1011,7 @@ void GridMapEditor::_notification(int p_what) {
case
NOTIFICATION_THEME_CHANGED
:
{
options
->
set_icon
(
get_icon
(
"GridMap"
,
"EditorIcons"
));
search_box
->
set_right_icon
(
get_icon
(
"Search"
,
"EditorIcons"
));
}
break
;
}
}
...
...
@@ -1031,6 +1058,9 @@ void GridMapEditor::_floor_changed(float p_value) {
void
GridMapEditor
::
_bind_methods
()
{
ClassDB
::
bind_method
(
"_text_changed"
,
&
GridMapEditor
::
_text_changed
);
ClassDB
::
bind_method
(
"_sbox_input"
,
&
GridMapEditor
::
_sbox_input
);
ClassDB
::
bind_method
(
"_icon_size_changed"
,
&
GridMapEditor
::
_icon_size_changed
);
ClassDB
::
bind_method
(
"_menu_option"
,
&
GridMapEditor
::
_menu_option
);
ClassDB
::
bind_method
(
"_configure"
,
&
GridMapEditor
::
_configure
);
ClassDB
::
bind_method
(
"_item_selected_cbk"
,
&
GridMapEditor
::
_item_selected_cbk
);
...
...
@@ -1132,6 +1162,12 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
add_child
(
hb
);
hb
->
set_h_size_flags
(
SIZE_EXPAND_FILL
);
search_box
=
memnew
(
LineEdit
);
search_box
->
set_h_size_flags
(
SIZE_EXPAND_FILL
);
hb
->
add_child
(
search_box
);
search_box
->
connect
(
"text_changed"
,
this
,
"_text_changed"
);
search_box
->
connect
(
"gui_input"
,
this
,
"_sbox_input"
);
mode_thumbnail
=
memnew
(
ToolButton
);
mode_thumbnail
->
set_toggle_mode
(
true
);
mode_thumbnail
->
set_pressed
(
true
);
...
...
@@ -1146,6 +1182,15 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
hb
->
add_child
(
mode_list
);
mode_list
->
connect
(
"pressed"
,
this
,
"_set_display_mode"
,
varray
(
DISPLAY_LIST
));
size_slider
=
memnew
(
HSlider
);
size_slider
->
set_h_size_flags
(
SIZE_EXPAND_FILL
);
size_slider
->
set_min
(
0.1
f
);
size_slider
->
set_max
(
4.0
f
);
size_slider
->
set_step
(
0.1
f
);
size_slider
->
set_value
(
1.0
f
);
size_slider
->
connect
(
"value_changed"
,
this
,
"_icon_size_changed"
);
add_child
(
size_slider
);
EDITOR_DEF
(
"editors/grid_map/preview_size"
,
64
);
display_mode
=
DISPLAY_THUMBNAIL
;
...
...
modules/gridmap/grid_map_editor_plugin.h
View file @
6f404efd
...
...
@@ -79,6 +79,8 @@ class GridMapEditor : public VBoxContainer {
double
accumulated_floor_delta
;
ToolButton
*
mode_thumbnail
;
ToolButton
*
mode_list
;
LineEdit
*
search_box
;
HSlider
*
size_slider
;
HBoxContainer
*
spatial_editor_hb
;
ConfirmationDialog
*
settings_dialog
;
VBoxContainer
*
settings_vbc
;
...
...
@@ -193,6 +195,11 @@ class GridMapEditor : public VBoxContainer {
void
_update_cursor_instance
();
void
_update_clip
();
void
_text_changed
(
const
String
&
p_text
);
void
_sbox_input
(
const
Ref
<
InputEvent
>
&
p_ie
);
void
_icon_size_changed
(
float
p_value
);
void
_update_duplicate_indicator
();
void
_duplicate_paste
();
void
_update_selection_transform
();
...
...
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