toons[i].anim_delay = 1; /* no delay between frames */
toons[i].start_frame = 0; /* always start with first */
}
-
- toons[i].move_delay *= GAME_FRAME_DELAY;
}
InitToonScreen(bitmap_db_door,
BackToFront, PrepareBackbuffer, ToonNeedsRedraw,
toons, NUM_TOONS,
- REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
+ REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE,
+ GAME_FRAME_DELAY);
}
-#define COMPILE_DATE_STRING "[2002-12-27 15:33]"
+#define COMPILE_DATE_STRING "[2002-12-27 17:46]"
CreateCheckbuttonGadgets();
}
+void FreeLevelEditorGadgets()
+{
+ int i;
+
+ for (i=0; i<NUM_EDITOR_GADGETS; i++)
+ FreeGadget(level_editor_gadget[i]);
+}
+
static void MapCounterButtons(int id)
{
MapGadget(level_editor_gadget[counterbutton_info[id].gadget_id_down]);
extern int elements_in_list;
void CreateLevelEditorGadgets();
+void FreeLevelEditorGadgets();
void UnmapLevelEditorGadgets();
void DrawLevelEd(void);
void HandleLevelEditorKeyInput(Key);
}
}
+void FreeGameButtons()
+{
+ int i;
+
+ for (i=0; i<NUM_GAME_BUTTONS; i++)
+ FreeGadget(game_gadget[i]);
+}
+
static void MapGameButtons()
{
int i;
void RequestQuitGame(boolean);
void CreateGameButtons();
+void FreeGameButtons();
void UnmapGameButtons();
#endif
InitImages(); /* needs to know current level directory */
InitSound(); /* needs to know current level directory */
+#if 0
InitGadgets(); /* needs images + number of level series */
+#endif
InitGfxBackground();
- InitToons();
if (global.autoplay_leveldir)
{
new_graphic_info[IMG_MENU_FONT_MEDIUM].bitmap,
new_graphic_info[IMG_MENU_FONT_SMALL].bitmap,
new_graphic_info[IMG_MENU_FONT_EM].bitmap);
+
+ InitGadgets();
+ InitToons();
}
static void InitImages()
}
#endif
+#if 0
+ SyncDisplay();
+#endif
+
ReinitializeGraphics();
FreeTileClipmasks();
#endif
}
+void FreeGadgets()
+{
+ FreeLevelEditorGadgets();
+ FreeGameButtons();
+ FreeTapeButtons();
+ FreeToolButtons();
+ FreeScreenGadgets();
+}
+
void InitGadgets()
{
+ static boolean gadgets_initialized = FALSE;
+
+ if (gadgets_initialized)
+ FreeGadgets();
+
CreateLevelEditorGadgets();
CreateGameButtons();
CreateTapeButtons();
CreateToolButtons();
CreateScreenGadgets();
+
+ gadgets_initialized = TRUE;
}
void InitElementInfo()
struct GadgetInfo *CreateGadget(int first_tag, ...)
{
- struct GadgetInfo *new_gadget = checked_malloc(sizeof(struct GadgetInfo));
+ struct GadgetInfo *new_gadget = checked_calloc(sizeof(struct GadgetInfo));
va_list ap;
/* always start with reliable default values */
- memset(new_gadget, 0, sizeof(struct GadgetInfo)); /* zero all fields */
new_gadget->id = getNewGadgetID();
new_gadget->callback_info = default_callback_info;
new_gadget->callback_action = default_callback_action;
+ new_gadget->next = NULL;
va_start(ap, first_tag);
HandleGadgetTags(new_gadget, first_tag, ap);
if (gi == gadget_list_last_entry)
gadget_list_last_entry = gi_previous;
- gi_previous->next = gi->next;
+ if (gi_previous)
+ gi_previous->next = gi->next;
+
free(gi);
}
boolean (*redraw_needed_function)(void),
struct ToonInfo *toons, int num_toons,
int startx, int starty,
- int width, int height)
+ int width, int height,
+ int frame_delay_value)
{
screen_info.save_buffer = save_buffer;
screen_info.update_function = update_function;
screen_info.starty = starty;
screen_info.width = width;
screen_info.height = height;
+ screen_info.frame_delay_value = frame_delay_value;
}
void DrawAnim(Bitmap *toon_bitmap, GC toon_clip_gc,
{
horiz_move = (anim->direction & (ANIMDIR_LEFT | ANIMDIR_RIGHT));
vert_move = (anim->direction & (ANIMDIR_UP | ANIMDIR_DOWN));
- anim_delay_value = anim->move_delay;
+ anim_delay_value = anim->move_delay * screen_info.frame_delay_value;
frame = getAnimationFrame(anim->anim_frames, anim->anim_delay,
anim->anim_mode, anim->start_frame,
int startx, starty;
int width, height;
+
+ int frame_delay_value;
};
struct ToonInfo
int getAnimationFrame(int, int, int, int, int);
-void InitToonScreen();
+void InitToonScreen(Bitmap *, void (*update_function)(void),
+ void (*prepare_backbuffer_function)(void),
+ boolean (*redraw_needed_function)(void),
+ struct ToonInfo *, int, int, int, int, int, int);
void InitAnimation(void);
void StopAnimation(void);
void DoAnimation(void);
CreateScreenScrollbars();
}
+void FreeScreenGadgets()
+{
+ int i;
+
+ for (i=0; i<NUM_SCREEN_GADGETS; i++)
+ FreeGadget(screen_gadget[i]);
+}
+
void MapChooseTreeGadgets(TreeInfo *ti)
{
int num_entries = numTreeInfoInGroup(ti);
void HandleGameActions(void);
void CreateScreenGadgets();
+void FreeScreenGadgets();
void MapChooseTreeGadgets(TreeInfo *);
void UnmapChooseTreeGadgets();
}
}
+void FreeTapeButtons()
+{
+ int i;
+
+ for (i=0; i<NUM_TAPE_BUTTONS; i++)
+ FreeGadget(tape_gadget[i]);
+}
+
void MapTapeEjectButton()
{
UnmapGadget(tape_gadget[TAPE_CTRL_ID_INDEX]);
void AutoPlayTape(void);
void CreateTapeButtons();
+void FreeTapeButtons();
void MapTapeEjectButton();
void MapTapeIndexButton();
void MapTapeButtons();
gfx_action = GfxAction[x][y];
#endif
+#if DEBUG
+ if (gfx_action < 0)
+ printf("getGfxAction: THIS SHOULD NEVER HAPPEN: GfxAction[%d][%d] == %d\n",
+ x, y, gfx_action);
+#endif
+
return gfx_action;
}
int cut_mode, int mask_mode)
{
int ux = LEVELX(x), uy = LEVELY(y);
- int move_dir = MovDir[ux][uy];
- int move_pos = getFramePosition(ux, uy);
- int gfx_action = getGfxAction(ux, uy);
- int graphic = el_dir_act2img(element, move_dir, gfx_action);
- int frame = getGraphicAnimationFrame(graphic, move_pos);
+ int graphic;
+ int frame;
+
+ if (IN_LEV_FIELD(ux, uy))
+ {
+ int move_dir = MovDir[ux][uy];
+ int move_pos = getFramePosition(ux, uy);
+ int gfx_action = getGfxAction(ux, uy);
+
+ graphic = el_dir_act2img(element, move_dir, gfx_action);
+ frame = getGraphicAnimationFrame(graphic, move_pos);
+ }
+ else
+ {
+ graphic = el2img(element);
+ frame = getGraphicAnimationFrame(graphic, 0);
+ }
if (element == EL_WALL_GROWING)
{
}
}
+void FreeToolButtons()
+{
+ int i;
+
+ for (i=0; i<NUM_TOOL_BUTTONS; i++)
+ FreeGadget(tool_gadget[i]);
+}
+
static void UnmapToolButtons()
{
int i;
int el_dir_act2img(int element, int direction, int action)
{
+#if DEBUG
+ if (element < 0)
+ {
+ printf("el_dir_act2img: THIS SHOULD NEVER HAPPEN: element == %d\n",
+ element);
+
+ return IMG_EMPTY;
+ }
+
+ if (action < 0)
+ {
+ printf("el_dir_act2img: THIS SHOULD NEVER HAPPEN: action == %d\n",
+ action);
+
+ return IMG_EMPTY;
+ }
+#endif
+
action = graphics_action_mapping[action];
direction = MV_DIR_BIT(direction);
int ReadPixel(DrawBuffer *, int, int);
void CreateToolButtons();
+void FreeToolButtons();
int get_next_element(int);
int el2gfx(int);