Update
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
This script contains procedures that supports for attribute sync between Sliders, attribute buttons and maya attributes.
|
||||
*/
|
||||
|
||||
proc string mgp_getAttrSyncCommand(string $node, string $attrLongName)
|
||||
{
|
||||
return ("MGPickerAttrSyncer -s \""+$node+"\" \""+$attrLongName+"\";");
|
||||
}
|
||||
|
||||
/*
|
||||
global proc _MGP_evaluateAllAttrSyncCommands()
|
||||
{
|
||||
// To-Do: Do a performance pass in c++ to achieve a optimum sync scheduling system.
|
||||
global int $MGPICKER_startTime_refresh;
|
||||
$elapsedTime = `timerX -startTime $MGPICKER_startTime_refresh`;
|
||||
string $pattern = "*MGPickerAttrSyncer*";
|
||||
if ($elapsedTime > 1)
|
||||
{
|
||||
$jobs = `scriptJob -listJobs`;
|
||||
for($i=0; $i<size($jobs); ++$i)
|
||||
{
|
||||
string $script_str = $jobs[$i];
|
||||
if(`gmatch $script_str $pattern`)
|
||||
{
|
||||
$parts = stringToStringArray($script_str, "\"");
|
||||
string $nodeAttr[] = stringToStringArray($parts[5], ".");
|
||||
string $syncCmd = `mgp_getAttrSyncCommand $nodeAttr[0] $nodeAttr[1]`;
|
||||
eval ($syncCmd);
|
||||
}
|
||||
}
|
||||
$MGPICKER_startTime_refresh = `timerX`;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
proc mgp_createScriptJobDoit(string $node, string $attrLongName)
|
||||
{
|
||||
// Because we need to catchQuiet when call this function, which occupies the return value,
|
||||
// so global variable is used here as a stupid workaround:
|
||||
global int $MGPICKER_WatcherID;
|
||||
string $syncCmd = `mgp_getAttrSyncCommand $node $attrLongName`;
|
||||
// to-do: check why _MGP_evaluateAllAttrSyncCommands helped but now it messed up.
|
||||
$MGPICKER_WatcherID = `scriptJob -killWithScene -attributeChange ($node+"."+$attrLongName) $syncCmd`;
|
||||
}
|
||||
|
||||
global proc int MGP_CreateWatcher(string $node, string $attrLongName)
|
||||
{
|
||||
if(!`objExists $node`)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if(`nodeType $node` == "container")
|
||||
{
|
||||
string $bindAttrs[]=`container -q -bindAttr $node`;
|
||||
int $sz = size($bindAttrs);
|
||||
for($i=0; $i<$sz; $i+=2)
|
||||
{
|
||||
if($bindAttrs[$i+1] == $attrLongName)
|
||||
{
|
||||
string $realObjDotName = $bindAttrs[$i];
|
||||
string $temp[]=`stringToStringArray $realObjDotName "."`;
|
||||
$node = $temp[0];
|
||||
$attrLongName = $temp[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!`attributeExists $attrLongName $node`)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int $error = catchQuiet(`mgp_createScriptJobDoit $node $attrLongName`);
|
||||
if($error)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
global int $MGPICKER_WatcherID;
|
||||
return $MGPICKER_WatcherID;
|
||||
}
|
||||
global proc MGP_DeleteWatcher(int $id)
|
||||
{
|
||||
if(!`scriptJob -ex $id`)
|
||||
{
|
||||
return;
|
||||
}
|
||||
scriptJob -kill $id;
|
||||
}
|
||||
global proc int MGP_WatcherExist(int $id)
|
||||
{
|
||||
return `scriptJob -ex $id`;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
# To-Do: Maya calls need to be removed for non-maya mode.
|
||||
from maya import mel
|
||||
|
||||
|
||||
def initializePythonModules():
|
||||
def _addToSysPath(pathStr, label):
|
||||
if not os.path.isdir(pathStr):
|
||||
print(
|
||||
"Error initializing MGPicker {}, as the directory does not exist: {}".format(
|
||||
label, pathStr
|
||||
)
|
||||
)
|
||||
return
|
||||
|
||||
if not sys.path.count(pathStr):
|
||||
sys.path.append(pathStr)
|
||||
|
||||
_addToSysPath(mel.eval("MGP_GetPythonAPIDir"), "python API")
|
||||
_addToSysPath(mel.eval("MGP_GetAutoLoaderDir"), "autoLoaders")
|
||||
|
||||
|
||||
initializePythonModules()
|
||||
@@ -0,0 +1,16 @@
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
|
||||
def MGP_LoadProcess(program, args=[]):
|
||||
if not program or not os.path.isfile(program):
|
||||
return False
|
||||
theArgs = [program]
|
||||
theArgs.extend(args)
|
||||
try:
|
||||
subprocess.Popen(theArgs)
|
||||
except Exception as e:
|
||||
print("Error loading program {}: {}".format(program, e.value))
|
||||
return False
|
||||
|
||||
return True
|
||||
@@ -0,0 +1,244 @@
|
||||
//==============================================================//
|
||||
// MGFloatingLicence Shared Procedures
|
||||
//==============================================================//
|
||||
//Author: Miguel (Wenfeng Gao)
|
||||
//website: http://mgland.com
|
||||
//E-mail: mgtoolspro@gmail.com
|
||||
//CopyRight Miguel @ mgland animation studio.
|
||||
//The script is shared between MGTools and MG-PickerStudio, etc.
|
||||
//==============source codes if necessary=========================
|
||||
proc initGlobalVars()
|
||||
{
|
||||
global string $gMG_LicenseConnectorDir_ov;
|
||||
$gMG_LicenseConnectorDir_ov = "MG_LicenceConnectorDir";
|
||||
|
||||
global string $gMG_Connector_APPName;
|
||||
$gMG_Connector_APPName = "MG-LicenceConnector";
|
||||
|
||||
global string $gMG_ConnectorInfoServerFileName = "MG_LicenceConnector.txt";
|
||||
global string $gMG_ConnectorInfoServerFile_Dir_Key = "MGPICKER_FLOAT_LIC_CONNECTOR_DIR";
|
||||
}
|
||||
initGlobalVars;
|
||||
proc int mg_osType()
|
||||
{
|
||||
int $osType = 0;
|
||||
if(`about -mac`)
|
||||
{
|
||||
$osType = 1;
|
||||
}
|
||||
else if(`about -linux`)
|
||||
{
|
||||
$osType = 2;
|
||||
}
|
||||
return $osType;
|
||||
}
|
||||
proc string mg_getProgramExt()
|
||||
{
|
||||
int $osType = 1-`about -win`;
|
||||
string $ext = ".exe";
|
||||
if($osType) //macos && linux
|
||||
{
|
||||
$ext = "";
|
||||
}
|
||||
return $ext;
|
||||
}
|
||||
global proc string MGP_GetConnectorProgramFileName()
|
||||
{
|
||||
global string $gMG_Connector_APPName;
|
||||
return ($gMG_Connector_APPName + `mg_getProgramExt`);
|
||||
}
|
||||
|
||||
proc string mg_substituteToLocalSep(string $path)
|
||||
{
|
||||
if(!`mg_osType`)
|
||||
{
|
||||
return `substituteAllString $path "/" "\\"`;
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
//for getting programs from optionVar and server define ------------------------------
|
||||
|
||||
proc string mg_getServerConnectionFile(string $serverConfigDir)
|
||||
{
|
||||
global string $gMG_ConnectorInfoServerFileName;
|
||||
string $file = $serverConfigDir + $gMG_ConnectorInfoServerFileName;
|
||||
return `mg_substituteToLocalSep $file`;
|
||||
}
|
||||
proc string mg_getSubfolderAbsolutePath(string $serverConfigDir, string $path)
|
||||
{
|
||||
string $pwd = $serverConfigDir;
|
||||
$path = `substring $path 3 (size($path))`;
|
||||
return $pwd + $path;
|
||||
}
|
||||
proc string mg_getParentfolderAbsolutePath(string $serverConfigDir, string $path)
|
||||
{
|
||||
string $pwd = $serverConfigDir;
|
||||
string $pathParts[] = `stringToStringArray $path "/"`;
|
||||
string $nonDotParts[];
|
||||
for($p in $pathParts)
|
||||
{
|
||||
if($p == "..")
|
||||
{
|
||||
$pwd = `dirname $pwd`;
|
||||
}
|
||||
else
|
||||
{
|
||||
$nonDotParts[size($nonDotParts)] = $p;
|
||||
}
|
||||
}
|
||||
string $leftoverPath = `stringArrayToString $nonDotParts "/"`;
|
||||
if(!`endsWith $pwd "/"`)
|
||||
{
|
||||
$pwd += "/";
|
||||
}
|
||||
return $pwd + $leftoverPath;
|
||||
}
|
||||
proc string mg_parseServerConnectorPath(string $serverConfigDir, string $path, int $fullPath)
|
||||
{
|
||||
$path = strip($path);
|
||||
$path = `substituteAllString $path "\\" "/"`;
|
||||
if(`gmatch $path "./*"`)
|
||||
{
|
||||
$path = `mg_getSubfolderAbsolutePath $serverConfigDir $path`;
|
||||
}
|
||||
else if(`gmatch $path "../*"`)
|
||||
{
|
||||
$path = `mg_getParentfolderAbsolutePath $serverConfigDir $path`;
|
||||
}
|
||||
|
||||
string $programFileName = `MGP_GetConnectorProgramFileName`;
|
||||
int $isFullPath = `endsWith $path $programFileName`;
|
||||
if(!$fullPath && $isFullPath)
|
||||
{
|
||||
$path = `dirname $path` + "/";
|
||||
}
|
||||
if($fullPath && !$isFullPath)
|
||||
{
|
||||
if(!`endsWith $path "/"`)
|
||||
{
|
||||
$path += "/";
|
||||
}
|
||||
$path += $programFileName;
|
||||
}
|
||||
return `mg_substituteToLocalSep $path`;
|
||||
}
|
||||
global proc string MG_GetServerConnector(string $serverConfigDir, int $fullPath)
|
||||
{
|
||||
global string $gMG_ConnectorInfoServerFile_Dir_Key;
|
||||
string $value = strip(`getenv $gMG_ConnectorInfoServerFile_Dir_Key`);
|
||||
if(!size($value))
|
||||
{
|
||||
string $file = `mg_getServerConnectionFile $serverConfigDir`;
|
||||
if(!`filetest -f $file`)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
$readFileID=`fopen $file "r"`;
|
||||
while(!`feof $readFileID`)
|
||||
{
|
||||
$nextLine=strip(`fgetline $readFileID`);
|
||||
if (size($nextLine) && !`startsWith $nextLine "#"`)
|
||||
{
|
||||
if(`startsWith $nextLine $gMG_ConnectorInfoServerFile_Dir_Key`)
|
||||
{
|
||||
string $datas[]=`stringToStringArray $nextLine "="`;
|
||||
if(size($datas)!=2)
|
||||
{
|
||||
fclose $readFileID;
|
||||
return "";
|
||||
}
|
||||
fclose $readFileID;
|
||||
$value = $datas[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose $readFileID;
|
||||
}
|
||||
if(size($value))
|
||||
{
|
||||
return `mg_parseServerConnectorPath $serverConfigDir $value $fullPath`;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
global proc string MG_getLicenseConnectorDir(string $serverConfigDir, int $fullPath)
|
||||
{
|
||||
global string $gMG_LicenseConnectorDir_ov;
|
||||
string $dir;
|
||||
//we check out the server data file first:
|
||||
string $pathInServerFile = `MG_GetServerConnector $serverConfigDir $fullPath`;
|
||||
if(size($pathInServerFile))
|
||||
{
|
||||
if(!$fullPath)
|
||||
{
|
||||
$pathInServerFile = `mg_substituteToLocalSep $pathInServerFile `;
|
||||
if(`filetest -d $pathInServerFile`)
|
||||
{
|
||||
return $pathInServerFile;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$pathInServerFile = `mg_substituteToLocalSep $pathInServerFile `;
|
||||
if(`filetest -f $pathInServerFile`)
|
||||
{
|
||||
return $pathInServerFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
//if not server record:
|
||||
int $hasRecord = 0;
|
||||
if(`optionVar -ex $gMG_LicenseConnectorDir_ov`)
|
||||
{
|
||||
$dir = `optionVar -q $gMG_LicenseConnectorDir_ov`;
|
||||
$dir = `mg_substituteToLocalSep $dir `;
|
||||
if(`filetest -d $dir`)
|
||||
{
|
||||
if($fullPath)
|
||||
{
|
||||
string $programFileName = `MGP_GetConnectorProgramFileName`;
|
||||
$dir += $programFileName;
|
||||
$hasRecord =`filetest -f $dir`;
|
||||
}
|
||||
else
|
||||
{
|
||||
$hasRecord = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
$dir = `mg_substituteToLocalSep $dir `;
|
||||
return $dir;
|
||||
}
|
||||
|
||||
// save the connector and news to optionvar.------------------------
|
||||
proc string processDirToSave(string $filePath)
|
||||
{
|
||||
if(!size($filePath))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
$filePath = `mg_substituteToLocalSep $filePath `;
|
||||
string $dir = $filePath;
|
||||
if(`filetest -f $filePath`)
|
||||
{
|
||||
$dir = `dirname $filePath`;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!`filetest -d $filePath`)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
if(!`endsWith $dir "/"`)
|
||||
{
|
||||
$dir += "/";
|
||||
}
|
||||
$dir = `mg_substituteToLocalSep $dir `;
|
||||
return $dir;
|
||||
}
|
||||
|
||||
//=========lazy source marker proc=========================
|
||||
global proc MGFloatLicence_SharedProcs()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
//==============================================================//
|
||||
// MG - Float License
|
||||
//==============================================================//
|
||||
//Author: Miguel (Wenfeng Gao)
|
||||
//website: http://mgland.com
|
||||
//Feedback: http://mgland.com/MGtools_en.html?url=Feedback
|
||||
//E-mail: mgtoolspro@gmail.com
|
||||
//CopyRight Miguel @ mgland animation studio.
|
||||
|
||||
proc sourceSharedScript()
|
||||
{
|
||||
|
||||
global string $gMGPicker_ProductName = "MGPicker";
|
||||
if(`exists "MGFloatLicence_SharedProcs"`)
|
||||
{
|
||||
return;
|
||||
}
|
||||
global string $MGPicker_ProgramPath;
|
||||
global string $MGPicker_ProgramFolder;
|
||||
global string $MGPicker_AutoSourceFolder;
|
||||
string $script = $MGPicker_ProgramPath + $MGPicker_ProgramFolder + "/"+$MGPicker_AutoSourceFolder+"/MGFloatLicence_SharedProcs.mel";
|
||||
eval ("source \""+$script+"\"");
|
||||
}
|
||||
sourceSharedScript;
|
||||
|
||||
//for getting programs------------------------------------------------------------
|
||||
proc string mgpicker_getServerConnectionDir()
|
||||
{
|
||||
global string $MGPicker_ProgramPath;
|
||||
global string $MGPicker_ProgramFolder;
|
||||
global string $MGPicker_ServerConfigFolder;
|
||||
return ($MGPicker_ProgramPath + $MGPicker_ProgramFolder + "/" + $MGPicker_ServerConfigFolder + "/");
|
||||
}
|
||||
|
||||
global proc string MGPicker_GetLicenceConnectorDir_ServerDefine(int $fullPath)
|
||||
{
|
||||
string $serverConfigDir = `mgpicker_getServerConnectionDir`;
|
||||
return `MG_GetServerConnector $serverConfigDir $fullPath`;
|
||||
}
|
||||
global proc string MGPicker_GetLicenseConnectorDir(int $fullPath)
|
||||
{
|
||||
string $serverConfigDir = `mgpicker_getServerConnectionDir`;
|
||||
return `MG_getLicenseConnectorDir $serverConfigDir $fullPath`;
|
||||
}
|
||||
|
||||
// for launching programs--------------------------------------------------------------------
|
||||
global proc int MGP_loadProcess(string $path, string $args)
|
||||
{
|
||||
string $argStr = "";
|
||||
if(size($args))
|
||||
{
|
||||
string $argList[]=`stringToStringArray $args " "`;
|
||||
$argStr = ", '" + `stringArrayToString $argList "','"` + "'";
|
||||
}
|
||||
$path = `substituteAllString $path "\\" "/"`;
|
||||
string $cmd = "import subprocess;subprocess.Popen(['"+$path+"'"+$argStr+"])";
|
||||
if(catch (`python $cmd`))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
|
||||
global proc MGPickerAttrNudgerProperties ()
|
||||
//
|
||||
// Procedure Name:
|
||||
// MGPickerAttrNudgerProperties
|
||||
//
|
||||
// Description:
|
||||
// layout of tool property sheet
|
||||
//
|
||||
// Input Arguments:
|
||||
// None.
|
||||
//
|
||||
// Return Value:
|
||||
// None.
|
||||
//
|
||||
{
|
||||
setUITemplate -pushTemplate DefaultTemplate;
|
||||
|
||||
string $parent = `toolPropertyWindow -q -location`;
|
||||
setParent $parent;
|
||||
string $curctx = `currentCtx`;
|
||||
|
||||
columnLayout -adj 1 MGPickerAttrNudger; //The layout name is critical, should be the context class name.
|
||||
global string $MGPicker_ProgramPath;
|
||||
string $icon = $MGPicker_ProgramPath+"MGPicker_Program/Icons/bgimages/pickerbanner.png";
|
||||
string $fl = `formLayout -bgc 0.106 0.106 0.106`;
|
||||
string $icoWgt = `image -bgc 0.106 0.106 0.106 -i $icon -w 342 -h 84`;
|
||||
formLayout -e
|
||||
|
||||
-af $icoWgt "left" -2
|
||||
-af $icoWgt "top" -2
|
||||
-af $icoWgt "right" -2
|
||||
-af $icoWgt "bottom" -2
|
||||
$fl;
|
||||
setParent ..;
|
||||
button -l "Feedback.." -c "showHelp -a \"http://twincodes.com/mgpicker.html\"";
|
||||
|
||||
setUITemplate -popTemplate;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
global proc MGPickerAttrNudgerValues(string $toolName)
|
||||
{
|
||||
global string $MGPicker_ProgramPath;
|
||||
string $icon = $MGPicker_ProgramPath+"MGPicker_Program/Icons/Colored/Picker_designerModeIcon.png";
|
||||
string $helpHtml =($MGPicker_ProgramPath+"MGPicker_Help/English/index.html");
|
||||
string $lan = `MGPickerService -q -osl`;
|
||||
if($lan=="Chinese")$helpHtml = ($MGPicker_ProgramPath+"MGPicker_Help/SimplifiedChinese/index.html");
|
||||
|
||||
string $help = " -a \""+$helpHtml+"\"";
|
||||
toolPropertySetCommon $toolName $icon $help;
|
||||
|
||||
MGPickerAttrNudgerOptionValues($toolName);
|
||||
toolPropertySelect MGPickerAttrNudger;
|
||||
}
|
||||
global proc MGPickerAttrNudgerOptionReset()
|
||||
{
|
||||
}
|
||||
global proc MGPickerAttrNudgerOptionValues(string $toolName)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,869 @@
|
||||
/*
|
||||
This script contains publish related function codes in picker.
|
||||
It will be auto-source when MG-Picker Studio tool loads.
|
||||
*/
|
||||
|
||||
proc string mgp_ensurePathEndsWithSlash(string $path)
|
||||
{
|
||||
if(!`size $path`)
|
||||
{
|
||||
return $path;
|
||||
}
|
||||
if(!`endsWith $path "/"`)
|
||||
{
|
||||
$path += "/";
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
global proc string MGP_getSceneBasename()
|
||||
{
|
||||
string $bn = basenameEx(`file -q -shn -sn`);
|
||||
//string $inner = `mgp_ensurePathEndsWithSlash $targetDir`+ $bn;
|
||||
return $bn;
|
||||
}
|
||||
proc int mgp_testTargetDir(string $targetDir)
|
||||
{
|
||||
if(!size($targetDir))
|
||||
{
|
||||
MGP_ScriptEditorFeedback `MGP_MultiLanguage "pkr.publish.emptyDir"` 2;
|
||||
return 0;
|
||||
}
|
||||
if(!`filetest -d $targetDir`)
|
||||
{
|
||||
if(!`sysFile -md $targetDir`)
|
||||
{
|
||||
MGP_ScriptEditorFeedback `MGP_MultiLanguage_rep1 "pkr.publish.dirCantBuild.war" $targetDir` 2;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
proc int mgp_testCurrentSceneSaveState()
|
||||
{
|
||||
string $sceneFile = `file -q -sn`;
|
||||
if(!`size $sceneFile`)
|
||||
{
|
||||
confirmDialog -title `MGP_getAppName` -message `MGP_MultiLanguage "pkr.publish.sceneUntitled"` -button "OK";
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
proc string mgp_getNonDuplicateFilename(string $dir, string $filename)
|
||||
{
|
||||
if(!`filetest -d $dir`)
|
||||
{
|
||||
return $filename;
|
||||
}
|
||||
$dir = `mgp_ensurePathEndsWithSlash $dir`;
|
||||
string $ext = `fileExtension $filename`;
|
||||
string $exFiles[]=`getFileList -fld $dir -fs ("*."+$ext)`;
|
||||
string $basename = `basenameEx $filename`;
|
||||
return `MGP_GetValidNonDupFileName $basename $ext "UntitledImage" $exFiles`;
|
||||
}
|
||||
proc int mgp_copyAllImagesToDir(string $targetDir,
|
||||
int $publishTextures,
|
||||
int $publishImagePlane,
|
||||
int $toRelative,
|
||||
int $publishInScenePickers)
|
||||
{
|
||||
if(!$publishTextures && !$publishImagePlane)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
string $textureFolderName = "sourceimages";
|
||||
string $targetDirSlash = `mgp_ensurePathEndsWithSlash $targetDir`;
|
||||
string $textureDir = $targetDirSlash + $textureFolderName;
|
||||
if(!`filetest -d $textureDir`)
|
||||
{
|
||||
if(!`sysFile -md $textureDir`)
|
||||
{
|
||||
MGP_ScriptEditorFeedback `MGP_MultiLanguage_rep2 "pkr.publish.canBuildDir.withinDir" $textureFolderName $targetDir` 2;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
$textureDir += "/";
|
||||
string $files[] = `ls -type "file"`;
|
||||
string $imageplanes[] = `ls -type "imagePlane"`;
|
||||
int $fileLen = size($files);
|
||||
int $imageplaneLen = size($imageplanes);
|
||||
|
||||
int $needProcess = 0;
|
||||
if($publishTextures)
|
||||
{
|
||||
if($fileLen)
|
||||
{
|
||||
$needProcess = 1;
|
||||
}
|
||||
}
|
||||
if($publishImagePlane)
|
||||
{
|
||||
if($imageplaneLen)
|
||||
{
|
||||
$needProcess = 1;
|
||||
}
|
||||
}
|
||||
if(!$needProcess)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
string $processedImage[];
|
||||
clear $processedImage;
|
||||
|
||||
//set project to support relative path:
|
||||
string $oldProj;
|
||||
if($toRelative)
|
||||
{
|
||||
$oldProj = `workspace -q -dir`;
|
||||
setProject $targetDir;
|
||||
workspace -dir $targetDir ;
|
||||
workspace -fileRule "sourceImages" "sourceimages";
|
||||
workspace -fileRule "mayaAscii" "";
|
||||
workspace -fileRule "mayaBinary" "";
|
||||
workspace -fileRule "autoSave" "";
|
||||
workspace -fileRule "offlineEdit" "";
|
||||
workspace -fileRule "movie" "";
|
||||
workspace -fileRule "templates" "";
|
||||
workspace -fileRule "particles" "";
|
||||
workspace -s;
|
||||
workspace -update;
|
||||
}
|
||||
|
||||
//copy and set relative the textures:
|
||||
if($publishTextures)
|
||||
{
|
||||
for($f in $files)
|
||||
{
|
||||
string $image = `getAttr ($f+".fileTextureName")`;
|
||||
string $bn = `basename $image ""`;
|
||||
if(`stringArrayContains $image $processedImage`)
|
||||
{
|
||||
if($toRelative)
|
||||
{
|
||||
//print ($textureFolderName+"/"+$bn+"\n");
|
||||
setAttr -type "string" ($f+".fileTextureName") ($textureFolderName+"/"+$bn);
|
||||
$rep = `MGP_MultiLanguage "pkr.publish.texture.relative"`;
|
||||
MGP_ScriptEditorFeedback $rep 0;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(`filetest -f $image`)
|
||||
{
|
||||
$bn = `mgp_getNonDuplicateFilename $textureDir $bn`;
|
||||
string $targetFile = ($textureDir + $bn);
|
||||
if(!`sysFile -copy $targetFile $image`)
|
||||
{
|
||||
MGP_ScriptEditorFeedback (`MGP_MultiLanguage "pkr.publish.errorCopyTexture"`+" "+$image+".") 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
string $rep = (`MGP_MultiLanguage "pkr.publish.textureCopied"`+" "+$image);
|
||||
if($toRelative)
|
||||
{
|
||||
//print ($textureFolderName+"/"+$bn+"\n");
|
||||
setAttr -type "string" ($f+".fileTextureName") ($textureFolderName+"/"+$bn);
|
||||
$rep += (", " + `MGP_MultiLanguage "pkr.publish.andRelative"`);
|
||||
}
|
||||
else
|
||||
{
|
||||
$rep += ".";
|
||||
}
|
||||
MGP_ScriptEditorFeedback $rep 0;
|
||||
$processedImage[size($processedImage)] = $image;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MGP_ScriptEditorFeedback (`MGP_MultiLanguage "pkr.publish.textureNotExist"`+" "+$image+".") 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
//copy and set relative the imageplane images:
|
||||
if($publishImagePlane)
|
||||
{
|
||||
for($ip in $imageplanes)
|
||||
{
|
||||
string $image = `getAttr ($ip+".imageName")`;
|
||||
string $bn = `basename $image ""`;
|
||||
if(`stringArrayContains $image $processedImage`)
|
||||
{
|
||||
if($toRelative)
|
||||
{
|
||||
setAttr -type "string" ($ip+".imageName") ($textureFolderName+"/"+$bn);
|
||||
$rep = `MGP_MultiLanguage_rep1 "pkr.publish.imagePlane.relative" $ip`;
|
||||
MGP_ScriptEditorFeedback $rep 0;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(`filetest -f $image`)
|
||||
{
|
||||
$bn = `mgp_getNonDuplicateFilename $textureDir $bn`;
|
||||
string $targetFile = ($textureDir + $bn);
|
||||
if(!`sysFile -copy $targetFile $image`)
|
||||
{
|
||||
MGP_ScriptEditorFeedback (`MGP_MultiLanguage "pkr.publish.errorCopyImageplane"`+" "+$image+".") 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
string $rep = (`MGP_MultiLanguage "pkr.publish.imageplaneCopied"`+" "+$image);
|
||||
if($toRelative)
|
||||
{
|
||||
setAttr -type "string" ($ip+".imageName") ($textureFolderName+"/"+$bn);
|
||||
$rep += (", "+`MGP_MultiLanguage "pkr.publish.andRelative"`);
|
||||
}
|
||||
else
|
||||
{
|
||||
$rep += ".";
|
||||
}
|
||||
MGP_ScriptEditorFeedback $rep 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MGP_ScriptEditorFeedback (`MGP_MultiLanguage "pkr.publish.iamgeplaneNotExist"`+" "+$image+".") 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
file -save;
|
||||
string $scFile = `file -q -sn`;
|
||||
if($publishInScenePickers)
|
||||
{
|
||||
string $bn = `basenameEx $scFile`;
|
||||
int $result = `MGPickerView -e -saveAsSceneNode $bn 1`;
|
||||
if(!$result)
|
||||
{
|
||||
MGP_ScriptEditorFeedback (`MGP_MultiLanguage "pkr.publish.inscenePicker.error"`) 2;
|
||||
file -new -f;
|
||||
if($toRelative)
|
||||
{
|
||||
//remember to set back the project:
|
||||
setProject $oldProj;
|
||||
workspace -dir $oldProj;
|
||||
workspace -update;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
file -save;
|
||||
|
||||
//now copy the scene dir:
|
||||
string $scDir = ($targetDirSlash+"scenes/pickerimages");
|
||||
//print ($scDir+"\n");
|
||||
|
||||
if(`filetest -d $scDir`)
|
||||
{
|
||||
//print "scDir exists!\n";
|
||||
string $tgtDir = ($targetDirSlash+"/pickerimages");
|
||||
int $result = MGP_CopyFolder($tgtDir,$scDir,1);
|
||||
//print ("\n"+$result+"\n"+"Source: "+$tgtDir+"\nTarget:"+$tgtDir+"\n");
|
||||
if($result)
|
||||
{
|
||||
MGP_DeleteFolder_Ex($scDir,"","",1, 0);
|
||||
MGP_ScriptEditorFeedback (`MGP_MultiLanguage "pkr.publish.inscenePicker.done"`) 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
MGP_ScriptEditorFeedback (`MGP_MultiLanguage "pkr.publish.erroCopyImageDir"`) 2;
|
||||
file -new -f;
|
||||
if($toRelative)
|
||||
{
|
||||
//remember to set back the project:
|
||||
setProject $oldProj;
|
||||
workspace -dir $oldProj;
|
||||
workspace -update;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MGP_ScriptEditorFeedback (`MGP_MultiLanguage "pkr.publish.inscenePicker.done"`) 0;
|
||||
}
|
||||
MGPicker -e -close "" 1 "";
|
||||
|
||||
}
|
||||
//now clean up:
|
||||
if($toRelative)
|
||||
{
|
||||
//clear all the project folder things:
|
||||
//they are all folders: assets, autosave, scenes
|
||||
sysFile -removeEmptyDir ($targetDirSlash+"assets");
|
||||
sysFile -removeEmptyDir ($targetDirSlash+"autosave");
|
||||
sysFile -removeEmptyDir ($targetDirSlash+"scenes/edits");
|
||||
//remember to set back the project:
|
||||
setProject $oldProj;
|
||||
}
|
||||
|
||||
//move out from scene dir:
|
||||
string $targetFile = ($targetDirSlash+`basename $scFile ""`);
|
||||
sysFile -cp $targetFile $scFile;
|
||||
sysFile -del $scFile;
|
||||
sysFile -removeEmptyDir ($targetDirSlash+"scenes");
|
||||
file -new -f;
|
||||
return 1;
|
||||
}
|
||||
global proc int MGP_PulishCurrentMayaScene(string $targetDir,
|
||||
int $publishTextures,
|
||||
int $publishImagePlane,
|
||||
int $makeImageRelative,
|
||||
int $publishInScenePickers)
|
||||
{
|
||||
if(!`mgp_testCurrentSceneSaveState`)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if(!`mgp_testTargetDir $targetDir`)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
//Save the scene to the target dir first:
|
||||
string $sn = `file -q -sn -shortName`;
|
||||
$targetDir = `mgp_ensurePathEndsWithSlash $targetDir`;
|
||||
string $scDir = ($targetDir+"scenes");
|
||||
if(!`filetest -d $scDir`)
|
||||
{
|
||||
sysFile -md $scDir;
|
||||
}
|
||||
file -rename ($scDir+"/"+$sn);
|
||||
file -save;
|
||||
//copy the textures and make them relative if desired:
|
||||
if($publishTextures || $publishImagePlane)
|
||||
{
|
||||
if(!`mgp_copyAllImagesToDir $targetDir $publishTextures $publishImagePlane $makeImageRelative $publishInScenePickers`)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
global proc string[] MGP_listAllSubFolderFilesRecursively(int $listMode , string $cFolder, int $folderFirstOrLast)
|
||||
//$listMode 0: list only folder
|
||||
//$listMode 1: list only file
|
||||
//$listMode 2: list both, in this mode, folder will be listed ahead of files with one parentFolder.
|
||||
//if $cFolder is actually a file, on array with a single record: the file will be returned.
|
||||
//$folderFirstOrLast: 0: will list folder ahead of its contained files. Useful when copy folder tree, which should create folder first.
|
||||
//$folderFirstOrLast: 1: will list files ahead of its contained folder. Useful when delete folder tree, which should delete files first.
|
||||
{
|
||||
string $result[];
|
||||
if(!size($cFolder))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
//if it is a folder:
|
||||
if(`filetest -d $cFolder`)
|
||||
{
|
||||
if(!`endsWith $cFolder "/"`)
|
||||
{
|
||||
$cFolder += "/";
|
||||
}
|
||||
if($listMode != 1 && !$folderFirstOrLast)
|
||||
{
|
||||
$result[size($result)] = $cFolder;
|
||||
}
|
||||
}
|
||||
else if(`filetest -f $cFolder`) //if it is actually a file, we return one single record: the file
|
||||
{
|
||||
if($listMode)
|
||||
{
|
||||
$result[size($result)] = $cFolder;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
else //if it is not a file nor a folder, we return;
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
string $items[] = `getFileList -fld $cFolder`;
|
||||
if(!size($items)) //if it is empty folder and we need to list foler and the folder is listed last, we append the foler:
|
||||
{
|
||||
if($listMode != 1 && $folderFirstOrLast)
|
||||
{
|
||||
$result[size($result)] = $cFolder;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
string $cPath;
|
||||
string $cSubFiles[];
|
||||
if(!$folderFirstOrLast) //if list folder first, we list the folder first:
|
||||
{
|
||||
if($listMode != 1)
|
||||
{
|
||||
for($item in $items)
|
||||
{
|
||||
if($item == "." || $item == "..")
|
||||
continue;
|
||||
|
||||
$cPath = $cFolder+$item;
|
||||
//if it is a directory, we recursively call this proc. The path will be record in the head of this proc.
|
||||
if(`filetest -d $cPath`)
|
||||
{
|
||||
$cPath +="/";
|
||||
$result = stringArrayCatenate ($result ,`MGP_listAllSubFolderFilesRecursively $listMode $cPath $folderFirstOrLast`);
|
||||
}
|
||||
}
|
||||
}
|
||||
if($listMode)
|
||||
{
|
||||
for($item in $items)
|
||||
{
|
||||
$cPath = $cFolder+$item;
|
||||
if(!`filetest -d $cPath`) //if it is a file and we are in listMode that list the files, we record it in $cSubFiles. So that we could add the files to the tail.
|
||||
{
|
||||
$cSubFiles[size($cSubFiles)] = $cPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($listMode) //we add files first with one folder.
|
||||
{
|
||||
for($item in $items)
|
||||
{
|
||||
$cPath = $cFolder+$item;
|
||||
if(!`filetest -d $cPath`) //if it is a file and we are in listMode that list the files, we record it in $cSubFiles. So that we could add the files to the tail.
|
||||
{
|
||||
$cSubFiles[size($cSubFiles)] = $cPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($listMode != 1)
|
||||
{
|
||||
for($item in $items)
|
||||
{
|
||||
$cPath = $cFolder+$item;
|
||||
//if it is a directory, we recursively call this proc. The path will be record in the head of this proc.
|
||||
if(`filetest -d $cPath`)
|
||||
{
|
||||
$cPath +="/";
|
||||
$result = stringArrayCatenate ($result ,`MGP_listAllSubFolderFilesRecursively $listMode $cPath $folderFirstOrLast`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// add files last if we are in listMode that list the files:
|
||||
if($listMode)
|
||||
{
|
||||
$result = stringArrayCatenate ($result , $cSubFiles);
|
||||
}
|
||||
if($listMode != 1 && $folderFirstOrLast)
|
||||
{
|
||||
$result[size($result)] = $cFolder;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
global proc int MGP_CopyFolder_Ex(string $targetFolder,string $sourceFolder,string $progressBarControl,string $textControl, int $returnAtFirstError, int $autoHideProgressBarWhenIsDone)
|
||||
//only copy folder, file as a $sourceFolder parameter will be skipped.
|
||||
//$progressBarControl: a progressBar Control
|
||||
//$textControl: a text Control
|
||||
//this proc will always override the exist folder/file.
|
||||
//$returnAtFirstError 1: will return at first error.
|
||||
{
|
||||
$targetFolder = `fromNativePath $targetFolder`;
|
||||
$sourceFolder = `fromNativePath $sourceFolder`;
|
||||
if(!`filetest -d $sourceFolder`)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if(!`filetest -d $targetFolder`)
|
||||
{
|
||||
//if fail in the first step. we return quickly.
|
||||
if(!`sysFile -md $targetFolder`)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if(!`endsWith $targetFolder "/"`)
|
||||
{
|
||||
$targetFolder+="/";
|
||||
}
|
||||
if(!`endsWith $sourceFolder "/"`)
|
||||
{
|
||||
$sourceFolder+="/";
|
||||
}
|
||||
int $sourceFolderSize = size($sourceFolder);
|
||||
|
||||
int $updateStatusBar = `control -q -ex $progressBarControl`;
|
||||
int $updateStatusText =`control -q -ex $textControl`;
|
||||
if($updateStatusBar)
|
||||
{
|
||||
progressBar -e -vis 1 -progress 0 $progressBarControl;
|
||||
}
|
||||
|
||||
//list all sub folders and files, will list folders first, then the files.
|
||||
string $subItems [] = `MGP_listAllSubFolderFilesRecursively 2 $sourceFolder 0`;
|
||||
int $totalNum = size($subItems);
|
||||
int $actualTotalNum =$totalNum-1;
|
||||
if(!$totalNum)
|
||||
{
|
||||
if($updateStatusBar)
|
||||
{
|
||||
progressBar -e -progress 100 $progressBarControl;
|
||||
if($autoHideProgressBarWhenIsDone)
|
||||
{
|
||||
progressBar -e -vis 0 -progress 0 $progressBarControl;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
int $cPercentage = 0;
|
||||
int $cResult;
|
||||
string $cTarget;
|
||||
string $cSource;
|
||||
string $cSubfix;
|
||||
if($totalNum > 1)
|
||||
{
|
||||
string $errorLbl = `MGP_MultiLanguage "pkr.error"`;
|
||||
for($i=1; $i<$totalNum; $i++) //we skip the first one because we have make $targetFolder;
|
||||
{
|
||||
$cSource = $subItems[$i];
|
||||
$cSubfix = `substring $cSource ($sourceFolderSize+1) (size($cSource))`;
|
||||
$cTarget = $targetFolder+$cSubfix;
|
||||
//if it is a folder:
|
||||
if(`endsWith $cTarget "/"`)
|
||||
{
|
||||
$cResult = `sysFile -md $cTarget`;
|
||||
}
|
||||
else
|
||||
{
|
||||
$cResult = `sysFile -cp $cTarget $cSource`;
|
||||
}
|
||||
if($updateStatusBar)
|
||||
{
|
||||
$cPercentage =( $i/float($actualTotalNum))*100;
|
||||
progressBar -e -progress $cPercentage $progressBarControl;
|
||||
}
|
||||
|
||||
if($cResult)
|
||||
{
|
||||
//print ($cSubfix+"\n");
|
||||
if($updateStatusText)
|
||||
{
|
||||
text -e -l $cSubfix $textControl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($updateStatusText)
|
||||
{
|
||||
text -e -l ("!!! "+$errorLbl+" @ "+$cSubfix) $textControl;
|
||||
}
|
||||
if($returnAtFirstError)
|
||||
{
|
||||
if($updateStatusBar)
|
||||
{
|
||||
progressBar -e -progress 100 $progressBarControl;
|
||||
if($autoHideProgressBarWhenIsDone)
|
||||
{
|
||||
progressBar -e -vis 0 -progress 0 $progressBarControl;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($autoHideProgressBarWhenIsDone && $updateStatusBar)
|
||||
{
|
||||
progressBar -e -vis 0 -progress 0 $progressBarControl;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
global proc int MGP_CopyFolder(string $targetFolder,string $sourceFolder,int $returnAtFirstError)
|
||||
//only copy folder, file as a $sourceFolder parameter will be skipped.
|
||||
//this proc will always override the exist folder/file.
|
||||
//$returnAtFirstError 1: will return at first error.
|
||||
{
|
||||
$targetFolder = `fromNativePath $targetFolder`;
|
||||
$sourceFolder = `fromNativePath $sourceFolder`;
|
||||
if(!`filetest -d $sourceFolder`)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if(!`filetest -d $targetFolder`)
|
||||
{
|
||||
//if fail in the first step. we return quickly.
|
||||
if(!`sysFile -md $targetFolder`)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if(!`endsWith $targetFolder "/"`)
|
||||
{
|
||||
$targetFolder+="/";
|
||||
}
|
||||
if(!`endsWith $sourceFolder "/"`)
|
||||
{
|
||||
$sourceFolder+="/";
|
||||
}
|
||||
int $sourceFolderSize = size($sourceFolder);
|
||||
|
||||
|
||||
//list all sub folders and files, will list folders first, then the files.
|
||||
string $subItems [] = `MGP_listAllSubFolderFilesRecursively 2 $sourceFolder 0`;
|
||||
int $totalNum = size($subItems);
|
||||
int $actualTotalNum =$totalNum-1;
|
||||
if(!$totalNum)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
int $cPercentage = 0;
|
||||
int $cResult;
|
||||
string $cTarget;
|
||||
string $cSource;
|
||||
string $cSubfix;
|
||||
if($totalNum > 1)
|
||||
{
|
||||
string $errorLbl = `MGP_MultiLanguage "pkr.error"`;
|
||||
for($i=1; $i<$totalNum; $i++) //we skip the first one because we have make $targetFolder;
|
||||
{
|
||||
$cSource = $subItems[$i];
|
||||
$cSubfix = `substring $cSource ($sourceFolderSize+1) (size($cSource))`;
|
||||
$cTarget = $targetFolder+$cSubfix;
|
||||
//if it is a folder:
|
||||
if(`endsWith $cTarget "/"`)
|
||||
{
|
||||
$cResult = `sysFile -md $cTarget`;
|
||||
}
|
||||
else
|
||||
{
|
||||
$cResult = `sysFile -cp $cTarget $cSource`;
|
||||
}
|
||||
if(!$cResult)
|
||||
{
|
||||
if($returnAtFirstError)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
global proc int MGP_DeleteFolder_Ex(string $deleteFolder,string $progressBarControl,string $textControl,int $returnAtFirstError, int $autoHideProgressBarWhenIsDone)
|
||||
//only delete folder, file as a $sourceFolder parameter will be skipped.
|
||||
//$progressBarControl: a progressBar Control
|
||||
//$textControl: a text Control
|
||||
//$returnAtFirstError 1: will return at first error.
|
||||
{
|
||||
$deleteFolder = `fromNativePath $deleteFolder`;
|
||||
if(!`filetest -d $deleteFolder`)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if(!`endsWith $deleteFolder "/"`)
|
||||
{
|
||||
$deleteFolder+="/";
|
||||
}
|
||||
|
||||
int $updateStatusBar = `control -q -ex $progressBarControl`;
|
||||
int $updateStatusText =`control -q -ex $textControl`;
|
||||
if($updateStatusBar)
|
||||
{
|
||||
progressBar -e -vis 1 -progress 0 $progressBarControl;
|
||||
}
|
||||
|
||||
//list all sub files and folders, will list files first, then the folers.
|
||||
string $subItems [] = `MGP_listAllSubFolderFilesRecursively 2 $deleteFolder 1`;
|
||||
//print $subItems;
|
||||
int $totalNum = size($subItems);
|
||||
int $actualTotalNum =$totalNum-1;
|
||||
int $cResult;
|
||||
string $errorLbl = `MGP_MultiLanguage "pkr.error"`;
|
||||
if(!$totalNum) //if nothing to delete.
|
||||
{
|
||||
if($updateStatusBar)
|
||||
{
|
||||
progressBar -e -progress 100 $progressBarControl;
|
||||
if($autoHideProgressBarWhenIsDone)
|
||||
{
|
||||
progressBar -e -vis 0 -progress 0 $progressBarControl;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else if($totalNum == 1) //the folder is empty
|
||||
{
|
||||
if(`endsWith $subItems[0] "/"`)
|
||||
{
|
||||
$cResult = `sysFile -removeEmptyDir $subItems[0]`;
|
||||
}
|
||||
else
|
||||
{
|
||||
$cResult = `sysFile -delete $subItems[0]`;
|
||||
}
|
||||
if($cResult)
|
||||
{
|
||||
if($updateStatusText)
|
||||
{
|
||||
text -e -l $subItems[0] $textControl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($updateStatusText)
|
||||
{
|
||||
text -e -l ("!!! "+$errorLbl+" @ "+$subItems[0]) $textControl;
|
||||
}
|
||||
}
|
||||
if($updateStatusBar)
|
||||
{
|
||||
progressBar -e -progress 100 $progressBarControl;
|
||||
if($autoHideProgressBarWhenIsDone)
|
||||
{
|
||||
progressBar -e -vis 0 -progress 0 $progressBarControl;
|
||||
}
|
||||
}
|
||||
return $cResult;
|
||||
}
|
||||
|
||||
int $cPercentage = 0;
|
||||
string $cItem;
|
||||
for($i=0; $i<$totalNum; $i++)
|
||||
{
|
||||
$cItem = $subItems[$i];
|
||||
//if it is a folder:
|
||||
if(`endsWith $cItem "/"`)
|
||||
{
|
||||
$cResult = `sysFile -removeEmptyDir $cItem`;
|
||||
}
|
||||
else
|
||||
{
|
||||
$cResult = `sysFile -delete $cItem`;
|
||||
}
|
||||
if($updateStatusBar)
|
||||
{
|
||||
$cPercentage =( ($i+1)/float($actualTotalNum))*100;
|
||||
progressBar -e -progress $cPercentage $progressBarControl;
|
||||
}
|
||||
if($cResult)
|
||||
{
|
||||
//print ($cItem+"\n");
|
||||
if($updateStatusText)
|
||||
{
|
||||
text -e -l $cItem $textControl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($updateStatusText)
|
||||
{
|
||||
text -e -l ("!!! "+$errorLbl+" @ "+$cItem) $textControl;
|
||||
}
|
||||
if($returnAtFirstError)
|
||||
{
|
||||
if($updateStatusBar)
|
||||
{
|
||||
progressBar -e -progress 100 $progressBarControl;
|
||||
if($autoHideProgressBarWhenIsDone)
|
||||
{
|
||||
progressBar -e -vis 0 -progress 0 $progressBarControl;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($autoHideProgressBarWhenIsDone && $updateStatusBar)
|
||||
{
|
||||
progressBar -e -vis 0 -progress 0 $progressBarControl;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
proc string mgp_getProgramPublishTargetRootPath(string $targetDir)
|
||||
{
|
||||
if(!size($targetDir))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
global string $MGPicker_FolderName;
|
||||
$targetDir = `mgp_ensurePathEndsWithSlash $targetDir`;
|
||||
$targetDir += ($MGPicker_FolderName + "/");
|
||||
return $targetDir;
|
||||
}
|
||||
|
||||
global proc int MGP_PulishPickerPrograms(string $targetDir,
|
||||
int $publishAutosourced)
|
||||
{
|
||||
if(!`mgp_testTargetDir $targetDir`)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
$targetDir = (`mgp_ensurePathEndsWithSlash $targetDir`);
|
||||
|
||||
global string $MGPicker_AppName;
|
||||
global string $MGPicker_ProgramPath;
|
||||
if(!`filetest -d $MGPicker_ProgramPath`)
|
||||
{
|
||||
MGP_ScriptEditorFeedback `MGP_MultiLanguage_rep1 "pkr.publish.cantFindProgram" $MGPicker_AppName` 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//publish picker program code.
|
||||
global string $MGPicker_FolderName;
|
||||
string $targetRoot = `mgp_getProgramPublishTargetRootPath $targetDir`;
|
||||
string $targetFolder = $targetRoot + $MGPicker_FolderName;
|
||||
if(!`filetest -d $targetFolder`)
|
||||
{
|
||||
if(!`sysFile -md $targetFolder`)
|
||||
{
|
||||
MGP_ScriptEditorFeedback (`MGP_MultiLanguage "pkr.publish.canBuildDir"`+" "+$targetFolder+".") 2;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
$targetFolder += "/";
|
||||
string $sourceDir = `mgp_ensurePathEndsWithSlash $MGPicker_ProgramPath`;
|
||||
|
||||
//now copy the installation resource first:
|
||||
string $installMel_source = $MGPicker_ProgramPath + "MGPicker_Program/Installer/MGPicker_installer.mel";
|
||||
string $installMel_target = $targetRoot + "MGPicker_installer.mel";
|
||||
sysFile -cp $installMel_target $installMel_source;
|
||||
|
||||
string $installMel_ReadMeSource1 = $MGPicker_ProgramPath + "MGPicker_Program/Installer/HowToInstall_English.txt";
|
||||
string $installMel_ReadMeTarget1 = $targetRoot + "HowToInstall_English.txt";
|
||||
sysFile -cp $installMel_ReadMeTarget1 $installMel_ReadMeSource1;
|
||||
|
||||
string $installMel_ReadMeSource2 = $MGPicker_ProgramPath + "MGPicker_Program/Installer/HowToInstall_SimplifiedChinese.txt";
|
||||
string $installMel_ReadMeTarget2 = $targetRoot + "HowToInstall_SimplifiedChinese.txt";
|
||||
sysFile -cp $installMel_ReadMeTarget2 $installMel_ReadMeSource2;
|
||||
|
||||
string $installMel_ReadMeSource3 = $MGPicker_ProgramPath + "MGPicker_Program/Installer/HowToInstall_TraditionalChinese.txt";
|
||||
string $installMel_ReadMeTarget3 = $targetRoot + "HowToInstall_TraditionalChinese.txt";
|
||||
sysFile -cp $installMel_ReadMeTarget3 $installMel_ReadMeSource3;
|
||||
|
||||
$targetFolder = `mgp_ensurePathEndsWithSlash $targetFolder`;
|
||||
//now copy other folders:
|
||||
string $fileFolders[]=`getFileList -fld $sourceDir`;
|
||||
for($f in $fileFolders)
|
||||
{
|
||||
if($f == "." || $f == "..")
|
||||
continue;
|
||||
|
||||
string $cf = ($sourceDir + $f);
|
||||
string $tf = ($targetFolder + $f);
|
||||
if(`filetest -f $cf`)
|
||||
{
|
||||
sysFile -cp $tf $cf;
|
||||
}
|
||||
else if(`filetest -d $cf`)
|
||||
{
|
||||
if($f == "MGPicker_UserConfig")
|
||||
{
|
||||
if($publishAutosourced)
|
||||
{
|
||||
string $sourceAutoSourceFld=$cf + "/AutoSourced";
|
||||
string $targetAutoSourceFld=$tf + "/AutoSourced";
|
||||
MGP_CopyFolder $targetAutoSourceFld $sourceAutoSourceFld 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MGP_CopyFolder $tf $cf 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user