summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-07-01 23:28:27 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-07-01 23:28:27 +0000
commitf4fe0980660963ebfd05d86ca9c6b7df0e03940a (patch)
treecf14e0af215c2dd9343df6ae0fc95ddce2becb21
parent995e35a5faf111223e24caeecc97c47cfe050e5a (diff)
downloadcrawl-ref-f4fe0980660963ebfd05d86ca9c6b7df0e03940a.tar.gz
crawl-ref-f4fe0980660963ebfd05d86ca9c6b7df0e03940a.zip
Add player icons (default species/job tile) to the selection menu for
saved games. Bugs/issues: * cannot handle more lines than fit the screen [*] * does not show actual equipment * probably should respect dolls.txt settings I guess the equipment problem could be solved by yet another per-character save file similar to dolls.txt, so newgame.cc could read directly from this rather than have to open the save to calculate equipment tiles or any such insanity. *) presumably because maxpagesize() assumes the entire screen is available for use by the menu git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10083 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/menu.cc98
-rw-r--r--crawl-ref/source/menu.h12
-rw-r--r--crawl-ref/source/newgame.cc45
-rw-r--r--crawl-ref/source/player.cc4
-rw-r--r--crawl-ref/source/tilereg.cc4
5 files changed, 130 insertions, 33 deletions
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index cfc4ab768b..431ede02a6 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -18,6 +18,7 @@ REVISION("$Rev$");
#ifdef USE_TILE
#include "monstuff.h"
#include "mon-util.h"
+ #include "newgame.h"
#endif
#include "player.h"
#ifdef USE_TILE
@@ -710,14 +711,16 @@ void Menu::select_items(int key, int qty)
cgotoxy( x, y );
}
-MonsterMenuEntry::MonsterMenuEntry(const std::string &str, const monsters* mon, int hotkey) :
+MonsterMenuEntry::MonsterMenuEntry(const std::string &str, const monsters* mon,
+ int hotkey) :
MenuEntry(str, MEL_ITEM, 1, hotkey)
{
data = (void*)mon;
quantity = 1;
}
-FeatureMenuEntry::FeatureMenuEntry(const std::string &str, const coord_def p, int hotkey) :
+FeatureMenuEntry::FeatureMenuEntry(const std::string &str, const coord_def p,
+ int hotkey) :
MenuEntry(str, MEL_ITEM, 1, hotkey)
{
pos = p;
@@ -725,6 +728,12 @@ FeatureMenuEntry::FeatureMenuEntry(const std::string &str, const coord_def p, in
}
#ifdef USE_TILE
+PlayerMenuEntry::PlayerMenuEntry(const std::string &str) :
+ MenuEntry(str, MEL_ITEM, 1)
+{
+ quantity = 1;
+}
+
bool MenuEntry::get_tiles(std::vector<tile_def>& tileset) const
{
return (false);
@@ -753,7 +762,6 @@ bool MonsterMenuEntry::get_tiles(std::vector<tile_def>& tileset) const
item_def item = mitm[m->inv[MSLOT_WEAPON]];
tileset.push_back(tile_def(tileidx_item(item), TEX_DEFAULT));
tileset.push_back(tile_def(TILE_ANIMATED_WEAPON, TEX_DEFAULT));
-
}
else if (mons_is_mimic(m->type))
tileset.push_back(tile_def(tileidx_monster_base(m), TEX_DEFAULT));
@@ -832,6 +840,84 @@ bool FeatureMenuEntry::get_tiles(std::vector<tile_def>& tileset) const
return (true);
}
+
+bool PlayerMenuEntry::get_tiles(std::vector<tile_def>& tileset) const
+{
+ if (!Options.tile_menu_icons)
+ return (false);
+
+ const player_save_info &player = *static_cast<player_save_info*>( data );
+
+ dolls_data equip_doll;
+ for (unsigned int j = 0; j < TILEP_PART_MAX; ++j)
+ equip_doll.parts[j] = TILEP_SHOW_EQUIP;
+
+ const int gender = TILEP_GENDER_MALE;
+ tilep_race_default(player.species, gender, player.experience_level,
+ equip_doll.parts);
+
+ int job = get_class_by_name(player.class_name.c_str());
+ if (job == -1)
+ job = JOB_FIGHTER;
+
+ tilep_job_default(job, gender, equip_doll.parts);
+
+ // FIXME: A lot of code duplication from DungeonRegion::pack_doll().
+ int p_order[TILEP_PART_MAX] =
+ {
+ TILEP_PART_SHADOW, // 0
+ TILEP_PART_HALO,
+ TILEP_PART_ENCH,
+ TILEP_PART_DRCWING,
+ TILEP_PART_CLOAK,
+ TILEP_PART_BASE, // 5
+ TILEP_PART_BOOTS,
+ TILEP_PART_LEG,
+ TILEP_PART_BODY,
+ TILEP_PART_ARM,
+ TILEP_PART_HAND1, // 10
+ TILEP_PART_HAND2,
+ TILEP_PART_HAIR,
+ TILEP_PART_BEARD,
+ TILEP_PART_HELM,
+ TILEP_PART_DRCHEAD // 15
+ };
+
+ int flags[TILEP_PART_MAX];
+ tilep_calc_flags(equip_doll.parts, flags);
+
+ // For skirts, boots go under the leg armour. For pants, they go over.
+ if (equip_doll.parts[TILEP_PART_LEG] < TILEP_LEG_SKIRT_OFS)
+ {
+ p_order[6] = TILEP_PART_BOOTS;
+ p_order[7] = TILEP_PART_LEG;
+ }
+
+ for (int i = 0; i < TILEP_PART_MAX; ++i)
+ {
+ const int p = p_order[i];
+ const int idx = equip_doll.parts[p];
+ if (idx == 0 || idx == TILEP_SHOW_EQUIP || flags[p] == TILEP_FLAG_HIDE)
+ continue;
+
+ ASSERT(idx >= TILE_MAIN_MAX && idx < TILEP_PLAYER_MAX);
+
+#if 0
+ // FIXME: Is there any way to make this work with tile_def?
+ int ymax = TILE_Y;
+
+ if (flags[p] == TILEP_FLAG_CUT_CENTAUR
+ || flags[p] == TILEP_FLAG_CUT_NAGA)
+ {
+ ymax = 18;
+ }
+ buf->add(doll.parts[p], x, y, 0, 0, true, ymax);
+#endif
+ tileset.push_back(tile_def(idx, TEX_PLAYER));
+ }
+
+ return (true);
+}
#endif
bool Menu::is_selectable(int item) const
@@ -1073,8 +1159,8 @@ bool Menu::line_up()
/////////////////////////////////////////////////////////////////
// slider_menu
-slider_menu::slider_menu(int fl)
- : Menu(fl), less(), starty(1), endy(get_number_of_lines()),
+slider_menu::slider_menu(int fl, bool text_only)
+ : Menu(fl, "", text_only), less(), starty(1), endy(get_number_of_lines()),
selected(0), need_less(true), need_more(true), oldselect(0),
lastkey(0), search()
{
@@ -1352,9 +1438,7 @@ void slider_menu::new_selection(int nsel)
if (!is_set(MF_NOWRAP))
{
do
- {
nsel += items.size();
- }
while ( nsel < 0 );
}
else
diff --git a/crawl-ref/source/menu.h b/crawl-ref/source/menu.h
index 034c5df682..5ad7ed620a 100644
--- a/crawl-ref/source/menu.h
+++ b/crawl-ref/source/menu.h
@@ -172,6 +172,16 @@ public:
#endif
};
+#ifdef USE_TILE
+class PlayerMenuEntry : public MenuEntry
+{
+public:
+ PlayerMenuEntry(const std::string &str);
+
+ virtual bool get_tiles(std::vector<tile_def>& tileset) const;
+};
+#endif
+
class FeatureMenuEntry : public MenuEntry
{
public:
@@ -413,7 +423,7 @@ class slider_menu : public Menu
{
public:
// Multiselect would be awkward to implement.
- slider_menu(int flags = MF_SINGLESELECT | MF_NOWRAP);
+ slider_menu(int flags = MF_SINGLESELECT | MF_NOWRAP, bool text_only = true);
void display();
std::vector<MenuEntry *> show();
diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc
index 54819b1257..3f28c38fe2 100644
--- a/crawl-ref/source/newgame.cc
+++ b/crawl-ref/source/newgame.cc
@@ -3230,7 +3230,7 @@ static void _enter_player_name(bool blankOK)
bool ask_name = true;
char *name = you.your_name;
std::vector<player_save_info> existing_chars;
- slider_menu char_menu;
+ slider_menu char_menu(MF_SINGLESELECT | MF_NOWRAP, false);
if (you.your_name[0] != 0)
ask_name = false;
@@ -3240,29 +3240,32 @@ static void _enter_player_name(bool blankOK)
existing_chars = find_saved_characters();
if (existing_chars.empty())
{
- cgotoxy(1,12);
- formatted_string::parse_string(
- " If you've never been here before, you might want to try out" EOL
- " the Dungeon Crawl tutorial. To do this, press "
- "<white>Ctrl-T</white> on the next" EOL
- " screen.").display();
+ cgotoxy(1,12);
+ formatted_string::parse_string(
+ " If you've never been here before, you might want to try out" EOL
+ " the Dungeon Crawl tutorial. To do this, press "
+ "<white>Ctrl-T</white> on the next" EOL
+ " screen.").display();
}
else
{
- MenuEntry *title = new MenuEntry("Or choose an existing character:");
- title->colour = LIGHTCYAN;
- char_menu.set_title( title );
- for (unsigned int i = 0; i < existing_chars.size(); ++i)
- {
- std::string desc = " " + existing_chars[i].short_desc();
- if (static_cast<int>(desc.length()) >= get_number_of_cols())
- desc = desc.substr(0, get_number_of_cols() - 1);
-
- MenuEntry *me = new MenuEntry(desc);
- me->data = &existing_chars[i];
- char_menu.add_entry(me);
- }
- char_menu.set_flags(MF_NOWRAP | MF_SINGLESELECT);
+ MenuEntry *title = new MenuEntry("Or choose an existing character:");
+ title->colour = LIGHTCYAN;
+ char_menu.set_title( title );
+ for (unsigned int i = 0; i < existing_chars.size(); ++i)
+ {
+ std::string desc = " " + existing_chars[i].short_desc();
+ if (static_cast<int>(desc.length()) >= get_number_of_cols())
+ desc = desc.substr(0, get_number_of_cols() - 1);
+
+#ifdef USE_TILE
+ MenuEntry *me = new PlayerMenuEntry(desc);
+#else
+ MenuEntry *me = new MenuEntry(desc);
+#endif
+ me->data = &existing_chars[i];
+ char_menu.add_entry(me);
+ }
}
}
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index b9c5916f3a..0003c3774f 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -1498,11 +1498,11 @@ int player_res_cold(bool calc_unid, bool temp, bool items)
if (items)
{
- // rings of fire resistance/fire
+ // rings of cold resistance/ice
rc += player_equip( EQ_RINGS, RING_PROTECTION_FROM_COLD, calc_unid );
rc += player_equip( EQ_RINGS, RING_ICE, calc_unid );
- // rings of ice
+ // rings of fire
rc -= player_equip( EQ_RINGS, RING_FIRE, calc_unid );
// Staves
diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc
index 627c6f7259..0bd0c025ac 100644
--- a/crawl-ref/source/tilereg.cc
+++ b/crawl-ref/source/tilereg.cc
@@ -456,7 +456,7 @@ static void _create_random_doll(dolls_data &rdoll)
_fill_doll_part(rdoll, TILEP_PART_BEARD);
}
-void _fill_doll_equipment(dolls_data &result)
+static void _fill_doll_equipment(dolls_data &result)
{
// Main hand.
if (result.parts[TILEP_PART_HAND1] == TILEP_SHOW_EQUIP)
@@ -3009,7 +3009,7 @@ void MenuRegion::place_entries()
int column = 0;
if (!Options.tile_menu_icons)
set_num_columns(1);
- const int max_columns = std::min(2, m_max_columns);
+ const int max_columns = std::min(2, m_max_columns);
const int column_width = mx / max_columns;
int lines = count_linebreaks(m_more);