From 662640c96c86ba83132f0683c35bfba24b43783c Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Mon, 6 Aug 2012 16:14:08 +0100 Subject: [PATCH] Fix previous merge with SOAP.cpp that created a bug in SOAP. add debug lines for PRTI, PRTO, WIFI and lines for SOAP. --- src/game/GameController.cpp | 2 ++ src/game/GameView.cpp | 2 +- src/graphics/Renderer.cpp | 31 ++++++++++++++++++++++++++++++- src/graphics/Renderer.h | 3 +++ src/simulation/ElementGraphics.h | 2 ++ src/simulation/elements/PRTI.cpp | 1 + src/simulation/elements/PRTO.cpp | 1 + src/simulation/elements/SOAP.cpp | 10 +++++++++- src/simulation/elements/WIFI.cpp | 1 + 9 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index ea21fd19f..2ca447d25 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -560,6 +560,8 @@ void GameController::Update() ui::Point pos = gameView->GetMousePosition(); if(pos.X >= 0 && pos.Y >= 0 && pos.X < XRES && pos.Y < YRES) { + gameModel->GetRenderer()->mousePosX = pos.X; + gameModel->GetRenderer()->mousePosY = pos.Y; gameView->SetSample(gameModel->GetSimulation()->Get(pos.X, pos.Y)); } diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index c9c293d6c..d0fde061b 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -1289,7 +1289,7 @@ void GameView::NotifyNotificationsChanged(GameModel * sender) std::vector notifications = sender->GetNotifications(); - int currentY = YRES-17; + int currentY = YRES-23; for(std::vector::iterator iter = notifications.begin(), end = notifications.end(); iter != end; ++iter) { int width = (Graphics::textwidth((*iter)->Message.c_str()))+8; diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp index c1f24da51..20bef9d3b 100644 --- a/src/graphics/Renderer.cpp +++ b/src/graphics/Renderer.cpp @@ -1127,6 +1127,14 @@ void Renderer::render_parts() #endif //Pixel rendering + if (pixel_mode & EFFECT_LINES) + { + if (t==PT_SOAP) + { + if ((parts[i].ctype&7) == 7) + draw_line(nx, ny, (int)(parts[parts[i].tmp].x+0.5f), (int)(parts[parts[i].tmp].y+0.5f), colr, colg, colb, cola); + } + } if(pixel_mode & PSPEC_STICKMAN) { char buff[20]; //Buffer for HP @@ -1619,6 +1627,25 @@ void Renderer::render_parts() addpixel(nx+nxo, ny+nyo, colr, colg, colb, 255-orbd[r]); } } + if (pixel_mode & EFFECT_DBGLINES) + { + if (mousePosX == nx && mousePosY == ny)//draw lines connecting wifi/portal channels + { + int z; + int type = parts[i].type; + if (type == PT_PRTI) + type = PT_PRTO; + else if (type == PT_PRTO) + type = PT_PRTI; + for (z = 0; zg = g; this->sim = sim; diff --git a/src/graphics/Renderer.h b/src/graphics/Renderer.h index bf0f4489b..e7d6e74b8 100644 --- a/src/graphics/Renderer.h +++ b/src/graphics/Renderer.h @@ -49,6 +49,9 @@ public: Graphics * g; gcache_item *graphicscache; + //Mouse position for debug information + int mousePosX, mousePosY; + //Zoom window ui::Point zoomWindowPosition; ui::Point zoomScopePosition; diff --git a/src/simulation/ElementGraphics.h b/src/simulation/ElementGraphics.h index e84db945b..0f3723cbf 100644 --- a/src/simulation/ElementGraphics.h +++ b/src/simulation/ElementGraphics.h @@ -25,6 +25,8 @@ #define EFFECT 0xFF000000 #define EFFECT_GRAVIN 0x01000000 #define EFFECT_GRAVOUT 0x02000000 +#define EFFECT_LINES 0x04000000 +#define EFFECT_DBGLINES 0x08000000 #define RENDER_EFFE OPTIONS | PSPEC_STICKMAN | EFFECT | PMODE_SPARK | PMODE_FLARE | PMODE_LFLARE #define RENDER_FIRE OPTIONS | PSPEC_STICKMAN | /*PMODE_FLAT |*/ PMODE_ADD | PMODE_BLEND | FIREMODE diff --git a/src/simulation/elements/PRTI.cpp b/src/simulation/elements/PRTI.cpp index 451c54bf0..8383d9036 100644 --- a/src/simulation/elements/PRTI.cpp +++ b/src/simulation/elements/PRTI.cpp @@ -129,6 +129,7 @@ int Element_PRTI::graphics(GRAPHICS_FUNC_ARGS) *firer = 255; *fireg = 0; *fireb = 0; + *pixel_mode |= EFFECT_DBGLINES; *pixel_mode |= EFFECT_GRAVIN; *pixel_mode &= ~PMODE; *pixel_mode |= PMODE_ADD; diff --git a/src/simulation/elements/PRTO.cpp b/src/simulation/elements/PRTO.cpp index 788e7d1e6..b4554ecb4 100644 --- a/src/simulation/elements/PRTO.cpp +++ b/src/simulation/elements/PRTO.cpp @@ -166,6 +166,7 @@ int Element_PRTO::graphics(GRAPHICS_FUNC_ARGS) *firer = 0; *fireg = 0; *fireb = 255; + *pixel_mode |= EFFECT_DBGLINES; *pixel_mode |= EFFECT_GRAVOUT; *pixel_mode &= ~PMODE; *pixel_mode |= PMODE_ADD; diff --git a/src/simulation/elements/SOAP.cpp b/src/simulation/elements/SOAP.cpp index d4ed39d43..1d3a55b71 100644 --- a/src/simulation/elements/SOAP.cpp +++ b/src/simulation/elements/SOAP.cpp @@ -43,6 +43,7 @@ Element_SOAP::Element_SOAP() HighTemperatureTransition = NT; Update = &Element_SOAP::update; + Graphics = &Element_SOAP::graphics; } @@ -120,7 +121,7 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS) parts[i].vx *= 0.5f; } - if(parts[i].ctype&2) + if(!(parts[i].ctype&2)) { for (rx=-2; rx<3; rx++) for (ry=-2; ry<3; ry++) @@ -279,5 +280,12 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS) return 0; } +//#TPT-Directive ElementHeader Element_SOAP static int graphics(GRAPHICS_FUNC_ARGS) +int Element_SOAP::graphics(GRAPHICS_FUNC_ARGS) + +{ + *pixel_mode |= EFFECT_LINES; + return 1; +} Element_SOAP::~Element_SOAP() {} diff --git a/src/simulation/elements/WIFI.cpp b/src/simulation/elements/WIFI.cpp index a108c910e..0dc08e016 100644 --- a/src/simulation/elements/WIFI.cpp +++ b/src/simulation/elements/WIFI.cpp @@ -93,6 +93,7 @@ int Element_WIFI::graphics(GRAPHICS_FUNC_ARGS) *colr = sin(frequency*q + 0) * 127 + 128; *colg = sin(frequency*q + 2) * 127 + 128; *colb = sin(frequency*q + 4) * 127 + 128; + *pixel_mode |= EFFECT_DBGLINES; return 0; }