Exemple #1
0
        public void fillSetList(string setName)
        {
            setList.Items.Clear();

            string fname = CoreGlobals.getWorkPaths().mTerrainTexturesPath + @"\" + setName + SimTerrainType.mTextureSetExtention;

            List <TerrainSetTexture> texSet = SimTerrainType.loadTerrainPalette(fname);

            foreach (TerrainSetTexture obj in texSet)
            {
                setList.Items.Add(obj.mTypeName);
            }
        }
Exemple #2
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));
            }
        }
Exemple #3
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);
            //   }

            //}
        }