Urho3DPlayer.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #include <Urho3D/Engine/Application.h>
  5. using namespace Urho3D;
  6. /// Urho3DPlayer application runs a script specified on the command line.
  7. class Urho3DPlayer : public Application
  8. {
  9. URHO3D_OBJECT(Urho3DPlayer, Application);
  10. public:
  11. /// Construct.
  12. explicit Urho3DPlayer(Context* context);
  13. /// Setup before engine initialization. Verify that a script file has been specified.
  14. void Setup() override;
  15. /// Setup after engine initialization. Load the script and execute its start function.
  16. void Start() override;
  17. /// Cleanup after the main loop. Run the script's stop function if it exists.
  18. void Stop() override;
  19. private:
  20. /// Handle reload start of the script file.
  21. void HandleScriptReloadStarted(StringHash eventType, VariantMap& eventData);
  22. /// Handle reload success of the script file.
  23. void HandleScriptReloadFinished(StringHash eventType, VariantMap& eventData);
  24. /// Handle reload failure of the script file.
  25. void HandleScriptReloadFailed(StringHash eventType, VariantMap& eventData);
  26. /// Parse script file name from the first argument.
  27. void GetScriptFileName();
  28. /// Script file name.
  29. String scriptFileName_;
  30. /// Flag whether CommandLine.txt was already successfully read.
  31. bool commandLineRead_;
  32. #ifdef URHO3D_ANGELSCRIPT
  33. /// Script file.
  34. SharedPtr<ScriptFile> scriptFile_;
  35. #endif
  36. };