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 init() { Settings EditorSettings = "EditorSettings"; this["currentLevel"] = ""; this["currentRolloutCtrl"] = ""; string levelInfoPath = "LevelInformation/levels"; for (string fieldName = EditorSettings.findFirstValue(levelInfoPath, true, true); fieldName != ""; fieldName = EditorSettings.findNextValue()) { int fieldSlashPos = 0; int levelSlashPos = 0; while (Util.strpos(fieldName, "/", fieldSlashPos) != -1) { levelSlashPos = fieldSlashPos; int temp = Util.strpos(fieldName, "/", fieldSlashPos); fieldSlashPos = temp + 1; } string levelName = Util.getSubStr(fieldName, levelSlashPos, ((fieldSlashPos - levelSlashPos) - 1)); GuiStackControl content = this.FOT("content"); bool alreadyExist = false; for (uint i = 0; i < content.getCount(); i++) { alreadyExist = false; if (((SimObject)content.getObject(i))["caption"] == levelName) { alreadyExist = true; break; } } if (this["currentLevel"] != levelName && !alreadyExist) { //Hold current level and reset gui params this["currentLevel"] = levelName; //%this.currentLevel = "\""@%levelName@"\""; //Create and hold current rollout ctrl #region GuiRolloutCtrl () oc_Newobject20 ObjectCreator oc_Newobject20 = new ObjectCreator("GuiRolloutCtrl", ""); oc_Newobject20["Profile"] = "GuiRolloutProfile"; oc_Newobject20["HorizSizing"] = "width"; oc_Newobject20["VertSizing"] = "bottom"; oc_Newobject20["position"] = "10 10"; oc_Newobject20["extent"] = "208 95"; oc_Newobject20["Caption"] = levelName; oc_Newobject20["Margin"] = "0 0 0 -3"; oc_Newobject20["DragSizable"] = new ObjectCreator.StringNoQuote("false"); oc_Newobject20["container"] = new ObjectCreator.StringNoQuote("true"); #region GuiStackControl () oc_Newobject19 ObjectCreator oc_Newobject19 = new ObjectCreator("GuiStackControl", ""); oc_Newobject19["StackingType"] = "Vertical"; oc_Newobject19["HorizStacking"] = "Left to Right"; oc_Newobject19["VertStacking"] = "Top to Bottom"; oc_Newobject19["Padding"] = "0"; oc_Newobject19["isContainer"] = "1"; oc_Newobject19["Profile"] = "ToolsGuiDefaultProfile"; oc_Newobject19["HorizSizing"] = "width"; oc_Newobject19["VertSizing"] = "bottom"; oc_Newobject19["position"] = "0 0"; oc_Newobject19["Extent"] = "208 0"; oc_Newobject19["MinExtent"] = "8 2"; oc_Newobject19["canSave"] = "1"; oc_Newobject19["isDecoy"] = "0"; oc_Newobject19["Visible"] = "1"; oc_Newobject19["tooltipprofile"] = "ToolsGuiToolTipProfile"; oc_Newobject19["hovertime"] = "1000"; #region GuiContainer () oc_Newobject10 ObjectCreator oc_Newobject10 = new ObjectCreator("GuiContainer", ""); oc_Newobject10["HorizSizing"] = "right"; oc_Newobject10["VertSizing"] = "bottom"; oc_Newobject10["Position"] = "0 0"; oc_Newobject10["Extent"] = "208 2"; #endregion oc_Newobject19["#Newobject10"] = oc_Newobject10; #region GuiContainer () oc_Newobject13 ObjectCreator oc_Newobject13 = new ObjectCreator("GuiContainer", ""); oc_Newobject13["HorizSizing"] = "right"; oc_Newobject13["VertSizing"] = "bottom"; oc_Newobject13["Position"] = "0 0"; oc_Newobject13["Extent"] = "208 22"; oc_Newobject13["Docking"] = "none"; #region GuiTextCtrl () oc_Newobject11 ObjectCreator oc_Newobject11 = new ObjectCreator("GuiTextCtrl", ""); oc_Newobject11["text"] = "Camera Speed Min:"; oc_Newobject11["maxLength"] = "1024"; oc_Newobject11["margin"] = "0 0 0 0"; oc_Newobject11["padding"] = "0 0 0 0"; oc_Newobject11["anchorTop"] = "1"; oc_Newobject11["anchorBottom"] = "0"; oc_Newobject11["anchorLeft"] = "1"; oc_Newobject11["anchorRight"] = "0"; oc_Newobject11["isContainer"] = "0"; oc_Newobject11["profile"] = "ToolsGuiTextRightProfile"; oc_Newobject11["horizSizing"] = "right"; oc_Newobject11["vertSizing"] = "bottom"; oc_Newobject11["position"] = "5 3"; oc_Newobject11["extent"] = "96 16"; oc_Newobject11["minExtent"] = "8 2"; oc_Newobject11["visible"] = "1"; oc_Newobject11["active"] = "1"; oc_Newobject11["tooltipProfile"] = "ToolsGuiToolTipProfile"; oc_Newobject11["hovertime"] = "1000"; oc_Newobject11["canSave"] = "1"; oc_Newobject11["canSaveDynamicFields"] = "0"; #endregion oc_Newobject13["#Newobject11"] = oc_Newobject11; #region GuiTextEditCtrl () oc_Newobject12 ObjectCreator oc_Newobject12 = new ObjectCreator("GuiTextEditCtrl", ""); oc_Newobject12["historySize"] = "0"; oc_Newobject12["password"] = "******"; oc_Newobject12["tabComplete"] = "0"; oc_Newobject12["sinkAllKeyEvents"] = "0"; oc_Newobject12["passwordMask"] = "*"; oc_Newobject12["maxLength"] = "1024"; oc_Newobject12["margin"] = "0 0 0 0"; oc_Newobject12["padding"] = "0 0 0 0"; oc_Newobject12["anchorTop"] = "1"; oc_Newobject12["anchorBottom"] = "0"; oc_Newobject12["anchorLeft"] = "1"; oc_Newobject12["anchorRight"] = "0"; oc_Newobject12["isContainer"] = "0"; oc_Newobject12["profile"] = "ToolsGuiNumericTextEditProfile"; oc_Newobject12["horizSizing"] = "width"; oc_Newobject12["vertSizing"] = "bottom"; oc_Newobject12["position"] = "106 2"; oc_Newobject12["extent"] = "95 18"; oc_Newobject12["minExtent"] = "8 2"; oc_Newobject12["visible"] = "1"; oc_Newobject12["active"] = "1"; oc_Newobject12["tooltipProfile"] = "ToolsGuiToolTipProfile"; oc_Newobject12["hovertime"] = "1000"; oc_Newobject12["canSave"] = "1"; oc_Newobject12["canSaveDynamicFields"] = "1"; oc_Newobject12["class"] = "ESettingsWindowTextEdit"; oc_Newobject12["editorSettingsRead"] = "EditorGui.readCameraSettings( \\\"" + levelName + "\\\" );"; oc_Newobject12["editorSettingsValue"] = "LevelInformation/levels/" + levelName + "/cameraSpeedMin"; oc_Newobject12["editorSettingsWrite"] = "EditorGui.writeCameraSettings( \\\"" + levelName + "\\\" );"; #endregion oc_Newobject13["#Newobject12"] = oc_Newobject12; #endregion oc_Newobject19["#Newobject13"] = oc_Newobject13; #region GuiContainer () oc_Newobject16 ObjectCreator oc_Newobject16 = new ObjectCreator("GuiContainer", ""); oc_Newobject16["HorizSizing"] = "right"; oc_Newobject16["VertSizing"] = "bottom"; oc_Newobject16["Position"] = "0 0"; oc_Newobject16["Extent"] = "208 22"; oc_Newobject16["Docking"] = "none"; #region GuiTextCtrl () oc_Newobject14 ObjectCreator oc_Newobject14 = new ObjectCreator("GuiTextCtrl", ""); oc_Newobject14["text"] = "Camera Speed Max:"; oc_Newobject14["maxLength"] = "1024"; oc_Newobject14["margin"] = "0 0 0 0"; oc_Newobject14["padding"] = "0 0 0 0"; oc_Newobject14["anchorTop"] = "1"; oc_Newobject14["anchorBottom"] = "0"; oc_Newobject14["anchorLeft"] = "1"; oc_Newobject14["anchorRight"] = "0"; oc_Newobject14["isContainer"] = "0"; oc_Newobject14["profile"] = "ToolsGuiTextRightProfile"; oc_Newobject14["horizSizing"] = "right"; oc_Newobject14["vertSizing"] = "bottom"; oc_Newobject14["position"] = "5 3"; oc_Newobject14["extent"] = "96 16"; oc_Newobject14["minExtent"] = "8 2"; oc_Newobject14["visible"] = "1"; oc_Newobject14["active"] = "1"; oc_Newobject14["tooltipProfile"] = "ToolsGuiToolTipProfile"; oc_Newobject14["hovertime"] = "1000"; oc_Newobject14["canSave"] = "1"; oc_Newobject14["canSaveDynamicFields"] = "0"; #endregion oc_Newobject16["#Newobject14"] = oc_Newobject14; #region GuiTextEditCtrl () oc_Newobject15 ObjectCreator oc_Newobject15 = new ObjectCreator("GuiTextEditCtrl", ""); oc_Newobject15["historySize"] = "0"; oc_Newobject15["password"] = "******"; oc_Newobject15["tabComplete"] = "0"; oc_Newobject15["sinkAllKeyEvents"] = "0"; oc_Newobject15["passwordMask"] = "*"; oc_Newobject15["maxLength"] = "1024"; oc_Newobject15["margin"] = "0 0 0 0"; oc_Newobject15["padding"] = "0 0 0 0"; oc_Newobject15["anchorTop"] = "1"; oc_Newobject15["anchorBottom"] = "0"; oc_Newobject15["anchorLeft"] = "1"; oc_Newobject15["anchorRight"] = "0"; oc_Newobject15["isContainer"] = "0"; oc_Newobject15["profile"] = "ToolsGuiNumericTextEditProfile"; oc_Newobject15["horizSizing"] = "width"; oc_Newobject15["vertSizing"] = "bottom"; oc_Newobject15["position"] = "106 2"; oc_Newobject15["extent"] = "95 18"; oc_Newobject15["minExtent"] = "8 2"; oc_Newobject15["visible"] = "1"; oc_Newobject15["active"] = "1"; oc_Newobject15["tooltipProfile"] = "ToolsGuiToolTipProfile"; oc_Newobject15["hovertime"] = "1000"; oc_Newobject15["canSave"] = "1"; oc_Newobject15["canSaveDynamicFields"] = "1"; oc_Newobject15["class"] = "ESettingsWindowTextEdit"; oc_Newobject15["editorSettingsRead"] = "EditorGui.readCameraSettings( \\\"" + levelName + "\\\" );"; oc_Newobject15["editorSettingsValue"] = "LevelInformation/levels/" + levelName + "/cameraSpeedMax"; oc_Newobject15["editorSettingsWrite"] = "EditorGui.writeCameraSettings( \\\"" + levelName + "\\\" );"; #endregion oc_Newobject16["#Newobject15"] = oc_Newobject15; #endregion oc_Newobject19["#Newobject16"] = oc_Newobject16; #region GuiContainer () oc_Newobject18 ObjectCreator oc_Newobject18 = new ObjectCreator("GuiContainer", ""); oc_Newobject18["HorizSizing"] = "right"; oc_Newobject18["VertSizing"] = "bottom"; oc_Newobject18["Position"] = "0 0"; oc_Newobject18["Extent"] = "208 24"; oc_Newobject18["Docking"] = "none"; #region GuiButtonCtrl () oc_Newobject17 ObjectCreator oc_Newobject17 = new ObjectCreator("GuiButtonCtrl", ""); oc_Newobject17["canSaveDynamicFields"] = "0"; oc_Newobject17["Enabled"] = "1"; oc_Newobject17["isContainer"] = "0"; oc_Newobject17["HorizSizing"] = "width"; oc_Newobject17["VertSizing"] = "bottom"; oc_Newobject17["Position"] = "5 2"; oc_Newobject17["Extent"] = "196 18"; oc_Newobject17["MinExtent"] = "8 8"; oc_Newobject17["canSave"] = "1"; oc_Newobject17["isDecoy"] = "0"; oc_Newobject17["Visible"] = "1"; oc_Newobject17["Command"] = "ECameraSettingsPage.deleteCameraSettingsGroup(\\\"" + levelName + "\\\", $ThisControl.getParent().getParent().getParent());"; oc_Newobject17["tooltipprofile"] = "ToolsGuiToolTipProfile"; oc_Newobject17["hovertime"] = "1000"; oc_Newobject17["text"] = "Delete Level Settings"; oc_Newobject17["groupNum"] = "-1"; oc_Newobject17["buttonType"] = "PushButton"; oc_Newobject17["useMouseEvents"] = "1"; #endregion oc_Newobject18["#Newobject17"] = oc_Newobject17; #endregion oc_Newobject19["#Newobject18"] = oc_Newobject18; #endregion oc_Newobject20["#Newobject19"] = oc_Newobject19; #endregion this["currentRolloutCtrl"] = oc_Newobject20.Create().AsString(); content.add(this["currentRolloutCtrl"]); } } }