Exemplo n.º 1
0
void text_draw_background()
{
	static int pos_x=12345678;
	static int pos_y=12345678;
	SDL_Rect r;
	int i,j;
	int w=text_screen->w+text_background->w-1;
	int h=text_screen->h+text_background->h-1;

	if (menu_moving)
	{
		if (pos_x>=0) pos_x=-text_screen->w;
		else pos_x++;
		if (pos_y>=0) pos_y=-text_screen->h;
		else pos_y++;
	}

	for(i=pos_x;i<w;i+=text_background->w)
		for(j=pos_y;j<h;j+=text_background->h)
		{
			r.x=i;
			r.y=j;
			r.w=text_background->w;
			r.h=text_background->h;
			SDL_BlitSurface(text_background,NULL,text_screen,&r);
		}
	if (menu_moving)
	{
#ifdef DREAMCAST
		text_draw_menu_msg();
#endif
		update_window_color();
	}
}
Exemplo n.º 2
0
static void handle_tick(struct tm* tick_time, TimeUnits tick_changed)
{
	time_t now = time(NULL);
	if ((now - last_color_change) > UPDATE_COLOR_EVERY_N_SECONDS) {
		update_window_color();
		last_color_change = now;
		layer_mark_dirty(s_face);
	}
	layer_mark_dirty(s_hand);
}
Exemplo n.º 3
0
static void main_window_load(Window *window) {
  mainwindow = window;
  
  Layer *root = window_get_root_layer(window);

  screen = layer_create(GRect(0, 0, SCREENWIDTH, SCREENHEIGHT));
  
  pointergfx = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_POINTER);
  bg = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BG);
  status = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_STATUS);
  bluetooth = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BLUETOOTH);

  weekdays[0] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_SUNDAY);
  weekdays[1] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_MONDAY);
  weekdays[2] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_TUESDAY);
  weekdays[3] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_WEDNESDAY);
  weekdays[4] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_THURSDAY);
  weekdays[5] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_FRIDAY);
  weekdays[6] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_SATURDAY);

  numbers[0] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_0_SMALL);
  numbers[1] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_1_SMALL);
  numbers[2] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_2_SMALL);
  numbers[3] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_3_SMALL);
  numbers[4] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_4_SMALL);
  numbers[5] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_5_SMALL);
  numbers[6] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_6_SMALL);
  numbers[7] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_7_SMALL);
  numbers[8] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_8_SMALL);
  numbers[9] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_9_SMALL);

  batteries[0] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BATT_LOW);
  batteries[1] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BATT_MED);
  batteries[2] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BATT_HIGH);
  batteries[3] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BATT_FULL);

  
  update_time();

  // this has to be set right away, otherwise it won't be until after tha animation.
  update_window_color();

  layer_set_update_proc(screen, draw_full);
  
  layer_add_child(root, screen);
}
Exemplo n.º 4
0
static void main_window_load(Window *window)
{
	/* initialize UI */
	Layer *window_layer = window_get_root_layer(window);
	GRect bounds = layer_get_frame(window_layer);

	s_time_font = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);

	s_face = layer_create(bounds);
	layer_set_update_proc(s_face, draw_face_layer);

	time_t ts = time(NULL);
	struct tm* now = localtime(&ts);

	update_window_color();

	s_hand = layer_create(bounds);
	layer_set_update_proc(s_hand, draw_hand_layer);

	layer_add_child(window_layer, s_face);
	layer_add_child(window_layer, s_hand);

	/* initial draw of the face */
	layer_mark_dirty(s_face);

	static const AnimationImplementation impl = {
		.update = draw_animation_frame
	};

	s_my_animation_ptr = animation_create();
	animation_set_implementation(s_my_animation_ptr, &impl);
	animation_set_duration(s_my_animation_ptr, 1000);
	animation_schedule(s_my_animation_ptr);

	/* initialize event handlers */
	handle_tick(now, MINUTE_UNIT);
	tick_timer_service_subscribe(MINUTE_UNIT, handle_tick);
}
Exemplo n.º 5
0
void draw_full(Layer *layer, GContext *ctx) {
  unsigned int i;
  int realdaymin;

#ifdef FORCESTARTAT
  APP_LOG(APP_LOG_LEVEL_DEBUG, "%d", daymin);
#endif
  
  realdaymin = daymin - (SCREENWIDTH / 2);
  if(realdaymin < 0)
    realdaymin = MINSINDAY + realdaymin;  

  graphics_context_set_compositing_mode(ctx, GCompOpSet);
  update_window_color();
  
#ifdef PROFILING
  int start, startms, end, endms;

  start = time(NULL);
  startms = time_ms(NULL, NULL);
#endif

  // fill the screen with background graphic
  for(i = 0; i < SCREENWIDTH / 32 + 1; i++) {
    graphics_draw_bitmap_in_rect(ctx, bg, GRect(i * 32, 0, 32, 101));
  }

  if(realdaymin <= MINSINDAY - SCREENWIDTH) {
    for(i = 0; i < SPRITECOUNT; i++) {
      // Consider sprites that wrap around past the end of a day.
      if(spritelist[i].rect.origin.x + spritelist[i].rect.size.w > MINSINDAY) {
        if(RANGE_TEST(realdaymin,
                      realdaymin + SCREENWIDTH,
                      spritelist[i].rect.origin.x - MINSINDAY,
                      spritelist[i].rect.origin.x - MINSINDAY + spritelist[i].rect.size.w)) {
          graphics_draw_bitmap_in_rect(ctx, bitmap_get(spritelist[i].res),
                                       GRect(spritelist[i].rect.origin.x - MINSINDAY - realdaymin,
                                             spritelist[i].rect.origin.y,
                                             spritelist[i].rect.size.w,
                                             spritelist[i].rect.size.h));
        }        
      }
      if(RANGE_TEST(realdaymin,
                    realdaymin + SCREENWIDTH,
                    spritelist[i].rect.origin.x,
                    spritelist[i].rect.origin.x + spritelist[i].rect.size.w)) {
        graphics_draw_bitmap_in_rect(ctx, bitmap_get(spritelist[i].res),
                                     GRect(spritelist[i].rect.origin.x - realdaymin,
                                           spritelist[i].rect.origin.y,
                                           spritelist[i].rect.size.w,
                                           spritelist[i].rect.size.h));
      }
    }
  } else {
    for(i = 0; i < SPRITECOUNT; i++) {
      if(RANGE_TEST(realdaymin,
                    MINSINDAY,
                    spritelist[i].rect.origin.x,
                    spritelist[i].rect.origin.x + spritelist[i].rect.size.w)) {
        graphics_draw_bitmap_in_rect(ctx, bitmap_get(spritelist[i].res),
                                     GRect(spritelist[i].rect.origin.x - realdaymin,
                                           spritelist[i].rect.origin.y,
                                           spritelist[i].rect.size.w,
                                           spritelist[i].rect.size.h));
      } else if (RANGE_TEST(0,
                            SCREENWIDTH - (MINSINDAY - realdaymin),
                            spritelist[i].rect.origin.x,
                            spritelist[i].rect.origin.x + spritelist[i].rect.size.w)) {
        graphics_draw_bitmap_in_rect(ctx, bitmap_get(spritelist[i].res),
                                     GRect(spritelist[i].rect.origin.x + (MINSINDAY - realdaymin),
                                           spritelist[i].rect.origin.y,
                                           spritelist[i].rect.size.w,
                                           spritelist[i].rect.size.h));
      }
    }
  }
  graphics_draw_bitmap_in_rect(ctx, pointergfx,
                               GRect(SCREENWIDTH / 2 - 6, 0, 13, 7));

  // Status bar stuff
  graphics_draw_bitmap_in_rect(ctx, status,
                               GRect(2, SCREENHEIGHT - 15, 66, 13));
  graphics_draw_bitmap_in_rect(ctx, weekdays[weekday],
                               GRect(4, SCREENHEIGHT - 13, 23, 9));
  if(day > 9) {
    graphics_draw_bitmap_in_rect(ctx, numbers[day / 10],
                                 GRect(31, SCREENHEIGHT - 13, 7, 9));
  }
  graphics_draw_bitmap_in_rect(ctx, numbers[day % 10],
                               GRect(39, SCREENHEIGHT - 13, 7, 9));
  if(battlife <= BATT_MED_LEVEL) {
    graphics_draw_bitmap_in_rect(ctx, batteries[0],
                                 GRect(49, SCREENHEIGHT - 13, 7, 9));
  } else if(battlife <= BATT_HIGH_LEVEL) {
    graphics_draw_bitmap_in_rect(ctx, batteries[1],
                                 GRect(49, SCREENHEIGHT - 13, 7, 9));
  } else if(battlife <= BATT_FULL_LEVEL) {
    graphics_draw_bitmap_in_rect(ctx, batteries[2],
                                 GRect(49, SCREENHEIGHT - 13, 7, 9));
  } else {
    graphics_draw_bitmap_in_rect(ctx, batteries[3],
                                 GRect(49, SCREENHEIGHT - 13, 7, 9));
  }
  if(btstatus) {
    graphics_draw_bitmap_in_rect(ctx, bluetooth,
                                 GRect(59, SCREENHEIGHT - 13, 7, 9));
  }

#ifdef PROFILING
  // before bitmaps_clean() to get peak heap usage.
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Heap free after draw: %d", heap_bytes_free());
#endif
  bitmaps_clean();

#ifdef PROFILING
  endms = time_ms(NULL, NULL);
  end = time(NULL);

  APP_LOG(APP_LOG_LEVEL_DEBUG, "Draw took %d milliseconds", ((end * 1000 + endms) - (start * 1000 + startms)));
#endif
}