Example #1
0
 public MainWindow()
 {
     InitializeComponent();
     //This odd event handler is needed because the TextBox control eats that spacebar, so we have to intercept an already-handled event.
     //this.Console.AddHandler(TextBox.KeyDownEvent, new KeyEventHandler(Console_KeyDown), true);
     this.Console.AddHandler(TextBox.PreviewKeyDownEvent, new KeyEventHandler(Console_KeyDown), true);
     Tolk.Load();
     Tolk.TrySAPI(false);
     Tolk.DetectScreenReader();
     Tolk.Speak("Bem-vindo ao terminal 3270!", true);
     Tolk.Speak("Pressione Alt + E para conectar, ou Alt + Q para sair.");
 }
 public static void Speak(string text, bool interrupt = true)
 {
     if (DivinityApp.IsScreenReaderActive())
     {
         if (!isLoaded)
         {
             Init();
         }
         if (isLoaded)
         {
             if (!Tolk.HasSpeech())
             {
                 Tolk.TrySAPI(true);
             }
             Tolk.Output(text, interrupt);
         }
         //DivinityApp.Log($"Tolk.DetectScreenReader: {Tolk.DetectScreenReader()} Tolk.HasSpeech: {Tolk.HasSpeech()} Tolk.IsLoaded: {Tolk.IsLoaded()}");
     }
 }
Example #3
0
        static void Main(string[] args)
        {
            Tolk.TrySAPI(true);
            Tolk.Load();

            //Console.WriteLine("Querying for the active screen reader driver...");
            //string name = Tolk.DetectScreenReader();
            //if (name != null) {
            //  Console.WriteLine("The active screen reader driver is: {0}", name);
            //}
            //else {
            //  Console.WriteLine("None of the supported screen readers is running");
            //}

            //if (Tolk.HasSpeech()) {
            //  Console.WriteLine("This screen reader driver supports speech");
            //}
            //if (Tolk.HasBraille()) {
            //  Console.WriteLine("This screen reader driver supports braille");
            //}

            //Console.WriteLine("Let's output some text...");
            //if (!Tolk.Output("Hello, World!")) {
            //  Console.WriteLine("Failed to output text");
            //}

            //Console.WriteLine("Finalizing Tolk...");
            //Tolk.Unload();

            //Console.WriteLine("Done!");
            var  G    = new AtlasWarriorsGame.Game();
            bool quit = false;

            displayMode = DisplayMode.ROOM;
            bool skipDraw = false;

            while (!quit)
            {
                // If not skipping draw, draw map. If so - reset skipDraw to draw map next time.
                if (!skipDraw)
                {
                    if (displayMode != DisplayMode.REFRESH_ONLY)
                    {
                        DrawMap(G.CurrentDungeon);
                    }
                }
                else
                {
                    skipDraw = false;
                }
                Console.Write($"\nHP {G.Player.CurrentHealth} ({G.Player.MaxHealth})");
                Console.Write("\n>");
                var input = Console.ReadKey();
                switch (input.Key)
                {
                case ConsoleKey.H:
                case ConsoleKey.LeftArrow:
                case ConsoleKey.NumPad4:
                    G.Player.NextMove = Player.Instruction.MOVE_W;
                    break;

                case ConsoleKey.K:
                case ConsoleKey.UpArrow:
                case ConsoleKey.NumPad8:
                    G.Player.NextMove = Player.Instruction.MOVE_N;
                    break;

                case ConsoleKey.L:
                case ConsoleKey.RightArrow:
                case ConsoleKey.NumPad6:
                    G.Player.NextMove = Player.Instruction.MOVE_E;
                    break;

                case ConsoleKey.J:
                case ConsoleKey.DownArrow:
                case ConsoleKey.NumPad2:
                    G.Player.NextMove = Player.Instruction.MOVE_S;
                    break;

                case ConsoleKey.Y:
                case ConsoleKey.NumPad7:
                    G.Player.NextMove = Player.Instruction.MOVE_NW;
                    break;

                case ConsoleKey.U:
                case ConsoleKey.NumPad9:
                    G.Player.NextMove = Player.Instruction.MOVE_NE;
                    break;

                case ConsoleKey.B:
                case ConsoleKey.NumPad1:
                    G.Player.NextMove = Player.Instruction.MOVE_SW;
                    break;

                case ConsoleKey.N:
                case ConsoleKey.NumPad3:
                    G.Player.NextMove = Player.Instruction.MOVE_SE;
                    break;

                // Non move options
                // Refresh screen
                case ConsoleKey.Spacebar:
                    DrawMap(G.CurrentDungeon, true);
                    skipDraw = true;
                    break;

                // Change draw mode - F1, F2, F3
                case ConsoleKey.F1:
                    displayMode = DisplayMode.ALL;
                    Console.Write("Display mode set to show all");
                    break;

                case ConsoleKey.F2:
                    displayMode = DisplayMode.ROOM;
                    Console.Write("Display mode set to show current visible area only");
                    break;

                case ConsoleKey.F3:
                    displayMode = DisplayMode.REFRESH_ONLY;
                    Console.Write("Display mode set to only show on refresh (Space)");
                    break;
                }
                G.DoTurn();
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            Tolk.TrySAPI(true);
            Tolk.Load();

            string introText =
                @"Atlas Warriors - Screen Reader Edition
Lachlan Kingsford

Welcome to Atlas Warriors. This screen reader edition provides screen-reader specific functionality:
F1: Screen mode - whole map
F2: Screen mode - current room only
F3: Screen mode - no refresh
Space: Draw whole screen

Move with Vim keys, arrows or numeric keypad.

Push any key to continue";

            Console.WriteLine(introText);
            Tolk.Output(introText);

            Console.ReadKey();

            var  G    = new AtlasWarriorsGame.Game();
            bool quit = false;

            displayMode = DisplayMode.ROOM;
            bool skipDraw = false;

            while (!quit)
            {
                // Interrupt reader at start of turn
                Tolk.Output("", true);

                // If not skipping draw, draw map. If so - reset skipDraw to draw map next time.
                if (!skipDraw)
                {
                    if (displayMode != DisplayMode.REFRESH_ONLY)
                    {
                        DrawMap(G.CurrentDungeon);
                    }
                }
                else
                {
                    skipDraw = false;
                }
                Console.Write($"\nHP {G.Player.CurrentHealth} ({G.Player.MaxHealth})");
                Tolk.Output($"{G.Player.CurrentHealth} of {G.Player.MaxHealth}");
                Console.Write("\n>");
                var input = Console.ReadKey();
                switch (input.Key)
                {
                case ConsoleKey.H:
                case ConsoleKey.LeftArrow:
                case ConsoleKey.NumPad4:
                    G.Player.NextMove = Player.Instruction.MOVE_W;
                    break;

                case ConsoleKey.K:
                case ConsoleKey.UpArrow:
                case ConsoleKey.NumPad8:
                    G.Player.NextMove = Player.Instruction.MOVE_N;
                    break;

                case ConsoleKey.L:
                case ConsoleKey.RightArrow:
                case ConsoleKey.NumPad6:
                    G.Player.NextMove = Player.Instruction.MOVE_E;
                    break;

                case ConsoleKey.J:
                case ConsoleKey.DownArrow:
                case ConsoleKey.NumPad2:
                    G.Player.NextMove = Player.Instruction.MOVE_S;
                    break;

                case ConsoleKey.Y:
                case ConsoleKey.NumPad7:
                    G.Player.NextMove = Player.Instruction.MOVE_NW;
                    break;

                case ConsoleKey.U:
                case ConsoleKey.NumPad9:
                    G.Player.NextMove = Player.Instruction.MOVE_NE;
                    break;

                case ConsoleKey.B:
                case ConsoleKey.NumPad1:
                    G.Player.NextMove = Player.Instruction.MOVE_SW;
                    break;

                case ConsoleKey.N:
                case ConsoleKey.NumPad3:
                    G.Player.NextMove = Player.Instruction.MOVE_SE;
                    break;

                // Non move options
                // Refresh screen
                case ConsoleKey.Spacebar:
                    DrawMap(G.CurrentDungeon, true);
                    skipDraw = true;
                    break;

                // Change draw mode - F1, F2, F3
                case ConsoleKey.F1:
                    displayMode = DisplayMode.ALL;
                    Console.Write("Display mode set to show all");
                    break;

                case ConsoleKey.F2:
                    displayMode = DisplayMode.ROOM;
                    Console.Write("Display mode set to show current visible area only");
                    break;

                case ConsoleKey.F3:
                    displayMode = DisplayMode.REFRESH_ONLY;
                    Console.Write("Display mode set to only show on refresh (Space)");
                    break;
                }
                G.DoTurn();

                if (G.GameOver)
                {
                    Console.WriteLine(G.EndGameTitle);
                    Tolk.Output(G.EndGameTitle, true);
                    Console.WriteLine(G.EndGameText);
                    Tolk.Output(G.EndGameText, false);
                    Console.WriteLine("(Press any key to quit)");
                    Tolk.Output("Press any key to quit");
                    Console.ReadKey();
                    quit = true;
                }
            }
        }