Modding talk:Code page 437: Difference between revisions

From Caves of Qud Wiki
Jump to navigation Jump to search
(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#">...")
 
imported>Teamtotobot
m (Teamtotobot moved page [[Talk:Modding: Code page 437]] to Talk:Modding/Code page 437: Bot: Moved page)
(No difference)

Revision as of 14:31, 22 September 2019

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);
        }