mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-22 03:09:15 +01:00
Added Menu_DrawTPL and Menu_DrawTPLMem
and Banner Class (WIP)
This commit is contained in:
parent
d8bad4932f
commit
3906d0fe32
71
source/libwiigui/gui_banner.cpp
Normal file
71
source/libwiigui/gui_banner.cpp
Normal file
@ -0,0 +1,71 @@
|
||||
#include "gui_banner.h"
|
||||
|
||||
GuiBanner::GuiBanner()
|
||||
{
|
||||
deg_beta=0.0;
|
||||
}
|
||||
|
||||
GuiBanner::~GuiBanner()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
GuiBanner::GuiBanner(const char *tplfilepath)
|
||||
{
|
||||
FILE *tplfp = fopen(tplfilepath,"rb");
|
||||
|
||||
if(tplfp !=NULL)
|
||||
{
|
||||
unsigned short heighttemp = 0;
|
||||
unsigned short widthtemp = 0;
|
||||
|
||||
fseek(tplfp , 0x14, SEEK_SET);
|
||||
fread((void*)&heighttemp,1,2,tplfp);
|
||||
fread((void*)&widthtemp,1,2,tplfp);
|
||||
fclose(tplfp);
|
||||
|
||||
filepath = tplfilepath;
|
||||
width = widthtemp;
|
||||
height = heighttemp;
|
||||
widescreen = 0;
|
||||
filecheck = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
filecheck = false;
|
||||
fclose(tplfp);
|
||||
}
|
||||
}
|
||||
|
||||
GuiBanner::GuiBanner(void *mem,u32 len,u16 w, u16 h)
|
||||
{
|
||||
if(memory !=NULL)
|
||||
{
|
||||
memory = mem;
|
||||
width = w;
|
||||
height = h;
|
||||
widescreen = 0;
|
||||
filecheck = true;
|
||||
free(mem);
|
||||
}
|
||||
else
|
||||
{
|
||||
filecheck = false;
|
||||
free(mem);
|
||||
}
|
||||
|
||||
}
|
||||
//void Menu_DrawTPL(f32 xpos, f32 ypos, f32 zpos, u16 width, u16 height, u16 distance,const char *filepath,f32 deg_alpha, f32 deg_beta, f32 scaleX, f32 scaleY, u8 alpha, bool shadow);
|
||||
//void Menu_DrawTPLMem(f32 xpos, f32 ypos, f32 zpos, u16 width, u16 height, u16 distance,const void *memory,u32 len, f32 deg_alpha, f32 deg_beta, f32 scaleX, f32 scaleY, u8 alpha, bool shadow);
|
||||
|
||||
void GuiBanner::Draw()
|
||||
{
|
||||
LOCK(this);
|
||||
if(!filecheck ||!this->IsVisible())
|
||||
return;
|
||||
float currScale = this->GetScale();
|
||||
//Menu_DrawTPL(50,70, 20, width, height, 50, filepath, 1, deg_beta, widescreen ? currScale*0.8 : currScale, currScale, 64, true);
|
||||
Menu_DrawTPL(xoffset,yoffset, 50, width, height, 50, filepath, 0, deg_beta, widescreen ? currScale*0.8 : currScale, currScale, 64, true);
|
||||
|
||||
this->UpdateEffects();
|
||||
}
|
22
source/libwiigui/gui_banner.h
Normal file
22
source/libwiigui/gui_banner.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef _GUIBANNER_H_
|
||||
#define _GUIBANNER_H_
|
||||
|
||||
#include "gui.h"
|
||||
|
||||
class GuiBanner : public GuiImage
|
||||
{
|
||||
public:
|
||||
GuiBanner();
|
||||
GuiBanner(const char *tplfilepath);
|
||||
GuiBanner(void *mem,u32 len,u16 w, u16 h);
|
||||
~GuiBanner();
|
||||
|
||||
void Draw();
|
||||
private:
|
||||
f32 deg_beta;
|
||||
const char *filepath;
|
||||
const void *memory;
|
||||
bool filecheck;
|
||||
};
|
||||
|
||||
#endif /* _GUIDISCCOVER_H_ */
|
186
source/video.cpp
186
source/video.cpp
@ -426,3 +426,189 @@ void Menu_DrawDiskCover(f32 xpos, f32 ypos, f32 zpos, u16 width, u16 height, u16
|
||||
GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
|
||||
GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);
|
||||
}
|
||||
|
||||
void Menu_DrawTPL(f32 xpos, f32 ypos, f32 zpos, u16 width, u16 height, u16 distance,const char *filepath,
|
||||
f32 deg_alpha, f32 deg_beta, f32 scaleX, f32 scaleY, u8 alpha, bool shadow)
|
||||
{
|
||||
TPLFile tplfile;
|
||||
GXTexObj texObj;
|
||||
|
||||
TPL_OpenTPLFromFile(&tplfile,filepath);
|
||||
TPL_GetTexture(&tplfile,0,&texObj); //Get
|
||||
|
||||
GX_LoadTexObj(&texObj, GX_TEXMAP0);
|
||||
GX_InvalidateTexAll();
|
||||
|
||||
TPL_CloseTPLFile(&tplfile);
|
||||
|
||||
GX_SetTevOp (GX_TEVSTAGE0, GX_REPLACE);
|
||||
GX_SetVtxDesc (GX_VA_TEX0, GX_DIRECT);
|
||||
|
||||
f32 cos_beta = cos(DegToRad(deg_beta));
|
||||
f32 s_offset_y = (zpos + (cos_beta * distance)) * tan(DegToRad(5));
|
||||
f32 s_offset_x = (cos_beta<0?-cos_beta:cos_beta) * s_offset_y;
|
||||
f32 s_offset_z = (s_offset_y<0 ? 0 : s_offset_y)*2;
|
||||
|
||||
Mtx m,m1,m2,m3,m4, mv;
|
||||
width *=.5;
|
||||
height*=.5;
|
||||
guMtxIdentity (m4);
|
||||
guMtxTransApply(m4,m4, 0, 0, distance);
|
||||
|
||||
guMtxIdentity (m1);
|
||||
guMtxScaleApply(m1,m1,scaleX,scaleY,1.0);
|
||||
guVector axis2 = (guVector) {0 , 1, 0 };
|
||||
guMtxRotAxisDeg (m2, &axis2, deg_beta);
|
||||
guVector axis = (guVector) {0 , 0, 1 };
|
||||
guMtxRotAxisDeg (m3, &axis, deg_alpha);
|
||||
// guMtxConcat(m2,m1,m);
|
||||
guMtxConcat(m3,m4,m3); // move distance then rotate z-axis
|
||||
guMtxConcat(m2,m3,m2); // rotate y-axis
|
||||
guMtxConcat(m1,m2,m); // scale
|
||||
|
||||
if(shadow)
|
||||
guMtxTransApply(m,m, xpos+width+0.5+s_offset_x,ypos+height+0.5+s_offset_y,zpos-s_offset_z);
|
||||
else
|
||||
guMtxTransApply(m,m, xpos+width+0.5,ypos+height+0.5,zpos);
|
||||
|
||||
guMtxConcat (GXmodelView2D, m, mv);
|
||||
GX_LoadPosMtxImm (mv, GX_PNMTX0);
|
||||
|
||||
if(shadow)
|
||||
{
|
||||
GX_Begin(GX_QUADS, GX_VTXFMT0,4);
|
||||
GX_Position3f32(-width, -height, 0);
|
||||
GX_Color4u8(0,0,0,alpha);
|
||||
GX_TexCoord2f32(0, 0);
|
||||
|
||||
GX_Position3f32(width, -height, 0);
|
||||
GX_Color4u8(0,0,0,alpha);
|
||||
GX_TexCoord2f32(1, 0);
|
||||
|
||||
GX_Position3f32(width, height, 0);
|
||||
GX_Color4u8(0,0,0,alpha);
|
||||
GX_TexCoord2f32(1, 1);
|
||||
|
||||
GX_Position3f32(-width, height, 0);
|
||||
GX_Color4u8(0,0,0,alpha);
|
||||
GX_TexCoord2f32(0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
GX_Begin(GX_QUADS, GX_VTXFMT0,4);
|
||||
GX_Position3f32(-width, -height, 0);
|
||||
GX_Color4u8(0xFF,0xFF,0xFF,alpha);
|
||||
GX_TexCoord2f32(0, 0);
|
||||
|
||||
GX_Position3f32(width, -height, 0);
|
||||
GX_Color4u8(0xFF,0xFF,0xFF,alpha);
|
||||
GX_TexCoord2f32(1, 0);
|
||||
|
||||
GX_Position3f32(width, height, 0);
|
||||
GX_Color4u8(0xFF,0xFF,0xFF,alpha);
|
||||
GX_TexCoord2f32(1, 1);
|
||||
|
||||
GX_Position3f32(-width, height, 0);
|
||||
GX_Color4u8(0xFF,0xFF,0xFF,alpha);
|
||||
GX_TexCoord2f32(0, 1);
|
||||
}
|
||||
|
||||
GX_End();
|
||||
GX_LoadPosMtxImm (GXmodelView2D, GX_PNMTX0);
|
||||
|
||||
GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
|
||||
GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);
|
||||
}
|
||||
|
||||
void Menu_DrawTPLMem(f32 xpos, f32 ypos, f32 zpos, u16 width, u16 height, u16 distance,const void *memory,u32 len,
|
||||
f32 deg_alpha, f32 deg_beta, f32 scaleX, f32 scaleY, u8 alpha, bool shadow)
|
||||
{
|
||||
TPLFile tplfile;
|
||||
GXTexObj texObj;
|
||||
|
||||
TPL_OpenTPLFromMemory(&tplfile, memory,len);
|
||||
TPL_GetTexture(&tplfile,0,&texObj); //Get
|
||||
|
||||
GX_LoadTexObj(&texObj, GX_TEXMAP0);
|
||||
GX_InvalidateTexAll();
|
||||
|
||||
TPL_CloseTPLFile(&tplfile);
|
||||
|
||||
GX_SetTevOp (GX_TEVSTAGE0, GX_REPLACE);
|
||||
GX_SetVtxDesc (GX_VA_TEX0, GX_DIRECT);
|
||||
|
||||
f32 cos_beta = cos(DegToRad(deg_beta));
|
||||
f32 s_offset_y = (zpos + (cos_beta * distance)) * tan(DegToRad(5));
|
||||
f32 s_offset_x = (cos_beta<0?-cos_beta:cos_beta) * s_offset_y;
|
||||
f32 s_offset_z = (s_offset_y<0 ? 0 : s_offset_y)*2;
|
||||
|
||||
Mtx m,m1,m2,m3,m4, mv;
|
||||
width *=.5;
|
||||
height*=.5;
|
||||
guMtxIdentity (m4);
|
||||
guMtxTransApply(m4,m4, 0, 0, distance);
|
||||
|
||||
guMtxIdentity (m1);
|
||||
guMtxScaleApply(m1,m1,scaleX,scaleY,1.0);
|
||||
guVector axis2 = (guVector) {0 , 1, 0 };
|
||||
guMtxRotAxisDeg (m2, &axis2, deg_beta);
|
||||
guVector axis = (guVector) {0 , 0, 1 };
|
||||
guMtxRotAxisDeg (m3, &axis, deg_alpha);
|
||||
// guMtxConcat(m2,m1,m);
|
||||
guMtxConcat(m3,m4,m3); // move distance then rotate z-axis
|
||||
guMtxConcat(m2,m3,m2); // rotate y-axis
|
||||
guMtxConcat(m1,m2,m); // scale
|
||||
|
||||
if(shadow)
|
||||
guMtxTransApply(m,m, xpos+width+0.5+s_offset_x,ypos+height+0.5+s_offset_y,zpos-s_offset_z);
|
||||
else
|
||||
guMtxTransApply(m,m, xpos+width+0.5,ypos+height+0.5,zpos);
|
||||
|
||||
guMtxConcat (GXmodelView2D, m, mv);
|
||||
GX_LoadPosMtxImm (mv, GX_PNMTX0);
|
||||
|
||||
if(shadow)
|
||||
{
|
||||
GX_Begin(GX_QUADS, GX_VTXFMT0,4);
|
||||
GX_Position3f32(-width, -height, 0);
|
||||
GX_Color4u8(0,0,0,alpha);
|
||||
GX_TexCoord2f32(0, 0);
|
||||
|
||||
GX_Position3f32(width, -height, 0);
|
||||
GX_Color4u8(0,0,0,alpha);
|
||||
GX_TexCoord2f32(1, 0);
|
||||
|
||||
GX_Position3f32(width, height, 0);
|
||||
GX_Color4u8(0,0,0,alpha);
|
||||
GX_TexCoord2f32(1, 1);
|
||||
|
||||
GX_Position3f32(-width, height, 0);
|
||||
GX_Color4u8(0,0,0,alpha);
|
||||
GX_TexCoord2f32(0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
GX_Begin(GX_QUADS, GX_VTXFMT0,4);
|
||||
GX_Position3f32(-width, -height, 0);
|
||||
GX_Color4u8(0xFF,0xFF,0xFF,alpha);
|
||||
GX_TexCoord2f32(0, 0);
|
||||
|
||||
GX_Position3f32(width, -height, 0);
|
||||
GX_Color4u8(0xFF,0xFF,0xFF,alpha);
|
||||
GX_TexCoord2f32(1, 0);
|
||||
|
||||
GX_Position3f32(width, height, 0);
|
||||
GX_Color4u8(0xFF,0xFF,0xFF,alpha);
|
||||
GX_TexCoord2f32(1, 1);
|
||||
|
||||
GX_Position3f32(-width, height, 0);
|
||||
GX_Color4u8(0xFF,0xFF,0xFF,alpha);
|
||||
GX_TexCoord2f32(0, 1);
|
||||
}
|
||||
|
||||
GX_End();
|
||||
GX_LoadPosMtxImm (GXmodelView2D, GX_PNMTX0);
|
||||
|
||||
GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
|
||||
GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);
|
||||
}
|
||||
|
@ -15,7 +15,12 @@ void InitVideo ();
|
||||
void StopGX();
|
||||
void ResetVideo_Menu();
|
||||
void Menu_Render();
|
||||
void Menu_DrawImg(f32 xpos, f32 ypos, f32 zpos, f32 width, f32 height, u8 data[], f32 degrees, f32 scaleX, f32 scaleY, u8 alphaF ,int XX1, int YY1,int XX2, int YY2,int XX3, int YY3,int XX4, int YY4);
|
||||
void Menu_DrawImg(f32 xpos, f32 ypos, f32 zpos, f32 width, f32 height, u8 data[],
|
||||
f32 degrees, f32 scaleX, f32 scaleY, u8 alphaF ,int XX1, int YY1,int XX2, int YY2,int XX3, int YY3,int XX4, int YY4);
|
||||
void Menu_DrawTPL(f32 xpos, f32 ypos, f32 zpos, u16 width, u16 height, u16 distance,
|
||||
const char *filepath,f32 deg_alpha, f32 deg_beta, f32 scaleX, f32 scaleY, u8 alpha, bool shadow);
|
||||
void Menu_DrawTPLMem(f32 xpos, f32 ypos, f32 zpos, u16 width, u16 height, u16 distance,
|
||||
const void *memory,u32 len, f32 deg_alpha, f32 deg_beta, f32 scaleX, f32 scaleY, u8 alpha, bool shadow);
|
||||
void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 filled);
|
||||
|
||||
extern int screenheight;
|
||||
|
Loading…
Reference in New Issue
Block a user