diff --git a/filmplakat.jpg b/filmplakat.jpg new file mode 100644 index 0000000..9b1c358 Binary files /dev/null and b/filmplakat.jpg differ diff --git a/resources/.DS_Store b/resources/.DS_Store new file mode 100644 index 0000000..9945625 Binary files /dev/null and b/resources/.DS_Store differ diff --git a/resources/src/fonts/.DS_Store b/resources/src/fonts/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/resources/src/fonts/.DS_Store differ diff --git a/resources/src/fonts/roboto/.DS_Store b/resources/src/fonts/roboto/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/resources/src/fonts/roboto/.DS_Store differ diff --git a/resources/src/fonts/roboto/Roboto-BoldItalic_30.ttf b/resources/src/fonts/roboto/Roboto-BoldItalic_35.ttf similarity index 100% rename from resources/src/fonts/roboto/Roboto-BoldItalic_30.ttf rename to resources/src/fonts/roboto/Roboto-BoldItalic_35.ttf diff --git a/resources/src/fonts/roboto/Roboto-Italic_12.ttf b/resources/src/fonts/roboto/Roboto-Italic_13.ttf similarity index 100% rename from resources/src/fonts/roboto/Roboto-Italic_12.ttf rename to resources/src/fonts/roboto/Roboto-Italic_13.ttf diff --git a/resources/src/fonts/roboto/Roboto-Italic_30.ttf b/resources/src/fonts/roboto/Roboto-Italic_33.ttf similarity index 100% rename from resources/src/fonts/roboto/Roboto-Italic_30.ttf rename to resources/src/fonts/roboto/Roboto-Italic_33.ttf diff --git a/resources/src/fonts/roboto/Roboto-LightItalic_28.ttf b/resources/src/fonts/roboto/Roboto-LightItalic_30.ttf similarity index 100% rename from resources/src/fonts/roboto/Roboto-LightItalic_28.ttf rename to resources/src/fonts/roboto/Roboto-LightItalic_30.ttf diff --git a/resources/src/resource_map.json b/resources/src/resource_map.json index cef0de8..8e79ad7 100644 --- a/resources/src/resource_map.json +++ b/resources/src/resource_map.json @@ -9,25 +9,26 @@ }, {"type":"font", "characterRegex": "[einzwdrvfünschbatulö]", - "defName":"FONT_ROBOTO_BOLDITALIC_30", - "file":"fonts/roboto/Roboto-BoldItalic_30.ttf" + "trackingAdjust": -1, + "defName":"FONT_ROBOTO_BOLDITALIC_35", + "file":"fonts/roboto/Roboto-BoldItalic_35.ttf" }, {"type":"font", - "characterRegex": "[einzwdrvfünschbatulög]", + "characterRegex": "[einzwdrvfünschbatulögı]", "trackingAdjust": -2, - "defName":"FONT_ROBOTO_ITALIC_30", - "file":"fonts/roboto/Roboto-Italic_30.ttf" + "defName":"FONT_ROBOTO_ITALIC_33", + "file":"fonts/roboto/Roboto-Italic_33.ttf" }, {"type":"font", "characterRegex": "[uhr]", "trackingAdjust": -2, - "defName":"FONT_ROBOTO_LIGHTITALIC_28", - "file":"fonts/roboto/Roboto-LightItalic_28.ttf" + "defName":"FONT_ROBOTO_LIGHTITALIC_30", + "file":"fonts/roboto/Roboto-LightItalic_30.ttf" }, {"type":"font", "characterRegex": "[0-9 .MDFSJAONoiranuebäzplgstmkv]", - "defName":"FONT_ROBOTO_ITALIC_12", - "file":"fonts/roboto/Roboto-Italic_12.ttf" + "defName":"FONT_ROBOTO_ITALIC_13", + "file":"fonts/roboto/Roboto-Italic_13.ttf" } ] } diff --git a/src/filmplakat.c b/src/filmplakat.c index 811d9b7..130d1f3 100644 --- a/src/filmplakat.c +++ b/src/filmplakat.c @@ -7,7 +7,7 @@ #define MY_UUID { 0x42, 0x35, 0x46, 0xE7, 0x54, 0x18, 0x4F, 0x47, 0x96, 0x63, 0xF0, 0xDB, 0x98, 0x7C, 0x04, 0x40 } PBL_APP_INFO(MY_UUID, "Filmplakat", "lastfuture", - 1, 3, /* App version */ + 2, 0, /* App version */ RESOURCE_ID_IMAGE_MENU_ICON, #if DEBUG APP_INFO_STANDARD_APP @@ -18,24 +18,21 @@ PBL_APP_INFO(MY_UUID, void itoa(int num, char* buffer) { const char digits[11] = "0123456789"; - if(num > 99) { - buffer[0] = '9'; - buffer[1] = '9'; - return; - } else if(num > 9) { + if(num > 9) { buffer[0] = digits[num / 10]; + buffer[1] = digits[num % 10]; } else { - buffer[0] = '0'; + buffer[0] = digits[num % 10]; + buffer[1] = '\0'; } - buffer[1] = digits[num % 10]; } Window window; -TextLayer row_1, row_2, row_3, row_4, row_5; -PropertyAnimation anim_1, anim_2, anim_3, anim_4, anim_5; -static char row_1_buffer[20], row_3_buffer[20], row_4_buffer[20], row_3_oldbuf[20], row_4_oldbuf[20], row_5_buffer[20]; -static int row_1_x, row_2_x, row_3_x, row_4_x, row_5_x, row_1_y, row_2_y, row_3_y, row_4_y, row_5_y; -static bool row_3_asc, row_4_asc, has_row_3, has_row_4, firstblood; +TextLayer row_1, row_1b, row_2, row_3, row_3b, row_4, row_4b, row_5, row_5b; +PropertyAnimation anim_1, anim_1b, anim_2, anim_3, anim_3b, anim_4, anim_4b, anim_5, anim_5b; +static char row_1_buffer[20], row_3_buffer[20], row_4_buffer[20], row_5_buffer[20], row_1_oldbuf[20], row_3_oldbuf[20], row_4_oldbuf[20], row_5_oldbuf[20]; +static int row_1_x, row_2_x, row_3_x, row_4_x, row_5_x, row_1_y, row_2_y, row_3_y, row_4_y, row_5_y, row_1_oldx, row_2_oldx, row_3_oldx, row_4_oldx, row_5_oldx, row_1_oldy, row_2_oldy, row_3_oldy, row_4_oldy, row_5_oldy; +static bool row_3_asc, row_4_asc, has_row_3, has_row_4, firstblood, tenplusone; GFont fontHour, fontUhr, fontMinutes, fontDate; PblTm t; @@ -89,6 +86,28 @@ static const char* TEENS[] = { "achtzehn", "neunzehn", }; +static const char* TEENS_DOTLESS[] = { + "null", + "eın", + "zwei", + "drei", + "vıer", + "fünf", + "sechs", + "sıeben", + "acht", + "neun", + "zehn", + "elf", + "zwölf", + "dreizehn", + "vıerzehn", + "fünfzehn", + "sechzehn", + "sıebzehn", + "achtzehn", + "neunzehn", +}; static const char* TENS[] = { "zwanzig", "dreissig", @@ -96,25 +115,32 @@ static const char* TENS[] = { "fünfzig", "sechzig", }; +static const char* TENS_DOTLESS[] = { + "zwanzıg", + "dreissig", + "vıerzıg", + "fünfzig", + "sechzig", +}; static const bool TEENS_ASC[] = { true, + false, + false, true, false, true, - true, + false, + false, true, false, true, true, false, true, - true, false, true, - true, - true, false, - true, + false, true, false, }; @@ -133,15 +159,15 @@ static const char* STR_S = "s"; static const char* ROW_2_BUFFER = "uhr"; -static const int UHR_ASC = 25; -static const int MINUTES_ASC = 23; -static const int MINUTES2_ASC = 25; -static const int DATE_ASC = 34; +static const int UHR_ASC = 28; +static const int MINUTES_ASC = 25; +static const int MINUTES2_ASC = 28; +static const int DATE_ASC = 36; -static const int MINUTES_X = 3; -static const int MINUTES2_X = 3; +static const int MINUTES_X = 5; +static const int MINUTES2_X = 5; -void setup_text_layer(TextLayer* row, PropertyAnimation *this_anim, int x, int y, int oldx, int oldy, GFont font, int magic){ +void setup_text_layer(TextLayer* row, PropertyAnimation *this_anim, int x, int y, int oldx, int oldy, GFont font, int magic, bool delayed){ text_layer_set_text_color(row, GColorWhite); text_layer_set_background_color(row, GColorClear); layer_add_child(&window.layer, &row->layer); @@ -154,8 +180,12 @@ void setup_text_layer(TextLayer* row, PropertyAnimation *this_anim, int x, int y if (firstblood) { speed = 600; + } else if (x == -144) { + speed = 1400; + } else if (oldx == 144) { + speed = 1000; } else { - speed = distance * 90; + speed = 500; } GRect start_rect = GRect(oldx,oldy,144-oldx-1,50); @@ -163,25 +193,28 @@ void setup_text_layer(TextLayer* row, PropertyAnimation *this_anim, int x, int y if (magic == 1) { // disappear start_rect = GRect(oldx,oldy,144-oldx-1,50); - target_rect = GRect(oldx,oldy,144-x-1,0); - speed = 300; + target_rect = GRect(-114,oldy,144-oldx-1,50); } else if (magic == 2) { // reappear - start_rect = GRect(x,y,144-oldx-1,0); + start_rect = GRect(144,y,144-x-1,50); target_rect = GRect(x,y,144-x-1,50); } else if (magic == 3) { // and stay down - start_rect = GRect(oldx,oldy,144-oldx-1,0); - target_rect = GRect(x,y,144-x-1,0); - speed = 100; + start_rect = GRect(0,0,0,0); + target_rect = GRect(0,0,0,0); + speed = 1; } else { } - layer_set_frame(&row->layer, start_rect); - property_animation_init_layer_frame(this_anim, &row->layer, NULL, &target_rect); - - animation_set_duration(&this_anim->animation, speed); - animation_set_curve(&this_anim->animation, AnimationCurveEaseInOut); - - animation_schedule(&this_anim->animation); + if (magic != 3) { + layer_set_frame(&row->layer, start_rect); + property_animation_init_layer_frame(this_anim, &row->layer, NULL, &target_rect); + + animation_set_duration(&this_anim->animation, speed); + animation_set_curve(&this_anim->animation, AnimationCurveEaseInOut); + if (delayed) { + animation_set_delay(&this_anim->animation, 100); + } + animation_schedule(&this_anim->animation); + } } void GetTime(int hours, int minutes, int day, int month, int weekday){ @@ -193,28 +226,49 @@ void GetTime(int hours, int minutes, int day, int month, int weekday){ if (hours == 12) { hours12h = 12; } strcat(row_1_buffer, TEENS[hours12h]); + tenplusone = false; + if (minutes == 0) { } else if (minutes < 20) { - strcat(row_3_buffer, TEENS[minutes]); + row_3_asc = TEENS_ASC[minutes]; + if (row_3_asc == false) { + strcat(row_3_buffer, TEENS_DOTLESS[minutes]); + } else { + strcat(row_3_buffer, TEENS[minutes]); + } if (minutes == 1) { strcat(row_3_buffer, STR_S); } has_row_3 = true; - row_3_asc = TEENS_ASC[minutes]; } else { int tenner = minutes/10; int oner = minutes % 10; if (oner == 0) { - strcat(row_3_buffer, TENS[tenner-2]); row_3_asc = TENS_ASC[tenner-2]; + if (row_3_asc == false && tenner!=2) { + strcat(row_3_buffer, TENS_DOTLESS[tenner-2]); + } else { + strcat(row_3_buffer, TENS[tenner-2]); + } has_row_3 = true; } else { - strcat(row_3_buffer, TEENS[oner]); - strcat(row_3_buffer, STR_UND); + if (oner == 1) { + tenplusone = true; + } row_3_asc = TEENS_ASC[oner]; + if (row_3_asc == false) { + strcat(row_3_buffer, TEENS_DOTLESS[oner]); + } else { + strcat(row_3_buffer, TEENS[oner]); + } + strcat(row_3_buffer, STR_UND); has_row_3 = true; - strcat(row_4_buffer, TENS[tenner-2]); row_4_asc = TENS_ASC[tenner-2]; + if (row_4_asc == false) { + strcat(row_4_buffer, TENS_DOTLESS[tenner-2]); + } else { + strcat(row_4_buffer, TENS[tenner-2]); + } has_row_4 = true; } } @@ -231,11 +285,15 @@ void GetTime(int hours, int minutes, int day, int month, int weekday){ void update_time(PblTm* t){ + memset(row_1_oldbuf,0,20); memset(row_3_oldbuf,0,20); memset(row_4_oldbuf,0,20); + memset(row_5_oldbuf,0,20); + strcat(row_1_oldbuf,row_1_buffer); strcat(row_3_oldbuf,row_3_buffer); strcat(row_4_oldbuf,row_4_buffer); + strcat(row_5_oldbuf,row_5_buffer); memset(row_1_buffer,0,20); memset(row_3_buffer,0,20); @@ -248,23 +306,24 @@ void update_time(PblTm* t){ strcat(row_1_buffer, STR_SPACE); // workaround for weird "z" bug GetTime(t->tm_hour,t->tm_min,t->tm_mday,t->tm_mon,t->tm_wday); + //GetTime(7,57,2,8,0); // longest strings? //GetTime(t->tm_hour,t->tm_sec,t->tm_mday,t->tm_mon,t->tm_wday); int spacing = 0; - int row_1_oldx = row_1_x; - int row_2_oldx = row_2_x; - int row_3_oldx = row_3_x; - int row_4_oldx = row_4_x; - int row_5_oldx = row_5_x; + row_1_oldx = row_1_x; + row_2_oldx = row_2_x; + row_3_oldx = row_3_x; + row_4_oldx = row_4_x; + row_5_oldx = row_5_x; - int row_1_oldy = row_1_y; - int row_2_oldy = row_2_y; - int row_3_oldy = row_3_y; - int row_4_oldy = row_4_y; - int row_5_oldy = row_5_y; + row_1_oldy = row_1_y; + row_2_oldy = row_2_y; + row_3_oldy = row_3_y; + row_4_oldy = row_4_y; + row_5_oldy = row_5_y; - row_1_x = row_2_x = row_3_x = row_4_x = row_5_x = 26; + row_1_x = row_2_x = row_3_x = row_4_x = row_5_x = 20; row_1_y = spacing; spacing += UHR_ASC; @@ -326,13 +385,26 @@ void update_time(PblTm* t){ } - setup_text_layer(&row_1,&anim_1,row_1_x,row_1_y,row_1_oldx,row_1_oldy,fontHour,0); - text_layer_set_text(&row_1,row_1_buffer); + int magic = 0; + bool haschanged = false; - setup_text_layer(&row_2,&anim_2,row_2_x,row_2_y,row_2_oldx,row_2_oldy,fontUhr,0); + if (strcmp(row_1_oldbuf,row_1_buffer)) { haschanged = true; } else { haschanged = false; } + + if (haschanged && firstblood != true) { + setup_text_layer(&row_1,&anim_1,-144,row_1_oldy,row_1_oldx,row_1_oldy,fontHour,0,false); + text_layer_set_text(&row_1,row_1_oldbuf); + setup_text_layer(&row_1b,&anim_1b,row_1_x,row_1_y,144,row_1_y,fontHour,magic,true); + text_layer_set_text(&row_1b,row_1_buffer); + } else { + setup_text_layer(&row_1,&anim_1,row_1_x,row_1_y,row_1_oldx,row_1_oldy,fontHour,0,true); + text_layer_set_text(&row_1,row_1_buffer); + text_layer_set_text(&row_1b,STR_SPACE); + } + + setup_text_layer(&row_2,&anim_2,row_2_x,row_2_y,row_2_oldx,row_2_oldy,fontUhr,0,false); text_layer_set_text(&row_2,ROW_2_BUFFER); - int magic = 0; + if (strcmp(row_3_oldbuf,row_3_buffer)) { haschanged = true; } else { haschanged = false; } if (has_row_3 == has_row_3_old && has_row_3 == true) { magic = 0; @@ -343,12 +415,34 @@ void update_time(PblTm* t){ } else if (has_row_3 != has_row_3_old && has_row_3 == true) { magic = 2; // reappear } - setup_text_layer(&row_3,&anim_3,row_3_x,row_3_y,row_3_oldx,row_3_oldy,fontMinutes,magic); - if (magic == 1) { - text_layer_set_text(&row_3,row_3_oldbuf); + if (magic == 0) { + if (haschanged) { + if (tenplusone) { + setup_text_layer(&row_3,&anim_3,row_3_x,row_3_y,144,row_3_y,fontMinutes,magic,true); + text_layer_set_text(&row_3,row_3_buffer); + text_layer_set_text(&row_3b,STR_SPACE); + } else { + setup_text_layer(&row_3,&anim_3,-144,row_3_oldy,row_3_oldx,row_3_oldy,fontMinutes,magic,false); + text_layer_set_text(&row_3,row_3_oldbuf); + setup_text_layer(&row_3b,&anim_3b,row_3_x,row_3_y,144,row_3_y,fontMinutes,magic,true); + text_layer_set_text(&row_3b,row_3_buffer); + } + } else { + setup_text_layer(&row_3,&anim_3,row_3_x,row_3_y,row_3_oldx,row_3_oldy,fontMinutes,magic,false); + text_layer_set_text(&row_3,row_3_buffer); + text_layer_set_text(&row_3b,STR_SPACE); + } } else { - text_layer_set_text(&row_3,row_3_buffer); + setup_text_layer(&row_3,&anim_3,row_3_x,row_3_y,row_3_oldx,row_3_oldy,fontMinutes,magic,false); + if (magic == 1) { + text_layer_set_text(&row_3,row_3_oldbuf); + } else { + text_layer_set_text(&row_3,row_3_buffer); + } + text_layer_set_text(&row_3b,STR_SPACE); } + + if (strcmp(row_4_oldbuf,row_4_buffer)) { haschanged = true; } else { haschanged = false; } if (has_row_4 == has_row_4_old && has_row_4 == true) { magic = 0; @@ -359,15 +453,43 @@ void update_time(PblTm* t){ } else if (has_row_4 != has_row_4_old && has_row_4 == true) { magic = 2; // reappear } - setup_text_layer(&row_4,&anim_4,row_4_x,row_4_y,row_4_oldx,row_4_oldy,fontMinutes,magic); - if (magic == 1) { - text_layer_set_text(&row_4,row_4_oldbuf); - } else { + if (tenplusone) { + setup_text_layer(&row_4,&anim_4,row_4_x,row_4_y,row_3_oldx,row_3_oldy,fontMinutes,0,false); text_layer_set_text(&row_4,row_4_buffer); + text_layer_set_text(&row_4b,STR_SPACE); + } else if (magic == 0) { + if (haschanged) { + setup_text_layer(&row_4,&anim_4,-144,row_4_oldy,row_4_oldx,row_4_oldy,fontMinutes,magic,false); + text_layer_set_text(&row_4,row_4_oldbuf); + setup_text_layer(&row_4b,&anim_4b,row_4_x,row_4_y,144,row_4_y,fontMinutes,magic,true); + text_layer_set_text(&row_4b,row_4_buffer); + } else { + setup_text_layer(&row_4,&anim_4,row_4_x,row_4_y,row_4_oldx,row_4_oldy,fontMinutes,magic,false); + text_layer_set_text(&row_4,row_4_buffer); + text_layer_set_text(&row_4b,STR_SPACE); + } + } else { + setup_text_layer(&row_4,&anim_4,row_4_x,row_4_y,row_4_oldx,row_4_oldy,fontMinutes,magic,false); + if (magic == 1) { + text_layer_set_text(&row_4,row_4_oldbuf); + } else { + text_layer_set_text(&row_4,row_4_buffer); + } + text_layer_set_text(&row_4b,STR_SPACE); } - setup_text_layer(&row_5,&anim_5,row_5_x,row_5_y,row_5_oldx,row_5_oldy,fontDate,0); - text_layer_set_text(&row_5,row_5_buffer); + if (strcmp(row_5_oldbuf,row_5_buffer)) { haschanged = true; } else { haschanged = false; } + + if (haschanged && firstblood != true) { + setup_text_layer(&row_5,&anim_5,-144,row_5_oldy,row_5_oldx,row_5_oldy,fontDate,0,false); + text_layer_set_text(&row_5,row_5_oldbuf); + setup_text_layer(&row_5b,&anim_5b,row_5_x,row_5_y,144,row_5_y,fontDate,magic,true); + text_layer_set_text(&row_5b,row_5_buffer); + } else { + setup_text_layer(&row_5,&anim_5,row_5_x,row_5_y,row_5_oldx,row_5_oldy,fontDate,0,true); + text_layer_set_text(&row_5,row_5_buffer); + text_layer_set_text(&row_5b,STR_SPACE); + } if (firstblood) { firstblood = false; @@ -389,27 +511,25 @@ void handle_init(AppContextRef ctx) { window_set_background_color(&window, GColorBlack); resource_init_current_app(&APP_RESOURCES); - fontHour = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLDITALIC_30)); - fontUhr = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_LIGHTITALIC_28)); - fontMinutes = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_ITALIC_30)); - fontDate = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_ITALIC_12)); + fontHour = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLDITALIC_35)); + fontUhr = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_LIGHTITALIC_30)); + fontMinutes = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_ITALIC_33)); + fontDate = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_ITALIC_13)); + memset(row_1_buffer,0,20); memset(row_3_buffer,0,20); memset(row_4_buffer,0,20); + memset(row_5_buffer,0,20); - row_1_x = row_2_x = row_3_x = row_4_x = row_5_x = 13; - row_1_y = row_2_y = row_3_y = row_4_y = row_5_y = 168/2; - row_1_y -= 30; - row_2_y -= 10; - row_3_y += 10; - row_4_y += 30; - row_5_y += 50; - - text_layer_init(&row_5, window.layer.frame); - text_layer_init(&row_4, window.layer.frame); - text_layer_init(&row_3, window.layer.frame); - text_layer_init(&row_2, window.layer.frame); text_layer_init(&row_1, window.layer.frame); + text_layer_init(&row_2, window.layer.frame); + text_layer_init(&row_3, window.layer.frame); + text_layer_init(&row_4, window.layer.frame); + text_layer_init(&row_5, window.layer.frame); + text_layer_init(&row_1b, window.layer.frame); + text_layer_init(&row_3b, window.layer.frame); + text_layer_init(&row_4b, window.layer.frame); + text_layer_init(&row_5b, window.layer.frame); get_time(&t); }