Cheats moved to Tools

This commit is contained in:
adelikat 2013-11-02 20:48:24 +00:00
parent df6af8e158
commit 9a349ba309
7 changed files with 44 additions and 41 deletions

View File

@ -1185,7 +1185,7 @@ namespace BizHawk.MultiClient
private void CheatsMenuItem_Click(object sender, EventArgs e)
{
LoadCheatsWindow();
GlobalWinF.Tools.Load<Cheats>();
}
private void LuaConsoleMenuItem_Click(object sender, EventArgs e)
@ -2046,7 +2046,7 @@ namespace BizHawk.MultiClient
{
if (CheatStatusButton.Visible)
{
LoadCheatsWindow();
GlobalWinF.Tools.Load<Cheats>();
}
}
@ -2173,7 +2173,7 @@ namespace BizHawk.MultiClient
else if (ext.ToUpper() == ".CHT")
{
Global.CheatList.Load(filePaths[0], false);
LoadCheatsWindow();
GlobalWinF.Tools.Load<Cheats>();
ToolHelpers.UpdateCheatRelatedTools();
}
else if (ext.ToUpper() == ".WCH")

View File

@ -93,7 +93,6 @@ namespace BizHawk.MultiClient
private GBtools.GBGPUView _gbgpuview;
private GBAtools.GBAGPUView _gbagpuview;
private PCEBGViewer _pcebgviewer;
private Cheats _cheats;
private ToolBox _toolbox;
private TI83KeyPad _ti83pad;
private TAStudio _tastudio;
@ -123,13 +122,18 @@ namespace BizHawk.MultiClient
public GenGameGenie Gengg { get { if (_gengg == null) _gengg = new GenGameGenie(); return _gengg; } set { _gengg = value; } }
public NESSoundConfig NesSound { get { if (_nessound == null) _nessound = new NESSoundConfig(); return _nessound; } set { _nessound = value; } }
//TODO: eventually start doing this, rather than tools attempting to talk to tools
public void Cheats_UpdateValues() { if (_cheats != null) { _cheats.UpdateValues(); } }
//TODO: clean me up
public void Cheats_Restart()
{
if (_cheats != null) _cheats.Restart();
else Global.CheatList.NewList(GenerateDefaultCheatFilename());
ToolHelpers.UpdateCheatRelatedTools();
if (GlobalWinF.Tools.Has<Cheats>())
{
GlobalWinF.Tools.Restart<Cheats>();
}
else
{
Global.CheatList.NewList(GenerateDefaultCheatFilename());
ToolHelpers.UpdateCheatRelatedTools();
}
}
public string GenerateDefaultCheatFilename()
@ -355,7 +359,7 @@ namespace BizHawk.MultiClient
}
if (Global.Config.RecentCheats.AutoLoad)
{
LoadCheatsWindow();
GlobalWinF.Tools.Load<Cheats>();
}
if (Global.Config.AutoLoadNESPPU && Global.Emulator is NES)
{
@ -1625,8 +1629,6 @@ namespace BizHawk.MultiClient
}
}
Cheats_UpdateValues();
CurrentlyOpenRom = file.CanonicalFullPath;
HandlePlatformMenus();
StateSlots.Clear();
@ -2096,7 +2098,7 @@ namespace BizHawk.MultiClient
case "Hex Editor": GlobalWinF.Tools.Load<HexEditor>(); break;
case "Trace Logger": LoadTraceLogger(); break;
case "Lua Console": OpenLuaConsole(); break;
case "Cheats": LoadCheatsWindow(); break;
case "Cheats": GlobalWinF.Tools.Load<Cheats>(); break;
case "TAStudio": LoadTAStudio(); break;
case "ToolBox": LoadToolBox(); break;
case "Virtual Pad": LoadVirtualPads(); break;
@ -2820,24 +2822,6 @@ namespace BizHawk.MultiClient
TI83KeyPad1.Focus();
}
public void LoadCheatsWindow()
{
if (_cheats == null)
{
_cheats = new Cheats();
}
if (!_cheats.IsHandleCreated || _cheats.IsDisposed)
{
_cheats = new Cheats();
_cheats.Show();
}
else
{
_cheats.Focus();
}
}
public VideoPluginSettings N64GenerateVideoSettings(GameInfo game, bool hasmovie)
{
string PluginToUse = "";
@ -3218,7 +3202,6 @@ namespace BizHawk.MultiClient
CloseForm(GBGPUView1);
CloseForm(GBAGPUView1);
CloseForm(PCEBGViewer1);
CloseForm(_cheats);
CloseForm(TI83KeyPad1);
CloseForm(TAStudio1); Global.MovieSession.EditorMode = false;
CloseForm(TraceLogger1);

View File

@ -16,7 +16,7 @@ using BizHawk.Emulation.Consoles.Sega;
namespace BizHawk.MultiClient
{
public partial class Cheats : Form
public partial class Cheats : Form, IToolForm
{
public const string NAME = "NamesColumn";
public const string ADDRESS = "AddressColumn";
@ -43,9 +43,11 @@ namespace BizHawk.MultiClient
private int defaultWidth;
private int defaultHeight;
private string _sortedColumn = "";
private string _sortedColumn = String.Empty;
private bool _sortReverse = false;
public bool UpdateBefore { get { return false; } }
public Cheats()
{
InitializeComponent();
@ -54,7 +56,7 @@ namespace BizHawk.MultiClient
CheatListView.QueryItemBkColor += CheatListView_QueryItemBkColor;
CheatListView.VirtualMode = true;
_sortedColumn = "";
_sortedColumn = String.Empty;
_sortReverse = false;
TopMost = Global.Config.CheatsAlwaysOnTop;
}
@ -294,7 +296,7 @@ namespace BizHawk.MultiClient
private void CheatListView_QueryItemText(int index, int column, out string text)
{
text = "";
text = String.Empty;
if (index >= Global.CheatList.Count || Global.CheatList[index].IsSeparator)
{
return;
@ -317,7 +319,7 @@ namespace BizHawk.MultiClient
text = Global.CheatList[index].CompareStr;
break;
case ON:
text = Global.CheatList[index].Enabled ? "*" : "";
text = Global.CheatList[index].Enabled ? "*" : String.Empty;
break;
case DOMAIN:
text = Global.CheatList[index].Domain.Name;
@ -577,6 +579,24 @@ namespace BizHawk.MultiClient
}
}
public string GenerateDefaultCheatFilename()
{
PathEntry pathEntry = Global.Config.PathEntries[Global.Emulator.SystemId, "Cheats"];
if (pathEntry == null)
{
pathEntry = Global.Config.PathEntries[Global.Emulator.SystemId, "Base"];
}
string path = PathManager.MakeAbsolutePath(pathEntry.Path, Global.Emulator.SystemId);
var f = new FileInfo(path);
if (f.Directory != null && f.Directory.Exists == false)
{
f.Directory.Create();
}
return Path.Combine(path, PathManager.FilesystemSafeName(Global.Game) + ".cht");
}
#region Events
#region File

View File

@ -900,8 +900,8 @@ namespace BizHawk.MultiClient
{
GlobalWinF.Tools.UpdateValues<RamWatch>();
GlobalWinF.Tools.UpdateValues<RamSearch>();
GlobalWinF.Tools.UpdateValues<Cheats>();
GlobalWinF.MainForm.UpdateCheatStatus();
GlobalWinF.MainForm.Cheats_UpdateValues();
UpdateValues();
}

View File

@ -112,7 +112,7 @@ namespace BizHawk.MultiClient
public static void client_opencheats()
{
GlobalWinF.MainForm.LoadCheatsWindow();
GlobalWinF.Tools.Load<Cheats>();
}
public static void client_openhexeditor()

View File

@ -88,7 +88,7 @@ namespace BizHawk.MultiClient
private void toolStripButton1_Click(object sender, EventArgs e)
{
GlobalWinF.MainForm.LoadCheatsWindow();
GlobalWinF.Tools.Load<Cheats>();
}
private void toolStripButton2_Click(object sender, EventArgs e)

View File

@ -209,7 +209,7 @@ namespace BizHawk.MultiClient
GlobalWinF.Tools.UpdateValues<RamWatch>();
GlobalWinF.Tools.UpdateValues<RamSearch>();
GlobalWinF.Tools.UpdateValues<HexEditor>();
GlobalWinF.MainForm.Cheats_UpdateValues();
GlobalWinF.Tools.UpdateValues<Cheats>();
GlobalWinF.MainForm.UpdateCheatStatus();
}