Add resources now that they are more stable; use cropped-to-content resources

This commit is contained in:
2026-03-15 23:23:15 -04:00
parent f83b291479
commit 7ba832f2c5
55 changed files with 28 additions and 3 deletions

View File

@@ -4,6 +4,7 @@
// declare general statics
static Window *s_main_window;
static GFont s_custom_font;
static Layer *s_time_bar_layer;
static TextLayer *s_time_layer;
static TextLayer *s_date_layer;
static BitmapLayer *s_guy_head_layer;
@@ -158,6 +159,11 @@ static void minute_handler(struct tm *tick_time, TimeUnits units_changed) {
}
}
static void time_bar_update_proc(Layer *layer, GContext *ctx) {
graphics_context_set_fill_color(ctx, GColorWhite);
graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone);
}
// define contents of the Window upon load
static void main_window_load(Window *window) {
Layer *window_layer = window_get_root_layer(window);
@@ -165,9 +171,11 @@ static void main_window_load(Window *window) {
// format silly guy layers
s_guy_head_layer = bitmap_layer_create(s_guy_head_grect_on);
s_guy_butt_layer = bitmap_layer_create(s_guy_butt_grect_on);
bitmap_layer_set_background_color(s_guy_head_layer, GColorBlack);
bitmap_layer_set_compositing_mode(s_guy_head_layer, GCompOpSet);
bitmap_layer_set_alignment(s_guy_head_layer, GAlignLeft);
bitmap_layer_set_bitmap(s_guy_head_layer, s_head_current);
bitmap_layer_set_background_color(s_guy_butt_layer, GColorBlack);
bitmap_layer_set_compositing_mode(s_guy_butt_layer, GCompOpSet);
bitmap_layer_set_alignment(s_guy_butt_layer, GAlignTopLeft);
bitmap_layer_set_bitmap(s_guy_butt_layer, s_butt_current);
// format time layer
@@ -182,9 +190,15 @@ static void main_window_load(Window *window) {
text_layer_set_font(s_date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
text_layer_set_text_alignment(s_date_layer, GTextAlignmentLeft);
// create time bar layer
GRect time_bar_frame = GRect(0, PBL_IF_ROUND_ELSE(115, 99), PBL_IF_ROUND_ELSE(260, 200), 30);
s_time_bar_layer = layer_create(time_bar_frame);
layer_set_update_proc(s_time_bar_layer, time_bar_update_proc);
// add layers as children to window
layer_add_child(window_layer, bitmap_layer_get_layer(s_guy_head_layer));
layer_add_child(window_layer, bitmap_layer_get_layer(s_guy_butt_layer));
layer_add_child(window_layer, s_time_bar_layer);
layer_add_child(window_layer, text_layer_get_layer(s_time_layer));
layer_add_child(window_layer, text_layer_get_layer(s_date_layer));
}
@@ -224,6 +238,9 @@ static void init() {
.load = main_window_load,
.unload = main_window_unload});
// set app background color
window_set_background_color(s_main_window, GColorBlack);
// load initial batch of silly guy parts into memory
s_head_current = gbitmap_create_with_resource(s_random_heads[rand() % s_head_count]);
s_butt_current = gbitmap_create_with_resource(s_random_butts[rand() % s_butt_count]);