Modding talk:Code page 437

From Caves of Qud Wiki
Revision as of 22:29, 14 July 2019 by Egocarib (talk | contribs) (Created page with "You can use this code to draw all the symbols from the Code Page 437 table in-game. (You'll have to call it from your own function somewhere). <syntaxhighlight lang="c#">...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

You can use this code to draw all the symbols from the Code Page 437 table in-game. (You'll have to call it from your own function somewhere).

        public void DebugDrawSymbolsForFun()
        {
            ScreenBuffer scrapBuffer = ScreenBuffer.GetScrapBuffer2(true);
            for (int i = 0; i <= 79; i++)
            {
                for (int j = 0; j <= 24; j++)
                {
                    if (i > 31 && i <= 47 && j > 4 && j <= 20)
                    {
                        string val1 = (i - 32).ToString("X");
                        string val2 = (j - 5).ToString("X");

                        string codePoint = "00" + val2 + val1;

                        int code = int.Parse(codePoint, System.Globalization.NumberStyles.HexNumber);
                        string unicodeString = char.ConvertFromUtf32(code);

                        scrapBuffer.Goto(i, j);
                        scrapBuffer.Write("&Y^k" + unicodeString[0]);
                    }
                    else
                    {
                        scrapBuffer.Goto(i, j);
                        scrapBuffer.Write("&y^k ");
                    }
                }
            }
            Popup._TextConsole.DrawBuffer(scrapBuffer, null, false);
        }