From 364659e640870a641939a7031101bfbb939594e0 Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Sat, 25 Jul 2020 14:04:12 -0700 Subject: [PATCH] You can now remove big overlays in the editor. --- SCM01EA.MAP | 604 ++++++++++++++++------------------- code/redalert/bigoverlay.cpp | 69 +++- code/redalert/bigoverlay.h | 7 + code/redalert/mapedit.cpp | 21 +- code/redalert/mapedit.h | 2 + 5 files changed, 376 insertions(+), 327 deletions(-) diff --git a/SCM01EA.MAP b/SCM01EA.MAP index fb34ecc..f95eeea 100644 --- a/SCM01EA.MAP +++ b/SCM01EA.MAP @@ -324,287 +324,245 @@ Percent=0 296=1266690944 297=1266691200 298=1283468416 -299=1166026880 -300=1182803840 -301=1182804096 -302=1182804352 -303=1199581312 -304=1199581568 -305=1199581824 -306=1216359040 -307=1216359296 -308=1233136512 -309=1233136768 -310=1249913984 -311=1149249408 -312=1149249664 -313=1166026368 -314=1166026624 -315=1166027136 -316=1182804608 -317=1199582080 -318=1098917760 -319=1115694720 -320=1115694976 -321=1115695232 -322=1132472192 -323=1132472448 -324=1132472704 -325=1149249920 -326=1149250176 -327=1166027392 -328=1166027648 -329=1082140544 -330=1082140800 -331=1098917504 -332=1098918016 -333=1098918272 -334=1115695488 -335=1115695744 -336=1132472960 -337=1048586368 -338=1048586624 -339=1065363328 -340=1065363584 -341=1065363840 -342=1065364096 -343=1082141056 -344=1082141312 -345=1082141568 -346=1098918528 -347=1098918784 -348=1098919040 -349=1115696000 -350=998254720 -351=1015031680 -352=1015031936 -353=1015032192 -354=1031809152 -355=1031809408 -356=1031809664 -357=1048586880 -358=1048587136 -359=1065364352 -360=1065364608 -361=998254976 -362=1015032448 -363=1031809920 -364=998254208 -365=998254464 -366=1015031424 -367=1031808896 -368=998253696 -369=1015030656 -370=1015030912 -371=1015031168 -372=1031807872 -373=1031808128 -374=1031808384 -375=1031808640 -376=1048585344 -377=1048585600 -378=1048585856 -379=1048586112 -380=1065362816 -381=1065363072 -382=998252928 -383=1015029888 -384=1015030144 -385=1015030400 -386=1031807360 -387=1031807616 -388=1048584832 -389=1048585088 -390=998252416 -391=1015029376 -392=1015029632 -393=1031806848 -394=1031807104 -395=1048584320 -396=1048584576 -397=998251904 -398=1015028864 -399=1015029120 -400=1031806336 -401=1031806592 -402=1048583808 -403=1048584064 -404=998251392 -405=1015028352 -406=1015028608 -407=1031805824 -408=1031806080 -409=1048583296 -410=1048583552 -411=998250880 -412=998251136 -413=1015028096 -414=1031805568 -415=1048583040 -416=796924288 -417=813701504 -418=813701760 -419=830478720 -420=830478976 -421=830479232 -422=847255936 -423=847256192 -424=780147072 -425=780147328 -426=796924544 -427=796924800 -428=813702016 -429=813702272 -430=830479488 -431=830479744 -432=847256704 -433=847256960 -434=796925056 -435=813702528 -436=830480000 -437=847257216 -438=796925312 -439=813702784 -440=830480256 -441=847257472 -442=847257728 -443=864034432 -444=864034688 -445=796925568 -446=796925824 -447=813703040 -448=813703296 -449=830480512 -450=830480768 -451=847257984 -452=847258240 -453=864035200 -454=864035456 -455=813703552 -456=830481024 -457=847258496 -458=864035712 -459=864035968 -460=880812928 -461=880813184 -462=813703808 -463=813704064 -464=830481280 -465=830481536 -466=847258752 -467=847259008 -468=864036224 -469=813704320 -470=813704576 -471=830481792 -472=830482048 -473=847259264 -474=847259520 -475=864036480 -476=864036736 -477=864036992 -478=880813696 -479=880813952 -480=796927872 -481=796928128 -482=813705344 -483=813705600 -484=830482816 -485=830483072 -486=847260288 -487=763373440 -488=780150400 -489=780150656 -490=780150912 -491=796927360 -492=796927616 -493=796928384 -494=813704832 -495=813705088 -496=813705856 -497=830482304 -498=830482560 -499=847259776 -500=847260032 -501=746595968 -502=746596224 -503=763372928 -504=763373184 -505=763373696 -506=780151168 -507=796928640 -508=679487104 -509=679487360 -510=696264064 -511=696264320 -512=696264576 -513=696264832 -514=713041536 -515=713041792 -516=713042048 -517=713042304 -518=729819008 -519=729819264 -520=729819520 -521=729819776 -522=746596480 -523=746596736 -524=645932672 -525=645932928 -526=662709632 -527=662709888 -528=662710144 -529=662710400 -530=679487616 -531=679487872 -532=696265088 -533=696265344 -534=612378752 -535=629155968 -536=629156224 -537=645933440 -538=645933696 -539=662710912 -540=612379008 -541=629156480 -542=645933952 -543=662711168 -544=662711424 -545=679488384 -546=612379264 -547=629156736 -548=645934208 -549=662711680 -550=679488640 -551=679488896 -552=679489152 -553=696266112 -554=629156992 -555=629157248 -556=645934464 -557=645934720 -558=662711936 -559=662712192 -560=612379776 -561=612380032 -562=629157504 -563=645934976 -564=578825344 -565=595602304 -566=595602560 -567=595602816 -568=612379520 -569=612380288 -570=629157760 -571=562047872 -572=562048128 -573=562048384 -574=578825088 -575=578825600 -576=578825856 -577=595603072 -578=595603328 -579=612380544 +299=1098917760 +300=1115694720 +301=1115694976 +302=1115695232 +303=1132472192 +304=1132472448 +305=1132472704 +306=1149249920 +307=1149250176 +308=1166027392 +309=1166027648 +310=1082140544 +311=1082140800 +312=1098917504 +313=1098918016 +314=1098918272 +315=1115695488 +316=1115695744 +317=1132472960 +318=1048586368 +319=1048586624 +320=1065363328 +321=1065363584 +322=1065363840 +323=1065364096 +324=1082141056 +325=1082141312 +326=1082141568 +327=1098918528 +328=1098918784 +329=1098919040 +330=1115696000 +331=998254720 +332=1015031680 +333=1015031936 +334=1015032192 +335=1031809152 +336=1031809408 +337=1031809664 +338=1048586880 +339=1048587136 +340=1065364352 +341=1065364608 +342=998254976 +343=1015032448 +344=1031809920 +345=998254208 +346=998254464 +347=1015031424 +348=1031808896 +349=998253696 +350=1015030656 +351=1015030912 +352=1015031168 +353=1031807872 +354=1031808128 +355=1031808384 +356=1031808640 +357=1048585344 +358=1048585600 +359=1048585856 +360=1048586112 +361=1065362816 +362=1065363072 +363=998252928 +364=1015029888 +365=1015030144 +366=1015030400 +367=1031807360 +368=1031807616 +369=1048584832 +370=1048585088 +371=998252416 +372=1015029376 +373=1015029632 +374=1031806848 +375=1031807104 +376=1048584320 +377=1048584576 +378=998251904 +379=1015028864 +380=1015029120 +381=1031806336 +382=1031806592 +383=1048583808 +384=1048584064 +385=998251392 +386=1015028352 +387=1015028608 +388=1031805824 +389=1031806080 +390=1048583296 +391=1048583552 +392=998250880 +393=998251136 +394=1015028096 +395=1031805568 +396=1048583040 +397=796924288 +398=813701504 +399=813701760 +400=830478720 +401=830478976 +402=830479232 +403=847255936 +404=847256192 +405=780147072 +406=780147328 +407=796924544 +408=796924800 +409=813702016 +410=813702272 +411=830479488 +412=830479744 +413=847256704 +414=847256960 +415=796925056 +416=813702528 +417=830480000 +418=847257216 +419=796925312 +420=813702784 +421=830480256 +422=847257472 +423=847257728 +424=864034432 +425=864034688 +426=796925568 +427=796925824 +428=813703040 +429=813703296 +430=830480512 +431=830480768 +432=847257984 +433=847258240 +434=864035200 +435=864035456 +436=813703552 +437=830481024 +438=847258496 +439=864035712 +440=864035968 +441=880812928 +442=880813184 +443=813703808 +444=813704064 +445=830481280 +446=830481536 +447=847258752 +448=847259008 +449=864036224 +450=813704320 +451=813704576 +452=830481792 +453=830482048 +454=847259264 +455=847259520 +456=864036480 +457=864036736 +458=864036992 +459=880813696 +460=880813952 +461=796927872 +462=796928128 +463=813705344 +464=813705600 +465=830482816 +466=830483072 +467=847260288 +468=763373440 +469=780150400 +470=780150656 +471=780150912 +472=796927360 +473=796927616 +474=796928384 +475=813704832 +476=813705088 +477=813705856 +478=830482304 +479=830482560 +480=847259776 +481=847260032 +482=645932672 +483=645932928 +484=662709632 +485=662709888 +486=662710144 +487=662710400 +488=679487616 +489=679487872 +490=696265088 +491=696265344 +492=612378752 +493=629155968 +494=629156224 +495=645933440 +496=645933696 +497=662710912 +498=612379008 +499=629156480 +500=645933952 +501=662711168 +502=662711424 +503=679488384 +504=612379264 +505=629156736 +506=645934208 +507=662711680 +508=679488640 +509=679488896 +510=679489152 +511=696266112 +512=629156992 +513=629157248 +514=645934464 +515=645934720 +516=662711936 +517=662712192 +518=612379776 +519=612380032 +520=629157504 +521=645934976 +522=578825344 +523=595602304 +524=595602560 +525=595602816 +526=612379520 +527=612380288 +528=629157760 +529=562047872 +530=562048128 +531=562048384 +532=578825088 +533=578825600 +534=578825856 +535=595603072 +536=595603328 +537=612380544 [BigOverlay] 0=1296971287,56,0,7 @@ -642,40 +600,36 @@ Percent=0 32=573650692,56,265,6 33=1263544231,36,271,17 34=1229596588,37,288,11 -35=1187784484,19,299,12 -36=1163011742,37,311,7 -37=1120019972,40,318,11 -38=1092691555,32,329,8 -39=1058482009,37,337,13 -40=1017587422,41,350,11 -41=1007101737,39,361,3 -42=1009591661,45,364,4 -43=1010311927,52,368,14 -44=1013129143,45,382,8 -45=1011228095,44,390,7 -46=1013324767,44,397,7 -47=1009129972,44,404,7 -48=1007884343,45,411,5 -49=793253506,6,416,8 -50=793253996,0,424,10 -51=807279234,1,434,4 -52=809376652,28,438,7 -53=811015539,22,445,10 -54=826023822,0,455,7 -55=828842361,30,462,7 -56=817308585,5,469,11 -57=812918401,34,480,7 -58=786703846,37,487,14 -59=755901926,37,501,7 -60=688793041,37,508,16 -61=655631820,36,524,10 -62=630794033,35,534,6 -63=625289178,7,540,6 -64=626010319,25,546,8 -65=634727242,13,554,6 -66=618670911,17,560,4 -67=593505023,36,564,7 -68=564144917,16,571,9 +37=1120019972,40,299,11 +38=1092691555,32,310,8 +39=1058482009,37,318,13 +40=1017587422,41,331,11 +41=1007101737,39,342,3 +42=1009591661,45,345,4 +43=1010311927,52,349,14 +44=1013129143,45,363,8 +45=1011228095,44,371,7 +46=1013324767,44,378,7 +47=1009129972,44,385,7 +48=1007884343,45,392,5 +49=793253506,6,397,8 +50=793253996,0,405,10 +51=807279234,1,415,4 +52=809376652,28,419,7 +53=811015539,22,426,10 +54=826023822,0,436,7 +55=828842361,30,443,7 +56=817308585,5,450,11 +57=812918401,34,461,7 +58=786703846,37,468,14 +61=655631820,36,482,10 +62=630794033,35,492,6 +63=625289178,7,498,6 +64=626010319,25,504,8 +65=634727242,13,512,6 +66=618670911,17,518,4 +67=593505023,36,522,7 +68=564144917,16,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FBdwlAPdqAOJNAIEFAIH+dQD/UPn/WgDK +7=AEBY1k0BQHr/WQDMAN5MATEC/1cATAFgV9dLAf9dAMUBAN1gXtTNAgCA/1wAzABQXtVKAB +8=Ag/1oASQNRANpKAf9cAEcDcFzYrAL/XABKAXGA2awB/2MASwDYRgP/WwBJBXB22y0E/1gA +9=TALkSwL/YwDKANrNBv9dAMYD/lgY/4A= [Briefing] 1=Rescue Einstein from the Headquarters inside this Soviet complex. Once @@ -761,5 +715,5 @@ Count=0 4=Direct Tanya to destroy the westmost power plants to take them off-line. [Digest] -1=Fp95NseCgmsoqx7UQ/UMrQlv2CM= +1=ty7v+aJuxNMiESmZBtqZtzZ5pIc= diff --git a/code/redalert/bigoverlay.cpp b/code/redalert/bigoverlay.cpp index 1998842..2bfcce0 100644 --- a/code/redalert/bigoverlay.cpp +++ b/code/redalert/bigoverlay.cpp @@ -18,6 +18,8 @@ BigOverlay::BigOverlay() { image = NULL; numOverlayedCells = 0; enabled = false; + screenx = -1; + screeny = -1; } /* @@ -28,6 +30,10 @@ BigOverlay::Place void BigOverlay::Place(int screenx, int screeny) { COORDINATE lightCoord; + if (enabled) { + return; + } + Map.FlagBigOverlayCells(this, screenx, screeny); CellClass::ConvertIsoCoordsToScreen(screenx, screeny); @@ -60,9 +66,38 @@ void BigOverlay::draw_it(void) { if ((!(cellptr->Is_Mapped(PlayerPtr) && cellptr->Is_Visible(PlayerPtr))) && !Debug_Unshroud) return; - int screenx, screeny; + screenx = 0; + screeny = 0; + if(Map.GetSelectedBigOverlay() == this) + { + GL_SetColor(1.0f, 0.0f, 0.0f); + } GetRenderPosition(screenx, screeny); GL_RenderImage(image, screenx, screeny, image->width, image->height); + if (Map.GetSelectedBigOverlay() == this) + { + GL_SetColor(1.0f, 1.0f, 1.0f); + } +} + +/* +==================== +BigOverlayManager::InRegion +==================== +*/ +bool BigOverlay::InRegion(int x, int y) { + Rect rect; + int width = image->width; + int height = image->height; + + rect.X = screenx; + rect.Y = screeny; + rect.X2 = rect.X + width; + rect.Y2 = rect.Y + height; + rect.Width = width; + rect.Height = height; + + return rect.ContainsPoint(x, y); } /* @@ -172,6 +207,22 @@ BigOverlay* BigOverlayManager::AllocateBigOverlay(void) { return NULL; } +/* +==================== +BigOverlayManager::Editor_RemoveBigOverlay +==================== +*/ +void BigOverlayManager::Editor_RemoveBigOverlay(BigOverlay* bigOverlay) { + for(int i = 0; i < bigOverlay->numOverlayedCells; i++) + { + CellClass* cellptr = &(Map)[bigOverlay->overlayedCells[i]]; + cellptr->bigOverlay = NULL; + } + + bigOverlay->numOverlayedCells = 0; + bigOverlay->enabled = false; +} + /* ==================== BigOverlayManager::Editor_PlaceNewBigOverlay @@ -290,6 +341,22 @@ void BigOverlayManager::Write_Scenerio(CCINIClass* ini) { } } +/* +==================== +BigOverlayManager::SelectBigOverlay +==================== +*/ +BigOverlay* BigOverlayManager::SelectBigOverlay(int x, int y) { + for (int i = 0; i < MAX_WORLD_BIGOVERLAYS; i++) { + if (bigOverlays[i].IsEnabled()) { + if(bigOverlays[i].InRegion(x, y)) { + return &bigOverlays[i]; + } + } + } + return NULL; +} + /* ==================== BigOverlayManager::Read_Scenerio diff --git a/code/redalert/bigoverlay.h b/code/redalert/bigoverlay.h index 5e58c3f..6694b1d 100644 --- a/code/redalert/bigoverlay.h +++ b/code/redalert/bigoverlay.h @@ -28,6 +28,9 @@ public: Image_t* GetImage(void) { return image; } void SetEnabled(bool enabled) { this->enabled = enabled; } COORDINATE GetPosition() { return position; } + int GetScreenX() { return screenx; } + int GetScreenY() { return screeny; } + bool InRegion(int x, int y); protected: void SetPosition(COORDINATE position) { this->position = position; } void SetOverlayNum(int overlayNum) { this->overlayNum = overlayNum; } @@ -42,6 +45,8 @@ private: Image_t* image; bool enabled; int index; + int screenx; + int screeny; }; class BigOverlayManager { @@ -65,7 +70,9 @@ public: // Allocates a big overlay BigOverlay* AllocateBigOverlay(void); + BigOverlay* SelectBigOverlay(int x, int y); + void Editor_RemoveBigOverlay(BigOverlay* bigOverlay); BigOverlay *Editor_PlaceNewBigOverlay(void); private: void RegisterBigOverlay(int theater, const char* name); diff --git a/code/redalert/mapedit.cpp b/code/redalert/mapedit.cpp index 39edd53..1e53b41 100644 --- a/code/redalert/mapedit.cpp +++ b/code/redalert/mapedit.cpp @@ -552,7 +552,17 @@ void MapEditClass::AI(KeyNumType & input, int x, int y) //GL_DrawText(6, 64, 64, tmp); rc = Mouse_Moved(); - if (Keyboard->Down(KN_LMOUSE) && rc) { + + if (Keyboard->Down(KN_DELETE)) { + if (GrabbedBigOverlay) + { + bigOverlayManager.Editor_RemoveBigOverlay(GrabbedBigOverlay); + GrabbedBigOverlay = NULL; + } + } + + bool lMouseDown = Keyboard->Down(KN_LMOUSE); + if (lMouseDown && rc) { if (GrabbedBigOverlay) { GrabbedBigOverlay->Place(Get_Mouse_X(), Get_Mouse_Y()); @@ -590,6 +600,15 @@ void MapEditClass::AI(KeyNumType & input, int x, int y) } } + if (lMouseDown && GrabbedBigOverlay == NULL && PendingObject == NULL) + { + BigOverlay* tempOverlay = bigOverlayManager.SelectBigOverlay(Get_Mouse_X(), Get_Mouse_Y()); + if (tempOverlay) + { + GrabbedBigOverlay = tempOverlay; + } + } + if (editorSidebar.mainmenu_selection != -1) { /* ** Turn off placement mode diff --git a/code/redalert/mapedit.h b/code/redalert/mapedit.h index 534b3e7..b7f2e57 100644 --- a/code/redalert/mapedit.h +++ b/code/redalert/mapedit.h @@ -205,6 +205,8 @@ class MapEditClass : public MouseClass // int Trigger_Needs_Team(TriggerClass *trigger); void Fatal(int txt); + BigOverlay* GetSelectedBigOverlay(void) { return GrabbedBigOverlay; } + /* ** mapeddlg.cpp */