#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
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;
"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,
"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,
"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,
"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,
"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,
} 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"
}
};
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()
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)
static void MapTextInputGadget(int id)
{
- MapGadget(level_editor_gadget[id]);
+ MapGadget(level_editor_gadget[textinput_info[id].gadget_id]);
}
static void MapMainDrawingArea()
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);
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;
static void DrawLevelInfoWindow()
{
- char infotext[MAX_INFOTEXT_LEN + 1];
+ char infotext[1024];
int infotext_yoffset = MINI_TILEX + ED_GADGET_DISTANCE;
int i, x, y;
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];
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()
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);
strcpy(level.name, gi->text.value);
break;
+ case ED_CTRL_ID_LEVEL_AUTHOR:
+ strcpy(level.author, gi->text.value);
+ break;
+
default:
break;
}
#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()' */
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;
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);
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");
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);
/* 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
/* 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" },
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 */
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)
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:
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)