Skip to content

Commit

Permalink
resources fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsfds committed May 24, 2024
1 parent ded706b commit 45c920e
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 24 deletions.
9 changes: 3 additions & 6 deletions src/Common/Helpers/ImageHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ public static class ImageHelper
/// </summary>
/// <param name="fileName">File name</param>
/// <param name="ass">Assembly</param>
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();

Expand Down
5 changes: 3 additions & 2 deletions src/Games/Games/BloodGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Common.Interfaces;
using Mods.Addons;
using Mods.Providers;
using System.Reflection;

namespace Games.Games
{
Expand Down Expand Up @@ -48,7 +49,7 @@ protected override Dictionary<string, IAddon> 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**.
Expand Down Expand Up @@ -86,7 +87,7 @@ protected override Dictionary<string, IAddon> 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.
Expand Down
12 changes: 6 additions & 6 deletions src/Games/Games/DukeGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected override Dictionary<string, IAddon> 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**.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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**.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion src/Games/Games/FuryGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Common.Interfaces;
using Mods.Addons;
using Mods.Providers;
using System.Reflection;

namespace Games.Games
{
Expand Down Expand Up @@ -39,7 +40,7 @@ protected override Dictionary<string, IAddon> 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**.
Expand Down
7 changes: 4 additions & 3 deletions src/Games/Games/RedneckGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Common.Interfaces;
using Mods.Addons;
using Mods.Providers;
using System.Reflection;

namespace Games.Games
{
Expand Down Expand Up @@ -56,7 +57,7 @@ protected override Dictionary<string, IAddon> 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**.
Expand Down Expand Up @@ -90,7 +91,7 @@ protected override Dictionary<string, IAddon> 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.
Expand Down Expand Up @@ -121,7 +122,7 @@ protected override Dictionary<string, IAddon> 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.
Expand Down
3 changes: 2 additions & 1 deletion src/Games/Games/SlaveGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Common.Interfaces;
using Mods.Addons;
using Mods.Providers;
using System.Reflection;

namespace Games.Games
{
Expand Down Expand Up @@ -39,7 +40,7 @@ protected override Dictionary<string, IAddon> 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**
Expand Down
7 changes: 4 additions & 3 deletions src/Games/Games/WangGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Common.Interfaces;
using Mods.Addons;
using Mods.Providers;
using System.Reflection;

namespace Games.Games
{
Expand Down Expand Up @@ -52,7 +53,7 @@ protected override Dictionary<string, IAddon> 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 = """
Expand Down Expand Up @@ -81,7 +82,7 @@ protected override Dictionary<string, IAddon> 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.
Expand Down Expand Up @@ -113,7 +114,7 @@ protected override Dictionary<string, IAddon> 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.
Expand Down
3 changes: 2 additions & 1 deletion src/Ports/Ports/BasePort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Games.Games;
using Mods.Addons;
using Mods.Serializable.Addon;
using System.Reflection;
using System.Text;

namespace Ports.Ports
Expand Down Expand Up @@ -110,7 +111,7 @@ public abstract class BasePort
/// <summary>
/// Port's icon
/// </summary>
public Stream Icon => ImageHelper.FileNameToStream($"{Name}.png");
public Stream Icon => ImageHelper.FileNameToStream($"{Name}.png", Assembly.GetExecutingAssembly());


/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion src/Tools/Tools/BaseTool.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using ClientCommon.Helpers;
using Common.Enums;
using Common.Helpers;
using System.Reflection;

namespace Tools.Tools
{
Expand Down Expand Up @@ -84,6 +85,6 @@ public virtual string? InstalledVersion
/// <summary>
/// Tool's icon
/// </summary>
public Stream Icon => ImageHelper.FileNameToStream($"{Name}.png");
public Stream Icon => ImageHelper.FileNameToStream($"{Name}.png", Assembly.GetExecutingAssembly());
}
}

0 comments on commit 45c920e

Please sign in to comment.