242 lines
8.5 KiB
C#
242 lines
8.5 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.IO;
|
|
using System.Windows.Forms;
|
|
using MyNes.Core;
|
|
using MyNes.Properties;
|
|
using SDL2;
|
|
|
|
namespace MyNes;
|
|
|
|
public class FormSDL2Settings : Form
|
|
{
|
|
private SDL2Settings sdl_settings;
|
|
|
|
private IContainer components;
|
|
|
|
private Label label1;
|
|
|
|
private RadioButton radioButton_direct3d;
|
|
|
|
private RadioButton radioButton_opengl;
|
|
|
|
private Label label2;
|
|
|
|
private Button button1;
|
|
|
|
private Button button2;
|
|
|
|
private Button button3;
|
|
|
|
private RichTextBox richTextBox1;
|
|
|
|
private Label label3;
|
|
|
|
private ComboBox comboBox1;
|
|
|
|
private GroupBox groupBox1;
|
|
|
|
private LinkLabel linkLabel1;
|
|
|
|
private Label label_brightness;
|
|
|
|
private TrackBar trackBar1;
|
|
|
|
private CheckBox checkBox1;
|
|
|
|
public FormSDL2Settings()
|
|
{
|
|
InitializeComponent();
|
|
int num = SDL.SDL_GetNumAudioDrivers();
|
|
for (int i = 0; i < num; i++)
|
|
{
|
|
string text = SDL.SDL_GetAudioDeviceName(i, 0);
|
|
if (text != null)
|
|
{
|
|
comboBox1.Items.Add(text);
|
|
}
|
|
}
|
|
sdl_settings = new SDL2Settings(Path.Combine(Program.WorkingFolder, "sdlsettings.ini"));
|
|
sdl_settings.LoadSettings();
|
|
radioButton_opengl.Checked = sdl_settings.Video_Driver == "opengl";
|
|
checkBox1.Checked = sdl_settings.Video_Modify_Brightness;
|
|
trackBar1.Value = sdl_settings.Video_Brightness;
|
|
label_brightness.Text = "Brightness " + trackBar1.Value + " %";
|
|
richTextBox1.Text = Resources.SDL2SettingsWarning;
|
|
if (sdl_settings.Audio_Device_Index >= 0 && sdl_settings.Audio_Device_Index < comboBox1.Items.Count)
|
|
{
|
|
comboBox1.SelectedIndex = sdl_settings.Audio_Device_Index;
|
|
}
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
if (MyNesMain.VideoProvider.ID == "sdl2.video")
|
|
{
|
|
((SDL2VideoRenderer)MyNesMain.VideoProvider).SetBrightness(sdl_settings.Video_Modify_Brightness, sdl_settings.Video_Brightness);
|
|
}
|
|
Close();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
sdl_settings.Video_Driver = (radioButton_opengl.Checked ? "opengl" : "direct3d");
|
|
sdl_settings.Audio_Device_Index = comboBox1.SelectedIndex;
|
|
if (sdl_settings.Audio_Device_Index < 0)
|
|
{
|
|
sdl_settings.Audio_Device_Index = 0;
|
|
}
|
|
sdl_settings.Video_Modify_Brightness = checkBox1.Checked;
|
|
sdl_settings.Video_Brightness = trackBar1.Value;
|
|
sdl_settings.SaveSettings();
|
|
if (MyNesMain.VideoProvider.ID == "sdl2.video")
|
|
{
|
|
((SDL2VideoRenderer)MyNesMain.VideoProvider).SetBrightness(checkBox1.Checked, trackBar1.Value);
|
|
}
|
|
base.DialogResult = DialogResult.OK;
|
|
Close();
|
|
}
|
|
|
|
private void button3_Click(object sender, EventArgs e)
|
|
{
|
|
radioButton_direct3d.Checked = false;
|
|
if (comboBox1.Items.Count > 0)
|
|
{
|
|
comboBox1.SelectedIndex = 0;
|
|
}
|
|
}
|
|
|
|
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
|
{
|
|
NesEmu.PAUSED = !NesEmu.PAUSED;
|
|
}
|
|
|
|
private void trackBar1_Scroll(object sender, EventArgs e)
|
|
{
|
|
label_brightness.Text = "Brightness " + trackBar1.Value + " %";
|
|
if (MyNesMain.VideoProvider.ID == "sdl2.video")
|
|
{
|
|
((SDL2VideoRenderer)MyNesMain.VideoProvider).SetBrightness(checkBox1.Checked, trackBar1.Value);
|
|
}
|
|
}
|
|
|
|
private void checkBox1_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
if (MyNesMain.VideoProvider.ID == "sdl2.video")
|
|
{
|
|
((SDL2VideoRenderer)MyNesMain.VideoProvider).SetBrightness(sdl_settings.Video_Modify_Brightness, sdl_settings.Video_Brightness);
|
|
}
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing && components != null)
|
|
{
|
|
components.Dispose();
|
|
}
|
|
base.Dispose(disposing);
|
|
}
|
|
|
|
private void InitializeComponent()
|
|
{
|
|
System.ComponentModel.ComponentResourceManager componentResourceManager = new System.ComponentModel.ComponentResourceManager(typeof(MyNes.FormSDL2Settings));
|
|
this.label1 = new System.Windows.Forms.Label();
|
|
this.radioButton_direct3d = new System.Windows.Forms.RadioButton();
|
|
this.radioButton_opengl = new System.Windows.Forms.RadioButton();
|
|
this.label2 = new System.Windows.Forms.Label();
|
|
this.button1 = new System.Windows.Forms.Button();
|
|
this.button2 = new System.Windows.Forms.Button();
|
|
this.button3 = new System.Windows.Forms.Button();
|
|
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
|
|
this.label3 = new System.Windows.Forms.Label();
|
|
this.comboBox1 = new System.Windows.Forms.ComboBox();
|
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
|
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
|
|
this.label_brightness = new System.Windows.Forms.Label();
|
|
this.trackBar1 = new System.Windows.Forms.TrackBar();
|
|
this.checkBox1 = new System.Windows.Forms.CheckBox();
|
|
this.groupBox1.SuspendLayout();
|
|
((System.ComponentModel.ISupportInitialize)this.trackBar1).BeginInit();
|
|
base.SuspendLayout();
|
|
componentResourceManager.ApplyResources(this.label1, "label1");
|
|
this.label1.Name = "label1";
|
|
componentResourceManager.ApplyResources(this.radioButton_direct3d, "radioButton_direct3d");
|
|
this.radioButton_direct3d.Checked = true;
|
|
this.radioButton_direct3d.Name = "radioButton_direct3d";
|
|
this.radioButton_direct3d.TabStop = true;
|
|
this.radioButton_direct3d.UseVisualStyleBackColor = true;
|
|
componentResourceManager.ApplyResources(this.radioButton_opengl, "radioButton_opengl");
|
|
this.radioButton_opengl.Name = "radioButton_opengl";
|
|
this.radioButton_opengl.TabStop = true;
|
|
this.radioButton_opengl.UseVisualStyleBackColor = true;
|
|
componentResourceManager.ApplyResources(this.label2, "label2");
|
|
this.label2.Name = "label2";
|
|
componentResourceManager.ApplyResources(this.button1, "button1");
|
|
this.button1.Name = "button1";
|
|
this.button1.UseVisualStyleBackColor = true;
|
|
this.button1.Click += new System.EventHandler(button1_Click);
|
|
componentResourceManager.ApplyResources(this.button2, "button2");
|
|
this.button2.Name = "button2";
|
|
this.button2.UseVisualStyleBackColor = true;
|
|
this.button2.Click += new System.EventHandler(button2_Click);
|
|
componentResourceManager.ApplyResources(this.button3, "button3");
|
|
this.button3.Name = "button3";
|
|
this.button3.UseVisualStyleBackColor = true;
|
|
this.button3.Click += new System.EventHandler(button3_Click);
|
|
componentResourceManager.ApplyResources(this.richTextBox1, "richTextBox1");
|
|
this.richTextBox1.Name = "richTextBox1";
|
|
this.richTextBox1.ReadOnly = true;
|
|
componentResourceManager.ApplyResources(this.label3, "label3");
|
|
this.label3.Name = "label3";
|
|
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
|
this.comboBox1.FormattingEnabled = true;
|
|
componentResourceManager.ApplyResources(this.comboBox1, "comboBox1");
|
|
this.comboBox1.Name = "comboBox1";
|
|
this.groupBox1.Controls.Add(this.linkLabel1);
|
|
this.groupBox1.Controls.Add(this.label_brightness);
|
|
this.groupBox1.Controls.Add(this.trackBar1);
|
|
this.groupBox1.Controls.Add(this.checkBox1);
|
|
componentResourceManager.ApplyResources(this.groupBox1, "groupBox1");
|
|
this.groupBox1.Name = "groupBox1";
|
|
this.groupBox1.TabStop = false;
|
|
componentResourceManager.ApplyResources(this.linkLabel1, "linkLabel1");
|
|
this.linkLabel1.Name = "linkLabel1";
|
|
this.linkLabel1.TabStop = true;
|
|
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(linkLabel1_LinkClicked);
|
|
componentResourceManager.ApplyResources(this.label_brightness, "label_brightness");
|
|
this.label_brightness.Name = "label_brightness";
|
|
componentResourceManager.ApplyResources(this.trackBar1, "trackBar1");
|
|
this.trackBar1.Maximum = 100;
|
|
this.trackBar1.Name = "trackBar1";
|
|
this.trackBar1.Scroll += new System.EventHandler(trackBar1_Scroll);
|
|
componentResourceManager.ApplyResources(this.checkBox1, "checkBox1");
|
|
this.checkBox1.Name = "checkBox1";
|
|
this.checkBox1.UseVisualStyleBackColor = true;
|
|
this.checkBox1.CheckedChanged += new System.EventHandler(checkBox1_CheckedChanged);
|
|
componentResourceManager.ApplyResources(this, "$this");
|
|
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
base.Controls.Add(this.groupBox1);
|
|
base.Controls.Add(this.comboBox1);
|
|
base.Controls.Add(this.label3);
|
|
base.Controls.Add(this.richTextBox1);
|
|
base.Controls.Add(this.button3);
|
|
base.Controls.Add(this.button2);
|
|
base.Controls.Add(this.button1);
|
|
base.Controls.Add(this.label2);
|
|
base.Controls.Add(this.radioButton_opengl);
|
|
base.Controls.Add(this.radioButton_direct3d);
|
|
base.Controls.Add(this.label1);
|
|
base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
|
base.MaximizeBox = false;
|
|
base.MinimizeBox = false;
|
|
base.Name = "FormSDL2Settings";
|
|
base.ShowIcon = false;
|
|
base.ShowInTaskbar = false;
|
|
this.groupBox1.ResumeLayout(false);
|
|
this.groupBox1.PerformLayout();
|
|
((System.ComponentModel.ISupportInitialize)this.trackBar1).EndInit();
|
|
base.ResumeLayout(false);
|
|
base.PerformLayout();
|
|
}
|
|
}
|