summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/chardump.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2006-11-29 18:12:52 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2006-11-29 18:12:52 +0000
commit61b0a568e4ac1a1c2c7fb8d038144488c0cd14d2 (patch)
tree1fb3a52208649aad9190b3640726ed0d0cb56dec /crawl-ref/source/chardump.cc
parent828402203ba5dabe03082ad8a0768a4b6a66e542 (diff)
downloadcrawl-ref-61b0a568e4ac1a1c2c7fb8d038144488c0cd14d2.tar.gz
crawl-ref-61b0a568e4ac1a1c2c7fb8d038144488c0cd14d2.zip
Redid how the resists screen works (both in-game and in-dump.)
Minor notes refactoring. Added a basic notes browser on '_'. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@528 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/chardump.cc')
-rw-r--r--crawl-ref/source/chardump.cc127
1 files changed, 46 insertions, 81 deletions
diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc
index e8b028f0c3..e5d65e183a 100644
--- a/crawl-ref/source/chardump.cc
+++ b/crawl-ref/source/chardump.cc
@@ -490,38 +490,14 @@ static void dump_stats( std::string & text )
//---------------------------------------------------------------
static void dump_stats2( std::string & text, bool calc_unid)
{
- char buffer[24*3][45];
- char str_pass[80];
- char* ptr_n;
+ std::vector<formatted_string> vfs = get_full_detail(calc_unid);
- get_full_detail(&buffer[0][0], calc_unid);
-
- for (int i = 0; i < 24; i++)
+ for (unsigned int i = 0; i < vfs.size(); i++)
{
- ptr_n = &buffer[i][0];
- if (buffer[i+24][0] == 0 && buffer[i+24*2][0] == 0)
- snprintf(&str_pass[0], 45, "%s", ptr_n);
- else
- snprintf(&str_pass[0], 45, "%-32s", ptr_n);
- text += str_pass;
-
- ptr_n = &buffer[i+24][0];
- if (buffer[i+24*2][0] == 0)
- snprintf(&str_pass[0], 45, "%s", ptr_n);
- else
- snprintf(&str_pass[0], 45, "%-20s", ptr_n);
- text += str_pass;
-
- ptr_n = &buffer[i+24*2][0];
- if (buffer[i+24*2][0] != 0)
- {
- snprintf(&str_pass[0], 45, "%s", ptr_n);
- text += str_pass;
- }
- text += "\n";
+ text += vfs[i];
+ text += '\n';
}
-
- text += "\n" "\n";
+ text += "\n\n";
}
static void sdump_notes(const std::string &, std::string& text)
@@ -532,7 +508,7 @@ static void sdump_notes(const std::string &, std::string& text)
text += "\nNotes\n| Turn |Location | Note\n";
text += "--------------------------------------------------------------\n";
for ( unsigned i = 0; i < note_list.size(); ++i ) {
- text += describe_note(note_list[i]);
+ text += note_list[i].describe();
text += "\n";
}
text += "\n";
@@ -1037,72 +1013,61 @@ static bool write_dump(
return (succeeded);
} // end dump_char()
-static void set_resist_dump_color( const char* data ) {
- while ( *data && *data != ':' )
- ++data;
- if ( *data == 0 )
- return;
- ++data;
- int pluscount = 0;
- while ( *data ) {
- if ( *data == '+' )
- ++pluscount;
- if ( *data == 'x' )
- --pluscount;
- ++data;
- }
- switch ( pluscount ) {
- case 3:
- case 2:
- textcolor(LIGHTGREEN);
- break;
- case 1:
- textcolor(GREEN);
- break;
- case -1:
- textcolor(RED);
- break;
- case -2:
- case -3:
- textcolor(LIGHTRED);
- break;
- default:
- textcolor(LIGHTGREY);
- break;
+void display_notes()
+{
+#ifdef DOS_TERM
+ char dosbuffer[4000];
+ gettext( 1, 1, 80, 25, dosbuffer );
+ window( 1, 1, 80, 25 );
+#endif
+ Menu scr;
+ scr.set_title( new MenuEntry("| Turn |Location | Note"));
+ for ( unsigned int i = 0; i < note_list.size(); ++i )
+ {
+ std::string prefix = note_list[i].describe(true, true, false);
+ std::string suffix = note_list[i].describe(false, false, true);
+ if ( suffix.empty() )
+ continue;
+ int spaceleft = get_number_of_cols() - prefix.length() - 1;
+ if ( spaceleft <= 0 )
+ return;
+ linebreak_string(suffix, spaceleft - 4, spaceleft);
+ std::vector<std::string> parts = split_string("\n", suffix);
+ scr.add_entry(new MenuEntry(prefix + parts[0]));
+ for ( unsigned int j = 1; j < parts.size(); ++j )
+ scr.add_entry(new MenuEntry(std::string(prefix.length()-2, ' ') +
+ std::string("| ") + parts[j]));
+
}
+ scr.show();
+#ifdef DOS_TERM
+ puttext(1, 1, 80, 25, dosbuffer);
+ window(1, 1, 80, 25);
+#endif
+ redraw_screen();
}
-void resists_screen() {
+void resists_screen()
+{
#ifdef DOS_TERM
char dosbuffer[4000];
gettext( 1, 1, 80, 25, dosbuffer );
window( 1, 1, 80, 25 );
#endif
+ std::vector<formatted_string> vfs = get_full_detail(false);
clrscr();
+ gotoxy(1,1);
textcolor(LIGHTGREY);
- char buffer[24*3][45];
- get_full_detail(&buffer[0][0], false);
-
- for (int line = 0; line < 24; ++line ) {
- for ( int block = 0; block < 3; ++block ) {
- const int idx = block * 24 + line;
- if ( buffer[idx][0] ) {
- gotoxy( block == 2 ? 53 : block * 32 + 1, line+1 );
- /* FIXME - hack - magic number 14 */
- if ( block != 0 && line < 14 )
- set_resist_dump_color(buffer[idx]);
- cprintf("%s", buffer[idx] );
- textcolor(LIGHTGREY);
- }
- }
+ formatted_scroller scr;
+ for ( unsigned i = 0; i < vfs.size(); ++i )
+ {
+ scr.add_item_formatted_string(vfs[i]);
}
-
- getch();
+ scr.show();
#ifdef DOS_TERM
puttext(1, 1, 80, 25, dosbuffer);
window(1, 1, 80, 25);
#endif
-
redraw_screen();
}