Skip to content

Commit

Permalink
Added MeowDSIO as submodule + DS1R support
Browse files Browse the repository at this point in the history
  • Loading branch information
Meowmaritus committed Feb 23, 2019
1 parent 680d632 commit e96d318
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 83 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "MeowDSIO"]
path = MeowDSIO
url = https://github.com/Meowmaritus/MeowDSIO.git
1 change: 1 addition & 0 deletions MeowDSIO
Submodule MeowDSIO added at d75ea8
16 changes: 16 additions & 0 deletions Paramdomizer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,32 @@ VisualStudioVersion = 15.0.27703.2042
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Paramdomizer", "Paramdomizer\Paramdomizer.csproj", "{30DA8574-1092-4BF3-BE7A-99B003494994}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MeowDSIO", "MeowDSIO\MeowDSIO\MeowDSIO.csproj", "{4AD69470-8146-4D20-94F0-DA9844EEE5A2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{30DA8574-1092-4BF3-BE7A-99B003494994}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30DA8574-1092-4BF3-BE7A-99B003494994}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30DA8574-1092-4BF3-BE7A-99B003494994}.Debug|x64.ActiveCfg = Debug|Any CPU
{30DA8574-1092-4BF3-BE7A-99B003494994}.Debug|x64.Build.0 = Debug|Any CPU
{30DA8574-1092-4BF3-BE7A-99B003494994}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30DA8574-1092-4BF3-BE7A-99B003494994}.Release|Any CPU.Build.0 = Release|Any CPU
{30DA8574-1092-4BF3-BE7A-99B003494994}.Release|x64.ActiveCfg = Release|Any CPU
{30DA8574-1092-4BF3-BE7A-99B003494994}.Release|x64.Build.0 = Release|Any CPU
{4AD69470-8146-4D20-94F0-DA9844EEE5A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4AD69470-8146-4D20-94F0-DA9844EEE5A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4AD69470-8146-4D20-94F0-DA9844EEE5A2}.Debug|x64.ActiveCfg = Debug|x64
{4AD69470-8146-4D20-94F0-DA9844EEE5A2}.Debug|x64.Build.0 = Debug|x64
{4AD69470-8146-4D20-94F0-DA9844EEE5A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4AD69470-8146-4D20-94F0-DA9844EEE5A2}.Release|Any CPU.Build.0 = Release|Any CPU
{4AD69470-8146-4D20-94F0-DA9844EEE5A2}.Release|x64.ActiveCfg = Release|x64
{4AD69470-8146-4D20-94F0-DA9844EEE5A2}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
161 changes: 82 additions & 79 deletions Paramdomizer/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,24 @@ private void Form1_Load(object sender, EventArgs e)
//check if running exe from data directory
gameDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

if (File.Exists(gameDirectory + "\\DARKSOULS.exe"))
if (File.Exists(gameDirectory + (checkBoxRemaster.Checked ? "\\DarkSoulsRemastered.exe" : "\\DARKSOULS.exe")))
{
//exe is in a valid game directory, just use this as the path instead of asking for input
txtGamePath.Text = gameDirectory;
txtGamePath.ReadOnly = true;

if (!File.Exists(gameDirectory + "\\param\\GameParam\\GameParam.parambnd"))
if (!File.Exists(gameDirectory + "\\param\\GameParam\\GameParam.parambnd" + (checkBoxRemaster.Checked ? ".dcx" : "")))
{
//user hasn't unpacked their game
lblMessage.Text = "You don't seem to have an unpacked Dark Souls installation. Please run UDSFM and come back :)";
if (checkBoxRemaster.Checked)
{
//invalid directory
lblMessage.Text = "Invalid Dark Souls: Remastered game directory; No GameParam found.";
}
else
{
//user hasn't unpacked their game
lblMessage.Text = "You don't seem to have an unpacked Dark Souls: Prepare to Die Edition installation. Please run UDSFM and come back :)";
}
lblMessage.Visible = true;
lblMessage.ForeColor = Color.Red;
}
Expand All @@ -56,16 +64,24 @@ private void btnOpenFolderDialog_Click(object sender, EventArgs e)
lblMessage.Text = "";
lblMessage.Visible = true;

if (!File.Exists(gameDirectory + "\\DARKSOULS.exe"))
if (!File.Exists(gameDirectory + (checkBoxRemaster.Checked ? "\\DarkSoulsRemastered.exe" : "\\DARKSOULS.exe")))
{
lblMessage.Text = "Not a valid Data directory!";
lblMessage.Text = $"Not a valid {(checkBoxRemaster.Checked ? "Dark Souls: Remastered" : "Dark Souls: Prepare to Die Edition")} Data directory.";
lblMessage.ForeColor = Color.Red;
return;
}
else if (!File.Exists(gameDirectory + "\\param\\GameParam\\GameParam.parambnd"))
else if (!File.Exists(gameDirectory + "\\param\\GameParam\\GameParam.parambnd" + (checkBoxRemaster.Checked ? ".dcx" : "")))
{
//user hasn't unpacked their game
lblMessage.Text = "You don't seem to have an unpacked Dark Souls installation. Please run UDSFM and come back :)";
if (checkBoxRemaster.Checked)
{
//invalid directory
lblMessage.Text = "Invalid Dark Souls: Remastered game directory; No GameParam found.";
}
else
{
//user hasn't unpacked their game
lblMessage.Text = "You don't seem to have an unpacked Dark Souls: Prepare to Die Edition installation. Please run UDSFM and come back :)";
}
lblMessage.ForeColor = Color.Red;
return;
}
Expand All @@ -82,16 +98,24 @@ private async void btnSubmit_Click(object sender, EventArgs e)
lblMessage.ForeColor = new Color();
lblMessage.Visible = true;

if (!File.Exists(gameDirectory + "\\DARKSOULS.exe"))
if (!File.Exists(gameDirectory + (checkBoxRemaster.Checked ? "\\DarkSoulsRemastered.exe" : "\\DARKSOULS.exe")))
{
lblMessage.Text = "Not a valid Data directory!";
lblMessage.Text = $"Not a valid {(checkBoxRemaster.Checked ? "Dark Souls: Remastered" : "Dark Souls: Prepare to Die Edition")} Data directory.";
lblMessage.ForeColor = Color.Red;
return;
}
else if (!File.Exists(gameDirectory + "\\param\\GameParam\\GameParam.parambnd"))
else if (!File.Exists(gameDirectory + "\\param\\GameParam\\GameParam.parambnd" + (checkBoxRemaster.Checked ? ".dcx" : "")))
{
//user hasn't unpacked their game
lblMessage.Text = "You don't seem to have an unpacked Dark Souls installation. Please run UDSFM and come back :)";
if (checkBoxRemaster.Checked)
{
//invalid directory
lblMessage.Text = "Invalid Dark Souls: Remastered game directory; No GameParam found.";
}
else
{
//user hasn't unpacked their game
lblMessage.Text = "You don't seem to have an unpacked Dark Souls: Prepare to Die Edition installation. Please run UDSFM and come back :)";
}
lblMessage.ForeColor = Color.Red;
return;
}
Expand All @@ -114,62 +138,27 @@ private async void btnSubmit_Click(object sender, EventArgs e)
string seed = txtSeed.Text;

//create backup of gameparam
if (!File.Exists(gameDirectory + "\\param\\GameParam\\GameParam.parambnd.bak"))
if (!File.Exists(gameDirectory + $"\\param\\GameParam\\GameParam.parambnd{(checkBoxRemaster.Checked ? ".dcx" : "")}.bak"))
{
File.Copy(gameDirectory + "\\param\\GameParam\\GameParam.parambnd", gameDirectory + "\\param\\GameParam\\GameParam.parambnd.bak");
lblMessage.Text = "Backed up GameParam.parambnd \n\n";
File.Copy(gameDirectory + $"\\param\\GameParam\\GameParam.parambnd{(checkBoxRemaster.Checked ? ".dcx" : "")}",
gameDirectory + $"\\param\\GameParam\\GameParam.parambnd{(checkBoxRemaster.Checked ? ".dcx" : "")}.bak");
lblMessage.Text = $"Backed up GameParam.parambnd{(checkBoxRemaster.Checked ? ".dcx" : "")} \n\n";
lblMessage.ForeColor = Color.Black;
lblMessage.Visible = true;
}

//Load parambnds/paramdefs into params
List<PARAM> AllParams = new List<PARAM>();
List<PARAMDEF> ParamDefs = new List<PARAMDEF>();

List<BND> gameparamBnds = Directory.GetFiles(gameDirectory + "\\param\\GameParam\\", "*.parambnd")
.Select(p => DataFile.LoadFromFile<BND>(p, new Progress<(int, int)>((pr) =>
{
}))).ToList();
PARAMBND gameparamBnd = DataFile.LoadFromFile<PARAMBND>(gameDirectory + $"\\param\\GameParam\\GameParam.parambnd{(checkBoxRemaster.Checked ? ".dcx" : "")}");

List<BND> paramdefBnds = Directory.GetFiles(gameDirectory + "\\paramdef\\", "*.paramdefbnd")
.Select(p => DataFile.LoadFromFile<BND>(p, new Progress<(int, int)>((pr) =>
{
}))).ToList();

for (int i = 0; i < paramdefBnds.Count(); i++)
{
foreach (MeowDSIO.DataTypes.BND.BNDEntry paramdef in paramdefBnds[i])
{
PARAMDEF newParamDef = paramdef.ReadDataAs<PARAMDEF>(new Progress<(int, int)>((p) =>
{
}));
ParamDefs.Add(newParamDef);
}
}

for (int i = 0; i < gameparamBnds.Count(); i++)
{
foreach (MeowDSIO.DataTypes.BND.BNDEntry param in gameparamBnds[i])
{
PARAM newParam = param.ReadDataAs<PARAM>(new Progress<(int, int)>((p) =>
{
}));

newParam.ApplyPARAMDEFTemplate(ParamDefs.Where(x => x.ID == newParam.ID).First());
AllParams.Add(newParam);
}
}
gameparamBnd.ApplyDefaultParamDefs();

//Hash seed so people can use meme seeds
Random r = new Random(seed.GetHashCode());

foreach (PARAM paramFile in AllParams)
foreach (var paramBndEntry in gameparamBnd)
{
if (paramFile.VirtualUri.EndsWith("AtkParam_Npc.param"))
var paramShortName = paramBndEntry.Name;
var paramFile = paramBndEntry.Param;
if (paramShortName.Contains("AtkParam_Npc"))
{
List<int> allSpEffects = new List<int>();
List<float> allKnockbackDists = new List<float>();
Expand Down Expand Up @@ -262,7 +251,7 @@ private async void btnSubmit_Click(object sender, EventArgs e)
}
}
}
else if (paramFile.VirtualUri.EndsWith("AtkParam_Pc.param"))
else if (paramShortName.Contains("AtkParam_Pc"))
{
List<float> allKnockbackDists = new List<float>();
List<int> allDmgLevels = new List<int>();
Expand Down Expand Up @@ -2927,25 +2916,7 @@ private async void btnSubmit_Click(object sender, EventArgs e)
}

//repack param files
foreach (BND paramBnd in gameparamBnds)
{
foreach (MeowDSIO.DataTypes.BND.BNDEntry param in paramBnd)
{
string filteredParamName = param.Name.Substring(param.Name.LastIndexOf("\\") + 1).Replace(".param", "");

PARAM matchingParam = AllParams.Where(x => x.VirtualUri == param.Name).First();

param.ReplaceData(matchingParam,new Progress<(int, int)>((p) =>
{
}));
}

DataFile.Resave(paramBnd, new Progress<(int, int)>((p) =>
{
}));
}
DataFile.Resave(gameparamBnd);

lblMessage.Text += "Randomizing Complete!";
lblMessage.ForeColor = Color.Black;
Expand Down Expand Up @@ -3166,5 +3137,37 @@ public static string[] InvalidVoiceIds

}

private void checkBoxRemaster_CheckedChanged(object sender, EventArgs e)
{
//check that entered path is valid
gameDirectory = txtGamePath.Text;

//reset message label
lblMessage.Text = "";
lblMessage.ForeColor = new Color();
lblMessage.Visible = true;

if (!File.Exists(gameDirectory + (checkBoxRemaster.Checked ? "\\DarkSoulsRemastered.exe" : "\\DARKSOULS.exe")))
{
lblMessage.Text = $"Not a valid {(checkBoxRemaster.Checked ? "Dark Souls: Remastered" : "Dark Souls: Prepare to Die Edition")} Data directory.";
lblMessage.ForeColor = Color.Red;
return;
}
else if (!File.Exists(gameDirectory + "\\param\\GameParam\\GameParam.parambnd" + (checkBoxRemaster.Checked ? ".dcx" : "")))
{
if (checkBoxRemaster.Checked)
{
//invalid directory
lblMessage.Text = "Invalid Dark Souls: Remastered game directory; No GameParam found.";
}
else
{
//user hasn't unpacked their game
lblMessage.Text = "You don't seem to have an unpacked Dark Souls: Prepare to Die Edition installation. Please run UDSFM and come back :)";
}
lblMessage.ForeColor = Color.Red;
return;
}
}
}
}
24 changes: 23 additions & 1 deletion Paramdomizer/Form1.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e96d318

Please sign in to comment.