ProjectModuleDependList.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. function ProjectModuleDependList::onAdd(%this)
  2. {
  3. %this.startListening(ThemeManager);
  4. }
  5. function ProjectModuleDependList::onThemeChange(%this, %theme)
  6. {
  7. if(isObject(%this.activeModule))
  8. {
  9. %this.show(%this.activeModule);
  10. }
  11. }
  12. function ProjectModuleDependList::show(%this, %module)
  13. {
  14. %this.activeModule = %module;
  15. %this.clearItems();
  16. for(%i = 0; %i < %module.getdependencyCount(); %i++)
  17. {
  18. %dep = %module.getDependency(%i);
  19. %name = getWord(%dep, 0);
  20. %version = getWord(%dep, 1);
  21. if(%version $= "*" || %version $= "0")
  22. {
  23. %version = "Latest";
  24. }
  25. %this.addDependItem(%name, %version);
  26. }
  27. if(!%module.Synchronized)
  28. {
  29. %this.addAddButton();
  30. }
  31. }
  32. function ProjectModuleDependList::hide(%this)
  33. {
  34. %this.activeModule = 0;
  35. %this.clearItems();
  36. }
  37. function ProjectModuleDependList::clearItems(%this)
  38. {
  39. for(%i = %this.getCount() - 1; %i >= 0; %i--)
  40. {
  41. %item = %this.getObject(%i);
  42. %item.delete();
  43. }
  44. }
  45. function ProjectModuleDependList::addDependItem(%this, %name, %version)
  46. {
  47. %width = getWord(%this.extent, 0) - 6;
  48. %text = new GuiControl()
  49. {
  50. HorizSizing="width";
  51. Position = "3 0";
  52. Extent = %width SPC "26";
  53. Text = %name @ ":" @ %version;
  54. Align = "Left";
  55. VAlign = "Middle";
  56. };
  57. ThemeManager.setProfile(%text, "subListProfile");
  58. %this.add(%text);
  59. }
  60. function ProjectModuleDependList::addAddButton(%this)
  61. {
  62. %width = 140;
  63. %addButton = new GuiButtonCtrl()
  64. {
  65. Class="ProjectModuleDependButton";
  66. ButtonEvent = "AddDepend";
  67. ButtonData = "";
  68. HorizSizing="right";
  69. Position = "3 0";
  70. Extent = %width SPC "26";
  71. MinExtent = %width SPC "26";
  72. Text = "+Add Dependency";
  73. Align = "Center";
  74. VAlign = "Middle";
  75. TextExtend = 1;
  76. };
  77. ThemeManager.setProfile(%addButton, "subListProfile");
  78. %this.add(%addButton);
  79. %this.startListening(%addButton);
  80. }
  81. function ProjectModuleDependButton::onClick(%this)
  82. {
  83. %this.postEvent(%this.buttonEvent, %this.buttonData);
  84. }
  85. function ProjectModuleDependList::onAddDepend(%this)
  86. {
  87. %width = 500;
  88. %height = 190;
  89. %dialog = new GuiControl()
  90. {
  91. class = "NewDependencyDialog";
  92. superclass = "EditorDialog";
  93. dialogSize = (%width + 8) SPC (%height + 8);
  94. dialogCanClose = true;
  95. dialogText = "New Dependency";
  96. };
  97. %dialog.init(%width, %height);
  98. %this.startListening(%dialog);
  99. Canvas.pushDialog(%dialog);
  100. }
  101. function ProjectModuleDependList::onDependencyAdded(%this, %data)
  102. {
  103. %this.activeModule.addDependency(%data.module, %data.version);
  104. %this.activeModule.save();
  105. %this.show(%this.activeModule);
  106. }
  107. function ProjectModuleDependList::onRemoveDepend(%this, %data)
  108. {
  109. }
  110. function ProjectModuleDependList::onDialogClosed(%this, %dialog)
  111. {
  112. %this.dialog = %dialog;
  113. %this.schedule(100, "deleteDialog");
  114. }
  115. function ProjectModuleDependList::deleteDialog(%this)
  116. {
  117. %this.dialog.delete();
  118. }