diff --git a/desktop_version/src/CustomLevels.cpp b/desktop_version/src/CustomLevels.cpp index 11d9b444904..4d62f5af998 100644 --- a/desktop_version/src/CustomLevels.cpp +++ b/desktop_version/src/CustomLevels.cpp @@ -1186,6 +1186,15 @@ bool customlevelclass::load(std::string& _path) edEntityEl->QueryIntAttribute("p5", &entity.p5); edEntityEl->QueryIntAttribute("p6", &entity.p6); + const char* activitytext = ""; + const char* activitycolour = ""; + + edEntityEl->QueryStringAttribute("activitytext", &activitytext); + edEntityEl->QueryStringAttribute("activitycolour", &activitycolour); + + entity.activitytext = activitytext; + entity.activitycolour = activitycolour; + customentities.push_back(entity); } } @@ -1409,14 +1418,23 @@ bool customlevelclass::save(const std::string& _path) { tinyxml2::XMLElement *edentityElement = doc.NewElement( "edentity" ); edentityElement->SetAttribute( "x", customentities[i].x); - edentityElement->SetAttribute( "y", customentities[i].y); - edentityElement->SetAttribute( "t", customentities[i].t); - edentityElement->SetAttribute( "p1", customentities[i].p1); - edentityElement->SetAttribute( "p2", customentities[i].p2); - edentityElement->SetAttribute( "p3", customentities[i].p3); + edentityElement->SetAttribute( "y", customentities[i].y); + edentityElement->SetAttribute( "t", customentities[i].t); + edentityElement->SetAttribute( "p1", customentities[i].p1); + edentityElement->SetAttribute( "p2", customentities[i].p2); + edentityElement->SetAttribute( "p3", customentities[i].p3); edentityElement->SetAttribute( "p4", customentities[i].p4); edentityElement->SetAttribute( "p5", customentities[i].p5); - edentityElement->SetAttribute( "p6", customentities[i].p6); + edentityElement->SetAttribute( "p6", customentities[i].p6); + if (!customentities[i].activitytext.empty()) + { + edentityElement->SetAttribute("activitytext", customentities[i].activitytext.c_str()); + } + if (!customentities[i].activitycolour.empty()) + { + edentityElement->SetAttribute("activitycolour", customentities[i].activitycolour.c_str()); + } + edentityElement->LinkEndChild( doc.NewText( customentities[i].scriptname.c_str() )) ; msg->LinkEndChild( edentityElement ); } diff --git a/desktop_version/src/CustomLevels.h b/desktop_version/src/CustomLevels.h index 8ce02e93b46..573b8b36c92 100644 --- a/desktop_version/src/CustomLevels.h +++ b/desktop_version/src/CustomLevels.h @@ -14,6 +14,8 @@ class CustomEntity //parameters int p1, p2, p3, p4, p5, p6; std::string scriptname; + std::string activitycolour; + std::string activitytext; }; diff --git a/desktop_version/src/Editor.cpp b/desktop_version/src/Editor.cpp index e831d5d12e2..c2e5f62ae77 100644 --- a/desktop_version/src/Editor.cpp +++ b/desktop_version/src/Editor.cpp @@ -261,6 +261,8 @@ static void addedentity( int xp, int yp, int tp, int p1 = 0, int p2 = 0, int p3 entity.p5=p5; entity.p6=p6; entity.scriptname=""; + entity.activitytext=""; + entity.activitycolour=""; customentities.push_back(entity); } @@ -798,14 +800,66 @@ void editorrender(void) } break; } - case 19: //Script Triggers - fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),customentities[i].p1*8,customentities[i].p2*8,graphics.getRGB(255,164,255)); - fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(255,255,255)); + case 19: // Script Triggers + fillboxabs((customentities[i].x * 8) - (ed.levx * 40 * 8), (customentities[i].y * 8) - (ed.levy * 30 * 8), customentities[i].p1 * 8, customentities[i].p2 * 8, graphics.getRGB(255, 164, 255)); + fillboxabs((customentities[i].x * 8) - (ed.levx * 40 * 8), (customentities[i].y * 8) - (ed.levy * 30 * 8), 8, 8, graphics.getRGB(255, 255, 255)); if (i == edent_under_cursor) { - graphics.bprint((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8)-8,customentities[i].scriptname,210,210,255); + graphics.bprint((customentities[i].x * 8) - (ed.levx * 40 * 8), (customentities[i].y * 8) - (ed.levy * 30 * 8) - 8, customentities[i].scriptname, 210, 210, 255); + } + break; + case 20: // Activity Zones + fillboxabs((customentities[i].x * 8) - (ed.levx * 40 * 8), (customentities[i].y * 8) - (ed.levy * 30 * 8), customentities[i].p1 * 8, customentities[i].p2 * 8, graphics.getRGB(164, 255, 255)); + fillboxabs((customentities[i].x * 8) - (ed.levx * 40 * 8), (customentities[i].y * 8) - (ed.levy * 30 * 8), 8, 8, graphics.getRGB(255, 255, 255)); + if (i == edent_under_cursor) + { + graphics.bprint((customentities[i].x * 8) - (ed.levx * 40 * 8), (customentities[i].y * 8) - (ed.levy * 30 * 8) - 8, customentities[i].scriptname, 210, 210, 255); } break; + case 21: // Collision Boxes + fillboxabs((customentities[i].x * 8) - (ed.levx * 40 * 8), (customentities[i].y * 8) - (ed.levy * 30 * 8), customentities[i].p1 * 8, customentities[i].p2 * 8, graphics.getRGB(164, 255, 164)); + fillboxabs((customentities[i].x * 8) - (ed.levx * 40 * 8), (customentities[i].y * 8) - (ed.levy * 30 * 8), 8, 8, graphics.getRGB(255, 255, 255)); + break; + case 22: // Damage Boxes + fillboxabs((customentities[i].x * 8) - (ed.levx * 40 * 8), (customentities[i].y * 8) - (ed.levy * 30 * 8), customentities[i].p1 * 8, customentities[i].p2 * 8, graphics.getRGB(255, 164, 164)); + fillboxabs((customentities[i].x * 8) - (ed.levx * 40 * 8), (customentities[i].y * 8) - (ed.levy * 30 * 8), 8, 8, graphics.getRGB(255, 255, 255)); + break; + case 23: // Directional Boxes + { + int x = (customentities[i].x * 8) - (ed.levx * 40 * 8); + int y = (customentities[i].y * 8) - (ed.levy * 30 * 8); + + // Move x and y to the center of the box + x += (customentities[i].p1 - 1) * 4; + y += (customentities[i].p2 - 1) * 4; + + if (customentities[i].p3 == 0) + { + // UP ARROW + graphics.bprint(x, y, "\xE2\x86\x91", 255, 255, 255); + } + else if (customentities[i].p3 == 1) + { + // DOWN ARROW + graphics.bprint(x, y, "\xE2\x86\x93", 255, 255, 255); + } + else if (customentities[i].p3 == 2) + { + // LEFT ARROW + graphics.bprint(x, y, "\xE2\x86\x90", 255, 255, 255); + } + else if (customentities[i].p3 == 3) + { + // RIGHT ARROW + graphics.bprint(x, y, "\xE2\x86\x92", 255, 255, 255); + } + fillboxabs((customentities[i].x * 8) - (ed.levx * 40 * 8), (customentities[i].y * 8) - (ed.levy * 30 * 8), customentities[i].p1 * 8, customentities[i].p2 * 8, graphics.getRGB(255, 255, 164)); + break; + } + case 24: // Safe Boxes + fillboxabs((customentities[i].x * 8) - (ed.levx * 40 * 8), (customentities[i].y * 8) - (ed.levy * 30 * 8), customentities[i].p1 * 8, customentities[i].p2 * 8, graphics.getRGB(164, 164, 255)); + fillboxabs((customentities[i].x * 8) - (ed.levx * 40 * 8), (customentities[i].y * 8) - (ed.levy * 30 * 8), 8, 8, graphics.getRGB(255, 255, 255)); + break; case 50: //Warp lines if(customentities[i].p1>=2) //Horizontal { diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index 6ac1d4d24ef..d5ccddca13e 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -850,6 +850,7 @@ void entityclass::createblock( int t, int xp, int yp, int w, int h, int trig /*= block.type = ACTIVITY; block.wp = w; block.hp = h; + block.script = script; block.rectset(xp, yp, w, h); //Ok, each and every activity zone in the game is initilised here. "Trig" in this case is a variable that diff --git a/desktop_version/src/Map.cpp b/desktop_version/src/Map.cpp index feffedb8cf7..9bfac30a244 100644 --- a/desktop_version/src/Map.cpp +++ b/desktop_version/src/Map.cpp @@ -2025,6 +2025,24 @@ void mapclass::loadlevel(int rx, int ry) obj.createblock(TRIGGER, ex, ey, ent.p1 * 8, ent.p2 * 8, 300 + tempscriptbox, "custom_" + ent.scriptname); tempscriptbox++; break; + case 20: // Activity Zone + obj.customactivitytext = ent.activitytext; + obj.customactivitycolour = ent.activitycolour; + obj.customscript = ent.scriptname; + obj.createblock(ACTIVITY, ex, ey, ent.p1 * 8, ent.p2 * 8, 35, "custom_" + ent.scriptname, true); + break; + case 21: // Collision Box + obj.createblock(BLOCK, ex, ey, ent.p1 * 8, ent.p2 * 8); + break; + case 22: // Damage Box + obj.createblock(DAMAGE, ex, ey, ent.p1 * 8, ent.p2 * 8); + break; + case 23: // Directional Box + obj.createblock(DIRECTIONAL, ex, ey, ent.p1 * 8, ent.p2 * 8, ent.p3); + break; + case 24: // Safe Box + obj.createblock(SAFE, ex, ey, ent.p1 * 8, ent.p2 * 8); + break; case 50: // Warp Lines obj.customwarpmode=true; switch (ent.p1) diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index 7831c924c51..8d2098e5439 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -839,6 +839,40 @@ void scriptclass::run(void) words[8] = word8; words[9] = word9; } + else if (words[0] == "createblock") + { + int i = BLOCK; + if (words[1] == "block") + { + i = BLOCK; + } + else if (words[1] == "trigger" || words[1] == "script") + { + i = TRIGGER; + } + else if (words[1] == "damage") + { + i = DAMAGE; + } + else if (words[1] == "directional") + { + i = DIRECTIONAL; + } + else if (words[1] == "safe") + { + i = SAFE; + } + else if (words[1] == "activity") + { + i = ACTIVITY; + } + else + { + i = ss_toi(words[1]); + } + + obj.createblock(i, ss_toi(words[2]), ss_toi(words[3]), ss_toi(words[4]), ss_toi(words[5]), ss_toi(words[6]), words[7], true); + } else if (words[0] == "createcrewman") { // Note: Do not change the "r" variable, it's used in custom levels