Create records for doors and aabbs, debug events problem, closes #38
This commit is contained in:
@@ -138,7 +138,6 @@ public:
|
||||
&HandleDeleteButton::delete_building_handler);
|
||||
}
|
||||
};
|
||||
static HandleDeleteButton *delete_button_handler = nullptr;
|
||||
static std::vector<Object *> ui_handlers;
|
||||
|
||||
BuildingsEditor::BuildingsEditor(WorldEditor *editor)
|
||||
@@ -156,37 +155,35 @@ void BuildingsEditor::exit()
|
||||
void BuildingsEditor::activate()
|
||||
{
|
||||
assert(!active);
|
||||
editor->event.add_listener(this, &BuildingsEditor::event_handler);
|
||||
print_line("BuildingsEditor ACTIVE");
|
||||
Array args;
|
||||
ui_handlers.push_back(memnew(HandleButton(
|
||||
this, "%buildings_create_building", "create_building", args)));
|
||||
ui_handlers.push_back(memnew(HandleChangeBuildingType(this)));
|
||||
ui_handlers.push_back(memnew(HandleDeleteButton(this)));
|
||||
int i;
|
||||
for (i = 0; i < (int)ui_handlers.size(); i++)
|
||||
assert(ui_handlers[i]);
|
||||
if (!delete_button_handler)
|
||||
delete_button_handler = memnew(HandleDeleteButton(this));
|
||||
assert(delete_button_handler);
|
||||
active = true;
|
||||
editor->event.add_listener(this, &BuildingsEditor::event_handler);
|
||||
}
|
||||
|
||||
void BuildingsEditor::deactivate()
|
||||
{
|
||||
assert(active);
|
||||
if (delete_button_handler) {
|
||||
memdelete(delete_button_handler);
|
||||
delete_button_handler = nullptr;
|
||||
}
|
||||
editor->event.remove_listener(this, &BuildingsEditor::event_handler);
|
||||
print_line("BuildingsEditor DEACTIVE");
|
||||
int i;
|
||||
for (i = 0; i < (int)ui_handlers.size(); i++)
|
||||
memdelete(ui_handlers[i]);
|
||||
ui_handlers.clear();
|
||||
editor->event.remove_listener(this, &BuildingsEditor::event_handler);
|
||||
active = false;
|
||||
}
|
||||
|
||||
void BuildingsEditor::event_handler(const String &event, const Array &args)
|
||||
{
|
||||
assert(active);
|
||||
print_line("E::" + event);
|
||||
if (event == "mouse_drag")
|
||||
mouse_drag(args[0]);
|
||||
else if (event == "mouse_press")
|
||||
@@ -242,6 +239,12 @@ inline void BuildingsEditor::mode_visibility(int mode, const String &path)
|
||||
|
||||
void BuildingsEditor::update(float delta)
|
||||
{
|
||||
#ifdef _VERBOSE_DEBUG
|
||||
if (active)
|
||||
print_line("update: " + String::num(delta) + " " +
|
||||
itos(editor->get_current_mode()) + " " +
|
||||
itos(editor->get_camera_mode()));
|
||||
#endif
|
||||
if (!active)
|
||||
activate();
|
||||
int mode = get_buildings_editor_mode();
|
||||
@@ -259,10 +262,16 @@ void BuildingsEditor::update(float delta)
|
||||
|
||||
void BuildingsEditor::mouse_drag(const Vector2 &position)
|
||||
{
|
||||
if (editor->get_current_mode() != WorldEditor::MODE_BUILDINGS)
|
||||
if (editor->get_current_mode() != WorldEditor::MODE_BUILDINGS) {
|
||||
print_verbose("bad editor mode: " +
|
||||
itos(editor->get_current_mode()));
|
||||
return;
|
||||
if (editor->get_camera_mode() != 3)
|
||||
}
|
||||
if (editor->get_camera_mode() != 3) {
|
||||
print_verbose("bad camera mode: " +
|
||||
itos(editor->get_camera_mode()));
|
||||
return;
|
||||
}
|
||||
print_line("in mouse_drag");
|
||||
Camera *camera = editor->get_viewport()->get_camera();
|
||||
Vector3 start = camera->project_ray_origin(position);
|
||||
@@ -337,10 +346,16 @@ void BuildingsEditor::mouse_drag(const Vector2 &position)
|
||||
|
||||
void BuildingsEditor::mouse_press(const Vector2 &position)
|
||||
{
|
||||
if (editor->get_current_mode() != WorldEditor::MODE_BUILDINGS)
|
||||
if (editor->get_current_mode() != WorldEditor::MODE_BUILDINGS) {
|
||||
print_verbose("bad editor mode: " +
|
||||
itos(editor->get_current_mode()));
|
||||
return;
|
||||
if (editor->get_camera_mode() != 3)
|
||||
}
|
||||
if (editor->get_camera_mode() != 3) {
|
||||
print_verbose("bad camera mode: " +
|
||||
itos(editor->get_camera_mode()));
|
||||
return;
|
||||
}
|
||||
print_line("in mouse_press");
|
||||
Camera *camera = editor->get_viewport()->get_camera();
|
||||
Vector3 start = camera->project_ray_origin(position);
|
||||
|
||||
Reference in New Issue
Block a user