Пример #1
0
        public void export()
        {
            GuiListBoxCtrl TerrainSelectListBox = "TerrainSelectListBox";
            int            itemId     = TerrainSelectListBox.getSelectedItem();
            TerrainBlock   terrainObj = TerrainSelectListBox.getItemObject(itemId);

            if (!terrainObj.isObject())
            {
                messageBox.MessageBoxOK("Export failed", "Could not find the selected TerrainBlock!");
                return;
            }
            string filePath    = ((GuiTextEditCtrl)"SelectFolderTextEdit").getText();
            string terrainName = terrainObj.getName();

            if (terrainName == "")
            {
                terrainName = "Unnamed";
            }

            string fileName   = terrainName + "_heightmap.png";
            string filePrefix = terrainName + "_layerMap";

            string ret = terrainObj.call("exportHeightMap", new string[] { filePath + "/" + fileName, "png" });

            if (ret.AsBool())
            {
                ret = terrainObj.call("exportLayerMaps", new string[] { filePath + "/" + filePrefix, "png" });
            }

            if (ret.AsBool())
            {
                close();
            }
        }
        public void create()
        {
            /*
             * %terrainName = %this-->theName.getText();
             * %resolution = %this-->theRezList.getSelected();
             * %materialName = %this-->theMaterialList.getText();
             * %genNoise = %this-->noiseRadio.getValue();
             *
             * %obj = TerrainBlock::createNew( %terrainName, %resolution, %materialName, %genNoise );
             *
             * if( %genNoise )
             *    ETerrainEditor.isDirty = true;
             *
             * if( isObject( %obj ) )
             * {
             *    // Submit an undo action.
             *    MECreateUndoAction::submit(%obj);
             *
             *    assert( isObject( EWorldEditor ),
             *       "ObjectBuilderGui::processNewObject - EWorldEditor is missing!" );
             *
             *    // Select it in the editor.
             *    EWorldEditor.clearSelection();
             *    EWorldEditor.selectObject(%obj);
             *
             *    // When we drop the selection don't store undo
             *    // state for it... the creation deals with it.
             *    EWorldEditor.dropSelection( true );
             * }
             *
             * Canvas.popDialog( %this );
             */

            string           terrainName  = ((GuiTextEditCtrl)this.findObjectByInternalName("theName", true)).getText();
            GuiPopUpMenuCtrl rezList      = this.findObjectByInternalName("theRezList", true);
            GuiPopUpMenuCtrl matList      = this.findObjectByInternalName("theMaterialList", true);
            string           resolution   = rezList.getSelected().AsString();
            string           materialName = matList.getText();
            string           genNoise     = ((GuiRadioCtrl)this.findObjectByInternalName("noiseRadio", true)).getValue();

            TerrainBlock obj = console.Eval("TerrainBlock::createNew(\"" + terrainName + "\",\"" + resolution + "\",\"" + materialName + "\",\"" + genNoise + "\");", true);

            if (genNoise.AsBool())
            {
                ((SimObject)"ETerrainEditor")["isDirty"] = "1";
            }

            if (obj.isObject())
            {
                EWorldEditor EWorldEditor = "EWorldEditor";
                // Submit an undo action.
                Extendable.MECreateUndoAction.submit(obj);
                // Select it in the editor.
                EWorldEditor.clearSelection();
                EWorldEditor.selectObject(obj);

                // When we drop the selection don't store undo
                // state for it... the creation deals with it.

                EWorldEditor.dropSelection(true);
            }
            ((GuiCanvas)"Canvas").popDialog(this);
        }