public static void Main(string[] sargs) { Thread.CurrentThread.CurrentUICulture = Culture; CommandArgs args = new CommandArgs (sargs); if (args.styles) Application.EnableVisualStyles (); // Damn .NET text rendering Application.SetCompatibleTextRenderingDefault(false); Directory.SetCurrentDirectory (System.IO.Path.GetDirectoryName (Application.ExecutablePath)); Localizations = new LocalizationInterface (); try { string [] langfiles = Directory.GetFiles ("MGE3", "*.lng"); foreach (string langfile in langfiles) { Localizations.Add (langfile); } } catch { }; string language = "English (default)"; bool autoLanguage = true; try { INIFile MGEini = new INIFile (iniFileName, new INIFile.INIVariableDef [] { INIFile.iniDefEmpty, MainForm.iniLanguage, MainForm.iniAutoLang }); language = MGEini.getKeyString ("Language"); autoLanguage = (MGEini.getKeyValue ("AutoLang") == 1); } catch { } Localizations.Current = language; Localizations.ApplyStrings("", strings); if (args.mutex && !MutexCheck.PerformCheck ()) { MessageBox.Show (strings ["MGEguiRunning"], strings ["Error"]); return; } Process [] morrowind = Process.GetProcessesByName ("Morrowind"); foreach (Process p in morrowind) { MessageBox.Show (strings ["MWRunning"], strings ["Error"]); return; } if (!File.Exists ("./morrowind.exe") || !File.Exists ("./morrowind.ini") || !Directory.Exists ("data files")) { MessageBox.Show (strings ["NotMWDir"], strings ["Error"]); return; } if (!Directory.Exists ("MGE3") || !File.Exists ("./MGE3/MGEfuncs.dll") || !File.Exists ("./d3d8.dll") || !File.Exists ("./dinput8.dll")) { MessageBox.Show (strings ["MGEMissing"], strings ["Error"]); return; } //Morrowind version info try { FileVersionInfo MorrowVersion = FileVersionInfo.GetVersionInfo ("Morrowind.exe"); if (MorrowVersion.FileMajorPart != 1 || MorrowVersion.FileMinorPart < 6) { MessageBox.Show (strings ["MWIncompat"], strings ["Error"]); return; } } catch { MessageBox.Show (strings ["MWCorrupt"], strings ["Error"]); return; } runDir = System.Windows.Forms.Application.StartupPath; //check if MW registry keys exist if (Registry.LocalMachine.OpenSubKey (reg_mw) == null) { MessageBox.Show (strings ["MWRegistry"], strings ["Error"]); return; } //Create some structures for (int i = 0; i < MACROS; i++) { Macros [i] = new Macro (); } for (int i = 0; i < TRIGGERS; i++) { Triggers [i] = new Trigger (); } DXMain.GetDeviceCaps (); mf = new MainForm (autoLanguage); Application.Run (mf); }
public static void Main(string[] sargs) { Thread.CurrentThread.CurrentUICulture = Culture; CommandArgs args = new CommandArgs (sargs); if (args.styles) Application.EnableVisualStyles (); // Damn .NET text rendering Application.SetCompatibleTextRenderingDefault(false); Directory.SetCurrentDirectory (System.IO.Path.GetDirectoryName (Application.ExecutablePath)); Localizations = new LocalizationInterface (); try { string [] langfiles = Directory.GetFiles ("MGE3", "*.lng"); foreach (string langfile in langfiles) { Localizations.Add (langfile); } } catch { }; Localizations.Add(new LocalizationInterface.Localization((Form)null)); // Adds truncated variant of default localization. String language = DefaultLocalization.Language; bool autoLanguage = true; try { INIFile MGEini = new INIFile (iniFileName, new INIFile.INIVariableDef [] { INIFile.iniDefEmpty, MainForm.iniLanguage, MainForm.iniAutoLang }); language = MGEini.getKeyString ("Language"); autoLanguage = (MGEini.getKeyValue ("AutoLang") == 1); } catch { } Localizations.Current = language; Localizations.ApplyStrings("", strings); if (args.mutex && !MutexCheck.PerformCheck ()) { MessageBox.Show (strings ["MGEguiRunning"], strings ["Error"]); return; } Process [] morrowind = Process.GetProcessesByName ("Morrowind"); foreach (Process p in morrowind) { MessageBox.Show (strings ["MWRunning"], strings ["Error"]); return; } if (!File.Exists ("./morrowind.exe") || !File.Exists ("./morrowind.ini") || !Directory.Exists ("data files")) { MessageBox.Show (strings ["NotMWDir"], strings ["Error"]); return; } if (!Directory.Exists ("MGE3") || !File.Exists ("./MGE3/MGEfuncs.dll") || !File.Exists ("./d3d8.dll") || !File.Exists ("./dinput8.dll")) { MessageBox.Show (strings ["MGEMissing"], strings ["Error"]); return; } //Morrowind version info try { FileVersionInfo MorrowVersion = FileVersionInfo.GetVersionInfo ("Morrowind.exe"); if (MorrowVersion.ProductPrivatePart != 722 && MorrowVersion.ProductPrivatePart != 1029 && MorrowVersion.ProductPrivatePart != 1875 && MorrowVersion.ProductPrivatePart != 1820) { MessageBox.Show (strings ["MWIncompat"], strings ["Error"]); return; } } catch { MessageBox.Show (strings ["MWCorrupt"], strings ["Error"]); return; } //Check for dsound.dll if (File.Exists ("dsound.dll") && new System.IO.FileInfo ("dsound.dll").Length == 16384) { try { File.Delete ("dsound.dll"); } catch { MessageBox.Show (strings ["DSound"], strings ["Error"]); return; } } runDir = System.Windows.Forms.Application.StartupPath; //check if MW registry keys exist RegistryKey key = Statics.reg_key_bethesda.OpenSubKey(Statics.reg_morrowind); if (key != null) { key.Close(); key = null; } else { MessageBox.Show (strings ["MWRegistry"], strings ["Error"]); return; } //mendres: Check if MGE needs administrator privileges. try { key = Statics.reg_key_bethesda.OpenSubKey(Statics.reg_morrowind, true); } catch (System.Security.SecurityException) { MessageBox.Show(strings["MgeAccess"], strings["Error"]); return; } if (key != null) { key.Close(); key = null; } //Create the data files directories MGE uses if (!Directory.Exists (@"data files\shaders")) { Directory.CreateDirectory (@"data files\shaders"); } if (!Directory.Exists (@"data files\MGE meshes")) { Directory.CreateDirectory (@"data files\MGE meshes"); } if (!Directory.Exists (@"data files\Textures\MGE")) { Directory.CreateDirectory (@"data files\Textures\MGE"); } if (!Directory.Exists (@"data files\MGE videos")) { Directory.CreateDirectory (@"data files\MGE videos"); } if (!Directory.Exists (@"data files\shaders\default")) { Directory.CreateDirectory (@"data files\shaders\default"); } if (!Directory.Exists (@"data files\shaders\water")) { Directory.CreateDirectory (@"data files\shaders\water"); } //Create some structures for (int i = 0; i < MACROS; i++) { Macros [i] = new Macro (); } for (int i = 0; i < TRIGGERS; i++) { Triggers [i] = new Trigger (); } DXMain.GetDeviceCaps (); bool GUIchecker = !lightversion; while (GUIchecker != lightversion) { GUIchecker = lightversion; if (lightversion) { mfl = new MainFormLight(autoLanguage); Application.Run(mfl); } else { mf = new MainForm (autoLanguage); Application.Run (mf); } } }
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; }
public Localization(string fileName) { FileName = fileName; langFile = new INIFile (fileName, langINI); Language = langFile.getKeyString (entLang); Translator = langFile.getKeyString (entTtor); }
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; }
public Patch(INIFile mcpFile, String section) { Dictionary<String, String> keys = mcpFile.getSectionKeys(section); foreach (String sKey in keys.Keys) { String value = mcpFile.getKeyString(section, sKey).Trim(); bool oKey = sKey.StartsWith(Keys[Key.Original], StringComparison.OrdinalIgnoreCase); bool pKey = sKey.StartsWith(Keys[Key.Patch], StringComparison.OrdinalIgnoreCase); bool aKey = sKey.StartsWith(Keys[Key.Attach], StringComparison.OrdinalIgnoreCase); bool dKey = sKey.StartsWith(Keys[Key.Description], StringComparison.OrdinalIgnoreCase); if (aKey || oKey || pKey || dKey) { value = value.Replace("\t", "\n"); String comment = mcpFile.getCommentAbove(section, sKey); Unit[] units = oKey ? Original : pKey ? Patched : aKey ? Attach : Description; List<Unit> array = units != null ? new List<Unit>(units) : new List<Unit>(); String tag = sKey.Substring(Keys[oKey ? Key.Original : pKey ? Key.Patch : aKey ? Key.Attach : Key.Description].Length).Trim(); array.Add(aKey || dKey ? new Unit(tag, 0, value, comment) : new Unit(Convert.ToUInt32(tag, 16), value, comment)); if (oKey) Original = array.ToArray(); else if (pKey) Patched = array.ToArray(); else if (aKey) Attach = array.ToArray(); else Description = array.ToArray(); continue; } foreach (Key key in Keys.Keys) { if (sKey.ToLower() == Keys[key].ToLower()) { NumberFormatInfo provider = new NumberFormatInfo(); provider.NumberDecimalSeparator = "."; switch (key) { case Key.Checked: { try { Checked = Convert.ToBoolean(value.ToLower()); } catch { } break; } case Key.Parent: { Parent = value; break; } case Key.Version: { try { version = Math.Abs((float)Convert.ToDouble(value, provider)); } catch { } break; } case Key.FileVersion: { try { fileVersion = Math.Abs(Convert.ToInt32(value)); } catch { } break; } case Key.Author: { Author = value; break; } case Key.Removed: { try { Removed = Convert.ToBoolean(value.ToLower()); } catch { } break; } case Key.Expanded: { try { Expanded = Convert.ToBoolean(value.ToLower()); } catch { } break; } } break; } } } }