mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-27 15:03:01 +00:00
but why
This commit is contained in:
parent
0585d127a6
commit
61e579a10a
4 changed files with 40 additions and 3 deletions
|
@ -5446,7 +5446,11 @@ bool FurnaceGUI::init() {
|
||||||
// get the icon (on macOS and Windows the icon is bundled with the app)
|
// get the icon (on macOS and Windows the icon is bundled with the app)
|
||||||
const FurnaceGUIImage* furIcon=getImage(GUI_IMAGE_ICON);
|
const FurnaceGUIImage* furIcon=getImage(GUI_IMAGE_ICON);
|
||||||
SDL_Surface* icon=NULL;
|
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
|
#endif
|
||||||
|
|
||||||
#ifdef IS_MOBILE
|
#ifdef IS_MOBILE
|
||||||
|
|
|
@ -1103,9 +1103,12 @@ struct FurnaceGUIQueryResult {
|
||||||
|
|
||||||
struct FurnaceGUIImage {
|
struct FurnaceGUIImage {
|
||||||
unsigned char* data;
|
unsigned char* data;
|
||||||
|
SDL_Texture* tex;
|
||||||
int width, height, ch;
|
int width, height, ch;
|
||||||
|
|
||||||
FurnaceGUIImage():
|
FurnaceGUIImage():
|
||||||
data(NULL),
|
data(NULL),
|
||||||
|
tex(NULL),
|
||||||
width(0),
|
width(0),
|
||||||
height(0),
|
height(0),
|
||||||
ch(0) {}
|
ch(0) {}
|
||||||
|
@ -1873,7 +1876,8 @@ class FurnaceGUI {
|
||||||
void pushToggleColors(bool status);
|
void pushToggleColors(bool status);
|
||||||
void popToggleColors();
|
void popToggleColors();
|
||||||
|
|
||||||
const FurnaceGUIImage* getImage(FurnaceGUIImages image);
|
FurnaceGUIImage* getImage(FurnaceGUIImages image);
|
||||||
|
SDL_Texture* getTexture(FurnaceGUIImages image);
|
||||||
|
|
||||||
void drawMobileControls();
|
void drawMobileControls();
|
||||||
void drawMobileOrderSel();
|
void drawMobileOrderSel();
|
||||||
|
|
|
@ -37,7 +37,29 @@ const unsigned int imageLen[GUI_IMAGE_MAX]={
|
||||||
image_icon_size
|
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;
|
FurnaceGUIImage* ret=NULL;
|
||||||
auto retPos=images.find(image);
|
auto retPos=images.find(image);
|
||||||
if (retPos!=images.cend()) {
|
if (retPos!=images.cend()) {
|
||||||
|
|
|
@ -36,6 +36,13 @@ void FurnaceGUI::drawIntro() {
|
||||||
|
|
||||||
dl->AddRectFilled(top,bottom,bgColor);
|
dl->AddRectFilled(top,bottom,bgColor);
|
||||||
dl->AddText(top,0xffffffff,"Furnace intro");
|
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();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue