Skip to content

Commit

Permalink
Add toggle to show archive editor when loading project #68
Browse files Browse the repository at this point in the history
Fixes #68
  • Loading branch information
ItsPepperpot committed Oct 12, 2024
1 parent e1b9b5b commit 0dbef3e
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 46 deletions.
1 change: 0 additions & 1 deletion IndustrialPark/ArchiveEditor/ArchiveEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ private void OpenFileDone(string fileName)
{
Program.MainForm.SetToolStripItemName(this, Text);
Program.MainForm.SetRecentOpenedArchives(fileName);
Show();
}
}

Expand Down
41 changes: 26 additions & 15 deletions IndustrialPark/MainForm/MainForm.Designer.cs

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

36 changes: 25 additions & 11 deletions IndustrialPark/MainForm/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ private void ApplyIPSettings(IPSettings settings)
BuildISO.PCSX2Path = settings.pcsx2Path;
BuildISO.recentGameDirPaths = settings.recentBuildIsoGamePaths;

bool showEditorsWhenLoadingProject = settings.showEditorsWhenLoadingProject;
showEditorsWhenLoadingProjectToolStripMenuItem.Checked = showEditorsWhenLoadingProject;

setFlyCursor(settings.flyModeCursor);

foreach (string filepath in settings.recentArchivePaths)
Expand Down Expand Up @@ -199,7 +202,7 @@ private void ApplyIPSettings(IPSettings settings)
}

if (settings.AutoloadOnStartup && !string.IsNullOrEmpty(settings.LastProjectPath) && File.Exists(settings.LastProjectPath))
ApplyProject(settings.LastProjectPath);
ApplyProject(settings.LastProjectPath, showEditorsWhenLoadingProject);
}

private delegate void StartLoop(Panel renderPanel);
Expand Down Expand Up @@ -245,7 +248,8 @@ private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
pcsx2Path = BuildISO.PCSX2Path,
recentBuildIsoGamePaths = BuildISO.recentGameDirPaths,
recentArchivePaths = openLastToolStripMenuItem.DropDownItems.Cast<ToolStripMenuItem>().Select(x => x.Text).ToArray(),
flyModeCursor = (int)flyModeCursor
flyModeCursor = (int)flyModeCursor,
showEditorsWhenLoadingProject = showEditorsWhenLoadingProjectToolStripMenuItem.Checked
};

File.WriteAllText(pathToSettings, JsonConvert.SerializeObject(settings, Formatting.Indented));
Expand Down Expand Up @@ -315,7 +319,7 @@ private void openToolStripMenuItem_Click(object sender, EventArgs e)
{ Filter = "JSON files|*.json" };

if (openFile.ShowDialog() == DialogResult.OK)
ApplyProject(openFile.FileName);
ApplyProject(openFile.FileName, showEditorsWhenLoadingProjectToolStripMenuItem.Checked);
}

private void saveToolStripMenuItem_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -439,14 +443,14 @@ public ProjectJson FromCurrentInstance()
};
}

private void ApplyProject(string projectPath)
private void ApplyProject(string projectPath, bool showEditors = true)
{
currentProjectPath = projectPath;
SetProjectToolStripStatusLabel();
ApplyProject(JsonConvert.DeserializeObject<ProjectJson>(File.ReadAllText(projectPath)));
ApplyProject(JsonConvert.DeserializeObject<ProjectJson>(File.ReadAllText(projectPath)), showEditors);
}

private void ApplyProject(ProjectJson ipSettings)
private void ApplyProject(ProjectJson ipSettings, bool showEditors = true)
{
if (ipSettings.version != ProjectJson.getCurrentVersion)
MessageBox.Show("You are trying to open a project file made with a different version of Industrial Park. The program will attempt to load the project, but there is a chance it will not load properly.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Expand All @@ -468,10 +472,13 @@ private void ApplyProject(ProjectJson ipSettings)
else
{
if (File.Exists(ipSettings.hipPaths[i]))
AddArchiveEditor(ipSettings.hipPaths[i], ipSettings.scoobyPlatforms[i]);
AddArchiveEditor(ipSettings.hipPaths[i], ipSettings.scoobyPlatforms[i], showEditors);
else
{
MessageBox.Show("Error opening " + ipSettings.hipPaths[i] + ": file not found");
MessageBox.Show("Error opening " + ipSettings.hipPaths[i] + ": file not found",
"File not Found",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}

Expand Down Expand Up @@ -804,11 +811,10 @@ private void newToolStripMenuItem_Click(object sender, EventArgs e)
archiveEditors.Last().Show();
}

public void AddArchiveEditor(string filePath = null, Platform scoobyPlatform = Platform.Unknown)
public void AddArchiveEditor(string filePath = null, Platform scoobyPlatform = Platform.Unknown, bool show = true)
{
ArchiveEditor ae = new ArchiveEditor();
ae.Show();
ae.Hide();

ae.Begin(filePath, scoobyPlatform);
archiveEditors.Add(ae);

Expand All @@ -826,6 +832,9 @@ public void AddArchiveEditor(string filePath = null, Platform scoobyPlatform = P
UpdateTitleBar();
SetupAssetVisibilityButtons();
closeAllEditorsToolStripMenuItem.Enabled = true;

if (show)
ae.Show();
}

public void EditorUpdate()
Expand Down Expand Up @@ -2024,5 +2033,10 @@ private void setFlyCursor(int flyModeCursor)
foreach (ToolStripMenuItem item in cursorInFlyModeToolStripMenuItem.DropDownItems)
item.Checked = Convert.ToInt32(item.Tag) == flyModeCursor;
}

private void showEditorsWhenLoadingProjectToolStripMenuItem_Click(object sender, EventArgs e)
{
showEditorsWhenLoadingProjectToolStripMenuItem.Checked = !showEditorsWhenLoadingProjectToolStripMenuItem.Checked;
}
}
}
50 changes: 31 additions & 19 deletions IndustrialPark/MainForm/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -166,44 +166,50 @@
<value>&amp;Archive Editor</value>
</data>
<data name="newToolStripMenuItem1.Size" type="System.Drawing.Size, System.Drawing">
<value>191, 22</value>
<value>262, 22</value>
</data>
<data name="newToolStripMenuItem1.Text" xml:space="preserve">
<value>&amp;New</value>
</data>
<data name="openToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>191, 22</value>
<value>262, 22</value>
</data>
<data name="openToolStripMenuItem.Text" xml:space="preserve">
<value>&amp;Open</value>
</data>
<data name="saveToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>191, 22</value>
<value>262, 22</value>
</data>
<data name="saveToolStripMenuItem.Text" xml:space="preserve">
<value>&amp;Save</value>
</data>
<data name="saveAsToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>191, 22</value>
<value>262, 22</value>
</data>
<data name="saveAsToolStripMenuItem.Text" xml:space="preserve">
<value>Save &amp;As...</value>
</data>
<data name="toolStripSeparator5.Size" type="System.Drawing.Size, System.Drawing">
<value>188, 6</value>
<value>259, 6</value>
</data>
<data name="autoSaveOnClosingToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>191, 22</value>
<value>262, 22</value>
</data>
<data name="autoSaveOnClosingToolStripMenuItem.Text" xml:space="preserve">
<value>Auto-Save On Closing</value>
</data>
<data name="autoLoadOnStartupToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>191, 22</value>
<value>262, 22</value>
</data>
<data name="autoLoadOnStartupToolStripMenuItem.Text" xml:space="preserve">
<value>Auto-Load On Startup</value>
</data>
<data name="showEditorsWhenLoadingProjectToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>262, 22</value>
</data>
<data name="showEditorsWhenLoadingProjectToolStripMenuItem.Text" xml:space="preserve">
<value>Show Editors When Loading Project</value>
</data>
<data name="projectToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>56, 19</value>
</data>
Expand Down Expand Up @@ -2585,6 +2591,12 @@
<data name="&gt;&gt;autoLoadOnStartupToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;showEditorsWhenLoadingProjectToolStripMenuItem.Name" xml:space="preserve">
<value>showEditorsWhenLoadingProjectToolStripMenuItem</value>
</data>
<data name="&gt;&gt;showEditorsWhenLoadingProjectToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;optionsToolStripMenuItem.Name" xml:space="preserve">
<value>optionsToolStripMenuItem</value>
</data>
Expand Down Expand Up @@ -3053,6 +3065,18 @@
<data name="&gt;&gt;toolStripStatusLabelTemplate.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;toolStripStatusLabel4.Name" xml:space="preserve">
<value>toolStripStatusLabel4</value>
</data>
<data name="&gt;&gt;toolStripStatusLabel4.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;toolStripStatusLabelNumSelected.Name" xml:space="preserve">
<value>toolStripStatusLabelNumSelected</value>
</data>
<data name="&gt;&gt;toolStripStatusLabelNumSelected.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;gizmoToolStripMenuItem.Name" xml:space="preserve">
<value>gizmoToolStripMenuItem</value>
</data>
Expand Down Expand Up @@ -3101,18 +3125,6 @@
<data name="&gt;&gt;toolStripComboBoxUserTemplate.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;toolStripStatusLabel4.Name" xml:space="preserve">
<value>toolStripStatusLabel4</value>
</data>
<data name="&gt;&gt;toolStripStatusLabel4.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;toolStripStatusLabelNumSelected.Name" xml:space="preserve">
<value>toolStripStatusLabelNumSelected</value>
</data>
<data name="&gt;&gt;toolStripStatusLabelNumSelected.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>MainForm</value>
</data>
Expand Down
1 change: 1 addition & 0 deletions IndustrialPark/Other/IPSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ public class IPSettings
public string pcsx2Path;
public string[] recentBuildIsoGamePaths;
public int flyModeCursor = 1;
public bool showEditorsWhenLoadingProject = true;
}
}

0 comments on commit 0dbef3e

Please sign in to comment.