summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/view.cc
diff options
context:
space:
mode:
authorpauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-30 21:06:06 +0000
committerpauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-30 21:06:06 +0000
commitfee3247c619f8ffd2d77c0d0a1c1bc7f24014f1b (patch)
tree6a3799b617ca13992691d7f5a733b0de42eccfc9 /crawl-ref/source/view.cc
parentf116902db8e7f917df91a3a1e775cc43cf7dd47a (diff)
downloadcrawl-ref-fee3247c619f8ffd2d77c0d0a1c1bc7f24014f1b.tar.gz
crawl-ref-fee3247c619f8ffd2d77c0d0a1c1bc7f24014f1b.zip
Add DEBUG_PANE_BOUNDS, which draws little bits at the upper-left and
right of each pane. The HUD bits are overwritten by the hud display, but as the comment notes: // Doesn't work for HUD because print_stats() overwrites it. // To debug HUD, add viewwindow(false,false) at end of _prep_input. Add checks that no panes extend beyond the term size, or all the way to the term bottom. (Bottom line is not available unless we can keep the screen from scrolling when we write to it) Fix a bunch of off-by-one errors. Using a point vs vector metaphor seems to flush them out nicely (hooray for affine math!) There are still problems with the monster list resizing too big and squishing the main map view -- didn't address any of that. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3959 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/view.cc')
-rw-r--r--crawl-ref/source/view.cc84
1 files changed, 72 insertions, 12 deletions
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index 5bd2a3b22f..14b61f6e31 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -74,6 +74,8 @@
#include "tutorial.h"
#include "xom.h"
+#define DEBUG_PANE_BOUNDS 0
+
// These are hidden from the rest of the world... use the functions
// below to get information about the map grid.
#define MAP_MAGIC_MAPPED_FLAG 0x01
@@ -4546,6 +4548,35 @@ bool view_update()
return (false);
}
+static void _debug_pane_bounds()
+{
+#if DEBUG_PANE_BOUNDS
+ // Doesn't work for HUD because print_stats() overwrites it.
+ // To debug HUD, add viewwindow(false,false) at end of _prep_input.
+
+ cgotoxy(1,1, GOTO_MLIST);
+ cprintf("+ L");
+ cgotoxy(crawl_view.mlistsz.x-4, crawl_view.mlistsz.y, GOTO_MLIST);
+ cprintf("L +");
+
+ cgotoxy(1,1, GOTO_STAT);
+ cprintf("+ H");
+ cgotoxy(crawl_view.hudsz.x-3, crawl_view.hudsz.y, GOTO_STAT);
+ cprintf("H +");
+
+ cgotoxy(1,1, GOTO_MSG);
+ cprintf("+ M");
+ cgotoxy(crawl_view.msgsz.x-2, crawl_view.msgsz.y, GOTO_MSG);
+ cprintf("M +");
+
+ cgotoxy(crawl_view.viewp.x, crawl_view.viewp.y);
+ cprintf("+V");
+ cgotoxy(crawl_view.viewp.x+crawl_view.viewsz.x-2,
+ crawl_view.viewp.y+crawl_view.viewsz.y-1);
+ cprintf("V+");
+#endif
+}
+
//---------------------------------------------------------------
//
// viewwindow -- now unified and rolled into a single pass
@@ -4851,6 +4882,8 @@ void viewwindow(bool draw_it, bool do_updates)
update_monster_pane();
}
}
+
+ _debug_pane_bounds();
} // end viewwindow()
//////////////////////////////////////////////////////////////////////////////
@@ -4956,6 +4989,12 @@ void crawl_view_geometry::set_player_at(const coord_def &c, bool centre)
void crawl_view_geometry::init_geometry()
{
+ // Points and sizes can be combined in these ways:
+ // p+p=meaningless, p+sz=p, p-p=sz, p-sz=p
+ // sz+p=p, sz+sz=sz, sz-p=meaningless, sz-sz=sz
+
+ const coord_def termp(1,1);
+
termsz = coord_def( get_number_of_cols(), get_number_of_lines() );
#ifndef USE_TILE
@@ -5000,9 +5039,10 @@ void crawl_view_geometry::init_geometry()
if (!mlist_inline)
{
- mlistp = coord_def(1, 1);
- mlistsz = coord_def(mlist_max_width, viewsz.y);
- mlistsz.x = std::min(mlist_min_width + freewidth, mlistsz.x);
+ mlistp = termp;
+ const int _mlist_max_width = mlist_max_width; // work around link problem?
+ mlistsz.x = std::min(mlist_min_width + freewidth, _mlist_max_width);
+ mlistsz.y = viewsz.y;
viewp.x = mlistp.x + mlistsz.x;
}
@@ -5030,17 +5070,20 @@ void crawl_view_geometry::init_geometry()
len = std::max(len, Options.mlist_min_height);
len = std::min(len, 1 + termsz.y - message_min_lines - (hudp.y + hudsz.y));
mlistsz = coord_def(termsz.x - (mlistp.x - 1), len);
-
- // The message pane takes all lines not used by the viewport and
- // the mlist.
- int msgstart = mlistp.y + mlistsz.y;
- msgp = coord_def(1, msgstart);
- msgsz = coord_def(termsz.x, termsz.y - msgstart - 1);
}
- else
+
+ // Calculate message area
{
- msgp = coord_def(1, viewsz.y + 1);
- msgsz = coord_def(termsz.x, termsz.y - viewsz.y);
+ // Always from lhs of term to rhs of term
+ msgp.x = termp.x;
+ msgsz.x = termsz.x;
+ // From bottom of mlist or view, whichever is lower, to bottom of term
+ msgp.y = std::max((mlistp+mlistsz).y, (viewp+viewsz).y);
+ msgsz.y = termsz.y - (msgp-termp).y;
+
+ // Well, actually not to the very bottom. Drawing the last line causes
+ // the screen to scroll. If this is fixed, we get another line of message.
+ msgsz.y -= 1;
}
#ifdef USE_TILE
@@ -5051,6 +5094,23 @@ void crawl_view_geometry::init_geometry()
viewhalfsz = viewsz / 2;
init_view();
+
+#ifndef USE_TILE
+ // Check that all the panes fit in the view. Note that currently
+ // no pane is allowed to stretch all the way to the bottom (see
+ // comment by message pane calculation, above.
+ ASSERT( (viewp+viewsz-termp).x <= termsz.x );
+ ASSERT( (viewp+viewsz-termp).y <= termsz.y-1 );
+
+ ASSERT( (hudp+hudsz-termp).x <= termsz.x );
+ ASSERT( (hudp+hudsz-termp).y <= termsz.y-1 );
+
+ ASSERT( (msgp+msgsz-termp).x <= termsz.x );
+ ASSERT( (msgp+msgsz-termp).y <= termsz.y-1 );
+
+ ASSERT( (mlistp+mlistsz-termp).x <= termsz.x );
+ ASSERT( (mlistp+mlistsz-termp).y <= termsz.y-1 );
+#endif
}
////////////////////////////////////////////////////////////////////////////