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;
|
|
|
|
|
|
2014-11-30 16:42:58 +00:00
|
|
|
|
using BizHawk.Emulation.Common;
|
2014-12-05 00:52:16 +00:00
|
|
|
|
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
2014-07-11 15:43:47 +00:00
|
|
|
|
using BizHawk.Client.Common;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Client.EmuHawk
|
|
|
|
|
{
|
2015-03-02 23:43:52 +00:00
|
|
|
|
public partial class StateHistorySettingsForm : Form
|
2014-07-11 15:43:47 +00:00
|
|
|
|
{
|
2014-12-21 18:25:04 +00:00
|
|
|
|
public IStatable Statable { get; set; }
|
|
|
|
|
|
2014-10-17 22:39:40 +00:00
|
|
|
|
private readonly TasStateManagerSettings Settings;
|
2014-07-11 15:43:47 +00:00
|
|
|
|
private decimal _stateSizeMb;
|
2015-03-02 23:43:52 +00:00
|
|
|
|
public StateHistorySettingsForm(TasStateManagerSettings settings)
|
2014-07-11 15:43:47 +00:00
|
|
|
|
{
|
|
|
|
|
Settings = settings;
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-02 23:43:52 +00:00
|
|
|
|
private void StateHistorySettings_Load(object sender, EventArgs e)
|
2014-07-11 15:43:47 +00:00
|
|
|
|
{
|
2014-12-21 18:25:04 +00:00
|
|
|
|
_stateSizeMb = Statable.SaveStateBinary().Length / (decimal)1024 / (decimal)1024;
|
2014-07-11 15:43:47 +00:00
|
|
|
|
|
2015-03-15 06:26:57 +00:00
|
|
|
|
if (Environment.Is64BitProcess) // ?
|
|
|
|
|
MemCapacityNumeric.Maximum = 1024 * 8;
|
|
|
|
|
else
|
|
|
|
|
MemCapacityNumeric.Maximum = 1024;
|
|
|
|
|
|
|
|
|
|
MemCapacityNumeric.Value = Settings.Capacitymb == 0 ? 1 : Settings.Capacitymb < MemCapacityNumeric.Maximum ?
|
|
|
|
|
Settings.Capacitymb : MemCapacityNumeric.Maximum;
|
|
|
|
|
DiskCapacityNumeric.Value = Settings.DiskCapacitymb == 0 ? 1 : Settings.DiskCapacitymb < MemCapacityNumeric.Maximum ?
|
|
|
|
|
Settings.DiskCapacitymb : MemCapacityNumeric.Maximum;
|
|
|
|
|
SaveCapacityNumeric.Value = Settings.DiskSaveCapacitymb == 0 ? 1 : Settings.DiskSaveCapacitymb < MemCapacityNumeric.Maximum ?
|
|
|
|
|
Settings.DiskSaveCapacitymb : MemCapacityNumeric.Maximum;
|
2014-07-11 15:43:47 +00:00
|
|
|
|
|
|
|
|
|
SavestateSizeLabel.Text = Math.Round(_stateSizeMb, 2).ToString() + " mb";
|
2014-08-22 17:04:31 +00:00
|
|
|
|
CapacityNumeric_ValueChanged(null, null);
|
2015-03-15 06:26:57 +00:00
|
|
|
|
SaveCapacityNumeric_ValueChanged(null, null);
|
2014-07-11 15:43:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-15 06:26:57 +00:00
|
|
|
|
private int MaxStatesInCapacity
|
2014-07-11 15:43:47 +00:00
|
|
|
|
{
|
2015-03-15 06:26:57 +00:00
|
|
|
|
get { return (int)Math.Floor((MemCapacityNumeric.Value + DiskCapacityNumeric.Value) / _stateSizeMb); }
|
2014-07-11 15:43:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OkBtn_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2015-03-15 06:26:57 +00:00
|
|
|
|
Settings.Capacitymb = (int)MemCapacityNumeric.Value;
|
|
|
|
|
Settings.DiskCapacitymb = (int)DiskCapacityNumeric.Value;
|
|
|
|
|
Settings.DiskSaveCapacitymb = (int)SaveCapacityNumeric.Value;
|
2014-07-11 15:43:47 +00:00
|
|
|
|
DialogResult = DialogResult.OK;
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CancelBtn_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DialogResult = DialogResult.Cancel;
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CapacityNumeric_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2015-03-15 06:26:57 +00:00
|
|
|
|
// TODO: Setting space for 2.6 (2) states in memory and 2.6 (2) on disk results in 5 total.
|
|
|
|
|
// Easy to fix the display, but the way TasStateManager works the total used actually is 5.
|
2014-08-22 17:04:31 +00:00
|
|
|
|
NumStatesLabel.Text = MaxStatesInCapacity.ToString();
|
2014-07-11 15:43:47 +00:00
|
|
|
|
}
|
2015-03-15 06:26:57 +00:00
|
|
|
|
|
|
|
|
|
private void SaveCapacityNumeric_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
NumSaveStatesLabel.Text = ((int)Math.Floor(SaveCapacityNumeric.Value / _stateSizeMb)).ToString();
|
|
|
|
|
}
|
2014-07-11 15:43:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|