summaryrefslogtreecommitdiffstats
path: root/crawl-ref
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
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')
-rw-r--r--crawl-ref/source/acr.cc16
-rw-r--r--crawl-ref/source/chardump.cc127
-rw-r--r--crawl-ref/source/chardump.h1
-rw-r--r--crawl-ref/source/enum.h1
-rw-r--r--crawl-ref/source/initfile.cc22
-rw-r--r--crawl-ref/source/initfile.h1
-rw-r--r--crawl-ref/source/menu.cc43
-rw-r--r--crawl-ref/source/menu.h5
-rw-r--r--crawl-ref/source/notes.cc206
-rw-r--r--crawl-ref/source/notes.h3
-rw-r--r--crawl-ref/source/output.cc345
-rw-r--r--crawl-ref/source/output.h4
-rw-r--r--crawl-ref/source/overmap.cc22
13 files changed, 454 insertions, 342 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index bc04926c5a..9adaefda6a 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -839,8 +839,8 @@ static void input() {
you.turn_is_over = false;
prep_input();
- /* you.paralysis check */
- if ( you.paralysis ) {
+ if ( you.paralysis )
+ {
world_reacts();
return;
}
@@ -851,13 +851,14 @@ static void input() {
gotoxy(18,9);
- if ( you_are_delayed() ) {
+ if ( you_are_delayed() )
+ {
world_reacts();
return;
}
- /* Change from previous code! */
- if ( you.turn_is_over ) {
+ if ( you.turn_is_over )
+ {
world_reacts();
return;
}
@@ -1040,6 +1041,10 @@ void process_command( command_type cmd ) {
make_user_note();
break;
+ case CMD_DISPLAY_NOTES:
+ display_notes();
+ break;
+
case CMD_CLEAR_MAP:
if (you.level_type != LEVEL_LABYRINTH &&
you.level_type != LEVEL_ABYSS) {
@@ -2345,6 +2350,7 @@ command_type keycode_to_command( keycode_type key ) {
case '%': return CMD_RESISTS_SCREEN;
case ',': return CMD_PICKUP;
case ':': return CMD_MAKE_NOTE;
+ case '_': return CMD_DISPLAY_NOTES;
case ';': return CMD_INSPECT_FLOOR;
case '!': return CMD_SHOUT;
case '^': return CMD_DISPLAY_RELIGION;
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();
}
diff --git a/crawl-ref/source/chardump.h b/crawl-ref/source/chardump.h
index 1603ae9f75..696b786a51 100644
--- a/crawl-ref/source/chardump.h
+++ b/crawl-ref/source/chardump.h
@@ -22,6 +22,7 @@ bool dump_char(const std::string &fname,
bool full_id = false);
void resists_screen();
+void display_notes();
std::string munge_description(const std::string &inStr);
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index afccb53482..fa119020c3 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -645,6 +645,7 @@ enum command_type
CMD_TOGGLE_AUTOPRAYER,
CMD_MAKE_NOTE,
CMD_RESISTS_SCREEN,
+ CMD_DISPLAY_NOTES,
/* overmap commands */
CMD_MAP_CLEAR_MAP,
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index 7abb47dab3..6316354b38 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -51,18 +51,26 @@ template<class A, class B> void append_vector(A &dest, const B &src)
dest.insert( dest.end(), src.begin(), src.end() );
}
+const std::string cols[16] =
+{
+ "black", "blue", "green", "cyan", "red", "magenta", "brown",
+ "lightgrey", "darkgrey", "lightblue", "lightgreen", "lightcyan",
+ "lightred", "lightmagenta", "yellow", "white"
+};
+
+const char* colour_to_str(unsigned char colour)
+{
+ if ( colour >= 16 )
+ return "lightgrey";
+ else
+ return cols[colour].c_str();
+}
+
// returns -1 if unmatched else returns 0-15
int str_to_colour( const std::string &str, int default_colour )
{
int ret;
- const std::string cols[16] =
- {
- "black", "blue", "green", "cyan", "red", "magenta", "brown",
- "lightgrey", "darkgrey", "lightblue", "lightgreen", "lightcyan",
- "lightred", "lightmagenta", "yellow", "white"
- };
-
const std::string element_cols[] =
{
"fire", "ice", "earth", "electricity", "air", "poison", "water",
diff --git a/crawl-ref/source/initfile.h b/crawl-ref/source/initfile.h
index ffe3ff5c30..f5c05972e0 100644
--- a/crawl-ref/source/initfile.h
+++ b/crawl-ref/source/initfile.h
@@ -20,6 +20,7 @@
std::string & trim_string( std::string &str );
std::string & tolower_string( std::string &str );
int str_to_colour( const std::string &str, int default_colour = -1 );
+const char* colour_to_str( unsigned char colour );
// last updated 12may2000 {dlb}
/* ***********************************************************************
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index 47a3e6a653..df4c012930 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -1276,21 +1276,50 @@ void column_composer::compose_formatted_column(
formatted_scroller::formatted_scroller(int _flags, const std::string& s) :
Menu(_flags)
{
+ add_text(s);
+}
+
+void formatted_scroller::add_text(const std::string& s)
+{
size_t eolpos = 0;
while ( true )
{
- const size_t newpos = s.find( EOL, eolpos );
- add_entry(new MenuEntry(std::string(s, eolpos, newpos-eolpos)));
+ const size_t newpos = s.find( "\n", eolpos );
+ add_item_formatted_string(formatted_string::parse_string(std::string(s, eolpos, newpos-eolpos)));
if ( newpos == std::string::npos )
break;
else
- eolpos = newpos + strlen(EOL);
- }
+ eolpos = newpos + 1;
+ }
+}
+
+void formatted_scroller::add_item_formatted_string(const formatted_string& fs)
+{
+ MenuEntry* me = new MenuEntry;
+ me->data = new formatted_string(fs);
+ add_entry(me);
+}
+
+void formatted_scroller::add_item_string(const std::string& s)
+{
+ add_entry( new MenuEntry(s) );
}
void formatted_scroller::draw_index_item(int index, const MenuEntry *me) const
{
- formatted_string::parse_string(me->text).display();
+ if ( me->data == NULL )
+ Menu::draw_index_item(index, me);
+ else
+ static_cast<formatted_string*>(me->data)->display();
+}
+
+formatted_scroller::~formatted_scroller()
+{
+ // very important: this destructor is called *before* the
+ // base (Menu) class destructor...which is at it should be.
+ for ( unsigned i = 0; i < items.size(); ++i )
+ if ( items[i]->data != NULL )
+ delete static_cast<formatted_string*>(items[i]->data);
}
int linebreak_string( std::string& s, int wrapcol, int maxcol )
@@ -1323,14 +1352,14 @@ int linebreak_string( std::string& s, int wrapcol, int maxcol )
// soft linebreak
else if ( s[loc] == ' ' && xpos > wrapcol )
{
- s.replace(loc, 1, EOL);
+ s.replace(loc, 1, "\n");
xpos = 0;
++breakcount;
}
// hard linebreak
else if ( xpos > maxcol )
{
- s.insert(loc, EOL);
+ s.insert(loc, "\n");
xpos = 0;
++breakcount;
}
diff --git a/crawl-ref/source/menu.h b/crawl-ref/source/menu.h
index 7ab4e3bc0e..c920078b14 100644
--- a/crawl-ref/source/menu.h
+++ b/crawl-ref/source/menu.h
@@ -417,7 +417,12 @@ private:
class formatted_scroller : public Menu
{
public:
+ formatted_scroller() {}
formatted_scroller(int flags, const std::string& s);
+ virtual void add_item_formatted_string(const formatted_string& s);
+ virtual void add_item_string(const std::string& s);
+ virtual void add_text(const std::string& s);
+ virtual ~formatted_scroller();
protected:
virtual void draw_index_item(int index, const MenuEntry* me) const;
};
diff --git a/crawl-ref/source/notes.cc b/crawl-ref/source/notes.cc
index 0af29ec998..75880e47f3 100644
--- a/crawl-ref/source/notes.cc
+++ b/crawl-ref/source/notes.cc
@@ -226,102 +226,118 @@ const char* number_to_ordinal( int number ) {
return ordinals[number-1];
}
-std::string describe_note( const Note& note ) {
- char buf[200], buf2[50];
-
- switch ( note.type ) {
- case NOTE_HP_CHANGE:
- // [ds] Shortened HP change note from "Had X hitpoints" to accommodate
- // the cause for the loss of hitpoints.
- snprintf(buf, sizeof buf, "HP: %d/%d [%s]",
- note.first, note.second, note.name.c_str());
- break;
- case NOTE_MP_CHANGE:
- snprintf(buf, sizeof buf, "Mana: %d/%d", note.first, note.second);
- break;
- case NOTE_MAXHP_CHANGE:
- snprintf(buf, sizeof buf, "Reached %d max hit points", note.first);
- break;
- case NOTE_MAXMP_CHANGE:
- snprintf(buf, sizeof buf, "Reached %d max mana", note.first);
- break;
- case NOTE_XP_LEVEL_CHANGE:
- snprintf(buf, sizeof buf, "Reached XP level %d. %s", note.first,
- note.name.c_str());
- break;
- case NOTE_DUNGEON_LEVEL_CHANGE:
- snprintf(buf, sizeof buf, "Entered %s",
- place_name(note.packed_place, true, true).c_str());
- break;
- case NOTE_LEARN_SPELL:
- snprintf(buf, sizeof buf, "Learned a level %d spell: %s",
- spell_difficulty(note.first), spell_title(note.first));
- break;
- case NOTE_GET_GOD:
- snprintf(buf, sizeof buf, "Became a worshipper of %s",
- god_name(note.first, true));
- break;
- case NOTE_LOSE_GOD:
- snprintf(buf, sizeof buf, "Fell from the grace of %s",
- god_name(note.first));
- break;
- case NOTE_GOD_GIFT:
- snprintf(buf, sizeof buf, "Received a gift from %s",
- god_name(note.first));
- break;
- case NOTE_ID_ITEM:
- if (note.desc.length() > 0)
- snprintf(buf, sizeof buf, "Identified %s (%s)", note.name.c_str(),
- note.desc.c_str());
- else
- snprintf(buf, sizeof buf, "Identified %s", note.name.c_str());
- break;
- case NOTE_GET_ITEM:
- snprintf(buf, sizeof buf, "Got %s", note.name.c_str());
- break;
- case NOTE_GAIN_SKILL:
- snprintf(buf, sizeof buf, "Reached skill %d in %s",
- note.second, skill_name(note.first));
- break;
- case NOTE_SEEN_MONSTER:
- snprintf(buf, sizeof buf, "Noticed %s", note.name.c_str() );
- break;
- case NOTE_KILL_MONSTER:
- snprintf(buf, sizeof buf, "Defeated %s", note.name.c_str());
- break;
- case NOTE_POLY_MONSTER:
- snprintf(buf, sizeof buf, "%s changed form", note.name.c_str() );
- break;
- case NOTE_GOD_POWER:
- snprintf(buf, sizeof buf, "Acquired %s's %s power",
- god_name(note.first),
- number_to_ordinal(real_god_power(note.first, note.second)+1));
- break;
- case NOTE_GET_MUTATION:
- snprintf(buf, sizeof buf, "Gained mutation: %s",
- mutation_name(note.first, note.second == 0 ? 1 : note.second));
- break;
- case NOTE_LOSE_MUTATION:
- snprintf(buf, sizeof buf, "Lost mutation: %s",
- mutation_name(note.first,
- note.second == 3 ? 3 : note.second+1));
- break;
- case NOTE_USER_NOTE:
- snprintf(buf, sizeof buf, "%s", note.name.c_str());
- break;
- case NOTE_MESSAGE:
- snprintf(buf, sizeof buf, "%s", note.name.c_str());
- break;
- default:
- snprintf(buf, sizeof buf, "Buggy note description: unknown note type");
- break;
+std::string Note::describe( bool when, bool where, bool what ) const {
+
+ std::string result;
+
+ if ( when )
+ {
+ char buf[20];
+ snprintf(buf, sizeof buf, "| %5ld ", turn );
+ result += buf;
+ }
+ if ( where )
+ {
+ result += "| ";
+ std::string placename = short_place_name(packed_place);
+ while ( placename.length() < 7 )
+ placename += ' ';
+ result += placename;
+ result += " | ";
+ }
+ if ( what )
+ {
+ char buf[200];
+ switch ( type ) {
+ case NOTE_HP_CHANGE:
+ // [ds] Shortened HP change note from "Had X hitpoints" to
+ // accommodate the cause for the loss of hitpoints.
+ snprintf(buf, sizeof buf, "HP: %d/%d [%s]",
+ first, second, name.c_str());
+ break;
+ case NOTE_MP_CHANGE:
+ snprintf(buf, sizeof buf, "Mana: %d/%d", first, second);
+ break;
+ case NOTE_MAXHP_CHANGE:
+ snprintf(buf, sizeof buf, "Reached %d max hit points", first);
+ break;
+ case NOTE_MAXMP_CHANGE:
+ snprintf(buf, sizeof buf, "Reached %d max mana", first);
+ break;
+ case NOTE_XP_LEVEL_CHANGE:
+ snprintf(buf, sizeof buf, "Reached XP level %d. %s", first,
+ name.c_str());
+ break;
+ case NOTE_DUNGEON_LEVEL_CHANGE:
+ snprintf(buf, sizeof buf, "Entered %s",
+ place_name(packed_place, true, true).c_str());
+ break;
+ case NOTE_LEARN_SPELL:
+ snprintf(buf, sizeof buf, "Learned a level %d spell: %s",
+ spell_difficulty(first), spell_title(first));
+ break;
+ case NOTE_GET_GOD:
+ snprintf(buf, sizeof buf, "Became a worshipper of %s",
+ god_name(first, true));
+ break;
+ case NOTE_LOSE_GOD:
+ snprintf(buf, sizeof buf, "Fell from the grace of %s",
+ god_name(first));
+ break;
+ case NOTE_GOD_GIFT:
+ snprintf(buf, sizeof buf, "Received a gift from %s",
+ god_name(first));
+ break;
+ case NOTE_ID_ITEM:
+ if (desc.length() > 0)
+ snprintf(buf, sizeof buf, "Identified %s (%s)",
+ name.c_str(), desc.c_str());
+ else
+ snprintf(buf, sizeof buf, "Identified %s", name.c_str());
+ break;
+ case NOTE_GET_ITEM:
+ snprintf(buf, sizeof buf, "Got %s", name.c_str());
+ break;
+ case NOTE_GAIN_SKILL:
+ snprintf(buf, sizeof buf, "Reached skill %d in %s",
+ second, skill_name(first));
+ break;
+ case NOTE_SEEN_MONSTER:
+ snprintf(buf, sizeof buf, "Noticed %s", name.c_str() );
+ break;
+ case NOTE_KILL_MONSTER:
+ snprintf(buf, sizeof buf, "Defeated %s", name.c_str());
+ break;
+ case NOTE_POLY_MONSTER:
+ snprintf(buf, sizeof buf, "%s changed form", name.c_str() );
+ break;
+ case NOTE_GOD_POWER:
+ snprintf(buf, sizeof buf, "Acquired %s's %s power",
+ god_name(first),
+ number_to_ordinal(real_god_power(first, second)+1));
+ break;
+ case NOTE_GET_MUTATION:
+ snprintf(buf, sizeof buf, "Gained mutation: %s",
+ mutation_name(first, second == 0 ? 1 : second));
+ break;
+ case NOTE_LOSE_MUTATION:
+ snprintf(buf, sizeof buf, "Lost mutation: %s",
+ mutation_name(first, second == 3 ? 3 : second+1));
+ break;
+ case NOTE_USER_NOTE:
+ snprintf(buf, sizeof buf, "%s", name.c_str());
+ break;
+ case NOTE_MESSAGE:
+ snprintf(buf, sizeof buf, "%s", name.c_str());
+ break;
+ default:
+ snprintf(buf, sizeof buf,
+ "Buggy note description: unknown note type");
+ break;
+ }
+ result += buf;
}
- snprintf(buf2, sizeof buf2, "| %5ld | ", note.turn );
- std::string placename = short_place_name(note.packed_place);
- while ( placename.length() < 7 )
- placename += ' ';
- return std::string(buf2) + placename + std::string(" | ") +
- std::string(buf);
+ return result;
}
Note::Note() {
diff --git a/crawl-ref/source/notes.h b/crawl-ref/source/notes.h
index 882fe81250..6a604e485c 100644
--- a/crawl-ref/source/notes.h
+++ b/crawl-ref/source/notes.h
@@ -53,10 +53,11 @@ struct Note {
std::string desc;
void load( FILE* fp );
void save( FILE* fp ) const;
+ std::string describe( bool when = true, bool where = true,
+ bool what = true ) const;
};
extern std::vector<Note> note_list;
-std::string describe_note( const Note& note );
void activate_notes( bool active );
bool notes_are_active();
void take_note( const Note& note );
diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc
index 9d510e9216..728f568452 100644
--- a/crawl-ref/source/output.cc
+++ b/crawl-ref/source/output.cc
@@ -23,6 +23,7 @@
#include "externs.h"
#include "fight.h"
+#include "initfile.h"
#include "itemname.h"
#include "menu.h"
#include "ouch.h"
@@ -551,14 +552,14 @@ void print_stats(void)
#endif
} // end print_stats()
-unsigned char* itosym1(int stat)
+const char* itosym1(int stat)
{
- return (unsigned char*)( (stat >= 1) ? "+ " : ". " );
+ return ( (stat >= 1) ? "+ " : ". " );
}
-unsigned char* itosym3(int stat)
+const char* itosym3(int stat)
{
- return (unsigned char*)( (stat >= 3) ? "+ + +" :
+ return ( (stat >= 3) ? "+ + +" :
(stat == 2) ? "+ + ." :
(stat == 1) ? "+ . ." :
(stat == 0) ? ". . ." :
@@ -600,79 +601,112 @@ int equip_name_to_slot(const char *s)
return -1;
}
-void get_full_detail(char* buffer, bool calc_unid)
-{
-#define CUR_AD &buffer[++lines*45],44
-#define BUF_SIZE 24*3*45
- int lines = -1;
-
- memset(buffer, 0, BUF_SIZE);
+static const char* determine_color_string( int level ) {
+ switch ( level ) {
+ case 3:
+ case 2:
+ return "<lightgreen>";
+ case 1:
+ return "<green>";
+ case -1:
+ return "<red>";
+ case -2:
+ case -3:
+ return "<lightred>";
+ default:
+ return "<lightgrey>";
+ }
+}
- snprintf(CUR_AD, "%s the %s", you.your_name, player_title());
- lines++;
- snprintf(CUR_AD, "Race : %s", species_name(you.species,you.experience_level) );
- snprintf(CUR_AD, "Class : %s", you.class_name);
- snprintf(CUR_AD, "Worship : %s",
- you.religion == GOD_NO_GOD? "" : god_name(you.religion) );
- snprintf(CUR_AD, "Level : %7d", you.experience_level);
- snprintf(CUR_AD, "Exp : %7lu", you.experience);
+std::vector<formatted_string> get_full_detail(bool calc_unid)
+{
+ char buf[1000];
+ // 3 columns, splits at columns 32, 52
+ column_composer cols(3, 32, 52);
+ snprintf(buf, sizeof buf,
+ "<red>%s the %s</red>\n\n"
+ "Race : %s\n"
+ "Class : %s\n"
+ "Worship : %s\n"
+ "Level : %7d\n"
+ "Exp : %7lu\n",
+ you.your_name, player_title(),
+ species_name(you.species,you.experience_level),
+ you.class_name,
+ you.religion == GOD_NO_GOD? "" : god_name(you.religion),
+ you.experience_level,
+ you.experience);
+ cols.add_formatted(0, buf, false);
if (you.experience_level < 27)
{
- int xp_needed = (exp_needed(you.experience_level+2) - you.experience) + 1;
- snprintf(CUR_AD, "Next Level : %7lu", exp_needed(you.experience_level + 2) + 1);
- snprintf(CUR_AD, "Exp Needed : %7d", xp_needed);
+ int xp_needed = (exp_needed(you.experience_level+2)-you.experience)+1;
+ snprintf(buf, sizeof buf,
+ "Next Level : %7lu\n"
+ "Exp Needed : %7d\n",
+ exp_needed(you.experience_level + 2) + 1,
+ xp_needed);
+ cols.add_formatted(0, buf, false);
}
else
- {
- snprintf(CUR_AD, " ");
- snprintf(CUR_AD, " ");
- }
-
- snprintf(CUR_AD, "Spls.Left : %7d", player_spell_levels() );
- snprintf(CUR_AD, "Gold : %7d", you.gold );
-
- lines++;
+ cols.add_formatted(0, "\n\n", false);
+
+ snprintf(buf, sizeof buf,
+ "Spls.Left : %7d\n"
+ "Gold : %7d\n",
+ player_spell_levels(),
+ you.gold);
+ cols.add_formatted(0, buf, false);
if (!player_rotted())
{
if (you.hp < you.hp_max)
- snprintf(CUR_AD, "HP : %3d/%d", you.hp, you.hp_max);
+ snprintf(buf, sizeof buf, "HP : %3d/%d",you.hp,you.hp_max);
else
- snprintf(CUR_AD, "HP : %3d", you.hp);
+ snprintf(buf, sizeof buf, "HP : %3d", you.hp);
}
else
{
- snprintf(CUR_AD, "HP : %3d/%d (%d)",
- you.hp, you.hp_max, you.hp_max + player_rotted() );
+ snprintf(buf, sizeof buf, "HP : %3d/%d (%d)",
+ you.hp, you.hp_max, you.hp_max + player_rotted() );
}
+ cols.add_formatted(0, buf, true);
if (you.magic_points < you.max_magic_points)
- snprintf(CUR_AD, "MP : %3d/%d",
- you.magic_points, you.max_magic_points);
+ snprintf(buf, sizeof buf, "MP : %3d/%d",
+ you.magic_points, you.max_magic_points);
else
- snprintf(CUR_AD, "MP : %3d", you.magic_points);
+ snprintf(buf, sizeof buf, "MP : %3d", you.magic_points);
+ cols.add_formatted(0, buf, false);
if (you.strength == you.max_strength)
- snprintf(CUR_AD, "Str : %3d", you.strength);
+ snprintf(buf, sizeof buf, "Str : %3d", you.strength);
else
- snprintf(CUR_AD, "Str : %3d (%d)",
- you.strength, you.max_strength);
+ snprintf(buf, sizeof buf, "Str : %3d (%d)",
+ you.strength, you.max_strength);
+ cols.add_formatted(0, buf, false);
if (you.intel == you.max_intel)
- snprintf(CUR_AD, "Int : %3d", you.intel);
+ snprintf(buf, sizeof buf, "Int : %3d", you.intel);
else
- snprintf(CUR_AD, "Int : %3d (%d)", you.intel, you.max_intel);
+ snprintf(buf, sizeof buf, "Int : %3d (%d)",
+ you.intel, you.max_intel);
+ cols.add_formatted(0, buf, false);
if (you.dex == you.max_dex)
- snprintf(CUR_AD, "Dex : %3d", you.dex);
+ snprintf(buf, sizeof buf, "Dex : %3d", you.dex);
else
- snprintf(CUR_AD, "Dex : %3d (%d)", you.dex, you.max_dex);
-
- snprintf(CUR_AD, "AC : %3d", player_AC() );
- snprintf(CUR_AD, "Evasion : %3d", player_evasion() );
- snprintf(CUR_AD, "Shield : %3d", player_shield_class() );
- lines++;
+ snprintf(buf, sizeof buf, "Dex : %3d (%d)",you.dex,you.max_dex);
+ cols.add_formatted(0, buf, false);
+
+ snprintf(buf, sizeof buf,
+ "AC : %3d\n"
+ "Evasion : %3d\n"
+ "Shield : %3d\n",
+ player_AC(),
+ player_evasion(),
+ player_shield_class());
+ cols.add_formatted(0, buf, false);
if (you.real_time != -1)
{
@@ -680,34 +714,47 @@ void get_full_detail(char* buffer, bool calc_unid)
char buff[200];
make_time_string( curr, buff, sizeof(buff), true );
- snprintf(CUR_AD, "Play time : %10s", buff);
- snprintf(CUR_AD, "Turns : %10ld", you.num_turns );
+ snprintf(buf, sizeof buf,
+ "Play time : %10s\n"
+ "Turns : %10ld\n",
+ buff, you.num_turns );
+ cols.add_formatted(0, buf, true);
}
- lines = 24 + 1;
-
- snprintf(CUR_AD, "Res.Fire : %s",
- itosym3( player_res_fire(calc_unid) ) );
- snprintf(CUR_AD, "Res.Cold : %s",
- itosym3( player_res_cold(calc_unid) ) );
- snprintf(CUR_AD, "Life Prot.: %s",
- itosym3( player_prot_life(calc_unid) ) );
- snprintf(CUR_AD, "Res.Poison: %s",
- itosym1( player_res_poison(calc_unid) ) );
- snprintf(CUR_AD, "Res.Elec. : %s",
- itosym1( player_res_electricity(calc_unid) ) );
- lines++;
-
- snprintf(CUR_AD, "Sust.Abil.: %s",
- itosym1( player_sust_abil(calc_unid) ) );
- snprintf(CUR_AD, "Res.Mut. : %s",
- itosym1( wearing_amulet( AMU_RESIST_MUTATION, calc_unid) ) );
- snprintf(CUR_AD, "Res.Slow : %s",
- itosym1( wearing_amulet( AMU_RESIST_SLOW, calc_unid) ) );
- snprintf(CUR_AD, "Clarity : %s",
- itosym1( wearing_amulet( AMU_CLARITY, calc_unid) ) );
- lines++;
- lines++;
+ const int rfire = player_res_fire(calc_unid);
+ const int rcold = player_res_cold(calc_unid);
+ const int rlife = player_prot_life(calc_unid);
+ const int rpois = player_res_poison(calc_unid);
+ const int relec = player_res_electricity(calc_unid);
+
+ snprintf(buf, sizeof buf, "\n\n"
+ "Res.Fire : %s%s\n"
+ "Res.Cold : %s%s\n"
+ "Life Prot.: %s%s\n"
+ "Res.Poison: %s%s\n"
+ "Res.Elec. : %s%s\n",
+ determine_color_string(rfire), itosym3(rfire),
+ determine_color_string(rcold), itosym3(rcold),
+ determine_color_string(rlife), itosym3(rlife),
+ determine_color_string(rpois), itosym1(rpois),
+ determine_color_string(relec), itosym1(relec));
+ cols.add_formatted(1, buf, false);
+
+ const int rsust = player_sust_abil(calc_unid);
+ const int rmuta = wearing_amulet(AMU_RESIST_MUTATION, calc_unid);
+ const int rslow = wearing_amulet(AMU_RESIST_SLOW, calc_unid);
+ const int rclar = wearing_amulet(AMU_CLARITY, calc_unid);
+
+ snprintf(buf, sizeof buf,
+ "Sust.Abil.: %s%s\n"
+ "Res.Mut. : %s%s\n"
+ "Res.Slow : %s%s\n"
+ "Clarity : %s%s\n \n",
+ determine_color_string(rsust), itosym1(rsust),
+ determine_color_string(rmuta), itosym1(rmuta),
+ determine_color_string(rslow), itosym1(rslow),
+ determine_color_string(rclar), itosym1(rclar));
+ cols.add_formatted(1, buf, true);
{
char str_pass[ITEMNAME_SIZE];
@@ -729,86 +776,116 @@ void get_full_detail(char* buffer, bool calc_unid)
if ( you.equip[ e_order[i] ] != -1)
{
- in_name( you.equip[ e_order[i] ], DESC_PLAIN,
- str_pass, true );
- snprintf(CUR_AD, "%-7s: %s", slot, str_pass);
+ const int inum = you.equip[e_order[i]];
+ in_name( inum, DESC_PLAIN, str_pass, true );
+ str_pass[38] = 0; // truncate
+ const char* colname = colour_to_str(you.inv[inum].colour);
+ snprintf(buf, sizeof buf, "%-7s: <%s>%s</%s>",
+ slot, colname, str_pass, colname);
}
else
{
if (e_order[i] == EQ_WEAPON)
{
if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BLADE_HANDS)
- snprintf(CUR_AD, "%-7s: Blade Hands", slot);
+ snprintf(buf, sizeof buf, "%-7s: Blade Hands", slot);
else if (you.skills[SK_UNARMED_COMBAT])
- snprintf(CUR_AD, "%-7s: Unarmed", slot);
+ snprintf(buf, sizeof buf, "%-7s: Unarmed", slot);
else
- snprintf(CUR_AD, "%-7s:", slot);
+ snprintf(buf, sizeof buf, "%-7s:", slot);
}
else
{
- snprintf(CUR_AD, "%-7s:", slot);
+ snprintf(buf, sizeof buf, "%-7s:", slot);
}
}
+ cols.add_formatted(1, buf, false);
}
}
- lines = 24 * 2 + 1;
- snprintf(CUR_AD, "See Invis. : %s",
- itosym1( player_see_invis(calc_unid) ) );
- snprintf(CUR_AD, "Warding : %s",
- itosym1( wearing_amulet(AMU_WARDING, calc_unid)
- || (you.religion == GOD_VEHUMET &&
- you.duration[DUR_PRAYER] &&
- !player_under_penance() &&
- you.piety >= 75) ) );
- snprintf(CUR_AD, "Conserve : %s",
- itosym1( wearing_amulet( AMU_CONSERVATION, calc_unid) ) );
- snprintf(CUR_AD, "Res.Corr. : %s",
- itosym1( wearing_amulet( AMU_RESIST_CORROSION, calc_unid) ) );
-
- if ( !wearing_amulet( AMU_THE_GOURMAND, calc_unid) )
+ const int rinvi = player_see_invis(calc_unid);
+ const int rward = wearing_amulet(AMU_WARDING, calc_unid) ||
+ (you.religion == GOD_VEHUMET && you.duration[DUR_PRAYER] &&
+ !player_under_penance() && you.piety >= 75);
+ const int rcons = wearing_amulet(AMU_CONSERVATION, calc_unid);
+ const int rcorr = wearing_amulet(AMU_RESIST_CORROSION, calc_unid);
+
+ snprintf(buf, sizeof buf, "\n\n"
+ "See Invis. : %s%s\n"
+ "Warding : %s%s\n"
+ "Conserve : %s%s\n"
+ "Res.Corr. : %s%s\n",
+ determine_color_string(rinvi), itosym1(rinvi),
+ determine_color_string(rward), itosym1(rward),
+ determine_color_string(rcons), itosym1(rcons),
+ determine_color_string(rcorr), itosym1(rcorr));
+ cols.add_formatted(2, buf, false);
+
+ int saplevel = 0;
+ switch (you.species)
+ {
+ case SP_GHOUL:
+ saplevel = 3;
+ snprintf(buf, sizeof buf, "Saprovore : %s%s",
+ determine_color_string(3), itosym3(3) );
+ break;
+
+ case SP_KOBOLD:
+ case SP_TROLL:
+ saplevel = 2;
+ snprintf(buf, sizeof buf, "Saprovore : %s%s",
+ determine_color_string(2), itosym3(2) );
+ break;
+
+ case SP_HILL_ORC:
+ case SP_OGRE:
+ saplevel = 1;
+ break;
+ default:
+ saplevel = 0;
+ break;
+ }
+ const char* pregourmand;
+ const char* postgourmand;
+ if ( wearing_amulet(AMU_THE_GOURMAND, calc_unid) )
{
- switch (you.species)
- {
- case SP_GHOUL:
- snprintf(CUR_AD, "Saprovore : %s", itosym3(3) );
- break;
-
- case SP_KOBOLD:
- case SP_TROLL:
- snprintf(CUR_AD, "Saprovore : %s", itosym3(2) );
- break;
-
- case SP_HILL_ORC:
- case SP_OGRE:
- snprintf(CUR_AD, "Saprovore : %s", itosym3(1) );
- break;
-
- default:
- snprintf(CUR_AD, "Gourmand : %s", itosym1(0) );
- break;
- }
+ pregourmand = "Gourmand : ";
+ postgourmand = itosym1(1);
+ saplevel = 1;
}
else
{
- snprintf(CUR_AD, "Gourmand : %s",
- itosym1( wearing_amulet( AMU_THE_GOURMAND, calc_unid) ) );
+ pregourmand = "Saprovore : ";
+ postgourmand = itosym3(saplevel);
}
-
- lines++;
+ snprintf(buf, sizeof buf, "%s%s%s", pregourmand,
+ determine_color_string(saplevel), postgourmand);
+ cols.add_formatted(2, buf, false);
+
+ cols.add_formatted(2, " \n", false);
if ( scan_randarts(RAP_PREVENT_TELEPORTATION, calc_unid) )
- snprintf(CUR_AD, "Prev.Telep.: %s",
- itosym1( scan_randarts(RAP_PREVENT_TELEPORTATION, calc_unid) ) );
+ snprintf(buf, sizeof buf, "Prev.Telep.: %s%s",
+ determine_color_string(-1), itosym1(1));
else
- snprintf(CUR_AD, "Rnd.Telep. : %s",
- itosym1( player_teleport(calc_unid) ) );
- snprintf(CUR_AD, "Ctrl.Telep.: %s",
- itosym1( player_control_teleport(calc_unid) ) );
- snprintf(CUR_AD, "Levitation : %s", itosym1( player_is_levitating() ) );
- snprintf(CUR_AD, "Ctrl.Flight: %s",
- itosym1( wearing_amulet(AMU_CONTROLLED_FLIGHT, calc_unid) ) );
- lines++;
-
- return;
+ {
+ const int rrtel = player_teleport(calc_unid);
+ snprintf(buf, sizeof buf, "Rnd.Telep. : %s%s",
+ determine_color_string(rrtel), itosym1(rrtel));
+ }
+ cols.add_formatted(2, buf, false);
+
+ const int rctel = player_control_teleport(calc_unid);
+ const int rlevi = player_is_levitating();
+ const int rcfli = wearing_amulet(AMU_CONTROLLED_FLIGHT, calc_unid);
+ snprintf(buf, sizeof buf,
+ "Ctrl.Telep.: %s%s\n"
+ "Levitation : %s%s\n"
+ "Ctrl.Flight: %s%s\n",
+ determine_color_string(rctel), itosym1(rctel),
+ determine_color_string(rlevi), itosym1(rlevi),
+ determine_color_string(rcfli), itosym1(rcfli));
+ cols.add_formatted(2, buf, false);
+
+ return cols.formatted_lines();
}
diff --git a/crawl-ref/source/output.h b/crawl-ref/source/output.h
index 3025c8899d..685216d502 100644
--- a/crawl-ref/source/output.h
+++ b/crawl-ref/source/output.h
@@ -14,6 +14,8 @@
#ifndef OUTPUT_H
#define OUTPUT_H
+#include "menu.h"
+
// last updated 12may2000 {dlb}
/* ***********************************************************************
* called from: acr - player - stuff
@@ -23,7 +25,7 @@ void print_stats(void);
/* ***********************************************************************
* called from: chardump
* *********************************************************************** */
-void get_full_detail(char* buffer, bool calc_unid);
+std::vector<formatted_string> get_full_detail(bool calc_unid);
const char *equip_slot_to_name(int equip);
diff --git a/crawl-ref/source/overmap.cc b/crawl-ref/source/overmap.cc
index 707d1c4eba..6e4c250dbc 100644
--- a/crawl-ref/source/overmap.cc
+++ b/crawl-ref/source/overmap.cc
@@ -127,7 +127,7 @@ void display_overmap()
BRANCH_HALL_OF_ZOT
};
- disp += " <white>Overview of the Dungeon</white>" EOL;
+ disp += " <white>Overview of the Dungeon</white>\n" ;
// print branches
int branchcount = 0;
@@ -138,7 +138,7 @@ void display_overmap()
{
if ( !branchcount )
{
- disp += EOL "<white>Branches:</white>" EOL;
+ disp += "\n<white>Branches:</white>\n";
seen_anything = true;
}
@@ -149,19 +149,19 @@ void display_overmap()
stair_level[branch].describe(false, true).c_str());
disp += buffer;
if ( (branchcount % 4) == 0 )
- disp += EOL;
+ disp += "\n";
else
disp += " ";
}
}
if ( branchcount && (branchcount % 4) )
- disp += EOL;
+ disp += "\n";
// print altars
// we loop through everything a dozen times, oh well
if ( !altars_present.empty() )
{
- disp += EOL "<white>Altars:</white>" EOL;
+ disp += "\n<white>Altars:</white>\n";
seen_anything = true;
}
@@ -201,13 +201,13 @@ void display_overmap()
}
}
if ( last_id.depth != 10000 )
- disp += EOL;
+ disp += "\n";
}
// print shops
if (!shops_present.empty())
{
- disp += EOL "<white>Shops:</white>" EOL;
+ disp += "\n<white>Shops:</white>\n";
seen_anything = true;
}
last_id.depth = 10000;
@@ -225,7 +225,7 @@ void display_overmap()
// the level name, plus 4 for the spacing; that makes
// a total of 16 chars per shop or exactly 5 per line.
if ( placecount % 5 == 0 )
- disp += EOL;
+ disp += "\n";
else
disp += " ";
}
@@ -238,12 +238,12 @@ void display_overmap()
}
disp += shoptype_to_char(ci_shops->second);
}
- disp += EOL;
+ disp += "\n";
// print portals
if ( !portals_present.empty() )
{
- disp += EOL "<white>Portals:</white>" EOL;
+ disp += "\n<white>Portals:</white>\n";
seen_anything = true;
}
for (int cur_portal = PORTAL_NONE; cur_portal < NUM_PORTALS; ++cur_portal)
@@ -273,7 +273,7 @@ void display_overmap()
}
}
if ( last_id.depth != 10000 )
- disp += EOL;
+ disp += "\n";
}
if (!seen_anything)