/* Configuration methods */ // loading all settings private void LoadSettings() { INIFile iniFile = new INIFile(Statics.iniFileName, iniDLWizardVars, true); configure = !iniFile.hasSection(iniDLWizardSets); if (configure) { iniFile.initialize(); iniFile.save(); } pluginDirs = new List<string>(iniFile.getSectList(iniDLWizardPlugDirs)); pluginDirs.Sort(); string dir2 = ""; foreach (string s in pluginDirs) { string dir1 = s.ToLower(Statics.Culture); if (dir1 == dir2) pluginDirs.Remove(s); dir2 = dir1; } pluginList = new MWPlugins(Statics.fn_datafiles, pluginDirs); switch ((int)iniFile.getKeyValue("PlugSort")) { case 0: rbPlugsName.Checked = true; break; case 1: rbPlugsType.Checked = true; break; case 2: rbPlugsLoad.Checked = true; break; } pluginsSort(null, null); preselectedPlugins = iniFile.getSectList(iniDLWizardPlugs); SelectPlugins(preselectedPlugins); cmbTexWorldResolution.SelectedIndex = (int)iniFile.getKeyValue("TexRes"); cmbTexWorldNormalRes.SelectedIndex = (int)iniFile.getKeyValue("NormRes"); cbTexTwoStep.Checked = (iniFile.getKeyValue("Tex2Step") == 1); cmbMeshWorldDetail.SelectedIndex = (int)iniFile.getKeyValue("WorldMesh"); udStatMinSize.Value = (int)iniFile.getKeyValue("MinStat"); udStatGrassDensity.Value = (int)iniFile.getKeyValue("GrassDens"); cmbStatSimplifyMeshes.SelectedIndex = (int)iniFile.getKeyValue("StatMesh"); cmbStatSkipMipLevels.SelectedIndex = (int)iniFile.getKeyValue("SkipMip"); cbStatActivators.Checked = (iniFile.getKeyValue("Activators") == 1); cbStatIncludeMisc.Checked = (iniFile.getKeyValue("MiscObj") == 1); cbStatOverrideList.Checked = (iniFile.getKeyValue("UseStatOvr") == 1); cbStatIntExt.Checked = (iniFile.getKeyValue("StatIntExt") == 1); cbStatIntWater.Checked = (iniFile.getKeyValue("StatIntWater") == 1); lbStatOverrideList.Items.Clear(); lbStatOverrideList.Items.AddRange(iniFile.getSectList(iniDLWizardStatOvr)); lStatOverrideList.Enabled = (lbStatOverrideList.Items.Count == 0); }
private bool SaveFile(String fileName) { try { File.Delete(fileName); } catch { return false; } List<INIFile.INIVariableDef> defmcp = new List<INIFile.INIVariableDef>(); List<String[]> comments = new List<String[]>(); // 0 - section, 1 - key, 2 - comment above defmcp.Add(INIFile.iniDefEmpty); foreach (String section in selections.Sections.Keys) { Patch patch = selections.Sections[section]; if (patch.Checked != new Patch().Checked) defmcp.Add(new INIFile.INIVariableDef(defmcp.Count.ToString(), section, Patch.Keys[Patch.Key.Checked], INIFile.INIVariableType.Dictionary, patch.Checked.ToString())); defmcp.Add(new INIFile.INIVariableDef(defmcp.Count.ToString(), section, Patch.Keys[Patch.Key.Version], INIFile.INIVariableType.Dictionary, patch.Version.ToString())); Dictionary<Patch.Key, String> str = new Dictionary<Patch.Key, String> { { Patch.Key.Parent, patch.Parent }, { Patch.Key.Author, patch.Author } }; foreach (Patch.Key key in str.Keys) if (str[key].Trim().Length > 0) defmcp.Add(new INIFile.INIVariableDef(defmcp.Count.ToString(), section, Patch.Keys[key], INIFile.INIVariableType.Dictionary, str[key].Trim())); if (patch.FileVersion != new Patch().FileVersion) defmcp.Add(new INIFile.INIVariableDef(defmcp.Count.ToString(), section, Patch.Keys[Patch.Key.FileVersion], INIFile.INIVariableType.Dictionary, patch.FileVersion.ToString())); Dictionary<Patch.Key, Unit[]> array = new Dictionary<Patch.Key, Unit[]> { { Patch.Key.Original, patch.Original }, { Patch.Key.Patch, patch.Patched }, { Patch.Key.Attach, patch.Attach }, { Patch.Key.Description, patch.Description } }; foreach (Patch.Key key in array.Keys) if (array[key] != null) foreach (Unit unit in array[key]) { String[] asm_lines = unit.Asm.Split(new Char[] { '\n' }); String[] hex_lines = unit.Hex.Split(new Char[] { '\n' }); String hex = ""; int comment = 0; foreach (String line in hex_lines) hex += (hex.Length > 0 ? "\t" : "") + ((comment = line.IndexOf(INIFile.INIComment)) < 0 ? line : line.Substring(0, comment)).TrimEnd(null); if (hex.Trim().Length == 0) continue; String variable = Patch.Keys[key] + " " + unit.ToString(); for (int i = 0; i < asm_lines.Length; i++) if (i == asm_lines.Length - 1 ? asm_lines[i].Trim().Length > 0 : true) comments.Add(new String[3] { section, variable, asm_lines[i] }); defmcp.Add(new INIFile.INIVariableDef(defmcp.Count.ToString(), section, variable, INIFile.INIVariableType.Dictionary, hex)); } if (patch.Removed != new Patch().Removed) defmcp.Add(new INIFile.INIVariableDef(defmcp.Count.ToString(), section, Patch.Keys[Patch.Key.Removed], INIFile.INIVariableType.Dictionary, patch.Removed.ToString())); } INIFile mcpFile = new INIFile(fileName, defmcp.ToArray(), Encoding.Default, true); mcpFile.initialize(); foreach (String[] triplet in comments) mcpFile.setCommentAbove(triplet[0], triplet[1], triplet[2]); return mcpFile.save(); }
private void LoadGraphicsSettings(bool reset, bool save) { INIFile iniFile = new INIFile (reset ? Statics.fn_nul : Statics.iniFileName, iniSettings, true); if (reset) iniFile.fileName = Statics.iniFileName; else bCalcRefresh_Click (null, null); if (save) { iniFile.initialize (); iniFile.save (); } loading = true; // Config cmbTipReadSpd.SelectedIndex = (int)iniFile.getKeyValue ("IipSpeed"); // Graphics cmbAntiAlias.SelectedIndex = (int)iniFile.getKeyValue ("AntiAlias"); cmbVWait.SelectedIndex = (int)iniFile.getKeyValue ("VWait"); cmbRefreshRate.SelectedIndex = cmbRefreshRate.FindStringExact (iniFile.getKeyValue ("Refresh").ToString ()); if (cmbRefreshRate.SelectedIndex == -1) cmbRefreshRate.SelectedIndex = 0; cmbAnisoLevel.SelectedIndex = (int)iniFile.getKeyValue ("AnisoLvl"); udLOD.Value = (decimal)iniFile.getKeyValue ("LODBias"); cmbFogMode.SelectedIndex = (int)iniFile.getKeyValue ("FogMode"); udFOV.Value = (decimal)iniFile.getKeyValue ("FOV"); cbFPSCounter.Checked = (iniFile.getKeyValue ("FPSCount") == 1); cbDisplayMessages.Checked = (iniFile.getKeyValue ("Messages") == 1); udMsgsTime.Value = (decimal)iniFile.getKeyValue ("MsgTime"); cbHWShader.Checked = (iniFile.getKeyValue ("HWShader") == 1); cmbSShotFormat.SelectedIndex = (int)iniFile.getKeyValue ("SSFormat"); tbSShotDir.Text = iniFile.getKeyString ("SSDir"); if (tbSShotDir.Text.Length == 0) bSSDirClear_Click (null, null); tbSShotName.Text = iniFile.getKeyString ("SSName"); udSShotNum.Value = (decimal)iniFile.getKeyValue ("SSNum"); // In-game cbDisableMGE.Checked = (iniFile.getKeyValue ("DisableMGE") == 1); cbDisableMWSE.Checked = (iniFile.getKeyValue ("DisableMWSE") == 1); udHDR.Value = (decimal)iniFile.getKeyValue ("HDRTime"); cbCam3rdPrsn.Checked = (iniFile.getKeyValue ("Cam3rdCustom") == 1); udCam3rdX.Value = (decimal)iniFile.getKeyValue ("Cam3rdX"); udCam3rdY.Value = (decimal)iniFile.getKeyValue ("Cam3rdY"); udCam3rdZ.Value = (decimal)iniFile.getKeyValue ("Cam3rdZ"); cbAutoCrosshair.Checked = (iniFile.getKeyValue ("AutoCrosshair") == 1); cbMenuCaching.Checked = (iniFile.getKeyValue ("MenuCaching") == 1); // Distant Land cbDLDistantLand.Checked = (iniFile.getKeyValue ("DistLand") == 1); cbDLDistantStatics.Checked = (iniFile.getKeyValue ("DistStat") == 1); udDLDrawDist.Value = (decimal)iniFile.getKeyValue ("DrawDist"); udDLDistNear.Value = (decimal)iniFile.getKeyValue ("EndNear"); udDLDistFar.Value = (decimal)iniFile.getKeyValue ("EndFar"); udDLDistVeryFar.Value = (int)iniFile.getKeyValue ("EndVFar"); udDLSizeFar.Value = (decimal)iniFile.getKeyValue ("SizeFar"); udDLSizeVeryFar.Value = (decimal)iniFile.getKeyValue ("SizeVFar"); cbDLReflLand.Checked = (iniFile.getKeyValue ("ReflLand") == 1); cbDLReflNStatics.Checked = (iniFile.getKeyValue ("ReflNear") == 1); cbDLReflInterior.Checked = (iniFile.getKeyValue ("ReflIntr") == 1); udDLFogAStart.Value = (decimal)iniFile.getKeyValue ("AboveBeg"); udDLFogAEnd.Value = (decimal)iniFile.getKeyValue ("AboveEnd"); udDLFogBStart.Value = (decimal)iniFile.getKeyValue ("BelowBeg"); udDLFogBEnd.Value = (decimal)iniFile.getKeyValue ("BelowEnd"); udDLFogIStart.Value = (decimal)iniFile.getKeyValue ("InterBeg"); udDLFogIEnd.Value = (decimal)iniFile.getKeyValue ("InterEnd"); cbDLSkyRefl.Checked = (iniFile.getKeyValue ("SkyRefl") == 1); cbDLDynRipples.Checked = (iniFile.getKeyValue ("DynRipples") == 1); cbDLReflBlur.Checked = (iniFile.getKeyValue ("ReflBlur") == 1); udDLFogExpMul.Value = (decimal)iniFile.getKeyValue ("DLExpMul"); cbDLFogExp.Checked = (iniFile.getKeyValue ("ExpFog") == 1); cbDLScattering.Checked = (iniFile.getKeyValue ("Scatter") == 1); udDLWtrWave.Value = (decimal)iniFile.getKeyValue ("WaveHght"); udDLWtrCaust.Value = (decimal)iniFile.getKeyValue ("Caustics"); int autoDistBy = (int)iniFile.getKeyValue ("AutoDistBy"); rbDLAutoByDrawDist.Checked = (autoDistBy == 1); rbDLAutoByAFogEnd.Checked = (autoDistBy == 2); cbDLAutoDist.Checked = (iniFile.getKeyValue ("AutoDist") == 1); cbDLSunShadows.Checked = (iniFile.getKeyValue ("SunShadows") == 1); cbPerPixelLighting.Checked = (iniFile.getKeyValue ("PPLighting") == 1); loading = false; }
private void bSave_Click(object sender, EventArgs e) { INIFile iniFile = new INIFile(Statics.iniFileName, iniWeatherSettings, true); iniFile.initialize(); foreach (Control ctl in this.Controls["gbWind"].Controls) { if (ctl.Name.Substring(0, 2) != "ud") continue; NumericUpDown ud = (NumericUpDown)ctl; iniFile.setKey(ud.Name.Substring(2), (double)ud.Value); } foreach (Control ctl in this.Controls["gbFogDay"].Controls) { if (ctl.Name.Substring(0, 2) != "ud") continue; NumericUpDown ud = (NumericUpDown)ctl; iniFile.setKey(ud.Name.Substring(2), (double)ud.Value); } foreach (Control ctl in this.Controls["gbFogOffsDay"].Controls) { if (ctl.Name.Substring(0, 2) != "ud") continue; NumericUpDown ud = (NumericUpDown)ctl; iniFile.setKey(ud.Name.Substring(2), (double)ud.Value); } iniFile.save(); Close(); }
private void LoadGraphicsSettings(bool reset, bool save) { INIFile iniFile = new INIFile (reset ? Statics.fn_nul : Statics.iniFileName, iniSettings, true); if (reset) iniFile.fileName = Statics.iniFileName; else bCalcRefresh_Click (null, null); if (save) { iniFile.initialize (); iniFile.save (); } loading = true; //Main cmbTipReadSpd.SelectedIndex = (int)iniFile.getKeyValue ("IipSpeed"); //Global Graphics cmbAntiAlias.SelectedIndex = (int)iniFile.getKeyValue ("AntiAlias"); cmbZBuffer.SelectedIndex = (int)iniFile.getKeyValue ("ZBuffer"); cmbVWait.SelectedIndex = (int)iniFile.getKeyValue ("VWait"); cmbRefreshRate.SelectedIndex = cmbRefreshRate.FindStringExact (iniFile.getKeyValue ("Refresh").ToString ()); if (cmbRefreshRate.SelectedIndex == -1) cmbRefreshRate.SelectedIndex = 0; //Render State cmbScaleFilter.SelectedIndex = (int)iniFile.getKeyValue ("ScaleFilt"); cmbMipFilter.SelectedIndex = (int)iniFile.getKeyValue ("MipFilt"); cmbAnisoLevel.SelectedIndex = (int)iniFile.getKeyValue ("AnisoLvl"); udLOD.Value = (int)iniFile.getKeyValue ("LODBias"); cmbFogMode.SelectedIndex = (int)iniFile.getKeyValue ("FogMode"); udZoom.Value = (decimal)iniFile.getKeyValue ("InitZoom"); udRotation.Value = (decimal)iniFile.getKeyValue ("ScrRot"); udFOV.Value = (decimal)iniFile.getKeyValue ("FOV"); cbFog.Checked = (iniFile.getKeyValue ("UseFog") == 1); cbFPSCounter.Checked = (iniFile.getKeyValue ("FPSCount") == 1); cbDisplayMessages.Checked = (iniFile.getKeyValue ("Messages") == 1); udMsgsTime.Value = (decimal)iniFile.getKeyValue ("MsgTime"); cbHWShader.Checked = (iniFile.getKeyValue ("HWShader") == 1); cbDisableShadersInMenu.Checked = (iniFile.getKeyValue("DisableShadersInMenu") == 1); cbAAFix.Checked = (iniFile.getKeyValue ("AAFix") == 1); cmbSShotFormat.SelectedIndex = (int)iniFile.getKeyValue ("SSFormat"); tbSShotDir.Text = iniFile.getKeyString ("SSDir"); if (tbSShotDir.Text.Length == 0) bSSDirClear_Click (null, null); tbSShotName.Text = iniFile.getKeyString ("SSName"); udSShotNum.Value = (decimal)iniFile.getKeyValue ("SSNum"); //Input cbLagFix.Checked = (iniFile.getKeyValue ("LagFix") == 1); //Misc cbDisableMWSE.Checked = (iniFile.getKeyValue ("DisableMWSE") == 1); cbDisableMWE.CheckState = (iniFile.getKeyValue("DisableMWE") == 1) ? CheckState.Checked : File.Exists(Statics.fn_mwedll) ? CheckState.Unchecked : CheckState.Indeterminate; cbDisableIntegration.Checked = (iniFile.getKeyValue("DisableIntegration") == 1); cbDisablePatch.Checked = (iniFile.getKeyValue("DisablePatch") == 1); cbZoomEffectsHUD.Checked = (iniFile.getKeyValue ("AffectUI") == 1); cbAspectZoom.Checked = (iniFile.getKeyValue ("AspectZoom") == 1); cbHook.Checked = (iniFile.getKeyValue ("HookTex") == 1); cbSetEffectVars.Checked = (iniFile.getKeyValue ("ShaderVars") == 1); cbHDR.Checked = (iniFile.getKeyValue ("UseHDR") == 1); udHDR.Value = (decimal)iniFile.getKeyValue ("HDRTime"); cbFPSConst.Checked = (iniFile.getKeyValue ("KeepFPS") == 1); udFPSDes.Value = (int)iniFile.getKeyValue ("FPSDesired"); udFPSTol.Value = (int)iniFile.getKeyValue ("FPSToler"); udMaxView.Value = (int)iniFile.getKeyValue ("MaxMWView"); udMinView.Value = (int)iniFile.getKeyValue ("MinMWView"); cbBindAI.Checked = (iniFile.getKeyValue ("AIToMWView") == 1); cbIdle.Checked = (iniFile.getKeyValue ("CPUIdle") == 1); udIdle.Value = (int)iniFile.getKeyValue ("IdleTime"); cbShaderDepth.Checked = (iniFile.getKeyValue ("ShaderDepth") == 1); cbCam3rdPrsn.Checked = (iniFile.getKeyValue ("Cam3rdCustom") == 1); udCam3rdX.Value = (decimal)iniFile.getKeyValue ("Cam3rdX"); udCam3rdY.Value = (decimal)iniFile.getKeyValue ("Cam3rdY"); udCam3rdZ.Value = (decimal)iniFile.getKeyValue ("Cam3rdZ"); //Distant Land cbDLDistantLand.Checked = (iniFile.getKeyValue ("DistLand") == 1); List<string> list = new List<string> (DLOptions.Keys); foreach (string key in list) DLOptions [key] = (iniFile.getKeyValue (key) == 1); cbDLDistantStatics.Checked = (iniFile.getKeyValue ("DistStat") == 1); udDLDrawDist.Value = (decimal)iniFile.getKeyValue ("DrawDist"); //udDLBlur.Value = (int)iniFile.getKeyValue ("DistBlur"); //removed udDLDistNear.Value = (decimal)iniFile.getKeyValue ("EndNear"); udDLDistFar.Value = (decimal)iniFile.getKeyValue ("EndFar"); udDLDistVeryFar.Value = (int)iniFile.getKeyValue ("EndVFar"); udDLSizeFar.Value = (decimal)iniFile.getKeyValue ("SizeFar"); udDLSizeVeryFar.Value = (decimal)iniFile.getKeyValue ("SizeVFar"); cbDLReflLand.Checked = (iniFile.getKeyValue ("ReflLand") == 1); cbDLReflNStatics.Checked = (iniFile.getKeyValue ("ReflNear") == 1); cbDLReflFStatics.Checked = (iniFile.getKeyValue ("ReflFar") == 1); udDLFogAStart.Value = (decimal)iniFile.getKeyValue ("AboveBeg"); udDLFogAEnd.Value = (decimal)iniFile.getKeyValue ("AboveEnd"); udDLFogBStart.Value = (decimal)iniFile.getKeyValue ("BelowBeg"); udDLFogBEnd.Value = (decimal)iniFile.getKeyValue ("BelowEnd"); udDLFogIStart.Value = (decimal)iniFile.getKeyValue ("InterBeg"); udDLFogIEnd.Value = (decimal)iniFile.getKeyValue ("InterEnd"); cbDLSkyRefl.Checked = (iniFile.getKeyValue ("SkyRefl") == 1); cbDLDynRipples.Checked = (iniFile.getKeyValue ("DynRipples") == 1); rbDLSM30.Checked = (iniFile.getKeyValue ("DLShader") == 3); cbDLReflBlur.Checked = (iniFile.getKeyValue ("ReflBlur") == 1); udDLFogExpMul.Value = (decimal)iniFile.getKeyValue ("DLExpMul"); cbDLFogExp.Checked = (iniFile.getKeyValue ("ExpFog") == 1); udDLWtrWave.Value = (decimal)iniFile.getKeyValue ("WaveHght"); udDLWtrCaust.Value = (decimal)iniFile.getKeyValue ("Caustics"); int autoDistBy = (int)iniFile.getKeyValue ("AutoDistBy"); rbDLAutoByDrawDist.Checked = (autoDistBy == 1); rbDLAutoByAFogEnd.Checked = (autoDistBy == 2); cbDLAutoDist.Checked = (iniFile.getKeyValue ("AutoDist") == 1); //MGE disabled cbDisableMGE.Checked = (iniFile.getKeyValue ("DisableMGE") == 1); //Tools PatchTreeSize.Width = (int)iniFile.getKeyValue("PTreeWidth"); PatchTreeSize.Height = (int)iniFile.getKeyValue("PTreeHeight"); PatchEditorSize.Width = (int)iniFile.getKeyValue("PEditorWidth"); PatchEditorSize.Height = (int)iniFile.getKeyValue("PEditorHeight"); PatchEditorBars.Width = (int)iniFile.getKeyValue("PEditorBarW"); PatchEditorBars.Height = (int)iniFile.getKeyValue("PEditorBarH"); loading = false; }
/* Configuration methods */ // loading all settings private void LoadSettings() { INIFile iniFile = new INIFile(Statics.iniFileName, iniDLWizardVars, true); configure = !iniFile.hasSection(iniDLWizardSets); if (configure) { iniFile.initialize(); iniFile.save(); } pluginDirs = new List<string>(iniFile.getSectList(iniDLWizardPlugDirs)); pluginDirs.Sort(); string lastdir = Statics.fn_datafiles; for (int i = 0; i < pluginDirs.Count; i++ ) { if (String.Compare(Path.GetFullPath(pluginDirs[i]), Path.GetFullPath(lastdir), true, Statics.Culture) == 0 || String.Compare(Path.GetFullPath(pluginDirs[i]), Path.GetFullPath(Statics.fn_statics), true, Statics.Culture) == 0 || String.Compare(Path.GetFullPath(pluginDirs[i]), Path.GetFullPath(Statics.fn_datafiles), true, Statics.Culture) == 0) pluginDirs.RemoveAt(i--); else lastdir = pluginDirs[i]; } pluginDirs.Insert(0, Statics.fn_statics); preselectedPlugins = iniFile.getSectList(iniDLWizardPlugs); pluginList = new MWPlugins(Statics.fn_datafiles, pluginDirs, preselectedPlugins); switch ((int)iniFile.getKeyValue("PlugSort")) { case 0: rbPlugsName.Checked = true; break; case 1: rbPlugsType.Checked = true; break; case 2: rbPlugsLoad.Checked = true; break; } pluginsSort(null, null); cmbTexWorldResolution.SelectedIndex = (int)iniFile.getKeyValue("TexRes"); cmbTexWorldNormalRes.SelectedIndex = (int)iniFile.getKeyValue("NormRes"); cbTexTwoStep.Checked = (iniFile.getKeyValue("Tex2Step") == 1); cmbMeshWorldDetail.SelectedIndex = (int)iniFile.getKeyValue("WorldMesh"); udStatMinSize.Value = (int)iniFile.getKeyValue("MinStat"); udStatGrassDensity.Value = (int)iniFile.getKeyValue("GrassDens"); cmbStatSimplifyMeshes.SelectedIndex = (int)iniFile.getKeyValue("StatMesh"); cmbStatSkipMipLevels.SelectedIndex = (int)iniFile.getKeyValue("SkipMip"); cbStatLowQualTextures.Checked = (iniFile.getKeyValue("LowQualTex") == 1); cbStatActivators.Checked = (iniFile.getKeyValue("Activators") == 1); cbStatIncludeMisc.Checked = (iniFile.getKeyValue("MiscObj") == 1); cbStatOldSimplification.Checked = (iniFile.getKeyValue("OldSimply") == 1); cbStatOverrideList.Checked = (iniFile.getKeyValue("UseStatOvr") == 1); cbStatIntExt.Checked = (iniFile.getKeyValue("StatIntExt") == 1); cbStatIntWater.Checked = (iniFile.getKeyValue("StatIntWater") == 1); lbStatOverrideList.Items.Clear(); lbStatOverrideList.Items.AddRange(iniFile.getSectList(iniDLWizardStatOvr)); lStatOverrideList.Enabled = (lbStatOverrideList.Items.Count == 0); }