rnd-19990122-1
authorHolger Schemel <info@artsoft.org>
Fri, 22 Jan 1999 18:17:04 +0000 (19:17 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:33:07 +0000 (10:33 +0200)
src/editor.c
src/files.c
src/init.c
src/main.h
src/misc.c
src/misc.h
src/screens.c
src/tools.c

index d7f0f4df364d76313f244891836cd4e6d4bda8c6..8570bd199ce47bf9083e7f0bb6d6688e415d1009 100644 (file)
 #define ED_COUNT_ELEM_SCORE_YPOS       (14 * MINI_TILEY)
 #define ED_COUNT_ELEM_CONTENT_XPOS     ED_PROPERTIES_XPOS
 #define ED_COUNT_ELEM_CONTENT_YPOS     (17 * MINI_TILEY)
-
+#define ED_COUNTER_YSTART              (ED_LEVELINFO_YPOS + 3 * TILEY)
+#define ED_COUNTER_YDISTANCE           (3 * MINI_TILEY)
+#define ED_COUNTER_YPOS(n)             (ED_COUNTER_YSTART + \
+                                        n * ED_COUNTER_YDISTANCE)
 /* standard distances */
 #define ED_BORDER_SIZE                 3
 #define ED_GADGET_DISTANCE             2
 #define ED_CTRL_ID_LEVEL_YSIZE_DOWN    31
 #define ED_CTRL_ID_LEVEL_YSIZE_TEXT    32
 #define ED_CTRL_ID_LEVEL_YSIZE_UP      33
-#define ED_CTRL_ID_LEVEL_COLLECT_DOWN  34
-#define ED_CTRL_ID_LEVEL_COLLECT_TEXT  35
-#define ED_CTRL_ID_LEVEL_COLLECT_UP    36
-#define ED_CTRL_ID_LEVEL_TIMELIMIT_DOWN        37
-#define ED_CTRL_ID_LEVEL_TIMELIMIT_TEXT        38
-#define ED_CTRL_ID_LEVEL_TIMELIMIT_UP  39
-#define ED_CTRL_ID_LEVEL_TIMESCORE_DOWN        40
-#define ED_CTRL_ID_LEVEL_TIMESCORE_TEXT        41
-#define ED_CTRL_ID_LEVEL_TIMESCORE_UP  42
+#define ED_CTRL_ID_LEVEL_RANDOM_DOWN   34
+#define ED_CTRL_ID_LEVEL_RANDOM_TEXT   35
+#define ED_CTRL_ID_LEVEL_RANDOM_UP     36
+#define ED_CTRL_ID_LEVEL_COLLECT_DOWN  37
+#define ED_CTRL_ID_LEVEL_COLLECT_TEXT  38
+#define ED_CTRL_ID_LEVEL_COLLECT_UP    39
+#define ED_CTRL_ID_LEVEL_TIMELIMIT_DOWN        40
+#define ED_CTRL_ID_LEVEL_TIMELIMIT_TEXT        41
+#define ED_CTRL_ID_LEVEL_TIMELIMIT_UP  42
+#define ED_CTRL_ID_LEVEL_TIMESCORE_DOWN        43
+#define ED_CTRL_ID_LEVEL_TIMESCORE_TEXT        44
+#define ED_CTRL_ID_LEVEL_TIMESCORE_UP  45
 
 /* drawing area identifiers */
-#define ED_CTRL_ID_DRAWING_LEVEL       43
-#define ED_CTRL_ID_ELEM_CONTENT_0      44
-#define ED_CTRL_ID_ELEM_CONTENT_1      45
-#define ED_CTRL_ID_ELEM_CONTENT_2      46
-#define ED_CTRL_ID_ELEM_CONTENT_3      47
-#define ED_CTRL_ID_ELEM_CONTENT_4      48
-#define ED_CTRL_ID_ELEM_CONTENT_5      49
-#define ED_CTRL_ID_ELEM_CONTENT_6      50
-#define ED_CTRL_ID_ELEM_CONTENT_7      51
-#define ED_CTRL_ID_AMOEBA_CONTENT      52
+#define ED_CTRL_ID_DRAWING_LEVEL       46
+#define ED_CTRL_ID_ELEM_CONTENT_0      47
+#define ED_CTRL_ID_ELEM_CONTENT_1      48
+#define ED_CTRL_ID_ELEM_CONTENT_2      49
+#define ED_CTRL_ID_ELEM_CONTENT_3      50
+#define ED_CTRL_ID_ELEM_CONTENT_4      51
+#define ED_CTRL_ID_ELEM_CONTENT_5      52
+#define ED_CTRL_ID_ELEM_CONTENT_6      53
+#define ED_CTRL_ID_ELEM_CONTENT_7      54
+#define ED_CTRL_ID_AMOEBA_CONTENT      55
 
 /* text input identifiers */
-#define ED_CTRL_ID_LEVEL_NAME          53
+#define ED_CTRL_ID_LEVEL_NAME          56
+#define ED_CTRL_ID_LEVEL_AUTHOR                57
 
 /* gadgets for scrolling of drawing area */
-#define ED_CTRL_ID_SCROLL_UP           54
-#define ED_CTRL_ID_SCROLL_DOWN         55
-#define ED_CTRL_ID_SCROLL_LEFT         56
-#define ED_CTRL_ID_SCROLL_RIGHT                57
-#define ED_CTRL_ID_SCROLL_VERTICAL     58
-#define ED_CTRL_ID_SCROLL_HORIZONTAL   59
+#define ED_CTRL_ID_SCROLL_UP           58
+#define ED_CTRL_ID_SCROLL_DOWN         59
+#define ED_CTRL_ID_SCROLL_LEFT         60
+#define ED_CTRL_ID_SCROLL_RIGHT                61
+#define ED_CTRL_ID_SCROLL_VERTICAL     62
+#define ED_CTRL_ID_SCROLL_HORIZONTAL   63
 
-#define ED_NUM_GADGETS                 60
+#define ED_NUM_GADGETS                 64
 
 /* values for counter gadgets */
 #define ED_COUNTER_ID_ELEM_SCORE       0
 #define ED_COUNTER_ID_ELEM_CONTENT     1
 #define ED_COUNTER_ID_LEVEL_XSIZE      2
 #define ED_COUNTER_ID_LEVEL_YSIZE      3
-#define ED_COUNTER_ID_LEVEL_COLLECT    4
-#define ED_COUNTER_ID_LEVEL_TIMELIMIT  5
-#define ED_COUNTER_ID_LEVEL_TIMESCORE  6
+#define ED_COUNTER_ID_LEVEL_RANDOM     4
+#define ED_COUNTER_ID_LEVEL_COLLECT    5
+#define ED_COUNTER_ID_LEVEL_TIMELIMIT  6
+#define ED_COUNTER_ID_LEVEL_TIMESCORE  7
 
 /* values for text input gadgets */
 #define ED_TEXTINPUT_ID_LEVEL_NAME     0
+#define ED_TEXTINPUT_ID_LEVEL_AUTHOR   1
 
-#define ED_NUM_COUNTERBUTTONS          7
+#define ED_NUM_COUNTERBUTTONS          8
 #define ED_NUM_SCROLLBUTTONS           4
 #define ED_NUM_SCROLLBARS              2
-#define ED_NUM_TEXTINPUT               1
+#define ED_NUM_TEXTINPUT               2
 
 /* values for CopyLevelToUndoBuffer() */
 #define UNDO_IMMEDIATE                 0
@@ -263,6 +272,7 @@ static int *gadget_elem_score_value = NULL;
 static int *gadget_elem_content_value = NULL;
 static int *gadget_level_xsize_value = NULL;
 static int *gadget_level_ysize_value = NULL;
+static int *gadget_level_random_value = NULL;
 static int *gadget_level_collect_value = NULL;
 static int *gadget_level_timelimit_value = NULL;
 static int *gadget_level_timescore_value = NULL;
@@ -294,7 +304,7 @@ static struct
     "element content"
   },
   {
-    ED_LEVELINFO_XPOS,                 ED_LEVELINFO_YPOS + 6 * MINI_TILEY,
+    ED_LEVELINFO_XPOS,                 ED_COUNTER_YPOS(0),
     MIN_LEV_FIELDX,                    MAX_LEV_FIELDX,
     ED_CTRL_ID_LEVEL_XSIZE_DOWN,       ED_CTRL_ID_LEVEL_XSIZE_UP,
     ED_CTRL_ID_LEVEL_XSIZE_TEXT,
@@ -302,7 +312,7 @@ static struct
     "playfield width"
   },
   {
-    ED_LEVELINFO_XPOS,                 ED_LEVELINFO_YPOS + 10 * MINI_TILEY,
+    ED_LEVELINFO_XPOS,                 ED_COUNTER_YPOS(1),
     MIN_LEV_FIELDY,                    MAX_LEV_FIELDY,
     ED_CTRL_ID_LEVEL_YSIZE_DOWN,       ED_CTRL_ID_LEVEL_YSIZE_UP,
     ED_CTRL_ID_LEVEL_YSIZE_TEXT,
@@ -310,7 +320,15 @@ static struct
     "playfield height"
   },
   {
-    ED_LEVELINFO_XPOS,                 ED_LEVELINFO_YPOS + 14 * MINI_TILEY,
+    ED_LEVELINFO_XPOS,                 ED_COUNTER_YPOS(2),
+    0,                                 100,
+    ED_CTRL_ID_LEVEL_RANDOM_DOWN,      ED_CTRL_ID_LEVEL_RANDOM_UP,
+    ED_CTRL_ID_LEVEL_RANDOM_TEXT,
+    &gadget_level_random_value,
+    "number of random elements"
+  },
+  {
+    ED_LEVELINFO_XPOS,                 ED_COUNTER_YPOS(3),
     0,                                 999,
     ED_CTRL_ID_LEVEL_COLLECT_DOWN,     ED_CTRL_ID_LEVEL_COLLECT_UP,
     ED_CTRL_ID_LEVEL_COLLECT_TEXT,
@@ -318,7 +336,7 @@ static struct
     "number of emeralds to collect"
   },
   {
-    ED_LEVELINFO_XPOS,                 ED_LEVELINFO_YPOS + 18 * MINI_TILEY,
+    ED_LEVELINFO_XPOS,                 ED_COUNTER_YPOS(4),
     0,                                 999,
     ED_CTRL_ID_LEVEL_TIMELIMIT_DOWN,   ED_CTRL_ID_LEVEL_TIMELIMIT_UP,
     ED_CTRL_ID_LEVEL_TIMELIMIT_TEXT,
@@ -326,7 +344,7 @@ static struct
     "time available to solve level"
   },
   {
-    ED_LEVELINFO_XPOS,                 ED_LEVELINFO_YPOS + 22 * MINI_TILEY,
+    ED_LEVELINFO_XPOS,                 ED_COUNTER_YPOS(5),
     0,                                 255,
     ED_CTRL_ID_LEVEL_TIMESCORE_DOWN,   ED_CTRL_ID_LEVEL_TIMESCORE_UP,
     ED_CTRL_ID_LEVEL_TIMESCORE_TEXT,
@@ -344,10 +362,16 @@ static struct
 } textinput_info[ED_NUM_TEXTINPUT] =
 {
   {
-    ED_LEVELINFO_XPOS,                 ED_LEVELINFO_YPOS + 26 * MINI_TILEY,
+    ED_LEVELINFO_XPOS,                 ED_COUNTER_YPOS(6),
     ED_CTRL_ID_LEVEL_NAME,
     level.name,
-    "level title"
+    "Level Title"
+  },
+  {
+    ED_LEVELINFO_XPOS,                 ED_COUNTER_YPOS(7),
+    ED_CTRL_ID_LEVEL_AUTHOR,
+    level.author,
+    "Level Author"
   }
 };
 
@@ -1150,42 +1174,44 @@ static void CreateDrawingAreas()
 
 static void CreateTextInputGadgets()
 {
-  Pixmap gd_pixmap = pix[PIX_DOOR];
-  int gd_x, gd_y;
-  struct GadgetInfo *gi;
-  unsigned long event_mask;
-  char infotext[MAX_INFOTEXT_LEN + 1];
-  int i, id;
+  int i;
 
-  /* text input gadget for the level name */
-  i = ED_TEXTINPUT_ID_LEVEL_NAME;
-  id = ED_CTRL_ID_LEVEL_NAME;
+  for (i=0; i<ED_NUM_TEXTINPUT; i++)
+  {
+    Pixmap gd_pixmap = pix[PIX_DOOR];
+    int gd_x, gd_y;
+    struct GadgetInfo *gi;
+    unsigned long event_mask;
+    char infotext[1024];
+    int id = ED_CTRL_ID_LEVEL_NAME + i;
 
-  event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
+    event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
 
-  gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
-  gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
+    gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
+    gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
 
-  sprintf(infotext, "Enter %s", textinput_info[i].infotext);
+    sprintf(infotext, "Enter %s", textinput_info[i].infotext);
+    infotext[MAX_INFOTEXT_LEN] = '\0';
 
-  gi = CreateGadget(GDI_CUSTOM_ID, id,
-                   GDI_INFO_TEXT, infotext,
-                   GDI_X, SX + textinput_info[i].x,
-                   GDI_Y, SY + textinput_info[i].y,
-                   GDI_TYPE, GD_TYPE_TEXTINPUT_ALPHANUMERIC,
-                   GDI_TEXT_VALUE, textinput_info[i].value,
-                   GDI_TEXT_SIZE, 30,
-                   GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x, gd_y,
-                   GDI_DESIGN_PRESSED, gd_pixmap, gd_x, gd_y,
-                   GDI_DESIGN_BORDER, ED_BORDER_SIZE,
-                   GDI_EVENT_MASK, event_mask,
-                   GDI_CALLBACK_ACTION, HandleTextInputGadgets,
-                   GDI_END);
+    gi = CreateGadget(GDI_CUSTOM_ID, id,
+                     GDI_INFO_TEXT, infotext,
+                     GDI_X, SX + textinput_info[i].x,
+                     GDI_Y, SY + textinput_info[i].y,
+                     GDI_TYPE, GD_TYPE_TEXTINPUT_ALPHANUMERIC,
+                     GDI_TEXT_VALUE, textinput_info[i].value,
+                     GDI_TEXT_SIZE, 30,
+                     GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x, gd_y,
+                     GDI_DESIGN_PRESSED, gd_pixmap, gd_x, gd_y,
+                     GDI_DESIGN_BORDER, ED_BORDER_SIZE,
+                     GDI_EVENT_MASK, event_mask,
+                     GDI_CALLBACK_ACTION, HandleTextInputGadgets,
+                     GDI_END);
 
-  if (gi == NULL)
-    Error(ERR_EXIT, "cannot create gadget");
+    if (gi == NULL)
+      Error(ERR_EXIT, "cannot create gadget");
 
-  level_editor_gadget[id] = gi;
+    level_editor_gadget[id] = gi;
+  }
 }
 
 static void CreateScrollbarGadgets()
@@ -1268,11 +1294,11 @@ static void MapControlButtons()
     MapGadget(level_editor_gadget[i]);
 }
 
-static void MapCounterButtons(int cnt_id)
+static void MapCounterButtons(int id)
 {
-  MapGadget(level_editor_gadget[counterbutton_info[cnt_id].gadget_id_down]);
-  MapGadget(level_editor_gadget[counterbutton_info[cnt_id].gadget_id_text]);
-  MapGadget(level_editor_gadget[counterbutton_info[cnt_id].gadget_id_up]);
+  MapGadget(level_editor_gadget[counterbutton_info[id].gadget_id_down]);
+  MapGadget(level_editor_gadget[counterbutton_info[id].gadget_id_text]);
+  MapGadget(level_editor_gadget[counterbutton_info[id].gadget_id_up]);
 }
 
 static void MapDrawingArea(int id)
@@ -1282,7 +1308,7 @@ static void MapDrawingArea(int id)
 
 static void MapTextInputGadget(int id)
 {
-  MapGadget(level_editor_gadget[id]);
+  MapGadget(level_editor_gadget[textinput_info[id].gadget_id]);
 }
 
 static void MapMainDrawingArea()
@@ -1651,8 +1677,9 @@ void AdjustEditorScrollbar(int id)
   AdjustScrollbar(gi, items_max, item_position);
 }
 
-void ModifyEditorTextInput(int gadget_id, char *new_text)
+void ModifyEditorTextInput(int textinput_id, char *new_text)
 {
+  int gadget_id = textinput_info[textinput_id].gadget_id;
   struct GadgetInfo *gi = level_editor_gadget[gadget_id];
 
   ModifyTextInputTextValue(gi, new_text);
@@ -2306,7 +2333,7 @@ void LevelNameTyping(KeySym key)
     ascii = '_';
 #endif
 
-  if (ascii && len<MAX_LEVNAMLEN-2)
+  if (ascii && len<MAX_LEVEL_NAME_LEN-2)
   {
     level.name[len] = ascii;
     level.name[len+1] = 0;
@@ -2394,7 +2421,7 @@ static void DrawDrawingWindow()
 
 static void DrawLevelInfoWindow()
 {
-  char infotext[MAX_INFOTEXT_LEN + 1];
+  char infotext[1024];
   int infotext_yoffset = MINI_TILEX + ED_GADGET_DISTANCE;
   int i, x, y;
 
@@ -2406,6 +2433,7 @@ static void DrawLevelInfoWindow()
 
   gadget_level_xsize_value = &lev_fieldx;
   gadget_level_ysize_value = &lev_fieldy;
+  gadget_level_random_value = &random_placement_num_objects;
   gadget_level_collect_value = &level.edelsteine;
   gadget_level_timelimit_value = &level.time;
   gadget_level_timescore_value = &level.score[10];
@@ -2417,17 +2445,26 @@ static void DrawLevelInfoWindow()
     y = counterbutton_info[i].y - infotext_yoffset;
 
     sprintf(infotext, "%s:", counterbutton_info[i].infotext);
-    DrawTextF(x, y, FC_YELLOW, infotext);
+    infotext[MAX_INFOTEXT_LEN] = '\0';
 
+    DrawTextF(x, y, FC_YELLOW, infotext);
     ModifyEditorCounter(i, **counterbutton_info[i].counter_value);
     MapCounterButtons(i);
   }
 
-  /* draw level name text input gadget */
-  x = textinput_info[ED_TEXTINPUT_ID_LEVEL_NAME].x;
-  y = textinput_info[ED_TEXTINPUT_ID_LEVEL_NAME].y - infotext_yoffset;
-  DrawTextF(x, y, FC_YELLOW, "Level Title:");
-  MapTextInputGadget(ED_CTRL_ID_LEVEL_NAME);
+  /* draw text input gadgets for level info */
+  for (i=ED_TEXTINPUT_ID_LEVEL_NAME; i<=ED_TEXTINPUT_ID_LEVEL_AUTHOR; i++)
+  {
+    x = textinput_info[i].x;
+    y = textinput_info[i].y - infotext_yoffset;
+
+    sprintf(infotext, "%s:", textinput_info[i].infotext);
+    infotext[MAX_INFOTEXT_LEN] = '\0';
+
+    DrawTextF(x, y, FC_YELLOW, infotext);
+    ModifyEditorTextInput(i, textinput_info[i].value);
+    MapTextInputGadget(i);
+  }
 }
 
 static void DrawElementContentAreas()
@@ -3512,6 +3549,16 @@ static void HandleCounterButtons(struct GadgetInfo *gi)
       level.fieldy = lev_fieldy;
       break;
 
+    case ED_CTRL_ID_LEVEL_RANDOM_DOWN:
+    case ED_CTRL_ID_LEVEL_RANDOM_UP:
+      step *= (id == ED_CTRL_ID_LEVEL_RANDOM_DOWN ? -1 : 1);
+      ModifyEditorCounter(ED_COUNTER_ID_LEVEL_RANDOM,
+                         *gadget_level_random_value + step);
+      break;
+    case ED_CTRL_ID_LEVEL_RANDOM_TEXT:
+      *gadget_level_random_value = gi->text.number_value;
+      break;
+
     case ED_CTRL_ID_LEVEL_COLLECT_DOWN:
     case ED_CTRL_ID_LEVEL_COLLECT_UP:
       step *= (id == ED_CTRL_ID_LEVEL_COLLECT_DOWN ? -1 : 1);
@@ -3557,6 +3604,10 @@ static void HandleTextInputGadgets(struct GadgetInfo *gi)
       strcpy(level.name, gi->text.value);
       break;
 
+    case ED_CTRL_ID_LEVEL_AUTHOR:
+      strcpy(level.author, gi->text.value);
+      break;
+
     default:
       break;
   }
index 87a60c1cc6112ad8546d4c8ad7587471b357d5d6..e56759e05cedd772759e79d4ea2670b08de0092d 100644 (file)
 #define LEVELCLASS_CONTRIBUTION_END    299
 #define LEVELCLASS_USER_START          300
 #define LEVELCLASS_USER_END            399
+
+#define LEVELCLASS_TUTORIAL            LEVELCLASS_TUTORIAL_START
+#define LEVELCLASS_CLASSICS            LEVELCLASS_CLASSICS_START
+#define LEVELCLASS_CONTRIBUTION                LEVELCLASS_CONTRIBUTION_START
+#define LEVELCLASS_USER                        LEVELCLASS_USER_START
 #define LEVELCLASS_UNDEFINED           999
 
+#define IS_LEVELCLASS_TUTORIAL(n) \
+       (leveldir[n].sort_priority >= LEVELCLASS_TUTORIAL_START && \
+        leveldir[n].sort_priority <= LEVELCLASS_TUTORIAL_END)
+#define IS_LEVELCLASS_CLASSICS(n) \
+       (leveldir[n].sort_priority >= LEVELCLASS_CLASSICS_START && \
+        leveldir[n].sort_priority <= LEVELCLASS_CLASSICS_END)
+#define IS_LEVELCLASS_CONTRIBUTION(n) \
+       (leveldir[n].sort_priority >= LEVELCLASS_CONTRIBUTION_START && \
+        leveldir[n].sort_priority <= LEVELCLASS_CONTRIBUTION_END)
+#define IS_LEVELCLASS_USER(n) \
+       (leveldir[n].sort_priority >= LEVELCLASS_USER_START && \
+        leveldir[n].sort_priority <= LEVELCLASS_USER_END)
+
+#define LEVELCLASS(n)  (IS_LEVELCLASS_TUTORIAL(n) ? LEVELCLASS_TUTORIAL : \
+                        IS_LEVELCLASS_CLASSICS(n) ? LEVELCLASS_CLASSICS : \
+                        IS_LEVELCLASS_CONTRIBUTION(n) ? LEVELCLASS_CONTRIBUTION : \
+                        IS_LEVELCLASS_USER(n) ? LEVELCLASS_USER : \
+                        LEVELCLASS_UNDEFINED)
+
 static void SaveUserLevelInfo();               /* for 'InitUserLevelDir()' */
 static char *getSetupLine(char *, int);                /* for 'SaveUserLevelInfo()' */
 
@@ -267,6 +291,7 @@ static void setLevelInfoToDefaults()
   level.high_speed = FALSE;
 
   strcpy(level.name, "Nameless Level");
+  strcpy(level.author, "Anonymous");
 
   for(i=0; i<LEVEL_SCORE_ELEMENTS; i++)
     level.score[i] = 10;
@@ -338,9 +363,9 @@ void LoadLevel(int level_nr)
   level.time           = (fgetc(file)<<8) | fgetc(file);
   level.edelsteine     = (fgetc(file)<<8) | fgetc(file);
 
-  for(i=0; i<MAX_LEVNAMLEN; i++)
+  for(i=0; i<MAX_LEVEL_NAME_LEN; i++)
     level.name[i]      = fgetc(file);
-  level.name[MAX_LEVNAMLEN - 1] = 0;
+  level.name[MAX_LEVEL_NAME_LEN - 1] = 0;
 
   for(i=0; i<LEVEL_SCORE_ELEMENTS; i++)
     level.score[i]     = fgetc(file);
@@ -413,9 +438,42 @@ void LoadLevel(int level_nr)
     level.time = 10;
 #endif
 
+  /* determine level author */
+  if (leveldir[leveldir_nr].author)
+  {
+    strncpy(level.author, leveldir[leveldir_nr].author,
+           MAX_LEVEL_AUTHOR_LEN - 1);
+    level.author[MAX_LEVEL_AUTHOR_LEN - 1] = '\0';
+  }
+  else
+  {
+    switch (LEVELCLASS(leveldir_nr))
+    {
+      case LEVELCLASS_TUTORIAL:
+       strcpy(level.author, PROGRAM_AUTHOR_STRING);
+       break;
+  
+      case LEVELCLASS_CLASSICS:
+      case LEVELCLASS_CONTRIBUTION:
+       strncpy(level.author, leveldir[leveldir_nr].name,
+               MAX_LEVEL_AUTHOR_LEN - 1);
+       level.author[MAX_LEVEL_AUTHOR_LEN - 1] = '\0';
+       break;
+  
+      case LEVELCLASS_USER:
+       strncpy(level.author, getRealName(), MAX_LEVEL_AUTHOR_LEN - 1);
+       level.author[MAX_LEVEL_AUTHOR_LEN - 1] = '\0';
+       break;
+  
+      default:
+       /* keep default value */
+       break;
+    }
+  }
+
+  /* player was faster than monsters in pre-1.0 levels */
   if (file_version == FILE_VERSION_1_0 &&
-      leveldir[leveldir_nr].sort_priority >= LEVELCLASS_CONTRIBUTION_START &&
-      leveldir[leveldir_nr].sort_priority <= LEVELCLASS_CONTRIBUTION_END)
+      IS_LEVELCLASS_CONTRIBUTION(leveldir_nr))
   {
     Error(ERR_WARN, "level file '%s' has version number 1.0", filename);
     Error(ERR_WARN, "using high speed movement for player");
@@ -455,7 +513,7 @@ void SaveLevel(int level_nr)
   fputc(level.edelsteine / 256, file);
   fputc(level.edelsteine % 256, file);
 
-  for(i=0; i<MAX_LEVNAMLEN; i++)
+  for(i=0; i<MAX_LEVEL_NAME_LEN; i++)
     fputc(level.name[i], file);
   for(i=0; i<LEVEL_SCORE_ELEMENTS; i++)
     fputc(level.score[i], file);
@@ -887,10 +945,11 @@ void SaveScore(int level_nr)
 
 /* level directory info */
 #define LEVELINFO_TOKEN_NAME           29
-#define LEVELINFO_TOKEN_LEVELS         30
-#define LEVELINFO_TOKEN_FIRST_LEVEL    31
-#define LEVELINFO_TOKEN_SORT_PRIORITY  32
-#define LEVELINFO_TOKEN_READONLY       33
+#define LEVELINFO_TOKEN_AUTHOR         30
+#define LEVELINFO_TOKEN_LEVELS         31
+#define LEVELINFO_TOKEN_FIRST_LEVEL    32
+#define LEVELINFO_TOKEN_SORT_PRIORITY  33
+#define LEVELINFO_TOKEN_READONLY       34
 
 #define FIRST_GLOBAL_SETUP_TOKEN       SETUP_TOKEN_PLAYER_NAME
 #define LAST_GLOBAL_SETUP_TOKEN                SETUP_TOKEN_TEAM_MODE
@@ -952,6 +1011,7 @@ static struct
 
   /* level directory info */
   { TYPE_STRING,  &ldi.name,           "name"                          },
+  { TYPE_STRING,  &ldi.author,         "author"                        },
   { TYPE_INTEGER, &ldi.levels,         "levels"                        },
   { TYPE_INTEGER, &ldi.first_level,    "first_level"                   },
   { TYPE_INTEGER, &ldi.sort_priority,  "sort_priority"                 },
@@ -1216,6 +1276,7 @@ static void checkSetupFileListIdentifier(struct SetupFileList *setup_file_list,
 static void setLevelDirInfoToDefaults(struct LevelDirInfo *ldi)
 {
   ldi->name = getStringCopy("non-existing");
+  ldi->author = NULL;
   ldi->levels = 0;
   ldi->first_level = 0;
   ldi->sort_priority = LEVELCLASS_UNDEFINED;   /* default: least priority */
index 33cec176b737016ff375784fe52dc6add95ae32a..77c5fb65e88283a984432e09eaa2d26e62ee5acd 100644 (file)
@@ -348,8 +348,8 @@ void InitWindow(int argc, char *argv[])
   XSizeHints size_hints;
   XWMHints wm_hints;
   XClassHint class_hints;
-  char *window_name = WINDOWTITLE_STRING;
-  char *icon_name = WINDOWTITLE_STRING;
+  char *window_name = WINDOW_TITLE_STRING;
+  char *icon_name = WINDOW_TITLE_STRING;
   long window_event_mask;
   Atom proto_atom = None, delete_atom = None;
 #endif
@@ -540,7 +540,7 @@ void InitGfx()
 #endif
 
   LoadGfx(PIX_SMALLFONT,&pic[PIX_SMALLFONT]);
-  DrawInitText(WINDOWTITLE_STRING,20,FC_YELLOW);
+  DrawInitText(WINDOW_TITLE_STRING,20,FC_YELLOW);
   DrawInitText(COPYRIGHT_STRING,50,FC_RED);
 #ifdef MSDOS
   DrawInitText("MSDOS version done by Guido Schulz",210,FC_BLUE);
index da627421439f005a7e89dcfd11f3a0d9177d16b6..00d49ab9edc81fbdaf5a73938ec0b4353ef7be4b 100644 (file)
@@ -199,7 +199,8 @@ typedef unsigned char byte;
 
 /* boundaries of arrays etc. */
 #define MAX_NAMELEN            (10+1)
-#define MAX_LEVNAMLEN          32
+#define MAX_LEVEL_NAME_LEN     32
+#define MAX_LEVEL_AUTHOR_LEN   34
 #define MAX_TAPELEN            (1000 * 50)     /* max. time * framerate */
 #define MAX_LEVDIR_ENTRIES     100
 #define MAX_SCORE_ENTRIES      100
@@ -214,6 +215,7 @@ typedef unsigned char byte;
 #define FRAMES_PER_SECOND      (1000 / GAME_FRAME_DELAY)
 #define GADGET_FRAME_DELAY     150     /* delay between gadget actions */
 #define MICROLEVEL_SCROLL_DELAY        50      /* delay for scrolling micro level */
+#define MICROLEVEL_LABEL_DELAY 250     /* delay for micro level label */
 
 struct HiScore
 {
@@ -336,7 +338,8 @@ struct LevelInfo
   int fieldy;
   int time;
   int edelsteine;
-  char name[MAX_LEVNAMLEN];
+  char name[MAX_LEVEL_NAME_LEN];
+  char author[MAX_LEVEL_AUTHOR_LEN];
   int score[LEVEL_SCORE_ELEMENTS];
   int mampfer_inhalt[8][3][3];
   int tempo_amoebe;
@@ -350,6 +353,7 @@ struct LevelDirInfo
 {
   char *filename;
   char *name;
+  char *author;
   int levels;
   int first_level;
   int last_level;
@@ -1232,10 +1236,11 @@ extern int              num_bg_loops;
 #define TAPES_DIRECTORY                "tapes"
 #define SCORES_DIRECTORY       "scores"
 
-#define VERSION_STRING         "1.2.1"
-#define GAMETITLE_STRING       "Rocks'n'Diamonds"
-#define WINDOWTITLE_STRING     GAMETITLE_STRING " " VERSION_STRING
-#define COPYRIGHT_STRING       "Copyright ^1995-99 by Holger Schemel"
+#define PROGRAM_VERSION_STRING "1.2.1"
+#define PROGRAM_TITLE_STRING   "Rocks'n'Diamonds"
+#define PROGRAM_AUTHOR_STRING  "Holger Schemel"
+#define WINDOW_TITLE_STRING    PROGRAM_TITLE_STRING " " PROGRAM_VERSION_STRING
+#define COPYRIGHT_STRING       "Copyright ^1995-99 by " PROGRAM_AUTHOR_STRING
 
 /* default name for empty highscore entry */
 #define EMPTY_PLAYER_NAME      "no name"
@@ -1265,19 +1270,17 @@ extern int              num_bg_loops;
 #define REDRAW_VIDEO_2         (1L << 5)
 #define REDRAW_VIDEO_3         (1L << 6)
 #define REDRAW_MICROLEVEL      (1L << 7)
-#define REDRAW_MICROLEVEL_LABEL        (1L << 8)
-#define REDRAW_FROM_BACKBUFFER (1L << 9)
+#define REDRAW_FROM_BACKBUFFER (1L << 8)
 #define REDRAW_DOOR_2          (REDRAW_VIDEO_1 | \
                                 REDRAW_VIDEO_2 | \
                                 REDRAW_VIDEO_3)
-#define REDRAW_DOOR_3          (1L << 10)
+#define REDRAW_DOOR_3          (1L << 9)
 #define REDRAW_DOORS           (REDRAW_DOOR_1 | \
                                 REDRAW_DOOR_2 | \
                                 REDRAW_DOOR_3)
 #define REDRAW_MAIN            (REDRAW_FIELD | \
                                 REDRAW_TILES | \
-                                REDRAW_MICROLEVEL | \
-                                REDRAW_MICROLEVEL_LABEL)
+                                REDRAW_MICROLEVEL)
 #define REDRAWTILES_THRESHOLD  (SCR_FIELDX * SCR_FIELDY / 2)
 
 /* areas in pixmap PIX_DOOR */
index c3e5b205eaa0e83837b2ed5b13d5bf4db5000d71..0e113727536ae9468a7c83c479be9936cfbff9f4 100644 (file)
@@ -241,6 +241,16 @@ char *getLoginName()
     return pwd->pw_name;
 }
 
+char *getRealName()
+{
+  struct passwd *pwd;
+
+  if (!(pwd = getpwuid(getuid())))
+    return "ANONYMOUS";
+  else
+    return pwd->pw_gecos;
+}
+
 char *getHomeDir()
 {
 #ifndef MSDOS
index d925f98355ddc7dcccc4dce479a9a4e95463cbef..9793cb733f54b697dc884747d15074e6cfccca5e 100644 (file)
@@ -45,6 +45,7 @@ unsigned int SimpleRND(unsigned int);
 unsigned int RND(unsigned int);
 unsigned int InitRND(long);
 char *getLoginName(void);
+char *getRealName(void);
 char *getHomeDir(void);
 char *getPath2(char *, char *);
 char *getPath3(char *, char *, char*);
index 11c6bf2a9c9e011a89a6d4b2ecb067125d154aff..2395c4676c25cfb4c0fff4af11b54bb6028c7402 100644 (file)
@@ -47,9 +47,9 @@ extern unsigned char get_ascii(KeySym);
 
 void DrawHeadline()
 {
-  int x = SX + (SXSIZE - strlen(GAMETITLE_STRING) * FONT1_XSIZE) / 2;
+  int x = SX + (SXSIZE - strlen(PROGRAM_TITLE_STRING) * FONT1_XSIZE) / 2;
 
-  DrawText(x, SY + 8, GAMETITLE_STRING, FS_BIG, FC_YELLOW);
+  DrawText(x, SY + 8, PROGRAM_TITLE_STRING, FS_BIG, FC_YELLOW);
   DrawTextFCentered(46, FC_RED, COPYRIGHT_STRING);
 }
 
index 900e5ef7078e610454db0973d6b92b0e898d237d..51014b9a410b139d742773a2b22a1865e42671c9 100644 (file)
@@ -189,15 +189,10 @@ void BackToFront()
     XCopyArea(display,backbuffer,window,gc,
              MICROLEV_XPOS, MICROLEV_YPOS, MICROLEV_XSIZE, MICROLEV_YSIZE,
              MICROLEV_XPOS, MICROLEV_YPOS);
-    redraw_mask &= ~REDRAW_MICROLEVEL;
-  }
-
-  if (redraw_mask & REDRAW_MICROLEVEL_LABEL)
-  {
     XCopyArea(display,backbuffer,window,gc,
              SX, MICROLABEL_YPOS, SXSIZE, FONT4_YSIZE,
              SX, MICROLABEL_YPOS);
-    redraw_mask &= ~REDRAW_MICROLEVEL_LABEL;
+    redraw_mask &= ~REDRAW_MICROLEVEL;
   }
 
   if (redraw_mask & REDRAW_TILES)
@@ -1442,41 +1437,61 @@ static void DrawMicroLevelExt(int xpos, int ypos, int from_x, int from_y)
   redraw_mask |= REDRAW_MICROLEVEL;
 }
 
+static void DrawMicroLevelLabelExt(int mode)
+{
+  char label_text[100];
+
+  XFillRectangle(display, drawto,gc,
+                SX, MICROLABEL_YPOS, SXSIZE, FONT4_YSIZE);
+
+  strcpy(label_text, (mode == 1 ? level.name :
+                     mode == 2 ? "created by" :
+                     mode == 3 ? level.author : ""));
+
+  if (strlen(label_text) > 0)
+  {
+    int size, lxpos, lypos;
+
+    label_text[SXSIZE / FONT4_XSIZE] = '\0';
+
+    size = strlen(label_text);
+    lxpos = SX + (SXSIZE - size * FONT4_XSIZE) / 2;
+    lypos = MICROLABEL_YPOS;
+
+    DrawText(lxpos, lypos, label_text, FS_SMALL, FC_SPECIAL2);
+  }
+
+  redraw_mask |= REDRAW_MICROLEVEL;
+}
+
 void DrawMicroLevel(int xpos, int ypos, boolean restart)
 {
   static unsigned long scroll_delay = 0;
+  static unsigned long label_delay = 0;
   static int from_x, from_y, scroll_direction;
+  static int label_state, label_counter;
 
   if (restart)
   {
     from_x = from_y = 0;
     scroll_direction = MV_RIGHT;
+    label_state = 1;
+    label_counter = 0;
 
     DrawMicroLevelExt(xpos, ypos, from_x, from_y);
+    DrawMicroLevelLabelExt(label_state);
 
-    XFillRectangle(display, drawto,gc,
-                  SX, MICROLABEL_YPOS, SXSIZE, FONT4_YSIZE);
-
-    if (level.name && restart)
-    {
-      int len = strlen(level.name);
-      int lxpos = SX + (SXSIZE - len * FONT4_XSIZE) / 2;
-      int lypos = MICROLABEL_YPOS;
-
-      DrawText(lxpos, lypos, level.name, FS_SMALL, FC_SPECIAL2);
-    }
-
-    /* initialize delay counter */
+    /* initialize delay counters */
     DelayReached(&scroll_delay, 0);
+    DelayReached(&label_delay, 0);
 
-    redraw_mask |= REDRAW_MICROLEVEL_LABEL;
+    return;
   }
-  else
-  {
-    if ((lev_fieldx <= STD_LEV_FIELDX && lev_fieldy <= STD_LEV_FIELDY) ||
-       !DelayReached(&scroll_delay, MICROLEVEL_SCROLL_DELAY))
-      return;
 
+  /* scroll micro level, if needed */
+  if ((lev_fieldx > STD_LEV_FIELDX || lev_fieldy > STD_LEV_FIELDY) &&
+      DelayReached(&scroll_delay, MICROLEVEL_SCROLL_DELAY))
+  {
     switch (scroll_direction)
     {
       case MV_LEFT:
@@ -1513,6 +1528,16 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart)
 
     DrawMicroLevelExt(xpos, ypos, from_x, from_y);
   }
+
+  /* redraw micro level label, if needed */
+  if (DelayReached(&label_delay, MICROLEVEL_LABEL_DELAY))
+  {
+    label_counter = (label_counter + 1) % 23;
+    label_state = (label_counter >= 0 && label_counter <= 7 ? 1 :
+                  label_counter >= 9 && label_counter <= 12 ? 2 :
+                  label_counter >= 14 && label_counter <= 21 ? 3 : 0);
+    DrawMicroLevelLabelExt(label_state);
+  }
 }
 
 int REQ_in_range(int x, int y)