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

Method PutStr

win/Qt/qt_msg.cpp:111–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111void NetHackQtMessageWindow::PutStr(int attr, const QString& text)
112{
113 changed=true;
114
115 // If the line is output from the "/" command, map the first character
116 // as a symbol
117 QString text2;
118 if (text.mid(1, 3) == " ") {
119 text2 = QChar(cp437(text.at(0).unicode())) + text.mid(1);
120 } else {
121 text2 = text;
122 }
123
124#if 0
125 if (attr != ATR_NONE) {
126 QListWidgetItem *item = new QListWidgetItem(text2);
127 if (attr != ATR_DIM && attr != ATR_INVERSE) {
128 QFont font = item->font();
129 font.setUnderline(attr == ATR_ULINE);
130 font.setWeight((attr == ATR_BOLD) ? QFont::Bold : QFont::Normal);
131 item->setFont(font);
132 // ATR_BLINK not supported
133 } else {
134 // ATR_DIM or ATR_INVERSE
135 QBrush fg = item->foreground();
136 QBrush bg = item->background();
137 if (fg.color() == bg.color()) { // from menu coloring [AddRow()]
138 // default foreground and background come up the same for
139 // some unknown reason
140 //[pr: both are set to 'Qt::color1' which has same RGB
141 // value as 'Qt::black'; X11 on OSX behaves similarly]
142 if (fg.color() == Qt::color1) {
143 fg = Qt::black;
144 bg = Qt::white;
145 } else {
146 fg = (bg.color() == Qt::white) ? Qt::black : Qt::white;
147 }
148 }
149 if (attr == ATR_DIM) {
150 QColor fg_clr = fg.color();
151 fg_clr.setAlpha(fg_clr.alpha() / 2);
152 item->setFlags(Qt::NoItemFlags);
153 } else if (attr == ATR_INVERSE) {
154 QBrush swapfb;
155 swapfb = fg; fg = bg; bg = swapfb;
156 }
157 item->setForeground(fg);
158 item->setBackground(bg);
159 }
160 }
161#else
162 nhUse(attr);
163#endif
164
165 if (list->count() >= (int) ::iflags.msg_history)
166 delete list->item(0);
167 list->addItem(text2);
168 /* assert( list->count() > 0 ); */

Callers

nothing calls this directly

Calls 5

cp437Function · 0.85
countMethod · 0.80
horizontalScrollBarMethod · 0.80
setFontMethod · 0.45
putMessageMethod · 0.45

Tested by

no test coverage detected