X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Feditor.c;h=64e96e24164b6515b4c6ae7bcd3a52ead062fe1b;hb=f941ccddee3065d7531298e37ad4dcfcd892c1f8;hp=d7f0f4df364d76313f244891836cd4e6d4bda8c6;hpb=854913a35af50b39cd124772fbc1fe8ca51f127b;p=rocksndiamonds.git diff --git a/src/editor.c b/src/editor.c index d7f0f4df..64e96e24 100644 --- a/src/editor.c +++ b/src/editor.c @@ -11,6 +11,8 @@ * editor.c * ***********************************************************/ +#include + #include "editor.h" #include "screens.h" #include "tools.h" @@ -72,11 +74,30 @@ #define ED_CTRL2_BUTTON_XSIZE 30 #define ED_CTRL2_BUTTON_YSIZE 20 #define ED_CTRL2_BUTTONS_XPOS 5 -#define ED_CTRL2_BUTTONS_YPOS 100 +#define ED_CTRL2_BUTTONS_YPOS 99 #define ED_NUM_CTRL1_BUTTONS (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT) #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT) #define ED_NUM_CTRL_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS) +/* values for the element list */ +#define ED_ELEMENTLIST_UP_XPOS 35 +#define ED_ELEMENTLIST_UP_YPOS 5 +#define ED_ELEMENTLIST_UP_ALT_YPOS 140 +#define ED_ELEMENTLIST_DOWN_XPOS 35 +#define ED_ELEMENTLIST_DOWN_YPOS 250 +#define ED_ELEMENTLIST_DOWN_ALT_YPOS 165 +#define ED_ELEMENTLIST_UPDOWN_XSIZE 30 +#define ED_ELEMENTLIST_UPDOWN_YSIZE 25 +#define ED_ELEMENTLIST_XPOS 6 +#define ED_ELEMENTLIST_YPOS 30 +#define ED_ELEMENTLIST_ALT_YPOS 190 +#define ED_ELEMENTLIST_XSIZE 22 +#define ED_ELEMENTLIST_YSIZE 22 +#define ED_ELEMENTLIST_BUTTONS_HORIZ 4 +#define ED_ELEMENTLIST_BUTTONS_VERT 10 +#define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \ + ED_ELEMENTLIST_BUTTONS_VERT) + /* values for element properties window */ #define ED_PROPERTIES_XPOS (TILEX - MINI_TILEX/2) @@ -91,7 +112,10 @@ #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 @@ -132,14 +156,14 @@ #define ED_CTRL_ID_SINGLE_ITEMS 0 #define ED_CTRL_ID_CONNECTED_ITEMS 1 #define ED_CTRL_ID_LINE 2 -#define ED_CTRL_ID_TEXT 3 +#define ED_CTRL_ID_ARC 3 #define ED_CTRL_ID_RECTANGLE 4 #define ED_CTRL_ID_FILLED_BOX 5 #define ED_CTRL_ID_WRAP_UP 6 -#define ED_CTRL_ID_PROPERTIES 7 +#define ED_CTRL_ID_TEXT 7 #define ED_CTRL_ID_FLOOD_FILL 8 #define ED_CTRL_ID_WRAP_LEFT 9 -#define ED_CTRL_ID_UNUSED1 10 +#define ED_CTRL_ID_PROPERTIES 10 #define ED_CTRL_ID_WRAP_RIGHT 11 #define ED_CTRL_ID_RANDOM_PLACEMENT 12 #define ED_CTRL_ID_GRAB_BRUSH 13 @@ -165,57 +189,71 @@ #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 + +/* gadgets for scrolling element list */ +#define ED_CTRL_ID_ELEMENTLIST_UP 64 +#define ED_CTRL_ID_ELEMENTLIST_DOWN 65 + +/* gadgets for buttons in element list */ +#define ED_CTRL_ID_ELEMENTLIST_FIRST 66 +#define ED_CTRL_ID_ELEMENTLIST_LAST 105 -#define ED_NUM_GADGETS 60 +#define ED_NUM_GADGETS 106 /* 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_SCROLLBUTTONS 4 +#define ED_NUM_COUNTERBUTTONS 8 +#define ED_NUM_SCROLLBUTTONS 6 #define ED_NUM_SCROLLBARS 2 -#define ED_NUM_TEXTINPUT 1 +#define ED_NUM_TEXTINPUT 2 /* values for CopyLevelToUndoBuffer() */ #define UNDO_IMMEDIATE 0 @@ -237,14 +275,14 @@ static struct { 's', "draw single items" }, { 'd', "draw connected items" }, { 'l', "draw lines" }, - { 't', "enter text elements" }, + { 'a', "draw arcs" }, { 'r', "draw outline rectangles" }, { 'R', "draw filled rectangles" }, { '\0', "wrap (rotate) level up" }, - { '?', "properties of drawing element" }, + { 't', "enter text elements" }, { 'f', "flood fill" }, { '\0', "wrap (rotate) level left" }, - { '\0', "" }, + { '?', "properties of drawing element" }, { '\0', "wrap (rotate) level right" }, { '\0', "random element placement" }, { 'b', "grab brush" }, @@ -263,6 +301,7 @@ static int *gadget_elem_score_value = NULL; 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; @@ -294,7 +333,7 @@ static struct "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, @@ -302,7 +341,7 @@ static struct "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, @@ -310,7 +349,15 @@ static struct "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, @@ -318,7 +365,7 @@ static struct "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, @@ -326,7 +373,7 @@ static struct "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, @@ -344,10 +391,16 @@ static struct } 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" } }; @@ -361,23 +414,39 @@ static struct { { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 0 * ED_SCROLLBUTTON_YSIZE, - ED_SCROLL_UP_XPOS, ED_SCROLL_UP_YPOS, ED_CTRL_ID_SCROLL_UP, + ED_SCROLL_UP_XPOS, ED_SCROLL_UP_YPOS, + ED_CTRL_ID_SCROLL_UP, "scroll level editing area up" }, { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 1 * ED_SCROLLBUTTON_YSIZE, - ED_SCROLL_DOWN_XPOS, ED_SCROLL_DOWN_YPOS, ED_CTRL_ID_SCROLL_DOWN, + ED_SCROLL_DOWN_XPOS, ED_SCROLL_DOWN_YPOS, + ED_CTRL_ID_SCROLL_DOWN, "scroll level editing area down" }, { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 2 * ED_SCROLLBUTTON_YSIZE, - ED_SCROLL_LEFT_XPOS, ED_SCROLL_LEFT_YPOS, ED_CTRL_ID_SCROLL_LEFT, + ED_SCROLL_LEFT_XPOS, ED_SCROLL_LEFT_YPOS, + ED_CTRL_ID_SCROLL_LEFT, "scroll level editing area left" }, { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 3 * ED_SCROLLBUTTON_YSIZE, - ED_SCROLL_RIGHT_XPOS, ED_SCROLL_RIGHT_YPOS, ED_CTRL_ID_SCROLL_RIGHT, + ED_SCROLL_RIGHT_XPOS, ED_SCROLL_RIGHT_YPOS, + ED_CTRL_ID_SCROLL_RIGHT, "scroll level editing area right" + }, + { + ED_ELEMENTLIST_UP_XPOS, ED_ELEMENTLIST_UP_ALT_YPOS, + ED_ELEMENTLIST_UP_XPOS, ED_ELEMENTLIST_UP_YPOS, + ED_CTRL_ID_ELEMENTLIST_UP, + "scroll element list up" + }, + { + ED_ELEMENTLIST_DOWN_XPOS, ED_ELEMENTLIST_DOWN_ALT_YPOS, + ED_ELEMENTLIST_DOWN_XPOS, ED_ELEMENTLIST_DOWN_YPOS, + ED_CTRL_ID_ELEMENTLIST_DOWN, + "scroll element list down" } }; @@ -388,7 +457,7 @@ static struct int width, height; int type; int gadget_id; - char *text; + char *infotext; } scrollbar_info[ED_NUM_SCROLLBARS] = { { @@ -421,7 +490,6 @@ static void HandleDrawingAreaInfo(struct GadgetInfo *); static void HandleTextInputGadgets(struct GadgetInfo *); static struct GadgetInfo *level_editor_gadget[ED_NUM_GADGETS]; -static boolean level_editor_gadgets_created = FALSE; static int drawing_function = ED_CTRL_ID_SINGLE_ITEMS; static int last_drawing_function = ED_CTRL_ID_SINGLE_ITEMS; @@ -635,10 +703,10 @@ int editor_element[] = EL_MAUER_Y, EL_MAUER_XY, + EL_INVISIBLE_STEEL, + EL_UNSICHTBAR, EL_SPEED_PILL, EL_LEERRAUM, - EL_LEERRAUM, - EL_LEERRAUM, EL_CHAR_A + ('S' - 'A'), EL_CHAR_A + ('O' - 'A'), @@ -849,14 +917,6 @@ static void ScrollMiniLevel(int from_x, int from_y, int scroll) BackToFront(); } -void InitLevelEditorGadgets() -{ - int i; - - for (i=0; ix < DX) + UnmapGadget(level_editor_gadget[i]); } void UnmapLevelEditorGadgets() @@ -1432,10 +1566,7 @@ void DrawLevelEd() OpenDoor(DOOR_OPEN_1); - if (!level_editor_gadgets_created) - CreateLevelEditorGadgets(); - else - strcpy(level_editor_gadget[ED_CTRL_ID_LEVEL_NAME]->text.value, level.name); + strcpy(level_editor_gadget[ED_CTRL_ID_LEVEL_NAME]->text.value, level.name); MapControlButtons(); @@ -1651,8 +1782,9 @@ void AdjustEditorScrollbar(int id) 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); @@ -1767,6 +1899,9 @@ void LevelEd(int mx, int my, int button) } else /********** EDIT/CTRL-FENSTER **********/ { + + +#if 0 static unsigned long choice_delay = 0; int choice = CheckElemButtons(mx,my,button); int elem_pos = choice-ED_BUTTON_ELEM; @@ -1779,14 +1914,8 @@ void LevelEd(int mx, int my, int button) int step = (button == 1 ? 1 : button == 2 ? 5 : 10); int i; -#if 0 - step = (button==1 ? MAX_ELEM_X : button==2 ? 5*MAX_ELEM_X : - elements_in_list); - element_shift += (choice==ED_BUTTON_EUP ? -step : step); -#else step = step * MAX_ELEM_X * (choice == ED_BUTTON_EUP ? -1 : +1); element_shift += step; -#endif if (element_shift<0) element_shift = 0; @@ -1816,6 +1945,9 @@ void LevelEd(int mx, int my, int button) DrawPropertiesWindow(); } } +#endif + + if (edit_mode == ED_MODE_DRAWING) /********** EDIT-FENSTER **********/ { @@ -2306,7 +2438,7 @@ void LevelNameTyping(KeySym key) ascii = '_'; #endif - if (ascii && len from_x ? +1 : -1); + int to_y = to_y2 - (to_y2 > from_y ? +1 : -1); + int len_x = ABS(to_x - from_x); + int len_y = ABS(to_y - from_y); + int radius, x, y; + + radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5); + + /* not optimal (some points get drawn twice) but simple, + and fast enough for the few points we are drawing */ + + for (x=0; x<=radius; x++) + { + int sx, sy, lx, ly; + + y = (int)(sqrt((float)(radius * radius - x * x)) + 0.5); + + sx = from_x + x * (from_x < to_x2 ? +1 : -1); + sy = from_y + y * (from_y < to_y2 ? +1 : -1); + lx = sx + level_xpos; + ly = sy + level_ypos; + + if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly)) + DrawLineElement(sx, sy, element, change_level); + } + + for (y=0; y<=radius; y++) + { + int sx, sy, lx, ly; + + x = (int)(sqrt((float)(radius * radius - y * y)) + 0.5); + + sx = from_x + x * (from_x < to_x2 ? +1 : -1); + sy = from_y + y * (from_y < to_y2 ? +1 : -1); + lx = sx + level_xpos; + ly = sy + level_ypos; + + if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly)) + DrawLineElement(sx, sy, element, change_level); + } +} + +static void DrawArc(int from_x, int from_y, int to_x, int to_y, + int element, boolean change_level) +{ + int to_x2 = to_x + (to_x < from_x ? -1 : +1); + int to_y2 = to_y + (to_y > from_y ? +1 : -1); + + DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level); +} + +#if 0 +static void DrawCircle(int from_x, int from_y, int to_x, int to_y, + int element, boolean change_level) +{ + int to_x2 = to_x + (to_x < from_x ? -1 : +1); + int to_y2 = to_y + (to_y > from_y ? +1 : -1); + int mirror_to_x2 = from_x - (to_x2 - from_x); + int mirror_to_y2 = from_y - (to_y2 - from_y); + + DrawArcExt(from_x, from_y, to_x2, to_y2, element, change_level); + DrawArcExt(from_x, from_y, mirror_to_x2, to_y2, element, change_level); + DrawArcExt(from_x, from_y, to_x2, mirror_to_y2, element, change_level); + DrawArcExt(from_x, from_y, mirror_to_x2, mirror_to_y2, element,change_level); +} +#endif + static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y) { int from_sx, from_sy; @@ -3363,6 +3573,7 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) break; case ED_CTRL_ID_LINE: + case ED_CTRL_ID_ARC: case ED_CTRL_ID_RECTANGLE: case ED_CTRL_ID_FILLED_BOX: case ED_CTRL_ID_GRAB_BRUSH: @@ -3376,6 +3587,8 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) if (drawing_function == ED_CTRL_ID_LINE) draw_func = DrawLine; + else if (drawing_function == ED_CTRL_ID_ARC) + draw_func = DrawArc; else if (drawing_function == ED_CTRL_ID_RECTANGLE) draw_func = DrawRectangle; else if (drawing_function == ED_CTRL_ID_FILLED_BOX) @@ -3512,6 +3725,16 @@ static void HandleCounterButtons(struct GadgetInfo *gi) 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); @@ -3557,6 +3780,10 @@ static void HandleTextInputGadgets(struct GadgetInfo *gi) strcpy(level.name, gi->text.value); break; + case ED_CTRL_ID_LEVEL_AUTHOR: + strcpy(level.author, gi->text.value); + break; + default: break; } @@ -3570,7 +3797,7 @@ static void HandleControlButtons(struct GadgetInfo *gi) int new_element; int player_present = FALSE; int level_changed = FALSE; - int x, y; + int i, x, y; new_element = (button == 1 ? new_element1 : button == 2 ? new_element2 : @@ -3686,6 +3913,29 @@ static void HandleControlButtons(struct GadgetInfo *gi) DrawMiniLevel(level_xpos, level_ypos); break; + case ED_CTRL_ID_ELEMENTLIST_UP: + case ED_CTRL_ID_ELEMENTLIST_DOWN: + step *= (id == ED_CTRL_ID_ELEMENTLIST_UP ? -1 : +1); + element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ; + + if (element_shift < 0) + element_shift = 0; + if (element_shift > elements_in_list - ED_NUM_ELEMENTLIST_BUTTONS) + element_shift = elements_in_list - ED_NUM_ELEMENTLIST_BUTTONS; + + for (i=0; ideco.design; + + UnmapGadget(gi); + getMiniGraphicSource(el2gfx(editor_element[element_shift + i]), + &design->pixmap, &design->x, &design->y); + MapGadget(gi); + } + break; + case ED_CTRL_ID_WRAP_LEFT: WrapLevel(-step, 0); break; @@ -3705,6 +3955,7 @@ static void HandleControlButtons(struct GadgetInfo *gi) case ED_CTRL_ID_SINGLE_ITEMS: case ED_CTRL_ID_CONNECTED_ITEMS: case ED_CTRL_ID_LINE: + case ED_CTRL_ID_ARC: case ED_CTRL_ID_TEXT: case ED_CTRL_ID_RECTANGLE: case ED_CTRL_ID_FILLED_BOX: @@ -4061,6 +4312,9 @@ static void HandleDrawingAreaInfo(struct GadgetInfo *gi) case ED_CTRL_ID_LINE: infotext = "Drawing line"; break; + case ED_CTRL_ID_ARC: + infotext = "Drawing arc"; + break; case ED_CTRL_ID_TEXT: infotext = "Setting text cursor"; break; @@ -4098,7 +4352,7 @@ static void HandleDrawingAreaInfo(struct GadgetInfo *gi) /* misuse this function to draw brush cursor, if needed */ if (edit_mode == ED_MODE_DRAWING && draw_with_brush && !button_status) { - if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly)) + if (IN_ED_FIELD(sx, sy) && IN_LEV_FIELD(lx, ly)) CopyBrushToCursor(sx, sy); else DeleteBrushFromCursor();