MCPcopy Index your code
hub / github.com/NetHack/NetHack / AddMenu

Method AddMenu

win/Qt/qt_menu.cpp:261–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259}
260
261void NetHackQtMenuWindow::AddMenu(int glyph, const ANY_P *identifier,
262 char ch, char gch, int attr, int clr,
263 const QString& str, unsigned itemflags)
264{
265 bool presel = (itemflags & MENU_ITEMFLAGS_SELECTED) != 0;
266 if (!ch && identifier->a_void!=0) {
267 // Supply a keyboard accelerator. Limited supply.
268 static char accel[]
269 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
270 if (accel[next_accel]) {
271 ch=accel[next_accel++];
272 }
273 }
274
275 if ((int)itemlist.size() < itemcount+1) {
276 itemlist.resize(itemcount*4+10);
277 }
278 itemlist[itemcount].glyph = glyph;
279 itemlist[itemcount].identifier = *identifier;
280 itemlist[itemcount].ch = ch;
281 itemlist[itemcount].gch = gch;
282 itemlist[itemcount].attr = attr;
283 itemlist[itemcount].color = clr;
284 itemlist[itemcount].str = str;
285 itemlist[itemcount].selected = itemlist[itemcount].preselected = presel;
286 itemlist[itemcount].itemflags = itemflags;
287 itemlist[itemcount].count = -1L;
288 // Display the boulder symbol correctly
289 if (str.left(8) == "boulder\t") {
290 int bracket = str.indexOf('[');
291 if (bracket != -1) {
292 itemlist[itemcount].str = str.left(bracket+1)
293 + QChar(cp437(str.at(bracket+1).unicode()))
294 + str.mid(bracket+2);
295 }
296 }
297 ++itemcount;
298
299 if (glyph != NO_GLYPH)
300 has_glyphs = true;
301}
302
303void NetHackQtMenuWindow::EndMenu(const QString& p)
304{

Callers

nothing calls this directly

Calls 1

cp437Function · 0.85

Tested by

no test coverage detected