mirror of
https://github.com/Relintai/voxelman.git
synced 2025-01-25 15:09:18 +01:00
Implemented add and remove tool mode selectors in world editor. Also added shortcuts (a, s).
This commit is contained in:
parent
7c0390de74
commit
f43e4a2cc4
@ -215,9 +215,30 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) {
|
|||||||
|
|
||||||
spatial_editor_hb = memnew(HBoxContainer);
|
spatial_editor_hb = memnew(HBoxContainer);
|
||||||
spatial_editor_hb->set_h_size_flags(SIZE_EXPAND_FILL);
|
spatial_editor_hb->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||||
spatial_editor_hb->set_alignment(BoxContainer::ALIGN_END);
|
spatial_editor_hb->set_alignment(BoxContainer::ALIGN_BEGIN);
|
||||||
SpatialEditor::get_singleton()->add_control_to_menu_panel(spatial_editor_hb);
|
SpatialEditor::get_singleton()->add_control_to_menu_panel(spatial_editor_hb);
|
||||||
|
|
||||||
|
_tool_button_group.instance();
|
||||||
|
|
||||||
|
ToolButton *add_button = memnew(ToolButton);
|
||||||
|
add_button->set_text("Add");
|
||||||
|
add_button->set_toggle_mode(true);
|
||||||
|
add_button->set_pressed(true);
|
||||||
|
add_button->set_button_group(_tool_button_group);
|
||||||
|
add_button->set_meta("tool_mode", TOOL_MODE_ADD);
|
||||||
|
add_button->connect("button_up", this, "_on_tool_button_pressed");
|
||||||
|
add_button->set_shortcut(ED_SHORTCUT("voxelman_world_editor/add_mode", "Add Mode", KEY_A));
|
||||||
|
spatial_editor_hb->add_child(add_button);
|
||||||
|
|
||||||
|
ToolButton *remove_button = memnew(ToolButton);
|
||||||
|
remove_button->set_text("Remove");
|
||||||
|
remove_button->set_toggle_mode(true);
|
||||||
|
remove_button->set_button_group(_tool_button_group);
|
||||||
|
remove_button->set_meta("tool_mode", TOOL_MODE_REMOVE);
|
||||||
|
remove_button->connect("button_up", this, "_on_tool_button_pressed");
|
||||||
|
remove_button->set_shortcut(ED_SHORTCUT("voxelman_world_editor/remove_mode", "Remove Mode", KEY_S));
|
||||||
|
spatial_editor_hb->add_child(remove_button);
|
||||||
|
|
||||||
set_custom_minimum_size(Size2(200 * EDSCALE, 0));
|
set_custom_minimum_size(Size2(200 * EDSCALE, 0));
|
||||||
|
|
||||||
TabContainer *tab_container = memnew(TabContainer);
|
TabContainer *tab_container = memnew(TabContainer);
|
||||||
@ -269,9 +290,18 @@ void VoxelWorldEditor::_on_surface_button_pressed() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VoxelWorldEditor::_on_tool_button_pressed() {
|
||||||
|
BaseButton *button = _tool_button_group->get_pressed_button();
|
||||||
|
|
||||||
|
if (button) {
|
||||||
|
_tool_mode = static_cast<VoxelWorldEditorToolMode>(static_cast<int>(button->get_meta("tool_mode")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void VoxelWorldEditor::_bind_methods() {
|
void VoxelWorldEditor::_bind_methods() {
|
||||||
ClassDB::bind_method("_node_removed", &VoxelWorldEditor::_node_removed);
|
ClassDB::bind_method("_node_removed", &VoxelWorldEditor::_node_removed);
|
||||||
ClassDB::bind_method("_on_surface_button_pressed", &VoxelWorldEditor::_on_surface_button_pressed);
|
ClassDB::bind_method("_on_surface_button_pressed", &VoxelWorldEditor::_on_surface_button_pressed);
|
||||||
|
ClassDB::bind_method("_on_tool_button_pressed", &VoxelWorldEditor::_on_tool_button_pressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelWorldEditorPlugin::_notification(int p_what) {
|
void VoxelWorldEditorPlugin::_notification(int p_what) {
|
||||||
|
@ -63,6 +63,7 @@ protected:
|
|||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
void _node_removed(Node *p_node);
|
void _node_removed(Node *p_node);
|
||||||
void _on_surface_button_pressed();
|
void _on_surface_button_pressed();
|
||||||
|
void _on_tool_button_pressed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VBoxContainer *_surfaces_vbox_container;
|
VBoxContainer *_surfaces_vbox_container;
|
||||||
@ -70,6 +71,8 @@ private:
|
|||||||
Ref<ButtonGroup> _surfaces_button_group;
|
Ref<ButtonGroup> _surfaces_button_group;
|
||||||
Ref<ButtonGroup> _liquid_surfaces_button_group;
|
Ref<ButtonGroup> _liquid_surfaces_button_group;
|
||||||
|
|
||||||
|
Ref<ButtonGroup> _tool_button_group;
|
||||||
|
|
||||||
VoxelWorldEditorToolMode _tool_mode;
|
VoxelWorldEditorToolMode _tool_mode;
|
||||||
VoxelWorld *_world;
|
VoxelWorld *_world;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user