Skip to content

Commit

Permalink
- ModGenerator now builds EXEData.ini files and stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorvinus committed Jul 7, 2015
1 parent 5533889 commit 79268f0
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 9 deletions.
18 changes: 17 additions & 1 deletion SADXLVL2/MainForm.Designer.cs

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

17 changes: 17 additions & 0 deletions SADXLVL2/MainForm.cs
Expand Up @@ -2621,5 +2621,22 @@ private void pointToolStripMenuItem_Click(object sender, EventArgs e)
LevelData_StateChanged();
}
}

private void playTestButton_Click(object sender, EventArgs e)
{
PlayTestLevel();
}

private void PlayTestLevel()
{
// Go through all of the data INI files in the mod.ini
// within each one, look at each file listed. Compare the project and mod versions. If the project version is different, overwrite the mod version with it.

// save spawn data somewhere where modloader can pick up on it

// set the current mod to this one

// start sonic.exe with the -testspawn flag
}
}
}
12 changes: 11 additions & 1 deletion SADXLVL2/Properties/Resources.Designer.cs

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

6 changes: 4 additions & 2 deletions SADXLVL2/Properties/Resources.resx
Expand Up @@ -117,7 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="UnknownImg" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\UnknownImg.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
Expand Down Expand Up @@ -145,7 +145,6 @@
<data name="paste" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\paste.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="hyoji_zanki_a" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\hyoji_zanki_a.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
Expand All @@ -164,4 +163,7 @@
<data name="hyoji_zankib" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\hyoji_zankib.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="PlayButton" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\PlayButton.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file added SADXLVL2/Resources/PlayButton.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions SADXLVL2/SADXLVL2.csproj
Expand Up @@ -155,6 +155,7 @@
<None Include="Resources\hyoji_zanki_s.png" />
<None Include="Resources\hyoji_zanki_t.png" />
<None Include="Resources\hyoji_zankib.png" />
<Content Include="Resources\PlayButton.png" />
<Content Include="TailsDX.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
66 changes: 61 additions & 5 deletions StructConverter/ModBuilder.cs
Expand Up @@ -331,11 +331,12 @@ private void ExportCPP(TextWriter writer, bool SA2)
}
writer.WriteLine("// Generated by SA Tools Struct Converter");
writer.WriteLine();
writer.WriteLine("#include \"stdafx.h\"");
if (SA2)
writer.WriteLine("#include \"SA2ModLoader.h\"");
else
writer.WriteLine("#include \"SADXModLoader.h\"");
writer.WriteLine();
writer.WriteLine();
Dictionary<string, string> models = new Dictionary<string, string>();
foreach (KeyValuePair<string, SA_Tools.FileInfo> item in IniData.Files.Where((a, i) => listView1.CheckedIndices.Contains(i)))
{
Expand Down Expand Up @@ -917,7 +918,8 @@ private void INIExport_Click(object sender, EventArgs e)
{
string destinationFolder = Path.Combine(Path.Combine(gameFolder, "mods"), projectName);

IniData output = new IniData();
#region Generate our EXEData ini file
IniData output = new IniData();
output.Files = new Dictionary<string, SA_Tools.FileInfo>();
foreach (KeyValuePair<string, SA_Tools.FileInfo> item in IniData.Files.Where((a, i) => listView1.CheckedIndices.Contains(i)))
{
Expand All @@ -936,7 +938,7 @@ private void INIExport_Click(object sender, EventArgs e)
string path = Path.GetDirectoryName(projectRelativeFileLocation);
for (int j = 0; j < list.Length; j++)
{
System.IO.FileInfo file = new System.IO.FileInfo(Path.Combine(path, j.ToString(NumberFormatInfo.InvariantInfo) + ".sa1mdl"));
System.IO.FileInfo file = new System.IO.FileInfo(Path.Combine(path, j.ToString(NumberFormatInfo.InvariantInfo) + ".sa1mdl")); // todo: this extension isn't getting copied correctly
file.CopyTo(Path.Combine(Path.Combine(destinationFolder, path), j.ToString(NumberFormatInfo.InvariantInfo)), true);
}
File.Copy(projectRelativeFileLocation, Path.Combine(destinationFolder, projectRelativeFileLocation), true);
Expand All @@ -952,8 +954,62 @@ private void INIExport_Click(object sender, EventArgs e)
output.Files.Add(item.Key, item.Value);
}

IniSerializer.Serialize(output, Path.Combine(destinationFolder, "exeData.ini"));
}
IniSerializer.Serialize(output, Path.Combine(destinationFolder, "exeData.ini")); // todo: put a copy of this in the project folder so that sadxlvl2 knows what to copy
// for it's built-in 'test/play' feature
#endregion

#region Add EXEData to mod.ini & copy to mod folder
string modIniFile = Path.Combine(projectFolder, "mod.ini");
StreamReader modReader = File.OpenText(modIniFile);
List<string> modINILines = new List<string>();

while(!modReader.EndOfStream)
{
modINILines.Add(modReader.ReadLine());
}

modReader.Close();

int lineIndex=0;
bool replaceLine = false;
bool addLine = true;
foreach(string line in modINILines)
{
if(line.ToLowerInvariant() == "EXEData=exeData.ini".ToLowerInvariant())
{
addLine = false;
replaceLine = false;
break;
}
else
{
string[] linesSplit = line.Split('=');
if(linesSplit[0].ToLowerInvariant() == "EXEData".ToLowerInvariant())
{
replaceLine = true;
addLine = false;
lineIndex = modINILines.FindIndex(item => item == line);
break;
}
}
}

if (addLine) modINILines.Add("EXEData=exeData.ini");
else if (replaceLine) modINILines[lineIndex] = "EXEData=exeData.ini";

if(addLine || replaceLine) // we need to output our updated lines to the file
{
StreamWriter modWriter = new StreamWriter(modIniFile, false, Encoding.Default);
foreach (string line in modINILines) modWriter.WriteLine(line);

modWriter.Flush();
modWriter.Close();
}

// copy mod.ini to mod folder
File.Copy(modIniFile, Path.Combine(destinationFolder, "mod.ini"));
#endregion
}

private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
Expand Down

0 comments on commit 79268f0

Please sign in to comment.