Added HD image support for sidebar unit/building icons. Icons but 32bit and 8bit for sidebar unit/building icons are now loaded at startup rather then when requested.

This commit is contained in:
Justin Marshall
2020-08-03 11:35:01 -07:00
parent 65ebb17489
commit 2d6681465f
12 changed files with 62 additions and 91 deletions
BIN
View File
Binary file not shown.
+3 -8
View File
@@ -419,8 +419,7 @@ void AircraftTypeClass::One_Time(void)
*/
char buffer[_MAX_FNAME];
sprintf(buffer, "%sICON", uclass.Graphic_Name());
_makepath(fullname, NULL, NULL, buffer, ".SHP");
((void const *&)uclass.CameoData) = MFCD::Retrieve(fullname);
((Image_t*&)uclass.CameoData) = LoadCameoImage(buffer);
/*
** Generic shape for all houses load method.
@@ -545,12 +544,8 @@ void AircraftTypeClass::Prep_For_Add(void)
void AircraftTypeClass::Display(int x, int y, WindowNumberType window, HousesType ) const
{
int shape = 0;
void const * ptr = Get_Cameo_Data();
if (ptr == NULL) {
ptr = Get_Image_Data();
shape = 5;
}
CC_Draw_Shape(ptr, shape, x, y, window, SHAPE_CENTER|SHAPE_WIN_REL);
Image_t *ptr = Get_Cameo_Data();
CC_DrawHD_Shape(ptr, shape, x, y, window, SHAPE_CENTER|SHAPE_WIN_REL);
}
#endif
+2 -9
View File
@@ -3288,15 +3288,13 @@ void BuildingTypeClass::One_Time(void)
** Fetch the sidebar cameo image for this building.
*/
if (building.Level != -1) {
// if (building.IsBuildable) {
sprintf(buffer, "%sICON", building.Graphic_Name());
if (building.IsFake) {
buffer[3] = 'F';
}
_makepath(fullname, NULL, NULL, buffer, ".SHP");
((void const *&)building.CameoData) = MFCD::Retrieve(fullname);
((Image_t*&)building.CameoData) = LoadCameoImage(buffer);
}
/*
@@ -3448,12 +3446,7 @@ void BuildingTypeClass::Display(int x, int y, WindowNumberType window, HousesTyp
GL_RenderImage(hdimage, x, y, hdimage->renderwidth[0], hdimage->renderheight[0]);
}
else {
void const* ptr = Get_Cameo_Data();
if (ptr == NULL) {
IsTheaterShape = IsTheater;
ptr = Get_Image_Data();
}
CC_Draw_Shape(ptr, 0, x, y, window, SHAPE_CENTER | SHAPE_WIN_REL);
CC_DrawHD_Shape(Get_Cameo_Data(), 0, x, y, window, SHAPE_CENTER | SHAPE_WIN_REL);
IsTheaterShape = false;
}
// jmarshall end
+3 -19
View File
@@ -1317,13 +1317,8 @@ void InfantryTypeClass::Display(int x, int y, WindowNumberType window, HousesTyp
if (house != HOUSE_NONE) {
int shape = 0;
void const * ptr = Get_Cameo_Data();
if (ptr == NULL) {
ptr = Get_Image_Data();
shape = 2;
}
CC_Draw_Shape(ptr, shape, x, y, window, SHAPE_NORMAL|SHAPE_CENTER|SHAPE_WIN_REL);
struct Image_t *ptr = Get_Cameo_Data();
CC_DrawHD_Shape(ptr, shape, x, y, window, SHAPE_NORMAL|SHAPE_CENTER|SHAPE_WIN_REL);
}
}
@@ -1468,18 +1463,7 @@ void InfantryTypeClass::One_Time(void)
*/
char buffer[_MAX_FNAME];
sprintf(buffer, "%.4sICON", uclass->Graphic_Name());
_makepath(fullname, NULL, NULL, buffer, ".SHP");
#ifndef NDEBUG
RawFileClass ifile(fullname);
if (ifile.Is_Available()) {
((void const *&)uclass->CameoData) = Load_Alloc_Data(ifile);
} else {
((void const *&)uclass->CameoData) = MFCD::Retrieve(fullname);
}
#else
((void const *&)uclass->CameoData) = MFCD::Retrieve(fullname);
#endif
((Image_t*&)uclass->CameoData) = LoadCameoImage(buffer);
}
}
+24 -1
View File
@@ -98,6 +98,7 @@
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "function.h"
#include "image.h"
/*
** Selected objects have a special marking box around them. This is the shapes that are
@@ -2201,6 +2202,28 @@ ObjectTypeClass::ObjectTypeClass(
DimensionData = NULL;
}
Image_t* ObjectTypeClass::LoadCameoImage(const char* fileName) {
char fullnamehd[2048];
// Try and load a HD cameo image.
sprintf(fullnamehd, "ui/sidebar/icons/%s.png", fileName);
Image_t* hdImage = Image_LoadImage(fullnamehd);
if (hdImage) {
return hdImage;
}
// If there is no HD image, then load the old 8bit image.
char fullname[_MAX_FNAME + _MAX_EXT];
_makepath(fullname, NULL, NULL, fileName, ".SHP");
const void* shapefile = MFCD::Retrieve(fullname);
int width = Get_Build_Frame_Width(shapefile, -1);
int height = Get_Build_Frame_Height(shapefile, -1);
const char* buffer = (const char* )Build_Frame(shapefile, 0, _ShapeBuffer);
Image_t* image = Image_CreateImageFrom8Bit(fullname, width, height, (unsigned char *)buffer);
return image;
}
/***********************************************************************************************
* ObjectTypeClass::Max_Pips -- Fetches the maximum pips allowed for this object. *
@@ -2307,7 +2330,7 @@ int ObjectTypeClass::Time_To_Build(HousesType ) const
* HISTORY: *
* 07/19/1995 JLB : Created. *
*=============================================================================================*/
void const * ObjectTypeClass::Get_Cameo_Data(void) const
struct Image_t* ObjectTypeClass::Get_Cameo_Data(void) const
{
return(NULL);
}
+17 -21
View File
@@ -125,11 +125,10 @@ SidebarClass::StripClass::SelectButton[COLUMNS][MAX_VISIBLE];
/*
** Shape data pointers
*/
void* SidebarClass::StripClass::LogoShapes = NULL;
void* SidebarClass::StripClass::LogoShapesHD = NULL;
struct Image_t*SidebarClass::StripClass::LogoShapes = NULL;
void const* SidebarClass::StripClass::ClockShapes;
void const* SidebarClass::StripClass::SpecialShapes[SPC_COUNT];
struct Image_t *SidebarClass::StripClass::SpecialShapes[SPC_COUNT];
/***********************************************************************************************
@@ -1174,10 +1173,7 @@ void SidebarClass::StripClass::One_Time(int)
for (SpecialWeaponType lp = SPC_FIRST; lp < SPC_COUNT; lp++) {
char buffer[_MAX_FNAME];
sprintf(buffer, "%sICON", SpecialWeaponFile[lp]);
char fullname[_MAX_FNAME + _MAX_EXT];
_makepath(fullname, NULL, NULL, buffer, ".SHP");
SpecialShapes[lp] = MFCD::Retrieve(fullname);
SpecialShapes[lp] = ObjectTypeClass::LoadCameoImage(buffer);
}
}
@@ -1197,7 +1193,7 @@ void SidebarClass::StripClass::One_Time(int)
* HISTORY: *
* 05/19/1995 JLB : commented *
*=============================================================================================*/
void const* SidebarClass::StripClass::Get_Special_Cameo(SpecialWeaponType type)
struct Image_t* SidebarClass::StripClass::Get_Special_Cameo(SpecialWeaponType type)
{
if ((unsigned)type < SPC_COUNT) {
return(SpecialShapes[type]);
@@ -1335,16 +1331,16 @@ void SidebarClass::StripClass::Reload_LogoShapes(void)
** Load hi-res strip art here since it is player side specific
*/
static char* stripnames[] = {
"stripna.shp", //Nato
"stripna.shp",
"stripus.shp", //USSR
"stripna.shp",
"stripus.shp", //UKRAINE
"stripna.shp",
"stripna.shp",
"stripna.shp",
"stripna.shp", //HOUSE_GOOD
"stripus.shp", //HOUSE_BAD
"stripna", //Nato
"stripna",
"stripus", //USSR
"stripna",
"stripus", //UKRAINE
"stripna",
"stripna",
"stripna",
"stripna", //HOUSE_GOOD
"stripus", //HOUSE_BAD
};
int houseloaded = 0;
@@ -1361,7 +1357,7 @@ void SidebarClass::StripClass::Reload_LogoShapes(void)
return;
// jmarshall end
LogoShapes = (void*)MFCD::Retrieve(stripnames[houseloaded]);
LogoShapes = ObjectTypeClass::LoadCameoImage(stripnames[houseloaded]);
}
/***********************************************************************************************
@@ -1748,7 +1744,7 @@ void SidebarClass::StripClass::Draw_It(bool complete)
bool completed;
int stage;
bool darken = false;
void const* shapefile = 0;
struct Image_t *shapefile = 0;
int shapenum = 0;
void const* remapper = 0;
FactoryClass* factory = 0;
@@ -1867,7 +1863,7 @@ void SidebarClass::StripClass::Draw_It(bool complete)
** Don't draw blank shapes over the new 640x400 sidebar art - ST 5/1/96 6:01PM
*/
if (shapenum != SB_BLANK || shapefile != LogoShapes) {
CC_Draw_Shape(shapefile, shapenum,
CC_DrawHD_Shape(shapefile, shapenum,
x - (WindowList[WINDOW_SIDEBAR][WINDOWX]) + (LEFT_EDGE_OFFSET * RESFACTOR),
y - WindowList[WINDOW_SIDEBAR][WINDOWY],
WINDOW_SIDEBAR,
+3 -4
View File
@@ -182,7 +182,7 @@ class SidebarClass: public PowerClass
void Deactivate(void);
void Flag_To_Redraw(void);
bool Factory_Link(int factory, RTTIType type, int id);
void const * Get_Special_Cameo(SpecialWeaponType type);
struct Image_t *Get_Special_Cameo(SpecialWeaponType type);
/*
** File I/O.
@@ -324,8 +324,7 @@ class SidebarClass: public PowerClass
** Pointer to the shape data for small versions of the logos. These are used as
** placeholder pieces on the side bar.
*/
static void * LogoShapes;
static void * LogoShapesHD;
static struct Image_t* LogoShapes;
/*
** This points to the animation sequence of frames used to mark the passage of time
@@ -337,7 +336,7 @@ class SidebarClass: public PowerClass
** This points to the animation sequence which deals with special
** shapes which handle non-production based icons.
*/
static void const * SpecialShapes[SPC_COUNT];
static struct Image_t * SpecialShapes[SPC_COUNT];
/*
** This is the last theater that the special palette remap table was loaded
+1 -1
View File
@@ -6541,7 +6541,7 @@ int TechnoTypeClass::Cost_Of(void) const
* HISTORY: *
* 07/29/1995 JLB : Created. *
*=============================================================================================*/
void const * TechnoTypeClass::Get_Cameo_Data(void) const
struct Image_t*TechnoTypeClass::Get_Cameo_Data(void) const
{
return(CameoData);
}
+5 -3
View File
@@ -299,7 +299,7 @@ class ObjectTypeClass : public AbstractTypeClass
virtual short const * Occupy_List(bool placement=false) const;
virtual short const * Overlap_List(void) const;
virtual BuildingClass * Who_Can_Build_Me(bool intheory, bool legal, HousesType house) const;
virtual void const * Get_Cameo_Data(void) const;
virtual struct Image_t* Get_Cameo_Data(void) const;
// jmarshall
struct Image_t* Get_HDImage_Data(void) const { return HDImageData; }
// jmarshall end
@@ -312,6 +312,8 @@ class ObjectTypeClass : public AbstractTypeClass
static void const * SelectShapes;
static void const * PipShapes;
public: // Has to be public for superweapon icons.
static struct Image_t* LoadCameoImage(const char* fileName);
};
@@ -500,7 +502,7 @@ class TechnoTypeClass : public ObjectTypeClass
** This is the small icon image that is used to display the object in
** the sidebar for construction selection purposes.
*/
void const * CameoData;
struct Image_t *CameoData;
/*
** The number of animation frames allotted to rotation is specified here.
@@ -575,7 +577,7 @@ class TechnoTypeClass : public ObjectTypeClass
virtual int Max_Passengers(void) const {return(MaxPassengers);}
virtual int Repair_Cost(void) const;
virtual int Repair_Step(void) const;
virtual void const * Get_Cameo_Data(void) const;
virtual struct Image_t *Get_Cameo_Data(void) const;
virtual int Cost_Of(void) const;
virtual int Time_To_Build(HousesType house) const;
virtual int Get_Ownable(void) const;
+2 -17
View File
@@ -1015,12 +1015,7 @@ UnitType UnitTypeClass::From_Name(char const * name)
void UnitTypeClass::Display(int x, int y, WindowNumberType window, HousesType ) const
{
int shape = 0;
void const * ptr = Get_Cameo_Data();
if (ptr == NULL) {
ptr = Get_Image_Data();
shape = Rotation/6;
}
CC_Draw_Shape(ptr, shape, x, y, window, SHAPE_CENTER|SHAPE_WIN_REL);
CC_DrawHD_Shape(Get_Cameo_Data(), shape, x, y, window, SHAPE_CENTER|SHAPE_WIN_REL);
}
@@ -1084,17 +1079,7 @@ void UnitTypeClass::One_Time(void)
** Fetch the supporting data files for the unit.
*/
sprintf(buffer, "%sICON", uclass.Graphic_Name());
_makepath(fullname, NULL, NULL, buffer, ".SHP");
#ifndef NDEBUG
RawFileClass datafile(fullname);
if (datafile.Is_Available()) {
((void const *&)uclass.CameoData) = Load_Alloc_Data(datafile);
} else {
((void const *&)uclass.CameoData) = MFCD::Retrieve(fullname);
}
#else
((void const *&)uclass.CameoData) = MFCD::Retrieve(fullname);
#endif
((Image_t*&)uclass.CameoData) = LoadCameoImage(buffer);
// }
/*
+2 -8
View File
@@ -426,12 +426,7 @@ BuildingClass * VesselTypeClass::Who_Can_Build_Me(bool intheory, bool legal, Hou
void VesselTypeClass::Display(int x, int y, WindowNumberType window, HousesType ) const
{
int shape = 0;
void const * ptr = Get_Cameo_Data();
if (ptr == NULL) {
ptr = Get_Image_Data();
shape = Rotation/6;
}
CC_Draw_Shape(ptr, shape, x, y, window, SHAPE_CENTER|SHAPE_WIN_REL);
CC_DrawHD_Shape(Get_Cameo_Data(), shape, x, y, window, SHAPE_CENTER|SHAPE_WIN_REL);
}
@@ -569,8 +564,7 @@ void VesselTypeClass::One_Time(void)
** Fetch the supporting data files for the unit.
*/
sprintf(buffer, "%sICON", uclass.Graphic_Name());
_makepath(fullname, NULL, NULL, buffer, ".SHP");
((void const *&)uclass.CameoData) = MFCD::Retrieve(fullname);
((Image_t*&)uclass.CameoData) = LoadCameoImage(buffer);
}
/*
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB