Store combinations on face close
This commit is contained in:
@@ -17,7 +17,6 @@ Since the original watchface is **NOT** open source, this "port" could be more a
|
|||||||
- The original [Maan On My Wrist](https://apps.rebble.io/en_US/application/557724772d93bc0eae00004c?native=false&query=maan§ion=watchfaces) is still perfectly silly on b&w screens!
|
- The original [Maan On My Wrist](https://apps.rebble.io/en_US/application/557724772d93bc0eae00004c?native=false&query=maan§ion=watchfaces) is still perfectly silly on b&w screens!
|
||||||
|
|
||||||
# Considerations For The Future
|
# Considerations For The Future
|
||||||
- Restore last combo after using an app
|
|
||||||
- Add more Maan art (see [this gallery](https://www.flickr.com/photos/53297919@N04/albums/72157624708812279) for potential candidates)
|
- Add more Maan art (see [this gallery](https://www.flickr.com/photos/53297919@N04/albums/72157624708812279) for potential candidates)
|
||||||
- Potential light mode (don't hold your breath - I'm still not sure this would look good and I don't like the idea of having settings)
|
- Potential light mode (don't hold your breath - I'm still not sure this would look good and I don't like the idea of having settings)
|
||||||
- Black&white support if I get bored or Pebble releases a modern b&w watch (Flint doesn't count)
|
- Black&white support if I get bored or Pebble releases a modern b&w watch (Flint doesn't count)
|
||||||
|
|||||||
34
src/c/main.c
34
src/c/main.c
@@ -119,6 +119,10 @@ static const GColor8 s_dark_bg_colors[] = {
|
|||||||
GColorBrilliantRose, GColorMelon, GColorShockingPink,
|
GColorBrilliantRose, GColorMelon, GColorShockingPink,
|
||||||
// Brown
|
// Brown
|
||||||
GColorRoseVale};
|
GColorRoseVale};
|
||||||
|
#define storage_key_head 0
|
||||||
|
#define storage_key_butt 1
|
||||||
|
#define storage_key_color 2
|
||||||
|
static uint8_t s_head_index, s_butt_index;
|
||||||
|
|
||||||
static void destroy_animation_handler(Animation *animation, bool finished, void *context) {
|
static void destroy_animation_handler(Animation *animation, bool finished, void *context) {
|
||||||
animation_destroy(animation);
|
animation_destroy(animation);
|
||||||
@@ -207,7 +211,8 @@ static void schedule_guy_animation(Animation *raise_tmpl, Animation *out_tmpl, A
|
|||||||
static void update_minute_30_out_handler(Animation *animation, bool finished, void *context) {
|
static void update_minute_30_out_handler(Animation *animation, bool finished, void *context) {
|
||||||
// destroy and reassign
|
// destroy and reassign
|
||||||
gbitmap_destroy(s_butt);
|
gbitmap_destroy(s_butt);
|
||||||
s_butt = gbitmap_create_with_resource(s_random_butts[rand() % s_butt_count]);
|
s_butt_index = rand() % s_butt_count;
|
||||||
|
s_butt = gbitmap_create_with_resource(s_random_butts[s_butt_index]);
|
||||||
|
|
||||||
// swap colors
|
// swap colors
|
||||||
replace_gbitmap_color(GColorGreen, s_random_color_next, s_butt, NULL);
|
replace_gbitmap_color(GColorGreen, s_random_color_next, s_butt, NULL);
|
||||||
@@ -228,7 +233,8 @@ static void update_minute_30() {
|
|||||||
static void update_minute_60_out_handler(Animation *animation, bool finished, void *context) {
|
static void update_minute_60_out_handler(Animation *animation, bool finished, void *context) {
|
||||||
// destroy and reassign
|
// destroy and reassign
|
||||||
gbitmap_destroy(s_head);
|
gbitmap_destroy(s_head);
|
||||||
s_head = gbitmap_create_with_resource(s_random_heads[rand() % s_head_count]);
|
s_head_index = rand() % s_head_count;
|
||||||
|
s_head = gbitmap_create_with_resource(s_random_heads[s_head_index]);
|
||||||
|
|
||||||
// swap colors
|
// swap colors
|
||||||
replace_gbitmap_color(GColorGreen, s_random_color_next, s_head, NULL);
|
replace_gbitmap_color(GColorGreen, s_random_color_next, s_head, NULL);
|
||||||
@@ -379,15 +385,22 @@ static void init() {
|
|||||||
window_set_background_color(s_main_window, GColorBlack);
|
window_set_background_color(s_main_window, GColorBlack);
|
||||||
|
|
||||||
// load initial batch of silly guy parts into memory
|
// load initial batch of silly guy parts into memory
|
||||||
s_head = gbitmap_create_with_resource(s_random_heads[rand() % s_head_count]);
|
if (persist_exists(storage_key_color)) {
|
||||||
s_butt = gbitmap_create_with_resource(s_random_butts[rand() % s_butt_count]);
|
s_head_index = persist_read_int(storage_key_head);
|
||||||
|
s_butt_index = persist_read_int(storage_key_butt);
|
||||||
// pick starting colors
|
s_random_color_current = (GColor8){.argb = persist_read_int(storage_key_color)};
|
||||||
|
} else {
|
||||||
|
s_head_index = rand() % s_head_count;
|
||||||
|
s_butt_index = rand() % s_butt_count;
|
||||||
s_random_color_current = s_dark_bg_colors[rand() % s_color_count];
|
s_random_color_current = s_dark_bg_colors[rand() % s_color_count];
|
||||||
|
}
|
||||||
|
s_head = gbitmap_create_with_resource(s_random_heads[s_head_index]);
|
||||||
|
s_butt = gbitmap_create_with_resource(s_random_butts[s_butt_index]);
|
||||||
|
|
||||||
|
// set starting colors
|
||||||
|
s_random_color_next = s_dark_bg_colors[rand() % s_color_count];
|
||||||
replace_gbitmap_color(GColorGreen, s_random_color_current, s_head, NULL);
|
replace_gbitmap_color(GColorGreen, s_random_color_current, s_head, NULL);
|
||||||
replace_gbitmap_color(GColorGreen, s_random_color_current, s_butt, NULL);
|
replace_gbitmap_color(GColorGreen, s_random_color_current, s_butt, NULL);
|
||||||
// don't overwrite current color, as it will need to be replaced
|
|
||||||
s_random_color_next = s_dark_bg_colors[rand() % s_color_count];
|
|
||||||
|
|
||||||
// load custom font
|
// load custom font
|
||||||
#if PBL_DISPLAY_WIDTH <= 180
|
#if PBL_DISPLAY_WIDTH <= 180
|
||||||
@@ -489,6 +502,11 @@ static void deinit() {
|
|||||||
gbitmap_destroy(s_bt0_icon);
|
gbitmap_destroy(s_bt0_icon);
|
||||||
gbitmap_destroy(s_bt1_icon);
|
gbitmap_destroy(s_bt1_icon);
|
||||||
|
|
||||||
|
// write to persistent storage
|
||||||
|
persist_write_int(storage_key_head, s_head_index);
|
||||||
|
persist_write_int(storage_key_butt, s_butt_index);
|
||||||
|
persist_write_int(storage_key_color, s_random_color_current.argb);
|
||||||
|
|
||||||
// destroy window
|
// destroy window
|
||||||
window_destroy(s_main_window);
|
window_destroy(s_main_window);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user