コード例 #1
0
    public void ChooseName()
    {
        //DateTime pressTic, drawTic;
        //TimeSpan diff;
        //pressTic = DateTime.Now;
        //drawTic = DateTime.Now;
        //diff = drawTic - pressTic;
        int key = SdlHardware.DetectKey();

        if (key != SdlHardware.KEY_SPC && key != SdlHardware.KEY_ESC &&
            key != SdlHardware.KEY_UP && key != SdlHardware.KEY_DOWN &&
            key != SdlHardware.KEY_LEFT && key != SdlHardware.KEY_RIGHT &&
            key != SdlHardware.KEY_RETURN /*&& ((int) diff.TotalMilliseconds > 500)*/)
        {
            name += SdlHardware.KeyToString(key);
        }
        else if (key == SdlHardware.KEY_SPC && name.Length > 0)
        {
            name = name.Remove(name.Length - 1);
        }
        else if (key == SdlHardware.KEY_RETURN)
        {
            nameChosen = true;
        }
        SdlHardware.Pause(105);
    }
コード例 #2
0
 public override void DrawMenu()
 {
     SdlHardware.ClearScreen();
     SdlHardware.WriteHiddenText("CURRENT CONTROLS ",
                                 100, 30,
                                 0xC0, 0xC0, 0xC0,
                                 font);
     SdlHardware.WriteHiddenText("Up: " + SdlHardware.KeyToString(Controls.Up),
                                 100, 40,
                                 0xC0, 0xC0, 0xC0,
                                 font);
     SdlHardware.WriteHiddenText("Down: " + SdlHardware.KeyToString(Controls.Down),
                                 100, 50,
                                 0xC0, 0xC0, 0xC0,
                                 font);
     SdlHardware.WriteHiddenText("Left: " + SdlHardware.KeyToString(Controls.Left),
                                 100, 60,
                                 0xC0, 0xC0, 0xC0,
                                 font);
     SdlHardware.WriteHiddenText("Right: " + SdlHardware.KeyToString(Controls.Right),
                                 100, 70,
                                 0xC0, 0xC0, 0xC0,
                                 font);
     SdlHardware.WriteHiddenText("Use item: " + SdlHardware.KeyToString(Controls.UseItem),
                                 100, 80,
                                 0xC0, 0xC0, 0xC0,
                                 font);
     SdlHardware.WriteHiddenText("Toggle walk: " + SdlHardware.KeyToString(Controls.ToggleWalk),
                                 100, 90,
                                 0xC0, 0xC0, 0xC0,
                                 font);
     SdlHardware.WriteHiddenText("Open inventory: " + SdlHardware.KeyToString(Controls.Inventory),
                                 100, 100,
                                 0xC0, 0xC0, 0xC0,
                                 font);
     SdlHardware.WriteHiddenText("Pause: " + SdlHardware.KeyToString(Controls.Pause),
                                 100, 110,
                                 0xC0, 0xC0, 0xC0,
                                 font);
     SdlHardware.WriteHiddenText("Accept: " + SdlHardware.KeyToString(Controls.Accept),
                                 100, 120,
                                 0xC0, 0xC0, 0xC0,
                                 font);
     SdlHardware.WriteHiddenText("Cancel: " + SdlHardware.KeyToString(Controls.Cancel),
                                 100, 130,
                                 0xC0, 0xC0, 0xC0,
                                 font);
     SdlHardware.ShowHiddenScreen();
 }