LuaEditor.cpp 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Source/LuaIDEApplication.h>
  9. #include <AzQtComponents/Utilities/HandleDpiAwareness.h>
  10. #include <QtCore/QCoreApplication>
  11. #if defined(EXTERNAL_CRASH_REPORTING)
  12. #include <ToolsCrashHandler.h>
  13. #endif
  14. #include <QApplication>
  15. #include <QDir>
  16. #include <QFileInfo>
  17. // Editor.cpp : Defines the entry point for the application.
  18. int main(int argc, char* argv[])
  19. {
  20. const AZ::Debug::Trace tracer;
  21. // here we free the console (and close the console window) in release.
  22. int exitCode = 0;
  23. {
  24. AZStd::unique_ptr<AZ::IO::LocalFileIO> fileIO = AZStd::unique_ptr<AZ::IO::LocalFileIO>(aznew AZ::IO::LocalFileIO());
  25. AZ::IO::FileIOBase::SetInstance(fileIO.get());
  26. QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
  27. QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
  28. QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
  29. QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
  30. AzQtComponents::Utilities::HandleDpiAwareness(AzQtComponents::Utilities::PerScreenDpiAware);
  31. LUAEditor::Application app(argc, argv);
  32. QString procName;
  33. {
  34. QCoreApplication qca(argc, argv);
  35. procName = QFileInfo(qca.applicationFilePath()).fileName();
  36. }
  37. LegacyFramework::ApplicationDesc desc(procName.toUtf8().data(), argc, argv);
  38. desc.m_applicationModule = NULL;
  39. desc.m_enableProjectManager = false;
  40. #if defined(EXTERNAL_CRASH_REPORTING)
  41. CrashHandler::ToolsCrashHandler::InitCrashHandler("LuaEditor", {});
  42. #endif
  43. exitCode = app.Run(desc);
  44. // this call will block until someone tells the core app to shut down via a bus message.
  45. // the bus message is usually sent (in gui mode) in response to pressing the quit button or something.
  46. // in an app that does not require GUI to be manufactured or use GUI windows, you should still call RUN
  47. // but make a component which does your processing, in response to RestoreState(). in the CoreMessages bus.
  48. // RestoreState will always be called right before the main message pump activates.
  49. // and will then block until someone calls:
  50. /*UIFramework::FrameworkMessages::Bus::Broadcast(&UIFramework::FrameworkMessages::Bus::Events::UserWantsToQuit); */
  51. // so ideally to make a file processor or something, simply call app.Initialize(.... but with false as the gui mode ... )
  52. // and make at least one component which starts processing in response to CoreMessages::RestoreState(), and then sends UserWantsToQuit() once it has done its processing.
  53. // calling UserWantsToQuit will simply queue the quit, so its safe to call from any thread.
  54. // your components can query
  55. // FrameworkApplicationMessages::Bus::BroadcastResult(result, &FrameworkApplicationMessages::Bus::Events::IsRunningInGUIMode) to
  56. // determine if its in GUI mode or not.
  57. }
  58. return exitCode;
  59. }