コード例 #1
0
        private void Form1_KeyUp(object sender, KeyEventArgs e)
        {
            NoxicoGame.KeyMap[e.KeyCode] = false;
            NoxicoGame.KeyTrg[e.KeyCode] = true;
            if (numpad.ContainsKey(e.KeyCode))
            {
                NoxicoGame.KeyMap[numpad[e.KeyCode]] = false;
                NoxicoGame.KeyTrg[numpad[e.KeyCode]] = true;
            }
            if (e.Modifiers == Keys.Shift)
            {
                NoxicoGame.Modifiers[0] = false;
            }

            if (e.KeyCode == (Keys)NoxicoGame.KeyBindings[KeyBinding.Screenshot])
            {
                if (e.Modifiers == Keys.Shift)
                {
                    using (var dumpFile = new StreamWriter("lol.txt", false, System.Text.Encoding.GetEncoding(437)))
                    {
                        for (int row = 0; row < Program.Rows; row++)
                        {
                            for (int col = 0; col < Program.Cols; col++)
                            {
                                dumpFile.Write(NoxicoGame.IngameTo437[image[col, row].Character]);
                            }
                            dumpFile.WriteLine();
                        }
                    }
                    using (var dumpFile = new StreamWriter("lol.html"))
                    {
                        dumpFile.WriteLine("<!DOCTYPE html><html><head>");
                        dumpFile.WriteLine("<meta http-equiv=\"Content-Type\" content=\"text/html; CHARSET=utf-8\" />");
                        dumpFile.WriteLine("</head><body>");
                        dumpFile.WriteLine("<table style=\"font-family: Unifont, monospace\" cellspacing=0 cellpadding=0>");
                        for (int row = 0; row < Program.Rows; row++)
                        {
                            dumpFile.Write("<tr>");
                            for (int col = 0; col < Program.Cols; col++)
                            {
                                var ch = string.Format("&#x{0:X};", (int)NoxicoGame.IngameToUnicode[image[col, row].Character]);
                                if (ch == "&#x20;")
                                {
                                    ch = "&nbsp;";
                                }
                                dumpFile.Write("<td style=\"background:{1};color:{2}\">{0}</td>", ch, image[col, row].Background.ToHex(), image[col, row].Foreground.ToHex());
                            }
                            dumpFile.WriteLine("</tr>");
                        }
                        dumpFile.WriteLine("</table>");
                        dumpFile.WriteLine("</body></html>");
                    }
                    return;
                }

                var shotDir = IniFile.GetValue("misc", "shotpath", "screenshots");
                if (shotDir.StartsWith('$'))
                {
                    shotDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + shotDir.Substring(1);
                }

                if (!Directory.Exists(shotDir))
                {
                    Directory.CreateDirectory(shotDir);
                }
                int i = 1;
                while (File.Exists(Path.Combine(shotDir, "screenshot" + i.ToString("000") + ".png")))
                {
                    i++;
                }
                backBuffer.Save(Path.Combine(shotDir, "screenshot" + i.ToString("000") + ".png"), ImageFormat.Png);
                Program.WriteLine("Screenshot saved.");
            }
            if (e.KeyValue == 191)
            {
                NoxicoGame.KeyMap[Keys.L] = false;
            }

            if (e.KeyCode == Keys.R && e.Control)
            {
                NoxicoGame.KeyMap[Keys.R] = false;
                for (int row = 0; row < Program.Rows; row++)
                {
                    for (int col = 0; col < Program.Cols; col++)
                    {
                        previousImage[col, row].Character = '\uFFFE';
                    }
                }
            }

            if (e.KeyCode == Keys.A && e.Control && NoxicoGame.Mode == UserMode.Walkabout)
            {
                NoxicoGame.KeyMap[Keys.A] = false;
                NoxicoGame.ShowMessageLog();
            }

#if DEBUG
            if (e.KeyCode == Keys.E && e.Control && NoxicoGame.Mode == UserMode.Walkabout)
            {
                (new Editor()).LoadBoard(Noxico.CurrentBoard);
            }
#endif
        }