예제 #1
0
        public void addSelectTexture(TerrainTextureButton but)
        {
            if (mSelectedButton != null)
            {
                mSelectedButton.Invalidate();
            }

            mSelectedButton = but;
            mSelectedButton.Invalidate();


            if (but is TerrainTextureSplatButton)
            {
                SelectedDef = SimTerrainType.getFromTypeName(but.typename);

                if (!isActiveSetSelected())
                {
                    TerrainGlobals.getTexturing().addActiveTexture(SimTerrainType.getWorkingTexName(mSelectedDef));
                }
            }
            else if (but is TerrainTextureDecalButton)
            {
                if (!isActiveSetSelected())
                {
                    TerrainGlobals.getTexturing().addActiveDecal(((TerrainTextureDecalButton)but).mFullFilename);
                }
                TerrainGlobals.getTerrainFrontEnd().SelectedDecalIndex = TerrainGlobals.getTexturing().getActiveDecalIndex(((TerrainTextureDecalButton)but).mFullFilename);
                if (TerrainGlobals.getEditor().getRenderMode() == BTerrainEditor.eEditorRenderMode.cRenderTextureSelectRender)
                {
                    TerrainGlobals.getTexturing().reloadCachedVisuals();
                }
            }
        }
예제 #2
0
            protected override void OnDoubleClick(EventArgs e)
            {
                mParent.mSelectedDef = SimTerrainType.getFromTypeName(typename);

                mParent.DialogResult = DialogResult.OK;
                mParent.Close();
            }
예제 #3
0
        public void SelectButton(TerrainTypeButton but)
        {
            if (mSelectedButton != null)
            {
                mSelectedButton.Invalidate();
            }

            mSelectedButton = but;
            mSelectedButton.Invalidate();
            mSelectedDef = SimTerrainType.getFromTypeName(mSelectedButton.typename);
        }
예제 #4
0
        public void swapSelectTexture(TerrainTextureButton but)
        {
            if (mSelectedButton != but)
            {
                TerrainTextureDef newDef  = null;
                TerrainTextureDef origDef = mSelectedDef;
                bool activeSel            = isActiveSetSelected();
                if (activeSel)
                {
                    newDef = SimTerrainType.getFromTypeName(but.typename);
                }
                else
                {
                    addSelectTexture(but);
                    newDef = mSelectedDef;
                }

                //replace across the board
                if (mSelectSwap)
                {
                    TerrainGlobals.getTexturing().swapActiveTextures(SimTerrainType.getActiveSetIndex(origDef), SimTerrainType.getActiveSetIndex(newDef));
                    SimTerrainType.swapActiveSetDef(SimTerrainType.getActiveSetIndex(origDef), SimTerrainType.getActiveSetIndex(newDef));
                }
                else if (mSelectReplace)
                {
                    if (SimTerrainType.getActiveSetIndex(newDef) == 0)
                    {
                        MessageBox.Show("You can not replace with the base texture");
                    }
                    else
                    {
                        TerrainGlobals.getTexturing().replaceActiveTexture(SimTerrainType.getActiveSetIndex(origDef), SimTerrainType.getActiveSetIndex(newDef));
                        SimTerrainType.removeActiveSetDef(origDef);
                    }
                }

                if (!activeSel)
                {
                    //now select our new texture
                    addSelectTexture(but);
                }
            }
            mSelectSwap     = false;
            mSelectReplace  = false;
            alertLabel.Text = "";

            TerrainGlobals.getTexturing().freeAllCaches();
            selectActiveSet();
            redrawPreviewList(0);
            SelectButton(but);

            //TerrainGlobals.getTexturing().reloadActiveTextures(true);
        }
예제 #5
0
        public void apply()
        {
            string fName     = Path.GetFileNameWithoutExtension(mData.Texture);
            string dir       = Path.GetDirectoryName(mData.Texture);
            string themeName = dir.Substring(dir.LastIndexOf("\\") + 1);

            TerrainTextureDef SelectedDef = SimTerrainType.getFromTypeName(themeName + "_" + fName);

            TerrainGlobals.getTexturing().addActiveTexture(SimTerrainType.getWorkingTexName(SelectedDef));
            SimTerrainType.addActiveSetDef(SelectedDef);
            TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex = SimTerrainType.getActiveSetIndex(SelectedDef);


            TerrainGlobals.getEditor().applyTextureToMask();
        }
예제 #6
0
        private void paletteComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            flowLayoutPanel1.Controls.Clear();

            string setName = paletteComboBox.SelectedItem.ToString();
            string fname   = CoreGlobals.getWorkPaths().mTerrainTexturesPath + @"\" + setName + SimTerrainType.mTextureSetExtention;
            List <TerrainSetTexture> texSet = SimTerrainType.loadTerrainPalette(fname);

            foreach (TerrainSetTexture obj in texSet)
            {
                TerrainTextureDef def = SimTerrainType.getFromTypeName(obj.mTypeName);
                if (def == null)
                {
                    def = new TerrainTextureDef();
                    def.ObstructLand = false;
                    def.TextureName  = EditorCore.CoreGlobals.getWorkPaths().mBlankTextureName;
                }
                flowLayoutPanel1.Controls.Add(new TerrainTypeButton(obj.mTypeName, TextureManager.loadTextureToThumbnail(SimTerrainType.getWorkingTexName(def), 16), this));
            }
        }
예제 #7
0
        public void redrawPreviewList(int paletteIndex)
        {
            //try
            //{

            flowLayoutPanel1.Controls.Clear();
            flowLayoutPanel1.Controls.Add(new TerrainTitleButton("SplatTextures", this));
            string setName = "";

            if (paletteIndex == 0)
            {
                List <TerrainTextureDef> activeTexDefs = SimTerrainType.getDefsOfActiveSet();

                if (activeTexDefs.Count == 0)
                {
                    MessageBox.Show("An error has occured with the active texture defnitions. Please send this scenario to the editor people.");
                    return;
                }

                for (int i = 0; i < activeTexDefs.Count; i++)
                {
                    flowLayoutPanel1.Controls.Add(new TerrainTextureSplatButton(activeTexDefs[i].TypeName,
                                                                                SimTerrainType.getWorkingTexName(activeTexDefs[i]),
                                                                                TextureManager.loadTextureToThumbnail(SimTerrainType.getWorkingTexName(activeTexDefs[i]), mThumbnailSize),
                                                                                this));
                }
                //visually identify our base texture
                flowLayoutPanel1.Controls[firstSplatIndex()].BackColor = Color.FromArgb(96, 0, 0, 0);
            }
            else if (paletteIndex <= mNumThemes)
            {
                setName = comboBox1.Items[paletteIndex].ToString();
                setName = setName.Remove(setName.LastIndexOf("_FULL"));

                List <TerrainTextureDef> tList = SimTerrainType.getFilteredDefs(setName);
                setName = comboBox1.Items[paletteIndex].ToString();
                for (int i = 0; i < tList.Count; i++)
                {
                    flowLayoutPanel1.Controls.Add(new TerrainTextureSplatButton(tList[i].TypeName,
                                                                                SimTerrainType.getWorkingTexName(tList[i]),
                                                                                TextureManager.loadTextureToThumbnail(SimTerrainType.getWorkingTexName(tList[i]), mThumbnailSize),
                                                                                this));
                }
            }
            else
            {
                setName = comboBox1.Items[paletteIndex].ToString();

                string fname = CoreGlobals.getWorkPaths().mTerrainTexturesPath + @"\" + setName + SimTerrainType.mTextureSetExtention;
                List <TerrainSetTexture> texSet = SimTerrainType.loadTerrainPalette(fname);

                for (int i = 0; i < texSet.Count; i++)
                {
                    TerrainSetTexture obj = texSet[i];
                    {
                        TerrainTextureDef def = SimTerrainType.getFromTypeName(obj.mTypeName);
                        if (def == null)
                        {
                            def = new TerrainTextureDef();
                            def.ObstructLand = false;
                            def.TextureName  = EditorCore.CoreGlobals.getWorkPaths().mBlankTextureName;
                        }
                        flowLayoutPanel1.Controls.Add(new TerrainTextureSplatButton(obj.mTypeName,
                                                                                    SimTerrainType.getWorkingTexName(def),
                                                                                    TextureManager.loadTextureToThumbnail(SimTerrainType.getWorkingTexName(def), mThumbnailSize),
                                                                                    this));
                    }
                }
            }

            flowLayoutPanel1.Controls.Add(new TerrainTitleButton("DecalTextures", this));
            int decalIndex = firstDecalIndex();

            //now add our decals
            if (paletteIndex == 0)
            {
                for (int i = 0; i < TerrainGlobals.getTexturing().getActiveDecalCount(); i++)
                {
                    string displName = Path.GetFileNameWithoutExtension(TerrainGlobals.getTexturing().getActiveDecal(i).mFilename);
                    displName = displName.Remove(displName.LastIndexOf("_"));

                    flowLayoutPanel1.Controls.Add(new TerrainTextureDecalButton(displName,
                                                                                TerrainGlobals.getTexturing().getActiveDecal(i).mFilename,
                                                                                TextureManager.loadTextureToThumbnail(TerrainGlobals.getTexturing().getActiveDecal(i).mFilename, mThumbnailSize),
                                                                                this));
                }
            }
            else if (paletteIndex <= mNumThemes)
            {
                setName = comboBox1.Items[paletteIndex].ToString();
                setName = setName.Remove(setName.LastIndexOf("_FULL"));

                string[] textureNames = Directory.GetFiles(CoreGlobals.getWorkPaths().mTerrainTexturesPath + "\\" + setName, "*_dcl_*.ddx", SearchOption.AllDirectories);

                for (int i = 0; i < textureNames.Length; i++)
                {
                    if (!textureNames[i].Contains("_df"))
                    {
                        continue;
                    }

                    String ext = Path.GetExtension(textureNames[i]);
                    if (!File.Exists(textureNames[i].Substring(0, textureNames[i].LastIndexOf("_df")) + "_op" + ext))
                    {
                        continue;
                    }


                    string displName = Path.GetFileNameWithoutExtension(textureNames[i]);
                    displName = displName.Remove(displName.LastIndexOf("_"));
                    flowLayoutPanel1.Controls.Add(new TerrainTextureDecalButton(displName,
                                                                                Path.ChangeExtension(textureNames[i], ".tga"),
                                                                                TextureManager.loadTextureToThumbnail(Path.ChangeExtension(textureNames[i], ".tga"), mThumbnailSize),
                                                                                this));
                }
            }
            else
            {
                //not supported yet...
            }

            //}
            //catch (System.Exception ex)
            //{
            //   if (mbPostTEDLoadRecovery)
            //   {
            //      CoreGlobals.getErrorManager().OnException(ex);
            //   }

            //}
        }