-#define COMPILE_DATE_STRING "[2003-12-07 03:11]"
+#define COMPILE_DATE_STRING "[2003-12-08 02:04]"
if (level.use_custom_template)
{
- if (Request("Copy and modify level tem- plate ?", REQ_ASK))
+ if (Request("Copy and modify level template ?", REQ_ASK))
{
level.use_custom_template = FALSE;
ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE],
boolean new_template = (!LevelFileExists(-1));
if (new_template ||
- Request("Save this tem- plate and kill the old ?", REQ_ASK))
+ Request("Save this template and kill the old ?", REQ_ASK))
SaveLevelTemplate();
if (new_template)
- Request("Tem- plate saved !", REQ_CONFIRM);
+ Request("Template saved !", REQ_CONFIRM);
}
else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
custom_element.num_change_pages < MAX_CHANGE_PAGES)
{
if (level.use_custom_template && !LevelFileExists(-1))
{
- Request("No level tem- plate found !", REQ_CONFIRM);
+ Request("No level template found !", REQ_CONFIRM);
level.use_custom_template = FALSE;
ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END);
}
}
+static boolean is_string_suffix(char *string, char *suffix)
+{
+ int string_len = strlen(string);
+ int suffix_len = strlen(suffix);
+
+ if (suffix_len > string_len)
+ return FALSE;
+
+ return (strcmp(&string[string_len - suffix_len], suffix) == 0);
+}
+
+#define MAX_CHEAT_INPUT_LEN 32
+
+static void HandleKeysCheating(Key key)
+{
+ static char cheat_input[2 * MAX_CHEAT_INPUT_LEN + 1] = "";
+ char letter = getCharFromKey(key);
+ int cheat_input_len = strlen(cheat_input);
+ int i;
+
+ if (letter == 0)
+ return;
+
+ if (cheat_input_len >= 2 * MAX_CHEAT_INPUT_LEN)
+ {
+ for (i = 0; i < MAX_CHEAT_INPUT_LEN + 1; i++)
+ cheat_input[i] = cheat_input[MAX_CHEAT_INPUT_LEN + i];
+
+ cheat_input_len = MAX_CHEAT_INPUT_LEN;
+ }
+
+ cheat_input[cheat_input_len++] = letter;
+ cheat_input[cheat_input_len] = '\0';
+
+#if 0
+ printf("::: '%s' [%d]\n", cheat_input, cheat_input_len);
+#endif
+
+#if 1
+ if (is_string_suffix(cheat_input, ":insert solution tape"))
+ InsertSolutionTape();
+#else
+ if (is_string_suffix(cheat_input, ":ist"))
+ InsertSolutionTape();
+#endif
+
+#ifdef DEBUG
+ else if (is_string_suffix(cheat_input, ":dump tape"))
+ DumpTape(&tape);
+ else if (is_string_suffix(cheat_input, ".q"))
+ for (i = 0; i < MAX_INVENTORY_SIZE; i++)
+ if (local_player->inventory_size < MAX_INVENTORY_SIZE)
+ local_player->inventory_element[local_player->inventory_size++] =
+ EL_DYNAMITE;
+#endif
+}
+
void HandleKey(Key key, int key_status)
{
int joy = 0;
TapeQuickLoad();
else if (key == setup.shortcut.toggle_pause)
TapeTogglePause(TAPE_TOGGLE_MANUAL);
+
+ HandleKeysCheating(key);
}
if (HandleGadgetsKeyInput(key))
HandleInfoScreen(0,0, 0, +1 * SCROLL_PAGE, MB_MENU_MARK);
break;
-#ifdef DEBUG
- case KSYM_t:
- DumpTape(&tape);
- break;
-#endif
-
default:
break;
}
printf("ScrollStepSize == %d (1/1)\n", ScrollStepSize);
break;
- case KSYM_Q:
- case KSYM_q:
- {
- int i;
-
- for (i = 0; i < MAX_INVENTORY_SIZE; i++)
- if (local_player->inventory_size < MAX_INVENTORY_SIZE)
- local_player->inventory_element[local_player->inventory_size++] =
- EL_DYNAMITE;
- }
-
- break;
-
-
#if 0
case KSYM_z:
}
break;
}
+
default:
if (key == KSYM_Escape)
{
LoadTapeFromFilename(filename);
}
+void LoadSolutionTape(int level_nr)
+{
+ char *filename = getSolutionTapeFilename(level_nr);
+
+ LoadTapeFromFilename(filename);
+}
+
static void SaveTape_VERS(FILE *file, struct TapeInfo *tape)
{
putFileVersion(file, tape->file_version);
void LoadTapeFromFilename(char *);
void LoadTape(int);
+void LoadSolutionTape(int);
void SaveTape(int);
void DumpTape(struct TapeInfo *);
return userlevel_dir;
}
-static char *getTapeDir(char *level_subdir)
-{
- static char *tape_dir = NULL;
- char *data_dir = getUserDataDir();
- char *tape_subdir = TAPES_DIRECTORY;
-
- if (tape_dir)
- free(tape_dir);
-
- if (level_subdir != NULL)
- tape_dir = getPath3(data_dir, tape_subdir, level_subdir);
- else
- tape_dir = getPath2(data_dir, tape_subdir);
-
- return tape_dir;
-}
-
static char *getScoreDir(char *level_subdir)
{
static char *score_dir = NULL;
return getLevelDirFromTreeInfo(leveldir_current);
}
+static char *getTapeDir(char *level_subdir)
+{
+ static char *tape_dir = NULL;
+ char *data_dir = getUserDataDir();
+ char *tape_subdir = TAPES_DIRECTORY;
+
+ if (tape_dir)
+ free(tape_dir);
+
+ if (level_subdir != NULL)
+ tape_dir = getPath3(data_dir, tape_subdir, level_subdir);
+ else
+ tape_dir = getPath2(data_dir, tape_subdir);
+
+ return tape_dir;
+}
+
+static char *getSolutionTapeDir()
+{
+ static char *tape_dir = NULL;
+ char *data_dir = getCurrentLevelDir();
+ char *tape_subdir = TAPES_DIRECTORY;
+
+ if (tape_dir)
+ free(tape_dir);
+
+ tape_dir = getPath2(data_dir, tape_subdir);
+
+ return tape_dir;
+}
+
static char *getDefaultGraphicsDir(char *graphics_subdir)
{
static char *graphics_dir = NULL;
return filename;
}
+char *getSolutionTapeFilename(int nr)
+{
+ static char *filename = NULL;
+ char basename[MAX_FILENAME_LEN];
+
+ if (filename != NULL)
+ free(filename);
+
+ sprintf(basename, "%03d.%s", nr, TAPEFILE_EXTENSION);
+ filename = getPath2(getSolutionTapeDir(), basename);
+
+ return filename;
+}
+
char *getScoreFilename(int nr)
{
static char *filename = NULL;
char *setLevelArtworkDir(TreeInfo *);
char *getLevelFilename(int);
char *getTapeFilename(int);
+char *getSolutionTapeFilename(int);
char *getScoreFilename(int);
char *getSetupFilename(void);
char *getEditorSetupFilename(void);
}
}
+void InsertSolutionTape()
+{
+ if (!TAPE_IS_EMPTY(tape))
+ return;
+
+ LoadSolutionTape(level_nr);
+
+ if (TAPE_IS_EMPTY(tape))
+ Request("No solution tape for this level !", REQ_CONFIRM);
+
+ DrawCompleteVideoDisplay();
+}
+
/* ------------------------------------------------------------------------- *
* tape autoplay functions
continue;
}
- LoadTape(level_nr);
+ LoadSolutionTape(level_nr);
if (TAPE_IS_EMPTY(tape))
{
printf("(no tape)\n");
unsigned int GetTapeLength(void);
void TapeQuickSave(void);
void TapeQuickLoad(void);
+void InsertSolutionTape(void);
void AutoPlayTape(void);
}
#define MAX_REQUEST_LINES 13
-#define MAX_REQUEST_LINE_LEN 7
+#define MAX_REQUEST_LINE_FONT1_LEN 7
+#define MAX_REQUEST_LINE_FONT2_LEN 10
boolean Request(char *text, unsigned int req_state)
{
int mx, my, ty, result = -1;
unsigned int old_door_state;
int last_game_status = game_status; /* save current game status */
+ int max_request_line_len = MAX_REQUEST_LINE_FONT1_LEN;
+ int font_nr = FONT_TEXT_2;
+ int max_word_len = 0;
+ char *text_ptr;
+
+ for (text_ptr = text; *text_ptr; text_ptr++)
+ {
+ max_word_len = (*text_ptr != ' ' ? max_word_len + 1 : 0);
+
+ if (max_word_len > MAX_REQUEST_LINE_FONT1_LEN)
+ {
+ max_request_line_len = MAX_REQUEST_LINE_FONT2_LEN;
+ font_nr = FONT_LEVEL_NUMBER;
+
+ break;
+ }
+ }
#if 1
SetMouseCursor(CURSOR_DEFAULT);
/* write text for request */
for (ty = 0; ty < MAX_REQUEST_LINES; ty++)
{
- char text_line[MAX_REQUEST_LINE_LEN + 1];
+ char text_line[max_request_line_len + 1];
int tx, tl, tc;
if (!*text)
break;
- for (tl = 0, tx = 0; tx < MAX_REQUEST_LINE_LEN; tl++, tx++)
+ for (tl = 0, tx = 0; tx < max_request_line_len; tl++, tx++)
{
tc = *(text + tx);
if (!tc || tc == ' ')
strncpy(text_line, text, tl);
text_line[tl] = 0;
- DrawText(DX + (DXSIZE - tl * getFontWidth(FONT_TEXT_2)) / 2,
- DY + 8 + ty * (getFontHeight(FONT_TEXT_2) + 2),
- text_line, FONT_TEXT_2);
+ DrawText(DX + (DXSIZE - tl * getFontWidth(font_nr)) / 2,
+ DY + 8 + ty * (getFontHeight(font_nr) + 2),
+ text_line, font_nr);
text += tl + (tc == ' ' ? 1 : 0);
}