This commit is contained in:
tildearrow 2023-02-15 18:59:49 -05:00
parent 0585d127a6
commit 61e579a10a
4 changed files with 40 additions and 3 deletions

View File

@ -5446,7 +5446,11 @@ bool FurnaceGUI::init() {
// get the icon (on macOS and Windows the icon is bundled with the app)
const FurnaceGUIImage* furIcon=getImage(GUI_IMAGE_ICON);
SDL_Surface* icon=NULL;
if (furIcon!=NULL) SDL_CreateRGBSurfaceFrom(furIcon->data,furIcon->width,furIcon->height,32,256*4,0xff,0xff00,0xff0000,0xff000000);
if (furIcon!=NULL) {
SDL_CreateRGBSurfaceFrom(furIcon->data,furIcon->width,furIcon->height,32,256*4,0xff,0xff00,0xff0000,0xff000000);
} else {
logE("furIcon is NULL!");
}
#endif
#ifdef IS_MOBILE

View File

@ -1103,9 +1103,12 @@ struct FurnaceGUIQueryResult {
struct FurnaceGUIImage {
unsigned char* data;
SDL_Texture* tex;
int width, height, ch;
FurnaceGUIImage():
data(NULL),
tex(NULL),
width(0),
height(0),
ch(0) {}
@ -1873,7 +1876,8 @@ class FurnaceGUI {
void pushToggleColors(bool status);
void popToggleColors();
const FurnaceGUIImage* getImage(FurnaceGUIImages image);
FurnaceGUIImage* getImage(FurnaceGUIImages image);
SDL_Texture* getTexture(FurnaceGUIImages image);
void drawMobileControls();
void drawMobileOrderSel();

View File

@ -37,7 +37,29 @@ const unsigned int imageLen[GUI_IMAGE_MAX]={
image_icon_size
};
const FurnaceGUIImage* FurnaceGUI::getImage(FurnaceGUIImages image) {
SDL_Texture* FurnaceGUI::getTexture(FurnaceGUIImages image) {
FurnaceGUIImage* img=getImage(image);
if (img==NULL) return NULL;
if (img->data==NULL) return NULL;
if (img->width<=0 || img->height<=0) return NULL;
if (img->tex==NULL) {
img->tex=SDL_CreateTexture(sdlRend,SDL_PIXELFORMAT_ABGR8888,SDL_TEXTUREACCESS_STATIC,img->width,img->height);
if (img->tex==NULL) {
logE("error while creating image %d texture! %s",(int)image,SDL_GetError());
return NULL;
}
if (SDL_UpdateTexture(img->tex,NULL,img->data,img->width*4)!=0) {
logE("error while updating texture of image %d! %s",(int)image,SDL_GetError());
}
}
return img->tex;
}
FurnaceGUIImage* FurnaceGUI::getImage(FurnaceGUIImages image) {
FurnaceGUIImage* ret=NULL;
auto retPos=images.find(image);
if (retPos!=images.cend()) {

View File

@ -36,6 +36,13 @@ void FurnaceGUI::drawIntro() {
dl->AddRectFilled(top,bottom,bgColor);
dl->AddText(top,0xffffffff,"Furnace intro");
SDL_Texture* icon=getTexture(GUI_IMAGE_ICON);
if (icon!=NULL) {
dl->AddImage(icon,ImVec2(introPos*100,40),ImVec2(256+introPos*100,40+256));
} else {
}
}
ImGui::End();
}