Skip to content

Commit

Permalink
Changes to Morph Dialog
Browse files Browse the repository at this point in the history
- Addition of Progress Bar to give Visual Feedback of loading when user has many morphs.
- When Morph checkbox is set to include morphs uses last used morphs if dialog isn't opened
- Skip over some parameters that may be not found with custom morphs for morph export data.
  • Loading branch information
samjay3d committed Aug 8, 2021
1 parent 2cd57af commit 065d983
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 14 deletions.
23 changes: 20 additions & 3 deletions Daz Studio/appdir_common/scripts/support/DAZ/Daz to Blender.dsa
Original file line number Diff line number Diff line change
Expand Up @@ -2201,10 +2201,27 @@
function getMorphString( aExportableProperties )
{
var sMorphString

if ( aExportableProperties.length == 0 ){
return "";
}
s_aMorphNamesToExport = [];
sPresetFilePath = s_sPresetPath + "LastUsed.csv"
oFile = new DzFile( sPresetFilePath );
if( !oFile.open( DzFile.ReadOnly ) ){
print( String( "Unable to open \"%1\" for Reading." ).arg( sPresetFilePath ) );
return;
}
aMorphLines = oFile.readLines();
for( var i = 0; i < aMorphLines.length; i++ ){
sMorphLine = aMorphLines[i]
if( sMorphLine.indexOf( "\"Export\"" ) > 0 ){
aItems = sMorphLine.split(",");
sMorphName = aItems[0].replace("\"", "").replace("\"", "");
s_aMorphNamesToExport.push( sMorphName );
}
}
sMorphString = s_aMorphNamesToExport.join( "\n1\n" );
sMorphString += "\n1\n.CTRLVS\n2\nAnything\n0";
return sMorphString
};
s_aMorphNamesToExport = [];
sMorphString = "";
for( var i = 0; i < aExportableProperties.length; i++ ){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,24 @@
wAddMorphsButton.released.connect( handleAddMorphsButton );
wRemoveMorphsButton.released.connect( handleRemoveMorphsButton );
};
/*********************************************************************/
// Number : Returns the amount of morphs to be used by progress bar
function getAmountofMorphs( oNode ){
var nPotentialMorphs = 0;

oObject = oNode.getObject();
nPotentialMorphs += oNode.getNumProperties();
nPotentialMorphs += oObject.getNumModifiers();
for ( var i = 0; i < oNode.getNumNodeChildren(); i++ ){
oChildNode = oNode.getNodeChild( i );
if( oChildNode.inherits( "DzBone" ) ){
continue;
}
nPotentialMorphs += oNode.getNumProperties();
nPotentialMorphs += oObject.getNumModifiers();
}
return nPotentialMorphs
}


/*********************************************************************/
Expand All @@ -318,7 +336,7 @@
var oSelectedNode;
var oParentNode;
var oParentFigureNode;

oSelectedNode = s_oNode;
// For item like clothing, create the morph list from the character
oParentNode = oSelectedNode;
Expand All @@ -328,15 +346,27 @@
oSelectedNode = oParentFigureNode;
}
}


nCounter = getAmountofMorphs( oSelectedNode ) * 2
startProgress( text( "Loading Available Morphs" ), nCounter, false, true );
App.statusLine( "Checking For Morphs in " + oSelectedNode.getLabel(), false );
s_oMorphs = {};
getAvailableMorphs( oSelectedNode );
for ( var i = 0; i < oSelectedNode.getNumNodeChildren(); i++ ){
oChildNode = oSelectedNode.getNodeChild( i );
if( oChildNode.inherits( "DzBone" ) ){
continue;
}
App.statusLine( "Checking For Morphs in " + oChildNode.name, false );
getAvailableMorphs( oChildNode );
}
App.statusLine( "Creating Morph Dialog", false );
updateMorphsTree();
finishProgress();
handlePresetChanged("LastUsed.csv");



};

/*********************************************************************/
Expand Down Expand Up @@ -383,10 +413,31 @@
oShape = oObject.getCurrentShape();
}
for( var i = 0; i < oNode.getNumProperties(); i++ ){
stepProgress( 1 );
oProperty = oNode.getProperty( i );
var bIsHidden = false;
var nMax = 1;
var nMin = 0;
var nPropValue = 0;
// Create Property Checks only if they exist
if( oProperty ){
if( typeof oProperty.isHidden === "function" ){
bIsHidden = oProperty.isHidden();
}
if( typeof oProperty.getMin === "function" ){
nMin = oProperty.getMin();
}
if( typeof oProperty.getMax === "function" ){
nMax = oProperty.getMax();
}
if( typeof oProperty.getValue === "function" ){
nPropValue = oProperty.getValue();
}
}
sPropName = oProperty.getName();
sPropLabel = oProperty.getLabel();
oPresentation = oProperty.getPresentation();

if (oPresentation != undefined){
sPath = oNode.getLabel() + "/" + oProperty.getPath();
sParent = sPath.split( "/" )[0];
Expand All @@ -397,11 +448,11 @@
oPresentation.type,
oProperty,
sParent,
oProperty.isHidden(),
oProperty.getMin(),
oProperty.getMax(),
bIsHidden,
nMin,
nMax,
false,
oProperty.getValue(),
nPropValue,
oNode
);

Expand All @@ -418,12 +469,32 @@
}
if( oObject ){
for( var i = 0; i < oObject.getNumModifiers(); i++ ){
stepProgress( 1 );
oModifer = oObject.getModifier( i );
sModName = oModifer.getName();
sModLabel = oModifer.getLabel();
if(oModifer.inherits( "DzMorph" ) ){
for( var j = 0; j < oModifer.getNumProperties(); j++ ){
oProperty = oModifer.getProperty( j );
var bIsHidden = false;
var nMax = 1;
var nMin = 0;
var nPropValue = 0;
// Create Property Checks only if they exist
if( oProperty ){
if( typeof oProperty.isHidden === "function" ){
bIsHidden = oProperty.isHidden();
}
if( typeof oProperty.getMin === "function" ){
nMin = oProperty.getMin();
}
if( typeof oProperty.getMax === "function" ){
nMax = oProperty.getMax();
}
if( typeof oProperty.getValue === "function" ){
nPropValue = oProperty.getValue();
}
}
sPropName = oProperty.getName();
sPropLabel = oProperty.getLabel();
oPresentation = oProperty.getPresentation();
Expand All @@ -437,11 +508,11 @@
oPresentation.type,
oProperty,
sParent,
oProperty.isHidden(),
oProperty.getMin(),
oProperty.getMax(),
bIsHidden,
nMin,
nMax,
false,
oProperty.getValue(),
nPropValue,
oNode
);
if( !( oMorphInfo.name in s_oMorphs ) ){
Expand All @@ -458,6 +529,7 @@
}
}
}

};

/*********************************************************************/
Expand All @@ -475,6 +547,7 @@
s_oMorphsForNode = {};
for( sParent in s_oAvailObjects ){
for( sMorph in s_oAvailObjects[sParent] ){
stepProgress( 1 );
sPath = s_oMorphs[sMorph].path;
sType = s_oMorphs[sMorph].path;
aPathParts = sPath.split( "/" );
Expand All @@ -491,7 +564,7 @@
}
}
else{
sPathPart_helper = ""
sPathPart_helper = "";
}
// Used to Match to correct node.
sID = sParent + sPathPart_helper + sPathPart;
Expand Down

0 comments on commit 065d983

Please sign in to comment.