Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a612ea5cfd | |||
|
|
5a93500001 | ||
|
|
905574d120 | ||
|
|
063254ccb6 | ||
|
|
8a908bf60c | ||
|
|
239b001daa | ||
|
|
03141ff8f0 | ||
|
|
e6e0c73dcd | ||
|
|
7d25bd8519 | ||
|
|
c61eead2ba | ||
|
|
2d6c5a7e26 | ||
|
|
b6be1a9ec1 | ||
|
|
5107b5b850 | ||
|
|
33f204fc37 | ||
|
|
dc99d2328d | ||
|
|
0817f01538 | ||
|
|
1b4caa8e34 | ||
|
|
6981a16a67 | ||
|
|
14054dc06f | ||
|
|
c04bb9d070 | ||
|
|
32f67308fa | ||
| efaba1f3d9 | |||
|
|
b368f33351 | ||
|
|
48ea11ab2e | ||
|
|
3e261ee077 | ||
|
|
a4939e5bf4 | ||
|
|
1c588291b7 | ||
|
|
39e4a6114f | ||
|
|
b54610c2f6 |
@@ -57,11 +57,11 @@ namespace ROMVault2
|
||||
|
||||
private static string clean(string s)
|
||||
{
|
||||
s = s.Replace("&", "&");
|
||||
s = s.Replace("\"", """);
|
||||
s = s.Replace("'", "'");
|
||||
s = s.Replace("<", "<");
|
||||
s = s.Replace(">", ">");
|
||||
s = s.Replace("&", "&");
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
@@ -142,6 +142,8 @@ namespace ROMVault2.DatReaders
|
||||
}
|
||||
|
||||
thisFileType = forceZipping.ToLower() != "no" ? FileType.ZipFile : FileType.File;
|
||||
if (Settings.FixLevel == eFixLevel.Uncompressed)
|
||||
thisFileType = FileType.File;
|
||||
tDir.Dat = tDat;
|
||||
return true;
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace ROMVault2.DatReaders
|
||||
}
|
||||
}
|
||||
|
||||
thisFileType = FileType.ZipFile;
|
||||
thisFileType = Settings.FixLevel == eFixLevel.Uncompressed ? FileType.File : FileType.ZipFile;
|
||||
tDir.Dat = tDat;
|
||||
return true;
|
||||
|
||||
|
||||
@@ -16,7 +16,9 @@ namespace ROMVault2.DatReaders
|
||||
|
||||
public static bool ReadDat(ref RvDir tDat, XmlDocument doc)
|
||||
{
|
||||
if (!LoadHeaderFromDat(ref tDat, ref doc))
|
||||
FileType thisFileType = FileType.Unknown;
|
||||
|
||||
if (!LoadHeaderFromDat(ref tDat, ref doc, ref thisFileType))
|
||||
return false;
|
||||
|
||||
if (doc.DocumentElement == null)
|
||||
@@ -27,13 +29,13 @@ namespace ROMVault2.DatReaders
|
||||
return false;
|
||||
for (int i = 0; i < gameNodeList.Count; i++)
|
||||
{
|
||||
LoadGameFromDat(ref tDat, gameNodeList[i]);
|
||||
LoadGameFromDat(ref tDat, gameNodeList[i], thisFileType);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool LoadHeaderFromDat(ref RvDir tDir, ref XmlDocument doc)
|
||||
private static bool LoadHeaderFromDat(ref RvDir tDir, ref XmlDocument doc, ref FileType thisFileType)
|
||||
{
|
||||
XmlNodeList head = doc.SelectNodes("softwarelist");
|
||||
if (head == null)
|
||||
@@ -62,21 +64,38 @@ namespace ROMVault2.DatReaders
|
||||
tDat.AddData(RvDat.DatData.MergeType, "split");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
val = VarFix.String(head[0].Attributes.GetNamedItem("forcepacking")).ToLower();
|
||||
switch (val.ToLower())
|
||||
{
|
||||
case "zip":
|
||||
tDat.AddData(RvDat.DatData.FileType, "zip");
|
||||
thisFileType = FileType.ZipFile;
|
||||
break;
|
||||
case "unzip":
|
||||
case "file":
|
||||
tDat.AddData(RvDat.DatData.FileType, "file");
|
||||
thisFileType = FileType.File;
|
||||
break;
|
||||
default:
|
||||
thisFileType = FileType.ZipFile;
|
||||
break;
|
||||
}
|
||||
if (Settings.FixLevel == eFixLevel.Uncompressed)
|
||||
thisFileType = FileType.File;
|
||||
|
||||
tDir.Dat = tDat;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void LoadGameFromDat(ref RvDir tDat, XmlNode gameNode)
|
||||
private static void LoadGameFromDat(ref RvDir tDat, XmlNode gameNode, FileType thisFileType)
|
||||
{
|
||||
if (gameNode.Attributes == null)
|
||||
return;
|
||||
|
||||
RvDir parent = tDat;
|
||||
|
||||
RvDir tDir = new RvDir(FileType.Zip)
|
||||
RvDir tDir = new RvDir(DBTypeGet.DirFromFile(thisFileType))
|
||||
{
|
||||
Name = VarFix.CleanFileName(gameNode.Attributes.GetNamedItem("name")),
|
||||
Game = new RvGame(),
|
||||
@@ -137,7 +156,7 @@ namespace ROMVault2.DatReaders
|
||||
if (romNodeList != null)
|
||||
for (int iR = 0; iR < romNodeList.Count; iR++)
|
||||
{
|
||||
LoadRomFromDat(ref tDir, romNodeList[iR]);
|
||||
LoadRomFromDat(ref tDir, romNodeList[iR], thisFileType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -164,7 +183,7 @@ namespace ROMVault2.DatReaders
|
||||
|
||||
}
|
||||
|
||||
private static void LoadRomFromDat(ref RvDir tGame, XmlNode romNode)
|
||||
private static void LoadRomFromDat(ref RvDir tGame, XmlNode romNode, FileType thisFileType)
|
||||
{
|
||||
if (romNode.Attributes == null)
|
||||
return;
|
||||
@@ -173,7 +192,7 @@ namespace ROMVault2.DatReaders
|
||||
string loadflag = VarFix.String(romNode.Attributes.GetNamedItem("loadflag"));
|
||||
if (name != null)
|
||||
{
|
||||
RvFile tRom = new RvFile(FileType.ZipFile)
|
||||
RvFile tRom = new RvFile(thisFileType) // changed
|
||||
{
|
||||
Name = VarFix.CleanFullFileName(name),
|
||||
Size = VarFix.ULong(romNode.Attributes.GetNamedItem("size")),
|
||||
|
||||
@@ -270,6 +270,10 @@ namespace ROMVault2.DatReaders
|
||||
// loop the ROMs in the parent sets
|
||||
for (int r1 = 0; r1 < romofGame.ChildCount; r1++)
|
||||
{
|
||||
// don't search fixes for files marked as nodump
|
||||
if (((RvFile)mGame.Child(r)).Status == "nodump" || ((RvFile)romofGame.Child(r1)).Status == "nodump")
|
||||
continue;
|
||||
|
||||
// only find fixes if the Name and the Size of the ROMs are the same
|
||||
if (mGame.Child(r).Name != romofGame.Child(r1).Name || ((RvFile)mGame.Child(r)).Size != ((RvFile)romofGame.Child(r1)).Size)
|
||||
continue;
|
||||
@@ -285,11 +289,13 @@ namespace ROMVault2.DatReaders
|
||||
if (b1)
|
||||
{
|
||||
((RvFile)mGame.Child(r)).CRC = ((RvFile)romofGame.Child(r1)).CRC;
|
||||
((RvFile)mGame.Child(r)).FileStatusSet(FileStatus.CRCFromDAT);
|
||||
((RvFile)mGame.Child(r)).Status = "(CRCFound)";
|
||||
}
|
||||
else
|
||||
{
|
||||
((RvFile)romofGame.Child(r1)).CRC = ((RvFile)mGame.Child(r)).CRC;
|
||||
((RvFile)romofGame.Child(r1)).FileStatusSet(FileStatus.CRCFromDAT);
|
||||
((RvFile)romofGame.Child(r1)).Status = "(CRCFound)";
|
||||
}
|
||||
|
||||
@@ -428,6 +434,8 @@ namespace ROMVault2.DatReaders
|
||||
byte[] chdMD51 = ((RvFile)romofGame.Child(r1)).MD5CHD;
|
||||
if (chdMD50 != null && chdMD51 != null && !ArrByte.bCompare(chdMD50, chdMD51)) continue;
|
||||
|
||||
// don't merge if only one of the ROM is nodump
|
||||
if ((((RvFile)romofGame.Child(r1)).Status == "nodump") != (((RvFile)mGame.Child(r)).Status == "nodump")) continue;
|
||||
|
||||
found = true;
|
||||
break;
|
||||
@@ -446,9 +454,9 @@ namespace ROMVault2.DatReaders
|
||||
return;
|
||||
|
||||
string parentName = searchGame.Game.GetData(RvGame.GameData.RomOf);
|
||||
if (String.IsNullOrEmpty(parentName) || parentName==searchGame.Name)
|
||||
if (String.IsNullOrEmpty(parentName) || parentName == searchGame.Name)
|
||||
parentName = searchGame.Game.GetData(RvGame.GameData.CloneOf);
|
||||
if (String.IsNullOrEmpty(parentName) || parentName==searchGame.Name)
|
||||
if (String.IsNullOrEmpty(parentName) || parentName == searchGame.Name)
|
||||
return;
|
||||
|
||||
int intIndex;
|
||||
|
||||
@@ -28,20 +28,24 @@ namespace ROMVault2.DatReaders
|
||||
XmlNodeList dirNodeList = doc.DocumentElement.SelectNodes("dir");
|
||||
if (dirNodeList != null)
|
||||
{
|
||||
for (int i = 0; i < dirNodeList.Count; i++)
|
||||
{
|
||||
LoadDirFromDat(ref tDat, dirNodeList[i], thisFileType);
|
||||
}
|
||||
foreach (XmlNode dirNode in dirNodeList)
|
||||
LoadDirFromDat(ref tDat, dirNode, thisFileType);
|
||||
}
|
||||
|
||||
XmlNodeList gameNodeList = doc.DocumentElement.SelectNodes("game");
|
||||
|
||||
if (gameNodeList != null)
|
||||
{
|
||||
for (int i = 0; i < gameNodeList.Count; i++)
|
||||
{
|
||||
LoadGameFromDat(ref tDat, gameNodeList[i], thisFileType);
|
||||
}
|
||||
foreach (XmlNode gameNode in gameNodeList)
|
||||
LoadGameFromDat(ref tDat, gameNode, thisFileType);
|
||||
}
|
||||
|
||||
XmlNodeList machineNodeList = doc.DocumentElement.SelectNodes("machine");
|
||||
|
||||
if (machineNodeList != null)
|
||||
{
|
||||
foreach (XmlNode machineNode in machineNodeList)
|
||||
LoadGameFromDat(ref tDat, machineNode, thisFileType);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -60,22 +64,27 @@ namespace ROMVault2.DatReaders
|
||||
XmlNodeList dirNodeList = doc.DocumentElement.SelectNodes("dir");
|
||||
if (dirNodeList != null)
|
||||
{
|
||||
for (int i = 0; i < dirNodeList.Count; i++)
|
||||
{
|
||||
LoadDirFromDat(ref tDat, dirNodeList[i], thisFileType);
|
||||
}
|
||||
foreach (XmlNode dirNode in dirNodeList)
|
||||
LoadDirFromDat(ref tDat, dirNode, thisFileType);
|
||||
}
|
||||
|
||||
XmlNodeList gameNodeList = doc.DocumentElement.SelectNodes("game");
|
||||
|
||||
if (gameNodeList != null)
|
||||
{
|
||||
for (int i = 0; i < gameNodeList.Count; i++)
|
||||
{
|
||||
LoadGameFromDat(ref tDat, gameNodeList[i], thisFileType);
|
||||
}
|
||||
foreach (XmlNode gameNode in gameNodeList)
|
||||
LoadGameFromDat(ref tDat, gameNode, thisFileType);
|
||||
}
|
||||
|
||||
XmlNodeList machineNodeList = doc.DocumentElement.SelectNodes("machine");
|
||||
|
||||
if (machineNodeList != null)
|
||||
{
|
||||
foreach (XmlNode machineNode in machineNodeList)
|
||||
LoadGameFromDat(ref tDat, machineNode, thisFileType);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -149,13 +158,15 @@ namespace ROMVault2.DatReaders
|
||||
}
|
||||
val = VarFix.String(packingNode.Attributes.GetNamedItem("dir")).ToLower(); // noautodir , nogame
|
||||
if (!String.IsNullOrEmpty(val))
|
||||
tDat.AddData(RvDat.DatData.DirSetup,val);
|
||||
tDat.AddData(RvDat.DatData.DirSetup, val);
|
||||
}
|
||||
}
|
||||
|
||||
// Look for: <notzipped>true</notzipped>
|
||||
string notzipped = VarFix.String(head.SelectSingleNode("notzipped"));
|
||||
if (notzipped.ToLower() == "true" || notzipped.ToLower() == "yes") thisFileType = FileType.File;
|
||||
if (Settings.FixLevel == eFixLevel.Uncompressed)
|
||||
thisFileType = FileType.File;
|
||||
|
||||
tDir.Dat = tDat;
|
||||
return true;
|
||||
|
||||
8
ROMVault2/FrmMain.Designer.cs
generated
8
ROMVault2/FrmMain.Designer.cs
generated
@@ -656,6 +656,7 @@
|
||||
this.GameGrid.SelectionChanged += new System.EventHandler(this.GameGridSelectionChanged);
|
||||
this.GameGrid.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.GameGridMouseDoubleClick);
|
||||
this.GameGrid.MouseUp += new System.Windows.Forms.MouseEventHandler(this.GameGrid_MouseUp);
|
||||
this.GameGrid.ColumnHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.GameGridColumnHeaderMouseClick);
|
||||
//
|
||||
// Type
|
||||
//
|
||||
@@ -664,7 +665,7 @@
|
||||
this.Type.Name = "Type";
|
||||
this.Type.ReadOnly = true;
|
||||
this.Type.Resizable = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.Type.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
|
||||
this.Type.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
|
||||
this.Type.Width = 40;
|
||||
//
|
||||
// CGame
|
||||
@@ -672,6 +673,7 @@
|
||||
this.CGame.HeaderText = "Game (Directory / Zip)";
|
||||
this.CGame.Name = "CGame";
|
||||
this.CGame.ReadOnly = true;
|
||||
this.CGame.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Programmatic;
|
||||
this.CGame.Width = 220;
|
||||
//
|
||||
// CDescription
|
||||
@@ -679,6 +681,7 @@
|
||||
this.CDescription.HeaderText = "Description";
|
||||
this.CDescription.Name = "CDescription";
|
||||
this.CDescription.ReadOnly = true;
|
||||
this.CDescription.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Programmatic;
|
||||
this.CDescription.Width = 220;
|
||||
//
|
||||
// CCorrect
|
||||
@@ -687,6 +690,7 @@
|
||||
this.CCorrect.Name = "CCorrect";
|
||||
this.CCorrect.ReadOnly = true;
|
||||
this.CCorrect.Resizable = System.Windows.Forms.DataGridViewTriState.False;
|
||||
this.CCorrect.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
|
||||
this.CCorrect.Width = 500;
|
||||
//
|
||||
// RomGrid
|
||||
@@ -756,7 +760,7 @@
|
||||
this.CGot.Name = "CGot";
|
||||
this.CGot.ReadOnly = true;
|
||||
this.CGot.Resizable = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.CGot.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
|
||||
this.CGot.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
|
||||
this.CGot.Width = 65;
|
||||
//
|
||||
// CRom
|
||||
|
||||
@@ -7,7 +7,6 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.ServiceModel;
|
||||
using System.Windows.Forms;
|
||||
using ROMVault2.Properties;
|
||||
using ROMVault2.RvDB;
|
||||
@@ -18,7 +17,6 @@ namespace ROMVault2
|
||||
{
|
||||
public partial class FrmMain : Form
|
||||
{
|
||||
|
||||
private static readonly Color CBlue = Color.FromArgb(214, 214, 255);
|
||||
private static readonly Color CGreyBlue = Color.FromArgb(214, 224, 255);
|
||||
private static readonly Color CRed = Color.FromArgb(255, 214, 214);
|
||||
@@ -35,10 +33,13 @@ namespace ROMVault2
|
||||
private static readonly Color CWhite = Color.FromArgb(255, 255, 255);
|
||||
|
||||
private readonly Color[] _displayColor;
|
||||
private readonly Color[] _fontColor;
|
||||
|
||||
private bool _updatingGameGrid;
|
||||
|
||||
public static int[] GameGridColumnXPositions;
|
||||
|
||||
private int _gameGridSortColumnIndex;
|
||||
private SortOrder _gameGridSortOrder = SortOrder.Descending;
|
||||
private static int[] _gameGridColumnXPositions;
|
||||
|
||||
private FrmKey _fk;
|
||||
|
||||
@@ -70,6 +71,7 @@ namespace ROMVault2
|
||||
|
||||
|
||||
_displayColor = new Color[(int)RepStatus.EndValue];
|
||||
_fontColor = new Color[(int)RepStatus.EndValue];
|
||||
|
||||
// RepStatus.UnSet
|
||||
|
||||
@@ -101,7 +103,10 @@ namespace ROMVault2
|
||||
|
||||
_displayColor[(int)RepStatus.Deleted] = CWhite;
|
||||
|
||||
GameGridColumnXPositions = new int[(int)RepStatus.EndValue];
|
||||
for (int i = 0; i < (int)RepStatus.EndValue; i++)
|
||||
_fontColor[i] = contrasty(_displayColor[i]);
|
||||
|
||||
_gameGridColumnXPositions = new int[(int)RepStatus.EndValue];
|
||||
|
||||
DirTree.Setup(ref DB.DirTree);
|
||||
|
||||
@@ -410,33 +415,33 @@ namespace ROMVault2
|
||||
if (cf != DirTree.GetSelected())
|
||||
DatSetSelected(cf);
|
||||
|
||||
if (e.Button == MouseButtons.Right)
|
||||
if (e.Button != MouseButtons.Right)
|
||||
return;
|
||||
|
||||
|
||||
RvDir tn = (RvDir)sender;
|
||||
|
||||
ContextMenu mnuContext = new ContextMenu();
|
||||
|
||||
MenuItem mnuFile = new MenuItem
|
||||
{
|
||||
RvDir tn = (RvDir)sender;
|
||||
Index = 0,
|
||||
Text = Resources.FrmMain_DirTreeRvSelected_Set_ROM_DIR,
|
||||
Tag = tn.TreeFullName
|
||||
};
|
||||
mnuFile.Click += MnuFileClick;
|
||||
mnuContext.MenuItems.Add(mnuFile);
|
||||
|
||||
ContextMenu mnuContext = new ContextMenu();
|
||||
|
||||
MenuItem mnuFile = new MenuItem
|
||||
{
|
||||
Index = 0,
|
||||
Text = Resources.FrmMain_DirTreeRvSelected_Set_ROM_DIR,
|
||||
Tag = tn.TreeFullName
|
||||
};
|
||||
mnuFile.Click += MnuFileClick;
|
||||
mnuContext.MenuItems.Add(mnuFile);
|
||||
|
||||
MenuItem mnuMakeDat = new MenuItem
|
||||
{
|
||||
Index = 1,
|
||||
Text = @"Make Dat",
|
||||
Tag = tn
|
||||
};
|
||||
mnuMakeDat.Click += MnuMakeDatClick;
|
||||
mnuContext.MenuItems.Add(mnuMakeDat);
|
||||
|
||||
|
||||
mnuContext.Show(DirTree, e.Location);
|
||||
}
|
||||
MenuItem mnuMakeDat = new MenuItem
|
||||
{
|
||||
Index = 1,
|
||||
Text = @"Make Dat",
|
||||
Tag = tn
|
||||
};
|
||||
mnuMakeDat.Click += MnuMakeDatClick;
|
||||
mnuContext.MenuItems.Add(mnuMakeDat);
|
||||
|
||||
mnuContext.Show(DirTree, e.Location);
|
||||
}
|
||||
|
||||
#region "DAT display code"
|
||||
@@ -444,9 +449,23 @@ namespace ROMVault2
|
||||
private void DatSetSelected(RvBase cf)
|
||||
{
|
||||
DirTree.Refresh();
|
||||
|
||||
if (Settings.IsMono)
|
||||
{
|
||||
if (GameGrid.RowCount > 0)
|
||||
GameGrid.CurrentCell = GameGrid[0,0];
|
||||
if (RomGrid.RowCount > 0)
|
||||
RomGrid.CurrentCell = RomGrid[0,0];
|
||||
}
|
||||
|
||||
GameGrid.Rows.Clear();
|
||||
RomGrid.Rows.Clear();
|
||||
|
||||
// clear sorting
|
||||
GameGrid.Columns[_gameGridSortColumnIndex].HeaderCell.SortGlyphDirection = SortOrder.None;
|
||||
_gameGridSortColumnIndex = 0;
|
||||
_gameGridSortOrder = SortOrder.Descending;
|
||||
|
||||
if (cf == null)
|
||||
return;
|
||||
|
||||
@@ -579,12 +598,27 @@ namespace ROMVault2
|
||||
lblDITRomsUnknown.Text = (tDir.DirStatus.CountUnknown() + tDir.DirStatus.CountInToSort()).ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
_updatingGameGrid = true;
|
||||
|
||||
if (Settings.IsMono)
|
||||
{
|
||||
if (GameGrid.RowCount > 0)
|
||||
GameGrid.CurrentCell = GameGrid[0,0];
|
||||
if (RomGrid.RowCount > 0)
|
||||
RomGrid.CurrentCell = RomGrid[0,0];
|
||||
}
|
||||
|
||||
GameGrid.Rows.Clear();
|
||||
RomGrid.Rows.Clear();
|
||||
|
||||
// clear sorting
|
||||
GameGrid.Columns[_gameGridSortColumnIndex].HeaderCell.SortGlyphDirection = SortOrder.None;
|
||||
_gameGridSortColumnIndex = 0;
|
||||
_gameGridSortOrder = SortOrder.Descending;
|
||||
|
||||
|
||||
ReportStatus tDirStat;
|
||||
|
||||
GameGridColumnXPositions = new int[(int)RepStatus.EndValue];
|
||||
_gameGridColumnXPositions = new int[(int)RepStatus.EndValue];
|
||||
|
||||
int rowCount = 0;
|
||||
for (int j = 0; j < tDir.ChildCount; j++)
|
||||
@@ -621,8 +655,8 @@ namespace ROMVault2
|
||||
if (tDirStat.Get(RepairStatus.DisplayOrder[l]) <= 0) continue;
|
||||
|
||||
int len = DigitLength(tDirStat.Get(RepairStatus.DisplayOrder[l])) * 7 + 26;
|
||||
if (len > GameGridColumnXPositions[columnIndex])
|
||||
GameGridColumnXPositions[columnIndex] = len;
|
||||
if (len > _gameGridColumnXPositions[columnIndex])
|
||||
_gameGridColumnXPositions[columnIndex] = len;
|
||||
columnIndex++;
|
||||
}
|
||||
}
|
||||
@@ -631,8 +665,8 @@ namespace ROMVault2
|
||||
int t = 0;
|
||||
for (int l = 0; l < (int)RepStatus.EndValue; l++)
|
||||
{
|
||||
int colWidth = GameGridColumnXPositions[l];
|
||||
GameGridColumnXPositions[l] = t;
|
||||
int colWidth = _gameGridColumnXPositions[l];
|
||||
_gameGridColumnXPositions[l] = t;
|
||||
t += colWidth;
|
||||
}
|
||||
|
||||
@@ -706,16 +740,17 @@ namespace ROMVault2
|
||||
}
|
||||
}
|
||||
|
||||
private void GameGrid_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
|
||||
private void GameGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
|
||||
{
|
||||
|
||||
if (_updatingGameGrid)
|
||||
return;
|
||||
|
||||
Rectangle cellBounds = GameGrid.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false);
|
||||
RvDir tRvDir = (ROMVault2.RvDB.RvDir)GameGrid.Rows[e.RowIndex].Tag;
|
||||
RvDir tRvDir = (RvDir)GameGrid.Rows[e.RowIndex].Tag;
|
||||
ReportStatus tDirStat = tRvDir.DirStatus;
|
||||
Color bgCol = Color.FromArgb(255, 255, 255);
|
||||
Color fgCol = Color.FromArgb(0, 0, 0);
|
||||
|
||||
if (cellBounds.Width == 0 || cellBounds.Height == 0)
|
||||
return;
|
||||
@@ -725,6 +760,7 @@ namespace ROMVault2
|
||||
if (tDirStat.Get(t1) <= 0) continue;
|
||||
|
||||
bgCol = _displayColor[(int)t1];
|
||||
fgCol = _fontColor[(int)t1];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -732,6 +768,7 @@ namespace ROMVault2
|
||||
{
|
||||
e.CellStyle.BackColor = bgCol;
|
||||
e.CellStyle.SelectionBackColor = bgCol;
|
||||
e.CellStyle.ForeColor = fgCol;
|
||||
|
||||
Bitmap bmp = new Bitmap(cellBounds.Width, cellBounds.Height);
|
||||
Graphics g = Graphics.FromImage(bmp);
|
||||
@@ -770,6 +807,7 @@ namespace ROMVault2
|
||||
else if (GameGrid.Columns[e.ColumnIndex].Name == "CGame")
|
||||
{
|
||||
e.CellStyle.BackColor = bgCol;
|
||||
e.CellStyle.ForeColor = fgCol;
|
||||
|
||||
if (String.IsNullOrEmpty(tRvDir.FileName))
|
||||
e.Value = tRvDir.Name;
|
||||
@@ -779,6 +817,7 @@ namespace ROMVault2
|
||||
else if (GameGrid.Columns[e.ColumnIndex].Name == "CDescription")
|
||||
{
|
||||
e.CellStyle.BackColor = bgCol;
|
||||
e.CellStyle.ForeColor = fgCol;
|
||||
|
||||
if (tRvDir.Game != null)
|
||||
e.Value = tRvDir.Game.GetData(RvGame.GameData.Description);
|
||||
@@ -802,7 +841,7 @@ namespace ROMVault2
|
||||
|
||||
if (tRvDir.DirStatus.Get(RepairStatus.DisplayOrder[l]) <= 0) continue;
|
||||
|
||||
gOff = FrmMain.GameGridColumnXPositions[columnIndex];
|
||||
gOff = _gameGridColumnXPositions[columnIndex];
|
||||
Bitmap bm = rvImages.GetBitmap(@"G_" + RepairStatus.DisplayOrder[l]);
|
||||
if (bm != null)
|
||||
{
|
||||
@@ -823,7 +862,7 @@ namespace ROMVault2
|
||||
|
||||
if (tRvDir.DirStatus.Get(RepairStatus.DisplayOrder[l]) > 0)
|
||||
{
|
||||
gOff = FrmMain.GameGridColumnXPositions[columnIndex];
|
||||
gOff = _gameGridColumnXPositions[columnIndex];
|
||||
g.DrawString(tRvDir.DirStatus.Get(RepairStatus.DisplayOrder[l]).ToString(CultureInfo.InvariantCulture), drawFont, drawBrushBlack, new PointF(gOff + 20, 3));
|
||||
columnIndex++;
|
||||
}
|
||||
@@ -833,9 +872,83 @@ namespace ROMVault2
|
||||
e.Value = bmp;
|
||||
}
|
||||
else
|
||||
Console.WriteLine("WARN: GameGrid_CellFormatting() unknown column: {0}", GameGrid.Columns[e.ColumnIndex].Name);
|
||||
Console.WriteLine("WARN: GameGrid_CellFormatting() unknown column: {0}", GameGrid.Columns[e.ColumnIndex].Name);
|
||||
}
|
||||
|
||||
private void GameGridColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
|
||||
{
|
||||
|
||||
// only allow sort on CGame/CDescription
|
||||
if (e.ColumnIndex != 1 && e.ColumnIndex != 2)
|
||||
return;
|
||||
|
||||
DataGridViewColumn newColumn = GameGrid.Columns[e.ColumnIndex];
|
||||
DataGridViewColumn oldColumn = GameGrid.Columns[_gameGridSortColumnIndex];
|
||||
|
||||
if (newColumn == oldColumn)
|
||||
{
|
||||
_gameGridSortOrder = _gameGridSortOrder == SortOrder.Ascending ? SortOrder.Descending : SortOrder.Ascending;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldColumn.HeaderCell.SortGlyphDirection = SortOrder.None;
|
||||
_gameGridSortOrder = SortOrder.Ascending;
|
||||
}
|
||||
|
||||
GameGrid.Sort(new GameGridRowComparer(_gameGridSortOrder, e.ColumnIndex));
|
||||
newColumn.HeaderCell.SortGlyphDirection = _gameGridSortOrder;
|
||||
_gameGridSortColumnIndex = e.ColumnIndex;
|
||||
}
|
||||
|
||||
private class GameGridRowComparer : System.Collections.IComparer
|
||||
{
|
||||
private readonly int _sortMod = 1;
|
||||
private readonly int _columnIndex;
|
||||
|
||||
public GameGridRowComparer(SortOrder sortOrder, int index)
|
||||
{
|
||||
_columnIndex = index;
|
||||
|
||||
if (sortOrder == SortOrder.Descending)
|
||||
_sortMod = -1;
|
||||
}
|
||||
|
||||
public int Compare(object a, object b)
|
||||
{
|
||||
DataGridViewRow aRow = (DataGridViewRow)a;
|
||||
DataGridViewRow bRow = (DataGridViewRow)b;
|
||||
|
||||
RvDir aRvDir = (RvDir)aRow.Tag;
|
||||
RvDir bRvDir = (RvDir)bRow.Tag;
|
||||
|
||||
int result = 0;
|
||||
switch (_columnIndex)
|
||||
{
|
||||
case 1: // CGame
|
||||
result = String.CompareOrdinal(aRvDir.Name, bRvDir.Name);
|
||||
break;
|
||||
case 2: // CDescription
|
||||
String aDes = "";
|
||||
String bDes = "";
|
||||
if (aRvDir.Game != null)
|
||||
aDes = aRvDir.Game.GetData(RvGame.GameData.Description);
|
||||
if (bRvDir.Game != null)
|
||||
bDes = bRvDir.Game.GetData(RvGame.GameData.Description);
|
||||
|
||||
result = String.CompareOrdinal(aDes, bDes);
|
||||
|
||||
// if desciptions match, fall through to sorting by name
|
||||
if (result == 0)
|
||||
result = String.CompareOrdinal(aRvDir.Name, bRvDir.Name);
|
||||
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("WARN: GameGridRowComparer::Compare() Invalid columnIndex: {0}", _columnIndex);
|
||||
break;
|
||||
}
|
||||
return _sortMod * result;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region "Rom Grid Code"
|
||||
@@ -860,7 +973,7 @@ namespace ROMVault2
|
||||
|
||||
private void gbSetInfo_Resize(object sender, EventArgs e)
|
||||
{
|
||||
int leftPos = 84;
|
||||
const int leftPos = 84;
|
||||
int rightPos = gbSetInfo.Width - 15;
|
||||
if (rightPos > 750) rightPos = 750;
|
||||
int width = rightPos - leftPos;
|
||||
@@ -890,14 +1003,14 @@ namespace ROMVault2
|
||||
lblSITDeveloper.Width = width;
|
||||
|
||||
int width3 = (int)((double)width * 0.24);
|
||||
int P2 = (int)((double)width * 0.38);
|
||||
int p2 = (int)((double)width * 0.38);
|
||||
|
||||
int width4 = (int) ((double) width*0.24);
|
||||
|
||||
lblSITEdition.Width = width3;
|
||||
|
||||
lblSIVersion.Left = leftPos + P2 - 78;
|
||||
lblSITVersion.Left = leftPos + P2;
|
||||
lblSIVersion.Left = leftPos + p2 - 78;
|
||||
lblSITVersion.Left = leftPos + p2;
|
||||
lblSITVersion.Width = width3;
|
||||
|
||||
lblSIType.Left = leftPos + width - width3 - 78;
|
||||
@@ -907,8 +1020,8 @@ namespace ROMVault2
|
||||
|
||||
lblSITMedia.Width = width3;
|
||||
|
||||
lblSILanguage.Left = leftPos + P2 - 78;
|
||||
lblSITLanguage.Left = leftPos + P2;
|
||||
lblSILanguage.Left = leftPos + p2 - 78;
|
||||
lblSITLanguage.Left = leftPos + p2;
|
||||
lblSITLanguage.Width = width3;
|
||||
|
||||
lblSIPlayers.Left = leftPos + width - width3 - 78;
|
||||
@@ -917,8 +1030,8 @@ namespace ROMVault2
|
||||
|
||||
lblSITRatings.Width = width3;
|
||||
|
||||
lblSIGenre.Left = leftPos + P2 - 78;
|
||||
lblSITGenre.Left = leftPos + P2;
|
||||
lblSIGenre.Left = leftPos + p2 - 78;
|
||||
lblSITGenre.Left = leftPos + p2;
|
||||
lblSITGenre.Width = width3;
|
||||
|
||||
lblSIPeripheral.Left = leftPos + width - width3 - 78;
|
||||
@@ -1160,6 +1273,9 @@ namespace ROMVault2
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.IsMono && RomGrid.RowCount > 0)
|
||||
RomGrid.CurrentCell = RomGrid[0,0];
|
||||
|
||||
RomGrid.Rows.Clear();
|
||||
AddDir(tGame, "");
|
||||
GC.Collect();
|
||||
@@ -1186,6 +1302,13 @@ namespace ROMVault2
|
||||
}
|
||||
}
|
||||
|
||||
// returns either white or black, depending of quick luminance of the Color " a "
|
||||
// called when the _displayColor is finished, in order to populate the _fontColor table.
|
||||
private Color contrasty(Color a)
|
||||
{
|
||||
return (a.R << 1) + a.B + a.G + (a.G << 2) < 1024 ? Color.White : Color.Black;
|
||||
}
|
||||
|
||||
private void AddRom(RvFile tRomTable, string pathAdd)
|
||||
{
|
||||
|
||||
@@ -1196,8 +1319,11 @@ namespace ROMVault2
|
||||
RomGrid.Rows[row].Tag = tRomTable;
|
||||
|
||||
for (int i = 0; i < RomGrid.Rows[row].Cells.Count; i++)
|
||||
RomGrid.Rows[row].Cells[i].Style.BackColor = _displayColor[(int)tRomTable.RepStatus];
|
||||
|
||||
{
|
||||
DataGridViewCellStyle cs = RomGrid.Rows[row].Cells[i].Style;
|
||||
cs.BackColor = _displayColor[(int)tRomTable.RepStatus];
|
||||
cs.ForeColor = _fontColor[(int)tRomTable.RepStatus];
|
||||
}
|
||||
string fname = pathAdd + tRomTable.Name;
|
||||
if (!string.IsNullOrEmpty(tRomTable.FileName))
|
||||
fname += " (Found: " + tRomTable.FileName + ")";
|
||||
@@ -1275,14 +1401,14 @@ namespace ROMVault2
|
||||
}
|
||||
}
|
||||
|
||||
private void RomGrid_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
|
||||
private void RomGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
|
||||
{
|
||||
|
||||
if (_updatingGameGrid)
|
||||
return;
|
||||
|
||||
Rectangle cellBounds = RomGrid.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false);
|
||||
RvFile tRvFile = (ROMVault2.RvDB.RvFile)RomGrid.Rows[e.RowIndex].Tag;
|
||||
RvFile tRvFile = (RvFile)RomGrid.Rows[e.RowIndex].Tag;
|
||||
|
||||
if (cellBounds.Width == 0 || cellBounds.Height == 0)
|
||||
return;
|
||||
@@ -1335,6 +1461,7 @@ namespace ROMVault2
|
||||
private void SettingsToolStripMenuItemClick(object sender, EventArgs e)
|
||||
{
|
||||
FrmSettings fcfg = new FrmSettings();
|
||||
fcfg.UpdateDats += UpdateDats;
|
||||
fcfg.ShowDialog(this);
|
||||
fcfg.Dispose();
|
||||
}
|
||||
@@ -1404,27 +1531,26 @@ namespace ROMVault2
|
||||
|
||||
private void GameGrid_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
int currentMouseOverRow = GameGrid.HitTest(e.X, e.Y).RowIndex;
|
||||
if (currentMouseOverRow >= 0)
|
||||
{
|
||||
object r1 = GameGrid.Rows[currentMouseOverRow].Cells[1].Value;
|
||||
string filename = r1 != null ? r1.ToString() : "";
|
||||
object r2 = GameGrid.Rows[currentMouseOverRow].Cells[2].Value;
|
||||
string description = r2 != null ? r2.ToString() : "";
|
||||
if (e.Button != MouseButtons.Right)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
Clipboard.Clear();
|
||||
Clipboard.SetText("Name : " + filename + Environment.NewLine + "Desc : " + description + Environment.NewLine);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
int currentMouseOverRow = GameGrid.HitTest(e.X, e.Y).RowIndex;
|
||||
if (currentMouseOverRow >= 0)
|
||||
{
|
||||
object r1 = GameGrid.Rows[currentMouseOverRow].Cells[1].Value;
|
||||
string filename = r1 != null ? r1.ToString() : "";
|
||||
object r2 = GameGrid.Rows[currentMouseOverRow].Cells[2].Value;
|
||||
string description = r2 != null ? r2.ToString() : "";
|
||||
|
||||
try
|
||||
{
|
||||
Clipboard.Clear();
|
||||
Clipboard.SetText("Name : " + filename + Environment.NewLine + "Desc : " + description + Environment.NewLine);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,6 +35,9 @@ namespace ROMVault2
|
||||
|
||||
private void UpdateGrid()
|
||||
{
|
||||
if (Settings.IsMono && DataGridGames.RowCount > 0)
|
||||
DataGridGames.CurrentCell = DataGridGames[0,0];
|
||||
|
||||
DataGridGames.Rows.Clear();
|
||||
foreach (DirMap t in Settings.DirPathMap)
|
||||
{
|
||||
@@ -77,7 +80,7 @@ namespace ROMVault2
|
||||
{
|
||||
ShowNewFolderButton = true,
|
||||
Description = Resources.FrmSetDir_BtnSetRomLocationClick_Please_select_a_folder_for_This_Rom_Set,
|
||||
RootFolder = Environment.SpecialFolder.DesktopDirectory,
|
||||
RootFolder = Environment.SpecialFolder.MyComputer,
|
||||
SelectedPath = DBHelper.GetRealPath(_datLocation)
|
||||
};
|
||||
if (browse.ShowDialog() == DialogResult.OK)
|
||||
|
||||
@@ -8,11 +8,17 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using ROMVault2.Properties;
|
||||
using System.IO;
|
||||
using ROMVault2.RvDB;
|
||||
|
||||
namespace ROMVault2
|
||||
{
|
||||
public partial class FrmSettings : Form
|
||||
{
|
||||
public delegate void UpdateDatsDelegate();
|
||||
|
||||
public event UpdateDatsDelegate UpdateDats;
|
||||
|
||||
public FrmSettings()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -29,6 +35,7 @@ namespace ROMVault2
|
||||
cboFixLevel.Items.Add("Level1");
|
||||
cboFixLevel.Items.Add("Level2");
|
||||
cboFixLevel.Items.Add("Level3");
|
||||
cboFixLevel.Items.Add("Uncompressed");
|
||||
}
|
||||
|
||||
private void FrmConfigLoad(object sender, EventArgs e)
|
||||
@@ -54,6 +61,26 @@ namespace ROMVault2
|
||||
|
||||
private void BtnOkClick(object sender, EventArgs e)
|
||||
{
|
||||
if (Settings.FixLevel != (eFixLevel)cboFixLevel.SelectedIndex)
|
||||
{
|
||||
if (Settings.FixLevel == eFixLevel.Uncompressed ||
|
||||
(eFixLevel)cboFixLevel.SelectedIndex == eFixLevel.Uncompressed)
|
||||
{
|
||||
DialogResult dlg = MessageBox.Show("Changing from/to uncompressed requires the cache file to be deleted.\nDo you want to proceed?", "Settings", MessageBoxButtons.YesNoCancel);
|
||||
|
||||
if (dlg == DialogResult.Cancel)
|
||||
Close();
|
||||
|
||||
if (dlg != DialogResult.Yes)
|
||||
return;
|
||||
|
||||
File.Delete(Settings.CacheFile);
|
||||
DB.Read(sender, new System.ComponentModel.DoWorkEventArgs(null));
|
||||
Settings.FixLevel = (eFixLevel)cboFixLevel.SelectedIndex;
|
||||
UpdateDats();
|
||||
}
|
||||
}
|
||||
|
||||
Settings.DatRoot = lblDATRoot.Text;
|
||||
Settings.ScanLevel = (eScanLevel)cboScanLevel.SelectedIndex;
|
||||
Settings.FixLevel = (eFixLevel)cboFixLevel.SelectedIndex;
|
||||
@@ -88,7 +115,7 @@ namespace ROMVault2
|
||||
{
|
||||
ShowNewFolderButton = true,
|
||||
Description = Resources.FrmSettings_BtnDatClick_Please_select_a_folder_for_DAT_Root,
|
||||
RootFolder = Environment.SpecialFolder.DesktopDirectory,
|
||||
RootFolder = Environment.SpecialFolder.MyComputer,
|
||||
SelectedPath = Settings.DatRoot
|
||||
};
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace ROMVault2.IO
|
||||
FullName = path;
|
||||
Name = Path.GetFileName(path);
|
||||
|
||||
if (Settings.MonoFileIO)
|
||||
if (Settings.IsUnix)
|
||||
{
|
||||
System.IO.FileInfo fi = new System.IO.FileInfo(path);
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace ROMVault2.IO
|
||||
FullName = path;
|
||||
Name = Path.GetFileName(path);
|
||||
|
||||
if (Settings.MonoFileIO)
|
||||
if (Settings.IsUnix)
|
||||
{
|
||||
System.IO.DirectoryInfo fi = new System.IO.DirectoryInfo(path);
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace ROMVault2.IO
|
||||
{
|
||||
List<DirectoryInfo> dirs = new List<DirectoryInfo>();
|
||||
|
||||
if (Settings.MonoFileIO)
|
||||
if (Settings.IsUnix)
|
||||
{
|
||||
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(FullName);
|
||||
System.IO.DirectoryInfo[] arrDi = di.GetDirectories(SearchPattern);
|
||||
@@ -183,7 +183,7 @@ namespace ROMVault2.IO
|
||||
{
|
||||
List<FileInfo> files = new List<FileInfo>();
|
||||
|
||||
if (Settings.MonoFileIO)
|
||||
if (Settings.IsUnix)
|
||||
{
|
||||
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(FullName);
|
||||
System.IO.FileInfo[] arrDi = di.GetFiles(SearchPattern);
|
||||
@@ -239,7 +239,7 @@ namespace ROMVault2.IO
|
||||
{
|
||||
public static bool Exists(string path)
|
||||
{
|
||||
if (Settings.MonoFileIO)
|
||||
if (Settings.IsUnix)
|
||||
return System.IO.Directory.Exists(path);
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ namespace ROMVault2.IO
|
||||
}
|
||||
public static void Move(String sourceDirName, String destDirName)
|
||||
{
|
||||
if (Settings.MonoFileIO)
|
||||
if (Settings.IsUnix)
|
||||
{
|
||||
System.IO.Directory.Move(sourceDirName, destDirName);
|
||||
return;
|
||||
@@ -288,7 +288,7 @@ namespace ROMVault2.IO
|
||||
}
|
||||
public static void Delete(String path)
|
||||
{
|
||||
if (Settings.MonoFileIO)
|
||||
if (Settings.IsUnix)
|
||||
{
|
||||
System.IO.Directory.Delete(path);
|
||||
return;
|
||||
@@ -301,7 +301,7 @@ namespace ROMVault2.IO
|
||||
|
||||
public static void CreateDirectory(String path)
|
||||
{
|
||||
if (Settings.MonoFileIO)
|
||||
if (Settings.IsUnix)
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(path);
|
||||
return;
|
||||
@@ -323,7 +323,7 @@ namespace ROMVault2.IO
|
||||
{
|
||||
public static bool Exists(string path)
|
||||
{
|
||||
if (Settings.MonoFileIO)
|
||||
if (Settings.IsUnix)
|
||||
return System.IO.File.Exists(path);
|
||||
|
||||
|
||||
@@ -340,7 +340,7 @@ namespace ROMVault2.IO
|
||||
}
|
||||
public static void Copy(String sourceFileName, String destFileName, bool overwrite)
|
||||
{
|
||||
if (Settings.MonoFileIO)
|
||||
if (Settings.IsUnix)
|
||||
{
|
||||
System.IO.File.Copy(sourceFileName, destFileName, overwrite);
|
||||
return;
|
||||
@@ -387,7 +387,7 @@ namespace ROMVault2.IO
|
||||
}
|
||||
public static void Move(String sourceFileName, String destFileName)
|
||||
{
|
||||
if (Settings.MonoFileIO)
|
||||
if (Settings.IsUnix)
|
||||
{
|
||||
System.IO.File.Move(sourceFileName, destFileName);
|
||||
return;
|
||||
@@ -412,7 +412,7 @@ namespace ROMVault2.IO
|
||||
}
|
||||
public static void Delete(String path)
|
||||
{
|
||||
if (Settings.MonoFileIO)
|
||||
if (Settings.IsUnix)
|
||||
{
|
||||
System.IO.File.Delete(path);
|
||||
return;
|
||||
@@ -431,7 +431,7 @@ namespace ROMVault2.IO
|
||||
|
||||
public static bool SetAttributes(String path, FileAttributes fileAttributes)
|
||||
{
|
||||
if (Settings.MonoFileIO)
|
||||
if (Settings.IsUnix)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -466,7 +466,7 @@ namespace ROMVault2.IO
|
||||
}
|
||||
public static string Combine(string path1, string path2)
|
||||
{
|
||||
if (Settings.MonoFileIO)
|
||||
if (Settings.IsUnix)
|
||||
return System.IO.Path.Combine(path1, path2);
|
||||
|
||||
if (path1 == null || path2 == null)
|
||||
@@ -538,7 +538,7 @@ namespace ROMVault2.IO
|
||||
}
|
||||
public static String GetDirectoryName(String path)
|
||||
{
|
||||
if (Settings.MonoFileIO)
|
||||
if (Settings.IsUnix)
|
||||
return System.IO.Path.GetDirectoryName(path);
|
||||
|
||||
|
||||
@@ -600,7 +600,7 @@ namespace ROMVault2.IO
|
||||
|
||||
public static int OpenFileRead(string path, out System.IO.Stream stream)
|
||||
{
|
||||
if (Settings.MonoFileIO)
|
||||
if (Settings.IsUnix)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -634,7 +634,7 @@ namespace ROMVault2.IO
|
||||
|
||||
public static int OpenFileWrite(string path, out System.IO.Stream stream)
|
||||
{
|
||||
if (Settings.MonoFileIO)
|
||||
if (Settings.IsUnix)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -675,7 +675,7 @@ namespace ROMVault2.IO
|
||||
{
|
||||
public static string GetShortPath(string path)
|
||||
{
|
||||
if (Settings.MonoFileIO)
|
||||
if (Settings.IsUnix)
|
||||
return path;
|
||||
|
||||
int remove = 0;
|
||||
|
||||
@@ -15,11 +15,8 @@ namespace ROMVault2
|
||||
//public static UsernamePassword Up;
|
||||
public static readonly Encoding Enc = Encoding.GetEncoding(28591);
|
||||
public const string Version = "2.2";
|
||||
public const int SubVersion = 0;
|
||||
|
||||
public static string ErrorMessage;
|
||||
public static string URL;
|
||||
|
||||
public const int SubVersion = 5;
|
||||
|
||||
public static SynchronizationContext SyncCont;
|
||||
|
||||
/// <summary>
|
||||
@@ -39,15 +36,7 @@ namespace ROMVault2
|
||||
progress.ShowDialog();
|
||||
|
||||
progress.Dispose();
|
||||
|
||||
if (!String.IsNullOrEmpty(ErrorMessage))
|
||||
{
|
||||
MessageBox.Show(ErrorMessage);
|
||||
if (!String.IsNullOrEmpty(URL))
|
||||
System.Diagnostics.Process.Start(URL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Application.Run(new FrmMain());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ROMVault2</RootNamespace>
|
||||
<AssemblyName>ROMVault21</AssemblyName>
|
||||
<AssemblyName>ROMVault225</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
@@ -35,7 +35,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Stage\</OutputPath>
|
||||
<OutputPath>..\..\Stage\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;UNMANAGED;COMPRESS;LZMA_STREAM;DOTNET20</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
||||
@@ -40,8 +40,8 @@ namespace ROMVault2
|
||||
{
|
||||
ShowNewFolderButton = true,
|
||||
Description = @"Please select a folder for Dats",
|
||||
RootFolder = Environment.SpecialFolder.DesktopDirectory,
|
||||
SelectedPath = @"apps"
|
||||
RootFolder = Environment.SpecialFolder.MyComputer,
|
||||
SelectedPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Reports")
|
||||
};
|
||||
|
||||
if (browse.ShowDialog() != DialogResult.OK) return;
|
||||
@@ -195,7 +195,7 @@ namespace ROMVault2
|
||||
SaveFileDialog saveFileDialog1 = new SaveFileDialog
|
||||
{
|
||||
Title = @"Generate Full Report",
|
||||
FileName = @"RVFullReport"+CleanTime()+".txt",
|
||||
FileName = @"RVFullReport" + CleanTime() + ".txt",
|
||||
Filter = @"Rom Vault Report (*.txt)|*.txt|All Files (*.*)|*.*",
|
||||
FilterIndex = 1
|
||||
};
|
||||
@@ -226,7 +226,7 @@ namespace ROMVault2
|
||||
SaveFileDialog saveFileDialog1 = new SaveFileDialog
|
||||
{
|
||||
Title = @"Generate Fix Report",
|
||||
FileName = @"RVFixReport"+CleanTime()+".txt",
|
||||
FileName = @"RVFixReport" + CleanTime() + ".txt",
|
||||
Filter = @"Rom Vault Fixing Report (*.txt)|*.txt|All Files (*.*)|*.*",
|
||||
FilterIndex = 1
|
||||
};
|
||||
|
||||
@@ -28,7 +28,8 @@ namespace ROMVault2
|
||||
TrrntZipLevel3,
|
||||
Level1,
|
||||
Level2,
|
||||
Level3
|
||||
Level3,
|
||||
Uncompressed
|
||||
}
|
||||
|
||||
public static class Settings
|
||||
@@ -48,7 +49,7 @@ namespace ROMVault2
|
||||
public static bool CacheSaveTimerEnabled = true;
|
||||
public static int CacheSaveTimePeriod = 10;
|
||||
|
||||
public static bool MonoFileIO
|
||||
public static bool IsUnix
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -56,7 +57,9 @@ namespace ROMVault2
|
||||
return ((p == 4) || (p == 6) || (p == 128));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static bool IsMono { get { return (Type.GetType ("Mono.Runtime") != null); } }
|
||||
|
||||
public static void SetDefaults()
|
||||
{
|
||||
CacheFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "RomVault2_" + DBVersion.Version + ".Cache");
|
||||
|
||||
@@ -246,7 +246,7 @@ namespace ROMVault2.SupportedFiles.CHD
|
||||
_resultType = CHDManCheck.Unset;
|
||||
|
||||
string chdExe = "chdman.exe";
|
||||
if (Settings.MonoFileIO)
|
||||
if (Settings.IsUnix)
|
||||
chdExe = "chdman";
|
||||
|
||||
string chdPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, chdExe);
|
||||
|
||||
@@ -6,18 +6,21 @@
|
||||
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading;
|
||||
using ROMVault2.SupportedFiles.Zip.ZLib;
|
||||
|
||||
namespace ROMVault2.SupportedFiles.Files
|
||||
{
|
||||
public static class UnCompFiles
|
||||
{
|
||||
private const int Buffersize = 4096;
|
||||
private static readonly byte[] Buffer;
|
||||
private const int Buffersize = 4096 * 1024;
|
||||
private static readonly byte[] Buffer0;
|
||||
private static readonly byte[] Buffer1;
|
||||
|
||||
static UnCompFiles()
|
||||
{
|
||||
Buffer = new byte[Buffersize];
|
||||
Buffer0 = new byte[Buffersize];
|
||||
Buffer1 = new byte[Buffersize];
|
||||
}
|
||||
|
||||
public static int CheckSumRead(string filename, bool testDeep, out byte[] crc, out byte[] bMD5, out byte[] bSHA1)
|
||||
@@ -26,11 +29,7 @@ namespace ROMVault2.SupportedFiles.Files
|
||||
bSHA1 = null;
|
||||
crc = null;
|
||||
|
||||
Stream ds;
|
||||
int errorCode = IO.FileStream.OpenFileRead(filename, out ds);
|
||||
if (errorCode != 0)
|
||||
return errorCode;
|
||||
|
||||
Stream ds = null;
|
||||
CRC32Hash crc32 = new CRC32Hash();
|
||||
|
||||
MD5 md5 = null;
|
||||
@@ -38,24 +37,66 @@ namespace ROMVault2.SupportedFiles.Files
|
||||
SHA1 sha1 = null;
|
||||
if (testDeep) sha1 = SHA1.Create();
|
||||
|
||||
long sizetogo = ds.Length;
|
||||
|
||||
while (sizetogo > 0)
|
||||
try
|
||||
{
|
||||
int sizenow = sizetogo > Buffersize ? Buffersize : (int)sizetogo;
|
||||
int errorCode = IO.FileStream.OpenFileRead(filename, out ds);
|
||||
if (errorCode != 0)
|
||||
return errorCode;
|
||||
|
||||
ds.Read(Buffer, 0, sizenow);
|
||||
crc32.TransformBlock(Buffer, 0, sizenow, null, 0);
|
||||
if (testDeep) md5.TransformBlock(Buffer, 0, sizenow, null, 0);
|
||||
if (testDeep) sha1.TransformBlock(Buffer, 0, sizenow, null, 0);
|
||||
sizetogo -= sizenow;
|
||||
long sizetogo = ds.Length;
|
||||
|
||||
// Pre load the first buffer0
|
||||
int sizeNext = sizetogo > Buffersize ? Buffersize : (int)sizetogo;
|
||||
ds.Read(Buffer0, 0, sizeNext);
|
||||
int sizebuffer = sizeNext;
|
||||
sizetogo -= sizeNext;
|
||||
bool whichBuffer = true;
|
||||
|
||||
while (sizebuffer > 0)
|
||||
{
|
||||
sizeNext = sizetogo > Buffersize ? Buffersize : (int)sizetogo;
|
||||
|
||||
Thread t0 = null;
|
||||
if (sizeNext > 0)
|
||||
{
|
||||
t0 = new Thread(() => { ds.Read(whichBuffer ? Buffer1 : Buffer0, 0, sizeNext); });
|
||||
t0.Start();
|
||||
}
|
||||
|
||||
byte[] buffer = whichBuffer ? Buffer0 : Buffer1;
|
||||
Thread t1 = new Thread(() => { crc32.TransformBlock(buffer, 0, sizebuffer, null, 0); });
|
||||
t1.Start();
|
||||
if (testDeep)
|
||||
{
|
||||
Thread t2 = new Thread(() => { md5.TransformBlock(buffer, 0, sizebuffer, null, 0); });
|
||||
Thread t3 = new Thread(() => { sha1.TransformBlock(buffer, 0, sizebuffer, null, 0); });
|
||||
t2.Start();
|
||||
t3.Start();
|
||||
t2.Join();
|
||||
t3.Join();
|
||||
}
|
||||
if (t0 != null)
|
||||
t0.Join();
|
||||
t1.Join();
|
||||
|
||||
sizebuffer = sizeNext;
|
||||
sizetogo -= sizeNext;
|
||||
whichBuffer = !whichBuffer;
|
||||
}
|
||||
|
||||
crc32.TransformFinalBlock(Buffer0, 0, 0);
|
||||
if (testDeep) md5.TransformFinalBlock(Buffer0, 0, 0);
|
||||
if (testDeep) sha1.TransformFinalBlock(Buffer0, 0, 0);
|
||||
|
||||
ds.Close();
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (ds != null)
|
||||
ds.Close();
|
||||
|
||||
crc32.TransformFinalBlock(Buffer, 0, 0);
|
||||
if (testDeep) md5.TransformFinalBlock(Buffer, 0, 0);
|
||||
if (testDeep) sha1.TransformFinalBlock(Buffer, 0, 0);
|
||||
|
||||
ds.Close();
|
||||
return 0x17;
|
||||
}
|
||||
|
||||
crc = crc32.Hash;
|
||||
if (testDeep) bMD5 = md5.Hash;
|
||||
@@ -63,8 +104,5 @@ namespace ROMVault2.SupportedFiles.Files
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using ROMVault2.SupportedFiles.Zip.ZLib;
|
||||
|
||||
// UInt16 = ushort
|
||||
@@ -17,11 +18,12 @@ using ROMVault2.SupportedFiles.Zip.ZLib;
|
||||
|
||||
namespace ROMVault2.SupportedFiles.Zip
|
||||
{
|
||||
|
||||
|
||||
public class ZipFile
|
||||
{
|
||||
const int Buffersize = 4096 * 128;
|
||||
private static byte[] _buffer;
|
||||
const int Buffersize = 4096 * 1024;
|
||||
private static byte[] _buffer0;
|
||||
private static byte[] _buffer1;
|
||||
|
||||
private const uint LocalFileHeaderSignature = 0x04034b50;
|
||||
private const uint CentralDirectoryHeaderSigniature = 0x02014b50;
|
||||
@@ -48,10 +50,10 @@ namespace ROMVault2.SupportedFiles.Zip
|
||||
|
||||
public bool Zip64 { get; private set; }
|
||||
public bool TrrntZip { get; private set; }
|
||||
|
||||
|
||||
public byte[] sha1 { get; private set; }
|
||||
public byte[] md5 { get; private set; }
|
||||
|
||||
|
||||
public ZipReturn FileStatus = ZipReturn.ZipUntested;
|
||||
public LocalFile(Stream zipFs)
|
||||
{
|
||||
@@ -414,7 +416,7 @@ namespace ROMVault2.SupportedFiles.Zip
|
||||
_generalPurposeBitFlag = br.ReadUInt16();
|
||||
if ((_generalPurposeBitFlag & 8) == 8)
|
||||
return ZipReturn.ZipCannotFastOpen;
|
||||
|
||||
|
||||
_compressionMethod = br.ReadUInt16();
|
||||
_lastModFileTime = br.ReadUInt16();
|
||||
_lastModFileDate = br.ReadUInt16();
|
||||
@@ -482,7 +484,7 @@ namespace ROMVault2.SupportedFiles.Zip
|
||||
|
||||
_dataLocation = (ulong)_zipFs.Position;
|
||||
return ZipReturn.ZipGood;
|
||||
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -717,25 +719,53 @@ namespace ROMVault2.SupportedFiles.Zip
|
||||
MD5 lmd5 = System.Security.Cryptography.MD5.Create();
|
||||
SHA1 lsha1 = System.Security.Cryptography.SHA1.Create();
|
||||
|
||||
ulong sizetogo = UncompressedSize;
|
||||
if (_buffer == null)
|
||||
_buffer = new byte[Buffersize];
|
||||
|
||||
while (sizetogo > 0)
|
||||
if (_buffer0 == null)
|
||||
{
|
||||
int sizenow = sizetogo > Buffersize ? Buffersize : (int)sizetogo;
|
||||
sInput.Read(_buffer, 0, sizenow);
|
||||
|
||||
crc32.TransformBlock(_buffer, 0, sizenow, null, 0);
|
||||
lmd5.TransformBlock(_buffer, 0, sizenow, null, 0);
|
||||
lsha1.TransformBlock(_buffer, 0, sizenow, null, 0);
|
||||
|
||||
sizetogo = sizetogo - (ulong)sizenow;
|
||||
_buffer0 = new byte[Buffersize];
|
||||
_buffer1 = new byte[Buffersize];
|
||||
}
|
||||
|
||||
crc32.TransformFinalBlock(_buffer, 0, 0);
|
||||
lmd5.TransformFinalBlock(_buffer, 0, 0);
|
||||
lsha1.TransformFinalBlock(_buffer, 0, 0);
|
||||
ulong sizetogo = UncompressedSize;
|
||||
|
||||
// Pre load the first buffer0
|
||||
int sizeNext = sizetogo > Buffersize ? Buffersize : (int)sizetogo;
|
||||
sInput.Read(_buffer0, 0, sizeNext);
|
||||
int sizebuffer = sizeNext;
|
||||
sizetogo -= (ulong)sizeNext;
|
||||
bool whichBuffer = true;
|
||||
|
||||
while (sizebuffer > 0)
|
||||
{
|
||||
sizeNext = sizetogo > Buffersize ? Buffersize : (int)sizetogo;
|
||||
|
||||
Thread t0 = null;
|
||||
if (sizeNext > 0)
|
||||
{
|
||||
t0 = new Thread(() => { sInput.Read(whichBuffer ? _buffer1 : _buffer0, 0, sizeNext); });
|
||||
t0.Start();
|
||||
}
|
||||
|
||||
byte[] buffer = whichBuffer ? _buffer0 : _buffer1;
|
||||
Thread t1 = new Thread(() => { crc32.TransformBlock(buffer, 0, sizebuffer, null, 0); });
|
||||
Thread t2 = new Thread(() => { lmd5.TransformBlock(buffer, 0, sizebuffer, null, 0); });
|
||||
Thread t3 = new Thread(() => { lsha1.TransformBlock(buffer, 0, sizebuffer, null, 0); });
|
||||
t1.Start();
|
||||
t2.Start();
|
||||
t3.Start();
|
||||
if (t0 != null)
|
||||
t0.Join();
|
||||
t1.Join();
|
||||
t2.Join();
|
||||
t3.Join();
|
||||
|
||||
sizebuffer = sizeNext;
|
||||
sizetogo -= (ulong)sizeNext;
|
||||
whichBuffer = !whichBuffer;
|
||||
}
|
||||
|
||||
crc32.TransformFinalBlock(_buffer0, 0, 0);
|
||||
lmd5.TransformFinalBlock(_buffer0, 0, 0);
|
||||
lsha1.TransformFinalBlock(_buffer0, 0, 0);
|
||||
|
||||
byte[] testcrc = crc32.Hash;
|
||||
md5 = lmd5.Hash;
|
||||
@@ -1365,7 +1395,7 @@ namespace ROMVault2.SupportedFiles.Zip
|
||||
_localFiles[_localFiles.Count - 1].LocalFileAddDirectory();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
public void BreakTrrntZip(string filename)
|
||||
{
|
||||
@@ -1525,7 +1555,7 @@ namespace ROMVault2.SupportedFiles.Zip
|
||||
int pos1 = 0;
|
||||
int pos2 = 0;
|
||||
|
||||
for (; ; )
|
||||
for (;;)
|
||||
{
|
||||
if (pos1 == bytes1.Length)
|
||||
return ((pos2 == bytes2.Length) ? 0 : -1);
|
||||
|
||||
@@ -11,10 +11,7 @@ namespace ROMVault2
|
||||
{
|
||||
public static class rvImages
|
||||
{
|
||||
private static List<string> names;
|
||||
private static List<Bitmap> images;
|
||||
|
||||
|
||||
|
||||
public static Bitmap GetBitmap(string bitmapName)
|
||||
{
|
||||
object bmObj = rvImages1.ResourceManager.GetObject(bitmapName);
|
||||
|
||||
Reference in New Issue
Block a user