From dedf941b253992acb543e30f08dc9a31a0153526 Mon Sep 17 00:00:00 2001 From: mothbeanie Date: Fri, 5 Jul 2024 14:59:15 -0700 Subject: [PATCH] Update region system to current codebase due to PR rot --- desktop_version/src/CustomLevels.cpp | 42 ++----- desktop_version/src/Game.cpp | 89 +++++++++++++++ desktop_version/src/Graphics.cpp | 9 ++ desktop_version/src/Graphics.h | 4 + desktop_version/src/GraphicsResources.cpp | 30 +++++ desktop_version/src/Map.cpp | 124 ++++++++++++++++++++- desktop_version/src/Map.h | 36 +++++- desktop_version/src/Render.cpp | 130 ++++++++++------------ desktop_version/src/Script.cpp | 17 +++ 9 files changed, 366 insertions(+), 115 deletions(-) diff --git a/desktop_version/src/CustomLevels.cpp b/desktop_version/src/CustomLevels.cpp index 347bff9a..bd8ac2aa 100644 --- a/desktop_version/src/CustomLevels.cpp +++ b/desktop_version/src/CustomLevels.cpp @@ -1682,35 +1682,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 @@ -1719,9 +1691,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; @@ -1729,12 +1701,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( @@ -1759,7 +1731,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/Game.cpp b/desktop_version/src/Game.cpp index 86805c2a..3f0d3ad0 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -229,6 +229,16 @@ void Game::init(void) 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)); SDL_memset(besttimes, -1, sizeof(besttimes)); @@ -5948,6 +5958,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 } } @@ -6332,6 +6386,41 @@ bool Game::customsavequick(const std::string& savfile) xml::update_tag(msgs, "crewmates", crewmates()); + 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 0c2dba35..e38ed3ac 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -1271,6 +1271,15 @@ void Graphics::draw_grid_tile( draw_grid_tile(texture, t, x, y, width, height, color, 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::cutscenebars(void) { const int usethispos = lerp(oldcutscenebarspos, cutscenebarspos); diff --git a/desktop_version/src/Graphics.h b/desktop_version/src/Graphics.h index c37622a2..bc1dba69 100644 --- a/desktop_version/src/Graphics.h +++ b/desktop_version/src/Graphics.h @@ -172,6 +172,8 @@ public: void draw_grid_tile(SDL_Texture* texture, int t, int x, int y, int width, int height, SDL_Color color, int scalex, int scaley); void draw_grid_tile(SDL_Texture* texture, int t, int x, int y, int width, int height, SDL_Color color); + void draw_region_image(int t, int xp, int yp, int wp, int hp); + void updatetextboxes(void); const char* textbox_line(char* buffer, size_t buffer_len, size_t textbox_i, size_t line_i); void drawgui(void); @@ -337,6 +339,8 @@ public: 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 571a1f00..7e25545f 100644 --- a/desktop_version/src/GraphicsResources.cpp +++ b/desktop_version/src/GraphicsResources.cpp @@ -442,6 +442,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); } @@ -476,6 +498,14 @@ void GraphicsResources::destroy(void) CLEAR(im_sprites_translated); CLEAR(im_flipsprites_translated); + + 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 2b822c11..ac5a19e7 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; revealmap = true; @@ -2205,16 +2203,16 @@ void mapclass::twoframedelayfix(void) // A bit kludge-y, but it's the least we can do without changing the frame ordering. if (GlitchrunnerMode_less_than_or_equal(Glitchrunner2_2) - || !custommode - || game.deathseq != -1) + || !custommode + || game.deathseq != -1) return; int block_idx = -1; // obj.checktrigger() sets block_idx int activetrigger = obj.checktrigger(&block_idx); if (activetrigger <= -1 - || !INBOUNDS_VEC(block_idx, obj.blocks) - || activetrigger < 300) + || !INBOUNDS_VEC(block_idx, obj.blocks) + || activetrigger < 300) { return; } @@ -2225,3 +2223,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 243938c6..fa2f3533 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; @@ -163,8 +178,6 @@ public: //Variables for playing custom levels bool custommode; bool custommodeforreal; - int custommmxoff, custommmyoff, custommmxsize, custommmysize; - int customzoom; bool customshowmm; //final level colour cycling stuff @@ -198,6 +211,25 @@ public: //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 252dc53d..495cd9d5 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -32,15 +32,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) @@ -2789,42 +2780,26 @@ 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 += 20; - data.legendyoff += 14; - break; - case 2: - data.legendxoff += 8; - data.legendyoff += 5; - break; - default: - data.legendxoff += 2; - data.legendyoff += 1; - break; - } - - return data; -} - static void rendermap(void) { 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; } @@ -2834,11 +2809,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)) { @@ -2847,7 +2822,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); } } } @@ -2859,17 +2834,22 @@ static void rendermaplegend(void) { // Draw the map legend, aka teleports/targets/trinkets - const MapRenderData data = getmaprenderdata(); + const MapRenderData data = map.get_render_data(); 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) { - font::print(PR_FONT_8X8 | PR_FULLBOR, data.legendxoff + (map.teleporters[i].x * 12 * data.zoom), data.legendyoff + (map.teleporters[i].y * 9 * data.zoom), "💿", 171, 255, 252); - } - else if (map.showtargets && !map.isexplored(map.teleporters[i].x, map.teleporters[i].y)) - { - font::print(PR_FONT_8X8 | PR_FULLBOR, data.legendxoff + (map.teleporters[i].x * 12 * data.zoom), data.legendyoff + (map.teleporters[i].y * 9 * data.zoom), "❓", 64, 64, 64); + if (map.showteleporters && map.isexplored(x + data.startx, y + data.starty)) + { + font::print(PR_FONT_8X8 | PR_FULLBOR, data.legendxoff + (x * 12 * data.zoom), data.legendyoff + (y * 9 * data.zoom), "💿", 171, 255, 252); + } + else if (map.showtargets && !map.isexplored(x + data.startx, y + data.starty)) + { + font::print(PR_FONT_8X8 | PR_FULLBOR, data.legendxoff + (x * 12 * data.zoom), data.legendyoff + (y * 9 * data.zoom), "❓", 64, 64, 64); + } } } @@ -2879,7 +2859,12 @@ static void rendermaplegend(void) { if (!obj.collect[i]) { - font::print(PR_FONT_8X8 | PR_FULLBOR, data.legendxoff + (map.shinytrinkets[i].x * 12 * data.zoom), data.legendyoff + (map.shinytrinkets[i].y * 9 * data.zoom), "🪙", 254, 252, 58); + 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) + { + font::print(PR_FONT_8X8 | PR_FULLBOR, data.legendxoff + (x * 12 * data.zoom), data.legendyoff + (y * 9 * data.zoom), "🪙", 254, 252, 58); + } } } } @@ -2887,44 +2872,45 @@ 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)) + if (room_x >= 0 && room_y >= 0 && room_x < data.width && room_y < data.height) { - int margin = (data.zoom == 4) ? 2 : 1; - graphics.draw_rect( - 40 + ((game.roomx - 100) * 12 * data.zoom) + margin + data.xoff, - 21 + ((game.roomy - 100) * 9 * data.zoom) + margin + data.yoff, - (12 * data.zoom) - (2 * margin), (9 * data.zoom) - (2 * margin), - 16, 245 - (help.glow), 245 - (help.glow) - ); - } - else if (map.cursorstate == 1 && int(map.cursordelay / 4) % 2 == 0) - { - 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); + } } } @@ -3491,7 +3477,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 7c005567..84f388ef 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -371,6 +371,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)