diff --git a/ToDo b/ToDo index 754d55e..4784487 100644 --- a/ToDo +++ b/ToDo @@ -1,6 +1,5 @@ * Mouse support * In game ;) - * Button for Weapon choice (weapon itself?) * Weapon choice touchpad sensitive * left button moves hare (arrow left and right replacement) * right button sets shooting direction (arrow up and down replacement) diff --git a/about.c b/about.c index c1f4a52..bb4373d 100644 --- a/about.c +++ b/about.c @@ -48,10 +48,8 @@ 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); + const int B1 = spMax(spGetSizeFactor()>>16,1); + const int B2 = spMax(spGetSizeFactor()>>15,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); @@ -64,7 +62,7 @@ void help_draw(void) help_button[2].y = spGetWindowSurface()->h-2-2*help_font->maxheight; int width = help_button[2].w; int height = help_font->maxheight; - draw_edgy_rectangle(help_button[2].x,help_button[2].y,&width,&height,B0,B1,B2,B4); + draw_edgy_rectangle(help_button[2].x,help_button[2].y,&width,&height,B1,B2); spFontDraw( help_button[2].x, help_button[2].y, 0, button_text, help_font ); } else @@ -83,7 +81,7 @@ void help_draw(void) help_button[1].y = 2+ help_font->maxheight; int width = help_button[1].w; int height = help_font->maxheight; - draw_edgy_rectangle(help_button[1].x,help_button[1].y,&width,&height,B0,B1,B2,B4); + draw_edgy_rectangle(help_button[1].x,help_button[1].y,&width,&height,B1,B2); spFontDraw( help_button[1].x, help_button[1].y, 0, button_text, help_font ); } else @@ -97,10 +95,10 @@ void help_draw(void) 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; + help_button[0].y = spGetWindowSurface()->h-B2*2-help_font->maxheight; int width = help_button[0].w; int height = help_font->maxheight; - draw_edgy_rectangle(help_button[0].x,help_button[0].y,&width,&height,B0,B1,B2,B4); + draw_edgy_rectangle(help_button[0].x,help_button[0].y,&width,&height,B1,B2); spFontDraw( help_button[0].x, help_button[0].y, 0, button_text, help_font ); spFlip(); } diff --git a/hase.c b/hase.c index ed379a5..1d0a67d 100644 --- a/hase.c +++ b/hase.c @@ -80,6 +80,17 @@ spNetIRCMessagePointer before_showing; SDL_Surface* screen; SDL_Surface* tomato; +spFontPointer help_font; +struct +{ + int x; + int y; + int w; + int h; + int pressed; +} weapon_button; + + void ( *hase_resize )( Uint16 w, Uint16 h ); void loadInformation(char* information) @@ -542,7 +553,6 @@ void draw(void) y += font->maxheight*3/4+(spGetSizeFactor()*2 >> SP_ACCURACY); } - spFontDrawRight( screen->w-1 - player[active_player]->weapon_points * tomato->w, screen->h-1-font->maxheight, 0, player[active_player]->weapon_points > 0 ? "Action points:" : "Action points: None", font ); int i; @@ -552,7 +562,18 @@ void draw(void) { char number[32]; int w_nr = weapon_pos[player[active_player]->activeHare->wp_y][player[active_player]->activeHare->wp_x]; - spFontDrawRight( screen->w-1, screen->h-1-font->maxheight*2, 0, weapon_name[w_nr], font ); + int B1 = spMax(spGetSizeFactor()>>16,1); + int B2 = spMax(spGetSizeFactor()>>15,1); + weapon_button.w = spFontWidth( weapon_name[w_nr], font ); + weapon_button.h = font->maxheight; + weapon_button.x = screen->w-1 - weapon_button.w; + weapon_button.y = screen->h-1-font->maxheight*2; + int width = weapon_button.w; + int height = font->maxheight; + spSetPattern8(153,60,102,195,153,60,102,195); + draw_edgy_rectangle(weapon_button.x,weapon_button.y,&width,&height,B1,B2); + spDeactivatePattern(); + spFontDraw( weapon_button.x, weapon_button.y, 0, weapon_name[w_nr], font ); int bar_w = spFontWidth(" 88.8 % ",font); int bar_s; if (w_nr == WP_BUILD_SML || w_nr == WP_BUILD_MID || w_nr == WP_BUILD_BIG || @@ -575,6 +596,14 @@ void draw(void) spDeactivatePattern(); spFontDrawMiddle( screen->w-1-bar_w/2, screen->h-1-3*font->maxheight, 0, number, font ); } + else + { + weapon_button.x = -1; + weapon_button.y = -1; + weapon_button.w = -1; + weapon_button.h = -1; + } + if (ragnarok_counter && (hase_game->options.bytewise.ragnarok_border >> 4) < 7) { sprintf(buffer,"RAGNARÖK %i",turn_count - (hase_game->options.bytewise.ragnarok_border >> 4)*5 + 1); @@ -1090,6 +1119,28 @@ int calc(Uint32 steps) spSoundPause(0,-1); spUpdateSprite(spActiveSprite(targeting),steps); spParticleUpdate(&particles,steps); + + if ( spGetInput()->touchscreen.pressed ) + { + int mx = spGetInput()->touchscreen.x; + int my = spGetInput()->touchscreen.y; + if ( weapon_button.x + weapon_button.w >= mx && + weapon_button.x <= mx && + weapon_button.y + weapon_button.h >= my && + weapon_button.y <= my ) + { + weapon_button.pressed = 1; + spMapSetByID( MAP_WEAPON, 1 ); + spGetInput()->touchscreen.pressed = 0; + } + } + else + if (weapon_button.pressed) + { + spMapSetByID( MAP_WEAPON, 0 ); + weapon_button.pressed = 0; + } + for (i = 0; i < steps; i++) { //Camera @@ -1799,6 +1850,11 @@ void update_map() int hase(void ( *resize )( Uint16 w, Uint16 h ),pGame game,pPlayer me_list) { + weapon_button.x = -1; + weapon_button.y = -1; + weapon_button.w = -1; + weapon_button.h = -1; + weapon_button.pressed = 0; input_ok_on = 0; time_t t = time(NULL); struct tm tm = *localtime(&t); diff --git a/lobbyGame.c b/lobbyGame.c index 1ac7d69..d52c114 100644 --- a/lobbyGame.c +++ b/lobbyGame.c @@ -84,13 +84,12 @@ void lobby_draw_buttons(window_text_positon position, int x, int y, char const * text[i] = 0; if (!in_button) { - int B0 = spMax(spGetSizeFactor()>>17,1); int B1 = spMax(spGetSizeFactor()>>16,1); int B2 = spMax(spGetSizeFactor()>>15,1); int B4 = spMax(spGetSizeFactor()>>14,1); width = spFontWidth( text, font ) + B4; int height = font->maxheight; - draw_edgy_rectangle(x,y,&width,&height,B0,B1,B2,B4); + draw_edgy_rectangle(x,y,&width,&height,B1,B2); int j = 0; for (; text[j] && text[j] != '}' && text[j] != ']';j++); if (text[j]) diff --git a/window.c b/window.c index b5b84e7..6e91295 100644 --- a/window.c +++ b/window.c @@ -121,7 +121,7 @@ pWindowElement add_window_element(pWindow window,int type,int reference) pWindow recent_window = NULL; -void draw_edgy_rectangle(int x, int y, int * width, int * height, int B0, int B1, int B2,int B4) +void draw_edgy_rectangle(int x, int y, int * width, int * height, int B1, int B2) { *width += 2*B1; int Y; @@ -180,13 +180,11 @@ static void window_draw_buttons(window_text_positon position, int x, int y, char text[i] = 0; if (!in_button) { - int B0 = spMax(spGetSizeFactor()>>17,1); - int B1 = spMax(spGetSizeFactor()>>16,1); - int B2 = spMax(spGetSizeFactor()>>15,1); - int B4 = spMax(spGetSizeFactor()>>14,1); + const int B1 = spMax(spGetSizeFactor()>>16,1); + const int B2 = spMax(spGetSizeFactor()>>15,1); width = spFontWidth( text, recent_window->font ); int height = recent_window->font->maxheight; - draw_edgy_rectangle(x,y,&width,&height,B0,B1,B2,B4); + draw_edgy_rectangle(x,y,&width,&height,B1,B2); int j = 0; for (; text[j] && text[j] != '}' && text[j] != ']';j++); if (text[j]) @@ -545,8 +543,7 @@ int window_calc(Uint32 steps) case 0: if (elem->type == -1) spMapSetByID( MAP_JUMP, 1 ); - else - if (window->selection != nr) + if (elem->type != 0 || elem->type != 2 || window->selection != nr) spGetInput()->touchscreen.pressed = 0; window->selection = nr; break; diff --git a/window.h b/window.h index c9bede9..71bc940 100644 --- a/window.h +++ b/window.h @@ -74,7 +74,7 @@ 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 B4); +void draw_edgy_rectangle(int x, int y, int * width, int * height, 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);