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(); } } }
void OnLoad(object sender, EventArgs e) { UIManager.Pause(); if (mPalette.mIsMaskPalette) { OpenFileDialog d = new OpenFileDialog(); d.Filter = "Terrain Texture Masks (*.bmp)|*.bmp"; d.InitialDirectory = CoreGlobals.getWorkPaths().mBrushMasks; if (d.ShowDialog() == DialogResult.OK) { TextureName = (d.FileName); } } else { if (mPalette.tpv.ShowDialog() == DialogResult.OK) { TextureName = SimTerrainType.getWorkingTexName(mPalette.tpv.mSelectedDef); } } UIManager.UnPause(); }
public void createTexturesFromSimDefs() { mActiveTextures.Clear(); List <TerrainTextureDef> activeTexDefs = SimTerrainType.getDefsOfActiveSet(); for (int i = 0; i < activeTexDefs.Count; i++) { if (BRenderDevice.getDevice() != null) { string fullFileName = SimTerrainType.getWorkingTexName(activeTexDefs[i]); addActiveTexture(fullFileName); } } }
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(); }
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); // } //} }
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)); } }