From 45c920e686fc0bd222eac0adf80e637a5b509976 Mon Sep 17 00:00:00 2001
From: fgsfds <4870330+fgsfds@users.noreply.github.com>
Date: Fri, 24 May 2024 14:53:45 +0500
Subject: [PATCH] resources fix
---
src/Common/Helpers/ImageHelper.cs | 9 +++------
src/Games/Games/BloodGame.cs | 5 +++--
src/Games/Games/DukeGame.cs | 12 ++++++------
src/Games/Games/FuryGame.cs | 3 ++-
src/Games/Games/RedneckGame.cs | 7 ++++---
src/Games/Games/SlaveGame.cs | 3 ++-
src/Games/Games/WangGame.cs | 7 ++++---
src/Ports/Ports/BasePort.cs | 3 ++-
src/Tools/Tools/BaseTool.cs | 3 ++-
9 files changed, 28 insertions(+), 24 deletions(-)
diff --git a/src/Common/Helpers/ImageHelper.cs b/src/Common/Helpers/ImageHelper.cs
index fa2bda14..f816bffd 100644
--- a/src/Common/Helpers/ImageHelper.cs
+++ b/src/Common/Helpers/ImageHelper.cs
@@ -10,14 +10,11 @@ public static class ImageHelper
///
/// File name
/// Assembly
- public static Stream FileNameToStream(string fileName, Assembly? ass = null)
+ public static Stream FileNameToStream(string fileName, Assembly callingAss)
{
- if (ass is null)
- {
- ass = Assembly.GetCallingAssembly();
- }
+ var assName = callingAss.GetName().Name!.Replace("BuildLauncher.", "");
- var resource = ass.GetManifestResourceStream($"{ass.GetName().Name!.Split('.')[1]}.Assets.{fileName}");
+ var resource = callingAss.GetManifestResourceStream($"{assName}.Assets.{fileName}");
resource.ThrowIfNull();
diff --git a/src/Games/Games/BloodGame.cs b/src/Games/Games/BloodGame.cs
index e0ffcdc1..cf54afca 100644
--- a/src/Games/Games/BloodGame.cs
+++ b/src/Games/Games/BloodGame.cs
@@ -5,6 +5,7 @@
using Common.Interfaces;
using Mods.Addons;
using Mods.Providers;
+using System.Reflection;
namespace Games.Games
{
@@ -48,7 +49,7 @@ protected override Dictionary GetOriginalCampaigns()
Id = bloodId,
Type = AddonTypeEnum.Official,
Title = "Blood",
- GridImage = ImageHelper.FileNameToStream("Blood.blood.png"),
+ GridImage = ImageHelper.FileNameToStream("Blood.blood.png", Assembly.GetExecutingAssembly()),
Author = "Monolith Productions",
Description = """
**Blood** is a PC game released for MS-DOS on May 31, 1997. It was developed by **Monolith Productions** and published by **GT Interactive**.
@@ -86,7 +87,7 @@ protected override Dictionary GetOriginalCampaigns()
Id = bloodCpId,
Type = AddonTypeEnum.Official,
Title = "Cryptic Passage",
- GridImage = ImageHelper.FileNameToStream("Blood.cp.jpg"),
+ GridImage = ImageHelper.FileNameToStream("Blood.cp.jpg", Assembly.GetExecutingAssembly()),
Author = "Sunstorm Interactive",
Description = """
**Cryptic Passage** (originally titled Passage to Transylvania) is the first of two expansion packs for Blood.
diff --git a/src/Games/Games/DukeGame.cs b/src/Games/Games/DukeGame.cs
index 90f2ab85..ddf15e65 100644
--- a/src/Games/Games/DukeGame.cs
+++ b/src/Games/Games/DukeGame.cs
@@ -87,7 +87,7 @@ protected override Dictionary GetOriginalCampaigns()
Id = dukeId,
Type = AddonTypeEnum.Official,
Title = "Duke Nukem 3D",
- GridImage = ImageHelper.FileNameToStream("Duke3D.duke3d.jpg"),
+ GridImage = ImageHelper.FileNameToStream("Duke3D.duke3d.jpg", Assembly.GetExecutingAssembly()),
Author = "3D Realms",
Description = """
Duke Nukem 3D is a first-person shooter developed and published by **3D Realms**.
@@ -120,7 +120,7 @@ Duke Nukem 3D is a first-person shooter developed and published by **3D Realms**
Id = dukeWtId,
Type = AddonTypeEnum.Official,
Title = "Duke Nukem 3D World Tour",
- GridImage = ImageHelper.FileNameToStream("Duke3D.dukewt.jpg"),
+ GridImage = ImageHelper.FileNameToStream("Duke3D.dukewt.jpg", Assembly.GetExecutingAssembly()),
Author = "Nerve Software, Gearbox Software",
Description = """
**Duke Nukem 3D: 20th Anniversary World Tour** is a 2016 special edition of Duke Nukem 3D.
@@ -155,7 +155,7 @@ Duke Nukem 3D is a first-person shooter developed and published by **3D Realms**
Id = dukeVacaId,
Type = AddonTypeEnum.Official,
Title = "Caribbean",
- GridImage = ImageHelper.FileNameToStream("Duke3D.carib.jpg"),
+ GridImage = ImageHelper.FileNameToStream("Duke3D.carib.jpg", Assembly.GetExecutingAssembly()),
Author = "Sunstorm Interactive",
Description = """
**Life's A Beach** is an expansion pack for the highly acclaimed first-person shooter Duke Nukem 3D. It was released on December 31, 1997 by **Sunstorm Interactive**.
@@ -188,7 +188,7 @@ Duke Nukem 3D is a first-person shooter developed and published by **3D Realms**
Id = dukeNwId,
Type = AddonTypeEnum.Official,
Title = "Nuclear Winter",
- GridImage = ImageHelper.FileNameToStream("Duke3D.nwinter.jpg"),
+ GridImage = ImageHelper.FileNameToStream("Duke3D.nwinter.jpg", Assembly.GetExecutingAssembly()),
Author = "Simply Silly Software",
Description = """
**Nuclear Winter**, is a Christmas-themed expansion pack for Duke Nukem 3D. It was developed by **Simply Silly Software** and published by **WizardWorks** on December 30, 1997.
@@ -220,7 +220,7 @@ Duke Nukem must travel to the North Pole in order to stop the brainwashed Santa
Id = dukeDcId,
Type = AddonTypeEnum.Official,
Title = "Duke it Out in DC",
- GridImage = ImageHelper.FileNameToStream("Duke3D.dukedc.jpg"),
+ GridImage = ImageHelper.FileNameToStream("Duke3D.dukedc.jpg", Assembly.GetExecutingAssembly()),
Author = "WizardWorks",
Description = """
**Duke It Out In D.C.** is a Duke Nukem 3D expansion pack developed by Sunstorm Interactive and published by **WizardWorks** on March 17, 1997.
@@ -255,7 +255,7 @@ Duke Nukem must travel to the North Pole in order to stop the brainwashed Santa
Id = duke64Id,
Type = AddonTypeEnum.Official,
Title = "Duke Nukem 64",
- GridImage = ImageHelper.FileNameToStream("Duke3D.duke64.jpg"),
+ GridImage = ImageHelper.FileNameToStream("Duke3D.duke64.jpg", Assembly.GetExecutingAssembly()),
Author = "3D Realms, Eurocom",
Description = """
**Duke Nukem 64** is the Nintendo 64 port of the first-person shooter MS-DOS/PC game Duke Nukem 3D.
diff --git a/src/Games/Games/FuryGame.cs b/src/Games/Games/FuryGame.cs
index 85cbdd52..4898607f 100644
--- a/src/Games/Games/FuryGame.cs
+++ b/src/Games/Games/FuryGame.cs
@@ -4,6 +4,7 @@
using Common.Interfaces;
using Mods.Addons;
using Mods.Providers;
+using System.Reflection;
namespace Games.Games
{
@@ -39,7 +40,7 @@ protected override Dictionary GetOriginalCampaigns()
Id = furyId,
Type = AddonTypeEnum.Official,
Title = IsAftershock() ? "Ion Fury: Aftershock" : "Ion Fury",
- GridImage = IsAftershock() ? ImageHelper.FileNameToStream("Fury.aftershock.jpg") : ImageHelper.FileNameToStream("Fury.fury.jpg"),
+ GridImage = IsAftershock() ? ImageHelper.FileNameToStream("Fury.aftershock.jpg", Assembly.GetExecutingAssembly()) : ImageHelper.FileNameToStream("Fury.fury.jpg", Assembly.GetExecutingAssembly()),
Author = "Voidpoint, LLC",
Description = """
**Ion Fury** (originally titled Ion Maiden) is a 2019 cyberpunk first-person shooter developed by **Voidpoint** and published by **3D Realms**.
diff --git a/src/Games/Games/RedneckGame.cs b/src/Games/Games/RedneckGame.cs
index 46371df4..73222696 100644
--- a/src/Games/Games/RedneckGame.cs
+++ b/src/Games/Games/RedneckGame.cs
@@ -6,6 +6,7 @@
using Common.Interfaces;
using Mods.Addons;
using Mods.Providers;
+using System.Reflection;
namespace Games.Games
{
@@ -56,7 +57,7 @@ protected override Dictionary GetOriginalCampaigns()
Id = redneckId,
Type = AddonTypeEnum.Official,
Title = "Redneck Rampage",
- GridImage = ImageHelper.FileNameToStream("Redneck.redneck.jpg"),
+ GridImage = ImageHelper.FileNameToStream("Redneck.redneck.jpg", Assembly.GetExecutingAssembly()),
Author = "Xatrix Entertainment",
Description = """
**Redneck Rampage** is a 1997 first-person shooter game developed by **Xatrix Entertainment** and published by **Interplay**.
@@ -90,7 +91,7 @@ protected override Dictionary GetOriginalCampaigns()
Id = redneckR66Id,
Type = AddonTypeEnum.Official,
Title = "Route 66",
- GridImage = ImageHelper.FileNameToStream("Redneck.route66.jpg"),
+ GridImage = ImageHelper.FileNameToStream("Redneck.route66.jpg", Assembly.GetExecutingAssembly()),
Author = "Sunstorm Interactive",
Description = """
**Redneck Rampage: Suckin' Grits on Route 66** is a 12-level expansion pack for Redneck Rampage. It was developed by Sunstorm Interactive and released on December 19, 1997.
@@ -121,7 +122,7 @@ protected override Dictionary GetOriginalCampaigns()
Id = redneckRaId,
Type = AddonTypeEnum.Official,
Title = "Rides Again",
- GridImage = ImageHelper.FileNameToStream("Redneck.again.jpg"),
+ GridImage = ImageHelper.FileNameToStream("Redneck.again.jpg", Assembly.GetExecutingAssembly()),
Author = "Xatrix Entertainment",
Description = """
**Redneck Rampage Rides Again** is a sequel to Redneck Rampage developed by **Xatrix Entertainment** and published by **Interplay Entertainment** for MS-DOS in 1998.
diff --git a/src/Games/Games/SlaveGame.cs b/src/Games/Games/SlaveGame.cs
index 4d538ec9..8925e0a7 100644
--- a/src/Games/Games/SlaveGame.cs
+++ b/src/Games/Games/SlaveGame.cs
@@ -4,6 +4,7 @@
using Common.Interfaces;
using Mods.Addons;
using Mods.Providers;
+using System.Reflection;
namespace Games.Games
{
@@ -39,7 +40,7 @@ protected override Dictionary GetOriginalCampaigns()
Id = slaveId,
Type = AddonTypeEnum.Official,
Title = "Powerslave",
- GridImage = ImageHelper.FileNameToStream("Slave.slave.jpg"),
+ GridImage = ImageHelper.FileNameToStream("Slave.slave.jpg", Assembly.GetExecutingAssembly()),
Author = "Lobotomy Software",
Description = """
**PowerSlave**, known as **Exhumed** in Europe and **1999 AD: Resurrection of the Pharaoh** in Japan, is a first-person shooter video game developed by **Lobotomy Software**
diff --git a/src/Games/Games/WangGame.cs b/src/Games/Games/WangGame.cs
index 64dbf80d..42e321ae 100644
--- a/src/Games/Games/WangGame.cs
+++ b/src/Games/Games/WangGame.cs
@@ -5,6 +5,7 @@
using Common.Interfaces;
using Mods.Addons;
using Mods.Providers;
+using System.Reflection;
namespace Games.Games
{
@@ -52,7 +53,7 @@ protected override Dictionary GetOriginalCampaigns()
Id = wangId,
Type = AddonTypeEnum.Official,
Title = "Shadow Warrior",
- GridImage = ImageHelper.FileNameToStream("Wang.wang.jpg"),
+ GridImage = ImageHelper.FileNameToStream("Wang.wang.jpg", Assembly.GetExecutingAssembly()),
Version = null,
Author = "3D Realms",
Description = """
@@ -81,7 +82,7 @@ protected override Dictionary GetOriginalCampaigns()
Id = wangWdId,
Type = AddonTypeEnum.Official,
Title = "Wanton Destruction",
- GridImage = ImageHelper.FileNameToStream("Wang.wanton.jpg"),
+ GridImage = ImageHelper.FileNameToStream("Wang.wanton.jpg", Assembly.GetExecutingAssembly()),
Author = "Sunstorm Interactive",
Description = """
**Wanton Destruction** is an official expansion that was created by **Sunstorm Interactive** and tested by **3D Realms**, but was not released by the distributor.
@@ -113,7 +114,7 @@ protected override Dictionary GetOriginalCampaigns()
Id = wangTdId,
Type = AddonTypeEnum.Official,
Title = "Twin Dragon",
- GridImage = ImageHelper.FileNameToStream("Wang.twin.jpg"),
+ GridImage = ImageHelper.FileNameToStream("Wang.twin.jpg", Assembly.GetExecutingAssembly()),
Author = "Wylde Productions, Level Infinity",
Description = """
**Twin Dragon** is an official expansion to the Shadow Warrior that was released as a free download on July 4, 1998.
diff --git a/src/Ports/Ports/BasePort.cs b/src/Ports/Ports/BasePort.cs
index db273328..ba54bec0 100644
--- a/src/Ports/Ports/BasePort.cs
+++ b/src/Ports/Ports/BasePort.cs
@@ -6,6 +6,7 @@
using Games.Games;
using Mods.Addons;
using Mods.Serializable.Addon;
+using System.Reflection;
using System.Text;
namespace Ports.Ports
@@ -110,7 +111,7 @@ public abstract class BasePort
///
/// Port's icon
///
- public Stream Icon => ImageHelper.FileNameToStream($"{Name}.png");
+ public Stream Icon => ImageHelper.FileNameToStream($"{Name}.png", Assembly.GetExecutingAssembly());
///
diff --git a/src/Tools/Tools/BaseTool.cs b/src/Tools/Tools/BaseTool.cs
index 40918026..39fea73a 100644
--- a/src/Tools/Tools/BaseTool.cs
+++ b/src/Tools/Tools/BaseTool.cs
@@ -1,6 +1,7 @@
using ClientCommon.Helpers;
using Common.Enums;
using Common.Helpers;
+using System.Reflection;
namespace Tools.Tools
{
@@ -84,6 +85,6 @@ public virtual string? InstalledVersion
///
/// Tool's icon
///
- public Stream Icon => ImageHelper.FileNameToStream($"{Name}.png");
+ public Stream Icon => ImageHelper.FileNameToStream($"{Name}.png", Assembly.GetExecutingAssembly());
}
}