예제 #1
0
void highlight_setting (int item)
{
	int x,y;
	int width;
	
	if ((hilite_item != -1) && (hilite_item != item))
	{
		if (hilite_item == (NUM_SETTINGS - 1))
		{
			x = GFX_X_CENTRE - (OPTION_BAR_WIDTH / 2);
			y = ((NUM_SETTINGS + 1) / 2) * 30 + 96 + 32;
			width = OPTION_BAR_WIDTH;
		}
		else
		{
			x = (hilite_item & 1) * 250 + 32 + 120; 
			y = (hilite_item / 2) * 30 + 96;
			width = 100;
		}

		gfx_clear_area (x, y, x + width, y + OPTION_BAR_HEIGHT);
		display_setting_item (hilite_item);		
	}

	if (item == (NUM_SETTINGS - 1))
	{
		x = GFX_X_CENTRE - (OPTION_BAR_WIDTH / 2);
		y = ((NUM_SETTINGS + 1) / 2) * 30 + 96 + 32;
		width = OPTION_BAR_WIDTH;
	}
	else
	{
		x = (item & 1) * 250 + 32 + 120; 
		y = (item / 2) * 30 + 96;
		width = 100;
	}
	
	gfx_draw_rectangle (x, y, x + width, y + OPTION_BAR_HEIGHT, GFX_COL_DARK_RED);
	display_setting_item (item);		
	hilite_item = item;
}
예제 #2
0
void highlight_option (int i)
{
	int y;
	int x;
	
	if ((hilite_item != -1) && (hilite_item != i))
	{
		x = GFX_X_CENTRE - (OPTION_BAR_WIDTH / 2);
		y = (384 - (30 * NUM_OPTIONS)) / 2;
		y += hilite_item * 30;
		gfx_clear_area (x, y, x + OPTION_BAR_WIDTH, y + OPTION_BAR_HEIGHT);
		display_option_item (hilite_item);		
	}

	x = GFX_X_CENTRE - (OPTION_BAR_WIDTH / 2);
	y = (384 - (30 * NUM_OPTIONS)) / 2;
	y += i * 30;
	
	gfx_draw_rectangle (x, y, x + OPTION_BAR_WIDTH, y + OPTION_BAR_HEIGHT,
						GFX_COL_DARK_RED);
	display_option_item (i);		

	hilite_item = i;
}
예제 #3
0
파일: task.c 프로젝트: eruanno123/smart-pht
void perform_delayed_operation(uint16_t opId, bool_t pleaseWaitInfo)
{
    if(!isSensorBusy)
    {
        // Do immediately
        handle_delayed_operation_event(opId);
    }
    else
    {
        if(pleaseWaitInfo)
        {
            gfx_set_color(COLOR_BLACK);
            gfx_fill_rectangle(120, 100, 240, 72);
            gfx_set_color(COLOR_YELLOW);
            gfx_draw_rectangle(120, 100, 240, 72);
            gfx_set_text_pos(200, 130);
            gfx_set_font(&FONT_DIALOG_12);
            gfx_outtext("Please wait...", 20);
        }

        delayedOperation = opId;
        // ... and wait
    }
}
예제 #4
0
void dashboard_draw_func(handle_t obj)
{
    gui_widget_t *w = (gui_widget_t *) obj;

    gfx_set_color(COLOR_BLACK);
    gfx_fill_rectangle(w->left, w->top, w->width, w->height);

    if(gui_widget_get_state(w, STATE_FOCUSED))
        gfx_set_color(COLOR_YELLOW);
    else
        gfx_set_color(COLOR_DARK_YELLOW);

    gfx_draw_rectangle(w->left, w->top, w->width, w->height);

    gfx_set_color(COLOR_WHITE);
    gfx_set_font(&FONT_DIALOG_12);
    gfx_set_text_pos(w->left + 10, w->top + 10);
    gfx_outtext("Pressure:", 100);
    gfx_set_text_pos(w->left + 10, w->top + 90);
    gfx_outtext("Humidity:", 100);
    gfx_set_text_pos(w->left + 10, w->top + 170);
    gfx_outtext("Temperature:", 100);

    if(w->extra != NULL)
    {
        dashboard_data_t *data = (dashboard_data_t*) w->extra;
        char buf[16];
        int16_t trend;

        // Min & max

        gfx_set_text_pos(w->left + 10, w->top + 60);
        gfx_set_color(COLOR_CYAN);
        gfx_outtext("min: ", 10);
        if(data->pressure.min != 0x8000)
            tiny_sprintf(stringCache, "%d1 hPa", data->pressure.min);
        else
            tiny_sprintf(stringCache, "---");
        gfx_set_color(data->alarmMask & ALARM_MIN_P ? COLOR_RED : COLOR_WHITE);
        gfx_outtext_ram(stringCache, 25);
        gfx_set_color(COLOR_CYAN);
        gfx_outtext(", max: ", 10);
        if(data->pressure.max != 0x8000)
            tiny_sprintf(stringCache, "%d1 hPa", data->pressure.max);
        else
            tiny_sprintf(stringCache, "---");
        gfx_set_color(data->alarmMask & ALARM_MAX_P ? COLOR_RED : COLOR_WHITE);
        gfx_outtext_ram(stringCache, 25);
        
        gfx_set_text_pos(w->left + 10, w->top + 140);
        gfx_set_color(COLOR_MAGENTA);
        gfx_outtext("min: ", 10);
        if(data->humidity.min != 0x8000)
            tiny_sprintf(stringCache, "%d2 %%RH", data->humidity.min);
        else
            tiny_sprintf(stringCache, "---");
        gfx_set_color(data->alarmMask & ALARM_MIN_H ? COLOR_RED : COLOR_WHITE);
        gfx_outtext_ram(stringCache, 25);
        gfx_set_color(COLOR_MAGENTA);
        gfx_outtext(", max: ", 10);
        if(data->humidity.max != 0x8000)
            tiny_sprintf(stringCache, "%d2 %%RH", data->humidity.max);
        else
            tiny_sprintf(stringCache, "---");
        gfx_set_color(data->alarmMask & ALARM_MAX_H ? COLOR_RED : COLOR_WHITE);
        gfx_outtext_ram(stringCache, 25);
        
        gfx_set_text_pos(w->left + 10, w->top + 220);
        gfx_set_color(COLOR_YELLOW);
        gfx_outtext("min: ", 10);
        if(data->temperature.min != 0x8000)
            tiny_sprintf(stringCache, "%d2 *C", data->temperature.min);
        else
            tiny_sprintf(stringCache, "---");
        gfx_set_color(data->alarmMask & ALARM_MIN_T ? COLOR_RED : COLOR_WHITE);
        gfx_outtext_ram(stringCache, 25);
        gfx_set_color(COLOR_YELLOW);
        gfx_outtext(", max: ", 10);
        if(data->temperature.max != 0x8000)
            tiny_sprintf(stringCache, "%d2 *C", data->temperature.max);
        else
            tiny_sprintf(stringCache, "---");
        gfx_set_color(data->alarmMask & ALARM_MAX_T ? COLOR_RED : COLOR_WHITE);
        gfx_outtext_ram(stringCache, 25);

        // TREND

        trend = (data->pressure.trend - data->pressure.trendLast);
        if(trend < 2 && trend > -2)
            draw_minus(w->left + 170, w->top + 38);
        else
        {
            draw_arrow(w->left + 170, w->top + 23, (bool_t) (trend > 0));
            tiny_sprintf(buf, "%c%d1", trend > 0? '+' : ' ', trend);
            gfx_set_text_pos(w->left + 150, w->top + 43);
            gfx_outtext_ram(buf, 16);
        }

        trend = (data->humidity.trend - data->humidity .trendLast);
        if (trend < 5 && trend > -5)
            draw_minus(w->left + 170, w->top + 118);
        else
        {
            draw_arrow(w->left + 170, w->top + 103, (bool_t) (trend > 0));
            tiny_sprintf(buf, "%c%d2", trend > 0? '+' : ' ', trend);
            gfx_set_text_pos(w->left + 150, w->top + 123);
            gfx_outtext_ram(buf, 16);
        }

        trend = (data->temperature.trend - data->temperature.trendLast);
        if (trend < 2 && trend > -2)
            draw_minus(w->left + 170, w->top + 198);
        else
        {
            draw_arrow(w->left + 170, w->top + 183, (bool_t) (trend > 0));
            tiny_sprintf(buf, "%c%d2", trend > 0? '+' : ' ', trend);
            gfx_set_text_pos(w->left + 150, w->top + 203);
            gfx_outtext_ram(buf, 16);
        }

        // Big digits
        
        gfx_set_font(&FONT_ARIALBLACK_36);
        gfx_set_color(COLOR_WHITE);
    
        gfx_set_text_pos(w->left + 10, w->top + 18);
        tiny_sprintf(stringCache, "%d1", data->pressure.val);
        gfx_outtext_ram(stringCache, 10);

        gfx_set_text_pos(w->left + 10, w->top + 98);
        tiny_sprintf(stringCache, "%d2", data->humidity.val);
        gfx_outtext_ram(stringCache, 10);

        gfx_set_text_pos(w->left + 10, w->top + 178);
        tiny_sprintf(stringCache, "%d2", data->temperature.val);
        gfx_outtext_ram(stringCache, 10);
    }
}
예제 #5
0
void draw_map(struct map * map, enum GAME_MODE game_mode, trait_t active_traits, int topleft_x, int topleft_y, int width, int height)
{
    gfx_gl_log("%s:%s: map", __FILE__, __FUNCTION__);
    if(globals.map_tilting == true)
        topleft_y += map->tilt;

    if(globals.opengl)
    {
#ifdef WITH_OPENGL
        glScissor(topleft_x, SCREEN_HEIGHT - topleft_y - height * 24 - 1, width * 24, height * 24);
        gfxgl_state(GL_SCISSOR_TEST, true);
#endif
    }
#ifdef WITH_NONOPENGL
    else
    {
        SDL_Rect r;

        r.x = topleft_x;
        r.y = topleft_y;
        r.w = width * 24;
        r.h = height * 24;
        SDL_SetClipRect(gfx_game_screen(), &r);
    }
#endif

    enum MOVE_DIRECTION amstate;

    if(game_mode == GAME_MODE_CLASSIC)
        amstate = MOVE_UP;
    else if(map->ameba_blocked == -1 || map->ameba_blocked == 0)
        amstate = MOVE_UP;
    else if(map->ameba_blocked_timer > map->frames_per_second * 3)
        amstate = MOVE_UP;
    else if(map->ameba_blocked_timer > map->frames_per_second * 1)
        amstate = MOVE_RIGHT;
    else
        amstate = MOVE_DOWN;

    if(globals.opengl)
    {
#ifdef WITH_OPENGL
        draw_map_opengl(map, game_mode, topleft_x, topleft_y, width, height, amstate);
#endif
    }
#ifdef WITH_NONOPENGL
    else
        draw_map_non_opengl(map, topleft_x, topleft_y, width, height, amstate);
#endif

#ifdef WITH_OPENGL
    bool texturechanged;

    texturechanged = false;
    if(globals.opengl && (game_mode == GAME_MODE_ADVENTURE || game_mode == GAME_MODE_PYJAMA_PARTY))
        if(map->girl->mob->alive && map->girl->mob->chat_bubble_timer > 0)
        {
            int x, y, w, h;

            w = font_width(map->girl->mob->chat_bubble);
            h = font_height();

            x = topleft_x + map->map_fine_x + (map->girl->mob->x - map->map_x    ) * 24 + 12 - w / 2;
            y = topleft_y + map->map_fine_y + (map->girl->mob->y - map->map_y - 1) * 24;

            x += map->move_offsets[2 * (map->girl->mob->x + map->girl->mob->y * map->width) + 0];
            y += map->move_offsets[2 * (map->girl->mob->x + map->girl->mob->y * map->width) + 1];

            SDL_Rect r;

            r.x = x - 4;
            r.y = y - 2;
            r.w = w + 4 * 2;
            r.h = h + 2 * 2;
            gfx_draw_rectangle(&r, 0x00, 0x00, 0x00, 0x80);

            font_write(x, y, map->girl->mob->chat_bubble);
            texturechanged = true;
        }
#endif

    if(map->level_start_anim_on > 0 && map->is_intermission == true)
    {
        struct image * img;

        img = gfx_image(GFX_IMAGE_INTERMISSION);
        if(img != NULL)
        {
            int x, y;

            x = 20 + get_rand(SCREEN_WIDTH - img->width - 40);
            y = 20 + get_rand(SCREEN_WIDTH - img->height - 40);
            gfx2d_draw_image(x, y, img);
        }
    }

    if(globals.opengl)
    {
#ifdef WITH_OPENGL
        gfxgl_state(GL_SCISSOR_TEST, false);
#endif
    }
#ifdef WITH_NONOPENGL
    else
        SDL_SetClipRect(gfx_game_screen(), NULL);
#endif


    gfx_gl_log("%s:%s: map cursor", __FILE__, __FUNCTION__);
    draw_map_cursor(map, topleft_x, topleft_y, width, height);
#ifdef WITH_OPENGL
    if(texturechanged == true)
        gfx_set_current_glyph_set(0);
#endif
    gfx_gl_log("%s:%s: map borders", __FILE__, __FUNCTION__);
    draw_map_borders(map, game_mode, active_traits, topleft_x, topleft_y, width, height);

    if(game_mode == GAME_MODE_ADVENTURE || game_mode == GAME_MODE_PYJAMA_PARTY || globals.smooth_classic_mode == true)
        if(map->girl->mob->moved_over_glyph != MAP_SIZEOF_)
        {
            int8_t * p;

            p = &map->move_offsets[2 * (map->girl->mob->x + map->girl->mob->y * map->width)];
            if(abs(p[0]) < 12 && abs(p[1]) < 12)
                map->girl->mob->moved_over_glyph = MAP_SIZEOF_;
        }
}