Converts the ad-hoc design of the Material Editor to utilize the same inspector interface as most everything else does.

- Overhauls the material editor to simplify and streamline the logic behind it since the inspector does most of the work
- Tweak a few order positions of materialdefinition fields to work better
- Sets AO, Rough and Metal channel fields to use an enum type for human readability
- Updates the MaterialPreview gui control to work with assetIds
- MatEd now supports setting of parent material to inherit from
- Creating a new material now can prompt selecting an existing material to inherit from
- Can now edit the mapTo value of a material in the matEd
- New standalone Composite Texture Editor window for convering AO, Roughness and Metalness maps in a material to an ORMMap
- Can also star the creation of a composite texture via RMB context menu in AB on an image asset
- Moved logic of CubemapEditor from MatEd to it's own stuff
- Made ImageAsset fields now be more clear when they have nothing assigned, and also have a clear button to empty the field's value so it's consistent across the board
- Reorganized the layout of the gui and image files for the MatEd to be easier to navigate
- MaterialEditor now overlays the EditorGUI instead of being forcefully embedded in it, allowing easy editing of the MatEd Gui via the Gui editor
This commit is contained in:
JeffR 2025-08-03 12:03:02 -05:00
parent 8e93753b15
commit f3cad0d77e
173 changed files with 3713 additions and 6977 deletions

View file

@ -0,0 +1,149 @@
function GuiInspectorGroup::buildMatORMSliderField(%this, %fieldName, %fieldLabel, %fieldDesc, %fieldDefaultVal, %fieldDataVals, %callbackName, %ownerObj)
{
echo("GuiInspectorGroup::buildMatORMSliderField()");
%extent = 200;
%fieldCtrl = %this.createInspectorField();
%extent = %this.stack.getExtent();
%width = mRound(%extent/2);
%height = 20;
%inset = 10;
%fieldCtrl.setHeightOverride(true, %height);
%minRange = getWord(%fieldDataVals,0);
%maxRange = getWord(%fieldDataVals,1);
%tickCount = getWord(%fieldDataVals,2);
%doSnap = getWord(%fieldDataVals,3);
if(%doSnap $= "")
%doSnap = 0;
%editControl = new GuiControl()
{
class = "guiMatORMSliderField";
Position = %fieldCtrl.edit.position;
Extent = %fieldCtrl.edit.extent;
};
%editText = new GuiTextEditCtrl() {
class = "guiMatORMSliderFieldText";
historySize = "0";
tabComplete = "0";
sinkAllKeyEvents = "0";
password = "0";
passwordMask = "*";
maxLength = "1024";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
Position = "0 0";
Extent = %fieldCtrl.edit.extent.x * 0.2 SPC %fieldCtrl.edit.extent.y;
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "ToolsGuiTextEditProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
text = %fieldDefaultVal;
};
%editSlider = new GuiSliderCtrl() {
class = "guiMatORMSliderFieldSlider";
range = %minRange SPC %maxRange;
ticks = %tickCount;
value = %fieldDefaultVal;
snap = %doSnap;
renderTicks = "true";
isContainer = "0";
Profile = "GuiSliderProfile";
HorizSizing = "width";
VertSizing = "bottom";
Position = (%fieldCtrl.edit.extent.x * 0.2) + 5 SPC 0;
Extent = (%fieldCtrl.edit.extent.x * 0.8) - 5 SPC %fieldCtrl.edit.extent.y;
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "$thisControl.onDragComplete();";
tooltipprofile = "GuiToolTipProfile";
tooltip = ""; //%tooltip;
hovertime = "1000";
canSaveDynamicFields = "0";
ownerObject = %ownerObj;
fieldName = %fieldName;
callbackName = %callbackName;
};
%editText.sliderControl = %editSlider;
%editSlider.textControl = %editText;
%editControl.add(%editText);
%editControl.add(%editSlider);
//set the field value
if(getSubStr(%this.fieldName, 0, 1) $= "$")
{
if(%fieldName $= "")
%editControl.setValue(%fieldName);
}
else if(isObject(%ownerObj))
{
//regular variable
%setCommand = %editControl @ ".setValue(" @ %ownerObj @ "." @ %fieldName @ ");";
eval(%setCommand);
}
%fieldCtrl.setCaption(%fieldLabel);
%fieldCtrl.setEditControl(%editControl);
%this.addInspectorField(%fieldCtrl);
}
function guiMatORMSliderFieldField::onResize(%this)
{
}
function guiMatORMSliderFieldText::onReturn(%this)
{
%value = %this.getText();
%this.sliderControl.setValue(%value);
%this.sliderControl.onDragComplete();
}
function guiMatORMSliderFieldSlider::onDragComplete( %this )
{
%value = %this.getValue();
%this.textControl.setText(%value);
if(getSubStr(%this.fieldName, 0, 1) $= "$")
{
//ah, a global var, just do it straight, then
%setCommand = %this.fieldName @ " = \"" @ %value @ "\";";
}
else if(isObject(%this.ownerObject))
{
//regular variable
%setCommand = %this.ownerObject @ "." @ %this.fieldName @ " = \"" @ %value @ "\";";
}
else if(%this.callbackName !$= "")
{
%setCommand = %this.callbackName @ "(\"" @ %this.fieldName @ "\",\"" @ %value @"\");";
}
eval(%setCommand);
}
function guiMatORMSliderFieldSlider::onMouseDragged(%this)
{
%this.onDragComplete();
}

View file

@ -0,0 +1,31 @@
function GuiInspectorGroup::buildBakeCompositeButtonField(%this, %fieldName, %fieldLabel, %fieldDesc, %fieldDefaultVal, %fieldDataVals, %callbackName, %ownerObj)
{
%fieldCtrl = %this.createInspectorField();
%extent = %this.stack.getExtent();
%width = mRound(%extent/2);
%button = new GuiButtonCtrl() {
canSaveDynamicFields = "0";
Profile = "ToolsGuiButtonProfile";
HorizSizing = "width";
VertSizing = "bottom";
Position = "16 3";
Extent = %width SPC 18;
MinExtent = "8 2";
canSave = "0";
Visible = "1";
hovertime = "100";
tooltip = ""; //%tooltip;
tooltipProfile = "EditorToolTipProfile";
text = "Bake";
maxLength = "1024";
command = "MaterialEditorGui.saveCompositeMap();";
};
%fieldCtrl.setCaption(%fieldLabel);
%fieldCtrl.setEditControl(%button);
%this.addInspectorField(%fieldCtrl);
}

View file

@ -0,0 +1,939 @@
function GuiInspectorGroup::buildMaterialRotAnimationField(%this, %fieldName, %fieldLabel, %fieldDesc, %fieldDefaultVal, %fieldDataVals, %callbackName, %ownerObj)
{
%container = new GuiContainer()
{
profile="inspectorStyleRolloutInnerProfile";
isContainer = "1";
position = "-1 120";
Extent = 300 SPC 100;
HorizSizing = "width";
new GuiCheckboxCtrl() {
canSaveDynamicFields = "0";
internalName = "RotationAnimation";
Enabled = "1";
isContainer = "0";
Profile = "ToolsGuiInspectorCheckBoxTitleProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "4 3";
Extent = "200 18";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "MaterialEditorGui.updateAnimationFlags();";
tooltipprofile = "ToolsGuiToolTipProfile";
hovertime = "1000";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
text = " Rotation Animation";
maxLength = "1024";
};
new GuiControl(){
class = "AggregateControl";
position = "0 29";
Extent = "290 20";
HorizSizing = "width";
internalName = "RotAnimAggCtrl";
new GuiTextCtrl(){ // u
profile = "ToolsGuiTextProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "11 1";
Extent = "12 16";
text = "U";
};
new GuiSliderCtrl() { // u
Profile = "ToolsGuiSliderProfile";
internalName = "RotationSliderU";
HorizSizing = "width";
VertSizing = "bottom";
position = "25 2";
Extent = "180 15";
Command = "MaterialEditorGui.updateRotationOffset(true, true);";
AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateRotationOffset(true, false);";
tooltipprofile = "ToolsGuiToolTipProfile";
ToolTip = "Change U Scroll Direction";
hovertime = "1000";
range = "-1 0";
ticks = "1";
value = "-0.5";
};
new GuiTextEditCtrl(){ // u
internalName = "RotationTextEditU";
HorizSizing = "left";
VertSizing = "bottom";
position = "210 0";
Extent = "34 18";
text = "0";
Command = "$ThisControl.getParent().updateFromChild($ThisControl);";
Profile = "ToolsGuiTextEditProfile";
};
};
new GuiControl() {
class = "AggregateControl";
position = "0 50";
Extent = "290 20";
HorizSizing = "width";
new GuiTextCtrl(){ // v
profile = "ToolsGuiTextProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "11 1";
Extent = "12 16";
text = "V";
};
new GuiSliderCtrl() { // v
Profile = "ToolsGuiSliderProfile";
internalName = "RotationSliderV";
HorizSizing = "width";
VertSizing = "bottom";
position = "25 2";
Extent = "180 15";
Command = "MaterialEditorGui.updateRotationOffset(true, true);";
AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateRotationOffset(true, false);";
tooltipprofile = "ToolsGuiToolTipProfile";
ToolTip = "Change V Scroll Direction";
hovertime = "1000";
range = "-1 0";
ticks = "1";
value = "-0.5";
};
new GuiTextEditCtrl(){ // v
internalName = "RotationTextEditV";
HorizSizing = "left";
VertSizing = "bottom";
position = "210 0";
Extent = "34 18";
text = "0";
Profile = "ToolsGuiTextEditProfile";
Command = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateRotationOffset();";
};
};
new GuiTextCtrl(){ // Pivot Point
HorizSizing = "left";
VertSizing = "bottom";
position = "211 12";
Extent = "34 16";
text = "Pivot";
profile = "ToolsGuiTextProfile";
};
new GuiBitmapCtrl(){
HorizSizing = "left";
VertSizing = "bottom";
position = "248 20";
Extent = "48 48";
isContainer = true;
bitmapAsset="";
new GuiBitmapCtrl(){
HorizSizing = "right";
VertSizing = "bottom";
position = "0 0";
Extent = "48 48";
bitmapAsset="ToolsModule:cubemapBtnBorder_n_image";
};
new GuiBitmapCtrl(){ //horizontal bar
internalName = "RotationCrosshair";
HorizSizing = "right";
VertSizing = "bottom";
position = "20 20";
Extent = "7 7";
MinExtent = "0 0";
bitmapAsset="ToolsModule:crosshair_blue_image";
};
};
new GuiControl() {
class = "AggregateControl";
position = "0 75";
Extent = "300 35";
HorizSizing = "width";
new GuiTextCtrl(){ // Speed
profile = "ToolsGuiTextRightProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "11 0";
Extent = "40 16";
text = "Speed";
};
new GuiSliderCtrl() {
canSaveDynamicFields = "0";
internalName = "RotationSpeedSlider";
Enabled = "1";
isContainer = "0";
Profile = "ToolsGuiSliderProfile";
HorizSizing = "width";
VertSizing = "bottom";
position = "58 3";
Extent = "148 16";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "MaterialEditorGui.updateRotationSpeed(true, true);";
AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateRotationSpeed(true, false);";
tooltipprofile = "ToolsGuiToolTipProfile";
ToolTip = "Scrolling Speed";
hovertime = "1000";
range = "-10 10";
ticks = "1";
value = "0";
};
new GuiTextEditCtrl() {
canSaveDynamicFields = "0";
internalName = "RotationSpeedTextEdit";
Enabled = "1";
isContainer = "0";
Profile = "ToolsGuiTextEditProfile";
HorizSizing = "left";
VertSizing = "bottom";
position = "210 1";
Extent = "34 18";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateRotationSpeed();";
hovertime = "1000";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
text = "0";
maxLength = "1024";
historySize = "0";
password = "0";
tabComplete = "0";
sinkAllKeyEvents = "0";
password = "0";
passwordMask = "*";
};
new GuiTextCtrl(){ // space
profile = "ToolsGuiTextRightProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "0 20";
Extent = "300 20";
text = " ";
};
};
};
%container.resize(0,0,%this-->stack.extent.x, 100);
%this-->stack.add(%container);
}
function MaterialEditorGui::updateRotationOffset(%this, %isSlider, %onMouseUp)
{
%layer = MaterialEditorGui.currentLayer;
%X = MaterialEditorGuiWindow-->RotationTextEditU.getText();
%Y = MaterialEditorGuiWindow-->RotationTextEditV.getText();
MaterialEditorPropertiesWindow-->RotationCrosshair.setPosition(45*mAbs(%X)-2, 45*mAbs(%Y)-2);
MaterialEditorGui.updateActiveMaterial("rotPivotOffset[" @ %layer @ "]", %X SPC %Y,%isSlider,%onMouseUp);
}
function MaterialEditorGui::updateRotationSpeed(%this, %isSlider, %onMouseUp)
{
%layer = MaterialEditorGui.currentLayer;
%speed = MaterialEditorGuiWindow-->RotationSpeedTextEdit.getText();
MaterialEditorGui.updateActiveMaterial("rotSpeed[" @ %layer @ "]",%speed,%isSlider,%onMouseUp);
}
function GuiInspectorGroup::buildMaterialScrollAnimationField(%this, %fieldName, %fieldLabel, %fieldDesc, %fieldDefaultVal, %fieldDataVals, %callbackName, %ownerObj)
{
%container = new GuiContainer(){ // Scroll Animation Properties
profile="inspectorStyleRolloutInnerProfile";
isContainer = "1";
position = "-1 240";
Extent = "300 105";
HorizSizing = "width";
new GuiBitmapCtrl(){
position = "0 5";
extent ="300 2";
HorizSizing = "width";
bitmapAsset ="ToolsModule:separator_v_image";
};
new GuiCheckboxCtrl() {
canSaveDynamicFields = "0";
internalName = "ScrollAnimation";
Enabled = "1";
isContainer = "0";
Profile = "ToolsGuiInspectorCheckBoxTitleProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "4 10";
Extent = "200 18";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
tooltipprofile = "ToolsGuiToolTipProfile";
hovertime = "1000";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
Command = "MaterialEditorGui.updateAnimationFlags();";
text = " Scroll Animation";
maxLength = "1024";
};
new GuiControl(){
class = "AggregateControl";
position = "0 29";
Extent = "290 20";
HorizSizing = "width";
new GuiTextCtrl(){ // u
profile = "ToolsGuiTextProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "11 1";
Extent = "12 16";
text = "U";
};
new GuiSliderCtrl() { // u
Profile = "ToolsGuiSliderProfile";
internalName = "ScrollSliderU";
HorizSizing = "width";
VertSizing = "bottom";
position = "25 2";
Extent = "180 15";
Command = "MaterialEditorGui.updateScrollOffset(true, true);";
AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl);MaterialEditorGui.updateScrollOffset(true, false);";
tooltipprofile = "ToolsGuiToolTipProfile";
ToolTip = "Change U Scroll Direction";
hovertime = "1000";
range = "-1 1";
ticks = "1";
value = "0";
};
new GuiTextEditCtrl(){ // u
internalName = "ScrollTextEditU";
HorizSizing = "left";
VertSizing = "bottom";
position = "210 0";
Extent = "34 18";
text = "0";
Profile = "ToolsGuiTextEditProfile";
Command = "$ThisControl.getParent().updateFromChild($ThisControl);MaterialEditorGui.updateScrollOffset();";
};
};
new GuiControl() {
class = "AggregateControl";
position = "0 50";
Extent = "290 20";
HorizSizing = "width";
new GuiTextCtrl(){ // v
profile = "ToolsGuiTextProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "11 1";
Extent = "12 16";
text = "V";
};
new GuiSliderCtrl() { // v
Profile = "ToolsGuiSliderProfile";
internalName = "ScrollSliderV";
HorizSizing = "width";
VertSizing = "bottom";
position = "25 2";
Extent = "180 15";
Command = "MaterialEditorGui.updateScrollOffset(true, true);";
AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl);MaterialEditorGui.updateScrollOffset(true, false);";
tooltipprofile = "ToolsGuiToolTipProfile";
ToolTip = "Change V Scroll Direction";
hovertime = "1000";
range = "-1 1";
ticks = "1";
value = "0";
};
new GuiTextEditCtrl(){ // v
internalName = "ScrollTextEditV";
HorizSizing = "left";
VertSizing = "bottom";
position = "210 0";
Extent = "34 18";
text = "0";
Profile = "ToolsGuiTextEditProfile";
Command = "$ThisControl.getParent().updateFromChild($ThisControl);MaterialEditorGui.updateScrollOffset();";
};
};
new GuiTextCtrl(){ // Direction Offset
HorizSizing = "left";
VertSizing = "bottom";
position = "211 12";
Extent = "34 16";
text = "Offset";
profile = "ToolsGuiTextProfile";
};
new GuiBitmapCtrl(){
HorizSizing = "left";
VertSizing = "bottom";
position = "248 20";
Extent = "48 48";
isContainer = true;
bitmapAsset="";
new GuiBitmapCtrl(){
HorizSizing = "right";
VertSizing = "bottom";
position = "0 0";
Extent = "48 48";
bitmapAsset="ToolsModule:cubemapBtnBorder_n_image";
};
new GuiBitmapCtrl(){ //vertical bar
HorizSizing = "right";
VertSizing = "bottom";
position = "20 20";
Extent = "7 7";
MinExtent = "7 7";
bitmapAsset="ToolsModule:crosshair_image";
};
new GuiBitmapCtrl(){ //horizontal bar
internalName = "ScrollCrosshair";
HorizSizing = "right";
VertSizing = "bottom";
position = "20 20";
Extent = "7 7";
MinExtent = "0 0";
bitmapAsset="ToolsModule:crosshair_blue_image";
};
};
new GuiControl() {
class = "AggregateControl";
position = "0 75";
Extent = "300 35";
HorizSizing = "width";
new GuiTextCtrl(){ // Speed
profile = "ToolsGuiTextRightProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "11 0";
Extent = "40 16";
text = "Speed";
};
new GuiSliderCtrl() {
canSaveDynamicFields = "0";
internalName = "ScrollSpeedSlider";
Enabled = "1";
isContainer = "0";
Profile = "ToolsGuiSliderProfile";
HorizSizing = "width";
VertSizing = "bottom";
position = "58 3";
Extent = "148 16";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "MaterialEditorGui.updateScrollSpeed(true, true);";
AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl);MaterialEditorGui.updateScrollSpeed(true, false);";
tooltipprofile = "ToolsGuiToolTipProfile";
ToolTip = "Scrolling Speed";
hovertime = "1000";
range = "0 10";
ticks = "0";
value = "0";
};
new GuiTextEditCtrl() {
canSaveDynamicFields = "0";
internalName = "ScrollSpeedTextEdit";
Enabled = "1";
isContainer = "0";
Profile = "ToolsGuiTextEditProfile";
HorizSizing = "left";
VertSizing = "bottom";
position = "210 1";
Extent = "34 18";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "$ThisControl.getParent().updateFromChild($ThisControl);MaterialEditorGui.updateScrollSpeed();";
hovertime = "1000";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
text = "0";
maxLength = "1024";
historySize = "0";
password = "0";
tabComplete = "0";
sinkAllKeyEvents = "0";
password = "0";
passwordMask = "*";
};
new GuiTextCtrl(){ // space
profile = "ToolsGuiTextRightProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "0 20";
Extent = "300 20";
text = " ";
};
};
};
%this-->stack.add(%container);
}
function MaterialEditorGui::updateScrollOffset(%this, %isSlider, %onMouseUp)
{
%layer = MaterialEditorGui.currentLayer;
%X = MaterialEditorGuiWindow-->ScrollTextEditU.getText();
%Y = MaterialEditorGuiWindow-->ScrollTextEditV.getText();
MaterialEditorGuiWindow-->ScrollCrosshair.setPosition( -(23 * %X)+20, -(23 * %Y)+20);
MaterialEditorGui.updateActiveMaterial("scrollDir[" @ %layer @ "]",%X SPC %Y,%isSlider,%onMouseUp);
}
function MaterialEditorGui::updateScrollSpeed(%this, %isSlider, %onMouseUp)
{
%layer = MaterialEditorGui.currentLayer;
%speed = MaterialEditorGuiWindow-->ScrollSpeedTextEdit.getText();
MaterialEditorGui.updateActiveMaterial("scrollSpeed[" @ %layer @ "]",%speed,%isSlider,%onMouseUp);
}
function GuiInspectorGroup::buildMaterialWaveAnimationField(%this, %fieldName, %fieldLabel, %fieldDesc, %fieldDefaultVal, %fieldDataVals, %callbackName, %ownerObj)
{
%container = new GuiContainer(){ // Wave Animation Properties
profile="inspectorStyleRolloutInnerProfile";
isContainer = "1";
position = "-1 360";
Extent = "300 85";
HorizSizing = "width";
new GuiBitmapCtrl(){
position = "0 0";
extent ="300 2";
HorizSizing = "width";
bitmapAsset ="ToolsModule:separator_v_image";
};
new GuiCheckboxCtrl() {
Profile = "ToolsGuiInspectorCheckBoxTitleProfile";
internalName = "WaveAnimation";
HorizSizing = "right";
VertSizing = "bottom";
position = "4 5";
Extent = "200 16";
MinExtent = "8 2";
text = " Wave Animation";
Command = "MaterialEditorGui.updateAnimationFlags();";
groupNum = "-1";
tooltipprofile = "ToolsGuiToolTipProfile";
};
new GuiCheckboxCtrl() {
Profile = "ToolsGuiCheckBoxProfile";
internalName = "ScaleAnimation";
HorizSizing = "right";
VertSizing = "bottom";
position = "180 24";
Extent = "55 16";
MinExtent = "8 2";
text = " Scale";
Command = "MaterialEditorGui.updateAnimationFlags();";
groupNum = "-1";
tooltipprofile = "ToolsGuiToolTipProfile";
};
new GuiTextCtrl() {
profile = "ToolsGuiTextRightProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "1 22";
Extent = "100 16";
text = " Wave Type";
};
new GuiContainer(){ // Wave Radio Button container
profile = "ToolsGuiDefaultProfile";
internalName = "WaveButtonContainer";
position = "120 24";
Extent = "49 13";
isContainer = "1";
new GuiBitmapButtonCtrl(){
profile = "ToolsGuiDefaultProfile";
buttonType = "RadioButton";
position = "1 0";
Extent = "13 13";
bitmapAsset = "ToolsModule:wav_sine_n_image";
command = "MaterialEditorGui.updateWaveType();";
tooltip="Sine Wave";
hovertime = "1000";
groupNum = "0";
waveType = "Sin";
tooltipprofile = "ToolsGuiToolTipProfile";
};
new GuiBitmapButtonCtrl(){
profile = "ToolsGuiDefaultProfile";
buttonType = "RadioButton";
position = "17 0";
Extent = "13 13";
bitmapAsset = "ToolsModule:wav_triangle_n_image";
command = "MaterialEditorGui.updateWaveType();";
tooltip="Triangle Wave";
hovertime = "1000";
groupNum = "0";
waveType = "Triangle";
tooltipprofile = "ToolsGuiToolTipProfile";
};
new GuiBitmapButtonCtrl(){
profile = "ToolsGuiDefaultProfile";
buttonType = "RadioButton";
position = "33 0";
Extent = "13 13";
bitmapAsset = "ToolsModule:wav_square_n_image";
command = "MaterialEditorGui.updateWaveType();";
tooltip="Square Wave";
hovertime = "1000";
groupNum = "0";
waveType = "Square";
tooltipprofile = "ToolsGuiToolTipProfile";
};
};
new GuiControl() {
class = "AggregateControl";
position = "0 61";
Extent = "300 20";
HorizSizing = "width";
new GuiTextCtrl() {
profile = "ToolsGuiTextRightProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "1 2";
Extent = "100 16";
text = "Frequency";
};
new GuiTextEditCtrl() { // frequence
canSaveDynamicFields = "0";
internalName = "WaveTextEditFreq";
Enabled = "1";
isContainer = "0";
Profile = "ToolsGuiTextEditProfile";
HorizSizing = "left";
VertSizing = "bottom";
position = "260 1";
Extent = "34 18";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateWaveFreq();";
hovertime = "1000";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
text = "0";
maxLength = "1024";
historySize = "0";
password = "0";
tabComplete = "0";
sinkAllKeyEvents = "0";
password = "0";
passwordMask = "*";
};
new GuiSliderCtrl() { // freqency
canSaveDynamicFields = "0";
internalName = "WaveSliderFreq";
Enabled = "1";
isContainer = "0";
Profile = "ToolsGuiSliderProfile";
HorizSizing = "width";
VertSizing = "bottom";
position = "120 4";
Extent = "137 16";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "MaterialEditorGui.updateWaveFreq(true, true);";
AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateWaveFreq(true, false);";
tooltipprofile = "ToolsGuiToolTipProfile";
ToolTip = "Changes Wave Frequency";
hovertime = "1000";
range = "0 10";
ticks = "9";
value = "0";
};
};
new GuiControl() {
class = "AggregateControl";
position = "0 40";
Extent = "300 20";
HorizSizing = "width";
new GuiTextCtrl() {
profile = "ToolsGuiTextRightProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "1 2";
Extent = "100 16";
text = "Amplitude";
};
new GuiTextEditCtrl() { // amplitude
Profile = "ToolsGuiTextEditProfile";
internalName = "WaveTextEditAmp";
HorizSizing = "left";
VertSizing = "bottom";
position = "260 1";
Extent = "34 18";
Command = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateWaveAmp();";
hovertime = "1000";
text = "0";
};
new GuiSliderCtrl() { // amplitude
canSaveDynamicFields = "0";
internalName = "WaveSliderAmp";
Enabled = "1";
isContainer = "0";
Profile = "ToolsGuiSliderProfile";
HorizSizing = "width";
VertSizing = "bottom";
position = "120 4";
Extent = "137 16";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "MaterialEditorGui.updateWaveAmp(true, true);";
AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateWaveAmp(true, false);";
tooltipprofile = "ToolsGuiToolTipProfile";
ToolTip = "Changes Wave Amplitude";
hovertime = "1000";
range = "0 1";
ticks = "1";
value = "0";
};
};
};
%this-->stack.add(%container);
}
function MaterialEditorGui::updateWaveType(%this)
{
for( %radioButton = 0; %radioButton < MaterialEditorGuiWindow-->WaveButtonContainer.getCount(); %radioButton++ )
{
if( MaterialEditorGuiWindow-->WaveButtonContainer.getObject(%radioButton).getValue() == 1 )
%type = MaterialEditorGuiWindow-->WaveButtonContainer.getObject(%radioButton).waveType;
}
%layer = MaterialEditorGui.currentLayer;
MaterialEditorGui.updateActiveMaterial("waveType[" @ %layer @ "]", %type);
}
function MaterialEditorGui::updateWaveAmp(%this, %isSlider, %onMouseUp)
{
%layer = MaterialEditorGui.currentLayer;
%amp = MaterialEditorGuiWindow-->WaveTextEditAmp.getText();
MaterialEditorGui.updateActiveMaterial("waveAmp[" @ %layer @ "]", %amp, %isSlider, %onMouseUp);
}
function MaterialEditorGui::updateWaveFreq(%this, %isSlider, %onMouseUp)
{
%layer = MaterialEditorGui.currentLayer;
%freq = MaterialEditorGuiWindow-->WaveTextEditFreq.getText();
MaterialEditorGui.updateActiveMaterial("waveFreq[" @ %layer @ "]", %freq, %isSlider, %onMouseUp);
}
function GuiInspectorGroup::buildMaterialSequenceAnimationField(%this, %fieldName, %fieldLabel, %fieldDesc, %fieldDefaultVal, %fieldDataVals, %callbackName, %ownerObj)
{
%container = new GuiContainer(){ // image Sequence Animation Properties
profile="inspectorStyleRolloutInnerProfile";
isContainer = "1";
position = "-1 480";
Extent = "300 80";
HorizSizing = "width";
new GuiBitmapCtrl(){
position = "0 5";
extent ="300 2";
HorizSizing = "width";
bitmapAsset ="ToolsModule:separator_v_image";
};
new GuiCheckboxCtrl() {
Profile = "ToolsGuiInspectorCheckBoxTitleProfile";
internalName = "SequenceAnimation";
HorizSizing = "right";
VertSizing = "bottom";
position = "4 10";
Extent = "200 16";
MinExtent = "8 2";
text = " Image Sequence";
Command = "MaterialEditorGui.updateAnimationFlags();";
groupNum = "-1";
};
new GuiControl() {
class = "AggregateControl";
position = "0 28";
Extent = "300 20";
HorizSizing = "width";
new GuiTextCtrl() {
profile = "ToolsGuiTextRightProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "1 2";
Extent = "100 16";
text = "Frames / Sec";
};
new GuiTextEditCtrl() {
canSaveDynamicFields = "0";
internalName = "SequenceTextEditFPS";
Enabled = "1";
isContainer = "0";
Profile = "ToolsGuiTextEditProfile";
HorizSizing = "left";
VertSizing = "bottom";
position = "260 1";
Extent = "34 18";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateSequenceFPS();";
hovertime = "1000";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
text = "0";
maxLength = "1024";
};
new GuiSliderCtrl() {
canSaveDynamicFields = "0";
internalName = "SequenceSliderFPS";
Enabled = "1";
isContainer = "0";
Profile = "ToolsGuiSliderProfile";
HorizSizing = "width";
VertSizing = "bottom";
position = "120 4";
Extent = "137 16";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "MaterialEditorGui.updateSequenceFPS(true, true);";
AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateSequenceFPS(true, false);";
tooltipprofile = "ToolsGuiToolTipProfile";
ToolTip = "How many frames to display per second.";
hovertime = "1000";
range = "0 30";
ticks = "5";
value = "0";
};
};
new GuiControl() {
class = "AggregateControl";
position = "0 49";
Extent = "300 20";
HorizSizing = "width";
new GuiTextCtrl() {
profile = "ToolsGuiTextRightProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "1 2";
Extent = "100 16";
text = "Frames";
};
new GuiTextEditCtrl() { // size
Profile = "ToolsGuiTextEditProfile";
internalName = "SequenceTextEditSSS";
HorizSizing = "left";
VertSizing = "bottom";
position = "260 1";
Extent = "34 18";
Command = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateSequenceSSS();";
hovertime = "1000";
text = "0";
};
new GuiSliderCtrl() { //size
canSaveDynamicFields = "0";
internalName = "SequenceSliderSSS";
Enabled = "1";
isContainer = "0";
Profile = "ToolsGuiSliderProfile";
HorizSizing = "width";
VertSizing = "bottom";
position = "120 4";
Extent = "137 16";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "MaterialEditorGui.updateSequenceSSS(true, true);";
AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateSequenceSSS(true, false);";
tooltipprofile = "ToolsGuiToolTipProfile";
ToolTip = "How many frames in the sequence.";
hovertime = "1000";
range = "0 100";
ticks = "9";
value = "0";
};
};
};
%this-->stack.add(%container);
}
function MaterialEditorGui::updateSequenceFPS(%this, %isSlider, %onMouseUp)
{
%layer = MaterialEditorGui.currentLayer;
%fps = MaterialEditorGuiWindow-->SequenceTextEditFPS.getText();
MaterialEditorGui.updateActiveMaterial("sequenceFramePerSec[" @ %layer @ "]", %fps, %isSlider, %onMouseUp);
}
function MaterialEditorGui::updateSequenceSSS(%this, %isSlider, %onMouseUp)
{
%layer = MaterialEditorGui.currentLayer;
%sss = 1 / MaterialEditorGuiWindow-->SequenceTextEditSSS.getText();
MaterialEditorGui.updateActiveMaterial("sequenceSegmentSize[" @ %layer @ "]", %sss, %isSlider, %onMouseUp);
}

View file

@ -0,0 +1,249 @@
//Generic methods
function GuiInspector::getWindow(%this)
{
%windowParent = %this;
if (!%windowParent.isMemberOfClass("GuiWindowCtrl"))
{
while(%windowParent.getParent() && !%windowParent.isMemberOfClass("GuiWindowCtrl"))
{
%windowParent = %windowParent.getParent();
}
}
return %windowParent;
}
function MaterialEditorPropInspector::getScrollbar(%this)
{
%scrollParent = %this;
if (!%scrollParent.isMemberOfClass("GuiScrollCtrl"))
{
while(%scrollParent.getParent() && !%scrollParent.isMemberOfClass("GuiScrollCtrl"))
{
%scrollParent = %scrollParent.getParent();
}
}
return %scrollParent;
}
function MaterialEditorPropInspector::onPreInspectObject(%this, %obj)
{
echo("MaterialEditorPropInspector::onPreInspectObject()");
%this.saveCollapseState();
%this.saveScrollState();
}
function MaterialEditorPropInspector::onPostInspectObject(%this, %obj)
{
echo("MaterialEditorPropInspector::onPostInspectObject()");
%this.loadCollapseState();
%this.loadScrollState();
}
function MaterialEditorPropInspector::saveScrollState(%this)
{
%this.scrollPos = %this.getScrollbar().getScrollPosition();
//echo(%this.getName() @ "::saveScrollState" SPC %this.scrollPos);
}
function MaterialEditorPropInspector::loadScrollState(%this)
{
if (%this.scrollPos $= "") return;
%this.getScrollbar().setScrollPosition(%this.scrollPos.x, %this.scrollPos.y);
//echo(%this.getName() @ "::loadScrollState" SPC %this.scrollPos);
}
function MaterialEditorPropInspector::saveCollapseState(%this)
{
%groupCount = %this.getInspectedGroupCount();
if (%groupCount == 0) return;
%this.collapseState = "";
for(%grp=0; %grp<%groupCount; %grp++)
{
%this.collapseState = %this.collapseState SPC %this.getInspectedGroup(%grp).isExpanded();
}
%this.collapseState = trim(%this.collapseState);
//echo(%this.getName() @ "::saveCollapsState" SPC %groupCount SPC %this.collapseState);
}
function MaterialEditorPropInspector::loadCollapseState(%this)
{
if (%this.collapseState $= "") return;
%groupCount = %this.getInspectedGroupCount();
//echo(%this.getName() @ "::loadCollapsState" SPC %groupCount SPC %this.collapseState);
for(%grp=0; %grp<%groupCount; %grp++)
{
if (getword(%this.collapseState,%grp))
%this.getInspectedGroup(%grp).instantExpand();
else
%this.getInspectedGroup(%grp).instantCollapse();
}
}
function GuiInspector::renew(%this)
{
%count = %this.getNumInspectObjects();
%inspecting = %this.getInspectObject(0);
for(%i=1; %i< %count;%i++)
%inspecting = %inspecting SPC %this.getInspectObject(%i);
%this.inspect(""); //clear
//readd
for(%i=0; %i<%count;%i++)
%this.addInspect(getword(%inspecting,%i));
}
/// Material Editor specific
function MaterialEditorPlugin::BuildEditorUI(%this)
{
if(isObject(NuMaterialEditorWindow))
NuMaterialEditorWindow.delete();
$MaterialEditor::currentLayer = 0;
%matWindow = UIBuilder::Window("Material Editor", MaterialEditorPropertiesWindow.Position.x - MaterialEditorPropertiesWindow.Extent.x SPC MaterialEditorPropertiesWindow.Position.y, MaterialEditorPropertiesWindow.Extent.x SPC MaterialEditorPropertiesWindow.Extent.y);
%matWindow.setName("NuMaterialEditorWindow");
%matWindow.closeCommand = "EWorldEditor.remove(NuMaterialEditorWindow);";
UIBuilder::Stack();
UIBuilder::SameLine();
%label = UIBuilder::Label("Layer");
%label.name = "numatedlabel";
%matLayerListCtrl = UIBuilder::Dropdown("0\t1\t2\t3", "$MaterialEditor::currentLayer", "onMaterialLayerSelected($ThisControl);");
%matLayerListCtrl.name = "NuMatEdLayerSelector";
UIBuilder::FitAllOnLine();
UIBuilder::End();
%inspector = UIBuilder::Inspector("NuMaterialEdPropInspector");
UIBuilder::End();
UIBuilder::End();
MaterialEditorGui.currentMaterial = materialEd_previewMaterial;//DetailBlue;
NuMaterialEdPropInspector.refreshMaterial();
%this.editorUI = %matWindow;
EWorldEditor.add(%matWindow);
}
function MaterialEditorPlugin::CloseEditorUI(%this)
{
EWorldEditor.remove(NuMaterialEditorWindow);
}
function onMaterialLayerSelected(%this)
{
$MaterialEditor::currentLayer = %this.getText();
NuMaterialEdPropInspector.refreshMaterial();
}
function MaterialEditorPropInspector::refreshMaterial(%this)
{
%this.onPreInspectObject(%this.getInspectObject());
%this.inspect(MaterialEditorGui.currentMaterial);
%this.setForcedArrayIndex(MaterialEditorGui.currentLayer);
//
//%this.getScrollbar().setExtent(%ext.x, %ext.y);
MaterialEditorGui.guiSync();
%this.onPostInspectObject(%this.getInspectObject());
}
function MaterialEditorPropInspector::onPostInspectorFieldModified(%this, %obj, %inspecting)
{
MaterialEditorGui.guiSync();
}
function NuMaterialEditorWindow::syncGUI(%this)
{
//do some presentation adjustments
%ormMapPresent = MaterialEditorGui.currentMaterial.ORMConfigMapAsset[$MaterialEditor::currentLayer] !$= "";
%hideORMSliders = %ormMapPresent;
if (!%hideORMSliders)
%hideORMSliders = MaterialEditorGui.currentMaterial.AOMapAsset[$MaterialEditor::currentLayer] !$= "";
if (!%hideORMSliders)
%hideORMSliders = MaterialEditorGui.currentMaterial.RoughMapAsset[$MaterialEditor::currentLayer] !$= "";
if (!%hideORMSliders)
%hideORMSliders = MaterialEditorGui.currentMaterial.MetalMapAsset[$MaterialEditor::currentLayer] !$= "";
%group = NuMaterialEdPropInspector.findExistentGroup("Light Influence Maps");
if(%ormMapPresent)
{
%group.hideField("isSRGb",false);
%group.hideField("AOMapAsset");
%group.hideField("aoChan");
%group.hideField("RoughMapAsset");
%group.hideField("roughness");
%group.hideField("roughnessChan");
%group.hideField("MetalMapAsset");
%group.hideField("metalness");
%group.hideField("metalChan");
%group.hideField("save");
}
else
{
%group.hideField("isSRGb");
if (%hideORMSliders)
{
%group.hideField("aoChan",false);
%group.hideField("roughness");
%group.hideField("roughnessChan",false);
%group.hideField("metalness");
%group.hideField("metalChan",false);
%group.hideField("save",false);
}
else
{
%group.hideField("aoChan");
%group.hideField("roughness",false);
%group.hideField("roughnessChan");
%group.hideField("metalness",false);
%group.hideField("metalChan");
%group.hideField("save");
}
%group.hideField("AOMapAsset",false);
%group.hideField("RoughMapAsset",false);
%group.hideField("MetalMapAsset",false);
}
%animflags = MaterialEditorGui.currentMaterial.animFlags[$MaterialEditor::currentLayer];
%group = NuMaterialEdPropInspector.findExistentGroup("Animation Properties");
%hideScroll = true;
if (strstr(%animflags, "Scroll")>=0)
%hideScroll = false;
%group.hideField("scrollDir",%hideScroll);
%group.hideField("scrollSpeed",%hideScroll);
%hideRotate = true;
if (strstr(%animflags, "Rotate")>=0)
%hideRotate = false;
%group.hideField("rotSpeed",%hideRotate);
%group.hideField("rotPivotOffset",%hideRotate);
%hideWave = true;
if (strstr(%animflags, "Wave")>=0)
%hideWave = false;
%group.hideField("waveType",%hideWave);
%group.hideField("waveFreq",%hideWave);
%group.hideField("waveAmp",%hideWave);
%showScale = false;
if (strstr(%animflags, "Scale")>=0)
%showScale = true;
%hideSequence = true;
if (strstr(%animflags, "Sequence")>=0)
%hideSequence = false;
%group.hideField("sequenceFramePerSec",%hideSequence);
%group.hideField("sequenceSegmentSize",%hideSequence);
cancel(NuMaterialEdPropInspector.refreshing);
NuMaterialEdPropInspector.refreshing = NuMaterialEdPropInspector.schedule(64,"renew");
}