123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363 |
- function ProjectModuleCard::onAdd(%this)
- {
- %this.toggleLaunchGroupCount = 0;
- %this.chain = new GuiChainCtrl()
- {
- HorizSizing="width";
- VertSizing="height";
- Position = "0 0";
- Extent = "286 100";
- IsVertical = "1";
- ChildSpacing = -4;
- };
- ThemeManager.setProfile(%this.chain, "emptyProfile");
- %this.add(%this.chain);
- %this.titleText = new GuiControl()
- {
- HorizSizing="width";
- Position = "0 13";
- Extent = "286 38";
- Text = "";
- FontSizeAdjust = "1.4";
- };
- ThemeManager.setProfile(%this.titleText, "titleProfile");
- %this.chain.add(%this.titleText);
- %this.authorText = new GuiControl()
- {
- HorizSizing="width";
- Position = "0 0";
- Extent = "180 22";
- MinExtent = "180 22";
- Text = "Module by Torque2D";
- TextWrap = 1;
- TextExtend = 1;
- FontSizeAdjust = "1.1";
- FontColor = ThemeManager.activeTheme.color5;
- OverrideFontColor = true;
- };
- ThemeManager.setProfile(%this.authorText, "codeProfile");
- %this.chain.add(%this.authorText);
- %this.versionText = new GuiControl()
- {
- HorizSizing="width";
- Position = "0 0";
- Extent = "180 26";
- Text = "Version: 1 Build: 1";
- FontColor = ThemeManager.activeTheme.setAlpha(ThemeManager.activeTheme.color4, 150);
- OverrideFontColor = true;
- };
- ThemeManager.setProfile(%this.versionText, "codeProfile");
- %this.chain.add(%this.versionText);
- %this.addSpacer(%this.chain);
- %this.descriptionText = new GuiControl()
- {
- HorizSizing="width";
- Position = "0 10";
- Extent = "286 150";
- MinExtent = "250 150";
- Text = "";
- TextWrap = 1;
- TextExtend = 1;
- };
- ThemeManager.setProfile(%this.descriptionText, "normalTextProfile");
- %this.chain.add(%this.descriptionText);
- %this.optionGroup = %this.addSubSection("Module Options");
- %this.launchGroupCheckBox = new GuiCheckBoxCtrl()
- {
- Class="ProjectManagerLaunchGroupCheckBox";
- HorizSizing="width";
- Position = "0 0";
- Extent = "286 26";
- Text = "Start on Project Launch";
- BoxOffset = "0 2";
- TextOffset = "22 0";
- TextExtent = "264 26";
- vAlign = "Middle";
- Tooltip = "This change will be applied after restarting.";
- };
- ThemeManager.setProfile(%this.launchGroupCheckBox, "checkboxProfile");
- ThemeManager.setProfile(%this.launchGroupCheckBox, "tipProfile", "TooltipProfile");
- %this.optionGroup.add(%this.launchGroupCheckBox);
- %this.launchGroupCheckBox.addListener(%this);
- %this.addEmptySpace(30, %this.optionGroup);
- %this.addSubSection("Dependencies");
- %this.dependList = new GuiChainCtrl()
- {
- Class = ProjectModuleDependList;
- HorizSizing="width";
- VertSizing="height";
- Position = "0 0";
- Extent = "286 100";
- IsVertical = "1";
- ChildSpacing = 2;
- };
- ThemeManager.setProfile(%this.dependList, "emptyProfile");
- %this.chain.add(%this.dependList);
- %this.button = new GuiButtonCtrl()
- {
- Class="ProjectModuleCardButton";
- HorizSizing="left";
- VertSizing="bottom";
- Position = "184 40";
- Extent = "100 30";
- MinExtent = "100 30";
- Text = "";
- };
- ThemeManager.setProfile(%this.button, "primaryButtonProfile");
- %this.add(%this.button);
- %this.startListening(%this.button);
- %this.startListening(ThemeManager);
- }
- function ProjectModuleCard::addSubSection(%this, %name)
- {
- %chain = new GuiChainCtrl()
- {
- HorizSizing="width";
- VertSizing="height";
- Position = "0 0";
- Extent = "286 0";
- IsVertical = "1";
- ChildSpacing = -4;
- };
- ThemeManager.setProfile(%chain, "emptyProfile");
- %this.chain.add(%chain);
- %subSection = new GuiControl()
- {
- HorizSizing="width";
- Extent = "286 24";
- Text = %name;
- FontSizeAdjust = "0.8";
- };
- ThemeManager.setProfile(%subSection, "titleProfile");
- %chain.add(%subSection);
- %this.addSpacer(%chain);
- %this.addEmptySpace(8, %chain);
- return %chain;
- }
- function ProjectModuleCard::addSpacer(%this, %chain)
- {
- %spacer = new GuiControl()
- {
- HorizSizing="width";
- Position = "0 0";
- Extent = "286 6";
- };
- ThemeManager.setProfile(%spacer, "spacerProfile");
- %chain.add(%spacer);
- return %spacer;
- }
- function ProjectModuleCard::addEmptySpace(%this, %size, %chain)
- {
- %empty = new GuiControl()
- {
- HorizSizing="width";
- Position = "0 0";
- Extent = "286" SPC %size;
- };
- ThemeManager.setProfile(%empty, "emptyProfile");
- %chain.add(%empty);
- return %empty;
- }
- function ProjectModuleCard::onThemeChange(%this, %theme)
- {
- %this.authorText.FontColor = %theme.color5;
- %this.versionText.FontColor = %theme.setAlpha(%theme.color4, 150);
- }
- function ProjectModuleCard::show(%this, %module)
- {
- if(isObject(%module))
- {
- %this.activeModule = %module;
- %this.moduleID = %module.moduleID;
- %this.versionID = %module.versionID;
- %this.titleText.setText(%module.moduleID);
- %this.setAuthor(%module);
- %this.setVersion(%module);
- %this.descriptionText.setText(%module.description);
- %this.button.visible = false;
- %projectModule = %this.getInstalledModule(%module.moduleID, %module.versionID);
- if(%projectModule != %module)
- {
- if(!isObject(%projectModule))
- {
- %this.button.setText("Install");
- %this.button.visible = true;
- }
- else if(%projectmodule.buildID < %module.buildID)
- {
- %this.button.setText("Update");
- %this.button.visible = true;
- }
- }
- else
- {
- }
- %this.optionGroup.visible = false;
- if(!%module.Synchronized)
- {
- %this.optionGroup.visible = true;
- %this.launchGroupCheckBox.setStateOn(%module.Group $= "launch");
- for(%i = 0; %i < %this.toggleLaunchGroupCount; %i++)
- {
- if(%this.toggleLaunchGroup[%i] $= %this.activeModule.getModulePath())
- {
- %this.launchGroupCheckBox.setStateOn(!%this.launchGroupCheckBox.getStateOn());
- break;
- }
- }
- }
- %this.visible = true;
- %this.dependList.show(%module);
- }
- }
- function ProjectModuleCard::hide(%this)
- {
- %this.activeModule = 0;
- %this.moduleID = "";
- %this.versionID = 0;
- %this.visible = false;
- }
- function ProjectModuleCard::setAuthor(%this, %module)
- {
- %author = %module.author;
- if(%author $= "")
- {
- %author = "Torque2D";
- }
- %type = %module.type;
- if(%type $= "")
- {
- %type = "Module";
- }
- %this.authorText.setText(%type SPC "by" SPC %author);
- }
- function ProjectModuleCard::setVersion(%this, %module)
- {
- %version = %module.versionID;
- if(%version $= "")
- {
- %version = 1;
- }
- %build = %module.buildID;
- if(%build $= "")
- {
- %build = 0;
- }
- %this.versionText.setText("Version:" SPC %version @ " Build:" SPC %build);
- }
- function ProjectModuleCard::getInstalledModule(%this, %moduleID, %versionID)
- {
- %allModules = ModuleDatabase.findModules(false);
- %count = getWordCount(%allModules);
- for(%i = 0; %i < %count; %i++)
- {
- %projectModule = getWord(%allModules, %i);
- if(%moduleID $= %projectModule.ModuleID && %versionID == %projectModule.VersionID)
- {
- return %projectModule;
- }
- }
- return 0;
- }
- function ProjectModuleCardButton::onClick(%this)
- {
- %this.postEvent("ButtonClick");
- }
- function ProjectModuleCard::onButtonClick(%this)
- {
- %this.postEvent(%this.button.getText() @ "Click");
- }
- function ProjectManagerLaunchGroupCheckBox::onClick(%this)
- {
- %state = %this.getStateOn();
- %this.postEvent("LauchGroupClick", %state);
- }
- function ProjectModuleCard::onLauchGroupClick(%this, %state)
- {
- %this.startListening(ProjectManager);
- if(isObject(%this.activeModule))
- {
- if((%state && %this.activeModule.group $= "launch") || (!%state && %this.activeModule.group !$= "launch"))
- {
- %path = %this.activeModule.getModulePath();
- for(%i = 0; %i < %this.toggleLaunchGroupCount; %i++)
- {
- if(%this.toggleLaunchGroup[%i] $= %path)
- {
- %this.toggleLaunchGroup[%i] = "";
- }
- }
- }
- else
- {
- %this.toggleLaunchGroup[%this.toggleLaunchGroupCount] = %this.activeModule.getModulePath();
- %this.toggleLaunchGroupCount++;
- }
- }
- }
- function ProjectModuleCard::onShutDown(%this)
- {
- for(%i = 0; %i < %this.toggleLaunchGroupCount; %i++)
- {
- %path = pathConcat(%this.toggleLaunchGroup[%i], "module.taml");
- if(%path !$= "" && isFile(%path))
- {
- %this.toggleLaunchGroupForPath(%path);
- }
- }
- }
- function ProjectModuleCard::toggleLaunchGroupForPath(%this, %path)
- {
- %module = TamlRead(%path);
- if(%module.group $= "launch")
- {
- %module.group = "";
- }
- else
- {
- %module.group = "launch";
- }
- TamlWrite(%module, %path);
- }
|