1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 09:39:43 +01:00

Update region system to current codebase due to PR rot

This commit is contained in:
mothbeanie 2024-07-05 14:59:15 -07:00 committed by Misa Elizabeth Kai
parent 94620d809e
commit dedf941b25
9 changed files with 366 additions and 115 deletions

View file

@ -1682,35 +1682,7 @@ bool customlevelclass::save(const std::string& _path)
void customlevelclass::generatecustomminimap(void) void customlevelclass::generatecustomminimap(void)
{ {
map.customzoom = 1; const MapRenderData data = map.get_render_data();
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);
// Start drawing the minimap // Start drawing the minimap
@ -1719,9 +1691,9 @@ void customlevelclass::generatecustomminimap(void)
graphics.clear(); graphics.clear();
// Scan over the map size // 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<SDL_Point> dark_points; std::vector<SDL_Point> dark_points;
std::vector<SDL_Point> light_points; std::vector<SDL_Point> light_points;
@ -1729,12 +1701,12 @@ void customlevelclass::generatecustomminimap(void)
bool dark = getroomprop(i2, j2)->tileset == 1; bool dark = getroomprop(i2, j2)->tileset == 1;
// Ok, now scan over each square // 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; int tile;
switch (map.customzoom) switch (data.zoom)
{ {
case 4: case 4:
tile = absfree( tile = absfree(
@ -1759,7 +1731,7 @@ void customlevelclass::generatecustomminimap(void)
if (tile >= 1) if (tile >= 1)
{ {
// Add this pixel // 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) if (dark)
{ {
dark_points.push_back(point); dark_points.push_back(point);

View file

@ -229,6 +229,16 @@ void Game::init(void)
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(crewstats, false, sizeof(crewstats));
SDL_memset(ndmresultcrewstats, false, sizeof(ndmresultcrewstats)); SDL_memset(ndmresultcrewstats, false, sizeof(ndmresultcrewstats));
SDL_memset(besttimes, -1, sizeof(besttimes)); SDL_memset(besttimes, -1, sizeof(besttimes));
@ -5948,6 +5958,50 @@ void Game::customloadquick(const std::string& savfile)
map.roomnameset = true; map.roomnameset = true;
map.roomname_special = 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, "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 //Special stats

View file

@ -1271,6 +1271,15 @@ void Graphics::draw_grid_tile(
draw_grid_tile(texture, t, x, y, width, height, color, 1, 1); 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) void Graphics::cutscenebars(void)
{ {
const int usethispos = lerp(oldcutscenebarspos, cutscenebarspos); const int usethispos = lerp(oldcutscenebarspos, cutscenebarspos);

View file

@ -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, 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_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); void updatetextboxes(void);
const char* textbox_line(char* buffer, size_t buffer_len, size_t textbox_i, size_t line_i); const char* textbox_line(char* buffer, size_t buffer_len, size_t textbox_i, size_t line_i);
void drawgui(void); void drawgui(void);
@ -337,6 +339,8 @@ public:
SDL_Texture* images[NUM_IMAGES]; SDL_Texture* images[NUM_IMAGES];
SDL_Texture* customminimaps[401];
bool flipmode; bool flipmode;
bool setflipmode; bool setflipmode;
bool notextoutline; bool notextoutline;

View file

@ -442,6 +442,28 @@ void GraphicsResources::init(void)
SDL_assert(0 && "Failed to create minimap texture! See stderr."); SDL_assert(0 && "Failed to create minimap texture! See stderr.");
return; 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_sprites_translated);
CLEAR(im_flipsprites_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 #undef CLEAR
VVV_freefunc(SDL_FreeSurface, im_sprites_surf); VVV_freefunc(SDL_FreeSurface, im_sprites_surf);

View file

@ -52,8 +52,6 @@ mapclass::mapclass(void)
custommode=false; custommode=false;
custommodeforreal=false; custommodeforreal=false;
custommmxoff=0; custommmyoff=0; custommmxsize=0; custommmysize=0;
customzoom=0;
customshowmm=true; customshowmm=true;
revealmap = 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. // 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) if (GlitchrunnerMode_less_than_or_equal(Glitchrunner2_2)
|| !custommode || !custommode
|| game.deathseq != -1) || game.deathseq != -1)
return; return;
int block_idx = -1; int block_idx = -1;
// obj.checktrigger() sets block_idx // obj.checktrigger() sets block_idx
int activetrigger = obj.checktrigger(&block_idx); int activetrigger = obj.checktrigger(&block_idx);
if (activetrigger <= -1 if (activetrigger <= -1
|| !INBOUNDS_VEC(block_idx, obj.blocks) || !INBOUNDS_VEC(block_idx, obj.blocks)
|| activetrigger < 300) || activetrigger < 300)
{ {
return; return;
} }
@ -2225,3 +2223,117 @@ void mapclass::twoframedelayfix(void)
game.setstatedelay(0); game.setstatedelay(0);
script.load(game.newscript); 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
}

View file

@ -12,6 +12,21 @@
#include "TowerBG.h" #include "TowerBG.h"
#include "WarpClass.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 struct Roomtext
{ {
int x, y; int x, y;
@ -163,8 +178,6 @@ public:
//Variables for playing custom levels //Variables for playing custom levels
bool custommode; bool custommode;
bool custommodeforreal; bool custommodeforreal;
int custommmxoff, custommmyoff, custommmxsize, custommmysize;
int customzoom;
bool customshowmm; bool customshowmm;
//final level colour cycling stuff //final level colour cycling stuff
@ -198,6 +211,25 @@ public:
//Map cursor //Map cursor
int cursorstate, cursordelay; 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 #ifndef MAP_DEFINITION

View file

@ -32,15 +32,6 @@ static int tr;
static int tg; static int tg;
static int tb; static int tb;
struct MapRenderData
{
int zoom;
int xoff;
int yoff;
int legendxoff;
int legendyoff;
};
static inline void drawslowdowntext(const int y) static inline void drawslowdowntext(const int y)
{ {
switch (game.slowdown) 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_LOW (graphics.flipmode ? PR_CJK_HIGH : PR_CJK_LOW)
#define FLIP_PR_CJK_HIGH (graphics.flipmode ? PR_CJK_LOW : PR_CJK_HIGH) #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) static void rendermap(void)
{ {
if (map.custommode && map.customshowmm) if (map.custommode && map.customshowmm)
{ {
graphics.drawpixeltextbox(35 + map.custommmxoff, 16 + map.custommmyoff, map.custommmxsize + 10, map.custommmysize + 10, 65, 185, 207); const MapRenderData data = map.get_render_data();
graphics.drawpartimage(graphics.minimap_mounted ? IMAGE_MINIMAP : IMAGE_CUSTOMMINIMAP, 40 + map.custommmxoff, 21 + map.custommmyoff, map.custommmxsize, map.custommmysize);
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; return;
} }
@ -2834,11 +2809,11 @@ static void rendermap(void)
static void rendermapfog(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)) if (!map.isexplored(i, j))
{ {
@ -2847,7 +2822,7 @@ static void rendermapfog(void)
{ {
for (int y = 0; y < data.zoom; y++) 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 // 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++) 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); if (map.showteleporters && map.isexplored(x + data.startx, y + data.starty))
} {
else if (map.showtargets && !map.isexplored(map.teleporters[i].x, map.teleporters[i].y)) font::print(PR_FONT_8X8 | PR_FULLBOR, data.legendxoff + (x * 12 * data.zoom), data.legendyoff + (y * 9 * data.zoom), "💿", 171, 255, 252);
{ }
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); 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]) 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) 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) if (!map.custommode && game.roomx == 109)
{ {
// Draw the tower specially // Draw the tower specially
if (!flashing || game.noflashingmode) 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) else if (map.cursorstate == 1)
{ {
if (int(map.cursordelay / 4) % 2 == 0) 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 + pixels_x, 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 + 2, 21 + 2, 12 - 4, 180 - 4, 255, 255, 255);
} }
} }
else if (map.cursorstate == 2 && (int(map.cursordelay / 15) % 2 == 0)) 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; 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; if (!flashing || ((map.cursorstate == 2 && int(map.cursordelay / 15) % 2 == 0) || game.noflashingmode))
graphics.draw_rect( {
40 + ((game.roomx - 100) * 12 * data.zoom) + margin + data.xoff, 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));
21 + ((game.roomy - 100) * 9 * data.zoom) + margin + data.yoff, }
(12 * data.zoom) - (2 * margin), (9 * data.zoom) - (2 * margin), else if (map.cursorstate == 1 && int(map.cursordelay / 4) % 2 == 0)
16, 245 - (help.glow), 245 - (help.glow) {
); 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);
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);
} }
} }
@ -3491,7 +3477,7 @@ void teleporterrender(void)
// Draw a box around the currently selected teleporter // Draw a box around the currently selected teleporter
const MapRenderData data = getmaprenderdata(); const MapRenderData data = map.get_render_data();
if (game.useteleporter) if (game.useteleporter)
{ {

View file

@ -371,6 +371,23 @@ void scriptclass::run(void)
map.customshowmm=false; 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") if (words[0] == "delay")
{ {
//USAGE: delay(frames) //USAGE: delay(frames)