You can now remove big overlays in the editor.

This commit is contained in:
Justin Marshall
2020-07-25 14:04:12 -07:00
parent 21a7ea57ea
commit 364659e640
5 changed files with 376 additions and 327 deletions
+68 -1
View File
@@ -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
+7
View File
@@ -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);
+20 -1
View File
@@ -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
+2
View File
@@ -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
*/