diff --git a/README.md b/README.md index f8faebf..359d704 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# Twilight Boxart +![Screenshot](https://https://raw.githubusercontent.com/KirovAir/TwilightBoxart/master/img/screenshot.png) + +# Twilight Boxart A boxart downloader written in C#. Uses various sources and scan methods to determine the correct boxart. Written for TwilightMenu++ but can be used for other loader UI's with some config changes. 😊 diff --git a/TwilightBoxart.CLI/TwilightBoxart.CLI.csproj b/TwilightBoxart.CLI/TwilightBoxart.CLI.csproj index 52d8dcd..483aef8 100644 --- a/TwilightBoxart.CLI/TwilightBoxart.CLI.csproj +++ b/TwilightBoxart.CLI/TwilightBoxart.CLI.csproj @@ -7,16 +7,6 @@ true - - - - - - - Always - - - diff --git a/TwilightBoxart.CLI/TwilightBoxart.ini b/TwilightBoxart.CLI/TwilightBoxart.ini deleted file mode 100644 index 276036e..0000000 --- a/TwilightBoxart.CLI/TwilightBoxart.ini +++ /dev/null @@ -1,5 +0,0 @@ -[Config] -SdRoot= -BoxArtDir={sdroot}\_nds\TWiLightMenu\boxart -BoxartWidth=128 -BoxartHeight=115 \ No newline at end of file diff --git a/TwilightBoxart.UX/App.config b/TwilightBoxart.UX/App.config index 85cb80c..d5b3839 100644 --- a/TwilightBoxart.UX/App.config +++ b/TwilightBoxart.UX/App.config @@ -1,33 +1,33 @@ - + - + - - + + - - + + - - + + - - + + - - + + - + diff --git a/TwilightBoxart.UX/MainForm.Designer.cs b/TwilightBoxart.UX/MainForm.Designer.cs index 157ba7e..8b54de6 100644 --- a/TwilightBoxart.UX/MainForm.Designer.cs +++ b/TwilightBoxart.UX/MainForm.Designer.cs @@ -54,10 +54,10 @@ private void InitializeComponent() // // btnBrowseSd // - this.btnBrowseSd.Location = new System.Drawing.Point(349, 18); - this.btnBrowseSd.Margin = new System.Windows.Forms.Padding(2); + this.btnBrowseSd.Location = new System.Drawing.Point(698, 35); + this.btnBrowseSd.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.btnBrowseSd.Name = "btnBrowseSd"; - this.btnBrowseSd.Size = new System.Drawing.Size(76, 30); + this.btnBrowseSd.Size = new System.Drawing.Size(152, 58); this.btnBrowseSd.TabIndex = 2; this.btnBrowseSd.Text = "Browse..."; this.btnBrowseSd.UseVisualStyleBackColor = true; @@ -66,61 +66,63 @@ private void InitializeComponent() // txtSdRoot // this.txtSdRoot.BackColor = System.Drawing.SystemColors.ControlLightLight; - this.txtSdRoot.Location = new System.Drawing.Point(6, 24); - this.txtSdRoot.Margin = new System.Windows.Forms.Padding(2); + this.txtSdRoot.Location = new System.Drawing.Point(12, 46); + this.txtSdRoot.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.txtSdRoot.Name = "txtSdRoot"; - this.txtSdRoot.ReadOnly = true; - this.txtSdRoot.Size = new System.Drawing.Size(339, 20); + this.txtSdRoot.Size = new System.Drawing.Size(674, 31); this.txtSdRoot.TabIndex = 1; + this.txtSdRoot.TextChanged += new System.EventHandler(this.txtSdRoot_TextChanged); // // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(3, 9); - this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label1.Location = new System.Drawing.Point(6, 17); + this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(129, 13); + this.label1.Size = new System.Drawing.Size(252, 25); this.label1.TabIndex = 2; this.label1.Text = "SD Root / Roms location:"; // // txtLog // this.txtLog.BackColor = System.Drawing.SystemColors.ControlLightLight; - this.txtLog.Location = new System.Drawing.Point(6, 127); + this.txtLog.Location = new System.Drawing.Point(12, 244); + this.txtLog.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); this.txtLog.Multiline = true; this.txtLog.Name = "txtLog"; this.txtLog.ReadOnly = true; this.txtLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.txtLog.Size = new System.Drawing.Size(499, 189); + this.txtLog.Size = new System.Drawing.Size(996, 360); this.txtLog.TabIndex = 10; // // txtBoxart // this.txtBoxart.BackColor = System.Drawing.SystemColors.ControlLightLight; - this.txtBoxart.Location = new System.Drawing.Point(6, 71); - this.txtBoxart.Margin = new System.Windows.Forms.Padding(2); + this.txtBoxart.Location = new System.Drawing.Point(12, 137); + this.txtBoxart.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.txtBoxart.Name = "txtBoxart"; this.txtBoxart.ReadOnly = true; - this.txtBoxart.Size = new System.Drawing.Size(339, 20); + this.txtBoxart.Size = new System.Drawing.Size(674, 31); this.txtBoxart.TabIndex = 4; + this.txtBoxart.TextChanged += new System.EventHandler(this.txtBoxart_TextChanged); // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(3, 56); - this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label2.Location = new System.Drawing.Point(6, 108); + this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(80, 13); + this.label2.Size = new System.Drawing.Size(161, 25); this.label2.TabIndex = 5; this.label2.Text = "Boxart location:"; // // btnBrowseBoxart // this.btnBrowseBoxart.Enabled = false; - this.btnBrowseBoxart.Location = new System.Drawing.Point(349, 65); - this.btnBrowseBoxart.Margin = new System.Windows.Forms.Padding(2); + this.btnBrowseBoxart.Location = new System.Drawing.Point(698, 125); + this.btnBrowseBoxart.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.btnBrowseBoxart.Name = "btnBrowseBoxart"; - this.btnBrowseBoxart.Size = new System.Drawing.Size(76, 30); + this.btnBrowseBoxart.Size = new System.Drawing.Size(152, 58); this.btnBrowseBoxart.TabIndex = 5; this.btnBrowseBoxart.Text = "Browse..."; this.btnBrowseBoxart.UseVisualStyleBackColor = true; @@ -129,9 +131,10 @@ private void InitializeComponent() // chkManualBoxartLocation // this.chkManualBoxartLocation.AutoSize = true; - this.chkManualBoxartLocation.Location = new System.Drawing.Point(430, 71); + this.chkManualBoxartLocation.Location = new System.Drawing.Point(860, 137); + this.chkManualBoxartLocation.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); this.chkManualBoxartLocation.Name = "chkManualBoxartLocation"; - this.chkManualBoxartLocation.Size = new System.Drawing.Size(87, 17); + this.chkManualBoxartLocation.Size = new System.Drawing.Size(169, 29); this.chkManualBoxartLocation.TabIndex = 6; this.chkManualBoxartLocation.Text = "Set Manually"; this.chkManualBoxartLocation.UseVisualStyleBackColor = true; @@ -139,10 +142,10 @@ private void InitializeComponent() // // btnDetect // - this.btnDetect.Location = new System.Drawing.Point(429, 18); - this.btnDetect.Margin = new System.Windows.Forms.Padding(2); + this.btnDetect.Location = new System.Drawing.Point(858, 35); + this.btnDetect.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.btnDetect.Name = "btnDetect"; - this.btnDetect.Size = new System.Drawing.Size(76, 30); + this.btnDetect.Size = new System.Drawing.Size(152, 58); this.btnDetect.TabIndex = 3; this.btnDetect.Text = "Detect SD"; this.toolTip.SetToolTip(this.btnDetect, "Will try to detect your (Twilight++) SD card"); @@ -152,10 +155,10 @@ private void InitializeComponent() // btnStart // this.btnStart.Enabled = false; - this.btnStart.Location = new System.Drawing.Point(430, 321); - this.btnStart.Margin = new System.Windows.Forms.Padding(2); + this.btnStart.Location = new System.Drawing.Point(858, 614); + this.btnStart.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.btnStart.Name = "btnStart"; - this.btnStart.Size = new System.Drawing.Size(76, 30); + this.btnStart.Size = new System.Drawing.Size(152, 58); this.btnStart.TabIndex = 12; this.btnStart.Text = "Start"; this.btnStart.UseVisualStyleBackColor = true; @@ -163,14 +166,15 @@ private void InitializeComponent() // // numWidth // - this.numWidth.Location = new System.Drawing.Point(46, 101); + this.numWidth.Location = new System.Drawing.Point(92, 194); + this.numWidth.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); this.numWidth.Maximum = new decimal(new int[] { 9999, 0, 0, 0}); this.numWidth.Name = "numWidth"; - this.numWidth.Size = new System.Drawing.Size(59, 20); + this.numWidth.Size = new System.Drawing.Size(118, 31); this.numWidth.TabIndex = 7; this.numWidth.Value = new decimal(new int[] { 128, @@ -181,14 +185,15 @@ private void InitializeComponent() // // numHeight // - this.numHeight.Location = new System.Drawing.Point(166, 101); + this.numHeight.Location = new System.Drawing.Point(332, 194); + this.numHeight.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); this.numHeight.Maximum = new decimal(new int[] { 9999, 0, 0, 0}); this.numHeight.Name = "numHeight"; - this.numHeight.Size = new System.Drawing.Size(59, 20); + this.numHeight.Size = new System.Drawing.Size(118, 31); this.numHeight.TabIndex = 8; this.numHeight.Value = new decimal(new int[] { 115, @@ -200,10 +205,10 @@ private void InitializeComponent() // lblSize2 // this.lblSize2.AutoSize = true; - this.lblSize2.Location = new System.Drawing.Point(120, 103); - this.lblSize2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.lblSize2.Location = new System.Drawing.Point(240, 198); + this.lblSize2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblSize2.Name = "lblSize2"; - this.lblSize2.Size = new System.Drawing.Size(41, 13); + this.lblSize2.Size = new System.Drawing.Size(80, 25); this.lblSize2.TabIndex = 13; this.lblSize2.Text = "Height:"; this.lblSize2.Visible = false; @@ -211,10 +216,10 @@ private void InitializeComponent() // lblSize1 // this.lblSize1.AutoSize = true; - this.lblSize1.Location = new System.Drawing.Point(3, 103); - this.lblSize1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.lblSize1.Location = new System.Drawing.Point(6, 198); + this.lblSize1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblSize1.Name = "lblSize1"; - this.lblSize1.Size = new System.Drawing.Size(38, 13); + this.lblSize1.Size = new System.Drawing.Size(73, 25); this.lblSize1.TabIndex = 14; this.lblSize1.Text = "Width:"; this.lblSize1.Visible = false; @@ -222,9 +227,10 @@ private void InitializeComponent() // chkBoxartSize // this.chkBoxartSize.AutoSize = true; - this.chkBoxartSize.Location = new System.Drawing.Point(349, 102); + this.chkBoxartSize.Location = new System.Drawing.Point(698, 196); + this.chkBoxartSize.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); this.chkBoxartSize.Name = "chkBoxartSize"; - this.chkBoxartSize.Size = new System.Drawing.Size(116, 17); + this.chkBoxartSize.Size = new System.Drawing.Size(230, 29); this.chkBoxartSize.TabIndex = 9; this.chkBoxartSize.Text = "Change boxart size"; this.chkBoxartSize.UseVisualStyleBackColor = true; @@ -234,10 +240,10 @@ private void InitializeComponent() // this.btnGithub.BackgroundImage = global::TwilightBoxart.UX.Properties.Resources.GitHub_Mark_64px; this.btnGithub.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.btnGithub.Location = new System.Drawing.Point(6, 321); - this.btnGithub.Margin = new System.Windows.Forms.Padding(2); + this.btnGithub.Location = new System.Drawing.Point(12, 617); + this.btnGithub.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.btnGithub.Name = "btnGithub"; - this.btnGithub.Size = new System.Drawing.Size(29, 30); + this.btnGithub.Size = new System.Drawing.Size(58, 58); this.btnGithub.TabIndex = 11; this.toolTip.SetToolTip(this.btnGithub, "Visit the Github Repository."); this.btnGithub.UseVisualStyleBackColor = true; @@ -245,9 +251,9 @@ private void InitializeComponent() // // MainForm // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(514, 357); + this.ClientSize = new System.Drawing.Size(1028, 687); this.Controls.Add(this.btnGithub); this.Controls.Add(this.chkBoxartSize); this.Controls.Add(this.lblSize1); @@ -267,7 +273,7 @@ private void InitializeComponent() this.DoubleBuffered = true; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Margin = new System.Windows.Forms.Padding(2); + this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.MaximizeBox = false; this.Name = "MainForm"; this.Text = "TwilightBoxart"; diff --git a/TwilightBoxart.UX/MainForm.cs b/TwilightBoxart.UX/MainForm.cs index 6b758d2..dacf361 100644 --- a/TwilightBoxart.UX/MainForm.cs +++ b/TwilightBoxart.UX/MainForm.cs @@ -44,6 +44,10 @@ private void DetectSd() } } } + else + { + Log("No SD card(s) found."); + } if (!string.IsNullOrEmpty(path)) { @@ -74,6 +78,8 @@ private void SetUx() txtBoxart.Text = _config.GetBoxartPath(txtSdRoot.Text); } + txtBoxart.ReadOnly = !chkManualBoxartLocation.Checked; + numHeight.Visible = chkBoxartSize.Checked; numWidth.Visible = chkBoxartSize.Checked; lblSize1.Visible = chkBoxartSize.Checked; @@ -103,7 +109,12 @@ private void MainForm_Load(object sender, EventArgs e) Log($"Error while loading {BoxartConfig.FileName}. Using defaults."); } - if (string.IsNullOrEmpty(_config.SdRoot)) + if (!string.IsNullOrEmpty(_config.SdRoot)) + { + txtSdRoot.Text = _config.SdRoot; + txtBoxart.Text = _config.GetBoxartPath(); + } + else { DetectSd(); } @@ -162,6 +173,16 @@ private void chkBoxartSize_CheckedChanged(object sender, EventArgs e) SetUx(); } + private void txtSdRoot_TextChanged(object sender, EventArgs e) + { + SetUx(); + } + + private void txtBoxart_TextChanged(object sender, EventArgs e) + { + SetUx(); + } + private void btnGithub_Click(object sender, EventArgs e) { if (MessageBox.Show(BoxartConfig.Credits + Environment.NewLine + Environment.NewLine + "Visit Github now?", "Hello", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) diff --git a/TwilightBoxart.UX/TwilightBoxart.manifest b/TwilightBoxart.UX/TwilightBoxart.manifest index c6e1ec1..3bf792e 100644 --- a/TwilightBoxart.UX/TwilightBoxart.manifest +++ b/TwilightBoxart.UX/TwilightBoxart.manifest @@ -1,6 +1,14 @@  - + + + diff --git a/TwilightBoxart/Models/DsiRom.cs b/TwilightBoxart/Models/DsiRom.cs index e9772df..36d4754 100644 --- a/TwilightBoxart/Models/DsiRom.cs +++ b/TwilightBoxart/Models/DsiRom.cs @@ -21,7 +21,7 @@ public override void DownloadBoxArt(string targetFile) // Todo: Make this less ugly, embedded and optional. if (TitleId[0] == 'K' || TitleId[0] == 'H') // This is DSiWare. There is no BoxArt available (probably) so use a default image. { - ImgDownloader.DownloadAndResize("https://www.imgdumper.nl/uploads9/5d790c464226f/5d790c463e9f2-BAE4069C-8E5A-47EF-978A-1601C73F0C84.jpeg", targetFile); + ImgDownloader.DownloadAndResize("https://raw.githubusercontent.com/KirovAir/TwilightBoxart/master/img/dsiware.jpg", targetFile); } } } diff --git a/TwilightBoxart/Models/NdsRom.cs b/TwilightBoxart/Models/NdsRom.cs index 48ff86c..1d2fdab 100644 --- a/TwilightBoxart/Models/NdsRom.cs +++ b/TwilightBoxart/Models/NdsRom.cs @@ -42,11 +42,29 @@ public override void DownloadBoxArt(string targetFile) } } + private static readonly string[] Qualities = { "HQ", "M", "S" }; + private static readonly string[] Extensions = { "jpg", "jpg", "png" }; private void DownloadAndResize(string region, string targetFile) { - // Example: https://art.gametdb.com/ds/coverS/US/BSKE.png - var url = $"https://art.gametdb.com/ds/coverS/{region}/{TitleId}.png"; - ImgDownloader.DownloadAndResize(url, targetFile); + var lastException = new Exception("Unable to download region " + region); + for (var i = 0; i < Qualities.Length; i++) + { + var quality = Qualities[i]; + var extension = Extensions[i]; + var url = $"https://art.gametdb.com/ds/cover{quality}/{region}/{TitleId}.{extension}"; + + try + { + ImgDownloader.DownloadAndResize(url, targetFile); + return; // Success. + } + catch (Exception e) + { + lastException = e; + } + } + + throw lastException; } private string GetUrlRegion() diff --git a/TwilightBoxart/TwilightBoxart.csproj b/TwilightBoxart/TwilightBoxart.csproj index 837b365..e34fa47 100644 --- a/TwilightBoxart/TwilightBoxart.csproj +++ b/TwilightBoxart/TwilightBoxart.csproj @@ -6,6 +6,7 @@ + @@ -17,6 +18,9 @@ PreserveNewest + + Always + diff --git a/TwilightBoxart/TwilightBoxart.ini b/TwilightBoxart/TwilightBoxart.ini new file mode 100644 index 0000000..d27567b --- /dev/null +++ b/TwilightBoxart/TwilightBoxart.ini @@ -0,0 +1,6 @@ +; These are the default config values. +[Config] +SdRoot= +BoxartPath={sdroot}\_nds\TWiLightMenu\boxart +BoxartWidth=128 +BoxartHeight=115 \ No newline at end of file diff --git a/img/dsiware.jpg b/img/dsiware.jpg new file mode 100644 index 0000000..358895f Binary files /dev/null and b/img/dsiware.jpg differ diff --git a/img/screenshot.png b/img/screenshot.png new file mode 100644 index 0000000..675dd97 Binary files /dev/null and b/img/screenshot.png differ