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; }
void gg_system_draw_rect(int x, int y, int width, int height, gg_colour_t *colour) { gg_rect_t dest; dest.x = x; dest.y = y; dest.width = width; dest.height = 1; gg_system_draw_filled_rect(dest.x, dest.y, dest.width, dest.height, colour); dest.y += height - 1; gg_system_draw_filled_rect(dest.x, dest.y, dest.width, dest.height, colour); dest.y = y + 1; dest.width = 1; dest.height = height - 2; gg_system_draw_filled_rect(dest.x, dest.y, dest.width, dest.height, colour); dest.x += width - 1; gg_system_draw_filled_rect(dest.x, dest.y, dest.width, dest.height, colour); }
/** @brief Renders a dialog. * * Renders a dialog in a specific style and at a specific position. * * @param menu The dialog to render. * @param style The style to render in. * @param pos The position to render at. */ void gg_dialog_render(gg_dialog_t *dialog, int active) { gg_dialog_style_t *style = &dialog->style; gg_widget_t *child = gg_bin_get_child(GG_BIN(dialog)); int size = 0; gg_rect_t area; int xmin, xmax, ymin, ymax; if (dialog->flags & GG_DIALOG_HIDDEN) return; gg_dialog_get_screen_pos(dialog, &xmin, &ymin); xmax = (xmin + dialog->width); ymax = (ymin + dialog->height); /* Draw the 'fade' */ gg_system_draw_filled_rect(0, 0, 640, 480, &style->fade_col); if (style->textured) gg_system_get_image_size(style->border.image[0], &size, NULL); xmin += size; xmax -= size; ymin += size; ymax -= size; area.x = xmin; area.y = ymin; area.width = xmax - xmin; area.height = ymax - ymin; if (dialog_in_trans) area.height *= dialog_get_transition(); if (style->textured) draw_border(style->border.image, dialog->title, active, area, size); xmin += style->hor_pad; xmax -= style->hor_pad; ymin += style->vert_pad; ymax -= style->vert_pad; if (!dialog_in_trans) child->render(child, xmin, ymin, active); dialog_get_transition(); }
/** Implements widget::render for text widgets. */ void gg_label_render(gg_widget_t *widget, int x, int y, int focus) { gg_label_t *label = GG_LABEL(widget); if (label->bgcolour.a != 0.0f) gg_system_draw_filled_rect(x, y, label->width_a, label->height_a, &label->bgcolour); x += label->xalign * (label->width_a - label->width); y += (1.0f - label->yalign) * (label->height_a - label->height); /* TODO Fix temporary hack */ if (!widget->enabled) gg_system_draw_string(label->label, x, y, &col_grey, 0, 0); else if (focus != GG_FOCUS_NONE) gg_system_draw_string(label->label, x, y, &col_texthighlight, label->bouncy, 0); else gg_system_draw_string(label->label, x, y, &label->colour, 0, 0); }
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; }
void draw_border(void *image[9], char *title, int active, gg_rect_t area, int size) { gg_rect_t source, dest; int image_size; int titlebar_height = 0; gg_system_get_image_size(image[0], &image_size, NULL); source.x = 0; source.y = 0; source.width = image_size; source.height = image_size; if (title) { int text_height; gg_system_get_string_size(title, NULL, &text_height); titlebar_height = text_height * GG_DIALOG_TITLE_FACT; titlebar_height += GG_DIALOG_TITLE_SEP_HEIGHT; dest.x = area.x; dest.y = area.y + area.height - titlebar_height; dest.width = area.width; dest.height = GG_DIALOG_TITLE_SEP_HEIGHT; gg_system_draw_filled_rect(dest.x, dest.y, dest.width, GG_DIALOG_TITLE_SEP_HEIGHT, &col_black); dest.y += GG_DIALOG_TITLE_SEP_HEIGHT; dest.height = titlebar_height - GG_DIALOG_TITLE_SEP_HEIGHT; if (active ) gg_system_draw_gradient_rect(dest.x, dest.y, dest.width, dest.height, &col_blue2, &col_blue, &col_blue2, &col_blue); else gg_system_draw_gradient_rect(dest.x, dest.y, dest.width, dest.height, &col_grey2, &col_grey, &col_grey2, &col_grey); gg_clipping_adjust(&dest); dest.y += text_height * (GG_DIALOG_TITLE_FACT - 1) / 2; gg_system_draw_string(title, dest.x + dest.width / 2, dest.y, &col_white, 0, 0.5); gg_clipping_undo(); } area.x -= size; area.y -= size; area.width += 2 * size; area.height += 2 * size; dest.x = area.x; dest.y = area.y; dest.width = size; dest.height = size; /* Draw four corners.. */ gg_system_draw_image(image[6], source, dest, GG_MODE_SCALE, GG_MODE_SCALE, &col_white); dest.y += area.height - size; gg_system_draw_image(image[0], source, dest, GG_MODE_SCALE, GG_MODE_SCALE, &col_white); dest.x += area.width - size; gg_system_draw_image(image[2], source, dest, GG_MODE_SCALE, GG_MODE_SCALE, &col_white); dest.y -= area.height - size; gg_system_draw_image(image[8], source, dest, GG_MODE_SCALE, GG_MODE_SCALE, &col_white); /* Draw bottom */ dest.x = area.x + size; dest.y = area.y; dest.width = area.width - (2 * size); dest.height = size; gg_system_draw_image(image[7], source, dest, GG_MODE_TILE, GG_MODE_SCALE, &col_white); /* Draw top */ dest.y += area.height - size; gg_system_draw_image(image[1], source, dest, GG_MODE_TILE, GG_MODE_SCALE, &col_white); /* Draw left */ dest.x = area.x; dest.y = area.y + size; dest.width = size; dest.height = area.height - (2 * size); gg_system_draw_image(image[3], source, dest, GG_MODE_SCALE, GG_MODE_TILE, &col_white); /* Draw right */ dest.x += area.width - size; gg_system_draw_image(image[5], source, dest, GG_MODE_SCALE, GG_MODE_TILE, &col_white); /* Draw middle */ dest.x = area.x + size; dest.width = area.width - 2 * size; dest.height -= titlebar_height; gg_system_draw_image(image[4], source, dest, GG_MODE_TILE, GG_MODE_TILE, &col_white); }