/***********************************************************
* Rocks'n'Diamonds -- McDuffin Strikes Back! *
*----------------------------------------------------------*
-* ©1995 Artsoft Development *
-* Holger Schemel *
-* 33659 Bielefeld-Senne *
-* Telefon: (0521) 493245 *
-* eMail: aeglos@valinor.owl.de *
-* aeglos@uni-paderborn.de *
-* q99492@pbhrzx.uni-paderborn.de *
+* (c) 1995-98 Artsoft Entertainment *
+* Holger Schemel *
+* Oststrasse 11a *
+* 33604 Bielefeld *
+* phone: ++49 +521 290471 *
+* email: aeglos@valinor.owl.de *
*----------------------------------------------------------*
* editor.c *
***********************************************************/
#include "buttons.h"
#include "files.h"
+/* positions in the level editor */
+#define ED_WIN_MB_LEFT_XPOS 7
+#define ED_WIN_MB_LEFT_YPOS 6
+#define ED_WIN_LEVELNR_XPOS 77
+#define ED_WIN_LEVELNR_YPOS 7
+#define ED_WIN_MB_MIDDLE_XPOS 7
+#define ED_WIN_MB_MIDDLE_YPOS 258
+#define ED_WIN_MB_RIGHT_XPOS 77
+#define ED_WIN_MB_RIGHT_YPOS 258
+
+/* other constants for the editor */
+#define ED_SCROLL_NO 0
+#define ED_SCROLL_LEFT 1
+#define ED_SCROLL_RIGHT 2
+#define ED_SCROLL_UP 4
+#define ED_SCROLL_DOWN 8
+
+/* delay value to avoid too fast scrolling etc. */
+#define CHOICE_DELAY_VALUE 100
+
static int level_xpos,level_ypos;
-static BOOL edit_mode;
-static BOOL name_typing;
+static boolean edit_mode;
+static boolean name_typing;
static int new_element1 = EL_MAUERWERK;
static int new_element2 = EL_LEERRAUM;
static int new_element3 = EL_ERDREICH;
EL_CHAR_A + ('N' - 'A'),
EL_CHAR_A + ('E' - 'A'),
+ EL_SPIELER1,
+ EL_SPIELER2,
+ EL_SPIELER3,
+ EL_SPIELER4,
+
EL_SPIELFIGUR,
EL_LEERRAUM,
EL_ERDREICH,
EL_DRACHE,
EL_SONDE,
- EL_LEERRAUM,
- EL_LEERRAUM,
- EL_LEERRAUM,
+ EL_MAUER_X,
+ EL_MAUER_Y,
+ EL_MAUER_XY,
EL_CHAR_A + ('S' - 'A'),
EL_CHAR_A + ('O' - 'A'),
else
graphic = GFX_LEERRAUM;
- DrawMiniGraphicExtHiRes(pix[PIX_DB_DOOR],gc,
- DOOR_GFX_PAGEX1+ED_BUTTON_ELEM_XPOS+3 +
- (i%MAX_ELEM_X)*ED_BUTTON_ELEM_XSIZE,
- DOOR_GFX_PAGEY1+ED_BUTTON_ELEM_YPOS+3 +
- (i/MAX_ELEM_X)*ED_BUTTON_ELEM_YSIZE,
- graphic);
+ DrawMiniGraphicExt(pix[PIX_DB_DOOR],gc,
+ DOOR_GFX_PAGEX1+ED_BUTTON_ELEM_XPOS+3 +
+ (i%MAX_ELEM_X)*ED_BUTTON_ELEM_XSIZE,
+ DOOR_GFX_PAGEY1+ED_BUTTON_ELEM_YPOS+3 +
+ (i/MAX_ELEM_X)*ED_BUTTON_ELEM_YSIZE,
+ graphic);
}
- DrawMiniGraphicExtHiRes(pix[PIX_DB_DOOR],gc,
- DOOR_GFX_PAGEX1+ED_WIN_MB_LEFT_XPOS,
- DOOR_GFX_PAGEY1+ED_WIN_MB_LEFT_YPOS,
- el2gfx(new_element1));
- DrawMiniGraphicExtHiRes(pix[PIX_DB_DOOR],gc,
- DOOR_GFX_PAGEX1+ED_WIN_MB_MIDDLE_XPOS,
- DOOR_GFX_PAGEY1+ED_WIN_MB_MIDDLE_YPOS,
- el2gfx(new_element2));
- DrawMiniGraphicExtHiRes(pix[PIX_DB_DOOR],gc,
- DOOR_GFX_PAGEX1+ED_WIN_MB_RIGHT_XPOS,
- DOOR_GFX_PAGEY1+ED_WIN_MB_RIGHT_YPOS,
- el2gfx(new_element3));
+ DrawMiniGraphicExt(pix[PIX_DB_DOOR],gc,
+ DOOR_GFX_PAGEX1+ED_WIN_MB_LEFT_XPOS,
+ DOOR_GFX_PAGEY1+ED_WIN_MB_LEFT_YPOS,
+ el2gfx(new_element1));
+ DrawMiniGraphicExt(pix[PIX_DB_DOOR],gc,
+ DOOR_GFX_PAGEX1+ED_WIN_MB_MIDDLE_XPOS,
+ DOOR_GFX_PAGEY1+ED_WIN_MB_MIDDLE_YPOS,
+ el2gfx(new_element2));
+ DrawMiniGraphicExt(pix[PIX_DB_DOOR],gc,
+ DOOR_GFX_PAGEX1+ED_WIN_MB_RIGHT_XPOS,
+ DOOR_GFX_PAGEY1+ED_WIN_MB_RIGHT_YPOS,
+ el2gfx(new_element3));
DrawTextExt(pix[PIX_DB_DOOR],gc,
DOOR_GFX_PAGEX2+ED_WIN_LEVELNR_XPOS,
DOOR_GFX_PAGEY1+ED_WIN_LEVELNR_YPOS,
static int check[4][2] = { {-1,0}, {0,-1}, {1,0}, {0,1} };
static int safety = 0;
+ /* check if starting field still has the desired content */
+ if (Feld[from_x][from_y] == fill_element)
+ return;
+
safety++;
- if (safety>lev_fieldx*lev_fieldy)
- {
- fprintf(stderr,"Something went wrong in 'FloodFill()'. Please debug.\n");
- exit(-1);
- }
+ if (safety > lev_fieldx*lev_fieldy)
+ Error(ERR_EXIT, "Something went wrong in 'FloodFill()'. Please debug.");
old_element = Feld[from_x][from_y];
Feld[from_x][from_y] = fill_element;
for(i=0;i<4;i++)
{
- x = from_x+check[i][0];
- y = from_y+check[i][1];
+ x = from_x + check[i][0];
+ y = from_y + check[i][1];
- if (IN_LEV_FIELD(x,y) && Feld[x][y]==old_element)
- FloodFill(x,y,fill_element);
+ if (IN_LEV_FIELD(x,y) && Feld[x][y] == old_element)
+ FloodFill(x, y, fill_element);
}
safety--;
{
static int last_button = 0;
static int in_field_pressed = FALSE;
- static BOOL use_floodfill = FALSE;
+ static boolean use_floodfill = FALSE;
int x = (mx-SX)/MINI_TILEX;
int y = (my-SY)/MINI_TILEY;
if (((choice == ED_BUTTON_EUP && element_shift>0) ||
(choice == ED_BUTTON_EDOWN &&
element_shift<elements_in_list-MAX_ELEM_X*MAX_ELEM_Y)) &&
- DelayReached(&choice_delay,10))
+ DelayReached(&choice_delay, CHOICE_DELAY_VALUE))
{
int i, step;
else if (last_button==3)
new_element3 = new_element;
- DrawMiniGraphicExtHiRes(drawto,gc,
- DX+ED_WIN_MB_LEFT_XPOS,
- DY+ED_WIN_MB_LEFT_YPOS,
- el2gfx(new_element1));
- DrawMiniGraphicExtHiRes(drawto,gc,
- DX+ED_WIN_MB_MIDDLE_XPOS,
- DY+ED_WIN_MB_MIDDLE_YPOS,
- el2gfx(new_element2));
- DrawMiniGraphicExtHiRes(drawto,gc,
- DX+ED_WIN_MB_RIGHT_XPOS,
- DY+ED_WIN_MB_RIGHT_YPOS,
- el2gfx(new_element3));
+ DrawMiniGraphicExt(drawto,gc,
+ DX+ED_WIN_MB_LEFT_XPOS,
+ DY+ED_WIN_MB_LEFT_YPOS,
+ el2gfx(new_element1));
+ DrawMiniGraphicExt(drawto,gc,
+ DX+ED_WIN_MB_MIDDLE_XPOS,
+ DY+ED_WIN_MB_MIDDLE_YPOS,
+ el2gfx(new_element2));
+ DrawMiniGraphicExt(drawto,gc,
+ DX+ED_WIN_MB_RIGHT_XPOS,
+ DY+ED_WIN_MB_RIGHT_YPOS,
+ el2gfx(new_element3));
redraw_mask |= REDRAW_DOOR_1;
}
edit_mode = FALSE;
break;
case ED_BUTTON_FILL:
- AreYouSure("Caution ! Flood fill mode ! Choose area !",AYS_OPEN);
+ Request("Caution ! Flood fill mode ! Choose area !",REQ_OPEN);
use_floodfill = TRUE;
return;
break;
case ED_BUTTON_LEFT:
if (level_xpos>=0)
{
- if (!DelayReached(&choice_delay,10))
+ if (!DelayReached(&choice_delay, CHOICE_DELAY_VALUE))
break;
if (lev_fieldx<2*SCR_FIELDX-2)
break;
case ED_BUTTON_RIGHT:
if (level_xpos<=lev_fieldx-2*SCR_FIELDX)
{
- if (!DelayReached(&choice_delay,10))
+ if (!DelayReached(&choice_delay, CHOICE_DELAY_VALUE))
break;
if (lev_fieldx<2*SCR_FIELDX-2)
break;
case ED_BUTTON_UP:
if (level_ypos>=0)
{
- if (!DelayReached(&choice_delay,10))
+ if (!DelayReached(&choice_delay, CHOICE_DELAY_VALUE))
break;
if (lev_fieldy<2*SCR_FIELDY-2)
break;
case ED_BUTTON_DOWN:
if (level_ypos<=lev_fieldy-2*SCR_FIELDY)
{
- if (!DelayReached(&choice_delay,10))
+ if (!DelayReached(&choice_delay, CHOICE_DELAY_VALUE))
break;
if (lev_fieldy<2*SCR_FIELDY-2)
break;
int choice = CheckCountButtons(mx,my,button);
int step = (button==1 ? 1 : button==2 ? 5 : button==3 ? 10 : 0);
- if (choice>=0 && choice<36 && DelayReached(&choice_delay,10))
+ if (choice >= 0 && choice < 36 &&
+ DelayReached(&choice_delay, CHOICE_DELAY_VALUE))
{
if (!(choice % 2))
step = -step;
edit_mode = TRUE;
break;
case ED_BUTTON_CLEAR:
- if (AreYouSure("Are you sure to clear this level ?",AYS_ASK))
+ if (Request("Are you sure to clear this level ?",REQ_ASK))
{
for(x=0;x<MAX_LEV_FIELDX;x++)
for(y=0;y<MAX_LEV_FIELDY;y++)
break;
case ED_BUTTON_UNDO:
if (leveldir[leveldir_nr].readonly ||
- AreYouSure("Exit without saving ?",AYS_ASK | AYS_STAY_OPEN))
+ Request("Exit without saving ?",REQ_ASK | REQ_STAY_OPEN))
{
CloseDoor(DOOR_CLOSE_BOTH);
game_status=MAINMENU;
if (leveldir[leveldir_nr].readonly)
{
- AreYouSure("This level is read only !",AYS_CONFIRM);
+ Request("This level is read only !",REQ_CONFIRM);
break;
}
figur_vorhanden = TRUE;
if (!figur_vorhanden)
- AreYouSure("No Level without Gregor Mc Duffin please !",
- AYS_CONFIRM);
+ Request("No Level without Gregor Mc Duffin please !",
+ REQ_CONFIRM);
else
{
- if (AreYouSure("Save this level and kill the old ?",
- AYS_ASK | AYS_STAY_OPEN))
+ if (Request("Save this level and kill the old ?",
+ REQ_ASK | REQ_STAY_OPEN))
{
for(x=0;x<lev_fieldx;x++)
for(y=0;y<lev_fieldy;y++)