From feaeb6251357a1d6db03523325ea278c0037c7c2 Mon Sep 17 00:00:00 2001 From: FriendlyAgent Date: Sat, 17 Oct 2020 23:59:29 +0200 Subject: [PATCH] Added settings --- .../Among Us Config Editor.csproj | 5 +- Among Us Config Editor/Languages.cs | 11 ++ Among Us Config Editor/Main.Designer.cs | 180 +++++++++++++++++- Among Us Config Editor/Main.cs | 79 +++++++- Among Us Config Editor/Settings.cs | 108 ++++++++++- 5 files changed, 368 insertions(+), 15 deletions(-) create mode 100644 Among Us Config Editor/Languages.cs diff --git a/Among Us Config Editor/Among Us Config Editor.csproj b/Among Us Config Editor/Among Us Config Editor.csproj index eca9795..36a25e7 100644 --- a/Among Us Config Editor/Among Us Config Editor.csproj +++ b/Among Us Config Editor/Among Us Config Editor.csproj @@ -8,8 +8,9 @@ amongus.ico https://github.com/FriendlyAgent/Among-Us-Config-Editor https://github.com/FriendlyAgent/Among-Us-Config-Editor - 1.0.0.2 - 1.0.0.2 + 1.0.0.3 + 1.0.0.3 + 1.0.3 diff --git a/Among Us Config Editor/Languages.cs b/Among Us Config Editor/Languages.cs new file mode 100644 index 0000000..d4acf5a --- /dev/null +++ b/Among Us Config Editor/Languages.cs @@ -0,0 +1,11 @@ +namespace Among_Us_Config_Editor +{ + public enum Languages + { + English = 0, + Spanish = 1, + Portuguese = 2, + Korean = 3, + Russian = 4, + } +} diff --git a/Among Us Config Editor/Main.Designer.cs b/Among Us Config Editor/Main.Designer.cs index 785a110..b5c256a 100644 --- a/Among Us Config Editor/Main.Designer.cs +++ b/Among Us Config Editor/Main.Designer.cs @@ -47,6 +47,18 @@ private void InitializeComponent() this.txtName = new System.Windows.Forms.TextBox(); this.cbPet = new System.Windows.Forms.ComboBox(); this.tcMain = new System.Windows.Forms.TabControl(); + this.tpSettings = new System.Windows.Forms.TabPage(); + this.lblLanguage = new System.Windows.Forms.Label(); + this.lblMusicVolume = new System.Windows.Forms.Label(); + this.lblSfcVolume = new System.Windows.Forms.Label(); + this.gbControls = new System.Windows.Forms.GroupBox(); + this.rbMouseAndKeyboard = new System.Windows.Forms.RadioButton(); + this.rbMouse = new System.Windows.Forms.RadioButton(); + this.cbCensorChat = new System.Windows.Forms.CheckBox(); + this.cbLanguage = new System.Windows.Forms.ComboBox(); + this.cbVSync = new System.Windows.Forms.CheckBox(); + this.tbMusicVolume = new System.Windows.Forms.TrackBar(); + this.tbSfxVolume = new System.Windows.Forms.TrackBar(); this.tpAbout = new System.Windows.Forms.TabPage(); this.lblVersionCurrent = new System.Windows.Forms.Label(); this.lblCreatedName = new System.Windows.Forms.Label(); @@ -62,6 +74,10 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.pbColor)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pbPet)).BeginInit(); this.tcMain.SuspendLayout(); + this.tpSettings.SuspendLayout(); + this.gbControls.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.tbMusicVolume)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.tbSfxVolume)).BeginInit(); this.tpAbout.SuspendLayout(); this.SuspendLayout(); // @@ -106,7 +122,6 @@ private void InitializeComponent() // this.cbInvisible.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.cbInvisible.AutoSize = true; - this.cbInvisible.Enabled = false; this.cbInvisible.Location = new System.Drawing.Point(291, 6); this.cbInvisible.Name = "cbInvisible"; this.cbInvisible.Size = new System.Drawing.Size(69, 19); @@ -201,7 +216,6 @@ private void InitializeComponent() this.cbCostume.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.cbCostume.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.cbCostume.Enabled = false; this.cbCostume.FormattingEnabled = true; this.cbCostume.Location = new System.Drawing.Point(66, 119); this.cbCostume.Name = "cbCostume"; @@ -214,7 +228,6 @@ private void InitializeComponent() this.cbHat.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.cbHat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.cbHat.Enabled = false; this.cbHat.FormattingEnabled = true; this.cbHat.Location = new System.Drawing.Point(66, 90); this.cbHat.Name = "cbHat"; @@ -227,7 +240,6 @@ private void InitializeComponent() this.cbColor.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.cbColor.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.cbColor.Enabled = false; this.cbColor.FormattingEnabled = true; this.cbColor.Location = new System.Drawing.Point(66, 61); this.cbColor.Name = "cbColor"; @@ -251,7 +263,6 @@ private void InitializeComponent() this.cbPet.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.cbPet.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.cbPet.Enabled = false; this.cbPet.FormattingEnabled = true; this.cbPet.Location = new System.Drawing.Point(66, 33); this.cbPet.Name = "cbPet"; @@ -265,6 +276,7 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.tcMain.Controls.Add(this.tpCosmetics); + this.tcMain.Controls.Add(this.tpSettings); this.tcMain.Controls.Add(this.tpAbout); this.tcMain.Location = new System.Drawing.Point(12, 12); this.tcMain.Name = "tcMain"; @@ -273,6 +285,145 @@ private void InitializeComponent() this.tcMain.TabIndex = 1; this.tcMain.TabStop = false; // + // tpSettings + // + this.tpSettings.Controls.Add(this.lblLanguage); + this.tpSettings.Controls.Add(this.lblMusicVolume); + this.tpSettings.Controls.Add(this.lblSfcVolume); + this.tpSettings.Controls.Add(this.gbControls); + this.tpSettings.Controls.Add(this.cbCensorChat); + this.tpSettings.Controls.Add(this.cbLanguage); + this.tpSettings.Controls.Add(this.cbVSync); + this.tpSettings.Controls.Add(this.tbMusicVolume); + this.tpSettings.Controls.Add(this.tbSfxVolume); + this.tpSettings.Location = new System.Drawing.Point(4, 24); + this.tpSettings.Name = "tpSettings"; + this.tpSettings.Padding = new System.Windows.Forms.Padding(3); + this.tpSettings.Size = new System.Drawing.Size(365, 367); + this.tpSettings.TabIndex = 3; + this.tpSettings.Text = "Settings"; + this.tpSettings.UseVisualStyleBackColor = true; + // + // lblLanguage + // + this.lblLanguage.AutoSize = true; + this.lblLanguage.Location = new System.Drawing.Point(3, 6); + this.lblLanguage.Name = "lblLanguage"; + this.lblLanguage.Size = new System.Drawing.Size(62, 15); + this.lblLanguage.TabIndex = 8; + this.lblLanguage.Text = "Language:"; + // + // lblMusicVolume + // + this.lblMusicVolume.AutoSize = true; + this.lblMusicVolume.Location = new System.Drawing.Point(3, 160); + this.lblMusicVolume.Name = "lblMusicVolume"; + this.lblMusicVolume.Size = new System.Drawing.Size(85, 15); + this.lblMusicVolume.TabIndex = 7; + this.lblMusicVolume.Text = "Music Volume:"; + // + // lblSfcVolume + // + this.lblSfcVolume.AutoSize = true; + this.lblSfcVolume.Location = new System.Drawing.Point(3, 109); + this.lblSfcVolume.Name = "lblSfcVolume"; + this.lblSfcVolume.Size = new System.Drawing.Size(72, 15); + this.lblSfcVolume.TabIndex = 6; + this.lblSfcVolume.Text = "SFX Volume:"; + // + // gbControls + // + this.gbControls.Controls.Add(this.rbMouseAndKeyboard); + this.gbControls.Controls.Add(this.rbMouse); + this.gbControls.Location = new System.Drawing.Point(100, 32); + this.gbControls.Name = "gbControls"; + this.gbControls.Size = new System.Drawing.Size(262, 71); + this.gbControls.TabIndex = 5; + this.gbControls.TabStop = false; + this.gbControls.Text = "Controls"; + // + // rbMouseAndKeyboard + // + this.rbMouseAndKeyboard.AutoSize = true; + this.rbMouseAndKeyboard.Location = new System.Drawing.Point(14, 47); + this.rbMouseAndKeyboard.Name = "rbMouseAndKeyboard"; + this.rbMouseAndKeyboard.Size = new System.Drawing.Size(137, 19); + this.rbMouseAndKeyboard.TabIndex = 1; + this.rbMouseAndKeyboard.TabStop = true; + this.rbMouseAndKeyboard.Text = "Mouse and Keyboard"; + this.rbMouseAndKeyboard.UseVisualStyleBackColor = true; + this.rbMouseAndKeyboard.CheckedChanged += new System.EventHandler(this.rbControls_CheckedChanged); + // + // rbMouse + // + this.rbMouse.AutoSize = true; + this.rbMouse.Location = new System.Drawing.Point(14, 22); + this.rbMouse.Name = "rbMouse"; + this.rbMouse.Size = new System.Drawing.Size(61, 19); + this.rbMouse.TabIndex = 0; + this.rbMouse.TabStop = true; + this.rbMouse.Text = "Mouse"; + this.rbMouse.UseVisualStyleBackColor = true; + this.rbMouse.CheckedChanged += new System.EventHandler(this.rbControls_CheckedChanged); + // + // cbCensorChat + // + this.cbCensorChat.AutoSize = true; + this.cbCensorChat.Location = new System.Drawing.Point(3, 32); + this.cbCensorChat.Name = "cbCensorChat"; + this.cbCensorChat.Size = new System.Drawing.Size(91, 19); + this.cbCensorChat.TabIndex = 4; + this.cbCensorChat.Text = "Censor Chat"; + this.cbCensorChat.UseVisualStyleBackColor = true; + this.cbCensorChat.CheckStateChanged += new System.EventHandler(this.cbCensorChat_CheckStateChanged); + // + // cbLanguage + // + this.cbLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbLanguage.FormattingEnabled = true; + this.cbLanguage.Location = new System.Drawing.Point(94, 3); + this.cbLanguage.Name = "cbLanguage"; + this.cbLanguage.Size = new System.Drawing.Size(268, 23); + this.cbLanguage.TabIndex = 3; + this.cbLanguage.SelectionChangeCommitted += new System.EventHandler(this.cbLanguage_SelectionChangeCommitted); + // + // cbVSync + // + this.cbVSync.AutoSize = true; + this.cbVSync.Location = new System.Drawing.Point(3, 57); + this.cbVSync.Name = "cbVSync"; + this.cbVSync.Size = new System.Drawing.Size(63, 19); + this.cbVSync.TabIndex = 2; + this.cbVSync.Text = "V-Sync"; + this.cbVSync.UseVisualStyleBackColor = true; + this.cbVSync.CheckStateChanged += new System.EventHandler(this.cbVSync_CheckStateChanged); + // + // tbMusicVolume + // + this.tbMusicVolume.BackColor = System.Drawing.SystemColors.Window; + this.tbMusicVolume.Location = new System.Drawing.Point(94, 160); + this.tbMusicVolume.Maximum = 100; + this.tbMusicVolume.Name = "tbMusicVolume"; + this.tbMusicVolume.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.tbMusicVolume.Size = new System.Drawing.Size(268, 45); + this.tbMusicVolume.TabIndex = 0; + this.tbMusicVolume.TickFrequency = 10; + this.tbMusicVolume.Value = 100; + this.tbMusicVolume.ValueChanged += new System.EventHandler(this.tbMusicVolume_ValueChanged); + // + // tbSfxVolume + // + this.tbSfxVolume.BackColor = System.Drawing.SystemColors.Window; + this.tbSfxVolume.Location = new System.Drawing.Point(94, 109); + this.tbSfxVolume.Maximum = 100; + this.tbSfxVolume.Name = "tbSfxVolume"; + this.tbSfxVolume.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.tbSfxVolume.Size = new System.Drawing.Size(268, 45); + this.tbSfxVolume.TabIndex = 0; + this.tbSfxVolume.TickFrequency = 10; + this.tbSfxVolume.Value = 100; + this.tbSfxVolume.ValueChanged += new System.EventHandler(this.tbSfxVolume_ValueChanged); + // // tpAbout // this.tpAbout.Controls.Add(this.lblVersionCurrent); @@ -387,6 +538,12 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.pbColor)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pbPet)).EndInit(); this.tcMain.ResumeLayout(false); + this.tpSettings.ResumeLayout(false); + this.tpSettings.PerformLayout(); + this.gbControls.ResumeLayout(false); + this.gbControls.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.tbMusicVolume)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.tbSfxVolume)).EndInit(); this.tpAbout.ResumeLayout(false); this.tpAbout.PerformLayout(); this.ResumeLayout(false); @@ -422,6 +579,19 @@ private void InitializeComponent() private System.Windows.Forms.Label lblVersion; private System.Windows.Forms.Label lblCreatedName; private System.Windows.Forms.Label lblVersionCurrent; + private System.Windows.Forms.TabPage tpSettings; + private System.Windows.Forms.TrackBar tbSfxVolume; + private System.Windows.Forms.TrackBar tbMusicVolume; + private System.Windows.Forms.ComboBox cbLanguage; + private System.Windows.Forms.CheckBox cbVSync; + private System.Windows.Forms.CheckBox cbCensorChat; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.RadioButton rbMouseAndKeyboard; + private System.Windows.Forms.RadioButton rbMouse; + private System.Windows.Forms.Label lblSfcVolume; + private System.Windows.Forms.Label lblMusicVolume; + private System.Windows.Forms.Label lblLanguage; + private System.Windows.Forms.GroupBox gbControls; } } diff --git a/Among Us Config Editor/Main.cs b/Among Us Config Editor/Main.cs index aa6f32c..16f6616 100644 --- a/Among Us Config Editor/Main.cs +++ b/Among Us Config Editor/Main.cs @@ -18,6 +18,8 @@ public partial class Main : Form { private Settings _settings; + private int MaxVolume = 255; + private readonly Dictionary _hats; private readonly Dictionary _costumes; @@ -63,6 +65,8 @@ public Main() cbColor.ValueMember = "Id"; cbColor.DrawMode = DrawMode.OwnerDrawVariable; cbColor.DrawItem += cboDrawImage_DrawItem; + + cbLanguage.DataSource = Enum.GetValues(typeof(Languages)); } private void Main_Load(object sender, EventArgs e) @@ -130,27 +134,68 @@ public void SetSettings() txtName.Enabled = true; } - cbInvisible.Enabled = true; + tbSfxVolume.ValueChanged -= tbSfxVolume_ValueChanged; + tbSfxVolume.Value = (int)Math.Round((100m * _settings.SfxVolume) / MaxVolume); ; + tbSfxVolume.ValueChanged += tbSfxVolume_ValueChanged; + + tbMusicVolume.ValueChanged -= tbMusicVolume_ValueChanged; + tbMusicVolume.Value = (int)Math.Round((100m * _settings.MusicVolume) / MaxVolume); ; + tbMusicVolume.ValueChanged += tbMusicVolume_ValueChanged; + + cbCensorChat.CheckStateChanged -= cbCensorChat_CheckStateChanged; + cbCensorChat.Checked = _settings.CensorChat; + cbCensorChat.CheckStateChanged += cbCensorChat_CheckStateChanged; + + cbVSync.CheckStateChanged -= cbVSync_CheckStateChanged; + cbVSync.Checked = _settings.Vsync; + cbVSync.CheckStateChanged += cbVSync_CheckStateChanged; var hatId = _settings.Hat; cbHat.SelectedValue = _settings.Hat; pbHat.Image = _hats[hatId].ImageResource; - cbHat.Enabled = true; var costumeId = _settings.Costume; cbCostume.SelectedValue = costumeId; pbCostume.Image = _costumes[costumeId].ImageResource; - cbCostume.Enabled = true; var petId = _settings.Pet; cbPet.SelectedValue = petId; pbPet.Image = _pets[petId].ImageResource; - cbPet.Enabled = true; var colorId = _settings.Color; cbColor.SelectedValue = colorId; pbColor.Image = _colors[colorId].ImageResource; - cbColor.Enabled = true; + + cbLanguage.SelectedItem = (Languages)_settings.Language; + + if (_settings.Controls == 0) + { + rbMouse.CheckedChanged -= rbControls_CheckedChanged; + rbMouse.Checked = true; + rbMouse.CheckedChanged += rbControls_CheckedChanged; + } + else + { + rbMouseAndKeyboard.CheckedChanged -= rbControls_CheckedChanged; + rbMouseAndKeyboard.Checked = true; + rbMouseAndKeyboard.CheckedChanged += rbControls_CheckedChanged; + } + } + + void rbControls_CheckedChanged(object sender, EventArgs e) + { + var radioButton = sender as RadioButton; + if (radioButton.Checked) + { + if (radioButton == rbMouse) + { + _settings.Controls = 0; + } + else + { + _settings.Controls = 1; + } + } } private void SettingsFileChanged(object sender, EventArgs e) @@ -256,6 +301,30 @@ private void llbSourceRepository_LinkClicked(object sender, LinkLabelLinkClicked UrlHelper.OpenBrowser(ConstValues.Url); } + private void cbVSync_CheckStateChanged(object sender, EventArgs e) + { + _settings.Vsync = cbVSync.Checked; + } + + private void cbCensorChat_CheckStateChanged(object sender, EventArgs e) + { + _settings.CensorChat = cbCensorChat.Checked; + } + private void tbSfxVolume_ValueChanged(object sender, EventArgs e) + { + _settings.SfxVolume = (int)Math.Round((MaxVolume / 100m) * tbSfxVolume.Value); + } + + private void tbMusicVolume_ValueChanged(object sender, EventArgs e) + { + _settings.MusicVolume = (int)Math.Round((MaxVolume / 100m) * tbMusicVolume.Value); + } + + private void cbLanguage_SelectionChangeCommitted(object sender, EventArgs e) + { + _settings.Language = (int)cbLanguage.SelectedItem; + } + string GetKnownFolderPath( Guid knownFolderId) { diff --git a/Among Us Config Editor/Settings.cs b/Among Us Config Editor/Settings.cs index ae1d7ff..21ffddf 100644 --- a/Among Us Config Editor/Settings.cs +++ b/Among Us Config Editor/Settings.cs @@ -85,19 +85,108 @@ public int Color } } + private int _language; + public int Language + { + get { return _language; } + set + { + if (_language != value) + { + _language = value; + OnPropertyChanged(); + } + } + } + + private int _musicVolume; + public int MusicVolume + { + get { return _musicVolume; } + set + { + if (_musicVolume != value) + { + _musicVolume = value; + OnPropertyChanged(); + } + } + } + + private int _sfxVolume; + public int SfxVolume + { + get { return _sfxVolume; } + set + { + if (_sfxVolume != value) + { + _sfxVolume = value; + OnPropertyChanged(); + } + } + } + + private int _controls; + public int Controls + { + get { return _controls; } + set + { + if (_controls != value) + { + _controls = value; + OnPropertyChanged(); + } + } + } + + private bool _vSync; + public bool Vsync + { + get { return _vSync; } + set + { + if (_vSync != value) + { + _vSync = value; + OnPropertyChanged(); + } + } + } + + private bool _censorChat; + public bool CensorChat + { + get { return _censorChat; } + set + { + if (_censorChat != value) + { + _censorChat = value; + OnPropertyChanged(); + } + } + } + public bool InSync { get { return (_name == _settings[0]) && + (_controls == int.Parse(_settings[1])) && (_color == int.Parse(_settings[2])) && + (_sfxVolume == int.Parse(_settings[11])) && + (_musicVolume == int.Parse(_settings[12])) && (_hat == int.Parse(_settings[10])) && (_costume == int.Parse(_settings[15])) && - (_pet == int.Parse(_settings[16])); + (_pet == int.Parse(_settings[16])) && + (_censorChat == bool.Parse(_settings[17])) && + (_language == int.Parse(_settings[18])) && + (_vSync == bool.Parse(_settings[19])); } } - public Settings( string path) { @@ -126,10 +215,16 @@ private void LoadSettings() } _name = _settings[0]; + _controls = int.Parse(_settings[1]); _color = int.Parse(_settings[2]); _hat = int.Parse(_settings[10]); + _sfxVolume = int.Parse(_settings[11]); + _musicVolume = int.Parse(_settings[12]); _costume = int.Parse(_settings[15]); _pet = int.Parse(_settings[16]); + _censorChat = bool.Parse(_settings[17]); + _language = int.Parse(_settings[18]); + _vSync = bool.Parse(_settings[19]); _watcher.EnableRaisingEvents = true; } @@ -155,10 +250,17 @@ public void Save() _watcher.EnableRaisingEvents = false; _settings[0] = _name; + _settings[1] = _controls.ToString(); _settings[2] = _color.ToString(); _settings[10] = _hat.ToString(); + _settings[11] = _sfxVolume.ToString(); + _settings[12] = _musicVolume.ToString(); _settings[15] = _costume.ToString(); _settings[16] = _pet.ToString(); + _settings[17] = _censorChat.ToString(); + _settings[18] = _language.ToString(); + _settings[19] = _vSync.ToString(); + File.WriteAllText(_path, string.Join(",", _settings)); _watcher.EnableRaisingEvents = true; @@ -166,7 +268,7 @@ public void Save() public void Dispose() { - throw new NotImplementedException(); + } } } \ No newline at end of file