public void addStaticIcon(string fullPath) { GuiIconButtonCtrl ctrl = this.createIcon(); string ext = Util.fileExt(fullPath); string file = Util.fileBase(fullPath); string fileLong = file + ext; string tip = fileLong + '\n' + "Size: " + Util.fileSize(fullPath) / 1000.0 + ' ' + "KB" + '\n' + "Date Created: " + Util.fileCreatedTime(fullPath) + '\n' + "Last Modified: " + Util.fileModifiedTime(fullPath); string createCmd = "EWCreatorWindow.createStatic( \\\"" + fullPath + "\\\" );"; ctrl.altCommand = "ColladaImportDlg.showDialog( \"" + fullPath + "\", \"" + createCmd + "\" );"; ctrl.iconBitmap = ((ext == ".dts") ? console.Call_Classname("EditorIconRegistry", "findIconByClassName", new string[] { "TSStatic" }) : "tools/gui/images/iconCollada"); ctrl.text = file; ctrl["class"] = "CreatorStaticIconBtn"; ctrl.tooltip = tip; ctrl.buttonType = "RadioButton"; ctrl.groupNum = -1; this.contentCtrl.addGuiControl(ctrl); }
public void setViewTypeAlphabetical() { GuiEditorGui.GuiEditor GuiEditor = "GuiEditor"; string controls = Util.enumerateConsoleClassesByCategory("Gui"); ArrayObject classes = new ObjectCreator("ArrayObject").Create(); // Collect relevant classes. foreach (string className in controls.Split('\t')) { if (GuiEditor.isFilteredClass(className) || !(Util.isMemberOfClass(className, "GuiControl"))) { continue; } classes.push_back(className, ""); } // Sort classes alphabetically. classes.sortk(true); // Add toolbox buttons. int numClasses = classes.count(); for (int i = 0; i < numClasses; i++) { string className = classes.getKey(i); #region GuiIconButtonCtrl () oc_Newobject2 ObjectCreator oc_Newobject2 = new ObjectCreator("GuiIconButtonCtrl", "", typeof(GuiEditorToolboxButton)); oc_Newobject2["profile"] = "ToolsGuiIconButtonSmallProfile"; oc_Newobject2["extent"] = "128 18"; oc_Newobject2["text"] = className; oc_Newobject2["iconBitmap"] = console.Call_Classname("EditorIconRegistry", "findIconByClassName", new string[] { className }); oc_Newobject2["buttonMargin"] = "2 2"; oc_Newobject2["iconLocation"] = "left"; oc_Newobject2["textLocation"] = "left"; oc_Newobject2["textMargin"] = "24"; oc_Newobject2["AutoSize"] = new ObjectCreator.StringNoQuote("true"); oc_Newobject2["command"] = "GuiEditor.createControl( " + className + " );"; oc_Newobject2["useMouseEvents"] = new ObjectCreator.StringNoQuote("true"); oc_Newobject2["tooltip"] = className + '\n' + "\n" + Util.getDescriptionOfClass(className); oc_Newobject2["tooltipProfile"] = "ToolsGuiToolTipProfile"; #endregion GuiIconButtonCtrl ctrl = oc_Newobject2.Create(); this.add(ctrl); } classes.delete(); this.currentViewType = "Alphabetical"; }
public void addShapeIcon(SimObject datablock) { GuiIconButtonCtrl ctrl = this.createIcon(); string name = datablock.getName(); string className = datablock.getClassName(); string cmd = className + "::create(" + name + ");"; string shapePath = (datablock["shapeFile"] != "") ? datablock["shapeFile"] : datablock["shapeName"]; string createCmd = "EWCreatorWindow.createObject( \\\"" + cmd + "\\\" );"; ctrl.altCommand = "ColladaImportDlg.showDialog( \"" + shapePath + "\", \"" + createCmd + "\" );"; ctrl.iconBitmap = console.Call_Classname("EditorIconRegistry", "findIconByClassName", new string[] { className }); ctrl.text = name; //ctrl["class"] = "CreatorShapeIconBtn"; ctrl.tooltip = name; ctrl.buttonType = "RadioButton"; ctrl.groupNum = -1; this.contentCtrl.addGuiControl(ctrl); }
public string createIcon() { ObjectCreator ctrlCreator = new ObjectCreator("GuiIconButtonCtrl"); ctrlCreator["profile"] = "GuiCreatorIconButtonProfile"; ctrlCreator["buttonType"] = "RadioButton"; ctrlCreator["groupNum"] = "-1"; GuiIconButtonCtrl ctrl = ctrlCreator.Create(); ctrl["profile"] = "GuiCreatorIconButtonProfile"; if (this.isList) { ctrl.iconLocation = "Left"; ctrl.textLocation = "Right"; ctrl.extent = "348 19".AsPoint2I(); ctrl.textMargin = 8; ctrl.buttonMargin = "2 2".AsPoint2I(); ctrl.autoSize = true; } else { ctrl.iconLocation = "Center"; ctrl.textLocation = "Bottom"; ctrl.extent = "40 40".AsPoint2I(); } return(ctrl); }
public void addFolderIcon(string text) { GuiIconButtonCtrl ctrl = this.createIcon(); ctrl.altCommand = "EWCreatorWindow.navigateDown(\"" + text + "\");"; ctrl.iconBitmap = "tools/gui/images/folder.png"; ctrl.text = text; ctrl.tooltip = text; ctrl["class"] = "CreatorFolderIconBtn"; ctrl.buttonType = "RadioButton"; ctrl.groupNum = -1; this.contentCtrl.addGuiControl(ctrl); }
public void addMissionObjectIcon(string className, string name, string buildfunc) { objectBuilderGui ObjectBuilderGui = "ObjectBuilderGui"; GuiIconButtonCtrl ctrl = this.createIcon(); // If we don't find a specific function for building an // object then fall back to the stock one string method = "build" + buildfunc; if (!ObjectBuilderGui.isMethod(method)) { method = "build" + className; } string cmd; if (!ObjectBuilderGui.isMethod(method)) { cmd = "return new " + className + "();"; } else { cmd = "ObjectBuilderGui." + method + "();"; } ctrl.altCommand = "ObjectBuilderGui.newObjectCallback = \"EWCreatorWindow.onFinishCreateObject\"; EWCreatorWindow.createObject( \"" + cmd + "\" );"; ctrl.iconBitmap = console.Call_Classname("EditorIconRegistry", "findIconByClassName", new string[] { className }); ctrl.text = name; ctrl["class"] = "CreatorMissionObjectIconBtn"; ctrl.tooltip = className; ctrl.buttonType = "RadioButton"; ctrl.groupNum = -1; this.contentCtrl.addGuiControl(ctrl); }
public void addPrefabIcon(string fullPath) { GuiIconButtonCtrl ctrl = this.createIcon(); string ext = Util.fileExt(fullPath); string file = Util.fileBase(fullPath); string fileLong = file + ext; string tip = fileLong + '\n' + "Size: " + Util.fileSize(fullPath) / 1000.0 + ' ' + "KB" + '\n' + "Date Created: " + Util.fileCreatedTime(fullPath) + '\n' + "Last Modified: " + Util.fileModifiedTime(fullPath); ctrl.altCommand = "EWCreatorWindow.createPrefab( \"" + fullPath + "\" );"; ctrl.iconBitmap = console.Call_Classname("EditorIconRegistry", "findIconByClassName", new string[] { "Prefab" }); ctrl.text = file; ctrl["class"] = "CreatorPrefabIconBtn"; ctrl.tooltip = tip; ctrl.buttonType = "RadioButton"; ctrl.groupNum = -1; this.contentCtrl.addGuiControl(ctrl); }
public void updateLayers(string matIndex) { TerrainEditor ETerrainEditor = "ETerrainEditor"; SimSet TerrainMaterialSet = "TerrainMaterialSet"; // Default to whatever was selected before. if (matIndex == "") { matIndex = ETerrainEditor.paintIndex.AsString(); } else { ETerrainEditor.paintIndex = matIndex.AsInt(); //TerrainPainterAddition } // The material string is a newline seperated string of // TerrainMaterial internal names which we can use to find // the actual material data in TerrainMaterialSet. string mats = ETerrainEditor.getMaterials(); GuiStackControl matList = this.findObjectByInternalName("theMaterialList", true); matList.deleteAllObjects(); string listWidth = matList.getExtent().x.AsString(); for (int i = 0; i < Util.getRecordCount(mats); i++) { string matInternalName = Util.getRecord(mats, i); TerrainMaterial mat = TerrainMaterialSet.findObjectByInternalName(matInternalName, true); // Is there no material info for this slot? if (!mat.isObject()) { continue; } //if( this.filter != "" ) //{ // if( Util.strstr( Util.strlwr(matInternalName), Util.strlwr(this.filter) ) == -1 ) // continue; //} ////TerrainPainterAddition //string terrainFolder = mat["terrainFolder"]; //if( terrainFolder == "" ) // terrainFolder = "Unused"; //string rolloutName = terrainFolder + "Rollout"; //GuiRolloutCtrl rollout = matList.FOT(rolloutName); //GuiStackControl stack = ""; //if( !rollout.isObject() ) //{ // ObjectCreator ocRollout = new ObjectCreator("GuiRolloutCtrl"); // ocRollout["caption"] = terrainFolder; // ocRollout["extent"] = listWidth + " " + "0"; // ocRollout["internalName"] = rolloutName; // rollout = ocRollout.Create(); // ObjectCreator ocStack = new ObjectCreator("GuiStackControl"); // ocStack["StackingType"] = "Vertical"; // ocStack["HorizStacking"] = "Left to Right"; // ocStack["VertStacking"] = "Top to Bottom"; // ocStack["Padding"] = "-2"; // ocStack["canSaveDynamicFields"] = "0"; // ocStack["Enabled"] = "1"; // ocStack["isContainer"] = "1"; // ocStack["Profile"] = "ToolsGuiDefaultProfile"; // ocStack["HorizSizing"] = "width"; // ocStack["VertSizing"] = "bottom"; // ocStack["Position"] = "1 3"; // ocStack["Extent"] = listWidth + "" + "16"; // ocStack["MinExtent"] = "16 16"; // ocStack["canSave"] = "1"; // ocStack["isDecoy"] = "0"; // ocStack["Visible"] = "1"; // ocStack["internalName"] = "stackControl"; // ocStack["tooltipprofile"] = "ToolsGuiToolTipProfile"; // ocStack["hovertime"] = "1000"; // stack = ocStack.Create(); // rollout.add(stack); // matList.add(rollout); //} //else //{ // stack = rollout.FOT("stackControl"); //} //int index = matList.getCount(); string command = "ETerrainEditor.setPaintMaterial( " + i + ", " + mat + " );TerrainPainter.removeOtherSelections($ThisControl);TerrainPainter.lastActiveButton = $ThisControl;"; string altCommand = "TerrainMaterialDlg.show( " + i + ", " + mat + ", EPainter_TerrainMaterialUpdateCallback );"; ObjectCreator oc = new ObjectCreator("GuiIconButtonCtrl", "", typeof(EPainterIconBtn)); //oc["class"] = "EPainterIconBtn"; oc["internalName"] = "EPainterMaterialButton" + i; oc["profile"] = "GuiCreatorIconButtonProfile"; oc["iconLocation"] = "Left"; oc["textLocation"] = "Right"; oc["extent"] = listWidth + " 46"; oc["textMargin"] = 5; oc["buttonMargin"] = "4 4"; oc["buttonType"] = "RadioButton"; oc["sizeIconToButton"] = true; oc["makeIconSquare"] = true; oc["tooltipprofile"] = "ToolsGuiToolTipProfile"; oc["command"] = command; oc["altCommand"] = altCommand; oc["useMouseEvents"] = true; ObjectCreator oc1 = new ObjectCreator("GuiBitmapButtonCtrl"); oc1["bitmap"] = "tools/gui/images/delete"; oc1["buttonType"] = "PushButton"; oc1["HorizSizing"] = "left"; oc1["VertSizing"] = "bottom"; oc1["position"] = (listWidth.AsInt() - 20) + " 26"; oc1["Extent"] = "17 17"; //Copyright Winterleaf Entertainment L.L.C. 2013 oc1["command"] = "TerrainPainter.showMaterialDeleteDlg( " + matInternalName + " );"; //Copyright Winterleaf Entertainment L.L.C. 2013 oc["#1"] = oc1; EPainterIconBtn ctrl = oc.Create(); ctrl.setText(matInternalName); ctrl.setBitmap(mat.diffuseMap); string tooltip = matInternalName; if (i < 9) { tooltip = tooltip + " (" + (i + 1) + ")"; } else if (i == 9) { tooltip = tooltip + " (0)"; } ctrl.tooltip = tooltip; //stack.add(ctrl); matList.add(ctrl); } //int matCount = ETerrainEditor.getMaterialCount(); int matCount = matList.getCount(); // Add one more layer as the 'add new' layer. ObjectCreator ocb = new ObjectCreator("GuiIconButtonCtrl"); ocb["profile"] = "GuiCreatorIconButtonProfile"; ocb["iconBitmap"] = "tools/worldEditor/images/terrainpainter/new_layer_icon"; ocb["iconLocation"] = "Left"; ocb["textLocation"] = "Right"; ocb["extent"] = listWidth + " 46"; ocb["textMargin"] = 5; ocb["buttonMargin"] = "4 4"; ocb["buttonType"] = "PushButton"; ocb["sizeIconToButton"] = true; ocb["makeIconSquare"] = true; ocb["tooltipprofile"] = "ToolsGuiToolTipProfile"; ocb["text"] = "New Layer"; ocb["tooltip"] = "New Layer"; ocb["command"] = "TerrainMaterialDlg.show( " + matCount + ", 0, EPainter_TerrainMaterialAddCallback );"; GuiIconButtonCtrl ictrl = ocb.Create(); matList.add(ictrl); // Make sure our selection is valid and that we're // not selecting the 'New Layer' button. if (matIndex.AsInt() < 0) { return; } if (matIndex.AsInt() >= matCount) { matIndex = "0"; } // To make things simple... click the paint material button to // active it and initialize other state. ictrl = matList.getObject(matIndex.AsUint()); //ictrl = matList.findObjectByInternalName("EPainterMaterialButton" + matIndex, true); ictrl.call("performClick"); }
public void setViewTypeCategorized() { GuiEditorGui.GuiEditor GuiEditor = "GuiEditor"; // Create rollouts for each class category we have and // record the classes in each category in a temporary array // on the rollout so we can later sort the class names before // creating the actual controls in the toolbox. string controls = Util.enumerateConsoleClassesByCategory("Gui"); foreach (string className in controls.Split('\t')) { if (GuiEditor.isFilteredClass(className) || !Util.isMemberOfClass(className, "GuiControl")) { continue; } // Get the class's next category under Gui. string category = Util.getWord(Util.getCategoryOfClass(className), 1); if (category == "") { continue; } // Find or create the rollout for the category. GuiRolloutCtrl rollout = this.getOrCreateRolloutForCategory(category); // Insert the item. if (!rollout["classes"].AsBool()) { rollout["classes"] = new ObjectCreator("ArrayObject").Create().AsString(); } ((ArrayObject)rollout["classes"]).push_back(className, ""); } // Go through the rollouts, sort the class names, and // create the toolbox controls. for (uint i = 0; i < this.getCount(); i++) { GuiRolloutCtrl rollout = this.getObject(i); if (!rollout.isMemberOfClass("GuiRolloutCtrl")) { continue; } // Get the array with the class names and sort it. // Sort in descending order to counter reversal of order // when we later add the controls to the stack. ArrayObject classes = rollout["classes"]; classes.sortk(true); // Add a control for each of the classes to the // rollout's stack control. GuiDynamicCtrlArrayControl stack = rollout.FOT("array"); int numClasses = classes.count(); for (int n = 0; n < numClasses; n++) { string className = classes.getKey(n); #region GuiIconButtonCtrl () oc_Newobject3 ObjectCreator oc_Newobject3 = new ObjectCreator("GuiIconButtonCtrl", "", typeof(GuiEditorToolboxButton)); oc_Newobject3["profile"] = "ToolsGuiIconButtonSmallProfile"; oc_Newobject3["extent"] = "128 18"; oc_Newobject3["text"] = className; oc_Newobject3["iconBitmap"] = console.Call_Classname("EditorIconRegistry", "findIconByClassName", new string[] { className }); oc_Newobject3["buttonMargin"] = "2 2"; oc_Newobject3["iconLocation"] = "left"; oc_Newobject3["textLocation"] = "left"; oc_Newobject3["textMargin"] = "24"; oc_Newobject3["AutoSize"] = new ObjectCreator.StringNoQuote("true"); oc_Newobject3["command"] = "GuiEditor.createControl( " + className + " );"; oc_Newobject3["useMouseEvents"] = new ObjectCreator.StringNoQuote("true"); //TODO doesn't work for every control. //oc_Newobject3["tooltip"] = className + '\n' + "\n" + Util.getDescriptionOfClass( className ); oc_Newobject3["tooltipProfile"] = "ToolsGuiToolTipProfile"; #endregion GuiIconButtonCtrl ctrl = oc_Newobject3.Create(); stack.add(ctrl); } // Delete the temporary array. rollout["classes"] = ""; classes.delete(); } this.currentViewType = "Categorized"; }
public void open(string filename) { EditorGui EditorGui = "EditorGui"; ShapeEdPropWindow ShapeEdPropWindow = "ShapeEdPropWindow"; ShapeEdSelectWindow ShapeEdSelectWindow = "ShapeEdSelectWindow"; ShapeEdAdvancedWindow ShapeEdAdvancedWindow = "ShapeEdAdvancedWindow"; ShapeEdAnimWindow ShapeEdAnimWindow = "ShapeEdAnimWindow"; ShapeEditorToolbar ShapeEditorToolbar = "ShapeEditorToolbar"; ShapeEditor.ShapeEdShapeView ShapeEdShapeView = "ShapeEdShapeView"; ShapeEditor.ShapeEdNodes ShapeEdNodes = "ShapeEdNodes"; Settings EditorSettings = "EditorSettings"; EWorldEditor EWorldEditor = "EWorldEditor"; GizmoProfile GlobalGizmoProfile = "GlobalGizmoProfile"; ShapeEditor.ShapeEdShapeTreeView ShapeEdShapeTreeView = "ShapeEdShapeTreeView"; ShapeEditor.ShapeEdPreviewGui ShapeEdPreviewGui = "ShapeEdPreviewGui"; ShapeEditorActions.ShapeEdUndoManager ShapeEdUndoManager = "ShapeEdUndoManager"; SimGroup MissionGroup = "MissionGroup"; GuiDynamicCtrlArrayControl ToolsPaletteArray = "ToolsPaletteArray"; editor Editor = "Editor"; ShapeEditor.ShapeEdMaterials ShapeEdMaterials = "ShapeEdMaterials"; ShapeEditor ShapeEditor = "ShapeEditor"; GuiBitmapButtonCtrl wireframeMode = ShapeEditorToolbar.FOT("wireframeMode"); GuiBitmapButtonCtrl showAdvanced = ShapeEditorToolbar.FOT("showAdvanced"); GuiIconButtonCtrl worldTransform = ShapeEdNodes.FOT("worldTransform"); GuiIconButtonCtrl objectTransform = ShapeEdNodes.FOT("objectTransform"); GuiCheckBoxCtrl highlightMaterial = ShapeEdMaterials.FOT("highlightMaterial"); GuiCanvas Canvas = "Canvas"; if (!this["isActivated"].AsBool()) { // Activate the Shape Editor EditorGui.setEditor(this, false); // Get editor settings (note the sun angle is not configured in the settings // dialog, so apply the settings here instead of in readSettings) this.readSettings(); ShapeEdShapeView["sunAngleX"] = EditorSettings.value("ShapeEditor/SunAngleX"); ShapeEdShapeView["sunAngleZ"] = EditorSettings.value("ShapeEditor/SunAngleZ"); EWorldEditor["forceLoadDAE"] = EditorSettings.value("forceLoadDAE"); bGlobal["$wasInWireFrameMode"] = bGlobal["$gfx::wireframe"]; wireframeMode.setStateOn(bGlobal["$gfx::wireframe"]); if (GlobalGizmoProfile.getFieldValue("alignment", -1) == "Object") { objectTransform.setStateOn(true); } else { worldTransform.setStateOn(true); } // Initialise and show the shape editor ShapeEdShapeTreeView.open(MissionGroup); ShapeEdShapeTreeView.buildVisibleTree(true); ShapeEdPreviewGui.setVisible(true); ShapeEdSelectWindow.setVisible(true); ShapeEdPropWindow.setVisible(true); ShapeEdAnimWindow.setVisible(true); ShapeEdAdvancedWindow.setVisible(showAdvanced.getValue().AsBool()); ShapeEditorToolbar.setVisible(true); EditorGui.bringToFront(ShapeEdPreviewGui); ((GuiBitmapButtonCtrl)ToolsPaletteArray.FOT("WorldEditorMove")).performClick(); this.map.push(); // Switch to the ShapeEditor UndoManager this["oldUndoMgr"] = Editor.getUndoManager(); Editor.setUndoManager(ShapeEdUndoManager); ShapeEdShapeView.setDisplayType(EditorGui["currentDisplayType"].AsInt()); this.initStatusBar(); // Customise menu bar this["oldCamFitCmd"] = this.replaceMenuCmd("Camera", "8", "ShapeEdShapeView.fitToShape();"); this["oldCamFitOrbitCmd"] = this.replaceMenuCmd("Camera", "9", "ShapeEdShapeView.fitToShape();"); base.onActivated(); } // Select the new shape if (ShapeEditor.shape.isObject() && (ShapeEditor.shape["baseShape"] == filename)) { // Shape is already selected => re-highlight the selected material if necessary ShapeEdMaterials.updateSelectedMaterial(highlightMaterial.getValue().AsBool()); } else if (filename != "") { ShapeEditor.selectShape(filename, ShapeEditor.isDirty()); // 'fitToShape' only works after the GUI has been rendered, so force a repaint first Canvas.repaint(0); ShapeEdShapeView.fitToShape(); } }