/***********************************************************
-* Rocks'n'Diamonds -- McDuffin Strikes Back! *
+* Rocks'n'Diamonds -- McDuffin Strikes Back! *
*----------------------------------------------------------*
-* (c) 1995-98 Artsoft Entertainment *
-* Holger Schemel *
-* Oststrasse 11a *
-* 33604 Bielefeld *
-* phone: ++49 +521 290471 *
-* email: aeglos@valinor.owl.de *
+* (c) 1995-2001 Artsoft Entertainment *
+* Holger Schemel *
+* Detmolder Strasse 189 *
+* 33604 Bielefeld *
+* Germany *
+* e-mail: info@artsoft.org *
*----------------------------------------------------------*
-* editor.c *
+* editor.c *
***********************************************************/
#include <math.h>
+#include "libgame/libgame.h"
+
#include "editor.h"
#include "screens.h"
#include "tools.h"
-#include "misc.h"
-#include "buttons.h"
#include "files.h"
#include "game.h"
#include "tape.h"
#define GADGET_ID_DOUBLE_SPEED 73
#define GADGET_ID_GRAVITY 74
#define GADGET_ID_STICK_ELEMENT 75
+#define GADGET_ID_EM_SLIPPERY_GEMS 76
/* another drawing area for random placement */
-#define GADGET_ID_RANDOM_BACKGROUND 76
+#define GADGET_ID_RANDOM_BACKGROUND 77
/* gadgets for buttons in element list */
-#define GADGET_ID_ELEMENTLIST_FIRST 77
-#define GADGET_ID_ELEMENTLIST_LAST (77 + ED_NUM_ELEMENTLIST_BUTTONS - 1)
+#define GADGET_ID_ELEMENTLIST_FIRST 78
+#define GADGET_ID_ELEMENTLIST_LAST (78 + ED_NUM_ELEMENTLIST_BUTTONS - 1)
#define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
#define ED_CHECKBUTTON_ID_GRAVITY 1
#define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 2
#define ED_CHECKBUTTON_ID_STICK_ELEMENT 3
+#define ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS 4
-#define ED_NUM_CHECKBUTTONS 4
+#define ED_NUM_CHECKBUTTONS 5
#define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_DOUBLE_SPEED
#define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED
GADGET_ID_STICK_ELEMENT,
&stick_element_properties_window,
"stick window to edit content", "stick window to edit content"
+ },
+ {
+ ED_SETTINGS_XPOS, ED_COUNTER_YPOS(4),
+ GADGET_ID_EM_SLIPPERY_GEMS,
+ &level.em_slippery_gems,
+ "slip down from certain flat walls","use EM style slipping behaviour"
}
};
{
char *info_text = "unknown";
- if (element < num_element_info)
- info_text = element_info[element];
+ if (element < NUM_LEVEL_ELEMENTS)
+ info_text = element_info[element].editor_description;
else
Error(ERR_WARN, "no element description for element %d", element);
static void CreateControlButtons()
{
- Bitmap gd_bitmap = pix[PIX_DOOR];
+ Bitmap *gd_bitmap = pix[PIX_DOOR];
struct GadgetInfo *gi;
unsigned long event_mask;
int i;
GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
GDI_EVENT_MASK, event_mask,
+ GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
GDI_CALLBACK_ACTION, HandleControlButtons,
GDI_END);
GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
GDI_EVENT_MASK, event_mask,
+ GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
GDI_CALLBACK_ACTION, HandleControlButtons,
GDI_END);
/* create buttons for element list */
for (i=0; i<ED_NUM_ELEMENTLIST_BUTTONS; i++)
{
- Bitmap deco_bitmap;
+ Bitmap *deco_bitmap;
int deco_x, deco_y, deco_xpos, deco_ypos;
int gd_xoffset, gd_yoffset;
int gd_x1, gd_x2, gd_y;
GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY,
GDI_DECORATION_SHIFTING, 1, 1,
GDI_EVENT_MASK, event_mask,
+ GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
GDI_CALLBACK_ACTION, HandleControlButtons,
GDI_END);
for (j=0; j<2; j++)
{
- Bitmap gd_bitmap = pix[PIX_DOOR];
+ Bitmap *gd_bitmap = pix[PIX_DOOR];
struct GadgetInfo *gi;
int id = (j == 0 ?
counterbutton_info[i].gadget_id_down :
GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
GDI_EVENT_MASK, event_mask,
+ GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
GDI_CALLBACK_ACTION, HandleCounterButtons,
GDI_END);
GDI_BORDER_SIZE, ED_BORDER_SIZE,
GDI_TEXTINPUT_DESIGN_WIDTH, gd_width,
GDI_EVENT_MASK, event_mask,
+ GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
GDI_CALLBACK_ACTION, HandleCounterButtons,
GDI_END);
for (i=0; i<ED_NUM_TEXTINPUT; i++)
{
- Bitmap gd_bitmap = pix[PIX_DOOR];
+ Bitmap *gd_bitmap = pix[PIX_DOOR];
int gd_x, gd_y;
struct GadgetInfo *gi;
unsigned long event_mask;
GDI_BORDER_SIZE, ED_BORDER_SIZE,
GDI_TEXTINPUT_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
GDI_EVENT_MASK, event_mask,
+ GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
GDI_CALLBACK_ACTION, HandleTextInputGadgets,
GDI_END);
for (i=0; i<ED_NUM_SCROLLBARS; i++)
{
int id = scrollbar_info[i].gadget_id;
- Bitmap gd_bitmap = pix[PIX_DOOR];
+ Bitmap *gd_bitmap = pix[PIX_DOOR];
int gd_x1, gd_x2, gd_y1, gd_y2;
struct GadgetInfo *gi;
int items_max, items_visible, item_position;
GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
GDI_BORDER_SIZE, ED_BORDER_SIZE,
GDI_EVENT_MASK, event_mask,
+ GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
GDI_CALLBACK_ACTION, HandleControlButtons,
GDI_END);
static void CreateCheckbuttonGadgets()
{
- Bitmap gd_bitmap = pix[PIX_DOOR];
+ Bitmap *gd_bitmap = pix[PIX_DOOR];
struct GadgetInfo *gi;
unsigned long event_mask;
int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
GDI_EVENT_MASK, event_mask,
+ GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
GDI_CALLBACK_ACTION, HandleRadiobuttons,
GDI_END);
GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
GDI_EVENT_MASK, event_mask,
+ GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
GDI_CALLBACK_ACTION, HandleCheckbuttons,
GDI_END);
DOOR_GFX_PAGEX6, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
/* draw mouse button brush elements */
- DrawMiniGraphicExt(drawto, gc,
+ DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS,
el2gfx(new_element1));
- DrawMiniGraphicExt(drawto, gc,
+ DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS,
el2gfx(new_element2));
- DrawMiniGraphicExt(drawto, gc,
+ DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
el2gfx(new_element3));
if (button == 1)
{
new_element1 = element;
- DrawMiniGraphicExt(drawto, gc,
+ DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS,
el2gfx(new_element1));
}
else if (button == 2)
{
new_element2 = element;
- DrawMiniGraphicExt(drawto, gc,
+ DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS,
el2gfx(new_element2));
}
else
{
new_element3 = element;
- DrawMiniGraphicExt(drawto, gc,
+ DrawMiniGraphicExt(drawto,
DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
el2gfx(new_element3));
}
else
DrawElementContentAreas();
}
+
+ if (IS_GEM(properties_element))
+ {
+ /* draw checkbutton gadget */
+ i = ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS;
+ x = checkbutton_info[i].x + xoffset_right2;
+ y = checkbutton_info[i].y + yoffset_right2;
+
+ DrawTextF(x, y, font_color, checkbutton_info[i].text);
+ ModifyGadget(level_editor_gadget[checkbutton_info[i].gadget_id],
+ GDI_CHECKED, *checkbutton_info[i].value, GDI_END);
+ MapCheckbuttonGadget(i);
+ }
}
static void DrawLineElement(int sx, int sy, int element, boolean change_level)
}
else
{
- DrawMiniGraphicExt(drawto, gc,
+ DrawMiniGraphicExt(drawto,
gi->x + sx * MINI_TILEX,
gi->y + sy * MINI_TILEY,
el2gfx(new_element));
- DrawMiniGraphicExt(window, gc,
+ DrawMiniGraphicExt(window,
gi->x + sx * MINI_TILEX,
gi->y + sy * MINI_TILEY,
el2gfx(new_element));
break;
case GADGET_ID_EXIT:
- if (!LevelChanged() ||
- Request("Level has changed! Exit without saving ?",
- REQ_ASK | REQ_STAY_OPEN))
- {
- CloseDoor(DOOR_CLOSE_1);
-
- /*
- CloseDoor(DOOR_CLOSE_ALL);
- */
-
- game_status = MAINMENU;
- DrawMainMenu();
- }
- else
- {
- CloseDoor(DOOR_CLOSE_1);
- BlitBitmap(pix[PIX_DB_DOOR], pix[PIX_DB_DOOR],
- DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1, DXSIZE,DYSIZE,
- DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
- OpenDoor(DOOR_OPEN_1);
- }
+ RequestExitLevelEditor(TRUE); /* if level has changed, ask user */
break;
default:
DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
else if (key == KSYM_Return)
DrawLevelText(0, 0, 0, TEXT_NEWLINE);
+ else if (key == KSYM_Escape)
+ DrawLevelText(0, 0, 0, TEXT_END);
}
else if (button_status == MB_RELEASED)
{
- int i, id;
+ int i, id = GADGET_ID_NONE;
switch (key)
{
button = MB_RIGHTBUTTON;
break;
+ case KSYM_Escape:
+ if (edit_mode == ED_MODE_DRAWING)
+ {
+ RequestExitLevelEditor(setup.ask_on_escape);
+ }
+ else
+ {
+ DrawDrawingWindow();
+ edit_mode = ED_MODE_DRAWING;
+ }
+ break;
+
default:
- id = GADGET_ID_NONE;
break;
}
ClickOnGadget(level_editor_gadget[id], button);
else if (letter == '.')
ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
- else if (key == KSYM_space || key == KSYM_Return)
+ else if (key == KSYM_Return || key == setup.shortcut.toggle_pause)
ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
else
for (i=0; i<ED_NUM_CTRL_BUTTONS; i++)
char infotext[MAX_INFOTEXT_LEN + 1];
char shortcut[MAX_INFOTEXT_LEN + 1];
+ if (game_status != LEVELED)
+ return;
+
ClearEditorGadgetInfoText();
+ if (gi->event.type == GD_EVENT_INFO_LEAVING)
+ return;
+
/* misuse this function to delete brush cursor, if needed */
if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
DeleteBrushFromCursor();
ClearEditorGadgetInfoText();
+ if (gi->event.type == GD_EVENT_INFO_LEAVING)
+ return;
+
/* make sure to stay inside drawing area boundaries */
sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
"Content area %d position: %d, %d",
id - GADGET_ID_ELEM_CONTENT_0 + 1, sx, sy);
}
+
+void RequestExitLevelEditor(boolean ask_if_level_has_changed)
+{
+ if (!ask_if_level_has_changed ||
+ !LevelChanged() ||
+ Request("Level has changed! Exit without saving ?",
+ REQ_ASK | REQ_STAY_OPEN))
+ {
+ CloseDoor(DOOR_CLOSE_1);
+ /*
+ CloseDoor(DOOR_CLOSE_ALL);
+ */
+ game_status = MAINMENU;
+ DrawMainMenu();
+ }
+ else
+ {
+ CloseDoor(DOOR_CLOSE_1);
+ BlitBitmap(pix[PIX_DB_DOOR], pix[PIX_DB_DOOR],
+ DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1, DXSIZE,DYSIZE,
+ DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
+ OpenDoor(DOOR_OPEN_1);
+ }
+}