//--------------------------------------- public void ClearData(frmMain apMainForm) { msMainSound = ""; msStartSound = ""; msStopSound = ""; mfVolume = 1; mfMinDistance= 1; mfMaxDistance = 10; mfRandom = 1; mfInterval =0; mbFadeStart=false; mbFadeEnd =false; mbStream =false; mbUse3D = true; mbLoop = true; mbBlockable = false; mfBlockVolMul = 0.6f; mlPriority =0; apMainForm.txtSoundFile.Text = ""; UpdateToForm(apMainForm); }
//--------------------------------------- public void UpdateToForm(frmMain apMainForm) { apMainForm.txtMainSoundFile.Text = msMainSound; apMainForm.txtStartSoundFile.Text = msStartSound; apMainForm.txtStopSoundFile.Text = msStopSound; apMainForm.txtSoundVolume.Text = mfVolume.ToString(); apMainForm.txtSoundMinDist.Text = mfMinDistance.ToString(); apMainForm.txtSoundMaxDist.Text = mfMaxDistance.ToString(); apMainForm.txtSoundRandom.Text = mfRandom.ToString(); apMainForm.txtSoundInterval.Text = mfInterval.ToString(); apMainForm.objSoundFadeEnd.SelectedIndex = mbFadeEnd ? 0 : 1; apMainForm.objSoundFadeStart.SelectedIndex = mbFadeStart ? 0 : 1; apMainForm.objSoundStream.SelectedIndex = mbStream ? 0 : 1; apMainForm.objSoundLoop.SelectedIndex = mbLoop ? 0 : 1; apMainForm.objSoundUse3D.SelectedIndex = mbUse3D ? 0 : 1; apMainForm.objSoundBlockable.SelectedIndex = mbBlockable ? 0 : 1; apMainForm.txtSoundBlockVolMul.Text = mfBlockVolMul.ToString(); apMainForm.txtSoundPriority.Text = mlPriority.ToString(); }
//--------------------------------------- public void Save(String asFile,frmMain apMainForm) { XmlDocument Doc = new XmlDocument(); XmlElement DocRoot = Doc.CreateElement("SOUNDENTITY"); Doc.AppendChild(DocRoot); XmlElement MainElem = Doc.CreateElement("MAIN"); DocRoot.AppendChild(MainElem); MainElem.SetAttribute("MainSound",msMainSound); MainElem.SetAttribute("StartSound",msStartSound); MainElem.SetAttribute("StopSound",msStopSound); XmlElement PropElem = Doc.CreateElement("PROPERTIES"); DocRoot.AppendChild(PropElem); PropElem.SetAttribute("Volume",mfVolume.ToString()); PropElem.SetAttribute("MinDistance",mfMinDistance.ToString()); PropElem.SetAttribute("MaxDistance",mfMaxDistance.ToString()); PropElem.SetAttribute("Random",mfRandom.ToString()); PropElem.SetAttribute("Interval",mfInterval.ToString()); PropElem.SetAttribute("FadeEnd",mbFadeEnd?"True":"False"); PropElem.SetAttribute("FadeStart",mbFadeStart?"True":"False"); PropElem.SetAttribute("Stream",mbStream?"True":"False"); PropElem.SetAttribute("Loop",mbLoop?"True":"False"); PropElem.SetAttribute("Use3D",mbUse3D?"True":"False"); PropElem.SetAttribute("Blockable",mbBlockable?"True":"False"); PropElem.SetAttribute("BlockVolumeMul",mfBlockVolMul.ToString()); PropElem.SetAttribute("Priority",mlPriority.ToString()); Doc.Save(asFile); }
//--------------------------------------- public void Load(String asFile,frmMain apMainForm) { XmlDocument Doc = new XmlDocument(); Doc.Load(asFile); XmlElement DocRoot = (XmlElement)Doc.FirstChild; //Iterate trough all child elemens for(int child_count=0;child_count< DocRoot.ChildNodes.Count;child_count++) { XmlElement ChildNode = (XmlElement)DocRoot.ChildNodes[child_count]; if(ChildNode.Name == "MAIN") { msMainSound = ChildNode.GetAttribute("MainSound"); msStartSound = ChildNode.GetAttribute("StartSound"); msStopSound = ChildNode.GetAttribute("StopSound"); } else if(ChildNode.Name == "PROPERTIES") { mfVolume = (float)Convert.ToDouble(ChildNode.GetAttribute("Volume")); mfMinDistance = (float)Convert.ToDouble(ChildNode.GetAttribute("MinDistance")); mfMaxDistance = (float)Convert.ToDouble(ChildNode.GetAttribute("MaxDistance")); mfRandom = (float)Convert.ToDouble(ChildNode.GetAttribute("Random")); mfInterval = (float)Convert.ToDouble(ChildNode.GetAttribute("Interval")); mbLoop = ChildNode.GetAttribute("Loop")=="True" ?true:false; mbUse3D = ChildNode.GetAttribute("Use3D")=="True" ?true:false; mbStream = ChildNode.GetAttribute("Stream")=="True" ?true:false; mbBlockable = ChildNode.GetAttribute("Blockable")=="True" ?true:false; try{ mfBlockVolMul = (float)Convert.ToDouble(ChildNode.GetAttribute("BlockVolumeMul")); } catch{ mfBlockVolMul = 0.6f; } try { mlPriority = Convert.ToInt32(ChildNode.GetAttribute("Priority")); } catch { mlPriority = 0; } mbFadeStart = ChildNode.GetAttribute("FadeStart")=="True" ?true:false; mbFadeEnd = ChildNode.GetAttribute("FadeEnd")=="True" ?true:false; } } UpdateToForm(apMainForm); }
//--------------------------------------- public void UpdateFromForm(frmMain apMainForm) { msMainSound = apMainForm.txtMainSoundFile.Text; msStartSound = apMainForm.txtStartSoundFile.Text; msStopSound = apMainForm.txtStopSoundFile.Text; try{ mfVolume = (float)Convert.ToDouble(apMainForm.txtSoundVolume.Text); } catch{ mfVolume =0; } try { mfMinDistance = (float)Convert.ToDouble(apMainForm.txtSoundMinDist.Text); } catch { mfMinDistance =1; } try { mfMaxDistance = (float)Convert.ToDouble(apMainForm.txtSoundMaxDist.Text); } catch{ mfMaxDistance = 10; } try{ mfRandom = (float)Convert.ToDouble(apMainForm.txtSoundRandom.Text); } catch{ mfRandom =1; } try{ mfInterval = (float)Convert.ToDouble(apMainForm.txtSoundInterval.Text); } catch{ mfInterval =0; } mbFadeEnd = apMainForm.objSoundFadeEnd.SelectedIndex==0?true:false; mbFadeStart = apMainForm.objSoundFadeStart.SelectedIndex==0?true:false; mbStream = apMainForm.objSoundStream.SelectedIndex==0?true:false; mbLoop = apMainForm.objSoundLoop.SelectedIndex==0?true:false; mbUse3D = apMainForm.objSoundUse3D.SelectedIndex==0?true:false; mbBlockable = apMainForm.objSoundBlockable.SelectedIndex==0?true:false; try { mfBlockVolMul = (float)Convert.ToDouble(apMainForm.txtSoundBlockVolMul.Text); } catch { mfBlockVolMul =0.6f; } try { mlPriority = Convert.ToInt32(apMainForm.txtSoundPriority.Text); } catch { mlPriority =0; } }
public void Save(String asFile,frmMain apMainForm) { XmlDocument Doc = new XmlDocument(); XmlElement DocRoot = Doc.CreateElement("Material"); Doc.AppendChild(DocRoot); XmlElement MainElem = Doc.CreateElement("Main"); DocRoot.AppendChild(MainElem); MainElem.SetAttribute("Type",(String)apMainForm.objMaterialTypes.SelectedItem); MainElem.SetAttribute("PhysicsMaterial",msPhysicsMaterial); MainElem.SetAttribute("UseAlpha",mbUseAlpha?"True" : "False"); MainElem.SetAttribute("DepthTest",mbDepthTest?"True" : "False"); MainElem.SetAttribute("Value",msValue); XmlElement TexElem = Doc.CreateElement("TextureUnits"); DocRoot.AppendChild(TexElem); //Textures for(int i=0; i< apMainForm.objTextureUnitTypes.Items.Count; i++) { HplTextureUnit TexUnit = (HplTextureUnit)mvTextureUnits[i]; String sTexType = (String)apMainForm.objTextureUnitTypes.Items[i]; XmlElement ChildElem = Doc.CreateElement(sTexType); /*if(TexUnit.msFile == ""){ MessageBox.Show("Could not save! Material has no "+(String)apMainForm.objTextureUnitTypes.Items[i]+" texture file!","Error"); return; }*/ ChildElem.SetAttribute("File", TexUnit.msFile); ChildElem.SetAttribute("Compress", "false"); ChildElem.SetAttribute("Type", "2D"); ChildElem.SetAttribute("Mipmaps",TexUnit.mbMipMaps? "true" : "false"); ChildElem.SetAttribute("Wrap",(String)apMainForm.objWrapModes.Items[(int)TexUnit.mWrapMode] ); ChildElem.SetAttribute("AnimMode", TexUnit.msAnimMode); ChildElem.SetAttribute("AnimFrameTime", TexUnit.msFrameTime); ChildElem.SetAttribute("Type",TexUnit.msType); TexElem.AppendChild(ChildElem); } Doc.Save(asFile); }
//--------------------------------------- public void UpdateFromForm(frmMain apMainForm) { msMainSound = apMainForm.txtMainSoundFile.Text; msStartSound = apMainForm.txtStartSoundFile.Text; msStopSound = apMainForm.txtStopSoundFile.Text; try{ mfVolume = (float)Convert.ToDouble(apMainForm.txtSoundVolume.Text); } catch { mfVolume = 0; } try { mfMinDistance = (float)Convert.ToDouble(apMainForm.txtSoundMinDist.Text); } catch { mfMinDistance = 1; } try { mfMaxDistance = (float)Convert.ToDouble(apMainForm.txtSoundMaxDist.Text); } catch { mfMaxDistance = 10; } try{ mfRandom = (float)Convert.ToDouble(apMainForm.txtSoundRandom.Text); } catch { mfRandom = 1; } try{ mfInterval = (float)Convert.ToDouble(apMainForm.txtSoundInterval.Text); } catch { mfInterval = 0; } mbFadeEnd = apMainForm.objSoundFadeEnd.SelectedIndex == 0?true:false; mbFadeStart = apMainForm.objSoundFadeStart.SelectedIndex == 0?true:false; mbStream = apMainForm.objSoundStream.SelectedIndex == 0?true:false; mbLoop = apMainForm.objSoundLoop.SelectedIndex == 0?true:false; mbUse3D = apMainForm.objSoundUse3D.SelectedIndex == 0?true:false; mbBlockable = apMainForm.objSoundBlockable.SelectedIndex == 0?true:false; try { mfBlockVolMul = (float)Convert.ToDouble(apMainForm.txtSoundBlockVolMul.Text); } catch { mfBlockVolMul = 0.6f; } try { mlPriority = Convert.ToInt32(apMainForm.txtSoundPriority.Text); } catch { mlPriority = 0; } }
public HplTrans(frmMain apMainForm) { mvCategories = new ArrayList(); mpMainForm = apMainForm; mvDirectories = new ArrayList(); }