mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 04:40:55 +00:00
@ modified constructor usage of ResourceImage class for more versatile use
This commit is contained in:
parent
ed5c468fec
commit
696b067095
4 changed files with 24 additions and 13 deletions
|
@ -147,19 +147,19 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
// Load special images
|
// Load special images
|
||||||
missingtexture3d = new ResourceImage("MissingTexture3D.png");
|
missingtexture3d = new ResourceImage("CodeImp.DoomBuilder.Resources.MissingTexture3D.png");
|
||||||
missingtexture3d.LoadImage();
|
missingtexture3d.LoadImage();
|
||||||
unknowntexture3d = new ResourceImage("UnknownTexture3D.png");
|
unknowntexture3d = new ResourceImage("CodeImp.DoomBuilder.Resources.UnknownTexture3D.png");
|
||||||
unknowntexture3d.LoadImage();
|
unknowntexture3d.LoadImage();
|
||||||
hourglass3d = new ResourceImage("Hourglass3D.png");
|
hourglass3d = new ResourceImage("CodeImp.DoomBuilder.Resources.Hourglass3D.png");
|
||||||
hourglass3d.LoadImage();
|
hourglass3d.LoadImage();
|
||||||
crosshair = new ResourceImage("Crosshair.png");
|
crosshair = new ResourceImage("CodeImp.DoomBuilder.Resources.Crosshair.png");
|
||||||
crosshair.LoadImage();
|
crosshair.LoadImage();
|
||||||
crosshairbusy = new ResourceImage("CrosshairBusy.png");
|
crosshairbusy = new ResourceImage("CodeImp.DoomBuilder.Resources.CrosshairBusy.png");
|
||||||
crosshairbusy.LoadImage();
|
crosshairbusy.LoadImage();
|
||||||
thingbox = new ResourceImage("ThingBox.png");
|
thingbox = new ResourceImage("CodeImp.DoomBuilder.Resources.ThingBox.png");
|
||||||
thingbox.LoadImage();
|
thingbox.LoadImage();
|
||||||
whitetexture = new ResourceImage("White.png");
|
whitetexture = new ResourceImage("CodeImp.DoomBuilder.Resources.White.png");
|
||||||
whitetexture.UseColorCorrection = false;
|
whitetexture.UseColorCorrection = false;
|
||||||
whitetexture.LoadImage();
|
whitetexture.LoadImage();
|
||||||
whitetexture.CreateTexture();
|
whitetexture.CreateTexture();
|
||||||
|
@ -1091,14 +1091,14 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
// Add some internal resources
|
// Add some internal resources
|
||||||
if(!internalsprites.ContainsKey("nothing"))
|
if(!internalsprites.ContainsKey("nothing"))
|
||||||
{
|
{
|
||||||
ImageData img = new ResourceImage("Nothing.png");
|
ImageData img = new ResourceImage("CodeImp.DoomBuilder.Resources.Nothing.png");
|
||||||
img.LoadImage();
|
img.LoadImage();
|
||||||
internalsprites.Add("nothing", img);
|
internalsprites.Add("nothing", img);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!internalsprites.ContainsKey("unknownthing"))
|
if(!internalsprites.ContainsKey("unknownthing"))
|
||||||
{
|
{
|
||||||
ImageData img = new ResourceImage("UnknownThing.png");
|
ImageData img = new ResourceImage("CodeImp.DoomBuilder.Resources.UnknownThing.png");
|
||||||
img.LoadImage();
|
img.LoadImage();
|
||||||
internalsprites.Add("unknownthing", img);
|
internalsprites.Add("unknownthing", img);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
|
@ -33,16 +34,26 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
{
|
{
|
||||||
public class ResourceImage : ImageData
|
public class ResourceImage : ImageData
|
||||||
{
|
{
|
||||||
|
#region ================== Variables
|
||||||
|
|
||||||
|
// Image source
|
||||||
|
private Assembly assembly;
|
||||||
|
private string resourcename;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region ================== Constructor / Disposer
|
#region ================== Constructor / Disposer
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
public ResourceImage(string resourcename)
|
public ResourceImage(string resourcename)
|
||||||
{
|
{
|
||||||
// Initialize
|
// Initialize
|
||||||
|
this.assembly = Assembly.GetCallingAssembly();
|
||||||
|
this.resourcename = resourcename;
|
||||||
SetName(resourcename);
|
SetName(resourcename);
|
||||||
|
|
||||||
// Temporarily load resource from memory
|
// Temporarily load resource from memory
|
||||||
Stream bitmapdata = General.ThisAssembly.GetManifestResourceStream("CodeImp.DoomBuilder.Resources." + Name);
|
Stream bitmapdata = assembly.GetManifestResourceStream(resourcename);
|
||||||
Bitmap bmp = (Bitmap)Image.FromStream(bitmapdata);
|
Bitmap bmp = (Bitmap)Image.FromStream(bitmapdata);
|
||||||
|
|
||||||
// Get width and height from image
|
// Get width and height from image
|
||||||
|
@ -74,7 +85,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
// because the resources this loads are in the assembly.
|
// because the resources this loads are in the assembly.
|
||||||
|
|
||||||
// Get resource from memory
|
// Get resource from memory
|
||||||
bitmapdata = General.ThisAssembly.GetManifestResourceStream("CodeImp.DoomBuilder.Resources." + Name);
|
bitmapdata = assembly.GetManifestResourceStream(resourcename);
|
||||||
if(bitmap != null) bitmap.Dispose();
|
if(bitmap != null) bitmap.Dispose();
|
||||||
bitmap = (Bitmap)Image.FromStream(bitmapdata);
|
bitmap = (Bitmap)Image.FromStream(bitmapdata);
|
||||||
bitmapdata.Dispose();
|
bitmapdata.Dispose();
|
||||||
|
|
|
@ -319,7 +319,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
// Font
|
// Font
|
||||||
postfilter = Filter.Box;
|
postfilter = Filter.Box;
|
||||||
font = new TextFont();
|
font = new TextFont();
|
||||||
fonttexture = new ResourceImage("Font.png");
|
fonttexture = new ResourceImage("CodeImp.DoomBuilder.Resources.Font.png");
|
||||||
fonttexture.LoadImage();
|
fonttexture.LoadImage();
|
||||||
fonttexture.MipMapLevels = 2;
|
fonttexture.MipMapLevels = 2;
|
||||||
fonttexture.CreateTexture();
|
fonttexture.CreateTexture();
|
||||||
|
|
|
@ -154,7 +154,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
thingtexture = new ResourceImage[NUM_THING_TEXTURES];
|
thingtexture = new ResourceImage[NUM_THING_TEXTURES];
|
||||||
for(int i = 0; i < NUM_THING_TEXTURES; i++)
|
for(int i = 0; i < NUM_THING_TEXTURES; i++)
|
||||||
{
|
{
|
||||||
thingtexture[i] = new ResourceImage("Thing2D_" + i.ToString(CultureInfo.InvariantCulture) + ".png");
|
thingtexture[i] = new ResourceImage("CodeImp.DoomBuilder.Resources.Thing2D_" + i.ToString(CultureInfo.InvariantCulture) + ".png");
|
||||||
thingtexture[i].UseColorCorrection = false;
|
thingtexture[i].UseColorCorrection = false;
|
||||||
thingtexture[i].LoadImage();
|
thingtexture[i].LoadImage();
|
||||||
thingtexture[i].CreateTexture();
|
thingtexture[i].CreateTexture();
|
||||||
|
|
Loading…
Reference in a new issue