New Cheat List - some small progress

This commit is contained in:
adelikat 2013-10-03 15:27:51 +00:00
parent b87e4b4bca
commit 741a4a9b83
4 changed files with 103 additions and 17 deletions

View File

@ -2,6 +2,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.IO;
using System.Windows.Forms;
namespace BizHawk.MultiClient namespace BizHawk.MultiClient
{ {
@ -112,7 +114,7 @@ namespace BizHawk.MultiClient
} }
else else
{ {
switch(domain.Endian) switch (domain.Endian)
{ {
default: default:
case Endian.Unknown: case Endian.Unknown:
@ -144,6 +146,38 @@ namespace BizHawk.MultiClient
public bool Load(string path, bool append) public bool Load(string path, bool append)
{ {
var file = new FileInfo(path);
if (file.Exists == false)
{
return false;
}
if (!append)
{
_currentFileName = path;
}
using (StreamReader sr = file.OpenText())
{
if (!append)
{
Clear();
}
string s;
while ((s = sr.ReadLine()) != null)
{
try
{
}
catch
{
continue;
}
}
}
throw new NotImplementedException(); throw new NotImplementedException();
} }
@ -165,5 +199,31 @@ namespace BizHawk.MultiClient
} }
#endregion #endregion
#region File Handling
public static FileInfo GetFileFromUser(string currentFile)
{
var ofd = new OpenFileDialog();
if (!String.IsNullOrWhiteSpace(currentFile))
{
ofd.FileName = Path.GetFileNameWithoutExtension(currentFile);
}
ofd.InitialDirectory = PathManager.MakeAbsolutePath(
Global.Config.PathEntries[Global.Emulator.SystemId, "Cheats"].Path,
Global.Emulator.SystemId);
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);
return file;
}
#endregion
} }
} }

View File

@ -72,7 +72,7 @@
this.ColumnsSubMenu = new System.Windows.Forms.ToolStripMenuItem(); this.ColumnsSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.toolStrip1 = new ToolStripEx(); this.toolStrip1 = new ToolStripEx();
this.newToolStripButton = new System.Windows.Forms.ToolStripButton(); this.newToolStripButton = new System.Windows.Forms.ToolStripButton();
this.openToolStripButton = new System.Windows.Forms.ToolStripButton(); this.OpenToolBarItem = new System.Windows.Forms.ToolStripButton();
this.saveToolStripButton = new System.Windows.Forms.ToolStripButton(); this.saveToolStripButton = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator = new System.Windows.Forms.ToolStripSeparator();
this.cutToolStripButton = new System.Windows.Forms.ToolStripButton(); this.cutToolStripButton = new System.Windows.Forms.ToolStripButton();
@ -186,12 +186,12 @@
// //
// OpenMenuItem // OpenMenuItem
// //
this.OpenMenuItem.Enabled = false;
this.OpenMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.OpenFile; this.OpenMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.OpenFile;
this.OpenMenuItem.Name = "OpenMenuItem"; this.OpenMenuItem.Name = "OpenMenuItem";
this.OpenMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O))); this.OpenMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
this.OpenMenuItem.Size = new System.Drawing.Size(195, 22); this.OpenMenuItem.Size = new System.Drawing.Size(195, 22);
this.OpenMenuItem.Text = "&Open..."; this.OpenMenuItem.Text = "&Open...";
this.OpenMenuItem.Click += new System.EventHandler(this.OpenMenuItem_Click);
// //
// SaveMenuItem // SaveMenuItem
// //
@ -213,7 +213,6 @@
// //
// AppendMenuItem // AppendMenuItem
// //
this.AppendMenuItem.Enabled = false;
this.AppendMenuItem.Name = "AppendMenuItem"; this.AppendMenuItem.Name = "AppendMenuItem";
this.AppendMenuItem.Size = new System.Drawing.Size(195, 22); this.AppendMenuItem.Size = new System.Drawing.Size(195, 22);
this.AppendMenuItem.Text = "Append File"; this.AppendMenuItem.Text = "Append File";
@ -231,7 +230,7 @@
// toolStripSeparator4 // toolStripSeparator4
// //
this.toolStripSeparator4.Name = "toolStripSeparator4"; this.toolStripSeparator4.Name = "toolStripSeparator4";
this.toolStripSeparator4.Size = new System.Drawing.Size(149, 6); this.toolStripSeparator4.Size = new System.Drawing.Size(57, 6);
// //
// toolStripSeparator1 // toolStripSeparator1
// //
@ -439,7 +438,7 @@
this.toolStrip1.ClickThrough = true; this.toolStrip1.ClickThrough = true;
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.newToolStripButton, this.newToolStripButton,
this.openToolStripButton, this.OpenToolBarItem,
this.saveToolStripButton, this.saveToolStripButton,
this.toolStripSeparator, this.toolStripSeparator,
this.cutToolStripButton, this.cutToolStripButton,
@ -465,15 +464,15 @@
this.newToolStripButton.Size = new System.Drawing.Size(23, 22); this.newToolStripButton.Size = new System.Drawing.Size(23, 22);
this.newToolStripButton.Text = "&New"; this.newToolStripButton.Text = "&New";
// //
// openToolStripButton // OpenToolBarItem
// //
this.openToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.OpenToolBarItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.openToolStripButton.Enabled = false; this.OpenToolBarItem.Image = ((System.Drawing.Image)(resources.GetObject("OpenToolBarItem.Image")));
this.openToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("openToolStripButton.Image"))); this.OpenToolBarItem.ImageTransparentColor = System.Drawing.Color.Magenta;
this.openToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.OpenToolBarItem.Name = "OpenToolBarItem";
this.openToolStripButton.Name = "openToolStripButton"; this.OpenToolBarItem.Size = new System.Drawing.Size(23, 22);
this.openToolStripButton.Size = new System.Drawing.Size(23, 22); this.OpenToolBarItem.Text = "&Open";
this.openToolStripButton.Text = "&Open"; this.OpenToolBarItem.Click += new System.EventHandler(this.OpenMenuItem_Click);
// //
// saveToolStripButton // saveToolStripButton
// //
@ -643,7 +642,7 @@
private System.Windows.Forms.ToolStripMenuItem RestoreWindowSizeMenuItem; private System.Windows.Forms.ToolStripMenuItem RestoreWindowSizeMenuItem;
private ToolStripEx toolStrip1; private ToolStripEx toolStrip1;
private System.Windows.Forms.ToolStripButton newToolStripButton; private System.Windows.Forms.ToolStripButton newToolStripButton;
private System.Windows.Forms.ToolStripButton openToolStripButton; private System.Windows.Forms.ToolStripButton OpenToolBarItem;
private System.Windows.Forms.ToolStripButton saveToolStripButton; private System.Windows.Forms.ToolStripButton saveToolStripButton;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator; private System.Windows.Forms.ToolStripSeparator toolStripSeparator;
private System.Windows.Forms.ToolStripButton cutToolStripButton; private System.Windows.Forms.ToolStripButton cutToolStripButton;

View File

@ -13,6 +13,8 @@ namespace BizHawk.MultiClient
{ {
public partial class NewCheatForm : Form public partial class NewCheatForm : Form
{ {
private NewCheatList Cheats = new NewCheatList();
public NewCheatForm() public NewCheatForm()
{ {
InitializeComponent(); InitializeComponent();
@ -79,9 +81,28 @@ namespace BizHawk.MultiClient
return true; return true;
} }
private void LoadFile(FileInfo file, bool append)
{
if (file != null)
{
bool result = true;
if (Cheats.Changes)
{
result = AskSave();
}
if (result)
{
Cheats.Load(file.FullName, append);
UpdateListView();
Global.Config.RecentCheats.Add(Cheats.CurrentFileName);
}
}
}
private void NewCheatForm_Load(object sender, EventArgs e) private void NewCheatForm_Load(object sender, EventArgs e)
{ {
} }
#region Events #region Events
@ -99,6 +120,12 @@ namespace BizHawk.MultiClient
RecentSubMenu.DropDownItems.AddRange(Global.Config.RecentCheats.GenerateRecentMenu(LoadFileFromRecent)); RecentSubMenu.DropDownItems.AddRange(Global.Config.RecentCheats.GenerateRecentMenu(LoadFileFromRecent));
} }
private void OpenMenuItem_Click(object sender, EventArgs e)
{
bool append = sender == AppendMenuItem;
LoadFile(NewCheatList.GetFileFromUser(Cheats.CurrentFileName), append);
}
private void ExitMenuItem_Click(object sender, EventArgs e) private void ExitMenuItem_Click(object sender, EventArgs e)
{ {
Close(); Close();

View File

@ -135,7 +135,7 @@
2Mz2wxeg6/UAAAAASUVORK5CYII= 2Mz2wxeg6/UAAAAASUVORK5CYII=
</value> </value>
</data> </data>
<data name="openToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="OpenToolBarItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJHSURBVDhPxZBdSNNhFMb/F110ZZEVhVBgeeHNICiiuggp YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJHSURBVDhPxZBdSNNhFMb/F110ZZEVhVBgeeHNICiiuggp