📄 guicore.cpp
字号:
if(tiy<0){ tih+=tiy; tiy=0; }
if((tiy+tih)>GUI_ScreenHeight) tih=GUI_ScreenHeight-tiy;
if(miy<0){ mih+=miy; miy=0; }
if((miy+mih)>GUI_ScreenHeight) mih=GUI_ScreenHeight-miy;
if(biy<0){ bih+=biy; biy=0; }
if((biy+bih)>GUI_ScreenHeight) bih=GUI_ScreenHeight-biy;
if(toh>0) for(int v=toy;v<toy+toh;v++){
if(low>0) memset(GUI_Screen+lox+GUI_ScreenWidth*v,cBorder_TL,low);
if(mow>0) memset(GUI_Screen+mox+GUI_ScreenWidth*v,cBorder_T,mow);
if(row>0) memset(GUI_Screen+rox+GUI_ScreenWidth*v,cBorder_TR,row);
}
if(moh>0) for(int v=moy;v<moy+moh;v++){
if(low>0) memset(GUI_Screen+lox+GUI_ScreenWidth*v,cBorder_L,low);
if(row>0) memset(GUI_Screen+rox+GUI_ScreenWidth*v,cBorder_R,row);
}
if(boh>0) for(int v=boy;v<boy+boh;v++){
if(low>0) memset(GUI_Screen+lox+GUI_ScreenWidth*v,cBorder_BL,low);
if(mow>0) memset(GUI_Screen+mox+GUI_ScreenWidth*v,cBorder_B,mow);
if(row>0) memset(GUI_Screen+rox+GUI_ScreenWidth*v,cBorder_BR,row);
}
if(tih>0) for(int v=tiy;v<tiy+tih;v++){
if(liw>0) memset(GUI_Screen+lix+GUI_ScreenWidth*v,240+cWindow_Back,liw);
if(miw>0) memset(GUI_Screen+mix+GUI_ScreenWidth*v,240+cWindow_Back,miw);
if(riw>0) memset(GUI_Screen+rix+GUI_ScreenWidth*v,240+cWindow_Back,riw);
}
if(mih>0) for(int v=miy;v<miy+mih;v++){
if(liw>0) memset(GUI_Screen+lix+GUI_ScreenWidth*v,240+cWindow_Back,liw);
if(riw>0) memset(GUI_Screen+rix+GUI_ScreenWidth*v,240+cWindow_Back,riw);
}
if(bih>0) for(int v=biy;v<biy+bih;v++){
if(liw>0) memset(GUI_Screen+lix+GUI_ScreenWidth*v,240+cWindow_Back,liw);
if(miw>0) memset(GUI_Screen+mix+GUI_ScreenWidth*v,240+cWindow_Back,miw);
if(riw>0) memset(GUI_Screen+rix+GUI_ScreenWidth*v,240+cWindow_Back,riw);
}
}
void CTL_BITMAP::refresh(WINDOW *parent){
CTL::refresh(parent);
if(!bitmap) return;
if(!*bitmap) return;
int sx=0,sy=0,dx=x,dy=y,width=(*bitmap)->w,height=(*bitmap)->h;
if(dx<0){ width+=dx; sx-=dx; dx=0; }
if((dx+width)>parent->get_width()){
width=parent->get_width()-dx;
}
if(dy<0){ height+=dy; sy-=dy; dy=0; }
if((dy+height)>parent->get_height()){
height=parent->get_height()-dy;
}
masked_blit(*bitmap,GUI_Bitmap,sx,sy,
parent->get_x()+dx,parent->get_y()+dy,width,height);
}
inline static void PlotStringHelper(WINDOW *window, pGUI_FONT font,
const char *String, int x, int y,
int col, int col_back, int col_fore){
while (*String){
if (x >= window->get_width()) break;
int lx = window->get_visible_x() + x + font->get_widthspace() - 1,
lx2 = window->get_visible_x() + x,
ly = window->get_visible_y() + y,
ly2 = window->get_visible_y() + y + font->get_heightspace() - 1;
vline(GUI_Bitmap, lx, ly, ly2, col);
hline(GUI_Bitmap, lx2, ly2, lx, col);
// if (x > -font->get_widthspace()) // this is always true - dbjh
PlotChar(window, font, *String, x, y, col_back, col_fore);
String++; x += font->get_widthspace();
}
}
void PlotString(WINDOW *window,pGUI_FONT font,const char *String,int x,int y){
PlotStringHelper(window, font, String, x, y, 240 + cText_Back, cText_Back, cText_Fore);
}
void PlotStringInv(WINDOW *window,pGUI_FONT font,const char *String,int x,int y){
PlotStringHelper(window, font, String, x, y, 240 + cText_Fore, cText_Fore, cText_Back);
}
void PlotStringTransparent(WINDOW *window,pGUI_FONT font,const char *String,int x,int y,int color){
while(*String){
if(x>=window->get_width()) break;
if(x>-font->get_widthspace())
PlotCharT(window,font,*String,x,y,color);
String++; x+=font->get_widthspace();
}
}
void PlotStringShadow(WINDOW *window,pGUI_FONT font,const char *String,int x,int y,int tcolor,int scolor){
x-=((strlen(String)*font->get_widthspace())>>1);
PlotStringTransparent(window,font,String,x+1,y+1,scolor);
PlotStringTransparent(window,font,String,x,y,tcolor);
}
void PlotMenuItem(WINDOW *window, pGUI_FONT font,
const char *String, int x, int y, int maxlen){
while (*String){
if(x>=window->get_width()) break;
if (maxlen > 0) maxlen--;
if (x > -font->get_widthspace())
PlotCharT(window, font, *String, x, y, cMenu_Fore);
String++; x+=font->get_widthspace();
}
while (maxlen--){
if(x>=window->get_width()) break;
if(x>-font->get_widthspace())
PlotCharT(window, font, ' ', x, y, cMenu_Fore);
String++; x+=font->get_widthspace();
}
}
void PlotSelectedMenuItem(WINDOW *window, pGUI_FONT font, const char *String, int x, int y, int maxlen){
PlotStringHelper(window, font, String, x, y, 240 + cSelected_Back, cSelected_Back, cSelected_Fore);
int len = strlen(String);
maxlen -= len;
if (maxlen <= 0)
return;
x += len * font->get_widthspace();
rectfill (GUI_Bitmap,
window->get_visible_x() + x,
window->get_visible_y() + y,
window->get_visible_x() + x + maxlen * font->get_widthspace() - 1,
window->get_visible_y() + y + font->get_heightspace() - 1,
240 + cSelected_Back);
}
PALETTE sneesepal;
BITMAP *sneese=0;
BITMAP *joypad=0;
void PlotChar(WINDOW *window,pGUI_FONT font,
char Character,int x,int y,int bcolor,int fcolor){
int width=font->get_width();
unsigned c=font->xlat[(unsigned char) Character];
unsigned char *Pointer=font->faces+c*((width+7)/8)*font->get_height();
bcolor+=240; fcolor+=240;
for(int v=0;v<font->get_height();v++){
// Enforce vertical boundaries
if((y+v)>=window->get_height() ||
(window->get_visible_y()+y+v)>=GUI_ScreenHeight) break;
if((y+v)<0 || (window->get_visible_y()+y+v)<0) continue;
for (int h=0,bit=0x80>>(8-(width&7));h<width;h++,bit>>=1){
// Enforce horizontal boundaries
if((x+h)>=window->get_width() ||
(window->get_visible_x()+x+h)>=GUI_ScreenWidth) break;
if((x+h)<0 || (window->get_visible_x()+x+h)<0) continue;
if(!bit) bit=0x80;
// GUI_Screen[window->get_visible_x()+x+h+
// GUI_ScreenWidth*(window->get_visible_y()+y+v)]=
// (Pointer[(h/8)+((width+7)/8)*v] & bit) ? fcolor : bcolor;
putpixel(GUI_Bitmap, window->get_visible_x()+x+h,
(window->get_visible_y()+y+v),
(Pointer[(h/8)+((width+7)/8)*v] & bit) ? fcolor : bcolor);
}
}
}
void PlotCharTDirect(pGUI_FONT font,char Character,int x,int y,int color){
int width=font->get_width();
unsigned c=font->xlat[(unsigned char) Character];
unsigned char *Pointer=font->faces+c*((width+7)/8)*font->get_height();
color+=240;
for(int v=0;v<font->get_height();v++){
// Enforce vertical boundaries
/*if ((y+v)>=ScreenY) break;*/
if ((y+v)>=224) break;
if ((y+v)<0) continue;
for (int h=0,bit=0x80>>(8-(width&7));h<width;h++,bit>>=1){
// Enforce horizontal boundaries
/* if((x+h)>=ScreenX) break; */
if((x+h)>=256) break;
if((x+h)<0) continue;
if(!bit) bit=0x80;
if(Pointer[(h/8)+((width+7)/8)*v] & bit)
putpixel((BITMAP *) gbSNES_Screen8.subbitmap, x+h, y+v, color);
// SNES_Screen8[x+h+(256+16)*(y+v)]=color;
}
}
}
void PlotStringTDirect(pGUI_FONT font,const char *String,int x,int y,int color){
while(*String){
if(x>-font->get_widthspace())
PlotCharTDirect(font,*String,x,y,color);
String++; x+=font->get_widthspace();
if(x>ScreenX) break;
}
}
void PlotStringSDirect(pGUI_FONT font,const char *String,int x,int y,int tcolor,int scolor){
x-=((strlen(String)*font->get_widthspace())>>1);
PlotStringTDirect(font,String,x+1,y+1,scolor);
PlotStringTDirect(font,String,x,y,tcolor);
}
extern "C" unsigned FPSLast;
extern "C" void ShowFPS(void);
void ShowFPS(void){
char FPS[5];
if (FPSLast <= 9999)
{
FPS[0] = '0' + (FPSLast / 1000);
FPS[1] = '0' + (FPSLast / 100) % 10;
FPS[2] = '0' + (FPSLast / 10) % 10;
if (FPS[0] == '0')
{
FPS[0] = ' ';
if (FPS[1] == '0')
{
FPS[1] = ' ';
if (FPS[2] == '0')
{
FPS[2] = ' ';
}
}
}
FPS[3] = '0' + FPSLast % 10;
FPS[4] = 0;
}
else
{
FPS[0] = 'X'; FPS[1] = 'X'; FPS[2] = 'X'; FPS[3] = 'X';
FPS[4] = 0;
}
PlotStringSDirect(default_font,FPS,180,2,1,2);
}
extern "C" unsigned BreaksLast;
extern "C" void ShowBreaks(void);
void ShowBreaks(void){
char Breaks[5];
if (BreaksLast <= 9999)
{
Breaks[0] = '0' + (BreaksLast / 1000);
Breaks[1] = '0' + (BreaksLast / 100) % 10;
Breaks[2] = '0' + (BreaksLast / 10) % 10;
if (Breaks[0] == '0')
{
Breaks[0] = ' ';
if (Breaks[1] == '0')
{
Breaks[1] = ' ';
if (Breaks[2] == '0')
{
Breaks[2] = ' ';
}
}
}
Breaks[3] = '0' + BreaksLast % 10;
Breaks[4] = 0;
}
else
{
Breaks[0] = 'X'; Breaks[1] = 'X'; Breaks[2] = 'X'; Breaks[3] = 'X';
Breaks[4] = 0;
}
PlotStringSDirect(default_font,Breaks,76,2,1,2);
}
void PlotCharT(WINDOW *window,pGUI_FONT font,
char Character,int x,int y,int color){
int width=font->get_width();
unsigned c=font->xlat[(unsigned char) Character];
unsigned char *Pointer=font->faces+c*((width+7)/8)*font->get_height();
color+=240;
for(int v=0;v<font->get_height();v++){
// Enforce vertical boundaries
if((y+v)>=window->get_height() ||
(window->get_visible_y()+y+v)>=GUI_ScreenHeight) break;
if((y+v)<0 || (window->get_visible_y()+y+v)<0) continue;
for (int h=0,bit=0x80>>(8-(width&7));h<width;h++,bit>>=1){
// Enforce horizontal boundaries
if((x+h)>=window->get_width() ||
(window->get_visible_x()+x+h)>=GUI_ScreenWidth) break;
if((x+h)<0 || (window->get_visible_x()+x+h)<0) continue;
if(!bit) bit=0x80;
if(Pointer[(h/8)+((width+7)/8)*v] & bit)
// GUI_Screen[window->get_visible_x()+x+h+
// GUI_ScreenWidth*(window->get_visible_y()+y+v)]=color;
putpixel(GUI_Bitmap, window->get_visible_x()+x+h,
(window->get_visible_y()+y+v),color);
}
}
}
/*
void PlotCharBorder(unsigned char Character,int x,int y){
unsigned char *Pointer=FontData+((long)Character)*FontWidth*FontHeight;
for(int v=0;v<FontHeight;v++){
for(int h=0;h<FontWidth;h++){
if(v>=0 && v<=FontHeight-1 && h>=0 && h<=FontWidth-1 &&
Pointer[h+FontWidth*v]==1)
// GUI_Screen[x+h+GUI_ScreenWidth*(v+y)]=255;
putpixel(GUI_Bitmap,x+h,(v+y),255;
else if((v>0 && Pointer[h+FontWidth*(v-1)]==1) ||
(v<FontHeight-1 && Pointer[h+FontWidth*(v+1)]==1) ||
(h>0 && Pointer[(h-1)+FontWidth*v]==1) ||
(h<FontWidth-1 && Pointer[(h+1)+FontWidth*v]==1))
// GUI_Screen[x+h+GUI_ScreenWidth*(v+y)]=240;
putpixel(GUI_Bitmap,x+h,(v+y),240;
}
}
}*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -