private void presetOptions_Click(object sender, EventArgs e) { if (sender == presetSaveButton) { RunPreset preset; if (newPreset) { preset = new RunPreset(); presets.Add(preset); availablePresets.Add(preset); } else { preset = getSelectedPreset(); } preset.name = (presetNameText.EditValue != null ? presetNameText.EditValue.ToString() : ""); switch (presetRunModeCombo.EditValue.ToString()) { case "Global": preset.engine = ""; preset.game = ""; preset.mod = ""; break; case "Current engine only": preset.engine = Engine.ToString(launcher.GetCurrentGame().engine); preset.game = ""; preset.mod = ""; break; case "Current game only": preset.engine = Engine.ToString(launcher.GetCurrentGame().engine); preset.game = launcher.GetCurrentGame().name; preset.mod = ""; break; case "Current mod only": preset.engine = Engine.ToString(launcher.GetCurrentGame().engine); preset.game = launcher.GetCurrentGame().name; preset.mod = new DirectoryInfo(launcher.GetCurrentMod().installPath).Name; break; } preset.runMode = RunMode.FromString(presetRunModeCombo.EditValue.ToString()); preset.exePath = (presetExecutableText.EditValue != null && presetExecutableText.EditValue.ToString() != "" ? presetExecutableText.EditValue.ToString() : ""); preset.command = (presetCommandText.EditValue.ToString() != null ? presetCommandText.EditValue.ToString() : ""); updatePresetCombo(); presetCombo.EditValue = preset.name; SavePresets(); } if (sender == presetCancelButton) { } endEdit(); }
private void presetActions_Click(object sender, EventArgs e) { if (sender == addButton) { newPreset = true; presetNameText.EditValue = ""; presetRunModeCombo.EditValue = "Windowed"; presetCoverageCombo.EditValue = "Global"; presetExecutableText.EditValue = ""; presetCommandText.EditValue = ""; startEdit(); } if (sender == editButton) { newPreset = false; RunPreset currentPreset = getSelectedPreset(); presetNameText.EditValue = currentPreset.name; if (currentPreset.mod == new DirectoryInfo(launcher.GetCurrentMod().installPath).Name) { presetCoverageCombo.EditValue = "Current mod only"; } else if (currentPreset.game == launcher.GetCurrentGame().name) { presetCoverageCombo.EditValue = "Current game only"; } else if (currentPreset.engine == Engine.ToString(launcher.GetCurrentGame().engine)) { presetCoverageCombo.EditValue = "Current engine only"; } else { presetCoverageCombo.EditValue = "Global"; } presetCommandText.EditValue = currentPreset.command; presetRunModeCombo.EditValue = RunMode.ToString(currentPreset.runMode); presetExecutableText.EditValue = (currentPreset.exePath != string.Empty ? currentPreset.exePath : ""); startEdit(); } if (sender == deleteButton) { RunPreset preset = getSelectedPreset(); if (preset != null) { presets.Remove(preset); availablePresets.Remove(preset); updatePresetCombo(); SavePresets(); } } }
private void Run(RunPreset runPreset, string command) { instance = new Instance(launcher, panel1); updateBackground(); Application.DoEvents(); instance.Start(runPreset, command); if (runPreset.runMode == RunMode.WINDOWED && (launcher.GetCurrentGame().engine == Engine.SOURCE || launcher.GetCurrentGame().engine == Engine.SOURCE2)) { FormBorderStyle = FormBorderStyle.Fixed3D; MaximizeBox = false; } modStarted(); }
private void menuModdingRun_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { // Run if (e.Item == toolsRun) { Run(RunMode.DEFAULT, ""); } // Run fullscreen if (e.Item == menuModdingRunFullscreen || e.Item == toolsRunPopupRunFullscreen) { Run(RunMode.FULLSCREEN, ""); } // Run Windowed else if (e.Item == menuModdingRunWindowed || e.Item == toolsRunPopupRunWindowed) { Run(RunMode.WINDOWED, ""); } // Run VR if (e.Item == menuModdingRunVR || e.Item == toolsRunPopupRunVR) { Run(RunMode.VR, ""); } // Expert mode else if (e.Item == menuModdingRunExpert || e.Item == toolsRunPopupExpert) { RunDialog dialog = new RunDialog(launcher); if (dialog.ShowDialog() == DialogResult.OK) { string arguments = dialog.commands; RunPreset runPreset = dialog.runPreset; Run(runPreset, arguments); } } }
private void LoadPresets() { if (!File.Exists(PRESET_PATH) && File.Exists(PRESET_PATH.Replace(".cfg", "_default.cfg"))) { File.Copy(PRESET_PATH.Replace(".cfg", "_default.cfg"), PRESET_PATH); } SourceSDK.KeyValue root = SourceSDK.KeyValue.readChunkfile(PRESET_PATH); presets = new List <RunPreset>(); availablePresets = new List <RunPreset>(); presetCombo.Properties.Items.Clear(); foreach (SourceSDK.KeyValue kv in root.getChildren()) { RunPreset preset = new RunPreset(); preset.name = (kv.getValue("name") != string.Empty ? kv.getValue("name") : kv.getKey()); preset.engine = kv.getValue("engine"); preset.game = kv.getValue("game"); preset.mod = kv.getValue("mod"); preset.exePath = kv.getValue("exe"); preset.command = kv.getValue("command"); preset.runMode = RunMode.FromString(kv.findChildByKey("runmode").getValue()); presets.Add(preset); if ( (preset.mod == string.Empty || preset.mod == new DirectoryInfo(launcher.GetCurrentMod().installPath).Name) && (preset.game == string.Empty || preset.game == launcher.GetCurrentGame().name) && (preset.engine == string.Empty || preset.engine == Engine.ToString(launcher.GetCurrentGame().engine)) ) { availablePresets.Add(preset); } } updatePresetCombo(); }
private void Run(int runMode, string command) { RunPreset preset = new RunPreset(runMode); Run(preset, command); }
private void okButton_Click(object sender, EventArgs e) { this.runPreset = getSelectedPreset(); this.commands = (commandText.EditValue != null ? commandText.EditValue.ToString() : ""); }