|
|
@@ -4,12 +4,63 @@ import UIEvents = require("../UIEvents");
|
|
|
|
|
|
import TextureSelector = require("./TextureSelector");
|
|
|
|
|
|
+var techniqueSource = new Atomic.UIMenuItemSource();
|
|
|
+
|
|
|
+var solidSource = new Atomic.UIMenuItemSource();
|
|
|
+solidSource.addItem(new Atomic.UIMenuItem("Diffuse", "Diffuse"));
|
|
|
+solidSource.addItem(new Atomic.UIMenuItem("Diffuse Emissive", "Diffuse Emissive"));
|
|
|
+solidSource.addItem(new Atomic.UIMenuItem("Diffuse Normal", "Diffuse Normal"));
|
|
|
+
|
|
|
+var tranSource = new Atomic.UIMenuItemSource();
|
|
|
+tranSource.addItem(new Atomic.UIMenuItem("Alpha", "Alpha"));
|
|
|
+tranSource.addItem(new Atomic.UIMenuItem("Alpha Mask", "Alpha Mask"));
|
|
|
+tranSource.addItem(new Atomic.UIMenuItem("Additive", "Additive"));
|
|
|
+tranSource.addItem(new Atomic.UIMenuItem("Additive Alpha", "Additive Alpha"));
|
|
|
+tranSource.addItem(new Atomic.UIMenuItem("Emissive Alpha", "Emissive Alpha"));
|
|
|
+tranSource.addItem(new Atomic.UIMenuItem("Alpha AO", "Alpha AO"));
|
|
|
+tranSource.addItem(new Atomic.UIMenuItem("Alpha Mask AO", "Alpha Mask AO"));
|
|
|
+
|
|
|
+var lightmapSource = new Atomic.UIMenuItemSource();
|
|
|
+lightmapSource.addItem(new Atomic.UIMenuItem("Lightmap", "Lightmap"));
|
|
|
+lightmapSource.addItem(new Atomic.UIMenuItem("Lightmap Alpha", "Lightmap Alpha"));
|
|
|
+
|
|
|
+var _ = new Atomic.UIMenuItem("Solid");
|
|
|
+_.subSource = solidSource;
|
|
|
+techniqueSource.addItem(_);
|
|
|
+
|
|
|
+_ = new Atomic.UIMenuItem("Transparency");
|
|
|
+_.subSource = tranSource;
|
|
|
+techniqueSource.addItem(_);
|
|
|
+
|
|
|
+_ = new Atomic.UIMenuItem("Lightmap");
|
|
|
+_.subSource = lightmapSource;
|
|
|
+techniqueSource.addItem(_);
|
|
|
+
|
|
|
+var techniqueLookup = {
|
|
|
+ "Techniques/Diff.xml": "Diffuse",
|
|
|
+ "Techniques/DiffEmissive.xml": "Diffuse Emissive",
|
|
|
+ "Techniques/DiffNormal.xml": "Diffuse Normal",
|
|
|
+}
|
|
|
+
|
|
|
+var techniqueReverseLookup = {};
|
|
|
+
|
|
|
+for (var key in techniqueLookup) {
|
|
|
+
|
|
|
+ techniqueReverseLookup[techniqueLookup[key]] = key;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
class MaterialInspector extends ScriptWidget {
|
|
|
|
|
|
constructor() {
|
|
|
|
|
|
super();
|
|
|
|
|
|
+ this.fd.id = "Vera";
|
|
|
+ this.fd.size = 11;
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
createShaderParametersSection(): Atomic.UISection {
|
|
|
@@ -17,6 +68,7 @@ class MaterialInspector extends ScriptWidget {
|
|
|
var section = new Atomic.UISection();
|
|
|
section.text = "Shader Paramaters";
|
|
|
section.value = 1;
|
|
|
+ section.fontDescription = this.fd;
|
|
|
|
|
|
return section;
|
|
|
|
|
|
@@ -37,23 +89,69 @@ class MaterialInspector extends ScriptWidget {
|
|
|
|
|
|
var thumb = <Atomic.Texture2D> cache.getTempResource("Texture2D", thumbnail);
|
|
|
|
|
|
-
|
|
|
if (thumb)
|
|
|
- return thumb;
|
|
|
+ return thumb;
|
|
|
|
|
|
return texture;
|
|
|
|
|
|
}
|
|
|
|
|
|
+ onTechniqueSet(techniqueName:string) {
|
|
|
+
|
|
|
+ this.techniqueButton.text = techniqueName;
|
|
|
+
|
|
|
+ var cache = Atomic.getResourceCache();
|
|
|
+ var technique = <Atomic.Technique> cache.getResource("Technique", techniqueReverseLookup[techniqueName]);
|
|
|
+ this.material.setTechnique(0, technique);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ createTechniquePopup(): Atomic.UIWidget {
|
|
|
+
|
|
|
+ var button = this.techniqueButton = new Atomic.UIButton();
|
|
|
+
|
|
|
+ var technique = this.material.getTechnique(0);
|
|
|
+
|
|
|
+ button.text = techniqueLookup[technique.name];
|
|
|
+
|
|
|
+ button.fontDescription = this.fd;
|
|
|
+
|
|
|
+ var lp = new Atomic.UILayoutParams();
|
|
|
+ lp.width = 140;
|
|
|
+ button.layoutParams = lp;
|
|
|
+
|
|
|
+ button.onClick = function() {
|
|
|
+
|
|
|
+ var menu = new Atomic.UIMenuWindow(button, "technique popup");
|
|
|
+
|
|
|
+ menu.fontDescription = this.fd;
|
|
|
+ menu.show(techniqueSource);
|
|
|
+
|
|
|
+ button.subscribeToEvent(button, "WidgetEvent", function(ev: Atomic.UIWidgetEvent) {
|
|
|
+
|
|
|
+ if (ev.type != Atomic.UI_EVENT_TYPE_CLICK)
|
|
|
+ return;
|
|
|
+
|
|
|
+ if (ev.target && ev.target.id == "technique popup") {
|
|
|
+
|
|
|
+ this.onTechniqueSet(ev.refid);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }.bind(this));
|
|
|
+
|
|
|
+ }.bind(this);
|
|
|
+
|
|
|
+ return button;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
createTextureSection(): Atomic.UISection {
|
|
|
|
|
|
var section = new Atomic.UISection();
|
|
|
section.text = "Textures";
|
|
|
section.value = 1;
|
|
|
-
|
|
|
- var fd = new Atomic.UIFontDescription();
|
|
|
- fd.id = "Vera";
|
|
|
- fd.size = 11;
|
|
|
+ section.fontDescription = this.fd;
|
|
|
|
|
|
var attrsVerticalLayout = new Atomic.UILayout(Atomic.UI_AXIS_Y);
|
|
|
attrsVerticalLayout.spacing = 3;
|
|
|
@@ -63,8 +161,8 @@ class MaterialInspector extends ScriptWidget {
|
|
|
section.contentRoot.addChild(attrsVerticalLayout);
|
|
|
|
|
|
// TODO: Filter on technique
|
|
|
- var textureUnits = [Atomic.TU_DIFFUSE, Atomic.TU_NORMAL, Atomic.TU_EMISSIVE, Atomic.TU_SPECULAR, Atomic.TU_ENVIRONMENT,
|
|
|
- Atomic.TU_CUSTOM1, Atomic.TU_CUSTOM2];
|
|
|
+ var textureUnits = [Atomic.TU_DIFFUSE, Atomic.TU_NORMAL]// ,Atomic.TU_EMISSIVE, Atomic.TU_SPECULAR, Atomic.TU_ENVIRONMENT,
|
|
|
+ //Atomic.TU_CUSTOM1, Atomic.TU_CUSTOM2];
|
|
|
|
|
|
for (var i in textureUnits) {
|
|
|
|
|
|
@@ -80,7 +178,7 @@ class MaterialInspector extends ScriptWidget {
|
|
|
name.skinBg = "InspectorTextAttrName";
|
|
|
|
|
|
name.text = tunitName;
|
|
|
- name.fontDescription = fd;
|
|
|
+ name.fontDescription = this.fd;
|
|
|
|
|
|
attrLayout.addChild(name);
|
|
|
|
|
|
@@ -88,8 +186,8 @@ class MaterialInspector extends ScriptWidget {
|
|
|
textureWidget.texture = this.getTextureThumbnail(this.material.getTexture(tunit));
|
|
|
|
|
|
var tlp = new Atomic.UILayoutParams();
|
|
|
- tlp.width = 32;
|
|
|
- tlp.height = 32;
|
|
|
+ tlp.width = 64;
|
|
|
+ tlp.height = 64;
|
|
|
textureWidget.layoutParams = tlp;
|
|
|
|
|
|
attrLayout.addChild(textureWidget);
|
|
|
@@ -101,8 +199,8 @@ class MaterialInspector extends ScriptWidget {
|
|
|
var callback = function(ev: Atomic.UIWidgetEvent) {
|
|
|
|
|
|
if (ev.type == Atomic.UI_EVENT_TYPE_CLICK) {
|
|
|
- var tselect = new TextureSelector(ev.target.view);
|
|
|
- }
|
|
|
+ var tselect = new TextureSelector(ev.target.view);
|
|
|
+ }
|
|
|
|
|
|
}.bind(editInfo);
|
|
|
|
|
|
@@ -118,10 +216,6 @@ class MaterialInspector extends ScriptWidget {
|
|
|
|
|
|
this.material = material;
|
|
|
|
|
|
- var fd = new Atomic.UIFontDescription();
|
|
|
- fd.id = "Vera";
|
|
|
- fd.size = 11;
|
|
|
-
|
|
|
var mlp = new Atomic.UILayoutParams();
|
|
|
mlp.width = 304;
|
|
|
|
|
|
@@ -138,6 +232,7 @@ class MaterialInspector extends ScriptWidget {
|
|
|
var materialSection = new Atomic.UISection();
|
|
|
materialSection.text = "Material";
|
|
|
materialSection.value = 1;
|
|
|
+ materialSection.fontDescription = this.fd;
|
|
|
materialLayout.addChild(materialSection);
|
|
|
|
|
|
var attrsVerticalLayout = new Atomic.UILayout(Atomic.UI_AXIS_Y);
|
|
|
@@ -145,34 +240,52 @@ class MaterialInspector extends ScriptWidget {
|
|
|
attrsVerticalLayout.layoutPosition = Atomic.UI_LAYOUT_POSITION_LEFT_TOP;
|
|
|
attrsVerticalLayout.layoutSize = Atomic.UI_LAYOUT_SIZE_AVAILABLE;
|
|
|
|
|
|
- var attrLayout = new Atomic.UILayout();
|
|
|
- attrLayout.layoutDistribution = Atomic.UI_LAYOUT_DISTRIBUTION_GRAVITY;
|
|
|
+ // NAME
|
|
|
+ var nameLayout = new Atomic.UILayout();
|
|
|
+ nameLayout.layoutDistribution = Atomic.UI_LAYOUT_DISTRIBUTION_GRAVITY;
|
|
|
|
|
|
var name = new Atomic.UITextField();
|
|
|
name.textAlign = Atomic.UI_TEXT_ALIGN_LEFT;
|
|
|
name.skinBg = "InspectorTextAttrName";
|
|
|
|
|
|
name.text = "Name";
|
|
|
- name.fontDescription = fd;
|
|
|
-
|
|
|
- attrLayout.addChild(name);
|
|
|
+ name.fontDescription = this.fd;
|
|
|
|
|
|
+ nameLayout.addChild(name);
|
|
|
|
|
|
var field = new Atomic.UIEditField();
|
|
|
field.textAlign = Atomic.UI_TEXT_ALIGN_LEFT;
|
|
|
field.skinBg = "TBAttrEditorField";;
|
|
|
- field.fontDescription = fd;
|
|
|
+ field.fontDescription = this.fd;
|
|
|
var lp = new Atomic.UILayoutParams();
|
|
|
lp.width = 140;
|
|
|
field.layoutParams = lp;
|
|
|
|
|
|
field.text = material.getTexture(Atomic.TU_DIFFUSE).name;
|
|
|
|
|
|
- attrLayout.addChild(field);
|
|
|
+ nameLayout.addChild(field);
|
|
|
+
|
|
|
+ attrsVerticalLayout.addChild(nameLayout);
|
|
|
+
|
|
|
+ // TECHNIQUE LAYOUT
|
|
|
+
|
|
|
+ var techniqueLayout = new Atomic.UILayout();
|
|
|
+ techniqueLayout.layoutDistribution = Atomic.UI_LAYOUT_DISTRIBUTION_GRAVITY;
|
|
|
|
|
|
+ name = new Atomic.UITextField();
|
|
|
+ name.textAlign = Atomic.UI_TEXT_ALIGN_LEFT;
|
|
|
+ name.skinBg = "InspectorTextAttrName";
|
|
|
+
|
|
|
+ name.text = "Technique";
|
|
|
+ name.fontDescription = this.fd;
|
|
|
|
|
|
- attrsVerticalLayout.addChild(attrLayout);
|
|
|
+ techniqueLayout.addChild(name);
|
|
|
|
|
|
+ var techniquePopup = this.createTechniquePopup();
|
|
|
+
|
|
|
+ techniqueLayout.addChild(techniquePopup);
|
|
|
+
|
|
|
+ attrsVerticalLayout.addChild(techniqueLayout);
|
|
|
|
|
|
materialSection.contentRoot.addChild(attrsVerticalLayout);
|
|
|
|
|
|
@@ -200,9 +313,10 @@ class MaterialInspector extends ScriptWidget {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ techniqueButton:Atomic.UIButton;
|
|
|
material: Atomic.Material;
|
|
|
-
|
|
|
nameTextField: Atomic.UITextField;
|
|
|
+ fd: Atomic.UIFontDescription = new Atomic.UIFontDescription();
|
|
|
|
|
|
|
|
|
}
|