From bf8ca30e88c11cc5d4b849bee601df1794bfd1cf Mon Sep 17 00:00:00 2001 From: mothbeanie Date: Thu, 24 Aug 2023 13:23:39 -0700 Subject: [PATCH] Add region system three new commands: setregion(id,x,y,x2,y2), changeregion(id), removeregion(id) --- desktop_version/src/CustomLevels.cpp | 42 ++----- desktop_version/src/FileSystemUtils.cpp | 4 +- desktop_version/src/Game.cpp | 92 +++++++++++++++- desktop_version/src/Graphics.cpp | 9 ++ desktop_version/src/Graphics.h | 4 + desktop_version/src/GraphicsResources.cpp | 36 +++++- desktop_version/src/Map.cpp | 116 +++++++++++++++++++- desktop_version/src/Map.h | 36 +++++- desktop_version/src/Render.cpp | 127 ++++++++++------------ desktop_version/src/Script.cpp | 17 +++ 10 files changed, 371 insertions(+), 112 deletions(-) diff --git a/desktop_version/src/CustomLevels.cpp b/desktop_version/src/CustomLevels.cpp index 29cd286f9e..222048ce71 100644 --- a/desktop_version/src/CustomLevels.cpp +++ b/desktop_version/src/CustomLevels.cpp @@ -1656,35 +1656,7 @@ bool customlevelclass::save(const std::string& _path) void customlevelclass::generatecustomminimap(void) { - map.customzoom = 1; - if (mapwidth <= 10 && mapheight <= 10) - { - map.customzoom = 2; - } - if (mapwidth <= 5 && mapheight <= 5) - { - map.customzoom = 4; - } - - // Set minimap offsets - switch (map.customzoom) - { - case 4: - map.custommmxoff = 24 * (5 - mapwidth); - map.custommmyoff = 18 * (5 - mapheight); - break; - case 2: - map.custommmxoff = 12 * (10 - mapwidth); - map.custommmyoff = 9 * (10 - mapheight); - break; - default: - map.custommmxoff = 6 * (20 - mapwidth); - map.custommmyoff = int(4.5 * (20 - mapheight)); - break; - } - - map.custommmxsize = 240 - (map.custommmxoff * 2); - map.custommmysize = 180 - (map.custommmyoff * 2); + const MapRenderData data = map.get_render_data(); // Start drawing the minimap @@ -1693,9 +1665,9 @@ void customlevelclass::generatecustomminimap(void) graphics.clear(); // Scan over the map size - for (int j2 = 0; j2 < mapheight; j2++) + for (int j2 = data.starty; j2 < data.starty + data.height; j2++) { - for (int i2 = 0; i2 < mapwidth; i2++) + for (int i2 = data.startx; i2 < data.startx + data.width; i2++) { std::vector dark_points; std::vector light_points; @@ -1703,12 +1675,12 @@ void customlevelclass::generatecustomminimap(void) bool dark = getroomprop(i2, j2)->tileset == 1; // Ok, now scan over each square - for (int j = 0; j < 9 * map.customzoom; j++) + for (int j = 0; j < 9 * data.zoom; j++) { - for (int i = 0; i < 12 * map.customzoom; i++) + for (int i = 0; i < 12 * data.zoom; i++) { int tile; - switch (map.customzoom) + switch (data.zoom) { case 4: tile = absfree( @@ -1733,7 +1705,7 @@ void customlevelclass::generatecustomminimap(void) if (tile >= 1) { // Add this pixel - SDL_Point point = { (i2 * 12 * map.customzoom) + i, (j2 * 9 * map.customzoom) + j }; + SDL_Point point = { ((i2 - data.startx) * 12 * data.zoom) + i, ((j2 - data.starty) * 9 * data.zoom) + j }; if (dark) { dark_points.push_back(point); diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index 54e0bb4a95..871c1d9950 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -399,9 +399,9 @@ bool FILESYSTEM_isMounted(const char* filename) return PHYSFS_getMountPoint(filename) != NULL; } -static bool FILESYSTEM_exists(const char *fname) +static bool FILESYSTEM_exists(const char* filename) { - return PHYSFS_exists(fname); + return PHYSFS_exists(filename); } static void generateBase36(char* string, const size_t string_size) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index aba868c958..b3281570d9 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -243,7 +243,17 @@ void Game::init(void) ndmresultcrewrescued = 0; ndmresulttrinkets = 0; - customcol=0; + customcol = 0; + + map.currentregion = 0; + for (size_t i = 0; i < SDL_arraysize(map.region); i++) + { + map.region[i].isvalid = false; + map.region[i].rx = 0; + map.region[i].ry = 0; + map.region[i].rx2 = 0; + map.region[i].ry2 = 0; + } SDL_memset(crewstats, false, sizeof(crewstats)); SDL_memset(ndmresultcrewstats, false, sizeof(ndmresultcrewstats)); @@ -5580,6 +5590,50 @@ void Game::customloadquick(const std::string& savfile) map.roomnameset = true; map.roomname_special = true; } + else if (SDL_strcmp(pKey, "currentregion") == 0) + { + map.currentregion = help.Int(pText); + } +#if !defined(NO_CUSTOM_LEVELS) + else if (SDL_strcmp(pKey, "regions") == 0) + { + tinyxml2::XMLElement* pElem2; + for (pElem2 = pElem->FirstChildElement(); pElem2 != NULL; pElem2 = pElem2->NextSiblingElement()) + { + int thisid = 0; + int thisrx = 0; + int thisry = 0; + int thisrx2 = (cl.mapwidth - 1); + int thisry2 = (cl.mapheight - 1); + if (pElem2->Attribute("id")) + { + thisid = help.Int(pElem2->Attribute("id")); + } + + for (tinyxml2::XMLElement* pElem3 = pElem2->FirstChildElement(); pElem3 != NULL; pElem3 = pElem3->NextSiblingElement()) + { + if (SDL_strcmp(pElem3->Value(), "rx") == 0 && pElem3->GetText() != NULL) + { + thisrx = help.Int(pElem3->GetText()); + } + if (SDL_strcmp(pElem3->Value(), "ry") == 0 && pElem3->GetText() != NULL) + { + thisry = help.Int(pElem3->GetText()); + } + if (SDL_strcmp(pElem3->Value(), "rx2") == 0 && pElem3->GetText() != NULL) + { + thisrx2 = help.Int(pElem3->GetText()); + } + if (SDL_strcmp(pElem3->Value(), "ry2") == 0 && pElem3->GetText() != NULL) + { + thisry2 = help.Int(pElem3->GetText()); + } + } + + map.setregion(thisid, thisrx, thisry, thisrx2, thisry2); + } + } +#endif } } @@ -5871,6 +5925,42 @@ std::string Game::writemaingamesave(tinyxml2::XMLDocument& doc) xml::update_tag(msgs, "trinkets", trinkets()); + xml::update_tag(msgs, "currentregion", map.currentregion); + + tinyxml2::XMLElement* msg = xml::update_element_delete_contents(msgs, "regions"); + for (size_t i = 0; i < SDL_arraysize(map.region); i++) + { + if (map.region[i].isvalid) + { + tinyxml2::XMLElement* region_el; + region_el = doc.NewElement("region"); + + region_el->SetAttribute("id", (help.String(i).c_str())); + + tinyxml2::XMLElement* rx_el; + rx_el = doc.NewElement("rx"); + rx_el->LinkEndChild(doc.NewText(help.String(map.region[i].rx).c_str())); + region_el->LinkEndChild(rx_el); + + tinyxml2::XMLElement* ry_el; + ry_el = doc.NewElement("ry"); + ry_el->LinkEndChild(doc.NewText(help.String(map.region[i].ry).c_str())); + region_el->LinkEndChild(ry_el); + + tinyxml2::XMLElement* rx2_el; + rx2_el = doc.NewElement("rx2"); + rx2_el->LinkEndChild(doc.NewText(help.String(map.region[i].rx2).c_str())); + region_el->LinkEndChild(rx2_el); + + tinyxml2::XMLElement* ry2_el; + ry2_el = doc.NewElement("ry2"); + ry2_el->LinkEndChild(doc.NewText(help.String(map.region[i].ry2).c_str())); + region_el->LinkEndChild(ry2_el); + + msg->LinkEndChild(region_el); + } + } + //Special stats diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 6501171f9c..1dd122d367 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -1076,6 +1076,15 @@ void Graphics::drawpartimage(const int t, const int xp, const int yp, const int draw_texture_part(images[t], xp, yp, 0, 0, wp, hp, 1, 1); } +void Graphics::draw_region_image(int t, int xp, int yp, int wp, int hp) +{ + if (!INBOUNDS_ARR(t, customminimaps) || customminimaps[t] == NULL) + { + return; + } + draw_texture_part(customminimaps[t], xp, yp, 0, 0, wp, hp, 1, 1); +} + void Graphics::draw_texture(SDL_Texture* image, const int x, const int y) { int w, h; diff --git a/desktop_version/src/Graphics.h b/desktop_version/src/Graphics.h index be5fd8349f..a9ee76b693 100644 --- a/desktop_version/src/Graphics.h +++ b/desktop_version/src/Graphics.h @@ -140,6 +140,8 @@ class Graphics void drawpartimage(int t, int xp, int yp, int wp, int hp); + void draw_region_image(int t, int xp, int yp, int wp, int hp); + void drawimage(int t, int xp, int yp, bool cent=false); void drawimagecol(int t, int xp, int yp, SDL_Color ct, bool cent= false); @@ -314,6 +316,8 @@ class Graphics SDL_Texture* images[NUM_IMAGES]; + SDL_Texture* customminimaps[401]; + bool flipmode; bool setflipmode; bool notextoutline; diff --git a/desktop_version/src/GraphicsResources.cpp b/desktop_version/src/GraphicsResources.cpp index 2fb1be0a91..a2627ef99f 100644 --- a/desktop_version/src/GraphicsResources.cpp +++ b/desktop_version/src/GraphicsResources.cpp @@ -2,6 +2,7 @@ #include "Alloc.h" #include "FileSystemUtils.h" +#include "Graphics.h" #include "GraphicsUtil.h" #include "Vlogging.h" #include "Screen.h" @@ -21,7 +22,9 @@ extern "C" static SDL_Surface* LoadImageRaw(const char* filename, unsigned char** data) { - //Temporary storage for the image that's loaded + *data = NULL; + + // Temporary storage for the image that's loaded SDL_Surface* loadedImage = NULL; unsigned int width, height; @@ -84,7 +87,6 @@ SDL_Surface* LoadImageSurface(const char* filename) if (optimizedImage == NULL) { - VVV_free(data); vlog_error("Image not found: %s", filename); SDL_assert(0 && "Image not found! See stderr."); } @@ -292,6 +294,28 @@ void GraphicsResources::init(void) SDL_assert(0 && "Failed to create minimap texture! See stderr."); return; } + + SDL_zeroa(graphics.customminimaps); + + EnumHandle handle = {}; + const char* item; + char full_item[73]; + while ((item = FILESYSTEM_enumerateAssets("graphics", &handle)) != NULL) + { + if (SDL_strncmp(item, "region", 6) != 0) + { + continue; + } + char* end; + int i = SDL_strtol(&item[6], &end, 10); + if (item == end || SDL_strcmp(end, ".png") != 0) + { + continue; + } + SDL_snprintf(full_item, sizeof(full_item), "graphics/%s", item); + graphics.customminimaps[i] = LoadImage(full_item); + } + FILESYSTEM_freeEnumerate(&handle); } @@ -323,6 +347,14 @@ void GraphicsResources::destroy(void) CLEAR(im_image10); CLEAR(im_image11); CLEAR(im_image12); + + for (size_t i = 0; i < SDL_arraysize(graphics.customminimaps); i++) + { + if (graphics.customminimaps[i] != NULL) + { + CLEAR(graphics.customminimaps[i]); + } + } #undef CLEAR VVV_freefunc(SDL_FreeSurface, im_sprites_surf); diff --git a/desktop_version/src/Map.cpp b/desktop_version/src/Map.cpp index 8d5881d493..895120829b 100644 --- a/desktop_version/src/Map.cpp +++ b/desktop_version/src/Map.cpp @@ -52,8 +52,6 @@ mapclass::mapclass(void) custommode=false; custommodeforreal=false; - custommmxoff=0; custommmyoff=0; custommmxsize=0; custommmysize=0; - customzoom=0; customshowmm=true; rcol = 0; @@ -2208,3 +2206,117 @@ void mapclass::twoframedelayfix(void) game.setstatedelay(0); script.load(game.newscript); } + +MapRenderData mapclass::get_render_data(void) +{ + MapRenderData data; + data.width = getwidth(); + data.height = getheight(); + + data.startx = 0; + data.starty = 0; + + // Region handling + if (region[currentregion].isvalid) + { + data.startx = region[currentregion].rx; + data.starty = region[currentregion].ry; + data.width = ((region[currentregion].rx2 - data.startx) + 1); + data.height = ((region[currentregion].ry2 - data.starty) + 1); + } + + data.zoom = 1; + + if (data.width <= 10 && data.height <= 10) + { + data.zoom = 2; + } + if (data.width <= 5 && data.height <= 5) + { + data.zoom = 4; + } + + data.xoff = 0; + data.yoff = 0; + + // Set minimap offsets + switch (data.zoom) + { + case 4: + data.xoff = 24 * (5 - data.width); + data.yoff = 18 * (5 - data.height); + break; + case 2: + data.xoff = 12 * (10 - data.width); + data.yoff = 9 * (10 - data.height); + break; + default: + data.xoff = 6 * (20 - data.width); + data.yoff = (int) (4.5 * (20 - data.height)); + break; + } + + data.pixelsx = 240 - (data.xoff * 2); + data.pixelsy = 180 - (data.yoff * 2); + + data.legendxoff = 40 + data.xoff; + data.legendyoff = 21 + data.yoff; + + // Magic numbers for centering legend tiles. + switch (data.zoom) + { + case 4: + data.legendxoff += 21; + data.legendyoff += 16; + break; + case 2: + data.legendxoff += 9; + data.legendyoff += 5; + break; + default: + data.legendxoff += 3; + data.legendyoff += 1; + break; + } + + return data; +} + +void mapclass::setregion(int id, int rx, int ry, int rx2, int ry2) +{ +#if !defined(NO_CUSTOM_LEVELS) + if (INBOUNDS_ARR(id, region)) + { + region[id].isvalid = true; + region[id].rx = SDL_clamp(rx, 0, cl.mapwidth - 1); + region[id].ry = SDL_clamp(ry, 0, cl.mapheight - 1); + region[id].rx2 = SDL_clamp(rx2, 0, cl.mapwidth - 1); + region[id].ry2 = SDL_clamp(ry2, 0, cl.mapheight - 1); + } +#endif +} + +void mapclass::removeregion(int id) +{ +#if !defined(NO_CUSTOM_LEVELS) + if (INBOUNDS_ARR(id, region)) + { + region[id].isvalid = false; + region[id].rx = 0; + region[id].ry = 0; + region[id].rx2 = 0; + region[id].ry2 = 0; + } +#endif +} + +void mapclass::changeregion(int id) +{ +#if !defined(NO_CUSTOM_LEVELS) + if (INBOUNDS_ARR(id, region)) + { + currentregion = id; + cl.generatecustomminimap(); + } +#endif +} \ No newline at end of file diff --git a/desktop_version/src/Map.h b/desktop_version/src/Map.h index a9248fe123..b3ae85f2a4 100644 --- a/desktop_version/src/Map.h +++ b/desktop_version/src/Map.h @@ -12,6 +12,21 @@ #include "TowerBG.h" #include "WarpClass.h" +struct MapRenderData +{ + int zoom; + int xoff; + int yoff; + int legendxoff; + int legendyoff; + int startx; + int starty; + int width; + int height; + int pixelsx; + int pixelsy; +}; + struct Roomtext { int x, y; @@ -158,8 +173,6 @@ class mapclass //Variables for playing custom levels bool custommode; bool custommodeforreal; - int custommmxoff, custommmyoff, custommmxsize, custommmysize; - int customzoom; bool customshowmm; //final level colour cycling stuff @@ -193,6 +206,25 @@ class mapclass //Map cursor int cursorstate, cursordelay; + + //Region system + struct regionstruct + { + bool isvalid; + int rx; + int ry; + int rx2; + int ry2; + }; + struct regionstruct region[401]; + void setregion(int id, int rx, int ry, int rx2, int ry2); + void removeregion(int id); + void changeregion(int id); + int currentregion; + int regionx, regiony; + int regionwidth, regionheight; + + MapRenderData get_render_data(void); }; #ifndef MAP_DEFINITION diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index dab519e1a7..9833bf2ffc 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -31,15 +31,6 @@ static int tr; static int tg; static int tb; -struct MapRenderData -{ - int zoom; - int xoff; - int yoff; - int legendxoff; - int legendyoff; -}; - static inline void drawslowdowntext(const int y) { switch (game.slowdown) @@ -2433,45 +2424,29 @@ static void draw_roomname_menu(void) #define FLIP_PR_CJK_LOW (graphics.flipmode ? PR_CJK_HIGH : PR_CJK_LOW) #define FLIP_PR_CJK_HIGH (graphics.flipmode ? PR_CJK_LOW : PR_CJK_HIGH) -static MapRenderData getmaprenderdata(void) -{ - MapRenderData data; - - data.zoom = map.custommode ? map.customzoom : 1; - data.xoff = map.custommode ? map.custommmxoff : 0; - data.yoff = map.custommode ? map.custommmyoff : 0; - data.legendxoff = 40 + data.xoff; - data.legendyoff = 21 + data.yoff; - - // Magic numbers for centering legend tiles. - switch (data.zoom) - { - case 4: - data.legendxoff += 21; - data.legendyoff += 16; - break; - case 2: - data.legendxoff += 9; - data.legendyoff += 5; - break; - default: - data.legendxoff += 3; - data.legendyoff += 1; - break; - } - - return data; -} - static void rendermap(void) { #ifndef NO_CUSTOM_LEVELS if (map.custommode && map.customshowmm) { - graphics.drawpixeltextbox(35 + map.custommmxoff, 16 + map.custommmyoff, map.custommmxsize + 10, map.custommmysize + 10, 65, 185, 207); - graphics.drawpartimage(graphics.minimap_mounted ? IMAGE_MINIMAP : IMAGE_CUSTOMMINIMAP, 40 + map.custommmxoff, 21 + map.custommmyoff, map.custommmxsize, map.custommmysize); + const MapRenderData data = map.get_render_data(); + + graphics.drawpixeltextbox(35 + data.xoff, 16 + data.yoff, data.pixelsx + 10, data.pixelsy + 10, 65, 185, 207); + + if (graphics.customminimaps[map.currentregion] != NULL) + { + graphics.draw_region_image(map.currentregion, 40 + data.xoff, 21 + data.yoff, data.pixelsx, data.pixelsy); + } + else if (map.currentregion == 0 && graphics.minimap_mounted) + { + graphics.drawpartimage(IMAGE_MINIMAP, 40 + data.xoff, 21 + data.yoff, data.pixelsx, data.pixelsy); + } + else + { + graphics.drawpartimage(IMAGE_CUSTOMMINIMAP, 40 + data.xoff, 21 + data.yoff, data.pixelsx, data.pixelsy); + } return; - } + } #endif /* NO_CUSTOM_LEVELS */ graphics.drawpixeltextbox(35, 16, 250, 190, 65, 185, 207); @@ -2480,11 +2455,11 @@ static void rendermap(void) static void rendermapfog(void) { - const MapRenderData data = getmaprenderdata(); + const MapRenderData data = map.get_render_data(); - for (int j = 0; j < map.getheight(); j++) + for (int j = data.starty; j < data.starty + data.height; j++) { - for (int i = 0; i < map.getwidth(); i++) + for (int i = data.startx; i < data.startx + data.width; i++) { if (!map.isexplored(i, j)) { @@ -2493,7 +2468,7 @@ static void rendermapfog(void) { for (int y = 0; y < data.zoom; y++) { - graphics.drawimage(IMAGE_COVERED, data.xoff + 40 + (x * 12) + (i * (12 * data.zoom)), data.yoff + 21 + (y * 9) + (j * (9 * data.zoom)), false); + graphics.drawimage(IMAGE_COVERED, data.xoff + 40 + (x * 12) + ((i - data.startx) * (12 * data.zoom)), data.yoff + 21 + (y * 9) + ((j - data.starty) * (9 * data.zoom)), false); } } } @@ -2505,19 +2480,24 @@ static void rendermaplegend(void) { // Draw the map legend, aka teleports/targets/trinkets - const MapRenderData data = getmaprenderdata(); + const MapRenderData data = map.get_render_data(); const int tile_offset = graphics.flipmode ? 3 : 0; for (size_t i = 0; i < map.teleporters.size(); i++) { - if (map.showteleporters && map.isexplored(map.teleporters[i].x, map.teleporters[i].y)) + int x = map.teleporters[i].x - data.startx; + int y = map.teleporters[i].y - data.starty; + if (x >= 0 && y >= 0 && x < data.width && y < data.height) { - graphics.drawtile(data.legendxoff + (map.teleporters[i].x * 12 * data.zoom), data.legendyoff + (map.teleporters[i].y * 9 * data.zoom), 1127 + tile_offset); - } - else if (map.showtargets && !map.isexplored(map.teleporters[i].x, map.teleporters[i].y)) - { - graphics.drawtile(data.legendxoff + (map.teleporters[i].x * 12 * data.zoom), data.legendyoff + (map.teleporters[i].y * 9 * data.zoom), 1126 + tile_offset); + if (map.showteleporters && map.isexplored(x + data.startx, y + data.starty)) + { + graphics.drawtile(data.legendxoff + (x * 12 * data.zoom), data.legendyoff + (y * 9 * data.zoom), 1127 + tile_offset); + } + else if (map.showtargets && !map.isexplored(x + data.startx, y + data.starty)) + { + graphics.drawtile(data.legendxoff + (x * 12 * data.zoom), data.legendyoff + (y * 9 * data.zoom), 1126 + tile_offset); + } } } @@ -2527,7 +2507,12 @@ static void rendermaplegend(void) { if (!obj.collect[i]) { - graphics.drawtile(data.legendxoff + (map.shinytrinkets[i].x * 12 * data.zoom), data.legendyoff + (map.shinytrinkets[i].y * 9 * data.zoom), 1086 + tile_offset); + int x = map.shinytrinkets[i].x - data.startx; + int y = map.shinytrinkets[i].y - data.starty; + if (x >= 0 && y >= 0 && x < data.width && y < data.height) + { + graphics.drawtile(data.legendxoff + (x * 12 * data.zoom), data.legendyoff + (y * 9 * data.zoom), 1086 + tile_offset); + } } } } @@ -2535,38 +2520,44 @@ static void rendermaplegend(void) static void rendermapcursor(const bool flashing) { - const MapRenderData data = getmaprenderdata(); + const MapRenderData data = map.get_render_data(); + int room_x = game.roomx - data.startx - 100; + int room_y = game.roomy - data.starty - 100; + int pixels_x = room_x * 12; + int pixels_y = room_y * 9; if (!map.custommode && game.roomx == 109) { // Draw the tower specially if (!flashing || game.noflashingmode) { - graphics.draw_rect(40 + ((game.roomx - 100) * 12) + 2, 21 + 2, 12 - 4, 180 - 4, 16, 245 - (help.glow * 2), 245 - (help.glow * 2)); + graphics.draw_rect(40 + pixels_x + 2, 21 + 2, 12 - 4, 180 - 4, 16, 245 - (help.glow * 2), 245 - (help.glow * 2)); } else if (map.cursorstate == 1) { if (int(map.cursordelay / 4) % 2 == 0) { - graphics.draw_rect(40 + ((game.roomx - 100) * 12), 21, 12, 180, 255, 255, 255); - graphics.draw_rect(40 + ((game.roomx - 100) * 12) + 2, 21 + 2, 12 - 4, 180 - 4, 255, 255, 255); + graphics.draw_rect(40 + pixels_x, 21, 12, 180, 255, 255, 255); + graphics.draw_rect(40 + pixels_x + 2, 21 + 2, 12 - 4, 180 - 4, 255, 255, 255); } } else if (map.cursorstate == 2 && (int(map.cursordelay / 15) % 2 == 0)) { - graphics.draw_rect(40 + ((game.roomx - 100) * 12) + 2, 21 + 2, 12 - 4, 180 - 4, 16, 245 - (help.glow), 245 - (help.glow)); + graphics.draw_rect(40 + pixels_x + 2, 21 + 2, 12 - 4, 180 - 4, 16, 245 - (help.glow), 245 - (help.glow)); } return; } - - if (!flashing || ((map.cursorstate == 2 && int(map.cursordelay / 15) % 2 == 0) || game.noflashingmode)) - { - graphics.draw_rect(40 + ((game.roomx - 100) * 12 * data.zoom) + 2 + data.xoff, 21 + ((game.roomy - 100) * 9 * data.zoom) + 2 + data.yoff, (12 * data.zoom) - 4, (9 * data.zoom) - 4, 16, 245 - (help.glow), 245 - (help.glow)); - } - else if (map.cursorstate == 1 && int(map.cursordelay / 4) % 2 == 0) + if (room_x >= 0 && room_y >= 0 && room_x < data.width && room_y < data.height) { - graphics.draw_rect(40 + ((game.roomx - 100) * 12 * data.zoom) + data.xoff, 21 + ((game.roomy - 100) * 9 * data.zoom) + data.yoff, 12 * data.zoom, 9 * data.zoom, 255, 255, 255); - graphics.draw_rect(40 + ((game.roomx - 100) * 12 * data.zoom) + 2 + data.xoff, 21 + ((game.roomy - 100) * 9 * data.zoom) + 2 + data.yoff, (12 * data.zoom) - 4, (9 * data.zoom) - 4, 255, 255, 255); + if (!flashing || ((map.cursorstate == 2 && int(map.cursordelay / 15) % 2 == 0) || game.noflashingmode)) + { + graphics.draw_rect(40 + (pixels_x * data.zoom) + 2 + data.xoff, 21 + (pixels_y * data.zoom) + 2 + data.yoff, (12 * data.zoom) - 4, (9 * data.zoom) - 4, 16, 245 - (help.glow), 245 - (help.glow)); + } + else if (map.cursorstate == 1 && int(map.cursordelay / 4) % 2 == 0) + { + graphics.draw_rect(40 + (pixels_x * data.zoom) + data.xoff, 21 + (pixels_y * data.zoom) + data.yoff, 12 * data.zoom, 9 * data.zoom, 255, 255, 255); + graphics.draw_rect(40 + (pixels_x * data.zoom) + 2 + data.xoff, 21 + (pixels_y * data.zoom) + 2 + data.yoff, (12 * data.zoom) - 4, (9 * data.zoom) - 4, 255, 255, 255); + } } } @@ -3123,7 +3114,7 @@ void teleporterrender(void) // Draw a box around the currently selected teleporter - const MapRenderData data = getmaprenderdata(); + const MapRenderData data = map.get_render_data(); if (game.useteleporter) { diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index 7bacf68e24..108beb960d 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -326,6 +326,23 @@ void scriptclass::run(void) map.customshowmm=false; } } + else if (words[0] == "setregion") + { + map.setregion( + ss_toi(words[1]), + ss_toi(words[2]), + ss_toi(words[3]), + ss_toi(words[4]), + ss_toi(words[5])); + } + else if (words[0] == "removeregion") + { + map.removeregion(ss_toi(words[1])); + } + else if (words[0] == "changeregion") + { + map.changeregion(ss_toi(words[1])); + } if (words[0] == "delay") { //USAGE: delay(frames)