project_manager.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*************************************************************************/
  2. /* project_manager.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  9. /* */
  10. /* Permission is hereby granted, free of charge, to any person obtaining */
  11. /* a copy of this software and associated documentation files (the */
  12. /* "Software"), to deal in the Software without restriction, including */
  13. /* without limitation the rights to use, copy, modify, merge, publish, */
  14. /* distribute, sublicense, and/or sell copies of the Software, and to */
  15. /* permit persons to whom the Software is furnished to do so, subject to */
  16. /* the following conditions: */
  17. /* */
  18. /* The above copyright notice and this permission notice shall be */
  19. /* included in all copies or substantial portions of the Software. */
  20. /* */
  21. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  22. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  23. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  24. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  25. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  26. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  27. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  28. /*************************************************************************/
  29. #ifndef PROJECT_MANAGER_H
  30. #define PROJECT_MANAGER_H
  31. #include "scene/gui/dialogs.h"
  32. #include "scene/gui/tree.h"
  33. #include "scene/gui/scroll_container.h"
  34. #include "scene/gui/file_dialog.h"
  35. #include "scene/gui/tool_button.h"
  36. class NewProjectDialog;
  37. class ProjectListFilter;
  38. class ProjectManager : public Control {
  39. OBJ_TYPE( ProjectManager, Control );
  40. Button *erase_btn;
  41. Button *open_btn;
  42. Button *run_btn;
  43. FileDialog *scan_dir;
  44. ProjectListFilter *project_filter;
  45. ConfirmationDialog *erase_ask;
  46. ConfirmationDialog *multi_open_ask;
  47. ConfirmationDialog *multi_run_ask;
  48. NewProjectDialog *npdialog;
  49. ScrollContainer *scroll;
  50. VBoxContainer *scroll_childs;
  51. Map<String, String> selected_list; // name -> main_scene
  52. String last_clicked;
  53. String single_selected_main;
  54. bool importing;
  55. void _item_doubleclicked();
  56. void _scan_projects();
  57. void _run_project();
  58. void _run_project_confirm();
  59. void _open_project();
  60. void _open_project_confirm();
  61. void _import_project();
  62. void _new_project();
  63. void _erase_project();
  64. void _erase_project_confirm();
  65. void _exit_dialog();
  66. void _scan_begin(const String& p_base);
  67. void _load_recent_projects();
  68. void _scan_dir(DirAccess *da,float pos, float total,List<String> *r_projects);
  69. void _panel_draw(Node *p_hb);
  70. void _panel_input(const InputEvent& p_ev,Node *p_hb);
  71. void _favorite_pressed(Node *p_hb);
  72. protected:
  73. static void _bind_methods();
  74. public:
  75. ProjectManager();
  76. ~ProjectManager();
  77. };
  78. class ProjectListFilter : public HBoxContainer {
  79. OBJ_TYPE( ProjectListFilter, HBoxContainer );
  80. private:
  81. friend class ProjectManager;
  82. enum Command {
  83. CMD_CLEAR_FILTER,
  84. };
  85. OptionButton *filter_option;
  86. LineEdit *search_box;
  87. ToolButton *clear_search_button;
  88. enum FilterOption {
  89. FILTER_NAME,
  90. FILTER_PATH,
  91. };
  92. FilterOption _current_filter;
  93. void _command(int p_command);
  94. void _search_text_changed(const String& p_newtext);
  95. void _setup_filters();
  96. void _filter_option_selected(int p_idx);
  97. protected:
  98. void _notification(int p_what);
  99. static void _bind_methods();
  100. public:
  101. String get_search_term();
  102. FilterOption get_filter_option();
  103. ProjectListFilter();
  104. };
  105. #endif // PROJECT_MANAGER_H