Cheats Window - progress (porting various functions from Ram Search)
This commit is contained in:
parent
6c297287e5
commit
ff5623cd46
|
@ -85,11 +85,20 @@
|
|||
public int HexEditorHeight = -1;
|
||||
|
||||
// NESPPU Setings
|
||||
public bool AutoLoadNESPPU = true;
|
||||
public bool AutoLoadNESPPU = false;
|
||||
public bool NESPPUSaveWindowPosition = true;
|
||||
public int NESPPUWndx = -1;
|
||||
public int NESPPUWndy = -1;
|
||||
|
||||
// Cheats Dialog
|
||||
public bool AutoLoadCheats = false;
|
||||
public bool CheatsSaveWindowPosition = true;
|
||||
public RecentFiles RecentCheats = new RecentFiles(8);
|
||||
public int CheatsWndx = -1;
|
||||
public int CheatsWndy = -1;
|
||||
public int CheatsWidth = -1;
|
||||
public int CheatsHeight = -1;
|
||||
|
||||
//Movie Settings
|
||||
public RecentFiles RecentMovies = new RecentFiles(8);
|
||||
|
||||
|
|
|
@ -139,8 +139,10 @@ namespace BizHawk.MultiClient
|
|||
LoadRamSearch();
|
||||
if (Global.Config.AutoLoadHexEditor)
|
||||
LoadHexEditor();
|
||||
//if (Global.Config.AutoLoadNESPPU && Global.Emulator is NES)
|
||||
// LoadNESPPU();
|
||||
if (Global.Config.AutoLoadCheats)
|
||||
LoadCheatsWindow();
|
||||
if (Global.Config.AutoLoadNESPPU && Global.Emulator is NES)
|
||||
LoadNESPPU();
|
||||
|
||||
if (Global.Config.MainWndx >= 0 && Global.Config.MainWndy >= 0 && Global.Config.SaveWindowPosition)
|
||||
this.Location = new Point(Global.Config.MainWndx, Global.Config.MainWndy);
|
||||
|
@ -1022,6 +1024,8 @@ namespace BizHawk.MultiClient
|
|||
if (!Cheats1.IsHandleCreated || Cheats1.IsDisposed)
|
||||
{
|
||||
Cheats1 = new Cheats();
|
||||
if (Global.Config.AutoLoadCheats)
|
||||
Cheats1.LoadWatchFromRecent(Global.Config.RecentCheats.GetRecentFileByPosition(0));
|
||||
Cheats1.Show();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -58,16 +58,25 @@
|
|||
this.toolStripSeparator = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.cutToolStripButton = new System.Windows.Forms.ToolStripButton();
|
||||
this.copyToolStripButton = new System.Windows.Forms.ToolStripButton();
|
||||
this.toolStripButtonSeparator = new System.Windows.Forms.ToolStripButton();
|
||||
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.toolStripButtonMoveUp = new System.Windows.Forms.ToolStripButton();
|
||||
this.toolStripButtonMoveDown = new System.Windows.Forms.ToolStripButton();
|
||||
this.toolStripButtonSeparator = new System.Windows.Forms.ToolStripButton();
|
||||
this.MessageLabel = new System.Windows.Forms.Label();
|
||||
this.recentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveWindowPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.findAndLoadCheatFileByGameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.autoTurnOnCheatsOnLoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.CheatsMenu.SuspendLayout();
|
||||
this.toolStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// CheatListView
|
||||
//
|
||||
this.CheatListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.CheatListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.CheatName,
|
||||
this.Address,
|
||||
|
@ -81,7 +90,7 @@
|
|||
this.CheatListView.UseCompatibleStateImageBehavior = false;
|
||||
this.CheatListView.View = System.Windows.Forms.View.Details;
|
||||
//
|
||||
// Name
|
||||
// CheatName
|
||||
//
|
||||
this.CheatName.Text = "Name";
|
||||
this.CheatName.Width = 110;
|
||||
|
@ -102,7 +111,8 @@
|
|||
//
|
||||
this.CheatsMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.fileToolStripMenuItem,
|
||||
this.cheatsToolStripMenuItem});
|
||||
this.cheatsToolStripMenuItem,
|
||||
this.optionsToolStripMenuItem});
|
||||
this.CheatsMenu.Location = new System.Drawing.Point(0, 0);
|
||||
this.CheatsMenu.Name = "CheatsMenu";
|
||||
this.CheatsMenu.Size = new System.Drawing.Size(509, 24);
|
||||
|
@ -117,6 +127,7 @@
|
|||
this.saveToolStripMenuItem,
|
||||
this.saveAsToolStripMenuItem,
|
||||
this.appendFileToolStripMenuItem,
|
||||
this.recentToolStripMenuItem,
|
||||
this.toolStripSeparator1,
|
||||
this.exitToolStripMenuItem});
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
|
@ -129,6 +140,7 @@
|
|||
this.newToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N)));
|
||||
this.newToolStripMenuItem.Size = new System.Drawing.Size(204, 22);
|
||||
this.newToolStripMenuItem.Text = "&New";
|
||||
this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click);
|
||||
//
|
||||
// openToolStripMenuItem
|
||||
//
|
||||
|
@ -136,6 +148,7 @@
|
|||
this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
|
||||
this.openToolStripMenuItem.Size = new System.Drawing.Size(204, 22);
|
||||
this.openToolStripMenuItem.Text = "&Open...";
|
||||
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
|
||||
//
|
||||
// saveToolStripMenuItem
|
||||
//
|
||||
|
@ -143,6 +156,7 @@
|
|||
this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
|
||||
this.saveToolStripMenuItem.Size = new System.Drawing.Size(204, 22);
|
||||
this.saveToolStripMenuItem.Text = "&Save";
|
||||
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
|
||||
//
|
||||
// saveAsToolStripMenuItem
|
||||
//
|
||||
|
@ -151,6 +165,7 @@
|
|||
| System.Windows.Forms.Keys.S)));
|
||||
this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(204, 22);
|
||||
this.saveAsToolStripMenuItem.Text = "Save &As...";
|
||||
this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click);
|
||||
//
|
||||
// appendFileToolStripMenuItem
|
||||
//
|
||||
|
@ -218,12 +233,14 @@
|
|||
this.moveUpToolStripMenuItem.Name = "moveUpToolStripMenuItem";
|
||||
this.moveUpToolStripMenuItem.Size = new System.Drawing.Size(165, 22);
|
||||
this.moveUpToolStripMenuItem.Text = "Move &Up";
|
||||
this.moveUpToolStripMenuItem.Click += new System.EventHandler(this.moveUpToolStripMenuItem_Click);
|
||||
//
|
||||
// moveDownToolStripMenuItem
|
||||
//
|
||||
this.moveDownToolStripMenuItem.Name = "moveDownToolStripMenuItem";
|
||||
this.moveDownToolStripMenuItem.Size = new System.Drawing.Size(165, 22);
|
||||
this.moveDownToolStripMenuItem.Text = "Move &Down";
|
||||
this.moveDownToolStripMenuItem.Click += new System.EventHandler(this.moveDownToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStrip1
|
||||
//
|
||||
|
@ -252,6 +269,7 @@
|
|||
this.newToolStripButton.Name = "newToolStripButton";
|
||||
this.newToolStripButton.Size = new System.Drawing.Size(23, 22);
|
||||
this.newToolStripButton.Text = "&New";
|
||||
this.newToolStripButton.Click += new System.EventHandler(this.newToolStripButton_Click);
|
||||
//
|
||||
// openToolStripButton
|
||||
//
|
||||
|
@ -261,6 +279,7 @@
|
|||
this.openToolStripButton.Name = "openToolStripButton";
|
||||
this.openToolStripButton.Size = new System.Drawing.Size(23, 22);
|
||||
this.openToolStripButton.Text = "&Open";
|
||||
this.openToolStripButton.Click += new System.EventHandler(this.openToolStripButton_Click);
|
||||
//
|
||||
// saveToolStripButton
|
||||
//
|
||||
|
@ -270,6 +289,7 @@
|
|||
this.saveToolStripButton.Name = "saveToolStripButton";
|
||||
this.saveToolStripButton.Size = new System.Drawing.Size(23, 22);
|
||||
this.saveToolStripButton.Text = "&Save";
|
||||
this.saveToolStripButton.Click += new System.EventHandler(this.saveToolStripButton_Click);
|
||||
//
|
||||
// toolStripSeparator
|
||||
//
|
||||
|
@ -294,6 +314,15 @@
|
|||
this.copyToolStripButton.Size = new System.Drawing.Size(23, 22);
|
||||
this.copyToolStripButton.Text = "&Duplicate";
|
||||
//
|
||||
// toolStripButtonSeparator
|
||||
//
|
||||
this.toolStripButtonSeparator.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.toolStripButtonSeparator.Image = global::BizHawk.MultiClient.Properties.Resources.InserSeparator;
|
||||
this.toolStripButtonSeparator.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.toolStripButtonSeparator.Name = "toolStripButtonSeparator";
|
||||
this.toolStripButtonSeparator.Size = new System.Drawing.Size(23, 22);
|
||||
this.toolStripButtonSeparator.Text = "Insert Separator";
|
||||
//
|
||||
// toolStripSeparator2
|
||||
//
|
||||
this.toolStripSeparator2.Name = "toolStripSeparator2";
|
||||
|
@ -307,6 +336,7 @@
|
|||
this.toolStripButtonMoveUp.Name = "toolStripButtonMoveUp";
|
||||
this.toolStripButtonMoveUp.Size = new System.Drawing.Size(23, 22);
|
||||
this.toolStripButtonMoveUp.Text = "toolStripButton1";
|
||||
this.toolStripButtonMoveUp.Click += new System.EventHandler(this.toolStripButtonMoveUp_Click);
|
||||
//
|
||||
// toolStripButtonMoveDown
|
||||
//
|
||||
|
@ -316,26 +346,65 @@
|
|||
this.toolStripButtonMoveDown.Name = "toolStripButtonMoveDown";
|
||||
this.toolStripButtonMoveDown.Size = new System.Drawing.Size(23, 22);
|
||||
this.toolStripButtonMoveDown.Text = "Move Down";
|
||||
this.toolStripButtonMoveDown.Click += new System.EventHandler(this.toolStripButtonMoveDown_Click);
|
||||
//
|
||||
// toolStripButtonSeparator
|
||||
// MessageLabel
|
||||
//
|
||||
this.toolStripButtonSeparator.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.toolStripButtonSeparator.Image = global::BizHawk.MultiClient.Properties.Resources.InserSeparator;
|
||||
this.toolStripButtonSeparator.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.toolStripButtonSeparator.Name = "toolStripButtonSeparator";
|
||||
this.toolStripButtonSeparator.Size = new System.Drawing.Size(23, 22);
|
||||
this.toolStripButtonSeparator.Text = "Insert Separator";
|
||||
this.MessageLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.MessageLabel.AutoSize = true;
|
||||
this.MessageLabel.Location = new System.Drawing.Point(13, 356);
|
||||
this.MessageLabel.Name = "MessageLabel";
|
||||
this.MessageLabel.Size = new System.Drawing.Size(35, 13);
|
||||
this.MessageLabel.TabIndex = 3;
|
||||
this.MessageLabel.Text = "label1";
|
||||
//
|
||||
// recentToolStripMenuItem
|
||||
//
|
||||
this.recentToolStripMenuItem.Name = "recentToolStripMenuItem";
|
||||
this.recentToolStripMenuItem.Size = new System.Drawing.Size(204, 22);
|
||||
this.recentToolStripMenuItem.Text = "Recent";
|
||||
//
|
||||
// optionsToolStripMenuItem
|
||||
//
|
||||
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.saveWindowPositionToolStripMenuItem,
|
||||
this.findAndLoadCheatFileByGameToolStripMenuItem,
|
||||
this.autoTurnOnCheatsOnLoadToolStripMenuItem});
|
||||
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
|
||||
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(56, 20);
|
||||
this.optionsToolStripMenuItem.Text = "&Options";
|
||||
//
|
||||
// saveWindowPositionToolStripMenuItem
|
||||
//
|
||||
this.saveWindowPositionToolStripMenuItem.Name = "saveWindowPositionToolStripMenuItem";
|
||||
this.saveWindowPositionToolStripMenuItem.Size = new System.Drawing.Size(248, 22);
|
||||
this.saveWindowPositionToolStripMenuItem.Text = "Save Window Position";
|
||||
//
|
||||
// findAndLoadCheatFileByGameToolStripMenuItem
|
||||
//
|
||||
this.findAndLoadCheatFileByGameToolStripMenuItem.Name = "findAndLoadCheatFileByGameToolStripMenuItem";
|
||||
this.findAndLoadCheatFileByGameToolStripMenuItem.Size = new System.Drawing.Size(248, 22);
|
||||
this.findAndLoadCheatFileByGameToolStripMenuItem.Text = "Find and Load Cheat File by Game";
|
||||
//
|
||||
// autoTurnOnCheatsOnLoadToolStripMenuItem
|
||||
//
|
||||
this.autoTurnOnCheatsOnLoadToolStripMenuItem.Name = "autoTurnOnCheatsOnLoadToolStripMenuItem";
|
||||
this.autoTurnOnCheatsOnLoadToolStripMenuItem.Size = new System.Drawing.Size(248, 22);
|
||||
this.autoTurnOnCheatsOnLoadToolStripMenuItem.Text = "Auto Turn on Cheats on Load";
|
||||
//
|
||||
// Cheats
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(509, 370);
|
||||
this.ClientSize = new System.Drawing.Size(509, 379);
|
||||
this.Controls.Add(this.MessageLabel);
|
||||
this.Controls.Add(this.toolStrip1);
|
||||
this.Controls.Add(this.CheatListView);
|
||||
this.Controls.Add(this.CheatsMenu);
|
||||
this.MainMenuStrip = this.CheatsMenu;
|
||||
this.Name = "Cheats";
|
||||
this.Text = "Cheats";
|
||||
this.Load += new System.EventHandler(this.Cheats_Load);
|
||||
this.CheatsMenu.ResumeLayout(false);
|
||||
this.CheatsMenu.PerformLayout();
|
||||
this.toolStrip1.ResumeLayout(false);
|
||||
|
@ -380,5 +449,11 @@
|
|||
private System.Windows.Forms.ToolStripButton toolStripButtonMoveUp;
|
||||
private System.Windows.Forms.ToolStripButton toolStripButtonSeparator;
|
||||
private System.Windows.Forms.ToolStripButton toolStripButtonMoveDown;
|
||||
private System.Windows.Forms.Label MessageLabel;
|
||||
private System.Windows.Forms.ToolStripMenuItem recentToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveWindowPositionToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem findAndLoadCheatFileByGameToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem autoTurnOnCheatsOnLoadToolStripMenuItem;
|
||||
}
|
||||
}
|
|
@ -6,6 +6,8 @@ using System.Drawing;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
using System.Globalization;
|
||||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
|
@ -30,6 +32,310 @@ namespace BizHawk.MultiClient
|
|||
public Cheats()
|
||||
{
|
||||
InitializeComponent();
|
||||
Closing += (o, e) => SaveConfigSettings();
|
||||
}
|
||||
|
||||
private void Cheats_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadConfigSettings();
|
||||
}
|
||||
|
||||
public void LoadWatchFromRecent(string file)
|
||||
{
|
||||
bool z = true;
|
||||
/*
|
||||
if (changes) z = AskSave();
|
||||
|
||||
if (z)
|
||||
{
|
||||
bool r = LoadWatchFile(file, false);
|
||||
if (!r)
|
||||
{
|
||||
DialogResult result = MessageBox.Show("Could not open " + file + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
|
||||
if (result == DialogResult.Yes)
|
||||
Global.Config.RecentWatches.Remove(file);
|
||||
}
|
||||
DisplayWatchList();
|
||||
changes = false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private void LoadConfigSettings()
|
||||
{
|
||||
defaultWidth = Size.Width; //Save these first so that the user can restore to its original size
|
||||
defaultHeight = Size.Height;
|
||||
|
||||
if (Global.Config.CheatsWndx >= 0 && Global.Config.CheatsWndy >= 0)
|
||||
Location = new Point(Global.Config.CheatsWndx, Global.Config.CheatsWndy);
|
||||
|
||||
if (Global.Config.CheatsWidth >= 0 && Global.Config.CheatsHeight >= 0)
|
||||
{
|
||||
Size = new System.Drawing.Size(Global.Config.CheatsWidth, Global.Config.CheatsHeight);
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveConfigSettings()
|
||||
{
|
||||
Global.Config.CheatsWndx = this.Location.X;
|
||||
Global.Config.CheatsWndy = this.Location.Y;
|
||||
Global.Config.CheatsWidth = this.Right - this.Left;
|
||||
Global.Config.CheatsHeight = this.Bottom - this.Top;
|
||||
}
|
||||
|
||||
private void DisplayCheatsList()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void MoveUp()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void MoveDown()
|
||||
{
|
||||
ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices;
|
||||
Cheat temp = new Cheat();
|
||||
|
||||
foreach (int index in indexes)
|
||||
{
|
||||
temp = cheatList[index];
|
||||
|
||||
if (index < cheatList.Count - 1)
|
||||
{
|
||||
|
||||
cheatList.Remove(cheatList[index]);
|
||||
cheatList.Insert(index + 1, temp);
|
||||
|
||||
}
|
||||
|
||||
//Note: here it will get flagged many times redundantly potnetially,
|
||||
//but this avoids it being flagged falsely when the user did not select an index
|
||||
Changes();
|
||||
}
|
||||
|
||||
List<int> i = new List<int>();
|
||||
for (int z = 0; z < indexes.Count; z++)
|
||||
i.Add(indexes[z] + 1);
|
||||
|
||||
CheatListView.SelectedIndices.Clear();
|
||||
//for (int z = 0; z < i.Count; z++)
|
||||
//CheatListView.SelectItem(i[z], true); //TODO
|
||||
|
||||
DisplayCheatsList();
|
||||
}
|
||||
|
||||
private void toolStripButtonMoveUp_Click(object sender, EventArgs e)
|
||||
{
|
||||
MoveUp();
|
||||
}
|
||||
|
||||
private void moveUpToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
MoveUp();
|
||||
}
|
||||
|
||||
private void toolStripButtonMoveDown_Click(object sender, EventArgs e)
|
||||
{
|
||||
MoveDown();
|
||||
}
|
||||
|
||||
private void moveDownToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
MoveDown();
|
||||
}
|
||||
|
||||
void Changes()
|
||||
{
|
||||
changes = true;
|
||||
MessageLabel.Text = Path.GetFileName(currentCheatFile) + " *";
|
||||
}
|
||||
|
||||
private FileInfo GetSaveFileFromUser()
|
||||
{
|
||||
var sfd = new SaveFileDialog();
|
||||
sfd.InitialDirectory = Global.Config.LastRomPath;
|
||||
sfd.Filter = "Cheat Files (*.cht)|*.cht|All Files|*.*";
|
||||
sfd.RestoreDirectory = true;
|
||||
Global.Sound.StopSound();
|
||||
var result = sfd.ShowDialog();
|
||||
Global.Sound.StartSound();
|
||||
if (result != DialogResult.OK)
|
||||
return null;
|
||||
var file = new FileInfo(sfd.FileName);
|
||||
Global.Config.LastRomPath = file.DirectoryName;
|
||||
return file;
|
||||
}
|
||||
|
||||
private void SaveAs()
|
||||
{
|
||||
var file = GetSaveFileFromUser();
|
||||
if (file != null)
|
||||
{
|
||||
SaveCheatFile(file.FullName);
|
||||
currentCheatFile = file.FullName;
|
||||
MessageLabel.Text = Path.GetFileName(currentCheatFile) + " saved.";
|
||||
}
|
||||
}
|
||||
|
||||
private bool SaveCheatFile(string path)
|
||||
{
|
||||
var file = new FileInfo(path);
|
||||
|
||||
using (StreamWriter sw = new StreamWriter(path))
|
||||
{
|
||||
string str = "";
|
||||
|
||||
for (int x = 0; x < cheatList.Count; x++)
|
||||
{
|
||||
//str += string.Format("{0:X4}", watchList[x].address) + "\t";
|
||||
//str += watchList[x].GetTypeByChar().ToString() + "\t";
|
||||
//str += watchList[x].GetSignedByChar().ToString() + "\t";
|
||||
|
||||
//if (watchList[x].bigendian == true)
|
||||
// str += "1\t";
|
||||
//else
|
||||
// str += "0\t";
|
||||
|
||||
//str += watchList[x].notes + "\n";
|
||||
}
|
||||
|
||||
sw.WriteLine(str);
|
||||
}
|
||||
changes = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool AskSave()
|
||||
{
|
||||
if (changes)
|
||||
{
|
||||
DialogResult result = MessageBox.Show("Save Changes?", "Ram Watch", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3);
|
||||
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
//TOOD: Do quicksave if filename, else save as
|
||||
if (string.Compare(currentCheatFile, "") == 0)
|
||||
{
|
||||
SaveAs();
|
||||
}
|
||||
else
|
||||
SaveCheatFile(currentCheatFile);
|
||||
return true;
|
||||
}
|
||||
else if (result == DialogResult.No)
|
||||
return true;
|
||||
else if (result == DialogResult.Cancel)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void NewCheatList()
|
||||
{
|
||||
bool result = true;
|
||||
if (changes) result = AskSave();
|
||||
|
||||
if (result == true)
|
||||
{
|
||||
cheatList.Clear();
|
||||
DisplayCheatsList();
|
||||
currentCheatFile = "";
|
||||
changes = false;
|
||||
MessageLabel.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
private void newToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
NewCheatList();
|
||||
}
|
||||
|
||||
private void newToolStripButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
NewCheatList();
|
||||
}
|
||||
|
||||
private void saveToolStripButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (changes)
|
||||
{
|
||||
SaveCheatFile(currentCheatFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
SaveAs();
|
||||
}
|
||||
}
|
||||
|
||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.Compare(currentCheatFile, "") == 0) return;
|
||||
|
||||
if (changes)
|
||||
SaveCheatFile(currentCheatFile);
|
||||
}
|
||||
|
||||
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveAs();
|
||||
}
|
||||
|
||||
private FileInfo GetFileFromUser()
|
||||
{
|
||||
var ofd = new OpenFileDialog();
|
||||
ofd.InitialDirectory = Global.Config.LastRomPath;
|
||||
ofd.Filter = "Cheat Files (*.cht)|*.cht|All Files|*.*";
|
||||
ofd.RestoreDirectory = true;
|
||||
|
||||
Global.Sound.StopSound();
|
||||
var result = ofd.ShowDialog();
|
||||
Global.Sound.StartSound();
|
||||
if (result != DialogResult.OK)
|
||||
return null;
|
||||
var file = new FileInfo(ofd.FileName);
|
||||
Global.Config.LastRomPath = file.DirectoryName;
|
||||
return file;
|
||||
}
|
||||
|
||||
bool LoadCheatFile(string path, bool append)
|
||||
{
|
||||
int y, z;
|
||||
var file = new FileInfo(path);
|
||||
if (file.Exists == false) return false;
|
||||
|
||||
using (StreamReader sr = file.OpenText())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return true; //TODO
|
||||
}
|
||||
|
||||
private void OpenCheatFile()
|
||||
{
|
||||
var file = GetFileFromUser();
|
||||
if (file != null)
|
||||
{
|
||||
bool r = true;
|
||||
if (changes) r = AskSave();
|
||||
if (r)
|
||||
{
|
||||
LoadCheatFile(file.FullName, false);
|
||||
DisplayCheatsList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void openToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenCheatFile();
|
||||
}
|
||||
|
||||
private void openToolStripButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenCheatFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue