Skip to content

Commit

Permalink
Complete gamecube banner editor #74
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsPepperpot committed Aug 1, 2024
1 parent 582cb33 commit c6d0e39
Show file tree
Hide file tree
Showing 8 changed files with 568 additions and 217 deletions.
2 changes: 2 additions & 0 deletions IndustrialPark/IndustrialPark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@
<Compile Include="MainForm\OpenLevel.Designer.cs">
<DependentUpon>OpenLevel.cs</DependentUpon>
</Compile>
<Compile Include="Other\GameCubeBanner.cs" />
<Compile Include="Other\MessageBox.cs" />
<Compile Include="Models\BSP_IO_Shared.cs" />
<Compile Include="Models\ChooseTarget.cs">
Expand Down Expand Up @@ -939,6 +940,7 @@
<Content Include="Resources\ArrowDefault.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\PlaceholderBanner1.png" />
<Content Include="Resources\Scripts\readme.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down
285 changes: 154 additions & 131 deletions IndustrialPark/MainForm/CreateGameCubeBanner.Designer.cs

Large diffs are not rendered by default.

119 changes: 119 additions & 0 deletions IndustrialPark/MainForm/CreateGameCubeBanner.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using IndustrialPark.Other;
using Image = System.Web.UI.WebControls.Image;

namespace IndustrialPark
{
Expand All @@ -14,5 +19,119 @@ private void cancelButton_Click(object sender, EventArgs e)
{
Close();
}

private void saveButton_Click(object sender, EventArgs e)
{
Bitmap image = new Bitmap(GameCubeBanner.IMAGE_WIDTH, GameCubeBanner.IMAGE_HEIGHT);
bannerPictureBox.DrawToBitmap(image, bannerPictureBox.ClientRectangle);

GameCubeBanner banner = new GameCubeBanner
{
Image = image,
Creator = creatorTextBox.Text,
CreatorFull = creatorFullTextBox.Text,
Description = descriptionTextBox.Text,
Title = titleTextBox.Text,
TitleFull = titleFullTextBox.Text
};

// Get save location from dialog

SaveFileDialog dialog = new SaveFileDialog
{
Filter = "GameCube Banner (*.bnr)|*.bnr",
Title = "Save GameCube Banner",
FileName = GameCubeBanner.DEFAULT_FILENAME,
AddExtension = true,
DefaultExt = "bnr"
};

if (dialog.ShowDialog() == DialogResult.OK)
{
// Save banner to file
if (banner.SaveToFile(dialog.FileName))
{
MessageBox.Show("Banner saved successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Failed to save banner.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}

private void selectImageButton_Click(object sender, EventArgs e)
{
// Open file dialog to select image
OpenFileDialog dialog = new OpenFileDialog
{
Filter = "Image Files|*.bmp;*.jpg;*.jpeg;*.png;*.gif;*.tif;*.tiff",
Title = "Select an image file"
};

if (dialog.ShowDialog() == DialogResult.OK)
{
imagePathTextBox.Text = dialog.FileName;
metadataTextChanged(null, null);

// Update PictureBox with image
try
{
bannerPictureBox.Image = new Bitmap(dialog.FileName);
}
catch (Exception ex)
{
MessageBox.Show("Failed to load image: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}

private void metadataTextChanged(object sender, EventArgs e)
{
// Enable save button if all metadata fields are filled
saveButton.Enabled = !string.IsNullOrWhiteSpace(titleTextBox.Text) &&
!string.IsNullOrWhiteSpace(creatorTextBox.Text) &&
!string.IsNullOrWhiteSpace(titleFullTextBox.Text) &&
!string.IsNullOrWhiteSpace(creatorFullTextBox.Text) &&
!string.IsNullOrWhiteSpace(descriptionTextBox.Text);

}

private void importBnrButton_Click(object sender, EventArgs e)
{
// Open file dialog to select BNR file

OpenFileDialog dialog = new OpenFileDialog
{
Filter = "GameCube Banner (*.bnr)|*.bnr",
Title = "Select a GameCube Banner file"
};

if (dialog.ShowDialog() == DialogResult.OK)
{
// Import banner from file
GameCubeBanner banner = GameCubeBanner.ImportFromFile(dialog.FileName);

if (banner != null)
{
// Set metadata fields
titleTextBox.Text = banner.Title;
creatorTextBox.Text = banner.Creator;
titleFullTextBox.Text = banner.TitleFull;
creatorFullTextBox.Text = banner.CreatorFull;
descriptionTextBox.Text = banner.Description;

// Convert image to PictureBox
bannerPictureBox.Image = banner.Image;

// Update image path text box
imagePathTextBox.Text = dialog.FileName;
}
else
{
MessageBox.Show("Failed to import banner.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}
24 changes: 0 additions & 24 deletions IndustrialPark/MainForm/CreateGameCubeBanner.resx
Original file line number Diff line number Diff line change
Expand Up @@ -120,28 +120,4 @@
<data name="label1.Text" xml:space="preserve">
<value>GameCube banners, named "opening.bnr", contain metadata about the game, including its title and creator, and a 96px x 32px banner image which is displayed in menu mode. It is also displayed in Dolphin's game list.</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="pictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAGAAAAAgCAYAAADtwH1UAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAACxMAAAsTAQCanBgAAAPpSURBVGhD7ZfpKzdRFMefP+pnl2xRtlKWCAlZsiZCIkmJ
LIUi8sIaUpZs2UO2f+o+fU7daWbMz7OY6b65Lz5xz5zfnXvP99xzz/yKxWLKYg4rgGGsAIaxAhjGCmAY
K4BhrACGsQIYxgpgGCuAYSIVoLGxUe3t7anr62t1eHioBgcHVUJCQqBvcnKymp+fF7/e3t5An5+QkpKi
hoaG1P7+vrq8vFQbGxuqvr7e48PaWltb1fb2trq6ulK7u7uylnhrDoPIBBgZGVGfn5/q8fFR7ezsqLu7
OxkvLCwE+s/OzspzNo0YQT7/S2JiolpfX5f5WQciv7+/y7ipqcnxGx0dFdvz87M6ODhQLy8vMp6cnPTM
FyaRCJ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