mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 03:55:19 -04:00
put launcher titles on 3DS bottom screen
This commit is contained in:
parent
f0f7da8a16
commit
18adec0295
@ -118,18 +118,6 @@ static void LScreen_MouseUp(struct LScreen* s, int idx) { }
|
|||||||
static void LScreen_MouseWheel(struct LScreen* s, float delta) { }
|
static void LScreen_MouseWheel(struct LScreen* s, float delta) { }
|
||||||
|
|
||||||
static void LScreen_DrawBackground(struct LScreen* s, struct Context2D* ctx) {
|
static void LScreen_DrawBackground(struct LScreen* s, struct Context2D* ctx) {
|
||||||
// I don't know of a good place to do this, so I'm sticking it here
|
|
||||||
#ifdef __3DS__
|
|
||||||
enum Screen3DS scr = Window_3DS_SetRenderScreen(TOP_SCREEN);
|
|
||||||
|
|
||||||
// Draw top screen background
|
|
||||||
Launcher_DrawBackgroundAll(ctx);
|
|
||||||
Rect2D r = { 0, 0, WindowInfo.Width, WindowInfo.Height };
|
|
||||||
Window_DrawFramebuffer(r);
|
|
||||||
|
|
||||||
Window_3DS_SetRenderScreen(scr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!s->title) {
|
if (!s->title) {
|
||||||
Launcher_DrawBackground(ctx, 0, 0, ctx->width, ctx->height);
|
Launcher_DrawBackground(ctx, 0, 0, ctx->width, ctx->height);
|
||||||
return;
|
return;
|
||||||
|
@ -536,6 +536,20 @@ void Launcher_DrawTitle(struct FontDesc* font, const char* text, struct Context2
|
|||||||
/* Skip dragging logo when very small window to save space */
|
/* Skip dragging logo when very small window to save space */
|
||||||
if (Window_Main.Height < 240) return;
|
if (Window_Main.Height < 240) return;
|
||||||
|
|
||||||
|
#ifdef __3DS__
|
||||||
|
/* Put title on top screen */
|
||||||
|
enum Screen3DS scr = Window_3DS_SetRenderScreen(TOP_SCREEN);
|
||||||
|
struct Bitmap bmp;
|
||||||
|
struct Context2D topCtx;
|
||||||
|
|
||||||
|
ctx = &topCtx;
|
||||||
|
bmp.width = max(Window_Main.Width, 1);
|
||||||
|
bmp.height = max(Window_Main.Height, 1);
|
||||||
|
Window_AllocFramebuffer(&bmp);
|
||||||
|
Context2D_Wrap(ctx, &bmp);
|
||||||
|
Launcher_DrawBackgroundAll(ctx);
|
||||||
|
#endif
|
||||||
|
|
||||||
DrawTextArgs_Make(&args, &title, font, false);
|
DrawTextArgs_Make(&args, &title, font, false);
|
||||||
x = ctx->width / 2 - Drawer2D_TextWidth(&args) / 2;
|
x = ctx->width / 2 - Drawer2D_TextWidth(&args) / 2;
|
||||||
|
|
||||||
@ -543,6 +557,11 @@ void Launcher_DrawTitle(struct FontDesc* font, const char* text, struct Context2
|
|||||||
Context2D_DrawText(ctx, &args, x + Display_ScaleX(4), Display_ScaleY(4));
|
Context2D_DrawText(ctx, &args, x + Display_ScaleX(4), Display_ScaleY(4));
|
||||||
Drawer2D.Colors['f'] = BITMAPCOLOR_WHITE;
|
Drawer2D.Colors['f'] = BITMAPCOLOR_WHITE;
|
||||||
Context2D_DrawText(ctx, &args, x, 0);
|
Context2D_DrawText(ctx, &args, x, 0);
|
||||||
|
|
||||||
|
#ifdef __3DS__
|
||||||
|
Window_DrawFramebuffer((Rect2D){ 0, 0, bmp.width, bmp.height });
|
||||||
|
Window_3DS_SetRenderScreen(scr);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher_MakeTitleFont(struct FontDesc* font) {
|
void Launcher_MakeTitleFont(struct FontDesc* font) {
|
||||||
|
@ -186,10 +186,16 @@ void Window_UpdateRawMouse(void) { }
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct Bitmap fb_bmp;
|
static struct Bitmap top_fb_bmp;
|
||||||
|
static struct Bitmap bottom_fb_bmp;
|
||||||
void Window_AllocFramebuffer(struct Bitmap* bmp) {
|
void Window_AllocFramebuffer(struct Bitmap* bmp) {
|
||||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(bmp->width * bmp->height, 4, "window pixels");
|
bmp->scan0 = (BitmapCol*)Mem_Alloc(bmp->width * bmp->height, 4, "window pixels");
|
||||||
fb_bmp = *bmp;
|
if (renderScreen == TOP_SCREEN) {
|
||||||
|
top_fb_bmp = *bmp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bottom_fb_bmp = *bmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_DrawFramebuffer(Rect2D r) {
|
void Window_DrawFramebuffer(Rect2D r) {
|
||||||
@ -197,7 +203,7 @@ void Window_DrawFramebuffer(Rect2D r) {
|
|||||||
gfxScreen_t screen = (renderScreen == TOP_SCREEN) ? GFX_TOP : GFX_BOTTOM;
|
gfxScreen_t screen = (renderScreen == TOP_SCREEN) ? GFX_TOP : GFX_BOTTOM;
|
||||||
gfxSetDoubleBuffering(screen, false);
|
gfxSetDoubleBuffering(screen, false);
|
||||||
u8* fb = gfxGetFramebuffer(screen, GFX_LEFT, &width, &height);
|
u8* fb = gfxGetFramebuffer(screen, GFX_LEFT, &width, &height);
|
||||||
|
struct Bitmap *bmp = (renderScreen == TOP_SCREEN) ? &top_fb_bmp : &bottom_fb_bmp;
|
||||||
// SRC y = 0 to 240
|
// SRC y = 0 to 240
|
||||||
// SRC x = 0 to 400
|
// SRC x = 0 to 400
|
||||||
// DST X = 0 to 240
|
// DST X = 0 to 240
|
||||||
@ -206,7 +212,7 @@ void Window_DrawFramebuffer(Rect2D r) {
|
|||||||
for (int y = r.y; y < r.y + r.Height; y++)
|
for (int y = r.y; y < r.y + r.Height; y++)
|
||||||
for (int x = r.x; x < r.x + r.Width; x++)
|
for (int x = r.x; x < r.x + r.Width; x++)
|
||||||
{
|
{
|
||||||
BitmapCol color = Bitmap_GetPixel(&fb_bmp, x, y);
|
BitmapCol color = Bitmap_GetPixel(bmp, x, y);
|
||||||
int addr = (width - 1 - y + x * width) * 3; // TODO -1 or not
|
int addr = (width - 1 - y + x * width) * 3; // TODO -1 or not
|
||||||
fb[addr+0] = BitmapCol_B(color);
|
fb[addr+0] = BitmapCol_B(color);
|
||||||
fb[addr+1] = BitmapCol_G(color);
|
fb[addr+1] = BitmapCol_G(color);
|
||||||
@ -217,10 +223,12 @@ void Window_DrawFramebuffer(Rect2D r) {
|
|||||||
gfxFlushBuffers();
|
gfxFlushBuffers();
|
||||||
//gfxSwapBuffers();
|
//gfxSwapBuffers();
|
||||||
// TODO: tearing??
|
// TODO: tearing??
|
||||||
|
/*
|
||||||
gfxSetDoubleBuffering(GFX_TOP, false);
|
gfxSetDoubleBuffering(GFX_TOP, false);
|
||||||
gfxScreenSwapBuffers(GFX_TOP, true);
|
gfxScreenSwapBuffers(GFX_TOP, true);
|
||||||
gfxSetDoubleBuffering(GFX_TOP, true);
|
gfxSetDoubleBuffering(GFX_TOP, true);
|
||||||
gfxScreenSwapBuffers(GFX_BOTTOM, true);
|
gfxScreenSwapBuffers(GFX_BOTTOM, true);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_FreeFramebuffer(struct Bitmap* bmp) {
|
void Window_FreeFramebuffer(struct Bitmap* bmp) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user