private void modListView_ItemCheck(object sender, ItemCheckEventArgs e) { if (suppressEvent) { return; } codes = new List <Code>(mainCodes.Codes); string modDir = Path.Combine(Environment.CurrentDirectory, "mods"); List <string> modlist = new List <string>(); foreach (ListViewItem item in modListView.CheckedItems) { modlist.Add((string)item.Tag); } if (e.NewValue == CheckState.Unchecked) { modlist.Remove((string)modListView.Items[e.Index].Tag); } else { modlist.Add((string)modListView.Items[e.Index].Tag); } foreach (string mod in modlist) { if (mods.ContainsKey(mod)) { SKCModInfo inf = mods[mod]; if (!string.IsNullOrEmpty(inf.Codes)) { codes.AddRange(CodeList.Load(Path.Combine(Path.Combine(modDir, mod), inf.Codes)).Codes); } } } loaderini.EnabledCodes = new List <string>(loaderini.EnabledCodes.Where(a => codes.Any(c => c.Name == a))); foreach (Code item in codes.Where(a => a.Required && !loaderini.EnabledCodes.Contains(a.Name))) { loaderini.EnabledCodes.Add(item.Name); } codesCheckedListBox.BeginUpdate(); codesCheckedListBox.Items.Clear(); foreach (Code item in codes) { codesCheckedListBox.Items.Add(item.Name, loaderini.EnabledCodes.Contains(item.Name)); } codesCheckedListBox.EndUpdate(); }
public Instrument() { InitializeComponent(); comboModeSelect.Items.Add(new InstrumentModeValue(InstrumentMode.Send)); comboModeSelect.Items.Add(new InstrumentModeValue(InstrumentMode.Receive)); AllCodes = CodeList.Load(Properties.Settings.Default.CodeListFileName); foreach (CodeList list in AllCodes) { comboListSelect.Items.Add(list); } comboListSelect.SelectedIndex = 0; bellPlayer = new SoundPlayer(Properties.Settings.Default.BellSoundFileName); RecentTapEvents = new List <TapEvent>(); _random = new Random(); comboModeSelect.SelectedIndex = 0; }
private void MainForm_Load(object sender, EventArgs e) { if (!Debugger.IsAttached) { Environment.CurrentDirectory = Application.StartupPath; } SetDoubleBuffered(modListView, true); loaderini = File.Exists(loaderinipath) ? IniSerializer.Deserialize <ManiaLoaderInfo>(loaderinipath) : new ManiaLoaderInfo(); try { mainCodes = CodeList.Load(codexmlpath); } catch { mainCodes = new CodeList() { Codes = new List <Code>() }; } LoadModList(); enableDebugConsole.Checked = loaderini.EnableConsole; startingScene.SelectedIndex = loaderini.StartingScene; if (File.Exists(datadllpath)) { installed = true; installButton.Text = "Uninstall loader"; using (MD5 md5 = MD5.Create()) { byte[] hash1 = md5.ComputeHash(File.ReadAllBytes(loaderdllpath)); byte[] hash2 = md5.ComputeHash(File.ReadAllBytes(datadllpath)); if (hash1.SequenceEqual(hash2)) { return; } } DialogResult result = MessageBox.Show(this, "Installed loader DLL differs from copy in mods folder." + "\n\nDo you want to overwrite the installed copy?", Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { File.Copy(loaderdllpath, datadllpath, true); } } }
private void MainForm_Load(object sender, EventArgs e) { // Try to use TLS 1.2 try { ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; } catch { } if (!Debugger.IsAttached) { Environment.CurrentDirectory = Application.StartupPath; } SetDoubleBuffered(modListView, true); loaderini = File.Exists(loaderinipath) ? IniSerializer.Deserialize <LoaderInfo>(loaderinipath) : new LoaderInfo(); try { if (File.Exists(codelstpath)) { mainCodes = CodeList.Load(codelstpath); } else if (File.Exists(codexmlpath)) { mainCodes = CodeList.Load(codexmlpath); } else { mainCodes = new CodeList(); } } catch (Exception ex) { MessageBox.Show(this, $"Error loading code list: {ex.Message}", "Sonic CD Steam Mod Manager", MessageBoxButtons.OK, MessageBoxIcon.Warning); mainCodes = new CodeList(); } LoadModList(); checkUpdateStartup.Checked = loaderini.UpdateCheck; checkUpdateModsStartup.Checked = loaderini.ModUpdateCheck; comboUpdateFrequency.SelectedIndex = (int)loaderini.UpdateUnit; numericUpdateFrequency.Value = loaderini.UpdateFrequency; }
private void MainForm_Load(object sender, EventArgs e) { // Try to use TLS 1.2 try { ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; } catch { } if (!Debugger.IsAttached) { Environment.CurrentDirectory = Application.StartupPath; } SetDoubleBuffered(modListView, true); loaderini = File.Exists(loaderinipath) ? IniSerializer.Deserialize <SKCLoaderInfo>(loaderinipath) : new SKCLoaderInfo(); try { if (File.Exists(codelstpath)) { mainCodes = CodeList.Load(codelstpath); } else if (File.Exists(codexmlpath)) { mainCodes = CodeList.Load(codexmlpath); } else { mainCodes = new CodeList(); } } catch (Exception ex) { MessageBox.Show(this, $"Error loading code list: {ex.Message}", "S&KC Mod Loader", MessageBoxButtons.OK, MessageBoxIcon.Warning); mainCodes = new CodeList(); } LoadModList(); consoleCheckBox.Checked = loaderini.DebugConsole; fileCheckBox.Checked = loaderini.DebugFile; switch (loaderini.Game) { case Game.S3K: gameS3K.Checked = true; break; case Game.SK: gameSK.Checked = true; break; case Game.S3: gameS3.Checked = true; break; } switch (loaderini.Palette) { case PaletteSetting.Accurate: paletteAccurateButton.Checked = true; break; case PaletteSetting.Linear: paletteLinearButton.Checked = true; break; case PaletteSetting.SKC: paletteSKCButton.Checked = true; break; case PaletteSetting.Old: paletteOldButton.Checked = true; break; } checkUpdateStartup.Checked = loaderini.UpdateCheck; checkUpdateModsStartup.Checked = loaderini.ModUpdateCheck; comboUpdateFrequency.SelectedIndex = (int)loaderini.UpdateUnit; numericUpdateFrequency.Value = loaderini.UpdateFrequency; }
private void LoadModList() { modTopButton.Enabled = modUpButton.Enabled = modDownButton.Enabled = modBottomButton.Enabled = configureModButton.Enabled = false; modDescription.Text = "Description: No mod selected."; modListView.Items.Clear(); mods = new Dictionary <string, SKCModInfo>(); codes = new List <Code>(mainCodes.Codes); string modDir = Path.Combine(Environment.CurrentDirectory, "mods"); foreach (string filename in ModInfo.GetModFiles(new DirectoryInfo(modDir))) { mods.Add((Path.GetDirectoryName(filename) ?? string.Empty).Substring(modDir.Length + 1), IniSerializer.Deserialize <SKCModInfo>(filename)); } modListView.BeginUpdate(); foreach (string mod in new List <string>(loaderini.Mods)) { if (mods.ContainsKey(mod)) { SKCModInfo inf = mods[mod]; suppressEvent = true; modListView.Items.Add(new ListViewItem(new[] { inf.Name, inf.Author, inf.Version }) { Checked = true, Tag = mod }); suppressEvent = false; if (!string.IsNullOrEmpty(inf.Codes)) { codes.AddRange(CodeList.Load(Path.Combine(Path.Combine(modDir, mod), inf.Codes)).Codes); } } else { MessageBox.Show(this, "Mod \"" + mod + "\" could not be found.\n\nThis mod will be removed from the list.", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); loaderini.Mods.Remove(mod); } } foreach (KeyValuePair <string, SKCModInfo> inf in mods.OrderBy(x => x.Value.Name)) { if (!loaderini.Mods.Contains(inf.Key)) { modListView.Items.Add(new ListViewItem(new[] { inf.Value.Name, inf.Value.Author, inf.Value.Version }) { Tag = inf.Key }); } } modListView.EndUpdate(); loaderini.EnabledCodes = new List <string>(loaderini.EnabledCodes.Where(a => codes.Any(c => c.Name == a))); foreach (Code item in codes.Where(a => a.Required && !loaderini.EnabledCodes.Contains(a.Name))) { loaderini.EnabledCodes.Add(item.Name); } codesCheckedListBox.BeginUpdate(); codesCheckedListBox.Items.Clear(); foreach (Code item in codes) { codesCheckedListBox.Items.Add(item.Name, loaderini.EnabledCodes.Contains(item.Name)); } codesCheckedListBox.EndUpdate(); }
private void MainForm_Load(object sender, EventArgs e) { if (!Debugger.IsAttached) { Environment.CurrentDirectory = Application.StartupPath; } SetDoubleBuffered(modListView, true); loaderini = File.Exists(loaderinipath) ? IniSerializer.Deserialize <SonicRLoaderInfo>(loaderinipath) : new SonicRLoaderInfo(); try { mainCodes = CodeList.Load(codexmlpath); } catch { mainCodes = new CodeList() { Codes = new List <Code>() }; } LoadModList(); debugConsoleCheckBox.Checked = loaderini.DebugConsole; debugFileCheckBox.Checked = loaderini.DebugFile; windowedCheckBox.Checked = loaderini.Windowed; horizontalResolution.Enabled = !loaderini.ForceAspectRatio; horizontalResolution.Value = Math.Max(horizontalResolution.Minimum, Math.Min(horizontalResolution.Maximum, loaderini.HorizontalResolution)); verticalResolution.Value = Math.Max(verticalResolution.Minimum, Math.Min(verticalResolution.Maximum, loaderini.VerticalResolution)); suppressEvent = true; forceAspectRatioCheckBox.Checked = loaderini.ForceAspectRatio; suppressEvent = false; windowedFullscreenCheckBox.Checked = loaderini.WindowedFullscreen; stretchFullscreenCheckBox.Checked = loaderini.StretchFullscreen; customWindowSizeCheckBox.Checked = windowHeight.Enabled = maintainWindowAspectRatioCheckBox.Enabled = loaderini.CustomWindowSize; windowWidth.Enabled = loaderini.CustomWindowSize && !loaderini.MaintainWindowAspectRatio; Rectangle rect = Screen.PrimaryScreen.Bounds; resolutionPresets[5] = rect.Size; resolutionPresets[6] = new Size(rect.Width / 2, rect.Height / 2); resolutionPresets[7] = new Size(rect.Width * 2, rect.Height * 2); foreach (Screen screen in Screen.AllScreens) { rect = Rectangle.Union(rect, screen.Bounds); } windowWidth.Maximum = rect.Width; windowWidth.Value = Math.Max(windowWidth.Minimum, Math.Min(rect.Width, loaderini.WindowWidth)); windowHeight.Maximum = rect.Height; windowHeight.Value = Math.Max(windowHeight.Minimum, Math.Min(rect.Height, loaderini.WindowHeight)); suppressEvent = true; maintainWindowAspectRatioCheckBox.Checked = loaderini.MaintainWindowAspectRatio; suppressEvent = false; if (File.Exists(datadllpath)) { installed = true; installButton.Text = "Uninstall loader"; using (MD5 md5 = MD5.Create()) { byte[] hash1 = md5.ComputeHash(File.ReadAllBytes(loaderdllpath)); byte[] hash2 = md5.ComputeHash(File.ReadAllBytes(datadllpath)); if (hash1.SequenceEqual(hash2)) { return; } } DialogResult result = MessageBox.Show(this, "Installed loader DLL differs from copy in mods folder." + "\n\nDo you want to overwrite the installed copy?", Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { File.Copy(loaderdllpath, datadllpath, true); } } }