JSResourceEditor.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  3. // LICENSE: Atomic Game Engine Editor and Tools EULA
  4. // Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
  5. // license information: https://github.com/AtomicGameEngine/AtomicGameEngine
  6. //
  7. #pragma once
  8. #include "ResourceEditor.h"
  9. using namespace Atomic;
  10. using namespace tb;
  11. namespace Atomic
  12. {
  13. class UIWebView;
  14. class WebClient;
  15. class WebMessageHandler;
  16. }
  17. namespace AtomicEditor
  18. {
  19. class JSResourceEditor: public ResourceEditor
  20. {
  21. OBJECT(JSResourceEditor);
  22. public:
  23. JSResourceEditor(Context* context, const String& fullpath, UITabContainer* container);
  24. virtual ~JSResourceEditor();
  25. bool OnEvent(const TBWidgetEvent &ev);
  26. bool FindText(const String& findText, unsigned flags);
  27. void FindTextClose();
  28. void GotoTokenPos(int tokenPos);
  29. void GotoLineNumber(int lineNumber);
  30. void FormatCode();
  31. void SetFocus();
  32. bool Save();
  33. private:
  34. void HandleWebViewLoadEnd(StringHash eventType, VariantMap& eventData);
  35. void HandleWebMessage(StringHash eventType, VariantMap& eventData);
  36. bool BeautifyJavascript(const char* source, String& output);
  37. SharedPtr<UIWebView> webView_;
  38. WeakPtr<WebClient> webClient_;
  39. WeakPtr<WebMessageHandler> messageHandler_;
  40. };
  41. }