Beispiel #1
0
void    special_effects_update_before (void)
{
return;
	t_skin *skin = Skins_GetCurrentSkin();

	al_lock_bitmap(gui_buffer, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_READWRITE);

	al_set_target_bitmap(gui_buffer);
	switch (skin->effect)
	{
		// BLOOD DROPS -------------------------------------------------------------
	case SKIN_EFFECT_BLOOD:
		for (int i = 0; i < MAX_BLOOD_DROP; i ++)
		{
			t_skinfx_particle* p = &g_skinfx_particles[i];
			if (p->v && p->save.a != 0)
				al_put_pixel(p->x, p->y, p->save);
		}
		break;
	case SKIN_EFFECT_HEARTS:
		// Save old graphics --------------------------------------------------
		const int w = al_get_bitmap_width(Graphics.Misc.Heart1);
		const int h = al_get_bitmap_height(Graphics.Misc.Heart1);
		for (int i = 0; i < MAX_HEARTS; i ++)
		{
			t_skinfx_particle* p = &g_skinfx_particles[i];
			al_draw_bitmap_region(hearts_save[i], 0, 0, w, h, p->x, p->y, 0x0000);
		}
		break;
	}
	al_unlock_bitmap(gui_buffer);
}
Beispiel #2
0
void    special_effects_update_after (void)
{
return;
	t_skin *skin = Skins_GetCurrentSkin();
	switch (skin->effect)
	{
	case SKIN_EFFECT_BLOOD:
		SkinFx_UpdateBlood();
		break;
	case SKIN_EFFECT_HEARTS:
		SkinFx_UpdateHearts();
		break;
	}
}
Beispiel #3
0
void    Skins_Background_Redraw()
{
#ifdef DEBUG_WHOLE
	Msg(MSGT_DEBUG, "Skins_Background_Redraw();");
#endif

	gui.info.must_redraw = TRUE;
	
    al_set_target_bitmap(gui_background);

    t_skin* skin = Skins_GetCurrentSkin();
    ALLEGRO_BITMAP* background = Skins_GetBackgroundPicture();
	if (background != NULL)
	{
        switch (skin->background_picture_mode)
		{
		case SKIN_BACKGROUND_PICTURE_MODE_CENTER:
			Skins_Background_Draw_Center(background);
			break;
		case SKIN_BACKGROUND_PICTURE_MODE_STRETCH:
			Skins_Background_Draw_Stretch(background);
			break;
		case SKIN_BACKGROUND_PICTURE_MODE_STRETCH_INT:
			Skins_Background_Draw_StretchInteger(background);
			break;
		case SKIN_BACKGROUND_PICTURE_MODE_TILE:
			Skins_Background_Draw_Tile(background);
			break;
        default:
            //assert(0);
            Skins_Background_Draw_Stretch(background);
            break;
		}
	}
	else
	{
		Skins_Background_Redraw_Grid();
		VMachine_Draw();
	}

    // Draw SK-1100 centered on bottom
    if (Inputs.SK1100_Enabled)
	{
		ALLEGRO_BITMAP *bmp = Graphics.Inputs.SK1100_Keyboard;
		al_draw_bitmap(bmp,
			(gui.info.screen.x - al_get_bitmap_width(bmp)) / 2,
			(gui.info.screen.y - al_get_bitmap_height(bmp) - 40), 0x0000);
	}
}
Beispiel #4
0
//-----------------------------------------------------------------------------
// gui_update ()
// Update the GUI
//-----------------------------------------------------------------------------
void    gui_update (void)
{
    t_list *boxes;

    // Update mous data
    gui_update_mouse ();

    // Theme effects (blood/snow/hearts) : saving data from the framebuffer
    if (Skins_GetCurrentSkin()->effect != SKIN_EFFECT_NONE)
        special_effects_update_before ();

    // Skins update
    Skins_Update();

    // Menus update
    // Note: must be done before updating applets
    gui_update_menus ();        

    // Boxes update (move / compute dirtyness)
    gui_update_boxes ();

    // Process box deletion
    for (boxes = gui.boxes; boxes != NULL; )
    {
        t_gui_box *box = boxes->elem;
        boxes = boxes->next;
        if (box->flags & GUI_BOX_FLAGS_DELETE)
            gui_box_delete(box);
    }

    // Widgets update
    widgets_call_update ();

    // Call applets handlers
    // Note: Must be done after updating widgets
    gui_update_applets ();
}
Beispiel #5
0
static void    gui_applet_blood_create (int v, int x, int y)
{
	int   max = 1;

	t_skin *skin = Skins_GetCurrentSkin();
	t_skinfx_particle* p = &g_skinfx_particles[g_skinfx_particles_next_spawn];
	switch (skin->effect)
	{
	case SKIN_EFFECT_BLOOD:
		max = MAX_BLOOD_DROP;
		p->v = v;
		p->x = p->ix = x;
		p->y = p->iy = y;
		p->vy = 0.0f;
		p->vy = RandomFloat(0.30f, 0.70f);
		p->sin_amp = 0.0f;
		p->sin_phase = 0.0f;
		p->sin_speed = RandomFloat(-0.02f, +0.02f);
		p->save = al_map_rgba(0,0,0,0);
		break;
	case SKIN_EFFECT_HEARTS:
		max = MAX_HEARTS;
		p->v = v;
		p->x = p->ix = x;
		p->y = p->iy = y;
		p->vx = 0.0f;
		p->vy = RandomFloat(-1.2f, -0.8f);
		p->sin_amp = RandomFloat(20.0f, 70.0f);
		p->sin_phase = RandomFloat(0.0f, MATH_PI*2.0f);
		p->sin_speed = RandomFloat(-0.02f, +0.02f);
		p->save = al_map_rgba(0,0,0,0);
		break;
	}

	g_skinfx_particles_next_spawn = (g_skinfx_particles_next_spawn + 1) % max;
}
Beispiel #6
0
// UPDATE GUI APPLETS, AFTER REFRESHING SCREEN --------------------------------
void    gui_update_applets_after_redraw (void)
{
    // Theme effects (blood/snow/hearts) : restoring data to the framebuffer
    if (Skins_GetCurrentSkin()->effect != SKIN_EFFECT_NONE)
        special_effects_update_after ();
}
Beispiel #7
0
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;
}