static void AboutBox_Layout(bool setup) { t_app_about_box *app = &AboutBox; // Global instance const int dragon_h = al_get_bitmap_height(Graphics.Misc.Dragon); al_set_target_bitmap(app->box->gfx_buffer); al_clear_to_color(COLOR_SKIN_WINDOW_BACKGROUND); if (setup) widget_closebox_add(app->box, (t_widget_callback)AboutBox_Switch); // Draw MEKA dragon sprite al_draw_bitmap(Graphics.Misc.Dragon, 16, (app->box->frame.size.y - dragon_h) / 2, 0); // Print about information lines { int y = 12; Font_SetCurrent((t_font_id)g_config.font_about); for (int i = 0; i < 4; i ++) { char buffer[256]; switch (i) { case 0: snprintf(buffer, countof(buffer), Msg_Get(MSG_About_Line_Meka_Date), MEKA_NAME_VERSION, MEKA_DATE); break; case 1: snprintf(buffer, countof(buffer), Msg_Get(MSG_About_Line_Authors), MEKA_AUTHORS_SHORT); break; case 2: snprintf(buffer, countof(buffer), Msg_Get(MSG_About_Line_Homepage), MEKA_HOMEPAGE); break; case 3: snprintf(buffer, countof(buffer), "Built %s, %s", MEKA_BUILD_DATE, MEKA_BUILD_TIME); break; } const int x = (( (app->box->frame.size.x - dragon_h - 18 - 6) - Font_TextWidth(FONTID_CUR, buffer) ) / 2) + dragon_h + 8 + 6; Font_Print(FONTID_CUR, buffer, x, y, COLOR_SKIN_WINDOW_TEXT); y += Font_Height() + 3; } } }
static void Options_Layout_AddLine(t_app_options* app, bool setup, t_frame *frame, const char *text, bool *v, void (*func)()) { frame->pos.x = OPTIONS_PAD_X; if (setup) widget_checkbox_add(Options.box, frame, v, (t_widget_callback)func); // FIXME: Cast frame->pos.x += frame->size.x + Font_TextWidth(app->font_id, " "); Font_Print(app->font_id, text, frame->pos.x, frame->pos.y+2, COLOR_SKIN_WINDOW_TEXT); frame->pos.y += (int)(Font_Height(app->font_id) * 1.3f); }
static void Options_Layout(t_app_options* app, bool setup) { app->font_id = (t_font_id)g_configuration.font_options; t_frame frame; al_set_target_bitmap(app->box->gfx_buffer); al_clear_to_color(COLOR_SKIN_WINDOW_BACKGROUND); if (setup) { // Add closebox widget widget_closebox_add(Options.box, (t_widget_callback)Options_Switch); // Add close button frame.size.x = Font_TextWidth(app->font_id, Msg_Get(MSG_Options_Close))+15; frame.size.y = Font_Height(app->font_id)*2; frame.pos.x = Options.box->frame.size.x - frame.size.x - OPTIONS_PAD_X; frame.pos.y = Options.box->frame.size.y - frame.size.y - OPTIONS_PAD_Y; widget_button_add(Options.box, &frame, 1, (t_widget_callback)Options_Switch, app->font_id, Msg_Get(MSG_Options_Close)); } // Draw option lines frame.pos.x = Font_Height(app->font_id)-2; frame.pos.y = OPTIONS_PAD_Y; frame.size.x = Font_Height(app->font_id); frame.size.y = Font_Height(app->font_id); Options_Layout_AddLine(app, setup, &frame, Msg_Get(MSG_Options_BIOS_Enable), &g_configuration.enable_BIOS, NULL); Options_Layout_AddLine(app, setup, &frame, Msg_Get(MSG_Options_DB_Display), &g_configuration.fb_uses_DB, Option_Switch_Uses_VLFN); Options_Layout_AddLine(app, setup, &frame, Msg_Get(MSG_Options_Product_Number), &g_configuration.show_product_number, NULL); //Options_Layout_AddLine(app, setup, &frame, Msg_Get(MSG_Options_Bright_Palette), &g_configuration.palette_type, Palette_Emu_Reload); Options_Layout_AddLine(app, setup, &frame, Msg_Get(MSG_Options_Allow_Opposite_Directions), &g_configuration.allow_opposite_directions, NULL); Options_Layout_AddLine(app, setup, &frame, Msg_Get(MSG_Options_Load_Close), &g_configuration.fb_close_after_load, NULL); Options_Layout_AddLine(app, setup, &frame, Msg_Get(MSG_Options_Load_FullScreen), &g_configuration.fullscreen_after_load, NULL); Options_Layout_AddLine(app, setup, &frame, Msg_Get(MSG_Options_FullScreen_Messages), &g_configuration.show_fullscreen_messages, NULL); Options_Layout_AddLine(app, setup, &frame, Msg_Get(MSG_Options_GUI_VSync), &g_configuration.video_mode_gui_vsync, NULL); Options_Layout_AddLine(app, setup, &frame, Msg_Get(MSG_Options_Capture_Crop_Align), &g_configuration.capture_crop_align_8x8, NULL); Options_Layout_AddLine(app, setup, &frame, Msg_Get(MSG_Options_NES_Enable), &g_configuration.enable_NES, Option_Switch_NES_Crap); }
void gui_draw() { // If we were asked to redraw everything, redraw the background as well if (gui.info.must_redraw == TRUE) gui_draw_background(); al_set_target_bitmap(gui_buffer); for (int i = gui.boxes_count - 1; i >= 0; i--) { t_gui_box* b = gui.boxes_z_ordered[i]; const t_frame bb = b->frame; const v2i bb_min = bb.GetMin(); const v2i bb_max = bb.GetMax(); if (!(b->flags & GUI_BOX_FLAGS_ACTIVE)) continue; // Draw widgets for (t_list* widgets = b->widgets; widgets != NULL; widgets = widgets->next) { t_widget *w = (t_widget *)widgets->elem; if (w->enabled && w->type != WIDGET_TYPE_CLOSEBOX) if (w->redraw_func != NULL) w->redraw_func(w); } // Blit content switch (b->type) { case GUI_BOX_TYPE_STANDARD: al_set_target_bitmap(gui_buffer); al_draw_bitmap_region(b->gfx_buffer, 0, 0, bb.size.x + 1, bb.size.y + 1, bb.pos.x, bb.pos.y, 0x0000); break; case GUI_BOX_TYPE_GAME: gamebox_draw(b, screenbuffer); break; } // Draw borders al_set_target_bitmap(gui_buffer); gui_rect(LOOK_ROUND, bb.pos.x - 2, bb.pos.y - 20, bb.pos.x + bb.size.x + 2, bb.pos.y + bb.size.y + 2, COLOR_SKIN_WINDOW_BORDER); al_draw_line(bb.pos.x, bb.pos.y - 1.5f, bb.pos.x + bb.size.x + 1, bb.pos.y - 1.5f, COLOR_SKIN_WINDOW_BORDER, 0); al_draw_line(bb.pos.x, bb.pos.y - 0.5f, bb.pos.x + bb.size.x + 1, bb.pos.y - 0.5f, COLOR_SKIN_WINDOW_BORDER, 0); // Draw resize widget (invisible for game window) if (b->flags & GUI_BOX_FLAGS_ALLOW_RESIZE) { const bool is_resizing = (gui.mouse.focus == GUI_FOCUS_BOX && gui.mouse.focus_box == b && gui.mouse.focus_is_resizing); if (b->type != GUI_BOX_TYPE_GAME || is_resizing) { const int sz = 9; // display size is 9, interaction is 12 const ALLEGRO_COLOR color = is_resizing ? COLOR_SKIN_WINDOW_TEXT_HIGHLIGHT : COLOR_SKIN_WINDOW_TITLEBAR_TEXT_UNACTIVE; al_draw_filled_triangle(bb_max.x+2, bb_max.y+2, bb_max.x+2-sz, bb_max.y+2, bb_max.x+2, bb_max.y+2-sz, color); } } // Draw title bar { t_frame titlebar_frame; titlebar_frame.pos.x = bb.pos.x; titlebar_frame.pos.y = bb.pos.y - 18; titlebar_frame.size.x = bb.size.x; titlebar_frame.size.y = 15; SkinGradient_DrawHorizontal(&Skins_GetCurrentSkin()->gradient_window_titlebar, gui_buffer, &titlebar_frame); // Draw title bar text, with wrapping // Is window the focused one? const ALLEGRO_COLOR color = (i == 0) ? COLOR_SKIN_WINDOW_TITLEBAR_TEXT : COLOR_SKIN_WINDOW_TITLEBAR_TEXT_UNACTIVE; Font_SetCurrent(FONTID_LARGE); if (Font_TextWidth(FONTID_CUR, b->title) <= (bb.size.x - 8)) { Font_Print (FONTID_CUR, b->title, bb.pos.x + 4, bb.pos.y - 17, color); } else { // FIXME-OPT: shit code. char title[256]; int len = strlen(b->title); strcpy(title, b->title); while (Font_TextWidth(FONTID_CUR, title) > (bb.size.x - 17)) title[--len] = EOSTR; strcat(title, ".."); Font_Print(FONTID_CUR, title, bb.pos.x + 4, bb.pos.y - 17, color); } // Draw widgets for (t_list* widgets = b->widgets; widgets != NULL; widgets = widgets->next) { t_widget *w = (t_widget *)widgets->elem; if (w->enabled && w->type == WIDGET_TYPE_CLOSEBOX) if (w->redraw_func != NULL) w->redraw_func(w); } } } // Redraw menus on top of the desktop gui_redraw_menus(); // Update applets that comes after the redraw gui_update_applets_after_redraw(); // Clear global redrawing flag and makes mouse reappear gui.info.must_redraw = FALSE; }