Updates to various components, added a few new ones.

This commit is contained in:
Areloch 2019-02-24 01:50:38 -06:00
parent 775ca57047
commit 34d05ff16f
52 changed files with 4566 additions and 1799 deletions

View file

@ -0,0 +1,276 @@
function GuiInspectorComponentGroup::buildMaterialField(%this, %component, %fieldName)
{
%extent = 200;
%currentMaterial = %component.getFieldValue(%fieldName);
//if we don't have a new material set on this slot, just use the default
if(%currentMaterial $= "" || %currentMaterial == 0)
%currentMaterial = %material;
%container = new GuiControl() {
canSaveDynamicFields = "0";
Profile = "EditorContainerProfile";
HorizSizing = "right";
VertSizing = "bottom";
Position = "0 0";
Extent = "300 110";
MinExtent = "8 2";
canSave = "0";
Visible = "1";
hovertime = "100";
tooltip = %tooltip;
tooltipProfile = "EditorToolTipProfile";
};
%labelControl = new GuiTextCtrl() {
canSaveDynamicFields = "0";
Profile = "EditorFontHLBold";
HorizSizing = "right";
VertSizing = "bottom";
Position = "16 3";
Extent = "100 18";
MinExtent = "8 2";
canSave = "0";
Visible = "1";
hovertime = "100";
tooltip = %tooltip;
tooltipProfile = "EditorToolTipProfile";
text = %fieldName;
maxLength = "1024";
};
//
%imageContainer = new GuiControl(){
profile = "ToolsGuiDefaultProfile";
Position = "20 25";
Extent = "74 87";
HorizSizing = "right";
VertSizing = "bottom";
isContainer = "1";
new GuiTextCtrl(){
position = "7 71";
profile = "ToolsGuiTextCenterProfile";
extent = "64 16";
text = %matName;
};
};
%previewButton = new GuiBitmapButtonCtrl(){
internalName = %matName;
HorizSizing = "right";
VertSizing = "bottom";
profile = "ToolsGuiButtonProfile";
position = "7 4";
extent = "64 64";
buttonType = "PushButton";
bitmap = "";
Command = "";
text = "Loading...";
useStates = false;
tooltip = "Change material";
new GuiBitmapButtonCtrl(){
HorizSizing = "right";
VertSizing = "bottom";
profile = "ToolsGuiButtonProfile";
position = "0 0";
extent = "64 64";
Variable = "";
buttonType = "toggleButton";
bitmap = "tools/materialEditor/gui/cubemapBtnBorder";
groupNum = "0";
text = "";
tooltip = "Change material";
};
};
%previewBorder = new GuiButtonCtrl(){
className = "materialFieldBtn";
internalName = %matName@"Border";
HorizSizing = "right";
VertSizing = "bottom";
profile = "ToolsGuiThumbHighlightButtonProfile";
position = "3 0";
extent = "72 88";
Variable = "";
buttonType = "toggleButton";
tooltip = %matName;
groupNum = "0";
text = "";
Object = %component;
targetField = %fieldName;
};
%previewBorder.Command = %previewBorder @ ".getMaterialName();";
%imageContainer.add(%previewButton);
%imageContainer.add(%previewBorder);
%container.add(%imageContainer);
//
%mapToLabel = new GuiTextCtrl() {
canSaveDynamicFields = "0";
Profile = "EditorFontHLBold";
HorizSizing = "right";
VertSizing = "bottom";
Position = "100 26";
Extent = %extent SPC "18";
MinExtent = "8 2";
canSave = "0";
Visible = "1";
hovertime = "100";
tooltip = %tooltip;
tooltipProfile = "EditorToolTipProfile";
text = "Mapped to:" SPC %material.mapTo;
maxLength = "1024";
};
%editControl = new GuiTextEditCtrl() {
class = "BehaviorEdTextField";
internalName = %accessor @ "File";
canSaveDynamicFields = "0";
Profile = "EditorTextEdit";
HorizSizing = "right";
VertSizing = "bottom";
Position = "100 50";
Extent = %extent SPC "22";
MinExtent = "8 2";
canSave = "0";
Visible = "1";
hovertime = "100";
tooltip = %tooltip;
tooltipProfile = "EditorToolTipProfile";
maxLength = "1024";
historySize = "0";
password = "0";
text = %currentMaterial;
tabComplete = "0";
sinkAllKeyEvents = "0";
password = "0";
passwordMask = "*";
precision = %precision;
accessor = %accessor;
isProperty = true;
undoLabel = %fieldName;
object = %this.object;
useWords = false;
};
%resetButton = new GuiButtonCtrl() {
canSaveDynamicFields = "0";
className = "materialFieldBtn";
Profile = "GuiButtonProfile";
HorizSizing = "right";
VertSizing = "bottom";
Position = "100 75";
Extent = (%extent * 0.3)-3 SPC "22";
MinExtent = "8 2";
canSave = "0";
Visible = "1";
hovertime = "100";
tooltip = "Reset to default material";
tooltipProfile = "EditorToolTipProfile";
text = "Reset";
pathField = %editControl;
};
%editMatButton = new GuiButtonCtrl() {
canSaveDynamicFields = "0";
className = "materialFieldBtn";
Profile = "GuiButtonProfile";
HorizSizing = "right";
VertSizing = "bottom";
Position = %resetButton.position.x + (%extent * 0.3) + 6 SPC "75";
Extent = (%extent * 0.6)-3 SPC "22";
MinExtent = "8 2";
canSave = "0";
Visible = "1";
hovertime = "100";
tooltip = "Edit in Material Editor";
tooltipProfile = "EditorToolTipProfile";
text = "Open in Editor";
pathField = %editControl;
};
%container.add(%mapToLabel);
%container.add(%labelControl);
%container.add(%editControl);
%container.add(%resetButton);
%container.add(%editMatButton);
//load the material
%matName = "";
// CustomMaterials are not available for selection
/*if ( !isObject( %currentMaterial ) || %currentMaterial.isMemberOfClass( "CustomMaterial" ) )
return;*/
%assetDef = AssetDatabase.acquireAsset(%currentMaterial);
%materialDef = %assetDef.materialDefinitionName;
if( %materialDef.isMemberOfClass("TerrainMaterial") )
{
%matName = %currentMaterial.getInternalName();
if( %materialDef.diffuseMap $= "")
%previewImage = "core/art/warnmat";
else
%previewImage = %materialDef.diffuseMap;
}
else if( %materialDef.toneMap[0] $= "" && %materialDef.diffuseMap[0] $= "" && !isObject(%materialDef.cubemap) )
{
%matName = %materialDef.name;
%previewImage = "core/art/warnmat";
}
else
{
%matName = %materialDef.name;
if( %materialDef.toneMap[0] !$= "" )
%previewImage = %materialDef.toneMap[0];
else if( %materialDef.diffuseMap[0] !$= "" )
%previewImage = %materialDef.diffuseMap[0];
else if( %materialDef.cubemap.cubeFace[0] !$= "" )
%previewImage = %materialDef.cubemap.cubeFace[0];
//%previewImage = MaterialEditorGui.searchForTexture( %material, %previewImage );
// were going to use a couple of string commands in order to properly
// find out what the img src path is
// **NEW** this needs to be updated with the above, but has some timing issues
%materialDiffuse = %previewImage;
%materialPath = %materialDef.getFilename();
if( strchr( %materialDiffuse, "/") $= "" )
{
%k = 0;
while( strpos( %materialPath, "/", %k ) != -1 )
{
%foo = strpos( %materialPath, "/", %k );
%k = %foo + 1;
}
%foobar = getSubStr( %materialPath , %k , 99 );
%previewImage = strreplace( %materialPath, %foobar, %previewImage );
}
else
%previewImage = strreplace( %materialPath, %materialPath, %previewImage );
}
%previewButton.setBitmap(%previewImage);
%previewButton.setText("");
%this.stack.add(%container);
}
function materialFieldBtn::onClick(%this)
{
AssetBrowser.showDialog("MaterialAsset", "", %this.Object, %this.targetField, "");
}
function materialFieldBtn::setMaterial(%this, %matAssetName)
{
}

View file

@ -0,0 +1,215 @@
function BehaviorFieldStack::createStateMachineEditor(%this, %behavior, %fieldIndex)
{
%fieldInfo = %behavior.template.getBehaviorField(%fieldIndex);
%name = getField(%fieldInfo, 0);
%button = new GuiButtonCtrl()
{
class = EditStateMachineBtn;
HorizSizing = "right";
VertSizing = "bottom";
Position = "0 2";
Extent = (%this.extent.x - 8) SPC 13;
text = "Edit States";
tooltip = "Open window to edit the state machine";
behavior = %behavior;
};
%this.add(%button);
}
function EditStateMachineBtn::onClick(%this)
{
Canvas.pushDialog(StateMachineEditor);
StateMachineEditor.behavior = %this.behavior;
StateMachineEditor.open();
}
function StateMachineEditor::open(%this)
{
//check our behavior and see if we have any existing state/field info to work with
//if we do, load those up first
for(%i = 0; %i < %this.behavior.stateMachine.count(); %i++)
{
%stateName = %this.behavior.stateMachine.getKey(%i);
%this.addState(%stateName);
}
}
function StateMachineEditor::addState(%this, %stateName)
{
if(%stateName $= "")
%stateName = "New State";
%state = new GuiControl() {
position = "0 0";
extent = "285 50";
horizSizing = "horizResizeWidth";
vertSizing = "vertResizeTop";
isContainer = "1";
new GuiTextEditCtrl() {
position = "0 0";
extent = "100 15";
text = %stateName;
};
new GuiButtonCtrl() {
//buttonMargin = "4 4";
text = "Remove State";
position = "184 0";
extent = "100 15";
//profile = "GuiButtonProfile";
command = "ScriptEditorGui.save();";
};
new GuiSeparatorCtrl() {
position = "0 15";
extent = %this.extent.x SPC "10";
type = "horizontal";
};
new GuiStackControl(%stateName@"StateStack")
{
//Profile = "EditorContainerProfile";
HorizSizing = "right";
VertSizing = "bottom";
Position = "0 25";
Extent = "285 20";
padding = 4;
new GuiButtonCtrl() {
text = "Add field";
position = "3 0";
extent = "280 20";
horizSizing = "left";
vertSizing = "top";
command = "StateMachineEditor.addField("@%stateName@");";
};
};
};
%this-->Stack.add(%state);
//%this-->stateStackScroll.computeSizes();
}
function StateMachineEditor::addField(%this, %stateName)
{
%index = %this.behavior.stateMachine.count();
%field = new GuiControl() {
position = "0 0";
extent = "285 20";
horizSizing = "width";
vertSizing = "height";
isContainer = "1";
fieldValueCtrl = "";
fieldID = %index++;
};
%fieldList = new GuiPopUpMenuCtrlEx()
{
class = "stateMachineFieldList";
Profile = "GuiPopupMenuProfile";
HorizSizing = "width";
VertSizing = "bottom";
position = "0 1";
Extent = "120 18";
behavior = %this.behavior;
};
%field.add(%fieldList);
%fieldList.refresh();
(%stateName@"StateStack").addToStack(%field);
%this-->Stack.updateStack();
%this-->stateStackScroll.computeSizes();
%this.behavior.addStateField(%stateName, "", "");
return %field;
}
//==============================================================================
function stateMachineFieldList::refresh(%this)
{
%this.clear();
// Find all the types.
%count = getWordCount(%this.behavior.stateFields);
%index = 0;
for (%j = 0; %j < %count; %j++)
{
%item = getWord(%this.behavior.stateFields, %j);
%this.add(%item, %index);
%this.fieldType[%index] = %item;
%index++;
}
}
function stateMachineFieldList::onSelect(%this)
{
//if(%this.getParent().fieldValueCtrl $= "")
%this.fieldType = %this.fieldType[%this.getSelected()];
if(%this.fieldType $= "transitionOnAnimEnd" || %this.fieldType $= "transitionOnAnimTrigger"
|| %this.fieldType $= "transitionOnTimeout")
{
%fieldCtrl = new GuiPopUpMenuCtrlEx()
{
class = "stateMachineFieldList";
Profile = "GuiPopupMenuProfile";
HorizSizing = "width";
VertSizing = "bottom";
position = "124 1";
Extent = "120 18";
};
}
else if(%this.fieldType $= "animation")
{
%fieldCtrl = new GuiPopUpMenuCtrlEx()
{
class = "stateMachineFieldList";
Profile = "GuiPopupMenuProfile";
HorizSizing = "width";
VertSizing = "bottom";
position = "124 1";
Extent = "120 18";
};
%index = 0;
%animBhvr = %this.behavior.owner.getBehavior("AnimationController");
for(%i = 0; %i < %animBhvr.getAnimationCount(); %i++)
{
%item = %animBhvr.getAnimationName(%i);
%fieldCtrl.add(%item, %index);
%fieldCtrl.fieldValue[%index] = %item;
%index++;
}
}
else
{
%fieldCtrl = new GuiTextEditCtrl() {
position = "124 1";
extent = "120 10";
text = "";
};
}
//get the state machine entry
%index = %this.getParent().fieldID;
%oldValue = %this.behavior.stateMachine.getValue(%index);
%this.behavior.stateMachine.setValue(%fieldType SPC %oldValue.y);
%this.getParent().add(%fieldCtrl);
}
//==============================================================================
//Now for the unique field types
/*function stateMachineFieldList::refresh(%this)
{
}*/

View file

@ -0,0 +1,40 @@
function GuiInspectorComponentGroup::buildTypeMaskField(%this, %component, %fieldName)
{
%extent = 200;
%container = new GuiControl() {
canSaveDynamicFields = "0";
Profile = "EditorContainerProfile";
HorizSizing = "right";
VertSizing = "bottom";
Position = "0 0";
Extent = "300 110";
MinExtent = "8 2";
canSave = "0";
Visible = "1";
hovertime = "100";
tooltip = %tooltip;
tooltipProfile = "EditorToolTipProfile";
};
%labelControl = new GuiTextCtrl() {
canSaveDynamicFields = "0";
Profile = "EditorFontHLBold";
HorizSizing = "right";
VertSizing = "bottom";
Position = "16 3";
Extent = "100 18";
MinExtent = "8 2";
canSave = "0";
Visible = "1";
hovertime = "100";
tooltip = %tooltip;
tooltipProfile = "EditorToolTipProfile";
text = %fieldName;
maxLength = "1024";
};
%container.add(%container);
%this.stack.add(%container);
}