public void Init(string dir = null) { if (string.IsNullOrEmpty(dir)) { string tempPath = Path.GetTempPath(); Debug.Log("<color=aqua>temp path:" + tempPath + "</color>"); dir = Path.Combine(tempPath, "planet_explorers_swap"); } try { DirectoryInfo dirInfo = new DirectoryInfo(dir); if (dirInfo.Exists) { FileSystemInfo[] fileSystemInfos = dirInfo.GetFileSystemInfos(); if (fileSystemInfos == null || fileSystemInfos.Length == 0) { mDirInfo = dirInfo; return; } else { Directory.Delete(dir, true); } } mDirInfo = Directory.CreateDirectory(dir); } catch (System.Exception ex) { GameLog.HandleIOException(ex); } }
public bool Read(BinaryReader r) { try { mVersion = r.ReadInt32(); if (mVersion != CurrentVersion) { //Debug.LogWarning("Error version:" + mVersion + "; need version:" + CurrentVersion); return(false); } byte[] b = r.ReadBytes(GuidLength); mGuid = new Guid(b); long length = r.ReadInt64(); if (length != r.BaseStream.Length) { Debug.LogError("Error check sum"); return(false); } return(true); } catch (Exception ex) { GameLog.HandleIOException(ex); return(false); } }
public static void SaveInputConfig(string configFile, bool bApply = true) { XmlDocument xmlDoc = new XmlDocument(); try{ using (FileStream fs = new FileStream(configFile, FileMode.Open, FileAccess.Read, FileShare.Read)) { xmlDoc.Load(fs); } }catch (Exception e) { GameLog.HandleIOException(e, GameLog.EIOFileType.Settings); xmlDoc = new XmlDocument(); } XmlElement rootNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode(s_inputConfRootName); if (null == rootNode) { rootNode = xmlDoc.CreateElement(s_inputConfRootName); xmlDoc.DocumentElement.AppendChild(rootNode); } else { rootNode.RemoveAll(); } rootNode.SetAttribute("Ver", s_inputConfVersion); for (int i = 0; i < s_settingsAll.Length; i++) { XmlElement typeNode = xmlDoc.CreateElement(((EPeInputSettingsType)i).ToString()); rootNode.AppendChild(typeNode); for (int j = 0; j < s_settingsAll[i].Length; j++) { XmlElement keysetNode = xmlDoc.CreateElement(GetSettingName(i, j)); typeNode.AppendChild(keysetNode); KeyJoySettingPair conf = s_settingsAll[i][j]; keysetNode.SetAttribute("Key", ((int)conf._key).ToString()); keysetNode.SetAttribute("Joy", ((int)conf._joy).ToString()); keysetNode.SetAttribute("KeyLock", Convert.ToString(conf._keyLock)); keysetNode.SetAttribute("JoyLock", Convert.ToString(conf._joyLock)); keysetNode.SetAttribute("KeyDes", conf._keyDesc); keysetNode.SetAttribute("JoyDes", conf._joyDesc); } } try{ using (FileStream fs = new FileStream(configFile, FileMode.Create, FileAccess.Write, FileShare.None)) { xmlDoc.Save(fs); } }catch (Exception e) { GameLog.HandleIOException(e, GameLog.EIOFileType.Settings); } if (bApply) { ResetLogicInput(); } }
public void ApplyAudio() { XmlDocument xmlDoc = new XmlDocument(); try{ using (FileStream fs = new FileStream(mFilepath, FileMode.Open, FileAccess.Read, FileShare.Read)) { xmlDoc.Load(fs); } } catch (Exception e) { GameLog.HandleIOException(e, GameLog.EIOFileType.Settings); xmlDoc = new XmlDocument(); } XmlElement findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("Sound"); if (null == findNode) { findNode = xmlDoc.CreateElement("Sound"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("Volume", SoundVolume.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("Music"); if (null == findNode) { findNode = xmlDoc.CreateElement("Music"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("Volume", MusicVolume.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("Dialog"); if (null == findNode) { findNode = xmlDoc.CreateElement("Dialog"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("Volume", DialogVolume.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("Effect"); if (null == findNode) { findNode = xmlDoc.CreateElement("Effect"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("Volume", EffectVolume.ToString()); try{ using (FileStream fs = new FileStream(mFilepath, FileMode.Create, FileAccess.Write, FileShare.None)) { xmlDoc.Save(fs); } }catch (Exception e) { GameLog.HandleIOException(e, GameLog.EIOFileType.Settings); } }
public void EndWriteCheckSum(BinaryWriter w) { try { w.Seek(VerGuidLength, SeekOrigin.Begin); w.Write((long)w.BaseStream.Length); } catch (Exception ex) { GameLog.HandleIOException(ex); } }
public bool CopyTo(string dirDst, System.Action <FileInfo> action = null) { try { CopyDir(mDirInfo, new DirectoryInfo(dirDst), action); return(true); } catch (System.Exception ex) { GameLog.HandleIOException(ex); return(false); } }
public void BeginWriteCheckSum(BinaryWriter w) { try { w.Seek(VerGuidLength, SeekOrigin.Begin); //place holder w.Write((long)0L); } catch (Exception ex) { GameLog.HandleIOException(ex); } }
public void Write(BinaryWriter w) { try { w.Seek(0, SeekOrigin.Begin); w.Write((int)CurrentVersion); w.Write(mGuid.ToByteArray()); } catch (Exception ex) { GameLog.HandleIOException(ex); } }
XmlNodeList GetXmlNodeList(string nodeName) { string path = Path.Combine(mDir, "WorldEntity.xml"); XmlDocument doc = new XmlDocument(); try{ doc.Load(path); } catch (System.Exception ex) { GameLog.HandleIOException(ex, GameLog.EIOFileType.InstallFiles); } XmlNodeList nodeList = doc.SelectNodes(@"WORLDDATA/ENTITIES//" + nodeName); return(nodeList); }
public bool CopyFrom(string dirSrc, NeedCopy needCopy = null) { if (!Directory.Exists(dirSrc)) { return(false); } try { CopyDir(new DirectoryInfo(dirSrc), mDirInfo, null, needCopy); return(true); } catch (System.Exception ex) { GameLog.HandleIOException(ex); return(false); } }
public void LoadSystemData() { if (LoadedData) { return; } if (null == InControl.InControlManager.Instance) { Debug.LogError("InControlManager isn't init."); } mFilepath = GameConfig.GetUserDataPath() + GameConfig.ConfigDataDir; if (!Directory.Exists(mFilepath)) { Directory.CreateDirectory(mFilepath); } mFilepath += "/SystemSaveData.xml"; try{ XmlDocument xmlDoc = new XmlDocument(); using (FileStream fs = new FileStream(mFilepath, FileMode.Open, FileAccess.Read, FileShare.Read)) { xmlDoc.Load(fs); } SetSystemData(xmlDoc); mHasData = true; } catch { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml("<" + "SystemData" + "/>"); xmlDoc.DocumentElement.SetAttribute("Version", mVersion); try{ using (FileStream fs = new FileStream(mFilepath, FileMode.Create, FileAccess.Write, FileShare.None)) { xmlDoc.Save(fs); } }catch (Exception e) { GameLog.HandleIOException(e, GameLog.EIOFileType.Settings); } ApplySettings(); mHasData = false; } LoadedData = true; }
public static bool LoadIso(string path) { VArtifactData ISO; long tick = System.DateTime.Now.Ticks; try { ISO = new VArtifactData(); string fullpath = path; string filename = Path.GetFileNameWithoutExtension(fullpath); //TextAsset ta = Resources.Load(fullpath,typeof(TextAsset)) as TextAsset; using (FileStream fs = new FileStream(fullpath, FileMode.Open, FileAccess.Read)) { byte[] iso_buffer = new byte[(int)(fs.Length)]; //byte[] iso_buffer = ta.bytes; ulong guid = CRC64.Compute(iso_buffer); fs.Read(iso_buffer, 0, (int)(fs.Length)); fs.Close(); if (ISO.Import(iso_buffer, new VAOption(false))) { isos[guid] = ISO; isoNameId[filename] = guid; Debug.Log("loadIso Time: " + (System.DateTime.Now.Ticks - tick)); return(true); } else { ISO = null; return(false); } } } catch (Exception e) { Debug.LogError("Failed to load file " + path); GameLog.HandleIOException(e, GameLog.EIOFileType.InstallFiles); ISO = null; return(false); } }
public static void LoadInputConfig(string configFile) { XmlDocument xmlDoc = new XmlDocument(); try{ using (FileStream fs = new FileStream(configFile, FileMode.Open, FileAccess.Read, FileShare.Read)) { xmlDoc.Load(fs); } }catch (Exception e) { GameLog.HandleIOException(e, GameLog.EIOFileType.Settings); xmlDoc = new XmlDocument(); } XmlElement rootNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode(s_inputConfRootName); if (null == rootNode || !rootNode.HasAttribute("Ver") || rootNode.GetAttribute("Ver") != s_inputConfVersion) { SaveInputConfig(configFile, false); return; } bool bError = false; foreach (XmlNode typeNode in rootNode.ChildNodes) { try{ int type = (int)Enum.Parse(typeof(EPeInputSettingsType), typeNode.Name); KeyJoySettingPair[] curSettings = s_settingsAll[type]; foreach (XmlNode pairNode in typeNode.ChildNodes) { try{ XmlElement pairElem = (XmlElement)pairNode; KeyCode key = (KeyCode)Convert.ToInt32(pairElem.GetAttribute("Key")); InputControlType joy = (InputControlType)Convert.ToInt32(pairElem.GetAttribute("Joy")); bool keyLock = Convert.ToBoolean(pairElem.GetAttribute("KeyLock")); bool joyLock = Convert.ToBoolean(pairElem.GetAttribute("JoyLock")); string keyDesc = pairElem.GetAttribute("KeyDes"); string joyDesc = pairElem.GetAttribute("JoyDes"); int idx = GetSettingIndex(type, pairNode.Name); curSettings[idx].Clone(new KeyJoySettingPair(key, joy, keyLock, joyLock, keyDesc, joyDesc)); }catch { bError = true; Debug.LogError("[PeInput]Error occured while reading xmlnode:" + typeNode.Name + "-" + pairNode.Name); } } }catch { bError = true; Debug.LogError("[PeInput]Error occured while reading settings type:" + typeNode.Name); } } //lz-2017.08.08 把玩家旧的不正确的翻滚配置修改正确 var settingsChrCtrl = s_settingsAll[(int)EPeInputSettingsType.SettingsChrCtrl]; if (settingsChrCtrl[0]._joy == InputControlType.None) { settingsChrCtrl[0]._joy = InputControlType.LeftStickY; } if (settingsChrCtrl[1]._joy == InputControlType.None) { settingsChrCtrl[1]._joy = InputControlType.LeftStickY; } if (settingsChrCtrl[2]._joy == InputControlType.None) { settingsChrCtrl[2]._joy = InputControlType.LeftStickX; } if (settingsChrCtrl[3]._joy == InputControlType.None) { settingsChrCtrl[3]._joy = InputControlType.LeftStickX; } if (bError) { SaveInputConfig(configFile, true); return; } ResetLogicInput(); }
public void ApplyMisc() { XmlDocument xmlDoc = new XmlDocument(); try{ using (FileStream fs = new FileStream(mFilepath, FileMode.Open, FileAccess.Read, FileShare.Read)) { xmlDoc.Load(fs); } }catch (Exception e) { GameLog.HandleIOException(e, GameLog.EIOFileType.Settings); xmlDoc = new XmlDocument(); } XmlElement findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("HideHeadgear"); if (null == findNode) { findNode = xmlDoc.CreateElement("HideHeadgear"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", HideHeadgear.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("HPNumbers"); if (null == findNode) { findNode = xmlDoc.CreateElement("HPNumbers"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", HPNumbers.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("ClipCursor"); if (null == findNode) { findNode = xmlDoc.CreateElement("ClipCursor"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", ClipCursor.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("FixBlurryFont"); if (null == findNode) { findNode = xmlDoc.CreateElement("FixBlurryFont"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", FixBlurryFont.ToString()); if (GameUI.Instance != null) { UILabel[] labels = GameUI.Instance.gameObject.GetComponentsInChildren <UILabel>(true); for (int i = 0; i < labels.Length; i++) { labels[i].MakePixelPerfect(); } } findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("AndyGuidance"); if (null == findNode) { findNode = xmlDoc.CreateElement("AndyGuidance"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", AndyGuidance.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("MouseStateTip"); if (null == findNode) { findNode = xmlDoc.CreateElement("MouseStateTip"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", MouseStateTip.ToString()); //#if UNITY_STANDALONE_WIN // if(ClipCursor) // CursorCliping.Lock(); // else // CursorCliping.Unlock(); //#endif findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("HidePlayerOverHeadInfo"); if (null == findNode) { findNode = xmlDoc.CreateElement("HidePlayerOverHeadInfo"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", HidePlayerOverHeadInfo.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("ApplyMonsterIK"); if (null == findNode) { findNode = xmlDoc.CreateElement("ApplyMonsterIK"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", ApplyMonsterIK.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("VoxelCache"); if (null == findNode) { findNode = xmlDoc.CreateElement("VoxelCache"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", VoxelCacheEnabled.ToString()); PECameraMan.ApplySysSetting(); try{ using (FileStream fs = new FileStream(mFilepath, FileMode.Create, FileAccess.Write, FileShare.None)) { xmlDoc.Save(fs); } }catch (Exception e) { GameLog.HandleIOException(e, GameLog.EIOFileType.Settings); } }
public void ApplyControl() { XmlDocument xmlDoc = new XmlDocument(); try{ using (FileStream fs = new FileStream(mFilepath, FileMode.Open, FileAccess.Read, FileShare.Read)) { xmlDoc.Load(fs); } }catch (Exception e) { GameLog.HandleIOException(e, GameLog.EIOFileType.Settings); xmlDoc = new XmlDocument(); } XmlElement findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("mMMOControlType"); if (null == findNode) { findNode = xmlDoc.CreateElement("mMMOControlType"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", mMMOControlType.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("UseController"); if (null == findNode) { findNode = xmlDoc.CreateElement("UseController"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", UseController.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("FirstPersonCtrl"); if (null == findNode) { findNode = xmlDoc.CreateElement("FirstPersonCtrl"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", FirstPersonCtrl.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("CameraSensitivity"); if (null == findNode) { findNode = xmlDoc.CreateElement("CameraSensitivity"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", cameraSensitivity.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("HoldGunCameraSensitivity"); if (null == findNode) { findNode = xmlDoc.CreateElement("HoldGunCameraSensitivity"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", holdGunCameraSensitivity.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("CameraFov"); if (null == findNode) { findNode = xmlDoc.CreateElement("CameraFov"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", CameraFov.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("CameraHorizontalInverse"); if (null == findNode) { findNode = xmlDoc.CreateElement("CameraHorizontalInverse"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", CameraHorizontalInverse.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("CameraVerticalInverse"); if (null == findNode) { findNode = xmlDoc.CreateElement("CameraVerticalInverse"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", CameraVerticalInverse.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("CamInertia"); if (null == findNode) { findNode = xmlDoc.CreateElement("CamInertia"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", CamInertia.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("DriveCamInertia"); if (null == findNode) { findNode = xmlDoc.CreateElement("DriveCamInertia"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", DriveCamInertia.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("AttackWhithMouseDir"); if (null == findNode) { findNode = xmlDoc.CreateElement("AttackWhithMouseDir"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", AttackWhithMouseDir.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("Tutorialed"); if (null == findNode) { findNode = xmlDoc.CreateElement("Tutorialed"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", Tutorialed.ToString()); PECameraMan.ApplySysSetting(); try{ using (FileStream fs = new FileStream(mFilepath, FileMode.Create, FileAccess.Write, FileShare.None)) { xmlDoc.Save(fs); } }catch (Exception e) { GameLog.HandleIOException(e, GameLog.EIOFileType.Settings); } }
public void ApplyVideo() { XmlDocument xmlDoc = new XmlDocument(); try{ using (FileStream fs = new FileStream(mFilepath, FileMode.Open, FileAccess.Read, FileShare.Read)) { xmlDoc.Load(fs); } }catch (Exception e) { GameLog.HandleIOException(e, GameLog.EIOFileType.Settings); xmlDoc = new XmlDocument(); } XmlElement findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("QualityLevel"); if (null == findNode) { findNode = xmlDoc.CreateElement("QualityLevel"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("Index", mQualityLevel.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("GLSetting"); if (null == findNode) { findNode = xmlDoc.CreateElement("GLSetting"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", GLSetting); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("LightCount"); if (null == findNode) { findNode = xmlDoc.CreateElement("LightCount"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("Index", mLightCount.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("AnisotropicFiltering"); if (null == findNode) { findNode = xmlDoc.CreateElement("AnisotropicFiltering"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("Index", mAnisotropicFiltering.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("AntiAliasing"); if (null == findNode) { findNode = xmlDoc.CreateElement("AntiAliasing"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("Index", mAntiAliasing.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("ShadowProjection"); if (null == findNode) { findNode = xmlDoc.CreateElement("ShadowProjection"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("Index", mShadowProjection.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("ShadowDistance"); if (null == findNode) { findNode = xmlDoc.CreateElement("ShadowDistance"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("Index", mShadowDistance.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("ShadowCascades"); if (null == findNode) { findNode = xmlDoc.CreateElement("ShadowCascades"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("Index", mShadowCascades.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("mWaterReflection"); if (null == findNode) { findNode = xmlDoc.CreateElement("mWaterReflection"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("Index", mWaterReflection.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("WaterRefraction"); if (null == findNode) { findNode = xmlDoc.CreateElement("WaterRefraction"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("Index", WaterRefraction.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("WaterDepth"); if (null == findNode) { findNode = xmlDoc.CreateElement("WaterDepth"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("Index", WaterDepth.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("GrassDensity"); if (null == findNode) { findNode = xmlDoc.CreateElement("GrassDensity"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("Index", GrassDensity.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("GrassLod"); if (null == findNode) { findNode = xmlDoc.CreateElement("GrassLod"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("Index", ((int)mGrassLod).ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("Terrain"); if (null == findNode) { findNode = xmlDoc.CreateElement("Terrain"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("Index", TerrainLevel.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("RandomTerrain"); if (null == findNode) { findNode = xmlDoc.CreateElement("RandomTerrain"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("Index", RandomTerrainLevel.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("DepthBlur"); if (null == findNode) { findNode = xmlDoc.CreateElement("DepthBlur"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", mDepthBlur.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("SSAO"); if (null == findNode) { findNode = xmlDoc.CreateElement("SSAO"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", mSSAO.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("SyncCount"); if (null == findNode) { findNode = xmlDoc.CreateElement("SyncCount"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("value", SyncCount.ToString()); ResetVSync(); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("Tree"); if (null == findNode) { findNode = xmlDoc.CreateElement("Tree"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("Index", mTreeLevel.ToString()); // GrassMgr.RefreshSettings(GrassDensity, (int)GrassLod); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("HDREffect"); if (null == findNode) { findNode = xmlDoc.CreateElement("HDREffect"); xmlDoc.DocumentElement.AppendChild(findNode); } findNode.SetAttribute("Index", HDREffect.ToString()); findNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("FastLightingMode"); if (null == findNode) { findNode = xmlDoc.CreateElement("FastLightingMode"); xmlDoc.DocumentElement.AppendChild(findNode); } //mFastLightingMode = true; findNode.SetAttribute("Index", mFastLightingMode.ToString()); switch (mQualityLevel) { case 0: QualitySettings.SetQualityLevel(0); #if Win32Ver TerrainLevel = 0; #else TerrainLevel = 1; //increase from 128M to 256M for bug 502857 #endif RandomTerrainLevel = 0; mTreeLevel = 1; HDREffect = false; break; case 1: QualitySettings.SetQualityLevel(1); TerrainLevel = 1; //increase from 128M to 256M for bug 502857 RandomTerrainLevel = 0; mTreeLevel = 1; HDREffect = false; break; case 2: QualitySettings.SetQualityLevel(2); TerrainLevel = 1; RandomTerrainLevel = 1; mTreeLevel = 1; HDREffect = false; break; case 3: QualitySettings.SetQualityLevel(3); TerrainLevel = 2; RandomTerrainLevel = 1; mTreeLevel = 3; HDREffect = true; break; case 4: QualitySettings.SetQualityLevel(4); TerrainLevel = 3; RandomTerrainLevel = 2; mTreeLevel = 4; HDREffect = true; break; case 5: QualitySettings.SetQualityLevel(5); TerrainLevel = 3; RandomTerrainLevel = 2; mTreeLevel = 5; HDREffect = true; break; case 6: QualitySettings.SetQualityLevel(3); // for Ubuntu with AMD card, larger than 3 will cause game select GL_FBCONFIG 47/55 which can not render defered-render cam QualitySettings.pixelLightCount = mLightCount; switch (mAnisotropicFiltering) { case 0: QualitySettings.anisotropicFiltering = AnisotropicFiltering.Disable; break; case 1: QualitySettings.anisotropicFiltering = AnisotropicFiltering.Enable; break; case 2: QualitySettings.anisotropicFiltering = AnisotropicFiltering.ForceEnable; break; } QualitySettings.antiAliasing = (mAntiAliasing > 0)? 4 : 0; QualitySettings.shadowProjection = (mShadowProjection == 1)? ShadowProjection.StableFit :ShadowProjection.CloseFit; switch (mShadowDistance) { case 0: QualitySettings.shadowDistance = 1; break; case 1: QualitySettings.shadowDistance = 50; break; case 2: QualitySettings.shadowDistance = 100; break; case 3: QualitySettings.shadowDistance = 200; break; case 4: QualitySettings.shadowDistance = 400; break; } switch (mShadowCascades) { case 0: QualitySettings.shadowCascades = 0; break; case 1: QualitySettings.shadowCascades = 2; break; case 2: QualitySettings.shadowCascades = 4; break; } break; } PeGrassSystem.Refresh(GrassDensity, (int)GrassLod); PECameraMan.ApplySysSetting(); try{ using (FileStream fs = new FileStream(mFilepath, FileMode.Create, FileAccess.Write, FileShare.None)) { xmlDoc.Save(fs); } }catch (Exception e) { GameLog.HandleIOException(e, GameLog.EIOFileType.Settings); } }