pmnames mons gender naming plus a window port interface change

add MALE, FEMALE, and gender-neutral names for individual monster species
to the mons array. The gender-neutral name (NEUTRAL) is mandatory, the
MALE and FEMALE versions are not.

replace code uses of the mname field of permonst with one of the three
potentially-available gender-specific names.

consolidate some separate mons entries that differed only by species into a
single mons entry (caveman, cavewoman and priest,priestess etc.)

consolidate several "* lord" and "* queen/* king" monst entries into
their single species, and allow both genders on some where it makes some
sense (there is probably more work and cleanup to come out of this at some
point, and the chosen gender-neutral name variations are not cast in stone
if someone has better suggestions).

related function or macro additions:
    pmname(pm, gender) to get the gender variation of the permonst name. It
    guards against monsters that haven't got anything except NEUTRAL naming
    and falls back to the NEUTRAL version if FEMALE and MALE versions are
    missing.

    Ugender to obtain the current hero gender.
    Mgender(mtmp) to obtain the gender of a monster

While the code can safely refer directly to pmnames[NEUTRAL] safely in the
code because it always exists, the other two (pmnames[MALE] and
pmnames[FEMALE] may not exist so use:
    pmname(ptr, gidx)
      where -ptr is a permonst *
            -gidx is an index into the pmnames array field of the
             permonst struct
pmname() checks for a valid index and checks for null-pointers for
pmnames[MALE] and pmnames[FEMALE], and will fall back to pmnames[NEUTRAL] if
the pointer requested if the requested variation is unavailable, or if the
gidx is out-of-range.

Allow code to specify makemon flags to request female or male (via MM_MALE
and MM_FEMALE flags respectively)to makedefs, since the species alone doesn't
distinguish male/female anymore. Specifying MM_MALE or MM_FEMALE won't
override the pm M2_MALE and M2_FEMALE flags on a mons[] entry.

male and female tiles have been added to win/share/monsters.txt.
The majority are duplicated placeholders except for those that were
separate mons entries before. Perhaps someone will contribute artwork in the
future to make the male and female variations visually distinguishable.

tilemapping via has the MALE tile indexes in the glyph2tile[]
array produced at build time. If a window port has information that the
FEMALE tile is required, it just has to increment the index returned
from the glyph2tile[] array by 1.

statues already preserved gender of the monster through STATUE_FEMALE
and STATUE_MALE, so ensure that pmnames takes that into consideration.

I expect some refinement will be required after broad play-testing puts it to
the test.

    consolidate caveman,cavewoman and priest,priestess monst.c entries etc

This commit will require a bump of editlevel in patchlevel.h because it alters
the index numbers of the monsters due to the consolidation of some. Those
index numbers are saved in some other structures, even though the mons[] array
itself is not part of the savefile.

Window Port Interface Change

Also add a parameter to print_glyph to convey additional information beyond
the glyph to the window ports. Every single window port was calling back to
mapglyph for the information anyway, so just included it in the interface and
produce the information right in the display core.

The mapglyph() function uses will be eliminated, although there are still some
in the code yet to be dealt with.

win32, tty, x11, Qt, msdos window ports have all had adjustments done to
utilize the new parameter instead of calling mapglyph, but some of those
window ports have not been thoroughly tested since the changes.

Interface change additional info:

    print_glyph(window, x, y, glyph, bkglyph, *glyphmod)
            -- Print the glyph at (x,y) on the given window.  Glyphs are
               integers at the interface, mapped to whatever the window-
               port wants (symbol, font, color, attributes, ...there's
               a 1-1 map between glyphs and distinct things on the map).
            -- bkglyph is a background glyph for potential use by some
               graphical or tiled environments to allow the depiction
               to fall against a background consistent with the grid
               around x,y. If bkglyph is NO_GLYPH, then the parameter
               should be ignored (do nothing with it).
                -- glyphmod provides extended information about the glyph
               that window ports can use to enhance the display in
               various ways.
                    unsigned int glyphmod[NUM_GLYPHMOD]
               where:
                    glyphmod[GM_TTYCHAR]  is the text characters associated
                                          with the original NetHack display.

                    glyphmod[GM_FLAGS]    are the special flags that denote
                                          additional information that window
                                          ports can use.

                    glyphmod[GM_COLOR] is the text character
                                       color associated with the original
                                       NetHack display.

Support for including the glyphmod info in the display glyph buffer
alongside the glyph itself was added and is the default operation.
That can be turned off by defining UNBUFFERED_GLYPHMOD at compile time.
With UNBUFFERED_GLYPHMOD operation, a call will be placed to map_glyphmod()
immediately prior to every print_glyph() call.
This commit is contained in:
nhmall
2020-12-26 11:23:23 -05:00
parent 62e6064a54
commit 0c3b9642e4
113 changed files with 9561 additions and 1259 deletions
+3 -2
View File
@@ -474,11 +474,12 @@ void NetHackQtBind::qt_cliparound_window(winid wid, int x, int y)
NetHackQtWindow* window=id_to_window[(int)wid];
window->ClipAround(x,y);
}
void NetHackQtBind::qt_print_glyph(winid wid,XCHAR_P x,XCHAR_P y,int glyph,int bkglyph UNUSED)
void NetHackQtBind::qt_print_glyph(winid wid,XCHAR_P x,XCHAR_P y,int glyph,
int bkglyph UNUSED, unsigned *glyphmod)
{
/* TODO: bkglyph */
NetHackQtWindow* window=id_to_window[(int)wid];
window->PrintGlyph(x,y,glyph);
window->PrintGlyph(x,y,glyph,glyphmod);
}
//void NetHackQtBind::qt_print_glyph_compose(winid wid,xchar x,xchar y,int glyph1, int glyph2)
//{
+1 -1
View File
@@ -64,7 +64,7 @@ public:
static void qt_cliparound(int x, int y);
static void qt_cliparound_window(winid wid, int x, int y);
static void qt_print_glyph(winid wid, XCHAR_P x, XCHAR_P y,
int glyph, int bkglyph);
int glyph, int bkglyph, unsigned int *);
static void qt_raw_print(const char *str);
static void qt_raw_print_bold(const char *str);
static int qt_nhgetch();
+13 -9
View File
@@ -82,30 +82,32 @@ NetHackQtGlyphs::NetHackQtGlyphs()
}
void NetHackQtGlyphs::drawGlyph(QPainter& painter, int glyph, int x, int y,
bool reversed)
bool fem, bool reversed)
{
if (!reversed) {
int tile = glyph2tile[glyph];
if (fem)
++tile;
int px = (tile % tiles_per_row) * width();
int py = tile / tiles_per_row * height();
painter.drawPixmap(x, y, pm, px, py, width(), height());
} else {
// for paper doll; mirrored image for left side of two-handed weapon
painter.drawPixmap(x, y, reversed_pixmap(glyph),
painter.drawPixmap(x, y, reversed_pixmap(glyph, fem),
0, 0, width(), height());
}
}
void NetHackQtGlyphs::drawCell(QPainter& painter, int glyph,
int cellx, int celly)
int cellx, int celly, bool fem)
{
drawGlyph(painter, glyph, cellx * width(), celly * height(), false);
drawGlyph(painter, glyph, cellx * width(), celly * height(), fem, false);
}
void NetHackQtGlyphs::drawBorderedCell(QPainter& painter, int glyph,
int cellx, int celly, int border,
bool reversed)
bool reversed, bool fem)
{
int wd = width(),
ht = height(),
@@ -113,7 +115,7 @@ void NetHackQtGlyphs::drawBorderedCell(QPainter& painter, int glyph,
lox = cellx * (wd + 2),
loy = celly * (ht + 2) + yoffset;
drawGlyph(painter, glyph, lox + 1, loy + 1, reversed);
drawGlyph(painter, glyph, lox + 1, loy + 1, fem, reversed);
#ifdef TEXTCOLOR
if (border != NO_BORDER) {
@@ -164,9 +166,11 @@ void NetHackQtGlyphs::drawBorderedCell(QPainter& painter, int glyph,
}
// mis-named routine to get the pixmap for a particular glyph
QPixmap NetHackQtGlyphs::glyph(int glyphindx)
QPixmap NetHackQtGlyphs::glyph(int glyphindx, bool fem)
{
int tile = glyph2tile[glyphindx];
if (fem)
++tile;
int px = (tile % tiles_per_row) * tilefile_tile_W;
int py = tile / tiles_per_row * tilefile_tile_H;
@@ -175,9 +179,9 @@ QPixmap NetHackQtGlyphs::glyph(int glyphindx)
}
// transpose a glyph's tile horizontally, scaled for use in paper doll
QPixmap NetHackQtGlyphs::reversed_pixmap(int glyphindx)
QPixmap NetHackQtGlyphs::reversed_pixmap(int glyphindx, bool fem)
{
QPixmap pxmp = glyph(glyphindx);
QPixmap pxmp = glyph(glyphindx, fem);
#ifdef ENHANCED_PAPERDOLL
qreal wid = (qreal) pxmp.width(),
//hgt = (qreal) pxmp.height(),
+5 -5
View File
@@ -24,13 +24,13 @@ public:
void setSize(int w, int h);
void drawGlyph(QPainter &, int glyph, int pixelx, int pixely,
bool reversed = false);
void drawCell(QPainter &, int glyph, int cellx, int celly);
bool fem, bool reversed = false);
void drawCell(QPainter &, int glyph, int cellx, int celly, bool fem);
void drawBorderedCell(QPainter &, int glyph,
int cellx, int celly, int bordercode,
bool reversed);
QPixmap glyph(int glyphindx);
QPixmap reversed_pixmap(int glyphindx);
bool reversed, bool fem = false);
QPixmap glyph(int glyphindx, bool fem = false);
QPixmap reversed_pixmap(int glyphindx, bool fem = false);
private:
QImage img;
+53 -12
View File
@@ -176,14 +176,19 @@ void NetHackQtMapViewport::paintEvent(QPaintEvent* event)
for (int j=garea.top(); j<=garea.bottom(); j++) {
for (int i=garea.left(); i<=garea.right(); i++) {
#if 0
unsigned short g=Glyph(i,j);
int color;
int ch;
unsigned special;
#else
int color = Glyphcolor(i,j);
int ch = Glyphttychar(i,j);
unsigned special = Glyphflags(i,j);
#endif
painter.setPen( Qt::green );
/* map glyph to character and color */
mapglyph(g, &ch, &color, &special, i, j, 0);
// mapglyph(g, &ch, &color, &special, i, j, 0);
ch = cp437(ch);
#ifdef TEXTCOLOR
painter.setPen( nhcolor_to_pen(color) );
@@ -220,15 +225,20 @@ void NetHackQtMapViewport::paintEvent(QPaintEvent* event)
}
painter.setFont(font());
} else {
} else { // tiles
for (int j=garea.top(); j<=garea.bottom(); j++) {
for (int i=garea.left(); i<=garea.right(); i++) {
unsigned short g=Glyph(i,j);
#if 0
int color;
int ch;
unsigned special;
mapglyph(g, &ch, &color, &special, i, j, 0);
qt_settings->glyphs().drawCell(painter, g, i, j);
#else
unsigned special = Glyphflags(i, j);
#endif
bool femflag = (special & MG_FEMALE) ? true : false;
qt_settings->glyphs().drawCell(painter, g, i, j, femflag);
#ifdef TEXTCOLOR
if ((special & MG_PET) != 0 && ::iflags.hilite_pet) {
painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(),
@@ -559,8 +569,14 @@ void NetHackQtMapViewport::Clear()
// FIXME: map column 0 should be surpressed from being displayed
//
Glyph(0, j) = GLYPH_NOTHING;
Glyphttychar(0, j) = ' ';
Glyphcolor(0, j) = NO_COLOR;
Glyphflags(0, j) = 0;
for (int i = 1; i < COLNO; ++i)
Glyph(i, j) = GLYPH_UNEXPLORED;
Glyphttychar(0, j) = ' ';
Glyphcolor(0, j) = NO_COLOR;
Glyphflags(0, j) = 0;
}
change.clear();
@@ -594,9 +610,12 @@ void NetHackQtMapViewport::CursorTo(int x,int y)
Changed(cursor.x(),cursor.y());
}
void NetHackQtMapViewport::PrintGlyph(int x,int y,int theglyph)
void NetHackQtMapViewport::PrintGlyph(int x,int y,int theglyph,unsigned *glyphmod)
{
Glyph(x,y)=theglyph;
Glyphttychar(x,y)=glyphmod[GM_TTYCHAR];
Glyphcolor(x,y)=glyphmod[GM_COLOR];
Glyphflags(x,y)=glyphmod[GM_FLAGS];
Changed(x,y);
}
@@ -701,9 +720,9 @@ void NetHackQtMapWindow2::ClipAround(int x,int y)
ensureVisible(x,y,width()*0.45,height()*0.45);
}
void NetHackQtMapWindow2::PrintGlyph(int x,int y,int glyph)
void NetHackQtMapWindow2::PrintGlyph(int x,int y,int glyph, unsigned *glyphmod)
{
m_viewport->PrintGlyph(x, y, glyph);
m_viewport->PrintGlyph(x, y, glyph, glyphmod);
}
#if 0 //RLC
@@ -825,8 +844,15 @@ void NetHackQtMapWindow::Clear()
{
for (int j = 0; j < ROWNO; ++j) {
Glyph(0, j) = GLYPH_NOTHING;
for (int i = 1; i < COLNO; ++i)
Glyphcolor(0, j) = NO_COLOR;
Glyphttychar(0, j) = ' ';
Glyphflags(0, j) = 0;
for (int i = 1; i < COLNO; ++i) {
Glyph(i, j) = GLYPH_UNEXPLORED;
Glyphcolor(i, j) = NO_COLOR;
Glyphttychar(i, j) = ' ';
Glyphflags(i, j) = 0;
}
}
change.clear();
@@ -897,13 +923,18 @@ void NetHackQtMapWindow::paintEvent(QPaintEvent* event)
for (int j=garea.top(); j<=garea.bottom(); j++) {
for (int i=garea.left(); i<=garea.right(); i++) {
unsigned short g=Glyph(i,j);
#if 0
int color;
char32_t ch;
unsigned special;
#else
int color = Glyphcolor(i,j);
char32_t ch = Glyphttychar(i,j);
unsigned special = Glyphflags(i,j);
#endif
painter.setPen( Qt::green );
/* map glyph to character and color */
mapglyph(g, &ch, &color, &special, i, j, 0);
// mapglyph(g, &ch, &color, &special, i, j, 0);
#ifdef TEXTCOLOR
painter.setPen( nhcolor_to_pen(color) );
#endif
@@ -935,11 +966,18 @@ void NetHackQtMapWindow::paintEvent(QPaintEvent* event)
for (int j=garea.top(); j<=garea.bottom(); j++) {
for (int i=garea.left(); i<=garea.right(); i++) {
unsigned short g=Glyph(i,j);
#if 0
int color;
int ch;
unsigned special;
mapglyph(g, &ch, &color, &special, i, j, 0);
qt_settings->glyphs().drawCell(painter, g, i, j);
#else
int color = Glyphcolor(i,j);
int ch = Glyphttychar(i,j);
unsigned special = Glyphflags(i,j);
#endif
bool femflag = (special & MG_FEMALE) ? true : false;
qt_settings->glyphs().drawCell(painter, g, i, j, femflag);
#ifdef TEXTCOLOR
if ((special & MG_PET) != 0 && ::iflags.hilite_pet) {
painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(),
@@ -1048,9 +1086,12 @@ void NetHackQtMapWindow::ClipAround(int x,int y)
viewport.center(x,y,0.45,0.45);
}
void NetHackQtMapWindow::PrintGlyph(int x,int y,int glyph)
void NetHackQtMapWindow::PrintGlyph(int x,int y,int glyph, unsigned *glyphmod)
{
Glyph(x,y)=glyph;
Glyphttychar(x,y)=glyphmod[GM_TTYCHAR];
Glyphcolor(x,y)=glyphmod[GM_COLOR];
Glyphflags(x,y)=glyphmod[GM_FLAGS];
Changed(x,y);
}
+8 -2
View File
@@ -32,6 +32,12 @@ private:
QFont *rogue_font;
unsigned short glyph[ROWNO][COLNO];
unsigned short& Glyph(int x, int y) { return glyph[y][x]; }
unsigned int glyphttychar[ROWNO][COLNO];
unsigned int& Glyphttychar(int x, int y) { return glyphttychar[y][x]; }
unsigned int glyphcolor[ROWNO][COLNO];
unsigned int& Glyphcolor(int x, int y) { return glyphcolor[y][x]; }
unsigned int glyphflags[ROWNO][COLNO];
unsigned int& Glyphflags(int x, int y) { return glyphflags[y][x]; }
QPoint cursor;
QPixmap pet_annotation;
QPixmap pile_annotation;
@@ -42,7 +48,7 @@ private:
void Clear();
void Display(bool block);
void CursorTo(int x,int y);
void PrintGlyph(int x,int y,int glyph);
void PrintGlyph(int x,int y,int glyph,unsigned *glyphmod);
void Changed(int x, int y);
void updateTiles();
@@ -64,7 +70,7 @@ public:
virtual void CursorTo(int x,int y);
virtual void PutStr(int attr, const QString& text);
virtual void ClipAround(int x,int y);
virtual void PrintGlyph(int x,int y,int glyph);
virtual void PrintGlyph(int x,int y,int glyph,unsigned *glyphmod);
signals:
void resized();
+15 -10
View File
@@ -82,14 +82,14 @@ public:
{
}
void setGlyph(int g)
void setGlyph(int g, bool fem)
{
NetHackQtGlyphs& glyphs = qt_settings->glyphs();
int gw = glyphs.width();
int gh = glyphs.height();
QPixmap pm(gw,gh);
QPainter p(&pm);
glyphs.drawGlyph(p, g, 0, 0);
glyphs.drawGlyph(p, g, 0, 0, fem);
p.end();
setIcon(QIcon(pm));
//RLC setHeight(std::max(pm.height()+1,height()));
@@ -124,7 +124,7 @@ public:
#endif
)
{
setGlyph(monnum_to_glyph(roles[id].malenum));
setGlyph(monnum_to_glyph(roles[id].malenum), false);
}
};
@@ -139,7 +139,7 @@ public:
#endif
)
{
setGlyph(monnum_to_glyph(races[id].malenum));
setGlyph(monnum_to_glyph(races[id].malenum), false);
}
};
@@ -257,6 +257,7 @@ NetHackQtPlayerSelector::NetHackQtPlayerSelector(NetHackQtKeyBuffer& ks UNUSED)
chosen_gend = flags.initgend;
chosen_align = flags.initalign;
bool fem = (chosen_gend > ROLE_NONE);
// XXX QListView unsorted goes in rev.
for (nrole=0; roles[nrole].name.m; nrole++)
@@ -264,8 +265,8 @@ NetHackQtPlayerSelector::NetHackQtPlayerSelector(NetHackQtKeyBuffer& ks UNUSED)
role->setRowCount(nrole);
for (i=0; roles[i].name.m; i++) {
QTableWidgetItem *item = new QTableWidgetItem(
QIcon(qt_settings->glyphs().glyph(roles[i].malenum)),
roles[i].name.m);
QIcon(qt_settings->glyphs().glyph(roles[i].malenum, fem)),
roles[i].name.m);
item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
role->setItem(i, 0, item);
}
@@ -280,7 +281,7 @@ NetHackQtPlayerSelector::NetHackQtPlayerSelector(NetHackQtKeyBuffer& ks UNUSED)
race->setRowCount(nrace);
for (i=0; races[i].noun; i++) {
QTableWidgetItem *item = new QTableWidgetItem(
QIcon(qt_settings->glyphs().glyph(races[i].malenum)),
QIcon(qt_settings->glyphs().glyph(races[i].malenum, fem)),
races[i].noun);
item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
race->setItem(i, 0, item);
@@ -290,9 +291,13 @@ NetHackQtPlayerSelector::NetHackQtPlayerSelector(NetHackQtKeyBuffer& ks UNUSED)
race->setHorizontalHeaderLabels(QStringList("Race"));
race->resizeColumnToContents(0);
// TODO: render the alignment and gender labels smaller to match the
// horizontal header labels for role and race; getting the font from
// race table above and setting it for labels below made no difference
// TODO:
// Render the alignment and gender labels smaller to match the
// horizontal header labels for role and race; getting the font from
// race table above and setting it for labels below made no difference.
//
// Maybe, if the order of choosing becomes more dynamic:
// Replace the role and race glyphs when gender gets set.
QLabel *gendlabel = new QLabel("Gender");
genderbox->layout()->addWidget(gendlabel);
+2 -1
View File
@@ -788,7 +788,8 @@ void NetHackQtStatusWindow::updateStats()
if (u.usteed) ++k, ride.show(); else ride.hide();
if (Upolyd) {
buf = nh_capitalize_words(mons[u.umonnum].mname);
buf = nh_capitalize_words(pmname(&mons[u.umonnum],
::flags.female ? FEMALE : MALE));
} else {
buf = rank_of(u.ulevel, g.pl_character[0], ::flags.female);
}
+1 -1
View File
@@ -109,7 +109,7 @@ void NetHackQtWindow::EndMenu(const QString& prompt UNUSED) { puts("unexpected E
int NetHackQtWindow::SelectMenu(int how UNUSED, MENU_ITEM_P **menu_list UNUSED)
{ puts("unexpected SelectMenu"); return 0; }
void NetHackQtWindow::ClipAround(int x UNUSED,int y UNUSED) { puts("unexpected ClipAround"); }
void NetHackQtWindow::PrintGlyph(int x UNUSED,int y UNUSED,int glyph UNUSED) { puts("unexpected PrintGlyph"); }
void NetHackQtWindow::PrintGlyph(int x UNUSED,int y UNUSED,int glyph UNUSED, unsigned *glyphmod UNUSED) { puts("unexpected PrintGlyph"); }
//void NetHackQtWindow::PrintGlyphCompose(int x,int y,int,int) { puts("unexpected PrintGlyphCompose"); }
void NetHackQtWindow::UseRIP(int how UNUSED, time_t when UNUSED) { puts("unexpected UseRIP"); }
+1 -1
View File
@@ -40,7 +40,7 @@ public:
virtual void EndMenu(const QString& prompt);
virtual int SelectMenu(int how, MENU_ITEM_P **menu_list);
virtual void ClipAround(int x, int y);
virtual void PrintGlyph(int x, int y, int glyph);
virtual void PrintGlyph(int x, int y, int glyph, unsigned *glyphmod);
virtual void UseRIP(int how, time_t when);
int nhid;