finished configurability of tape date and time display positions
authorHolger Schemel <info@artsoft.org>
Tue, 3 Feb 2015 15:18:09 +0000 (16:18 +0100)
committerHolger Schemel <info@artsoft.org>
Tue, 3 Feb 2015 15:19:59 +0000 (16:19 +0100)
ChangeLog
build-scripts/create_element_defs.pl
src/conf_gfx.c
src/conf_var.c
src/tape.c
src/tape.h

index 8a8d07361994fbd21109460f419b6f1701f3d223..b374cd42a42eb7609e6a53b05ae158446ac354b4 100644 (file)
--- 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)
 
index 8c097551a790a5c1f643d1640c5edb958c2d96d6..06e1897217dcd9a9097d25a382289cc67fd6dbd3 100755 (executable)
@@ -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/;
index 96ff7825da2219bf8aedc4ddb73c64822cb1cf16..b3b4c32b523e66cd360e2e14fda3349da3ccafe1 100644 (file)
@@ -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"                  },
index 4e06b2d24e052c69353f13a9ce2a9d8cd85e28f3..b4f3f0eff00fbe842c4b3314b1813b98b8b75125 100644 (file)
@@ -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",
index 9de9839b5f2608b77108f742418df5229e31f11d..6ef7cf4c197a1ca1c79386c5f6260a11793417f8 100644 (file)
@@ -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;
 }
index d1b60330484758f17e7e3b680c03a9070132007b..6b536fb1901baa68dedefdf1bbc649301c1328cc 100644 (file)
@@ -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;