void gg_ticker_render(gg_widget_t *widget, int x, int y, int focus) { gg_box_t *box = GG_BOX(widget); gg_rect_t rect; rect.x = x; rect.y = y; rect.width = widget->width_a; rect.height = widget->height_a; gg_clipping_adjust(&rect); int size = gg_container_get_size(GG_CONTAINER(widget)); int i; gg_ticker_t *ticker = GG_TICKER(widget); int child_x = ticker->width_a - ticker->offset; for (i = 0; i < size; i++) { gg_widget_t *child = gg_container_get_child(GG_CONTAINER(widget), i); if (child_x < widget->width_a && child_x + child->width_a > 0) { int focus_child; if (focus == GG_FOCUS_ALL) focus_child = GG_FOCUS_ALL; else if (focus == GG_FOCUS_ONE) focus_child = (box->sel == i ? GG_FOCUS_ONE : GG_FOCUS_NONE); else focus_child = 0; child->render(child, x + child_x, y, focus_child); } child_x += child->width_a + ticker->spacing; } gg_clipping_undo(); if (child_x <= 0) { ticker->start_time = gg_system_get_ticks(); ticker->offset = 0; } else { ticker->offset += 1; } ticker->offset = (gg_system_get_ticks() - ticker->start_time) * TICKER_SPEED / 1000; gg_ticker_set_focus_pos(widget, GG_TICKER(widget)->focus_x, 0); }
int draw_sonic_fade( int inout ) { float amount=(gg_system_get_ticks()-fade_start)/(SONIC_FADE_SPEED*1000); int i=0; gg_colour_t col_red={1.0f, 0.0f, 0.0f, 1.0f }; gg_colour_t col_blue={0.0f, 0.0f, 1.0f, 1.0f }; gg_colour_t col_yellow={1.0f, 1.0f, 0.0f, 1.0f }; gg_colour_t col_black={0.0f, 0.0f, 0.0f, 1.0f }; gg_colour_t col_white={1.0f, 1.0f, 1.0f, 1.0f }; if ( amount < 1.0f ) { if ( inout == FADE_IN ) amount=1.0f-amount; if ( amount < 0.7f ) amount=(amount)/0.7f; else if (amount >= 0.7f ) amount=1.0f; gg_system_draw_filled_rect(0, 480-(480*amount), 640, 480, &col_blue ); gg_system_draw_filled_rect(640-(640*amount), 0, 640, (480/3), &col_yellow ); text_draw_string( 640-(640*amount)+280, (480/3)-30, "DreamChess the chess game", 1.2f, &col_white); gg_system_draw_filled_rect(0, 0, (((640/3)+(480/14))*amount)-(480/14), 480, &col_red ); for ( i=0; i<14; i++ ) { draw_tri((((640/3)+(480/14))*amount)-(480/14)+2, i*(480/14)-2, (((640/3)+(480/14))*amount)-(480/14)+2, i*(480/14)+(480/14)-2, (((640/3)+(480/14))*amount)-(480/14)+(480/14)+2, i*(480/14)+((480/14)/2)-2, &col_black); draw_tri((((640/3)+(480/14))*amount)-(480/14), i*(480/14), (((640/3)+(480/14))*amount)-(480/14), i*(480/14)+(480/14), (((640/3)+(480/14))*amount)-(480/14)+(480/14), i*(480/14)+((480/14)/2), &col_red); } text_draw_string( 640-(640*amount*2)+840, 480-(480/3), "Chess Hill", 3.0f, &col_white); text_draw_string( (640*amount*2)-1000, 480-(480/3)-50, "Zone", 3.0f, &col_white); text_draw_string( (640*amount*2)-860, 480-(480/3)-60, "1", 4.0f, &col_yellow); } /*printf( "Drawing sonic fade.. :%i,%f\n", inout, amount );*/ if ( amount >= 1.0f ) { return FALSE; } return TRUE; }
float dialog_get_transition() { float ticks = gg_system_get_ticks(); if (dialog_trans_reset) { dialog_transition_start_pos = gg_system_get_ticks(); dialog_trans_reset = 0; } float dialog_transition = ((ticks-dialog_transition_start_pos) / dialog_transition_speed); if (dialog_transition > 1.0f) { dialog_transition = 1.0f; dialog_in_trans = 0; } if (dialog_trans_in) return dialog_transition; else return 1.0f - dialog_transition; }
void gg_ticker_init(gg_ticker_t *ticker, int width, int spacing) { gg_box_init((gg_box_t *) ticker, spacing); ticker->render = gg_ticker_render; ticker->get_requested_size = gg_ticker_get_requested_size; ticker->set_size = gg_ticker_set_size; ticker->get_focus_pos = gg_ticker_get_focus_pos; ticker->set_focus_pos = gg_ticker_set_focus_pos; ticker->input = gg_ticker_input; ticker->id = gg_ticker_get_class_id(); ticker->width = width; ticker->offset = 0; ticker->start_time = gg_system_get_ticks(); ticker->focus_x = width / 2; }
void gg_system_draw_string(char *s, int x, int y, gg_colour_t *colour, int bounce, int effect, float align) { int i; unsigned int ticks = gg_system_get_ticks(); gg_rect_t rect_d; rect_d.x = x; if (align != 0.0f) { int width; gg_system_get_string_size(s, &width, NULL); rect_d.x -= width * align; } for (i = 0; i < strlen((char *) s); i++) { int y_off = 0; void *image = driver->get_char_image(s[i]); gg_rect_t rect_s = {0, 0}; if (bounce) { float phase = ((ticks % (1000 / GG_BOUNCE_SPEED)) / (float) (1000 / GG_BOUNCE_SPEED)); if (phase < 0.5) y_off = phase * 2 * (GG_BOUNCE_AMP + 1); else y_off = ((1.0 - phase) * 2) * (GG_BOUNCE_AMP + 1); } gg_system_get_image_size(image, &rect_s.width, &rect_s.height); //printf( "Char i:%c=%i,%i\n", s[i], rect_s.width, rect_s.height ); rect_d.width = rect_s.width; rect_d.height = rect_s.height; rect_d.y = y + y_off; gg_system_draw_image(image, rect_s, rect_d, GG_MODE_SCALE, GG_MODE_SCALE, colour, effect); rect_d.x += rect_s.width+1.0f; ticks += 1000 / GG_BOUNCE_SPEED / GG_BOUNCE_LEN; } }
int draw_fade( int inout ) { float amount=(gg_system_get_ticks()-fade_start)/(FADE_SPEED*1000); gg_colour_t col={0.0f, 0.0f, 0.0f, 1.0f-amount }; if ( inout == FADE_OUT ) col.a=amount; if (col.a > 1.0f) col.a = 1.0f; if (col.a >= 0.0f) gg_system_draw_filled_rect(0, 0, 640, 480, &col ); if ( amount >= 1.0f ) return FALSE; return TRUE; }