37const char*
const kKeys[FontKeyboard::keyTotal] = {
38 "`",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"0",
"-",
"=",
39 "Q",
"W",
"E",
"R",
"T",
"Y",
"U",
"I",
"O",
"P",
"[",
"]",
"\\",
40 "A",
"S",
"D",
"F",
"G",
"H",
"J",
"K",
"L",
";",
"'",
41 "Z",
"X",
"C",
"V",
"B",
"N",
"M",
",",
".",
"/",
75const int kPageLetters[FontKeyboard::keyTotal] = {
76 0, 247, 248, 249, 250, 251, 252, 253, 254, 255, 246, 227, 0,
77 176, 182, 164, 177, 179, 184, 180, 168, 174, 175, 158, 159, 0,
78 160, 178, 163, 165, 166, 167, 169, 170, 171, 157, 224,
79 185, 183, 162, 181, 161, 173, 172, 244, 232, 243,
92const int kPageCaps[FontKeyboard::keyTotal] = {
93 0, 231, 239, 245, 240, 225, 226, 0, 241, 154, 155, 0, 0,
94 144, 150, 132, 145, 147, 152, 148, 136, 142, 143, 0, 0, 0,
95 128, 146, 131, 133, 134, 135, 137, 138, 139, 156, 114,
96 153, 151, 130, 149, 129, 141, 140, 0, 0, 230,
109const int kPageSymbols[FontKeyboard::keyTotal] = {
110 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 116,
111 0, 0, 100, 0, 0, 0, 0, 104, 0, 0, 112, 113, 0,
112 96, 106, 99, 101, 102, 103, 0, 186, 107, 109, 115,
113 0, 0, 98, 105, 97, 0, 108, 242, 117, 0,
120const int kPageCodes[FontKeyboard::keyTotal] = {
121 0, 118, 110, 111, 119, 120, 233, 234, 235, 0, 0, 0, 0,
122 0, 0, 84, 228, 190, 89, 90, 0, 83, 82, 0, 0, 0,
123 0, 189, 187, 86, 94, 93, 92, 74, 188, 0, 0,
124 0, 0, 91, 191, 0, 0, 229, 0, 0, 0,
145const int kPageTiles1[FontKeyboard::keyTotal] = {
146 1, 20, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
147 121, 122, 123, 14, 15, 16, 17, 18, 19, 2, 21, 22, 23,
148 124, 0, 124, 24, 25, 26, 27, 28, 29, 30, 31,
149 125, 122, 126, 32, 33, 34, 35, 237, 238, 236,
153const int kPageTiles2[FontKeyboard::keyTotal] = {
154 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
155 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
156 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
157 77, 0, 0, 0, 0, 0, 0, 0, 0, 0,
164const int kPageTiles3[FontKeyboard::keyTotal] = {
165 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204,
166 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217,
167 218, 219, 220, 221, 222, 223, 0, 0, 0, 0, 0,
168 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
174const int kPageControls[FontKeyboard::keyTotal] = {
175 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
176 0, 0, 80, 88, 0, 0, 0, 0, 0, 73, 0, 0, 0,
177 81, 0, 87, 0, 0, 0, 0, 0, 79, 0, 0,
178 0, 95, 85, 75, 76, 78, 0, 0, 0, 0,
197constexpr int kSpaceInd = 127;
201 "Letters",
"Uppercase",
"Symbols",
"Tiles I",
202 "Codes",
"Tiles II",
"Tiles III",
"Controls",
206 "",
"Shift",
"Ctrl",
"Shift+Ctrl",
207 "Alt",
"Shift+Alt",
"Ctrl+Alt",
"Shift+Ctrl+Alt",
218 "The characters the game itself lets you type into a name.",
219 "The same set, shifted -- capitals and the punctuation above the number row.",
220 "Bold letters and the extra marks: accents, quotes, dots.",
221 "Tiles from the loaded tileset. Q W E / A D / Z X C draws a box.",
222 "One byte, many characters: names pulled from memory, and words the game spells out for you.",
223 "The rest of the loaded tileset -- these change as you play.",
224 "Usually blank: these only hold anything in certain game states.",
225 "Text-engine codes. These do not print -- they END, WRAP or PAUSE the text, and in a name they glitch it.",
231const char*
const kNaturalPlain[] = {
232 "`",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"0",
"-",
"=",
233 "[",
"]",
"\\",
";",
"'",
",",
".",
"/",
235const char*
const kNaturalShift[] = {
236 "~",
"!",
"@",
"#",
"$",
"%",
"^",
"&",
"*",
"(",
")",
"_",
"+",
237 "{",
"}",
"|",
":",
"\"",
"<",
">",
"?",
239constexpr int kNaturalCount = 21;
274int FontKeyboard::getPage()
const
279void FontKeyboard::setPage(
int val)
281 if(val < 0 || val >=
pageTotal || val == page)
288QStringList FontKeyboard::getPageNames()
const
294 ret.append(QString(kPageNames[i]));
299int FontKeyboard::getPageCount()
const
304QVariantList FontKeyboard::getPageOrder()
const
310 ret.append(kPageOrder[i]);
315QStringList FontKeyboard::keyLabels()
318 ret.reserve(keyTotal);
320 for(
int i = 0; i < keyTotal; i++)
321 ret.append(QString(kKeys[i]));
326int FontKeyboard::pageFor(
bool shift,
bool ctrl,
bool alt)
328 return (shift ? 1 : 0) | (ctrl ? 2 : 0) | (alt ? 4 : 0);
336 return QString(kPageBadges[page]);
363 return pageFor(shift, ctrl, alt);
365 return pageFor(shift != caps,
false,
false);
369 bool shift,
bool ctrl,
bool alt,
bool caps)
const
379 const QString wanted = key.toUpper();
381 for(
int i = 0; i < keyTotal; i++) {
382 if(wanted != QString(kKeys[i]))
385 return kPages[page][i];
393 if(key.size() == 1) {
394 const QChar c = key.at(0);
396 return shift ? key.toUpper() : key.toLower();
399 for(
int i = 0; i < kNaturalCount; i++) {
400 if(key != QString(kNaturalPlain[i]))
403 return QString(shift ? kNaturalShift[i] : kNaturalPlain[i]);
414 return QString(kPageDescs[page]);
419 return dataForInd(
indFor(page, key), key.toUpper(), page);
424 return dataForInd(kSpaceInd, QStringLiteral(
"Space"), 0);
427QVariantMap FontKeyboard::dataForInd(
int ind,
const QString& key,
int page)
const
439 const bool chorded = (page & 2) || (page & 4);
440 const QString natural = chorded
453 ret[
"code"] = QString();
454 ret[
"title"] = QString();
455 ret[
"tip"] = QString();
456 ret[
"category"] =
static_cast<int>(
CatNone);
458 ret[
"natural"] =
false;
462 const QString alias = f->
getAlias();
464 ret[
"empty"] =
false;
466 ret[
"title"] = (alias !=
"") ? alias : f->getName();
468 ret[
"category"] =
static_cast<int>(categoryOf(f));
469 ret[
"render"] =
static_cast<int>(renderOf(f));
481 if(bare.startsWith(
'<') && bare.endsWith(
'>'))
482 bare = bare.mid(1, bare.size() - 2);
484 const bool sameLetter = (bare.size() == 1)
485 && (bare.compare(key, Qt::CaseInsensitive) == 0);
487 ret[
"natural"] = (!natural.isEmpty() && natural == f->
getName()) || sameLetter;
500 if(str.endsWith(
'>')) {
501 const int open = str.lastIndexOf(
'<');
503 return str.left(open);
506 return str.left(str.size() - 1);
static QString pageDescription(int page)
The quiet line under the deck saying what this page is.
static int indFor(int page, const QString &key)
The font code on key of page, or 0 when that key is empty.
static QString chopLastToken(const QString &str)
Drop the last whole token off a code string – "RED<player>" -> "RED".
static int effectivePage(bool shift, bool ctrl, bool alt, bool caps)
Assignable keys per page: 26 letters + 10 digits + the 11 punctuation keys ( - = [ ] \ ; ' ,...
Render
< Current page = its modifier mask, 0-7.
@ RenderEmpty
No tile on this key.
@ RenderLabel
Control code: no glyph at all, so the cap shows its name.
@ RenderTile
A single 8x8 tile, clipped from the shared animated sheet.
@ RenderPreview
Multi-char/variable: render the expanded text (<poke> -> "Poke").
QVariantMap keyDataFor(const QString &key, bool shift, bool ctrl, bool alt, bool caps) const
keyData() for the page this key actually reads. What the deck binds to.
Category
Tile category. Order matches the old filter strip = the usage order.
protected::void pageChanged()
FontKeyboard(QObject *parent=nullptr)
static QString naturalChar(const QString &key, bool shift)
What a REAL keyboard (US layout) types for key with/without Shift – "a"/"A", "1"/"!...
static constexpr int pageTotal
Modifier combos: none/S/C/A/SC/SA/CA/SCA.
QVariantMap spaceData() const
The same map for the spacebar (the Space tile lives there, not on a letter).
static QString pageBadge(int page)
The modifier badge for a page, e.g. "" / "Shift" / "Ctrl+Alt".
QVariantMap keyData(int page, const QString &key) const
Everything a keycap needs: { ind, code, title, tip, category, render, empty, natural }...
static FontsDB * inst()
< Number of font glyphs.
const FontDBEntry * getStoreByVal(int ind) const
Glyph by its font-code value.
One in-game font character: its code, output text, and classification flags.
const QString getTip() const
const QString getName() const
bool getSingleChar() const
bool getMultiChar() const
const QString getAlias() const