//--------------------------------------------------------------------------------------- void FSkookumScriptRuntime::on_world_init_pre(UWorld * world_p, const UWorld::InitializationValues init_vals) { //A_DPRINT("on_world_init_pre: %S %p\n", *world_p->GetName(), world_p); // Use this callback as an opportunity to take care of connecting to the IDE #ifdef SKOOKUM_REMOTE_UNREAL if (!IsRunningCommandlet() && !m_remote_client.is_authenticated()) { m_remote_client.attempt_connect(0.0, true, true); } #endif if (world_p->IsGameWorld()) { if (!m_game_world_p) { m_game_world_p = world_p; if (is_skookum_initialized()) { SkUEClassBindingHelper::set_world(world_p); } m_game_tick_handle = world_p->OnTickDispatch().AddRaw(this, &FSkookumScriptRuntime::tick_game); } } else if (world_p->WorldType == EWorldType::Editor) { if (!m_editor_world_p) { m_editor_world_p = world_p; m_editor_tick_handle = world_p->OnTickDispatch().AddRaw(this, &FSkookumScriptRuntime::tick_editor); } } }
//--------------------------------------------------------------------------------------- void FSkookumScriptRuntime::on_world_init_pre(UWorld * world_p, const UWorld::InitializationValues init_vals) { //A_DPRINT("on_world_init_pre: %S %p\n", *world_p->GetName(), world_p); // Make sure atomics are bound by now if (m_runtime.is_compiled_scripts_loaded() && !m_runtime.is_compiled_scripts_bound()) { m_runtime.bind_compiled_scripts(); } // Use this callback as an opportunity to take care of connecting to the IDE #ifdef SKOOKUM_REMOTE_UNREAL if (!IsRunningCommandlet() && !m_remote_client.is_authenticated()) { m_remote_client.attempt_connect(0.0, true, true); } #endif if (world_p->IsGameWorld()) { // Keep track of how many game worlds we got ++m_num_game_worlds; if (!m_game_world_p) { m_game_world_p = world_p; if (is_skookum_initialized()) { SkUEClassBindingHelper::set_world(world_p); SkookumScript::initialize_gameplay(); } m_game_tick_handle = world_p->OnTickDispatch().AddRaw(this, &FSkookumScriptRuntime::tick_game); } } else if (world_p->WorldType == EWorldType::Editor) { if (!m_editor_world_p) { m_editor_world_p = world_p; m_editor_tick_handle = world_p->OnTickDispatch().AddRaw(this, &FSkookumScriptRuntime::tick_editor); } } }
void FSkookumScriptRuntime::compile_and_load_binaries() { #ifdef SKOOKUM_REMOTE_UNREAL // At this point, have zero patience with the IDE and launch it if not connected if (!IsRunningCommandlet()) { // At this point, wait if necessary to make sure we are connected m_remote_client.ensure_connected(0.0); // Alert user in case we are still not connected - and allow for corrective measures bool load_binaries = true; #if WITH_EDITOR while (!m_remote_client.is_authenticated()) { FText title = FText::FromString(TEXT("SkookumScript UE4 Plugin cannot connect to the SkookumIDE!")); EAppReturnType::Type decision = FMessageDialog::Open( EAppMsgType::CancelRetryContinue, FText::Format(FText::FromString(TEXT( "The SkookumScript UE4 Plugin cannot connect to the SkookumIDE. A connection to the SkookumIDE is required to properly work with SkookumScript.\n\n" "The connection problem could be caused by any of the following situations:\n" "- The SkookumIDE application is not running. If this is the case, your security software (Virus checker, VPN, Firewall) may have blocked or even removed it. If so, allow SkookumIDE.exe to run, then click 'Retry'. " "You can also try to launch the IDE manually. It should be located at the following path: {0}. Once running, click 'Retry'.\n" "- The SkookumIDE application is running, but stuck on an error. If so, try to resolve the error, and when the SkookumIDE is back up, click 'Retry'.\n" "- The SkookumIDE application is running and seems to be working fine. " "If so, the IP and port that the SkookumScript UE4 Plugin is trying to connect to ({1}) might be different from the IP and port that the SkookumIDE is listening to (see SkookumIDE log window), or blocked by a firewall. " "These problems could be due to your networking environment, such as a custom firewall, virtualization software such as VirtualBox, or multiple network adapters.\n\n" "For additional information including how to specify the SkookumIDE address for the runtime, please see http://skookumscript.com/docs/v3.0/ide/ip-addresses/ and ensure 'Settings'->'Remote runtimes' on the SkookumIDE is set properly.\n\n" "If you are having difficulties resolving this issue, please don't hesitate to ask us for help at the SkookumScript Forum (http://forum.skookumscript.com). We are here to make your experience skookum!\n")), FText::FromString(FPaths::ConvertRelativePathToFull(IPluginManager::Get().FindPlugin(TEXT("SkookumScript"))->GetBaseDir() / TEXT("SkookumIDE") / TEXT("SkookumIDE.exe"))), FText::FromString(m_remote_client.get_ip_address_ide()->ToString(true))), &title); if (decision != EAppReturnType::Retry) { load_binaries = (decision == EAppReturnType::Continue); break; } m_remote_client.ensure_connected(10.0); } #endif if (load_binaries && m_remote_client.is_authenticated()) { #if WITH_EDITOR RetryCompilation: #endif // Block while binaries are being recompiled m_remote_client.cmd_compiled_state(true); m_freshen_binaries_requested = false; // Request satisfied while (!m_remote_client.is_load_compiled_binaries_requested() && !m_remote_client.is_compiled_binaries_have_errors()) { m_remote_client.wait_for_update(); } #if WITH_EDITOR if (m_remote_client.is_compiled_binaries_have_errors()) { FText title = FText::FromString(TEXT("Compilation errors!")); EAppReturnType::Type decision = FMessageDialog::Open( EAppMsgType::CancelRetryContinue, FText::FromString(TEXT( "The SkookumScript compiled binaries could not be generated because errors were found in the script files.\n\n")), &title); if (decision == EAppReturnType::Retry) { m_remote_client.clear_load_compiled_binaries_requested(); goto RetryCompilation; } load_binaries = (decision == EAppReturnType::Continue); } #endif m_remote_client.clear_load_compiled_binaries_requested(); } if (load_binaries) { // Attempt to load binaries at this point bool success_b = m_runtime.load_compiled_scripts(); if (success_b) { // Inform the IDE about the version we got m_remote_client.cmd_incremental_update_reply(true, SkBrain::ms_session_guid, SkBrain::ms_revision); } else { // Something went wrong - let the user know FText title = FText::FromString(TEXT("Unable to load SkookumScript compiled binaries!")); FMessageDialog::Open( EAppMsgType::Ok, FText::FromString(TEXT( "Unable to load the compiled binaries. This is most likely caused by errors in the script files which prevented a successful compilation. The project will continue to load with SkookumScript temporarily disabled.")), &title); } } } else #endif { // If no remote connection, or commandlet mode, load binaries at this point bool success_b = m_runtime.load_compiled_scripts(); SK_ASSERTX(success_b, AErrMsg("Unable to load SkookumScript compiled binaries!", AErrLevel_notify)); } }