BizHawk/BizHawk.Client.EmuHawk/tools/TAStudio/GreenzoneSettings.cs

62 lines
1.7 KiB
C#
Raw Normal View History

2014-07-11 15:43:47 +00:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
{
public partial class GreenzoneSettingsForm : Form
2014-07-11 15:43:47 +00:00
{
private readonly TasStateManagerSettings Settings;
2014-07-11 15:43:47 +00:00
private decimal _stateSizeMb;
public GreenzoneSettingsForm(TasStateManagerSettings settings)
2014-07-11 15:43:47 +00:00
{
Settings = settings;
InitializeComponent();
}
private void GreenzoneSettings_Load(object sender, EventArgs e)
{
_stateSizeMb = Global.Emulator.SaveStateBinary().Length / (decimal)1024 / (decimal)1024;
SaveGreenzoneCheckbox.Checked = Settings.SaveGreenzone;
CapacityNumeric.Value = Settings.Capacitymb == 0 ? 1 : Settings.Capacitymb < CapacityNumeric.Maximum ?
Settings.Capacitymb :
CapacityNumeric.Maximum;
SavestateSizeLabel.Text = Math.Round(_stateSizeMb, 2).ToString() + " mb";
CapacityNumeric_ValueChanged(null, null);
2014-07-11 15:43:47 +00:00
}
private ulong MaxStatesInCapacity
2014-07-11 15:43:47 +00:00
{
get { return (ulong)Math.Floor(CapacityNumeric.Value / _stateSizeMb); }
2014-07-11 15:43:47 +00:00
}
private void OkBtn_Click(object sender, EventArgs e)
{
Settings.SaveGreenzone = SaveGreenzoneCheckbox.Checked;
Settings.Capacitymb = (int)CapacityNumeric.Value;
DialogResult = DialogResult.OK;
Close();
}
private void CancelBtn_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void CapacityNumeric_ValueChanged(object sender, EventArgs e)
{
NumStatesLabel.Text = MaxStatesInCapacity.ToString();
2014-07-11 15:43:47 +00:00
}
}
}