From: Holger Schemel Date: Sun, 3 Jan 1999 23:19:14 +0000 (+0100) Subject: rnd-19990104-1 X-Git-Tag: 1.3.0^2~39 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=209871b6f17880f98d41cf7d7953f6bf2227a16c;p=rocksndiamonds.git rnd-19990104-1 --- diff --git a/src/buttons.c b/src/buttons.c index 9200cf85..2d6c173e 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -1749,6 +1749,19 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) redraw_mask |= REDRAW_ALL; } +void ClickOnGadget(struct GadgetInfo *gi) +{ + /* simulate releasing mouse button over last gadget, if still pressed */ + if (button_status) + HandleGadgets(-1, -1, 0); + + /* simulate pressing mouse button over specified gadget */ + HandleGadgets(gi->x, gi->y, 1); + + /* simulate releasing mouse button over specified gadget */ + HandleGadgets(gi->x, gi->y, 0); +} + void MapGadget(struct GadgetInfo *gi) { if (gi == NULL) @@ -1769,10 +1782,10 @@ void UnmapGadget(struct GadgetInfo *gi) void HandleGadgets(int mx, int my, int button) { - static struct GadgetInfo *gi = NULL; + static struct GadgetInfo *last_gi = NULL; static unsigned long pressed_delay = 0; - struct GadgetInfo *new_gi; + struct GadgetInfo *new_gi, *gi; boolean gadget_pressed; boolean gadget_pressed_repeated; boolean gadget_moving; @@ -1783,23 +1796,28 @@ void HandleGadgets(int mx, int my, int button) if (gadget_list_first_entry == NULL) return; - new_gi = getGadgetInfoFromMousePosition(mx,my); + new_gi = getGadgetInfoFromMousePosition(mx, my); gadget_pressed = - (button != 0 && gi == NULL && new_gi != NULL && !motion_status); + (button != 0 && last_gi == NULL && new_gi != NULL && !motion_status); gadget_pressed_repeated = - (button != 0 && gi != NULL && new_gi == gi); + (button != 0 && last_gi != NULL && new_gi == last_gi); gadget_moving = - (button != 0 && gi != NULL && new_gi == gi && motion_status); + (button != 0 && last_gi != NULL && new_gi == last_gi && motion_status); gadget_moving_off_borders = - (button != 0 && gi != NULL && new_gi != gi && motion_status); + (button != 0 && last_gi != NULL && new_gi != last_gi && motion_status); gadget_released = - (button == 0 && gi != NULL && new_gi == gi); + (button == 0 && last_gi != NULL && new_gi == last_gi); gadget_released_off_borders = - (button == 0 && gi != NULL && new_gi != gi); + (button == 0 && last_gi != NULL && new_gi != last_gi); if (gadget_pressed) - gi = new_gi; + last_gi = new_gi; + + gi = last_gi; + + if (button == 0) + last_gi = NULL; if (gi) { @@ -1903,7 +1921,4 @@ void HandleGadgets(int mx, int my, int button) gi->event_mask & GD_EVENT_OFF_BORDERS) gi->callback(gi); } - - if (button == 0) - gi = NULL; } diff --git a/src/buttons.h b/src/buttons.h index 718f1ee5..e3ba29be 100644 --- a/src/buttons.h +++ b/src/buttons.h @@ -368,6 +368,8 @@ struct GadgetInfo struct GadgetInfo *CreateGadget(int, ...); void FreeGadget(struct GadgetInfo *); +void ClickOnGadget(struct GadgetInfo *); + void MapGadget(struct GadgetInfo *); void UnmapGadget(struct GadgetInfo *); diff --git a/src/editor.c b/src/editor.c index 7c453d92..1e4d4f5f 100644 --- a/src/editor.c +++ b/src/editor.c @@ -101,7 +101,7 @@ #define ED_CTRL_ID_RANDOM_PLACEMENT 12 #define ED_CTRL_ID_BRUSH 13 #define ED_CTRL_ID_WRAP_DOWN 14 -#define ED_CTRL_ID_UNUSED2 15 +#define ED_CTRL_ID_PICK_ELEMENT 15 #define ED_CTRL_ID_UNDO 16 #define ED_CTRL_ID_INFO 17 #define ED_CTRL_ID_SAVE 18 @@ -153,6 +153,7 @@ 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; static int properties_element = 0; static short ElementContent[MAX_ELEMCONT][3][3]; @@ -607,7 +608,8 @@ static void CreateControlButtons() id == ED_CTRL_ID_RECTANGLE || id == ED_CTRL_ID_FILLED_BOX || id == ED_CTRL_ID_FLOOD_FILL || - id == ED_CTRL_ID_BRUSH) + id == ED_CTRL_ID_BRUSH || + id == ED_CTRL_ID_PICK_ELEMENT) { button_type = GD_TYPE_RADIO_BUTTON; radio_button_nr = 1; @@ -1149,6 +1151,39 @@ void AdjustLevelScrollPosition() level_ypos = -1; } +static void PickDrawingElement(int button, int element) +{ + if (button < 1 || button > 3) + return; + + if (button == 1) + { + new_element1 = element; + DrawMiniGraphicExt(drawto, gc, + 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, + DX + ED_WIN_MB_MIDDLE_XPOS, + DY + ED_WIN_MB_MIDDLE_YPOS, + el2gfx(new_element2)); + } + else + { + new_element3 = element; + DrawMiniGraphicExt(drawto, gc, + DX + ED_WIN_MB_RIGHT_XPOS, + DY + ED_WIN_MB_RIGHT_YPOS, + el2gfx(new_element3)); + } + + redraw_mask |= REDRAW_DOOR_1; +} + void LevelEd(int mx, int my, int button) { static int last_button = 0; @@ -1249,26 +1284,7 @@ void LevelEd(int mx, int my, int button) else new_element = EL_LEERRAUM; - if (last_button==1) - new_element1 = new_element; - else if (last_button==2) - new_element2 = new_element; - else if (last_button==3) - new_element3 = new_element; - - 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; + PickDrawingElement(last_button, new_element); if (!HAS_CONTENT(properties_element)) { @@ -2642,6 +2658,13 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) } break; + case ED_CTRL_ID_PICK_ELEMENT: + if (button_press_event) + PickDrawingElement(button, Feld[lx][ly]); + if (button_release_event) + ClickOnGadget(level_editor_gadget[last_drawing_function]); + break; + default: break; } @@ -2716,6 +2739,8 @@ static void HandleControlButtons(struct GadgetInfo *gi) case ED_CTRL_ID_FILLED_BOX: case ED_CTRL_ID_FLOOD_FILL: case ED_CTRL_ID_BRUSH: + case ED_CTRL_ID_PICK_ELEMENT: + last_drawing_function = drawing_function; drawing_function = id; break; diff --git a/src/files.c b/src/files.c index f0be82d6..069e61a9 100644 --- a/src/files.c +++ b/src/files.c @@ -73,6 +73,17 @@ #define TAPE_PERMS LEVEL_PERMS #define SETUP_PERMS LEVEL_PERMS +/* sort priorities of level series (also used as level series classes) */ +#define LEVELCLASS_TUTORIAL_START 10 +#define LEVELCLASS_TUTORIAL_END 99 +#define LEVELCLASS_CLASSICS_START 100 +#define LEVELCLASS_CLASSICS_END 199 +#define LEVELCLASS_CONTRIBUTION_START 200 +#define LEVELCLASS_CONTRIBUTION_END 299 +#define LEVELCLASS_USER_START 300 +#define LEVELCLASS_USER_END 399 +#define LEVELCLASS_UNDEFINED 999 + static void SaveUserLevelInfo(); /* for 'InitUserLevelDir()' */ static char *getSetupLine(char *, int); /* for 'SaveUserLevelInfo()' */ @@ -400,7 +411,9 @@ void LoadLevel(int level_nr) level.time = 10; #endif - if (file_version == FILE_VERSION_1_0) + if (file_version == FILE_VERSION_1_0 && + leveldir[leveldir_nr].sort_priority >= LEVELCLASS_CONTRIBUTION_START && + leveldir[leveldir_nr].sort_priority <= LEVELCLASS_CONTRIBUTION_END) { Error(ERR_WARN, "level file '%s' has version number 1.0", filename); Error(ERR_WARN, "using high speed movement for player"); @@ -873,8 +886,9 @@ void SaveScore(int level_nr) /* level directory info */ #define LEVELINFO_TOKEN_NAME 29 #define LEVELINFO_TOKEN_LEVELS 30 -#define LEVELINFO_TOKEN_SORT_PRIORITY 31 -#define LEVELINFO_TOKEN_READONLY 32 +#define LEVELINFO_TOKEN_FIRST_LEVEL 31 +#define LEVELINFO_TOKEN_SORT_PRIORITY 32 +#define LEVELINFO_TOKEN_READONLY 33 #define FIRST_GLOBAL_SETUP_TOKEN SETUP_TOKEN_PLAYER_NAME #define LAST_GLOBAL_SETUP_TOKEN SETUP_TOKEN_TEAM_MODE @@ -937,6 +951,7 @@ static struct /* level directory info */ { TYPE_STRING, &ldi.name, "name" }, { TYPE_INTEGER, &ldi.levels, "levels" }, + { TYPE_INTEGER, &ldi.first_level, "first_level" }, { TYPE_INTEGER, &ldi.sort_priority, "sort_priority" }, { TYPE_BOOLEAN, &ldi.readonly, "readonly" } }; @@ -1200,7 +1215,8 @@ static void setLevelDirInfoToDefaults(struct LevelDirInfo *ldi) { ldi->name = getStringCopy("non-existing"); ldi->levels = 0; - ldi->sort_priority = 999; /* default: least priority */ + ldi->first_level = 0; + ldi->sort_priority = LEVELCLASS_UNDEFINED; /* default: least priority */ ldi->readonly = TRUE; } @@ -1338,14 +1354,12 @@ int getLastPlayedLevelOfLevelSeries(char *level_series_name) if (token_value) { - int highest_level_nr = leveldir[level_series_nr].levels - 1; - last_level_nr = atoi(token_value); - if (last_level_nr < 0) - last_level_nr = 0; - if (last_level_nr > highest_level_nr) - last_level_nr = highest_level_nr; + if (last_level_nr < leveldir[level_series_nr].first_level) + last_level_nr = leveldir[level_series_nr].first_level; + if (last_level_nr > leveldir[level_series_nr].last_level) + last_level_nr = leveldir[level_series_nr].last_level; } return last_level_nr; @@ -1422,6 +1436,9 @@ static int LoadLevelInfoFromLevelDir(char *level_directory, int start_entry) leveldir[current_entry] = ldi; leveldir[current_entry].filename = getStringCopy(dir_entry->d_name); + leveldir[current_entry].last_level = + leveldir[current_entry].first_level + + leveldir[current_entry].levels - 1; leveldir[current_entry].user_defined = (level_directory == options.level_directory ? FALSE : TRUE); @@ -1485,7 +1502,8 @@ static void SaveUserLevelInfo() ldi.name = getLoginName(); ldi.levels = 100; - ldi.sort_priority = 300; + ldi.first_level = 0; + ldi.sort_priority = LEVELCLASS_USER_START; ldi.readonly = FALSE; fprintf(file, "%s\n\n", diff --git a/src/game.c b/src/game.c index dc992f25..3471f671 100644 --- a/src/game.c +++ b/src/game.c @@ -3496,9 +3496,9 @@ void GameActions() else if (element == EL_BURNING) CheckForDragon(x, y); else if (element == EL_SP_TERMINAL) - DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL, 7, 10, ANIM_NORMAL); + DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL, 7, 12, ANIM_NORMAL); else if (element == EL_SP_TERMINAL_ACTIVE) - DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL_ACTIVE, 7, 2, ANIM_NORMAL); + DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL_ACTIVE, 7, 4, ANIM_NORMAL); if (SiebAktiv) { diff --git a/src/main.h b/src/main.h index b5b01634..26251e84 100644 --- a/src/main.h +++ b/src/main.h @@ -349,6 +349,8 @@ struct LevelDirInfo char *filename; char *name; int levels; + int first_level; + int last_level; int sort_priority; boolean user_defined; boolean readonly; @@ -787,17 +789,17 @@ extern int num_bg_loops; /* game graphics: ** 0 - 255: graphics from "RocksScreen" -** 256 - 511: graphics from "RocksMore" -** 512 - 767: graphics from "RocksFont" +** 256 - 511: graphics from "RocksFont" +** 512 - 767: graphics from "RocksMore" ** 768 - 1023: graphics from "RocksHeroes" */ #define GFX_START_ROCKSSCREEN 0 #define GFX_END_ROCKSSCREEN 255 -#define GFX_START_ROCKSMORE 256 -#define GFX_END_ROCKSMORE 511 -#define GFX_START_ROCKSFONT 512 -#define GFX_END_ROCKSFONT 767 +#define GFX_START_ROCKSFONT 256 +#define GFX_END_ROCKSFONT 511 +#define GFX_START_ROCKSMORE 512 +#define GFX_END_ROCKSMORE 767 #define GFX_START_ROCKSHEROES 768 #define GFX_END_ROCKSHEROES 1023 @@ -1211,10 +1213,10 @@ extern int num_bg_loops; #define TAPES_DIRECTORY "tapes" #define SCORES_DIRECTORY "scores" -#define VERSION_STRING "1.2.0" +#define VERSION_STRING "1.2.1" #define GAMETITLE_STRING "Rocks'n'Diamonds" #define WINDOWTITLE_STRING GAMETITLE_STRING " " VERSION_STRING -#define COPYRIGHT_STRING "Copyright ^1995-98 by Holger Schemel" +#define COPYRIGHT_STRING "Copyright ^1995-99 by Holger Schemel" /* default name for empty highscore entry */ #define EMPTY_PLAYER_NAME "no name" diff --git a/src/screens.c b/src/screens.c index 11c62850..16f08ca7 100644 --- a/src/screens.c +++ b/src/screens.c @@ -89,13 +89,21 @@ void DrawMainMenu() DrawMicroLevel(MICROLEV_XPOS,MICROLEV_YPOS); + DrawTextF(7*32 + 6, 3*32 + 9, FC_RED, "%d-%d", + leveldir[leveldir_nr].first_level, + leveldir[leveldir_nr].last_level); + + if (leveldir[leveldir_nr].readonly) + { + DrawTextF(15*32 + 6, 3*32 + 9 - 7, FC_RED, "READ"); + DrawTextF(15*32 + 6, 3*32 + 9 + 7, FC_RED, "ONLY"); + } + for(i=2; i<10; i++) DrawGraphic(0, i, GFX_KUGEL_BLAU); DrawGraphic(10, 3, GFX_PFEIL_L); DrawGraphic(14, 3, GFX_PFEIL_R); - DrawTextF(15*32 + 6, 3*32 + 9, FC_RED, "%d", leveldir[leveldir_nr].levels); - DrawText(SX + 56, SY + 326, "A Game by Artsoft Entertainment", FS_SMALL, FC_RED); @@ -165,8 +173,8 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) y = choice; } - if (y == 4 && ((x == 11 && level_nr > 0) || - (x == 15 && level_nr < leveldir[leveldir_nr].levels - 1)) && + if (y == 4 && ((x == 11 && level_nr > leveldir[leveldir_nr].first_level) || + (x == 15 && level_nr < leveldir[leveldir_nr].last_level)) && button) { static unsigned long level_delay = 0; @@ -175,10 +183,10 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) int font_color = (leveldir[leveldir_nr].readonly ? FC_RED : FC_YELLOW); new_level_nr = level_nr + (x == 11 ? -step : +step); - if (new_level_nr < 0) - new_level_nr = 0; - if (new_level_nr > leveldir[leveldir_nr].levels - 1) - new_level_nr = leveldir[leveldir_nr].levels - 1; + if (new_level_nr < leveldir[leveldir_nr].first_level) + new_level_nr = leveldir[leveldir_nr].first_level; + if (new_level_nr > leveldir[leveldir_nr].last_level) + new_level_nr = leveldir[leveldir_nr].last_level; if (old_level_nr == new_level_nr || !DelayReached(&level_delay, GADGET_FRAME_DELAY))