From 3955631c5325e8e342c1af734c3ca1ad6a425726 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 3 Feb 2015 16:18:09 +0100 Subject: [PATCH] finished configurability of tape date and time display positions --- ChangeLog | 3 + build-scripts/create_element_defs.pl | 1 + src/conf_gfx.c | 16 +-- src/conf_var.c | 28 ++--- src/tape.c | 154 ++++++++++++++++++++++----- src/tape.h | 2 +- 6 files changed, 152 insertions(+), 52 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8a8d0736..b374cd42 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2015-02-03 + * finished configurability of tape date and time display positions + 2015-02-02 * fixed configurability of editor element palette (for columns != 4) diff --git a/build-scripts/create_element_defs.pl b/build-scripts/create_element_defs.pl index 8c097551..06e18972 100755 --- a/build-scripts/create_element_defs.pl +++ b/build-scripts/create_element_defs.pl @@ -2391,6 +2391,7 @@ sub print_image_config_vars # --- some suffix replacements --- $var =~ s/^(menu\.main\..*)\.chars$/$1.size/; + $var =~ s/^(tape\.text\..*)\.chars$/$1.size/; $var =~ s/^(game\.panel\..*)\.chars$/$1.size/; $var =~ s/^(game\.panel\..*)\.tile_size$/$1.size/; $var =~ s/^(request\.button\..*)\.tile_size$/$1.size/; diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 96ff7825..b3b4c32b 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -7106,7 +7106,7 @@ struct ConfigInfo image_config[] = { "tape.text.date_yyyy.y", "-1" }, { "tape.text.date_yyyy.align", "left" }, { "tape.text.date_yyyy.valign", "top" }, - { "tape.text.date_yyyy.digits", "2" }, + { "tape.text.date_yyyy.digits", "4" }, { "tape.text.date_yyyy.font", "font.tape_recorder" }, { "tape.text.date_yyyy.draw_masked", "true" }, { "tape.text.date_yy.x", "-1" }, @@ -7116,13 +7116,13 @@ struct ConfigInfo image_config[] = { "tape.text.date_yy.digits", "2" }, { "tape.text.date_yy.font", "font.tape_recorder" }, { "tape.text.date_yy.draw_masked", "true" }, - { "tape.text.date_mmm.x", "-1" }, - { "tape.text.date_mmm.y", "-1" }, - { "tape.text.date_mmm.align", "left" }, - { "tape.text.date_mmm.valign", "top" }, - { "tape.text.date_mmm.digits", "2" }, - { "tape.text.date_mmm.font", "font.tape_recorder" }, - { "tape.text.date_mmm.draw_masked", "true" }, + { "tape.text.date_mon.x", "-1" }, + { "tape.text.date_mon.y", "-1" }, + { "tape.text.date_mon.align", "left" }, + { "tape.text.date_mon.valign", "top" }, + { "tape.text.date_mon.chars", "3" }, + { "tape.text.date_mon.font", "font.tape_recorder" }, + { "tape.text.date_mon.draw_masked", "true" }, { "tape.text.date_mm.x", "-1" }, { "tape.text.date_mm.y", "-1" }, { "tape.text.date_mm.align", "left" }, diff --git a/src/conf_var.c b/src/conf_var.c index 4e06b2d2..b4f3f0ef 100644 --- a/src/conf_var.c +++ b/src/conf_var.c @@ -6135,32 +6135,32 @@ struct TokenIntPtrInfo image_config_vars[] = &tape.text.date_yy.draw_masked }, { - "tape.text.date_mmm.x", - &tape.text.date_mmm.x + "tape.text.date_mon.x", + &tape.text.date_mon.x }, { - "tape.text.date_mmm.y", - &tape.text.date_mmm.y + "tape.text.date_mon.y", + &tape.text.date_mon.y }, { - "tape.text.date_mmm.align", - &tape.text.date_mmm.align + "tape.text.date_mon.align", + &tape.text.date_mon.align }, { - "tape.text.date_mmm.valign", - &tape.text.date_mmm.valign + "tape.text.date_mon.valign", + &tape.text.date_mon.valign }, { - "tape.text.date_mmm.digits", - &tape.text.date_mmm.size + "tape.text.date_mon.chars", + &tape.text.date_mon.size }, { - "tape.text.date_mmm.font", - &tape.text.date_mmm.font + "tape.text.date_mon.font", + &tape.text.date_mon.font }, { - "tape.text.date_mmm.draw_masked", - &tape.text.date_mmm.draw_masked + "tape.text.date_mon.draw_masked", + &tape.text.date_mon.draw_masked }, { "tape.text.date_mm.x", diff --git a/src/tape.c b/src/tape.c index 9de9839b..6ef7cf4c 100644 --- a/src/tape.c +++ b/src/tape.c @@ -186,14 +186,9 @@ static struct GadgetInfo *tape_gadget[NUM_TAPE_BUTTONS]; /* video display functions */ /* ========================================================================= */ -void DrawVideoDisplay(unsigned int state, unsigned int value) +static void DrawVideoDisplay_Graphics(unsigned int state, unsigned int value) { int i, j, k; - static char *monatsname[12] = - { - "JAN", "FEB", "MAR", "APR", "MAY", "JUN", - "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" - }; static struct { @@ -289,35 +284,136 @@ void DrawVideoDisplay(unsigned int state, unsigned int value) } } } +} + + +#define DATETIME_NONE (0) + +#define DATETIME_DATE_YYYY (1 << 0) +#define DATETIME_DATE_YY (1 << 1) +#define DATETIME_DATE_MON (1 << 2) +#define DATETIME_DATE_MM (1 << 3) +#define DATETIME_DATE_DD (1 << 4) + +#define DATETIME_TIME_HH (1 << 5) +#define DATETIME_TIME_MIN (1 << 6) +#define DATETIME_TIME_MM (1 << 7) +#define DATETIME_TIME_SS (1 << 8) + +#define DATETIME_XOFFSET_1 (1 << 9) +#define DATETIME_XOFFSET_2 (1 << 10) - if (state & VIDEO_STATE_DATE_ON) +#define DATETIME_DATE (DATETIME_DATE_YYYY | \ + DATETIME_DATE_YY | \ + DATETIME_DATE_MON | \ + DATETIME_DATE_MM | \ + DATETIME_DATE_DD) + +#define DATETIME_TIME (DATETIME_TIME_HH | \ + DATETIME_TIME_MIN | \ + DATETIME_TIME_MM | \ + DATETIME_TIME_SS) + +#define MAX_DATETIME_STRING_SIZE 32 + +static void DrawVideoDisplay_DateTime(unsigned int state, unsigned int value) +{ + int i; + + static char *month_shortnames[] = { - struct TextPosInfo *pos = &tape.text.date; - int tag = value % 100; - int monat = (value / 100) % 100; - int jahr = (value / 10000); - int xpos1 = VX + pos->x; - int xpos2 = VX + pos->x + pos->xoffset; - int xpos3 = VX + pos->x + pos->xoffset2; - int ypos = VY + pos->y; - - DrawText(xpos1, ypos, int2str(tag, 2), pos->font); - DrawText(xpos2, ypos, monatsname[monat], pos->font); - DrawText(xpos3, ypos, int2str(jahr, 2), pos->font); + "JAN", + "FEB", + "MAR", + "APR", + "MAY", + "JUN", + "JUL", + "AUG", + "SEP", + "OCT", + "NOV", + "DEC" + }; + + static struct + { + struct TextPosInfo *pos; + int type; } + datetime_info[] = + { + { &tape.text.date, DATETIME_DATE_DD }, + { &tape.text.date, DATETIME_DATE_MON | DATETIME_XOFFSET_1 }, + { &tape.text.date, DATETIME_DATE_YY | DATETIME_XOFFSET_2 }, + { &tape.text.date_yyyy, DATETIME_DATE_YYYY }, + { &tape.text.date_yy, DATETIME_DATE_YY }, + { &tape.text.date_mon, DATETIME_DATE_MON }, + { &tape.text.date_mm, DATETIME_DATE_MM }, + { &tape.text.date_dd, DATETIME_DATE_DD }, + + { &tape.text.time, DATETIME_TIME_MIN }, + { &tape.text.time, DATETIME_TIME_SS | DATETIME_XOFFSET_1 }, + { &tape.text.time_hh, DATETIME_TIME_HH }, + { &tape.text.time_mm, DATETIME_TIME_MM }, + { &tape.text.time_ss, DATETIME_TIME_SS }, + + { NULL, DATETIME_NONE }, + }; - if (state & VIDEO_STATE_TIME_ON) + for (i = 0; datetime_info[i].pos != NULL; i++) { - struct TextPosInfo *pos = &tape.text.time; - int min = value / 60; - int sec = value % 60; - int xpos1 = VX + pos->x; - int xpos2 = VX + pos->x + pos->xoffset; - int ypos = VY + pos->y; - - DrawText(xpos1, ypos, int2str(min, 2), pos->font); - DrawText(xpos2, ypos, int2str(sec, 2), pos->font); + struct TextPosInfo *pos = datetime_info[i].pos; + int type = datetime_info[i].type; + int xpos, ypos; + + if (pos->x == -1 && + pos->y == -1) + continue; + + xpos = VX + pos->x + (type & DATETIME_XOFFSET_1 ? pos->xoffset : + type & DATETIME_XOFFSET_2 ? pos->xoffset2 : 0); + ypos = VY + pos->y; + + if ((type & DATETIME_DATE) && (state & VIDEO_STATE_DATE_ON)) + { + char s[MAX_DATETIME_STRING_SIZE]; + int year2 = value / 10000; + int year4 = (year2 < 70 ? 2000 + year2 : 1900 + year2); + int month_index = (value / 100) % 100; + int month = month_index + 1; + int day = value % 100; + + strcpy(s, (type & DATETIME_DATE_YYYY ? int2str(year4, 4) : + type & DATETIME_DATE_YY ? int2str(year2, 2) : + type & DATETIME_DATE_MON ? month_shortnames[month_index] : + type & DATETIME_DATE_MM ? int2str(month, 2) : + type & DATETIME_DATE_DD ? int2str(day, 2) : "")); + + DrawText(xpos, ypos, s, pos->font); + } + else if ((type & DATETIME_TIME) && (state & VIDEO_STATE_TIME_ON)) + { + char s[MAX_DATETIME_STRING_SIZE]; + int hh = (value / 3600) % 100; + int min = value / 60; + int mm = (value / 60) % 60; + int ss = value % 60; + + strcpy(s, (type & DATETIME_TIME_HH ? int2str(hh, 2) : + type & DATETIME_TIME_MIN ? int2str(min, 2) : + type & DATETIME_TIME_MM ? int2str(mm, 2) : + type & DATETIME_TIME_SS ? int2str(ss, 2) : "")); + + DrawText(xpos, ypos, s, pos->font); + } } +} + +void DrawVideoDisplay(unsigned int state, unsigned int value) +{ + DrawVideoDisplay_Graphics(state, value); + DrawVideoDisplay_DateTime(state, value); redraw_mask |= REDRAW_DOOR_2; } diff --git a/src/tape.h b/src/tape.h index d1b60330..6b536fb1 100644 --- a/src/tape.h +++ b/src/tape.h @@ -135,7 +135,7 @@ struct TapeTextInfo struct TextPosInfo date; struct TextPosInfo date_yyyy; struct TextPosInfo date_yy; - struct TextPosInfo date_mmm; + struct TextPosInfo date_mon; struct TextPosInfo date_mm; struct TextPosInfo date_dd; -- 2.34.1