Rewrote the avoidpath debug code to use new graphics functions

svn-id: r45533
This commit is contained in:
Filippos Karapetis 2009-10-30 11:26:00 +00:00
parent 0c2ab71829
commit 932cd54bbe
3 changed files with 36 additions and 38 deletions

View file

@ -26,8 +26,7 @@
#include "sci/sci.h" #include "sci/sci.h"
#include "sci/engine/state.h" #include "sci/engine/state.h"
#include "sci/engine/kernel.h" #include "sci/engine/kernel.h"
#include "sci/gfx/gfx_widgets.h" #include "sci/gui/gui.h"
#include "sci/gfx/gfx_state_internal.h" // required for GfxPort, GfxContainer
#include "common/list.h" #include "common/list.h"
@ -307,41 +306,42 @@ static void draw_line(EngineState *s, Common::Point p1, Common::Point p2, int ty
// Red : Barred access // Red : Barred access
// Blue: Near-point access // Blue: Near-point access
// Yellow: Contained access // Yellow: Contained access
int poly_colors[][3] = {{0, 255, 0}, {0, 0, 255}, {255, 0, 0}, {255, 255, 0}}; int poly_colors[4] = {
gfx_color_t col; s->_gui->paletteFind(0, 255, 0), // green
GfxList *decorations = s->picture_port->_decorations; s->_gui->paletteFind(255, 0, 0), // red
GfxPrimitive *line; s->_gui->paletteFind(0, 0, 255), // blue
s->_gui->paletteFind(255, 255, 0) // yellow
};
col.visual = PaletteEntry(poly_colors[type][0], poly_colors[type][1], poly_colors[type][2]); // Clip
col.alpha = 0; p1.x = CLIP<int16>(p1.x, 0, 319);
col.priority = -1; p1.y = CLIP<int16>(p1.y, 0, 199);
col.control = 0; p2.x = CLIP<int16>(p2.x, 0, 319);
col.mask = GFX_MASK_VISUAL | GFX_MASK_PRIORITY; p2.y = CLIP<int16>(p2.y, 0, 199);
p1.y += 10; assert(type >= 0 && type <= 3);
p2.y += 10; s->_gui->graphDrawLine(p1, p2, poly_colors[type], 255, 255);
line = gfxw_new_line(p1, p2, col, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL);
decorations->add((GfxContainer *)decorations, (GfxWidget *)line);
} }
static void draw_point(EngineState *s, Common::Point p, int start) { static void draw_point(EngineState *s, Common::Point p, int start) {
// Colors for starting and end point // Colors for starting and end point
// Green: End point // Green: End point
// Blue: Starting point // Blue: Starting point
int point_colors[][3] = {{0, 255, 0}, {0, 0, 255}}; int point_colors[2] = {
gfx_color_t col; s->_gui->paletteFind(0, 255, 0), // green
GfxList *decorations = s->picture_port->_decorations; s->_gui->paletteFind(0, 0, 255) // blue
GfxBox *box; };
col.visual = PaletteEntry(point_colors[start][0], point_colors[start][1], point_colors[start][2]); Common::Rect rect = Common::Rect(p.x - 1, p.y - 1, p.x - 1 + 3, p.y - 1 + 3);
col.alpha = 0;
col.priority = -1;
col.control = 0;
col.mask = GFX_MASK_VISUAL | GFX_MASK_PRIORITY;
box = gfxw_new_box(s->gfx_state, gfx_rect(p.x - 1, p.y - 1 + 10, 3, 3), col, col, GFX_BOX_SHADE_FLAT); // Clip
decorations->add((GfxContainer *)decorations, (GfxWidget *)box); rect.top = CLIP<int16>(rect.top, 0, 199);
rect.bottom = CLIP<int16>(rect.bottom, 0, 199);
rect.left = CLIP<int16>(rect.left, 0, 319);
rect.right = CLIP<int16>(rect.right, 0, 319);
assert(start >= 0 && start <= 1);
s->_gui->graphFrameBox(rect, point_colors[start]);
} }
static void draw_polygon(EngineState *s, reg_t polygon) { static void draw_polygon(EngineState *s, reg_t polygon) {
@ -1685,17 +1685,6 @@ static reg_t output_path(PathfindingState *p, EngineState *s) {
reg_t kAvoidPath(EngineState *s, int argc, reg_t *argv) { reg_t kAvoidPath(EngineState *s, int argc, reg_t *argv) {
Common::Point start = Common::Point(argv[0].toSint16(), argv[1].toSint16()); Common::Point start = Common::Point(argv[0].toSint16(), argv[1].toSint16());
#ifdef DEBUG_AVOIDPATH
GfxPort *port = s->picture_port;
if (!port->_decorations) {
port->_decorations = gfxw_new_list(gfx_rect(0, 0, 320, 200), 0);
port->_decorations->setVisual(port->_visual);
} else {
port->_decorations->free_contents(port->_decorations);
}
#endif
switch (argc) { switch (argc) {
case 3 : { case 3 : {
@ -1730,6 +1719,9 @@ reg_t kAvoidPath(EngineState *s, int argc, reg_t *argv) {
print_input(s, poly_list, start, end, opt); print_input(s, poly_list, start, end, opt);
draw_input(s, poly_list, start, end, opt); draw_input(s, poly_list, start, end, opt);
} }
// Update the whole screen
s->_gui->graphUpdateBox(Common::Rect(0, 0, 319, 219));
#endif #endif
p = convert_polygon_set(s, poly_list, start, end, opt); p = convert_polygon_set(s, poly_list, start, end, opt);

View file

@ -434,6 +434,11 @@ void SciGui::graphFillBox(Common::Rect rect, uint16 colorMask, int16 color, int1
_gfx->FillRect(rect, colorMask, color, priority, control); _gfx->FillRect(rect, colorMask, color, priority, control);
} }
void SciGui::graphFrameBox(Common::Rect rect, int16 color) {
_gfx->PenColor(color);
_gfx->FrameRect(rect);
}
void SciGui::graphDrawLine(Common::Point startPoint, Common::Point endPoint, int16 color, int16 priority, int16 control) { void SciGui::graphDrawLine(Common::Point startPoint, Common::Point endPoint, int16 color, int16 priority, int16 control) {
_gfx->OffsetLine(startPoint, endPoint); _gfx->OffsetLine(startPoint, endPoint);
_screen->drawLine(startPoint.x, startPoint.y, endPoint.x, endPoint.y, color, priority, control); _screen->drawLine(startPoint.x, startPoint.y, endPoint.x, endPoint.y, color, priority, control);

View file

@ -93,6 +93,7 @@ public:
virtual void graphFillBoxForeground(Common::Rect rect); virtual void graphFillBoxForeground(Common::Rect rect);
virtual void graphFillBoxBackground(Common::Rect rect); virtual void graphFillBoxBackground(Common::Rect rect);
virtual void graphFillBox(Common::Rect rect, uint16 colorMask, int16 color, int16 priority, int16 control); virtual void graphFillBox(Common::Rect rect, uint16 colorMask, int16 color, int16 priority, int16 control);
virtual void graphFrameBox(Common::Rect rect, int16 color);
virtual void graphDrawLine(Common::Point startPoint, Common::Point endPoint, int16 color, int16 priority, int16 control); virtual void graphDrawLine(Common::Point startPoint, Common::Point endPoint, int16 color, int16 priority, int16 control);
virtual reg_t graphSaveBox(Common::Rect rect, uint16 flags); virtual reg_t graphSaveBox(Common::Rect rect, uint16 flags);
virtual void graphRestoreBox(reg_t handle); virtual void graphRestoreBox(reg_t handle);