Beispiel #1
0
 void UiModule::PostInitialize()
 {
     SubscribeToEventCategories();
     ui_console_manager_->SendInitializationReadyEvent();
     ether_logic_ = new Ether::Logic::EtherLogic(GetFramework(), ui_view_);
     ui_state_machine_->RegisterScene("Ether", ether_logic_->GetScene());
     ether_logic_->Start();
     ui_state_machine_->SwitchToEtherScene();
     LogDebug("Ether Logic STARTED");
 }
Beispiel #2
0
    void WorldBuildingModule::PostInitialize()
    {
        // Get all category id's that we are interested in
        SubscribeToEventCategories();

        // Register building key context
        input_context_ = GetFramework()->Input().RegisterInputContext("WorldBuildingContext", 90);
        connect(input_context_.get(), SIGNAL(KeyPressed(KeyEvent*)), build_scene_manager_.get(), SLOT(KeyPressed(KeyEvent*)));
        connect(input_context_.get(), SIGNAL(KeyReleased(KeyEvent*)), build_scene_manager_.get(), SLOT(KeyReleased(KeyEvent*)));
    }
Beispiel #3
0
    bool UiModule::HandleEvent(event_category_id_t category_id, event_id_t event_id, Foundation::EventDataInterface* data)
    {
        PROFILE(UiModule_HandleEvent);

        QString category = service_category_identifiers_.keys().value(service_category_identifiers_.values().indexOf(category_id));
        if (category == "Framework")
        {
            switch (event_id)
            {
                case Foundation::NETWORKING_REGISTERED:
                {
                    if (!event_query_categories_.contains("NetworkState"))
                        event_query_categories_ << "NetworkState";
                    SubscribeToEventCategories();
                    break;
                }
                case Foundation::WORLD_STREAM_READY:
                {
                    ProtocolUtilities::WorldStreamReadyEvent *event_data = dynamic_cast<ProtocolUtilities::WorldStreamReadyEvent *>(data);
                    if (event_data)
                        current_world_stream_ = event_data->WorldStream;
                    break;
                }
                default:
                    break;
            }
        }
        else if (category == "NetworkState")
        {
            switch (event_id)
            {
                case ProtocolUtilities::Events::EVENT_CONNECTION_FAILED:
                {
                    PublishConnectionState(Failed);
                    break;
                }
                case ProtocolUtilities::Events::EVENT_SERVER_DISCONNECTED:
                {
                    PublishConnectionState(Disconnected);
                    break;
                }
                case ProtocolUtilities::Events::EVENT_SERVER_CONNECTED:
                {
                    // Udp connection has been established, we are still loading object so lets not change UI layer yet
                    // to connected state. See Scene categorys EVENT_CONTROLLABLE_ENTITY case for real UI switch.
                    break;
                }
                default:
                    break;
            }
        }
        else if (category == "Console")
        {
            switch (event_id)
            {
                case Console::Events::EVENT_CONSOLE_TOGGLE:
                {
                    ui_console_manager_->ToggleConsole();
                    break;
                }
                case Console::Events::EVENT_CONSOLE_PRINT_LINE:
                {
                    Console::ConsoleEventData* console_data=dynamic_cast<Console::ConsoleEventData*>(data);
                    ui_console_manager_->QueuePrintRequest(QString(console_data->message.c_str()));
                    break;
                }
                default:
                    break;
            }
        }
        else if (category == "Scene")
        {
            switch (event_id)
            {
                case Scene::Events::EVENT_CONTROLLABLE_ENTITY:
                {
                    PublishConnectionState(Connected);
                    break;
                }
                default:
                    break;
            }
        }

        return false;
    }