diff --git a/BRAM_Manager/App.config b/BRAM_Manager/App.config
index 731f6de..e3382e1 100644
--- a/BRAM_Manager/App.config
+++ b/BRAM_Manager/App.config
@@ -1,6 +1,18 @@
+
+
+
+
+
+
+
+
+ c:\\
+
+
+
\ No newline at end of file
diff --git a/BRAM_Manager/BRAM_Manager.csproj b/BRAM_Manager/BRAM_Manager.csproj
index a29e54f..8eaebfc 100644
--- a/BRAM_Manager/BRAM_Manager.csproj
+++ b/BRAM_Manager/BRAM_Manager.csproj
@@ -34,6 +34,9 @@
4
7.3
+
+ icon.ico
+
@@ -81,5 +84,8 @@
+
+
+
\ No newline at end of file
diff --git a/BRAM_Manager/MainForm.Designer.cs b/BRAM_Manager/MainForm.Designer.cs
index 5a41934..7a1cc76 100644
--- a/BRAM_Manager/MainForm.Designer.cs
+++ b/BRAM_Manager/MainForm.Designer.cs
@@ -85,16 +85,16 @@ private void InitializeComponent() {
this.LeftList.FormattingEnabled = true;
this.LeftList.Location = new System.Drawing.Point(12, 27);
this.LeftList.Name = "LeftList";
- this.LeftList.Size = new System.Drawing.Size(120, 199);
+ this.LeftList.Size = new System.Drawing.Size(130, 199);
this.LeftList.TabIndex = 1;
this.LeftList.SelectedIndexChanged += new System.EventHandler(this.LeftList_SelectedIndexChanged);
//
// RightList
//
this.RightList.FormattingEnabled = true;
- this.RightList.Location = new System.Drawing.Point(238, 27);
+ this.RightList.Location = new System.Drawing.Point(229, 27);
this.RightList.Name = "RightList";
- this.RightList.Size = new System.Drawing.Size(120, 199);
+ this.RightList.Size = new System.Drawing.Size(129, 199);
this.RightList.TabIndex = 2;
this.RightList.SelectedIndexChanged += new System.EventHandler(this.RightList_SelectedIndexChanged);
//
@@ -103,20 +103,20 @@ private void InitializeComponent() {
this.LeftAddress.Location = new System.Drawing.Point(12, 232);
this.LeftAddress.Name = "LeftAddress";
this.LeftAddress.ReadOnly = true;
- this.LeftAddress.Size = new System.Drawing.Size(120, 20);
+ this.LeftAddress.Size = new System.Drawing.Size(130, 20);
this.LeftAddress.TabIndex = 3;
//
// RightAddress
//
- this.RightAddress.Location = new System.Drawing.Point(238, 232);
+ this.RightAddress.Location = new System.Drawing.Point(229, 232);
this.RightAddress.Name = "RightAddress";
this.RightAddress.ReadOnly = true;
- this.RightAddress.Size = new System.Drawing.Size(120, 20);
+ this.RightAddress.Size = new System.Drawing.Size(129, 20);
this.RightAddress.TabIndex = 4;
//
// LeftBrowse
//
- this.LeftBrowse.Location = new System.Drawing.Point(75, 259);
+ this.LeftBrowse.Location = new System.Drawing.Point(86, 259);
this.LeftBrowse.Name = "LeftBrowse";
this.LeftBrowse.Size = new System.Drawing.Size(56, 23);
this.LeftBrowse.TabIndex = 5;
@@ -186,7 +186,7 @@ private void InitializeComponent() {
//
// RightSave
//
- this.RightSave.Location = new System.Drawing.Point(238, 258);
+ this.RightSave.Location = new System.Drawing.Point(229, 258);
this.RightSave.Name = "RightSave";
this.RightSave.Size = new System.Drawing.Size(56, 23);
this.RightSave.TabIndex = 12;
@@ -206,7 +206,7 @@ private void InitializeComponent() {
// RightFreeSpace
//
this.RightFreeSpace.AutoSize = true;
- this.RightFreeSpace.Location = new System.Drawing.Point(235, 285);
+ this.RightFreeSpace.Location = new System.Drawing.Point(226, 285);
this.RightFreeSpace.Name = "RightFreeSpace";
this.RightFreeSpace.Size = new System.Drawing.Size(37, 13);
this.RightFreeSpace.TabIndex = 14;
@@ -215,21 +215,23 @@ private void InitializeComponent() {
// LeftEdited
//
this.LeftEdited.AutoSize = true;
- this.LeftEdited.Location = new System.Drawing.Point(95, 285);
+ this.LeftEdited.Location = new System.Drawing.Point(102, 285);
this.LeftEdited.Name = "LeftEdited";
this.LeftEdited.Size = new System.Drawing.Size(40, 13);
this.LeftEdited.TabIndex = 15;
this.LeftEdited.Text = "Edited ";
+ this.LeftEdited.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.LeftEdited.Visible = false;
//
// RightEdited
//
this.RightEdited.AutoSize = true;
- this.RightEdited.Location = new System.Drawing.Point(321, 285);
+ this.RightEdited.Location = new System.Drawing.Point(318, 285);
this.RightEdited.Name = "RightEdited";
this.RightEdited.Size = new System.Drawing.Size(40, 13);
this.RightEdited.TabIndex = 16;
this.RightEdited.Text = "Edited ";
+ this.RightEdited.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.RightEdited.Visible = false;
//
// MainForm
@@ -254,6 +256,7 @@ private void InitializeComponent() {
this.Controls.Add(this.RightList);
this.Controls.Add(this.LeftList);
this.Controls.Add(this.menuStrip1);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = this.menuStrip1;
this.Name = "MainForm";
diff --git a/BRAM_Manager/MainForm.cs b/BRAM_Manager/MainForm.cs
index 256a0a0..cf9ee00 100644
--- a/BRAM_Manager/MainForm.cs
+++ b/BRAM_Manager/MainForm.cs
@@ -11,9 +11,27 @@
namespace BRAM_Manager {
public partial class MainForm : Form {
- public string initialDirectory = "c:\\";
+ public string savedInitialDirectory = "c:\\";
public BRAM leftBRAM, rightBRAM;
+ public char[] characterMap = new char[] {
+ ' ', '▁', '▂', '▃', '▄', '▅', '▆', '▇', '█', '♤', '♡', '◇', '♧', '○', '●', '/',
+ '\\', '円', '年', '月', '日', '時', '分', '秒', '◢', '◣', '◥', '◤', '→', '←', '↑', '↓',
+ ' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?',
+ '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '¥', ']', '^', '_',
+ ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', ':', '}', '~', '☓',
+ ' ', '。', '「', '」', '、', '・', 'を', 'ぁ', '╭', '─', '╮', '│', '│', '╰', '─', '╯',
+ 'ー', 'あ', 'い', 'う', 'え', 'お', 'か', 'き', 'く', 'け', 'こ', 'さ', 'し', 'す', 'せ', 'そ',
+ ' ', '。', '「', '」', '、', '・', 'ヲ', 'ァ', '┬', '│', '┴', 'ォ', 'ャ', 'ュ', 'ョ', 'ッ',
+ 'ー', 'ア', 'イ', 'ウ', 'エ', 'オ', 'カ', 'キ', 'ク', 'ケ', 'コ', 'サ', 'シ', 'ス', 'セ', 'ソ',
+ 'タ', 'チ', 'ツ', 'テ', 'ト', 'ナ', 'ニ', 'ヌ', 'ネ', 'ノ', 'ハ', 'ヒ', 'フ', 'ヘ', 'ホ', 'マ',
+ 'ミ', 'ム', 'メ', 'モ', 'ヤ', 'ユ', 'ヨ', 'ラ', 'リ', 'ル', 'レ', 'ロ', 'ワ', 'ン', '゛', '゜',
+ 'た', 'ち', 'つ', 'て', 'と', 'な', 'に', 'ぬ', 'ね', 'の', 'は', 'ひ', 'ふ', 'へ', 'ほ', 'ま',
+ 'み', 'む', 'め', 'も', 'や', 'ゆ', 'よ', 'ら', 'り', 'る', 'れ', 'ろ', 'わ', 'ん', '゛', '©'};
+
public struct BRAM {
public byte[] data;
public byte[] header;
@@ -33,14 +51,20 @@ public struct BRAMEntry {
public MainForm() {
InitializeComponent();
+
+ savedInitialDirectory = Properties.Settings.Default.savedInitialDirectory;
}
//--------------------------------------------------
// Main functions
//--------------------------------------------------
- // Opens a file browser and returns the path to the selected file
public string OpenFileBrowser() {
+ return OpenFileBrowser(savedInitialDirectory);
+ }
+
+ // Opens a file browser and returns the path to the selected file
+ public string OpenFileBrowser(string initialDirectory) {
using (OpenFileDialog openFileDialog = new OpenFileDialog()) {
openFileDialog.InitialDirectory = initialDirectory;
openFileDialog.Filter = "BRAM files (*.bup;*.sav)|*.bup;*.sav|All files (*.*)|*.*";
@@ -48,7 +72,9 @@ public string OpenFileBrowser() {
openFileDialog.RestoreDirectory = true;
if (openFileDialog.ShowDialog() == DialogResult.OK) {
- initialDirectory = Path.GetDirectoryName(openFileDialog.FileName);
+ savedInitialDirectory = Path.GetDirectoryName(openFileDialog.FileName);
+ Properties.Settings.Default.savedInitialDirectory = savedInitialDirectory;
+ Properties.Settings.Default.Save();
return openFileDialog.FileName;
}
}
@@ -63,7 +89,7 @@ public string SaveFileBrowser(string defaultDirectory = "", string defaultFileNa
if (defaultDirectory.Length > 0)
saveFileDialog.InitialDirectory = defaultDirectory;
else
- saveFileDialog.InitialDirectory = initialDirectory;
+ saveFileDialog.InitialDirectory = savedInitialDirectory;
if (defaultFileName.Length > 0)
saveFileDialog.FileName = defaultFileName;
saveFileDialog.Filter = "BRAM files (*.bup;*.sav)|*.bup;*.sav|All files (*.*)|*.*";
@@ -71,7 +97,9 @@ public string SaveFileBrowser(string defaultDirectory = "", string defaultFileNa
saveFileDialog.RestoreDirectory = true;
if (saveFileDialog.ShowDialog() == DialogResult.OK) {
- initialDirectory = Path.GetDirectoryName(saveFileDialog.FileName);
+ savedInitialDirectory = Path.GetDirectoryName(saveFileDialog.FileName);
+ Properties.Settings.Default.savedInitialDirectory = savedInitialDirectory;
+ Properties.Settings.Default.Save();
return saveFileDialog.FileName;
}
@@ -91,6 +119,18 @@ public byte[] ReadBytes(byte[] data, int from, int to) {
return result;
}
+ public string DecodeBytes(byte[] data) {
+ string result = string.Empty;
+
+ foreach (byte Byte in data) {
+ if (characterMap.Length > Byte) {
+ result += characterMap[Byte];
+ }
+ }
+
+ return result;
+ }
+
// Writes bytes to a byte array, given a starting location and a length
public void WriteBytes(byte[] input, byte[] dest, int startLoc, int length) {
int index = 0;
@@ -105,7 +145,17 @@ public BRAM ReadFile(string file) {
BRAM result = new BRAM();
result.saves = new List();
- string dataString = System.IO.File.ReadAllText(file);
+ string dataString;
+
+ try {
+ dataString = System.IO.File.ReadAllText(file);
+ }
+ catch (IOException)
+ {
+ MessageBox.Show("File is in use.");
+ return result;
+ }
+
byte[] data = System.IO.File.ReadAllBytes(file);
if (dataString.StartsWith("HUBM")) {
int length = data.Length;
@@ -127,7 +177,8 @@ public BRAM ReadFile(string file) {
newEntry.length = nextLength;
newEntry.data = ReadBytes(data, nextSaveIndex, nextSaveIndex + nextLength);
- newEntry.name = System.Text.Encoding.UTF8.GetString(ReadBytes(data, nextSaveIndex + 6, nextSaveIndex + 16));
+ //newEntry.name = System.Text.Encoding.UTF8.GetString(ReadBytes(data, nextSaveIndex + 6, nextSaveIndex + 16));
+ newEntry.name = DecodeBytes(ReadBytes(data, nextSaveIndex + 6, nextSaveIndex + 16));
newEntry.startsAt = nextSaveIndex;
result.saves.Add(newEntry);
@@ -138,7 +189,7 @@ public BRAM ReadFile(string file) {
result.loaded = true;
}
else {
- System.Windows.Forms.MessageBox.Show("File is not a valid BRAM file.");
+ MessageBox.Show("File is not a valid BRAM file.");
}
return result;
@@ -211,7 +262,8 @@ public void OpenAndLoadFile(string path, ref BRAM bram, ref ListBox list, ref Te
// Main interface
private void LeftBrowse_Click(object sender, EventArgs e) {
- string path = OpenFileBrowser();
+ string openPath = LeftAddress.Text.Length > 0 ? Path.GetDirectoryName(LeftAddress.Text) : savedInitialDirectory;
+ string path = OpenFileBrowser(openPath);
if (path.Length == 0)
return;
@@ -219,7 +271,8 @@ private void LeftBrowse_Click(object sender, EventArgs e) {
}
private void RightBrowse_Click(object sender, EventArgs e) {
- string path = OpenFileBrowser();
+ string openPath = RightAddress.Text.Length > 0 ? Path.GetDirectoryName(RightAddress.Text) : savedInitialDirectory;
+ string path = OpenFileBrowser(openPath);
if (path.Length == 0)
return;
@@ -252,7 +305,7 @@ private void DeleteButton_Click(object sender, EventArgs e) {
selectedList = ref RightList;
}
else {
- System.Windows.Forms.MessageBox.Show("Please select a file to delete.");
+ MessageBox.Show("Please select a file to delete.");
return;
}
@@ -282,7 +335,7 @@ private void DeleteButton_Click(object sender, EventArgs e) {
private void CopyButton_Click(object sender, EventArgs e) {
if (!(leftBRAM.loaded && rightBRAM.loaded)) {
- System.Windows.Forms.MessageBox.Show("Please load two BRAM files.");
+ MessageBox.Show("Please load two BRAM files.");
return;
}
@@ -301,15 +354,24 @@ private void CopyButton_Click(object sender, EventArgs e) {
otherList = LeftList;
}
else {
- System.Windows.Forms.MessageBox.Show("Please select a file to copy.");
+ MessageBox.Show("Please select a file to copy.");
return;
}
BRAMEntry entry = selectedBRAM.saves[selectedList.SelectedIndex];
if (otherBRAM.freeSpace < entry.length) {
- System.Windows.Forms.MessageBox.Show("Not enough space in destination BRAM.");
+ MessageBox.Show("Not enough space in destination BRAM.");
return;
}
+
+ foreach (BRAMEntry otherEntry in otherBRAM.saves) {
+ if (otherEntry.name == entry.name) {
+ if (MessageBox.Show("Filename already exists, which can cause issues. Are you sure you want to copy?", "", MessageBoxButtons.YesNo) == DialogResult.No) {
+ return;
+ }
+ }
+ }
+
otherBRAM.saves.Add(entry);
otherList.Items.Add(String.Format("{0} ({1}B)", entry.name, entry.length));
otherBRAM.freeSpace -= entry.length;
@@ -333,7 +395,7 @@ private void UpButton_Click(object sender, EventArgs e) {
selectedList = ref RightList;
}
else {
- System.Windows.Forms.MessageBox.Show("Please select a file to move.");
+ MessageBox.Show("Please select a file to move.");
return;
}
@@ -360,7 +422,7 @@ private void DownButton_Click(object sender, EventArgs e) {
selectedList = ref RightList;
}
else {
- System.Windows.Forms.MessageBox.Show("Please select a file to move.");
+ MessageBox.Show("Please select a file to move.");
return;
}
@@ -396,6 +458,11 @@ private void newBRAMToolStripMenuItem_Click(object sender, EventArgs e) {
}
private void clearAllToolStripMenuItem_Click(object sender, EventArgs e) {
+ if (leftBRAM.edited || rightBRAM.edited) {
+ if (MessageBox.Show("There are unsaved changes. Are you sure you want to clear?", "", MessageBoxButtons.YesNo) == DialogResult.No) {
+ return;
+ }
+ }
leftBRAM = new BRAM();
rightBRAM = new BRAM();
LeftList.Items.Clear();
@@ -404,6 +471,8 @@ private void clearAllToolStripMenuItem_Click(object sender, EventArgs e) {
RightAddress.Text = "";
LeftFreeSpace.Text = "";
RightFreeSpace.Text = "";
+ LeftEdited.Visible = false;
+ RightEdited.Visible = false;
}
// Misc
@@ -415,7 +484,7 @@ private void LeftList_SelectedIndexChanged(object sender, EventArgs e) {
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) {
if (leftBRAM.edited || rightBRAM.edited) {
- if (MessageBox.Show("There are unsaved changes. Are you sure you want to quit?", "BRAM Manager", MessageBoxButtons.YesNo) == DialogResult.No ){
+ if (MessageBox.Show("There are unsaved changes. Are you sure you want to quit?", "", MessageBoxButtons.YesNo) == DialogResult.No ){
e.Cancel = true;
}
}
diff --git a/BRAM_Manager/Properties/Settings.Designer.cs b/BRAM_Manager/Properties/Settings.Designer.cs
index d352b25..6c5000f 100644
--- a/BRAM_Manager/Properties/Settings.Designer.cs
+++ b/BRAM_Manager/Properties/Settings.Designer.cs
@@ -9,18 +9,30 @@
//------------------------------------------------------------------------------
namespace BRAM_Manager.Properties {
-
-
+
+
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
-
+
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-
+
public static Settings Default {
get {
return defaultInstance;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("c:\\\\")]
+ public string savedInitialDirectory {
+ get {
+ return ((string)(this["savedInitialDirectory"]));
+ }
+ set {
+ this["savedInitialDirectory"] = value;
+ }
+ }
}
}
diff --git a/BRAM_Manager/Properties/Settings.settings b/BRAM_Manager/Properties/Settings.settings
index 3964565..f18ffaa 100644
--- a/BRAM_Manager/Properties/Settings.settings
+++ b/BRAM_Manager/Properties/Settings.settings
@@ -1,7 +1,9 @@
-
-
-
-
-
-
+
+
+
+
+ c:\\
+
+
+
\ No newline at end of file
diff --git a/BRAM_Manager/icon.ico b/BRAM_Manager/icon.ico
new file mode 100644
index 0000000..0607671
Binary files /dev/null and b/BRAM_Manager/icon.ico differ