From 7eec2d73cfa570db7704b990d871e23ebfeb215b Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 16 Feb 1999 03:59:02 +0100 Subject: [PATCH] rnd-19990216-2 --- src/buttons.c | 4 + src/buttons.h | 64 ++++----- src/editor.c | 365 +++++++++++++++++++++----------------------------- src/game.c | 13 -- src/game.h | 13 ++ 5 files changed, 200 insertions(+), 259 deletions(-) diff --git a/src/buttons.c b/src/buttons.c index db43b201..c24981f3 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -510,6 +510,10 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap) gi->custom_id = va_arg(ap, int); break; + case GDI_CUSTOM_TYPE_ID: + gi->custom_type_id = va_arg(ap, int); + break; + case GDI_INFO_TEXT: { int max_textsize = MAX_INFO_TEXTSIZE - 1; diff --git a/src/buttons.h b/src/buttons.h index 3740bfc9..cd8db0ef 100644 --- a/src/buttons.h +++ b/src/buttons.h @@ -130,38 +130,39 @@ void DrawCompleteVideoDisplay(void); /* gadget creation tags */ #define GDI_END 0 #define GDI_CUSTOM_ID 1 -#define GDI_X 2 -#define GDI_Y 3 -#define GDI_WIDTH 4 -#define GDI_HEIGHT 5 -#define GDI_TYPE 6 -#define GDI_STATE 7 -#define GDI_CHECKED 8 -#define GDI_RADIO_NR 9 -#define GDI_NUMBER_VALUE 10 -#define GDI_NUMBER_MIN 11 -#define GDI_NUMBER_MAX 12 -#define GDI_TEXT_VALUE 13 -#define GDI_TEXT_SIZE 14 -#define GDI_DESIGN_UNPRESSED 15 -#define GDI_DESIGN_PRESSED 16 -#define GDI_ALT_DESIGN_UNPRESSED 17 -#define GDI_ALT_DESIGN_PRESSED 18 -#define GDI_DESIGN_BORDER 19 -#define GDI_DECORATION_DESIGN 20 +#define GDI_CUSTOM_TYPE_ID 2 +#define GDI_X 3 +#define GDI_Y 4 +#define GDI_WIDTH 5 +#define GDI_HEIGHT 6 +#define GDI_TYPE 7 +#define GDI_STATE 8 +#define GDI_CHECKED 9 +#define GDI_RADIO_NR 10 +#define GDI_NUMBER_VALUE 11 +#define GDI_NUMBER_MIN 12 +#define GDI_NUMBER_MAX 13 +#define GDI_TEXT_VALUE 14 +#define GDI_TEXT_SIZE 15 +#define GDI_DESIGN_UNPRESSED 16 +#define GDI_DESIGN_PRESSED 17 +#define GDI_ALT_DESIGN_UNPRESSED 18 +#define GDI_ALT_DESIGN_PRESSED 19 +#define GDI_DESIGN_BORDER 20 +#define GDI_DECORATION_DESIGN 21 #define GDI_DECORATION_POSITION 22 -#define GDI_DECORATION_SIZE 21 -#define GDI_DECORATION_SHIFTING 23 -#define GDI_EVENT_MASK 24 -#define GDI_EVENT 25 -#define GDI_CALLBACK_INFO 26 -#define GDI_CALLBACK_ACTION 27 -#define GDI_AREA_SIZE 28 -#define GDI_ITEM_SIZE 29 -#define GDI_SCROLLBAR_ITEMS_MAX 30 -#define GDI_SCROLLBAR_ITEMS_VISIBLE 31 -#define GDI_SCROLLBAR_ITEM_POSITION 32 -#define GDI_INFO_TEXT 33 +#define GDI_DECORATION_SIZE 23 +#define GDI_DECORATION_SHIFTING 24 +#define GDI_EVENT_MASK 25 +#define GDI_EVENT 26 +#define GDI_CALLBACK_INFO 27 +#define GDI_CALLBACK_ACTION 28 +#define GDI_AREA_SIZE 29 +#define GDI_ITEM_SIZE 30 +#define GDI_SCROLLBAR_ITEMS_MAX 31 +#define GDI_SCROLLBAR_ITEMS_VISIBLE 32 +#define GDI_SCROLLBAR_ITEM_POSITION 33 +#define GDI_INFO_TEXT 34 typedef void (*gadget_function)(void *); @@ -220,6 +221,7 @@ struct GadgetInfo { int id; /* internal gadget identifier */ int custom_id; /* custom gadget identifier */ + int custom_type_id; /* custom gadget type identifier */ char info_text[MAX_INFO_TEXTSIZE]; /* short popup info text */ int x, y; /* gadget position */ int width, height; /* gadget size */ diff --git a/src/editor.c b/src/editor.c index 9df18677..e909faa0 100644 --- a/src/editor.c +++ b/src/editor.c @@ -380,15 +380,15 @@ static struct { 'E', "exit level editor" } }; -/* pointers to counter values */ -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; +/* values for random placement */ +#define RANDOM_USE_PERCENTAGE 0 +#define RANDOM_USE_QUANTITY 1 + +static int random_placement_value = 10; +static int random_placement_method = RANDOM_USE_QUANTITY; +static int random_placement_background_element = EL_ERDREICH; +static boolean random_placement_background_restricted = FALSE; +static boolean stick_element_properties_window = FALSE; static struct { @@ -396,7 +396,7 @@ static struct int min_value, max_value; int gadget_id_down, gadget_id_up; int gadget_id_text; - int **counter_value; + int *value; char *infotext_above, *infotext_right; } counterbutton_info[ED_NUM_COUNTERBUTTONS] = { @@ -405,7 +405,7 @@ static struct MIN_SCORE, MAX_SCORE, GADGET_ID_ELEM_SCORE_DOWN, GADGET_ID_ELEM_SCORE_UP, GADGET_ID_ELEM_SCORE_TEXT, - &gadget_elem_score_value, + NULL, /* will be set when used */ "element score", NULL }, { @@ -413,7 +413,7 @@ static struct MIN_ELEM_CONTENT, MAX_ELEM_CONTENT, GADGET_ID_ELEM_CONTENT_DOWN, GADGET_ID_ELEM_CONTENT_UP, GADGET_ID_ELEM_CONTENT_TEXT, - &gadget_elem_content_value, + &MampferMax, "element content", NULL }, { @@ -421,7 +421,7 @@ static struct MIN_LEV_FIELDX, MAX_LEV_FIELDX, GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP, GADGET_ID_LEVEL_XSIZE_TEXT, - &gadget_level_xsize_value, + &level.fieldx, "playfield size", "width", }, { @@ -429,7 +429,7 @@ static struct MIN_LEV_FIELDY, MAX_LEV_FIELDY, GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP, GADGET_ID_LEVEL_YSIZE_TEXT, - &gadget_level_ysize_value, + &level.fieldy, NULL, "height", }, { @@ -437,7 +437,7 @@ static struct 0, 999, GADGET_ID_LEVEL_COLLECT_DOWN, GADGET_ID_LEVEL_COLLECT_UP, GADGET_ID_LEVEL_COLLECT_TEXT, - &gadget_level_collect_value, + &level.edelsteine, "number of emeralds to collect", NULL }, { @@ -445,7 +445,7 @@ static struct 0, 999, GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP, GADGET_ID_LEVEL_TIMELIMIT_TEXT, - &gadget_level_timelimit_value, + &level.time, "time available to solve level", "(0 => no time limit)" }, { @@ -453,7 +453,7 @@ static struct 0, 255, GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP, GADGET_ID_LEVEL_TIMESCORE_TEXT, - &gadget_level_timescore_value, + &level.score[SC_ZEITBONUS], "score for each 10 seconds left", NULL }, { @@ -461,7 +461,7 @@ static struct 1, 100, GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP, GADGET_ID_LEVEL_RANDOM_TEXT, - &gadget_level_random_value, + &random_placement_value, "random element placement", "in" } }; @@ -565,16 +565,6 @@ static struct } }; -/* values for random placement */ -#define RANDOM_USE_PERCENTAGE 0 -#define RANDOM_USE_QUANTITY 1 - -static int random_placement_value = 10; -static int random_placement_method = RANDOM_USE_QUANTITY; -static int random_placement_background_element = EL_ERDREICH; -static boolean random_placement_background_restricted = FALSE; -static boolean stick_element_properties_window = FALSE; - static struct { int x, y; @@ -655,17 +645,20 @@ static int new_element3 = EL_ERDREICH; #define BUTTON_ELEMENT(button) (button == 1 ? new_element1 : \ button == 2 ? new_element2 : \ button == 3 ? new_element3 : EL_LEERRAUM) +#define BUTTON_STEPSIZE(button) (button == 1 ? 1 : button == 2 ? 5 : 10) /* forward declaration for internal use */ static void DrawDrawingWindow(); static void DrawLevelInfoWindow(); static void DrawPropertiesWindow(); static void CopyLevelToUndoBuffer(int); -static void HandleControlButtons(struct GadgetInfo *); -static void HandleCounterButtons(struct GadgetInfo *); static void HandleDrawingAreas(struct GadgetInfo *); -static void HandleDrawingAreaInfo(struct GadgetInfo *); +static void HandleCounterButtons(struct GadgetInfo *); static void HandleTextInputGadgets(struct GadgetInfo *); +static void HandleRadiobuttons(struct GadgetInfo *); +static void HandleCheckbuttons(struct GadgetInfo *); +static void HandleControlButtons(struct GadgetInfo *); +static void HandleDrawingAreaInfo(struct GadgetInfo *); static struct GadgetInfo *level_editor_gadget[NUM_EDITOR_GADGETS]; @@ -1178,6 +1171,7 @@ static void CreateControlButtons() gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL_BUTTONS_ALT_GFX_YPOS + gd_yoffset; gi = CreateGadget(GDI_CUSTOM_ID, id, + GDI_CUSTOM_TYPE_ID, i, GDI_INFO_TEXT, control_info[i].text, GDI_X, EX + gd_xoffset, GDI_Y, EY + gd_yoffset, @@ -1235,9 +1229,10 @@ static void CreateControlButtons() gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].ypos; gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE; gd_y2 = gd_y1; - } + } gi = CreateGadget(GDI_CUSTOM_ID, id, + GDI_CUSTOM_TYPE_ID, i, GDI_INFO_TEXT, scrollbutton_info[i].infotext, GDI_X, x, GDI_Y, y, @@ -1283,6 +1278,7 @@ static void CreateControlButtons() deco_ypos = (ED_ELEMENTLIST_YSIZE - MINI_TILEY) / 2; gi = CreateGadget(GDI_CUSTOM_ID, id, + GDI_CUSTOM_TYPE_ID, i, GDI_INFO_TEXT, element_info[editor_element[i]], GDI_X, DX + gd_xoffset, GDI_Y, DY + gd_yoffset, @@ -1340,6 +1336,7 @@ static void CreateCounterButtons() (j == 0 ? "decrease" : "increase")); gi = CreateGadget(GDI_CUSTOM_ID, id, + GDI_CUSTOM_TYPE_ID, i, GDI_INFO_TEXT, infotext, GDI_X, xpos, GDI_Y, ypos, @@ -1368,6 +1365,7 @@ static void CreateCounterButtons() gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS; gi = CreateGadget(GDI_CUSTOM_ID, id, + GDI_CUSTOM_TYPE_ID, i, GDI_INFO_TEXT, "enter counter value", GDI_X, xpos, GDI_Y, ypos, @@ -1430,6 +1428,7 @@ static void CreateDrawingAreas() id = GADGET_ID_ELEM_CONTENT_0 + i; gi = CreateGadget(GDI_CUSTOM_ID, id, + GDI_CUSTOM_TYPE_ID, i, GDI_X, gx, GDI_Y, gy, GDI_WIDTH, 3 * MINI_TILEX, @@ -1509,6 +1508,7 @@ static void CreateTextInputGadgets() infotext[MAX_INFOTEXT_LEN] = '\0'; gi = CreateGadget(GDI_CUSTOM_ID, id, + GDI_CUSTOM_TYPE_ID, i, GDI_INFO_TEXT, infotext, GDI_X, SX + textinput_info[i].x, GDI_Y, SY + textinput_info[i].y, @@ -1563,6 +1563,7 @@ static void CreateScrollbarGadgets() gd_y2 = DOOR_GFX_PAGEY1 + scrollbar_info[i].ypos; gi = CreateGadget(GDI_CUSTOM_ID, id, + GDI_CUSTOM_TYPE_ID, i, GDI_INFO_TEXT, scrollbar_info[i].infotext, GDI_X, SX + scrollbar_info[i].x, GDI_Y, SY + scrollbar_info[i].y, @@ -1612,6 +1613,7 @@ static void CreateCheckbuttonGadgets() (*radiobutton_info[i].value == radiobutton_info[i].checked_value); gi = CreateGadget(GDI_CUSTOM_ID, id, + GDI_CUSTOM_TYPE_ID, i, GDI_INFO_TEXT, radiobutton_info[i].infotext, GDI_X, SX + radiobutton_info[i].x, GDI_Y, SY + radiobutton_info[i].y, @@ -1625,7 +1627,7 @@ static void CreateCheckbuttonGadgets() GDI_ALT_DESIGN_UNPRESSED, gd_pixmap, gd_x3, gd_y, GDI_ALT_DESIGN_PRESSED, gd_pixmap, gd_x4, gd_y, GDI_EVENT_MASK, event_mask, - GDI_CALLBACK_ACTION, HandleControlButtons, + GDI_CALLBACK_ACTION, HandleRadiobuttons, GDI_END); if (gi == NULL) @@ -1644,6 +1646,7 @@ static void CreateCheckbuttonGadgets() gd_y = DOOR_GFX_PAGEY1 + ED_CHECKBUTTON_YPOS; gi = CreateGadget(GDI_CUSTOM_ID, id, + GDI_CUSTOM_TYPE_ID, i, GDI_INFO_TEXT, checkbutton_info[i].infotext, GDI_X, SX + checkbutton_info[i].x, GDI_Y, SY + checkbutton_info[i].y, @@ -1656,7 +1659,7 @@ static void CreateCheckbuttonGadgets() GDI_ALT_DESIGN_UNPRESSED, gd_pixmap, gd_x3, gd_y, GDI_ALT_DESIGN_PRESSED, gd_pixmap, gd_x4, gd_y, GDI_EVENT_MASK, event_mask, - GDI_CALLBACK_ACTION, HandleControlButtons, + GDI_CALLBACK_ACTION, HandleCheckbuttons, GDI_END); if (gi == NULL) @@ -1976,7 +1979,7 @@ static void ModifyEditorTextInput(int textinput_id, char *new_text) static void ModifyEditorCounter(int counter_id, int new_value) { - int *counter_value = *counterbutton_info[counter_id].counter_value; + int *counter_value = counterbutton_info[counter_id].value; int gadget_id = counterbutton_info[counter_id].gadget_id_text; struct GadgetInfo *gi = level_editor_gadget[gadget_id]; @@ -2080,12 +2083,16 @@ static void DrawLevelInfoWindow() DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS2_YPOS, "Editor Settings", FS_BIG, FC_YELLOW); + + /* gadget_level_xsize_value = &lev_fieldx; gadget_level_ysize_value = &lev_fieldy; gadget_level_random_value = &random_placement_value; gadget_level_collect_value = &level.edelsteine; gadget_level_timelimit_value = &level.time; - gadget_level_timescore_value = &level.score[10]; + gadget_level_timescore_value = &level.score[SC_ZEITBONUS]; + */ + /* draw counter gadgets */ for (i=ED_COUNTER_ID_LEVEL_FIRST; i<=ED_COUNTER_ID_LEVEL_LAST; i++) @@ -2110,7 +2117,13 @@ static void DrawLevelInfoWindow() DrawTextF(x, y, font_color, infotext); } + + /* ModifyEditorCounter(i, **counterbutton_info[i].counter_value); + */ + + ModifyEditorCounter(i, *counterbutton_info[i].value); + MapCounterButtons(i); } @@ -2213,12 +2226,24 @@ static void DrawElementContentAreas() UnmapDrawingArea(GADGET_ID_ELEM_CONTENT_0 + i); /* display counter to choose number of element content areas */ + + /* gadget_elem_content_value = num_areas; + */ + x = counterbutton_info[ED_COUNTER_ID_ELEM_CONTENT].x + xoffset_right; y = counterbutton_info[ED_COUNTER_ID_ELEM_CONTENT].y + yoffset_right; DrawTextF(x, y, font_color, "number of content areas"); + + /* ModifyEditorCounter(ED_COUNTER_ID_ELEM_CONTENT, *gadget_elem_content_value); + */ + + + ModifyEditorCounter(ED_COUNTER_ID_ELEM_CONTENT, + *counterbutton_info[ED_COUNTER_ID_ELEM_CONTENT].value); + MapCounterButtons(ED_COUNTER_ID_ELEM_CONTENT); /* delete content areas in case of reducing number of them */ @@ -2289,55 +2314,55 @@ static void DrawPropertiesWindow() static struct { int element; - int *counter_value; + int *value; char *text; } elements_with_counter[] = { - { EL_EDELSTEIN, &level.score[0], TEXT_COLLECTING }, - { EL_EDELSTEIN_BD, &level.score[0], TEXT_COLLECTING }, - { EL_EDELSTEIN_GELB,&level.score[0], TEXT_COLLECTING }, - { EL_EDELSTEIN_ROT, &level.score[0], TEXT_COLLECTING }, - { EL_EDELSTEIN_LILA,&level.score[0], TEXT_COLLECTING }, - { EL_DIAMANT, &level.score[1], TEXT_COLLECTING }, - { EL_KAEFER_R, &level.score[2], TEXT_SMASHING }, - { EL_KAEFER_O, &level.score[2], TEXT_SMASHING }, - { EL_KAEFER_L, &level.score[2], TEXT_SMASHING }, - { EL_KAEFER_U, &level.score[2], TEXT_SMASHING }, - { EL_BUTTERFLY_R, &level.score[2], TEXT_SMASHING }, - { EL_BUTTERFLY_O, &level.score[2], TEXT_SMASHING }, - { EL_BUTTERFLY_L, &level.score[2], TEXT_SMASHING }, - { EL_BUTTERFLY_U, &level.score[2], TEXT_SMASHING }, - { EL_FLIEGER_R, &level.score[3], TEXT_SMASHING }, - { EL_FLIEGER_O, &level.score[3], TEXT_SMASHING }, - { EL_FLIEGER_L, &level.score[3], TEXT_SMASHING }, - { EL_FLIEGER_U, &level.score[3], TEXT_SMASHING }, - { EL_FIREFLY_R, &level.score[3], TEXT_SMASHING }, - { EL_FIREFLY_O, &level.score[3], TEXT_SMASHING }, - { EL_FIREFLY_L, &level.score[3], TEXT_SMASHING }, - { EL_FIREFLY_U, &level.score[3], TEXT_SMASHING }, - { EL_MAMPFER, &level.score[4], TEXT_SMASHING }, - { EL_MAMPFER2, &level.score[4], TEXT_SMASHING }, - { EL_ROBOT, &level.score[5], TEXT_SMASHING }, - { EL_PACMAN_R, &level.score[6], TEXT_SMASHING }, - { EL_PACMAN_O, &level.score[6], TEXT_SMASHING }, - { EL_PACMAN_L, &level.score[6], TEXT_SMASHING }, - { EL_PACMAN_U, &level.score[6], TEXT_SMASHING }, - { EL_KOKOSNUSS, &level.score[7], TEXT_CRACKING }, - { EL_DYNAMIT_AUS, &level.score[8], TEXT_COLLECTING }, - { EL_SCHLUESSEL1, &level.score[9], TEXT_COLLECTING }, - { EL_SCHLUESSEL2, &level.score[9], TEXT_COLLECTING }, - { EL_SCHLUESSEL3, &level.score[9], TEXT_COLLECTING }, - { EL_SCHLUESSEL4, &level.score[9], TEXT_COLLECTING }, - { EL_EM_KEY_1_FILE, &level.score[9], TEXT_COLLECTING }, - { EL_EM_KEY_2_FILE, &level.score[9], TEXT_COLLECTING }, - { EL_EM_KEY_3_FILE, &level.score[9], TEXT_COLLECTING }, - { EL_EM_KEY_4_FILE, &level.score[9], TEXT_COLLECTING }, - { EL_AMOEBE_NASS, &level.tempo_amoebe, TEXT_SPEED }, - { EL_AMOEBE_NORM, &level.tempo_amoebe, TEXT_SPEED }, - { EL_AMOEBE_VOLL, &level.tempo_amoebe, TEXT_SPEED }, - { EL_AMOEBE_BD, &level.tempo_amoebe, TEXT_SPEED }, - { EL_SIEB_INAKTIV, &level.dauer_sieb, TEXT_DURATION }, - { EL_ABLENK_AUS, &level.dauer_ablenk, TEXT_DURATION }, + { EL_EDELSTEIN, &level.score[SC_EDELSTEIN], TEXT_COLLECTING }, + { EL_EDELSTEIN_BD, &level.score[SC_EDELSTEIN], TEXT_COLLECTING }, + { EL_EDELSTEIN_GELB,&level.score[SC_EDELSTEIN], TEXT_COLLECTING }, + { EL_EDELSTEIN_ROT, &level.score[SC_EDELSTEIN], TEXT_COLLECTING }, + { EL_EDELSTEIN_LILA,&level.score[SC_EDELSTEIN], TEXT_COLLECTING }, + { EL_DIAMANT, &level.score[SC_DIAMANT], TEXT_COLLECTING }, + { EL_KAEFER_R, &level.score[SC_KAEFER], TEXT_SMASHING }, + { EL_KAEFER_O, &level.score[SC_KAEFER], TEXT_SMASHING }, + { EL_KAEFER_L, &level.score[SC_KAEFER], TEXT_SMASHING }, + { EL_KAEFER_U, &level.score[SC_KAEFER], TEXT_SMASHING }, + { EL_BUTTERFLY_R, &level.score[SC_KAEFER], TEXT_SMASHING }, + { EL_BUTTERFLY_O, &level.score[SC_KAEFER], TEXT_SMASHING }, + { EL_BUTTERFLY_L, &level.score[SC_KAEFER], TEXT_SMASHING }, + { EL_BUTTERFLY_U, &level.score[SC_KAEFER], TEXT_SMASHING }, + { EL_FLIEGER_R, &level.score[SC_FLIEGER], TEXT_SMASHING }, + { EL_FLIEGER_O, &level.score[SC_FLIEGER], TEXT_SMASHING }, + { EL_FLIEGER_L, &level.score[SC_FLIEGER], TEXT_SMASHING }, + { EL_FLIEGER_U, &level.score[SC_FLIEGER], TEXT_SMASHING }, + { EL_FIREFLY_R, &level.score[SC_FLIEGER], TEXT_SMASHING }, + { EL_FIREFLY_O, &level.score[SC_FLIEGER], TEXT_SMASHING }, + { EL_FIREFLY_L, &level.score[SC_FLIEGER], TEXT_SMASHING }, + { EL_FIREFLY_U, &level.score[SC_FLIEGER], TEXT_SMASHING }, + { EL_MAMPFER, &level.score[SC_MAMPFER], TEXT_SMASHING }, + { EL_MAMPFER2, &level.score[SC_MAMPFER], TEXT_SMASHING }, + { EL_ROBOT, &level.score[SC_ROBOT], TEXT_SMASHING }, + { EL_PACMAN_R, &level.score[SC_PACMAN], TEXT_SMASHING }, + { EL_PACMAN_O, &level.score[SC_PACMAN], TEXT_SMASHING }, + { EL_PACMAN_L, &level.score[SC_PACMAN], TEXT_SMASHING }, + { EL_PACMAN_U, &level.score[SC_PACMAN], TEXT_SMASHING }, + { EL_KOKOSNUSS, &level.score[SC_KOKOSNUSS], TEXT_CRACKING }, + { EL_DYNAMIT_AUS, &level.score[SC_DYNAMIT], TEXT_COLLECTING }, + { EL_SCHLUESSEL1, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING }, + { EL_SCHLUESSEL2, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING }, + { EL_SCHLUESSEL3, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING }, + { EL_SCHLUESSEL4, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING }, + { EL_EM_KEY_1_FILE, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING }, + { EL_EM_KEY_2_FILE, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING }, + { EL_EM_KEY_3_FILE, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING }, + { EL_EM_KEY_4_FILE, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING }, + { EL_AMOEBE_NASS, &level.tempo_amoebe, TEXT_SPEED }, + { EL_AMOEBE_NORM, &level.tempo_amoebe, TEXT_SPEED }, + { EL_AMOEBE_VOLL, &level.tempo_amoebe, TEXT_SPEED }, + { EL_AMOEBE_BD, &level.tempo_amoebe, TEXT_SPEED }, + { EL_SIEB_INAKTIV, &level.dauer_sieb, TEXT_DURATION }, + { EL_ABLENK_AUS, &level.dauer_ablenk, TEXT_DURATION }, { -1, NULL, NULL } }; @@ -2397,10 +2422,26 @@ static void DrawPropertiesWindow() int x = counterbutton_info[ED_COUNTER_ID_ELEM_SCORE].x + xoffset_right; int y = counterbutton_info[ED_COUNTER_ID_ELEM_SCORE].y + yoffset_right; + + /* gadget_elem_score_value = elements_with_counter[i].counter_value; + */ + + + counterbutton_info[ED_COUNTER_ID_ELEM_SCORE].value = + elements_with_counter[i].value; DrawTextF(x, y, font_color, elements_with_counter[i].text); + + + /* ModifyEditorCounter(ED_COUNTER_ID_ELEM_SCORE, *gadget_elem_score_value); + */ + + + ModifyEditorCounter(ED_COUNTER_ID_ELEM_SCORE, + *counterbutton_info[ED_COUNTER_ID_ELEM_SCORE].value); + MapCounterButtons(ED_COUNTER_ID_ELEM_SCORE); break; } @@ -3289,127 +3330,47 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) static void HandleCounterButtons(struct GadgetInfo *gi) { - int id = gi->custom_id; + int gadget_id = gi->custom_id; + int counter_id = gi->custom_type_id; int button = gi->event.button; - int step = (button == 1 ? 1 : button == 2 ? 5 : 10); + int *counter_value = counterbutton_info[counter_id].value; + int step = BUTTON_STEPSIZE(button) * + (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1); - switch (id) - { - case GADGET_ID_ELEM_SCORE_DOWN: - case GADGET_ID_ELEM_SCORE_UP: - step *= (id == GADGET_ID_ELEM_SCORE_DOWN ? -1 : 1); - ModifyEditorCounter(ED_COUNTER_ID_ELEM_SCORE, - *gadget_elem_score_value + step); - break; - case GADGET_ID_ELEM_SCORE_TEXT: - *gadget_elem_score_value = gi->text.number_value; - break; - - case GADGET_ID_ELEM_CONTENT_DOWN: - case GADGET_ID_ELEM_CONTENT_UP: - step *= (id == GADGET_ID_ELEM_CONTENT_DOWN ? -1 : 1); - ModifyEditorCounter(ED_COUNTER_ID_ELEM_CONTENT, - *gadget_elem_content_value + step); - DrawElementContentAreas(); - break; - case GADGET_ID_ELEM_CONTENT_TEXT: - *gadget_elem_content_value = gi->text.number_value; - DrawElementContentAreas(); - break; - - case GADGET_ID_LEVEL_XSIZE_DOWN: - case GADGET_ID_LEVEL_XSIZE_UP: - step *= (id == GADGET_ID_LEVEL_XSIZE_DOWN ? -1 : 1); - ModifyEditorCounter(ED_COUNTER_ID_LEVEL_XSIZE, - *gadget_level_xsize_value + step); - level.fieldx = lev_fieldx; - break; - case GADGET_ID_LEVEL_XSIZE_TEXT: - *gadget_level_xsize_value = gi->text.number_value; - level.fieldx = lev_fieldx; - break; - - case GADGET_ID_LEVEL_YSIZE_DOWN: - case GADGET_ID_LEVEL_YSIZE_UP: - step *= (id == GADGET_ID_LEVEL_YSIZE_DOWN ? -1 : 1); - ModifyEditorCounter(ED_COUNTER_ID_LEVEL_YSIZE, - *gadget_level_ysize_value + step); - level.fieldy = lev_fieldy; - break; - case GADGET_ID_LEVEL_YSIZE_TEXT: - *gadget_level_ysize_value = gi->text.number_value; - level.fieldy = lev_fieldy; - break; - - case GADGET_ID_LEVEL_RANDOM_DOWN: - case GADGET_ID_LEVEL_RANDOM_UP: - step *= (id == GADGET_ID_LEVEL_RANDOM_DOWN ? -1 : 1); - ModifyEditorCounter(ED_COUNTER_ID_LEVEL_RANDOM, - *gadget_level_random_value + step); - break; - case GADGET_ID_LEVEL_RANDOM_TEXT: - *gadget_level_random_value = gi->text.number_value; - break; - - case GADGET_ID_LEVEL_COLLECT_DOWN: - case GADGET_ID_LEVEL_COLLECT_UP: - step *= (id == GADGET_ID_LEVEL_COLLECT_DOWN ? -1 : 1); - ModifyEditorCounter(ED_COUNTER_ID_LEVEL_COLLECT, - *gadget_level_collect_value + step); - break; - case GADGET_ID_LEVEL_COLLECT_TEXT: - *gadget_level_collect_value = gi->text.number_value; - break; - - case GADGET_ID_LEVEL_TIMELIMIT_DOWN: - case GADGET_ID_LEVEL_TIMELIMIT_UP: - step *= (id == GADGET_ID_LEVEL_TIMELIMIT_DOWN ? -1 : 1); - ModifyEditorCounter(ED_COUNTER_ID_LEVEL_TIMELIMIT, - *gadget_level_timelimit_value + step); - break; - case GADGET_ID_LEVEL_TIMELIMIT_TEXT: - *gadget_level_timelimit_value = gi->text.number_value; - break; - - case GADGET_ID_LEVEL_TIMESCORE_DOWN: - case GADGET_ID_LEVEL_TIMESCORE_UP: - step *= (id == GADGET_ID_LEVEL_TIMESCORE_DOWN ? -1 : 1); - ModifyEditorCounter(ED_COUNTER_ID_LEVEL_TIMESCORE, - *gadget_level_timescore_value + step); - break; - case GADGET_ID_LEVEL_TIMESCORE_TEXT: - *gadget_level_timescore_value = gi->text.number_value; - break; - - default: - break; - } + if (gadget_id == counterbutton_info[counter_id].gadget_id_text) + *counter_value = gi->text.number_value; + else + ModifyEditorCounter(counter_id, *counter_value + step); + + if (counter_id == ED_COUNTER_ID_ELEM_CONTENT) + DrawElementContentAreas(); + else if (counter_id == ED_COUNTER_ID_LEVEL_XSIZE) + lev_fieldx = level.fieldx; + else if (counter_id == ED_COUNTER_ID_LEVEL_YSIZE) + lev_fieldy = level.fieldy; } static void HandleTextInputGadgets(struct GadgetInfo *gi) { - int id = gi->custom_id; - - switch (id) - { - case GADGET_ID_LEVEL_NAME: - strcpy(level.name, gi->text.value); - break; + strcpy(textinput_info[gi->custom_type_id].value, gi->text.value); +} - case GADGET_ID_LEVEL_AUTHOR: - strcpy(level.author, gi->text.value); - break; +static void HandleRadiobuttons(struct GadgetInfo *gi) +{ + *radiobutton_info[gi->custom_type_id].value = + radiobutton_info[gi->custom_type_id].checked_value; +} - default: - break; - } +static void HandleCheckbuttons(struct GadgetInfo *gi) +{ + *checkbutton_info[gi->custom_type_id].value ^= TRUE; } static void HandleControlButtons(struct GadgetInfo *gi) { int id = gi->custom_id; int button = gi->event.button; - int step = (button == 1 ? 1 : button == 2 ? 5 : 10); + int step = BUTTON_STEPSIZE(button); int new_element = BUTTON_ELEMENT(button); int player_present = FALSE; int level_changed = FALSE; @@ -3745,32 +3706,6 @@ static void HandleControlButtons(struct GadgetInfo *gi) } break; - case GADGET_ID_RANDOM_PERCENTAGE: - *radiobutton_info[ED_RADIOBUTTON_ID_PERCENTAGE].value = - radiobutton_info[ED_RADIOBUTTON_ID_PERCENTAGE].checked_value; - break; - - case GADGET_ID_RANDOM_QUANTITY: - *radiobutton_info[ED_RADIOBUTTON_ID_QUANTITY].value = - radiobutton_info[ED_RADIOBUTTON_ID_QUANTITY].checked_value; - break; - - case GADGET_ID_RANDOM_RESTRICTED: - *checkbutton_info[ED_CHECKBUTTON_ID_RANDOM_RESTRICTED].value ^= TRUE; - break; - - case GADGET_ID_DOUBLE_SPEED: - *checkbutton_info[ED_CHECKBUTTON_ID_DOUBLE_SPEED].value ^= TRUE; - break; - - case GADGET_ID_GRAVITY: - *checkbutton_info[ED_CHECKBUTTON_ID_GRAVITY].value ^= TRUE; - break; - - case GADGET_ID_STICK_ELEMENT: - *checkbutton_info[ED_CHECKBUTTON_ID_STICK_ELEMENT].value ^= TRUE; - break; - default: if (id >= GADGET_ID_ELEMENTLIST_FIRST && id <= GADGET_ID_ELEMENTLIST_LAST) diff --git a/src/game.c b/src/game.c index 2df15b77..f66cd400 100644 --- a/src/game.c +++ b/src/game.c @@ -87,19 +87,6 @@ #define DOUBLE_PLAYER_SPEED(p) (HALVE_MOVE_DELAY((p)->move_delay_value)) #define HALVE_PLAYER_SPEED(p) (DOUBLE_MOVE_DELAY((p)->move_delay_value)) -/* score for elements */ -#define SC_EDELSTEIN 0 -#define SC_DIAMANT 1 -#define SC_KAEFER 2 -#define SC_FLIEGER 3 -#define SC_MAMPFER 4 -#define SC_ROBOT 5 -#define SC_PACMAN 6 -#define SC_KOKOSNUSS 7 -#define SC_DYNAMIT 8 -#define SC_SCHLUESSEL 9 -#define SC_ZEITBONUS 10 - /* game button identifiers */ #define GAME_CTRL_ID_STOP 0 #define GAME_CTRL_ID_PAUSE 1 diff --git a/src/game.h b/src/game.h index 8e33f098..20b8e89a 100644 --- a/src/game.h +++ b/src/game.h @@ -16,6 +16,19 @@ #include "main.h" +/* score for elements (also used by editor.c) */ +#define SC_EDELSTEIN 0 +#define SC_DIAMANT 1 +#define SC_KAEFER 2 +#define SC_FLIEGER 3 +#define SC_MAMPFER 4 +#define SC_ROBOT 5 +#define SC_PACMAN 6 +#define SC_KOKOSNUSS 7 +#define SC_DYNAMIT 8 +#define SC_SCHLUESSEL 9 +#define SC_ZEITBONUS 10 + void GetPlayerConfig(void); void InitGame(void); void InitMovDir(int, int); -- 2.34.1