diff --git a/ToDo b/ToDo index df00c69..5e37ed8 100644 --- a/ToDo +++ b/ToDo @@ -1,2 +1,5 @@ -Nice to have -* Rumble +* Mouse support + * On menu items + * In Lobby +* Fruit Loops Chose too much left? +* Level load arrows? diff --git a/about.c b/about.c index b37225b..6a2d49d 100644 --- a/about.c +++ b/about.c @@ -36,28 +36,119 @@ const char help_text[] = spTextBlockPointer help_block; Sint32 help_scroll; spFontPointer help_font; +struct +{ + int x; + int y; + int w; + int h; +} help_button[3]; //exit, up, down +int help_was_pressed; void help_draw(void) { spClearTarget(LL_BG); + int B0 = spMax(spGetSizeFactor()>>17,1); + int B1 = spMax(spGetSizeFactor()>>16,1); + int B2 = spMax(spGetSizeFactor()>>15,1); + int B4 = spMax(spGetSizeFactor()>>14,1); spFontDrawMiddle( spGetWindowSurface()->w/2, 2, 0, "How to Play", help_font ); int h = spGetWindowSurface()->h - 4 - 4*help_font->maxheight; spFontDrawTextBlock(left,2+spGetWindowSurface()->w/6,2*help_font->maxheight+2, 0,help_block,h,help_scroll,help_font); if (help_scroll != SP_ONE) - spFontDraw( 2+spGetWindowSurface()->w*5/6, spGetWindowSurface()->h-2-2*help_font->maxheight, 0, "[v]", help_font ); + { + const char button_text[] = "[v]"; + help_button[2].w = spFontWidth( button_text, help_font ); + help_button[2].h = help_font->maxheight; + help_button[2].x = 2+spGetWindowSurface()->w*5/6; + help_button[2].y = spGetWindowSurface()->h-2-2*help_font->maxheight; + int width = help_button[2].w + B4; + int height = help_font->maxheight + B4; + draw_edgy_rectangle(help_button[2].x,help_button[2].y,width,height,B0,B1,B2); + spFontDraw( help_button[2].x, help_button[2].y, 0, button_text, help_font ); + } + else + { + help_button[2].x = -1; + help_button[2].y = -1; + help_button[2].w = -1; + help_button[2].h = -1; + } if (help_scroll != 0) - spFontDraw( 2+spGetWindowSurface()->w*5/6, 2+ help_font->maxheight, 0, "[^]", help_font ); - spFontDrawMiddle( spGetWindowSurface()->w/2, spGetWindowSurface()->h-2- help_font->maxheight, 0, "{jump}Okay", help_font ); + { + const char button_text[] = "[^]"; + help_button[1].w = spFontWidth( button_text, help_font ); + help_button[1].h = help_font->maxheight; + help_button[1].x = 2+spGetWindowSurface()->w*5/6; + help_button[1].y = 2+ help_font->maxheight; + int width = help_button[1].w + B4; + int height = help_font->maxheight + B4; + draw_edgy_rectangle(help_button[1].x,help_button[1].y,width,height,B0,B1,B2); + spFontDraw( help_button[1].x, help_button[1].y, 0, button_text, help_font ); + } + else + { + help_button[1].x = -1; + help_button[1].y = -1; + help_button[1].w = -1; + help_button[1].h = -1; + } + const char button_text[] = "{jump}Okay"; + help_button[0].w = spFontWidth( button_text, help_font ); + help_button[0].h = help_font->maxheight; + help_button[0].x = spGetWindowSurface()->w/2 - help_button[0].w/2; + help_button[0].y = spGetWindowSurface()->h-B4-help_font->maxheight; + int width = help_button[0].w + B4; + int height = help_font->maxheight + B4; + draw_edgy_rectangle(help_button[0].x,help_button[0].y,width,height,B0,B1,B2); + spFontDraw( help_button[0].x, help_button[0].y, 0, button_text, help_font ); spFlip(); } int help_calc(Uint32 steps) { + if ( spGetInput()->touchscreen.pressed ) + { + help_was_pressed = 1; + int mx = spGetInput()->touchscreen.x; + int my = spGetInput()->touchscreen.y; + int i = 3; + while (i --> 0 ) + { + if ( help_button[i].x + help_button[i].w >= mx && + help_button[i].x <= mx && + help_button[i].y + help_button[i].h >= my && + help_button[i].y <= my ) + { + switch (i) + { + case 0: + spMapSetByID(MAP_JUMP,1); + break; + case 1: + spGetInput()->axis[1] = -1; + break; + case 2: + spGetInput()->axis[1] = +1; + break; + } + break; + } + } + } + else + if (help_was_pressed) + { + help_was_pressed = 0; + spGetInput()->axis[1] = 0; + } if (spMapGetByID(MAP_JUMP) || spMapGetByID(MAP_CHAT) || spMapGetByID(MAP_MENU)) { spMapSetByID(MAP_JUMP,0); spMapSetByID(MAP_CHAT,0); spMapSetByID(MAP_MENU,0); + spGetInput()->touchscreen.pressed = 0; + spGetInput()->axis[1] = 0; return 1; } if (spGetInput()->axis[1] > 0) @@ -77,6 +168,15 @@ int help_calc(Uint32 steps) void start_help(spFontPointer font, void ( *resize )( Uint16 w, Uint16 h )) { + int i = 3; + while (i --> 0 ) + { + help_button[i].x = -1; + help_button[i].y = -1; + help_button[i].w = -1; + help_button[i].h = -1; + } + help_was_pressed = 0; help_block = spCreateTextBlock(help_text,spGetWindowSurface()->w*2/3-4,font); help_scroll = 0; help_font = font; diff --git a/window.c b/window.c index d7bcb82..3a4a5bc 100644 --- a/window.c +++ b/window.c @@ -123,6 +123,18 @@ typedef enum RIGHT } window_text_positon; +void draw_edgy_rectangle(int x, int y, int width, int height, int B0, int B1, int B2) +{ + int X = x + width/2 - B2; + int Y = y + height/2 - B2; + spRectangle ( X, Y, 0, width + B2 , height + B2, LL_BG); + spRectangleBorder( X, Y, 0, width , height , B1, B1, LL_FG); + spRectangle( x - B2, y - B2, 0, B0, B0, LL_BG ); + spRectangle( x + width - B2, y - B2, 0, B0, B0, LL_BG ); + spRectangle( x - B2, y + height - B2, 0, B0, B0, LL_BG ); + spRectangle( x + width - B2, y + height - B2, 0, B0, B0, LL_BG ); +} + static void window_draw_buttons(window_text_positon position, int x, int y, char const * const text__) { int l = strlen(text__); @@ -169,14 +181,7 @@ static void window_draw_buttons(window_text_positon position, int x, int y, char int B4 = spMax(spGetSizeFactor()>>14,1); width = spFontWidth( text, recent_window->font ) + B4; int height = recent_window->font->maxheight + B4; - int X = x + width/2 - B2; - int Y = y + height/2 - B2; - spRectangle ( X, Y, 0, width + B2 , height + B2, LL_BG); - spRectangleBorder( X, Y, 0, width , height , B1, B1, LL_FG); - spRectangle( x - B2, y - B2, 0, B0, B0, LL_BG ); - spRectangle( x + width - B2, y - B2, 0, B0, B0, LL_BG ); - spRectangle( x - B2, y + height - B2, 0, B0, B0, LL_BG ); - spRectangle( x + width - B2, y + height - B2, 0, B0, B0, LL_BG ); + draw_edgy_rectangle(x,y,width,height,B0,B1,B2); int j = 0; for (; text[j] && text[j] != '}' && text[j] != ']';j++); if (text[j]) diff --git a/window.h b/window.h index 56ec570..14f43fc 100644 --- a/window.h +++ b/window.h @@ -59,6 +59,8 @@ int modal_window(pWindow window, void ( *resize )( Uint16 w, Uint16 h )); pWindow create_text_box(spFontPointer font, void ( *resize )( Uint16 w, Uint16 h ), char* caption, char* text,int len,int show_selection,int* sprite_count,int insult_button); void delete_window(pWindow window); +void draw_edgy_rectangle(int x, int y, int width, int height, int B0, int B1, int B2); + int message_box(spFontPointer font, void ( *resize )( Uint16 w, Uint16 h ), char* caption); int text_box(spFontPointer font, void ( *resize )( Uint16 w, Uint16 h ), char* caption, char* text,int len,int show_selection,int* sprite_count,int insult_button); int sprite_box(spFontPointer font, void ( *resize )( Uint16 w, Uint16 h ), char* caption,int show_selection,int* sprite_count);