ProjectLibraryPanel.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. function ProjectLibraryPanel::onAdd(%this)
  2. {
  3. %this.init("Library");
  4. }
  5. function ProjectLibraryPanel::load(%this)
  6. {
  7. %this.manager = new ModuleManager();
  8. %this.manager.addListener(AssetDatabase);
  9. %this.manager.EchoInfo = false;
  10. %this.manager.ScanModules(pathConcat(getMainDotCsDir(), "library"));
  11. %allModules = %this.manager.findModules(false);
  12. for(%i = 0; %i < getWordCount(%allModules); %i++)
  13. {
  14. %mod = getWord(%allModules, %i);
  15. %this.addModule(%mod);
  16. }
  17. %this.list.sortByText();
  18. }
  19. function ProjectLibraryPanel::addModule(%this, %module)
  20. {
  21. if(%module.type !$= "Template")
  22. {
  23. %this.list.addItemWithID(%this.getModuleName(%module), %module);
  24. }
  25. }
  26. function ProjectLibraryPanel::onOpen(%this, %allModules)
  27. {
  28. %count = %this.list.getItemCount();
  29. for(%i = 0; %i < %count; %i++)
  30. {
  31. %module = %this.list.getItemID(%i);
  32. %this.refreshColor(%module, %i, %allModules);
  33. }
  34. }
  35. function ProjectLibraryPanel::refreshColor(%this, %module, %index, %projectModules)
  36. {
  37. %color = %this.gray;
  38. if(%module.Deprecated)
  39. {
  40. %color = %this.darkRed;
  41. }
  42. for(%i = 0; %i < getWordCount(%projectModules); %i++)
  43. {
  44. %projectModule = getWord(%projectModules, %i);
  45. if(%projectModule.ModuleId $= %module.ModuleId && %projectModule.VersionId $= %module.VersionId)
  46. {
  47. %color = %this.yellow;
  48. if(%module.Deprecated)
  49. {
  50. %color = %this.darkRed;
  51. }
  52. else if(%module.BuildID > %projectModule.BuildID)
  53. {
  54. %color = %this.purple;
  55. }
  56. }
  57. }
  58. %this.list.setItemColor(%index, %color);
  59. }
  60. function ProjectLibraryPanel::onInstallClick(%this)
  61. {
  62. %index = %this.list.getSelectedItem();
  63. %module = %this.list.getItemID(%index);
  64. if(isObject(%module))
  65. {
  66. %this.manager.CopyModule(%module.moduleID, %module.versionID, %module.moduleID, ProjectManager.getProjectFolder(), true);
  67. %this.manager.synchronizeDependencies(%module, ProjectManager.getProjectFolder());
  68. ModuleDatabase.ScanModules(ProjectManager.getProjectFolder());
  69. %installedModule = ModuleDatabase.findModule(%module.moduleID, %module.versionID);
  70. %this.postEvent("ModuleInstalled", %installedModule);
  71. }
  72. }
  73. function ProjectLibraryPanel::onUpdateClick(%this)
  74. {
  75. }