Пример #1
0
        public static void EPainter_TerrainMaterialAddCallback(TerrainMaterial mat, int matIndex)
        {
            if (!mat.isObject())
            {
                return;
            }

            ((TerrainEditor)"ETerrainEditor").addMaterial(mat.getInternalName());
            ((TerrainPainter)"TerrainPainter").setup(matIndex);
        }
Пример #2
0
        public void setTerrainFolder(string terrainFolder)
        {
            TerrainMaterial mat        = this["activeMat"];
            GuiTreeViewCtrl matLibTree = FOT("matLibTree");

            if (mat.isObject())
            {
                mat["terrainFolder"] = terrainFolder;
                matLibTree.buildVisibleTree(false);
            }
        }
Пример #3
0
        public void setActiveMaterial(TerrainMaterial mat)
        {
            if (mat.isObject())
            {
                GuiTextEditCtrl matNameCtrl        = this.findObjectByInternalName("matNameCtrl", true);
                GuiBitmapCtrl   baseTexCtrl        = this.findObjectByInternalName("baseTexCtrl", true);
                GuiBitmapCtrl   detailTexCtrl      = this.findObjectByInternalName("detailTexCtrl", true);
                GuiBitmapCtrl   macroTexCtrl       = this.findObjectByInternalName("macroTexCtrl", true);
                GuiBitmapCtrl   normTexCtrl        = this.findObjectByInternalName("normTexCtrl", true);
                GuiTextEditCtrl detSizeCtrl        = this.findObjectByInternalName("detSizeCtrl", true);
                GuiTextEditCtrl baseSizeCtrl       = this.findObjectByInternalName("baseSizeCtrl", true);
                GuiTextEditCtrl detStrengthCtrl    = this.findObjectByInternalName("detStrengthCtrl", true);
                GuiTextEditCtrl detDistanceCtrl    = this.findObjectByInternalName("detDistanceCtrl", true);
                GuiCheckBoxCtrl sideProjectionCtrl = this.findObjectByInternalName("sideProjectionCtrl", true);
                GuiTextEditCtrl parallaxScaleCtrl  = this.findObjectByInternalName("parallaxScaleCtrl", true);

                GuiTextEditCtrl macroSizeCtrl     = this.findObjectByInternalName("macroSizeCtrl", true);
                GuiTextEditCtrl macroStrengthCtrl = this.findObjectByInternalName("macroStrengthCtrl", true);
                GuiTextEditCtrl macroDistanceCtrl = this.findObjectByInternalName("macroDistanceCtrl", true);

                //TerrainPainterAddition
                GuiTextEditCtrl terrainFolderCtrl = FOT("terrainFolderCtrl");

                this["activeMat"] = mat;

                matNameCtrl.setText(mat.internalName);

                baseTexCtrl.setBitmapX(mat.diffuseMap == "" ? "tools/materialeditor/gui/unknownImage" : mat.diffuseMap);
                detailTexCtrl.setBitmapX(mat.detailMap == "" ? "tools/materialeditor/gui/unknownImage" : mat.detailMap);
                macroTexCtrl.setBitmapX(mat.macroMap == "" ? "tools/materialeditor/gui/unknownImage" : mat.macroMap);
                normTexCtrl.setBitmapX(mat.normalMap == "" ? "tools/materialeditor/gui/unknownImage" : mat.normalMap);

                detSizeCtrl.setText(mat.detailSize.AsString());
                baseSizeCtrl.setText(mat.diffuseSize.AsString());
                detStrengthCtrl.setText(mat.detailStrength.AsString());
                detDistanceCtrl.setText(mat.detailDistance.AsString());
                sideProjectionCtrl.setValue(mat.useSideProjection.AsString());
                parallaxScaleCtrl.setText(mat.parallaxScale.AsString());

                macroSizeCtrl.setText(mat.macroSize.AsString());
                macroStrengthCtrl.setText(mat.macroStrength.AsString());
                macroDistanceCtrl.setText(mat.macroDistance.AsString());

                //TerrainPainterAddition
                terrainFolderCtrl.setText(mat["terrainFolder"]);
                activateMaterialCtrls(true);
            }
            else
            {
                this["activeMat"] = "0";
                activateMaterialCtrls(false);
            }
        }
Пример #4
0
        public static void EPainter_TerrainMaterialUpdateCallback(TerrainMaterial mat, int matIndex)
        {
            if (matIndex == -1 || !mat.isObject())
            {
                return;
            }

            // Update the material and the UI.

            ((TerrainEditor)"ETerrainEditor").updateMaterial((uint)matIndex, mat.getInternalName());
            ((TerrainPainter)"TerrainPainter").setup(matIndex);
        }
Пример #5
0
        public void buildTree()
        {
            // Refresh the material list.
            GuiTreeViewCtrl matLibTree = FOT("matLibTree");

            matLibTree.clear();

            int root = matLibTree.insertItem(0, "RootMaterial", "RootMaterial", "");

            //TerrainPainterAddition
            SimSet TerrainMaterialSet = "TerrainMaterialSet";

            for (uint i = 0; i < TerrainMaterialSet.getCount(); i++)
            {
                TerrainMaterial mat = TerrainMaterialSet.getObject(i);
                if (!mat.isObject())
                {
                    continue;
                }

                string terrainFolderName = mat["terrainFolder"];
                if (terrainFolderName == "")
                {
                    terrainFolderName = "Unused";
                }

                int folder = matLibTree.findItemByName(terrainFolderName);
                if (folder == 0)
                {
                    folder = matLibTree.insertItem(root, terrainFolderName, terrainFolderName, "");
                }

                if (matLibTree.getParentItem(folder) == root)
                {
                    matLibTree.insertObject(folder, mat, true);
                }
            }
        }
Пример #6
0
        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");
        }
Пример #7
0
        public void saveDirtyMaterial(TerrainMaterial mat)
        {
            // Skip over obviously bad cases.
            if (!mat.isObject())
            {
                return;
            }

            GuiTextEditCtrl matNameCtrl        = this.findObjectByInternalName("matNameCtrl", true);
            GuiBitmapCtrl   baseTexCtrl        = this.findObjectByInternalName("baseTexCtrl", true);
            GuiBitmapCtrl   detailTexCtrl      = this.findObjectByInternalName("detailTexCtrl", true);
            GuiBitmapCtrl   macroTexCtrl       = this.findObjectByInternalName("macroTexCtrl", true);
            GuiBitmapCtrl   normTexCtrl        = this.findObjectByInternalName("normTexCtrl", true);
            GuiTextEditCtrl detSizeCtrl        = this.findObjectByInternalName("detSizeCtrl", true);
            GuiTextEditCtrl baseSizeCtrl       = this.findObjectByInternalName("baseSizeCtrl", true);
            GuiTextEditCtrl detStrengthCtrl    = this.findObjectByInternalName("detStrengthCtrl", true);
            GuiTextEditCtrl detDistanceCtrl    = this.findObjectByInternalName("detDistanceCtrl", true);
            GuiCheckBoxCtrl sideProjectionCtrl = this.findObjectByInternalName("sideProjectionCtrl", true);
            GuiTextEditCtrl parallaxScaleCtrl  = this.findObjectByInternalName("parallaxScaleCtrl", true);

            GuiTextEditCtrl macroSizeCtrl     = this.findObjectByInternalName("macroSizeCtrl", true);
            GuiTextEditCtrl macroStrengthCtrl = this.findObjectByInternalName("macroStrengthCtrl", true);
            GuiTextEditCtrl macroDistanceCtrl = this.findObjectByInternalName("macroDistanceCtrl", true);

            //TerrainPainterAddition
            GuiTextEditCtrl terrainFolderCtrl = FOT("terrainFolderCtrl");

            // Read out properties from the dialog.
            string newDiffuse = "";
            string newNormal  = "";
            string newDetail  = "";
            string newMacro   = "";

            string newName = matNameCtrl.getText();

            if (baseTexCtrl.bitmap != "tools/materialeditor/gui/unknownImage")
            {
                newDiffuse = baseTexCtrl.bitmap;
            }

            if (normTexCtrl.bitmap != "tools/materialeditor/gui/unknownImage")
            {
                newNormal = normTexCtrl.bitmap;
            }

            if (detailTexCtrl.bitmap != "tools/materialeditor/gui/unknownImage")
            {
                newDetail = detailTexCtrl.bitmap;
            }

            if (macroTexCtrl.bitmap != "tools/materialeditor/gui/unknownImage")
            {
                newMacro = macroTexCtrl.bitmap;
            }

            string detailSize        = detSizeCtrl.getText();
            string diffuseSize       = baseSizeCtrl.getText();
            string detailStrength    = detStrengthCtrl.getText();
            string detailDistance    = detDistanceCtrl.getText();
            string useSideProjection = sideProjectionCtrl.getValue();
            string parallaxScale     = parallaxScaleCtrl.getText();

            string macroSize     = macroSizeCtrl.getText();
            string macroStrength = macroStrengthCtrl.getText();
            string macroDistance = macroDistanceCtrl.getText();

            string terrainFolder = terrainFolderCtrl.getText();

            if (mat.internalName == newName && mat.diffuseMap == newDiffuse && mat.normalMap == newNormal && mat.detailMap == newDetail && mat["macroMap"] == newMacro && mat["detailSize"] == detailSize && mat["diffuseSize"] == diffuseSize && mat["detailStrength"] == detailStrength && mat["detailDistance"] == detailDistance && mat["useSideProjection"] == useSideProjection && mat["macroSize"] == macroSize && mat["macroStrength"] == macroStrength && mat["macroDistance"] == macroDistance && mat.parallaxScale.AsString() == parallaxScale && mat["terrainFolder"] == terrainFolder)
            {
                return;
            }

            // Make sure the material name is unique.
            if (mat.internalName != newName)
            {
                TerrainMaterial existingMat = ((SimSet)"TerrainMaterialSet").findObjectByInternalName(newName, true);
                if (existingMat.isObject())
                {
                    messageBox.MessageBoxOK("Error", "There already is a terrain material called '" + newName + "'.");
                    // Reset the name edit control to the old name.
                    matNameCtrl.setText(mat.internalName);
                }
                else
                {
                    mat.setInternalName(newName);
                }
            }
            mat["diffuseMap"]        = newDiffuse;
            mat["normalMap"]         = newNormal;
            mat["detailMap"]         = newDetail;
            mat["macroMap"]          = newMacro;
            mat["detailSize"]        = detailSize;
            mat["diffuseSize"]       = diffuseSize;
            mat["detailStrength"]    = detailStrength;
            mat["detailDistance"]    = detailDistance;
            mat["macroSize"]         = macroSize;
            mat["macroStrength"]     = macroStrength;
            mat["macroDistance"]     = macroDistance;
            mat["useSideProjection"] = useSideProjection;
            mat["parallaxScale"]     = parallaxScale;

            //TerrainPainterAddition
            mat["terrainFolder"] = terrainFolder;

            // Mark the material as dirty and needing saving.

            string fileName = mat.getFilename();

            if (fileName == "")
            {
                fileName = "art/terrains/materials.cs";
            }

            PersistenceManager ETerrainMaterialPersistMan = "ETerrainMaterialPersistMan";

            ETerrainMaterialPersistMan.setDirty(mat, fileName);
        }