Exemple #1
0
        public static SimpleUI InitUI()
        {
            FontSurface fnt = FontSurface.BitmapMonospace("Resources" + "/" + "monkey.png", new Size(6, 14));
            Screen      initialActionChoices = new Screen("Act!", new List <MenuItem>()),
                        attackChoices        = new Screen("Attack!", new List <MenuItem>());
            MenuItem moveItem   = new MenuItem("Move", null, Demo.OnKeyDown_SelectMove, Demo.HighlightMove),
                     attackItem = new MenuItem("Attack", attackChoices, null),
                     waitItem   = new MenuItem("Wait", null, null, Demo.waitAction),
                     lookItem   = new MenuItem("Look", null, Demo.OnKeyDown_LookAround);

            initialActionChoices.menu.Add(moveItem);
            initialActionChoices.menu.Add(attackItem);
            initialActionChoices.menu.Add(waitItem);
            initialActionChoices.menu.Add(lookItem);
            attackChoices.previousScreen = initialActionChoices;
            //attackChoices.menu.Add(new MenuItem("Scorch", null, Demo.OnKeyDown_SelectSkill));
            SimpleUI sui = new SimpleUI(initialActionChoices, fnt);

            sui.allScreens.Add("Act", initialActionChoices);
            sui.allScreens.Add("Attack", attackChoices);
            sui.allMenuItems.Add(moveItem);
            sui.allMenuItems.Add(attackItem);
            sui.allMenuItems.Add(waitItem);
            sui.allMenuItems.Add(lookItem);
            return(sui);
        }
Exemple #2
0
        public static DialogUI CreateYesNoDialog(string speaker, List <string> startText, LinkedAction yesAction, LinkedAction noAction)
        {
            FontSurface fnt           = FontSurface.BitmapMonospace("Resources" + "/" + "monkey.png", new Size(6, 14));
            Dialog      initialDialog = new Dialog(speaker, startText, new List <DialogItem>());
            DialogItem  yesItem       = new DialogItem("Yes", null, null, yesAction),
                        noItem        = new DialogItem("No", null, null, noAction);

            initialDialog.options.Add(yesItem);
            initialDialog.options.Add(noItem);
            initialDialog.setSize();
            //attackChoices.menu.Add(new DialogItem("Scorch", null, Demo.OnKeyDown_SelectSkill));
            DialogUI dui = new DialogUI(initialDialog, fnt);

            dui.allDialogItems.Add(yesItem);
            dui.allDialogItems.Add(noItem);
            return(dui);
        }
Exemple #3
0
        public static DialogUI CreateLoadGameDialog(SortedDictionary <DateTime, Demo.GameState> allSavedStates)
        {
            FontSurface fnt          = FontSurface.BitmapMonospace("Resources" + "/" + "monkey.png", new Size(6, 14));
            Dialog      chooseDialog = new Dialog("The Narrator", new List <String>()
            {
                "Choose a saved game:"
            }, new List <DialogItem>()),
                        finishedLoadDialog = new Dialog("The Narrator", new List <String>()
            {
                "Are you ready?"
            }, new List <DialogItem>()),
                        cannotLoadDialog = new Dialog("The Narrator", new List <String>()
            {
                "Play a little first, then you will have a game to load."
            }, new List <DialogItem>());
            DialogItem newGameItem = new DialogItem("New Game", chooseDialog, null, Demo.Init),
                       endOKItem   = new DialogItem("OK!", null, null, DialogBrowser.Hide);

            if (!System.IO.File.Exists("save.mobsav"))
            {
                chooseDialog.options = new List <DialogItem>()
                {
                    new DialogItem("[No Previous Game]", cannotLoadDialog, null)
                };
            }
            finishedLoadDialog.options.Add(endOKItem);
            finishedLoadDialog.setSize();
            finishedLoadDialog.previousDialog = null;
            //            finishedLoadDialog.options.Add(endOKItem);
            DialogUI dui = new DialogUI(chooseDialog, fnt);

            foreach (DateTime dt in Demo.allSavedStates.Keys)
            {
                chooseDialog.options.Add(new DialogItem("Saved on " + dt.ToShortDateString() + " at " + dt.ToShortTimeString(), null, null, Demo.LoadGame));
            }
            chooseDialog.setSize();
            dui.allDialogItems.AddRange(chooseDialog.options);
            chooseDialog.previousDialog = null;
            cannotLoadDialog.options.Add(newGameItem);
            cannotLoadDialog.setSize();
            cannotLoadDialog.previousDialog = null;
            //attackChoices.menu.Add(new DialogItem("Scorch", null, Demo.OnKeyDown_SelectSkill));
            dui.allDialogItems.Add(newGameItem);
            return(dui);
        }
Exemple #4
0
        }/*
          * public void ShowOld()
          * {
          * string tx = mandrillDict['┌'].ToString();
          * tx = tx.PadRight(maxWidth - 1, mandrillDict['─']);
          * tx += mandrillDict['┐'];
          * //            for (int i = 1; i < maxWidth - 1; i++)
          * //              tx += mandrillDict['─'];
          *
          * font.DrawText(10.0, font.FontHeight * 1, tx);
          * font.DrawText(10.0, font.FontHeight * 2, mandrillDict['│'] + currentDialog.speaker.PadRight(maxWidth - 2, ' ') + mandrillDict['│']);
          *
          * tx = mandrillDict['├'].ToString();
          * tx = tx.PadRight(maxWidth - 1, mandrillDict['─']);
          * tx += mandrillDict['┤'];
          * font.DrawText(10.0, font.FontHeight * 3, tx);
          * for (int i = 0; i < currentDialog.options.Count; i++)
          * {
          *     font.DrawText(10.0, font.FontHeight * (4 + i), "" + mandrillDict['│']);
          *     if (i == currentDialog.)
          *     {
          *         if (currentDialog.menu[i].enabled)
          *             font.Color = Color.Red;
          *         else
          *             font.Color = Color.Gray;
          *         font.DrawText(16.0, font.FontHeight * (4 + i), "> " + currentDialog.menu[i].text.PadRight(maxWidth - 4, ' '));
          *
          *     }
          *     else
          *     {
          *         if (currentDialog.menu[i].enabled)
          *             font.Color = Color.White;
          *         else
          *             font.Color = Color.Gray;
          *         font.DrawText(16.0, font.FontHeight * (4 + i), currentDialog.menu[i].text.PadRight(maxWidth - 2, ' '));
          *
          *     }
          *     font.Color = Color.White;
          *     font.DrawText(10.0 + 6.0 * (maxWidth - 1), font.FontHeight * (4 + i), "" + mandrillDict['│']);
          * }
          *
          * tx = mandrillDict['└'].ToString();
          * tx = tx.PadRight(maxWidth - 1, mandrillDict['─']);
          * tx += mandrillDict['┘'];
          * font.DrawText(10.0, font.FontHeight * (4 + currentDialog.options.Count), tx);
          * }*/

        public static DialogUI InitUI()
        {
            FontSurface fnt           = FontSurface.BitmapMonospace("Resources" + "/" + "monkey.png", new Size(6, 14));
            Dialog      initialDialog = new Dialog("The Narrator", new List <String>()
            {
                "Welcome to the Unpleasant Dungeon!", "Navigate through menus with the arrow keys.",
                "Confirm a selection with the " + ScreenBrowser.confirmKey.ToString() + " key.", "Do you understand?"
            }, new List <DialogItem>()),
                        yesDialog = new Dialog("The Narrator", new List <String>()
            {
                "Great!", "You can press " + ScreenBrowser.backKey.ToString() + " to go back in menus and dialogs.", "Are you ready to start?"
            }, new List <DialogItem>()),
                        noDialog = new Dialog("The Narrator", new List <String>()
            {
                "Then how did you get here?"
            }, new List <DialogItem>());
            DialogItem yesItem   = new DialogItem("Yes", yesDialog, null),
                       noItem    = new DialogItem("No", noDialog, null),
                       endOKItem = new DialogItem("OK!", null, null, DialogBrowser.Hide),
                       huhItem   = new DialogItem("???", initialDialog, null);

            initialDialog.options.Add(yesItem);
            initialDialog.options.Add(noItem);
            initialDialog.setSize();
            yesDialog.options.Add(endOKItem);
            yesDialog.setSize();
            noDialog.options.Add(huhItem);
            noDialog.setSize();
            yesDialog.previousDialog = initialDialog;
            noDialog.previousDialog  = initialDialog;
            //attackChoices.menu.Add(new DialogItem("Scorch", null, Demo.OnKeyDown_SelectSkill));
            DialogUI dui = new DialogUI(initialDialog, fnt);

            dui.allDialogItems.Add(yesItem);
            dui.allDialogItems.Add(noItem);
            return(dui);
        }
Exemple #5
0
        public void Main(string[] args)
        {
            using (AgateSetup setupDisplay = new AgateSetup())
            {
                setupDisplay.AskUser = true;
                setupDisplay.Initialize(true, false, false);

                if (setupDisplay.WasCanceled)
                {
                    return;
                }

                DisplayWindow wind = DisplayWindow.CreateWindowed("Font Tester", 800, 600);

                FontSurface font       = new FontSurface("Sans Serif", 12);
                FontSurface bitmapFont = FontSurface.BitmapMonospace("lotafont.png", new Size(16, 16));

                int frame = 0;


                while (wind.IsClosed == false)
                {
                    Display.BeginFrame();
                    Display.Clear(Color.DarkGray);


                    // test the color changing
                    font.Color = Color.LightGreen;
                    font.DrawText(20, 150, "This is regular green text.");
                    font.Color = Color.White;

                    // test display alignment property
                    Point  textPoint = new Point(100, 50);
                    string text      = string.Format("This text is centered on {0},{1}.", textPoint.X, textPoint.Y);
                    Size   textSize  = font.StringDisplaySize(text);

                    // draw a box around where the text should be displayed.
                    Display.DrawRect(new Rectangle(textPoint.X - textSize.Width / 2, textPoint.Y - textSize.Height / 2,
                                                   textSize.Width, textSize.Height), Color.Gray);

                    font.DisplayAlignment = OriginAlignment.Center;
                    font.DrawText(textPoint, text);
                    font.DisplayAlignment = OriginAlignment.TopLeft;

                    // test text scaling
                    font.SetScale(2.0, 2.0);
                    text      = "This text is twice as big.";
                    textPoint = new Point(50, 75);
                    textSize  = font.StringDisplaySize(text);

                    // draw a box with the same size the text should appear as
                    Display.DrawRect(new Rectangle(textPoint, textSize), Color.White);

                    font.DrawText(textPoint, text);
                    font.SetScale(1.0, 1.0);

                    // this draws a white background behind the text we want to Display.
                    text  = "F2: Toggle VSync   F5:  Toggle Windowed / Fullscreen      ";
                    text += "FPS: " + Display.FramesPerSecond.ToString("0.00") + "    ";

                    if (Core.IsActive)
                    {
                        text += "Active";
                    }
                    else
                    {
                        text += "Not Active";
                    }

                    // figure out how big the displayed text will be
                    textSize = font.StringDisplaySize(text);

                    // draw the white background
                    Display.FillRect(new Rectangle(new Point(0, 0), textSize), Color.White);

                    // draw the text on top of the background
                    font.Color = Color.Black;
                    font.DrawText(text);  // supplying no position arguments defaults to (0, 0)

                    // draw something which moves to let us know the program is running
                    Display.FillRect(new Rectangle(
                                         10, 200, 70 + (int)(50 * Math.Cos(frame / 10.0)), 50), Color.Red);

                    // do some bitmap font stuff
                    bitmapFont.DrawText(10, 350, "THIS IS BITMAP FONT TEXT.");

                    bitmapFont.Color = Color.Red;
                    bitmapFont.DrawText(10, 366, "THIS IS RED TEXT.");
                    bitmapFont.Color = Color.White;

                    bitmapFont.SetScale(3, 2);
                    bitmapFont.DrawText(10, 382, "THIS IS BIGG.");
                    bitmapFont.SetScale(1, 1);

                    Display.FillRect(new Rectangle(95, 425, 10, 10), Color.Blue);
                    bitmapFont.DisplayAlignment = OriginAlignment.Center;
                    bitmapFont.DrawText(100, 430, "CHECK");
                    bitmapFont.DisplayAlignment = OriginAlignment.TopLeft;

                    Display.FillRect(new Rectangle(-10, -10, 20, 20), Color.Green);

                    // and we're done.
                    Display.EndFrame();
                    Core.KeepAlive();

                    frame++;

                    // toggle full screen if the user pressed F5;
                    if (Keyboard.Keys[KeyCode.F5])
                    {
                        System.Diagnostics.Debug.Print("IsFullscreen: {0}", Display.CurrentWindow.IsFullScreen);

                        if (Display.CurrentWindow.IsFullScreen == false)
                        {
                            Display.CurrentWindow.SetFullScreen(800, 600, 32);
                        }
                        else
                        {
                            Display.CurrentWindow.SetWindowed();
                        }

                        System.Diagnostics.Debug.Print("IsFullscreen: {0}", Display.CurrentWindow.IsFullScreen);
                    }
                    else if (Keyboard.Keys[KeyCode.F2])
                    {
                        Display.VSync = !Display.VSync;
                        Keyboard.ReleaseKey(KeyCode.F2);
                    }
                    else if (Keyboard.Keys[KeyCode.Escape])
                    {
                        Display.Dispose();
                        return;
                    }
                }
            }
        }
Exemple #6
0
        public static DialogUI InitLoadUI()
        {
            FontSurface fnt           = FontSurface.BitmapMonospace("Resources" + "/" + "monkey.png", new Size(6, 14));
            Dialog      initialDialog = new Dialog("The Narrator", new List <String>()
            {
                "Welcome to the Unpleasant Dungeon!", "Navigate through menus with the arrow keys.",
                "Confirm a selection with the " + ScreenBrowser.confirmKey.ToString() + " key.", "You can press " + ScreenBrowser.backKey.ToString() + " to go back in menus and dialogs.",
                "You can quit this game by pressing Q, which will also give you the option to Save.",
                "Do you want to start a new game, or load a previous game?"
            }, new List <DialogItem>()),
                        finishedLoadDialog = new Dialog("The Narrator", new List <String>()
            {
                "Choose a saved game:"
            }, new List <DialogItem>()),
                        remapConfirmDialog = new Dialog("The Narrator", new List <String>()
            {
                "Remap the Confirm Key.", "Confirm is currently " + ScreenBrowser.confirmKey.ToString() + ".",
                "Back is currently " + ScreenBrowser.backKey.ToString() + "."
            }, new List <DialogItem>()),
                        remapBackDialog = new Dialog("The Narrator", new List <String>()
            {
                "Remap the Back Key:", "Confirm is currently " + ScreenBrowser.confirmKey.ToString() + ".",
                "Back is currently " + ScreenBrowser.backKey.ToString() + "."
            }, new List <DialogItem>()),
                        cannotLoadDialog = new Dialog("The Narrator", new List <String>()
            {
                "Play a little first, then you will have a game to load."
            }, new List <DialogItem>());
            DialogItem newGameItem        = new DialogItem("New Game", finishedLoadDialog, null, Demo.Init),
                       loadItem           = new DialogItem("Load Previous Game", null, null, Demo.LoadStates),
                       remapItem          = new DialogItem("Use Different Keys", remapConfirmDialog, null, RegisterConfirmKey),
                       remapConfirmOKItem = new DialogItem("OK", remapBackDialog, null, RegisterBackKey),
                       remapBackOKItem    = new DialogItem("OK", initialDialog, null, AssignInitialDialog),
                       endOKItem          = new DialogItem("OK!", null, null, DialogBrowser.Hide);

            if (!System.IO.File.Exists("save.mobsav"))
            {
                loadItem = new DialogItem("[No Previous Game]", cannotLoadDialog, null);
            }
            initialDialog.options.Add(newGameItem);
            initialDialog.options.Add(loadItem);
            initialDialog.options.Add(remapItem);
            initialDialog.setSize();
            initialDialog.previousDialog = null;
//            finishedLoadDialog.options.Add(endOKItem);
            finishedLoadDialog.setSize();
            finishedLoadDialog.previousDialog = null;
            remapConfirmDialog.options.Add(remapConfirmOKItem);
            remapConfirmDialog.setSize();
            remapConfirmDialog.previousDialog = initialDialog;
            remapBackDialog.options.Add(remapBackOKItem);
            remapBackDialog.setSize();
            remapBackDialog.previousDialog = remapConfirmDialog;
            cannotLoadDialog.options.Add(newGameItem);
            cannotLoadDialog.setSize();
            cannotLoadDialog.previousDialog = null;
            //attackChoices.menu.Add(new DialogItem("Scorch", null, Demo.OnKeyDown_SelectSkill));
            DialogUI dui = new DialogUI(initialDialog, fnt);

            dui.allDialogItems.Add(newGameItem);
            dui.allDialogItems.Add(loadItem);
            return(dui);
        }
Exemple #7
0
        public void Run(string[] args)
        {
            using (var wind = new DisplayWindowBuilder(args)
                              .BackbufferSize(800, 600)
                              .QuitOnClose()
                              .Build())
            {
                DisplayWindow fullWind = null;

                FontSurface bitmapFontSurface = FontSurface.BitmapMonospace("lotafont.png", new Size(16, 16));
                Font        bitmapFont        = new FontBuilder("lotafont").AddFontSurface(
                    new FontSettings(16, FontStyles.None), bitmapFontSurface).Build();

                int frame = 0;

                while (AgateApp.IsAlive)
                {
                    Display.BeginFrame();
                    Display.Clear(Color.DarkGray);

                    IFont font = Font.AgateSans;
                    font.Size = 12;

                    // test the color changing
                    font.Color = Color.LightGreen;
                    font.DrawText(20, 150, "This is regular green text.");
                    font.Color = Color.White;

                    // test display alignment property
                    Point  textPoint = new Point(100, 50);
                    string text      = string.Format("This text is centered on {0},{1}.", textPoint.X, textPoint.Y);
                    Size   textSize  = font.MeasureString(text);

                    // draw a box around where the text should be displayed.
                    Display.Primitives.DrawRect(Color.Gray,
                                                new Rectangle(textPoint.X - textSize.Width / 2, textPoint.Y - textSize.Height / 2,
                                                              textSize.Width, textSize.Height));

                    font.DisplayAlignment = OriginAlignment.Center;
                    font.DrawText(textPoint, text);
                    font.DisplayAlignment = OriginAlignment.TopLeft;

                    // test text scaling
                    font.Size = 24;
                    text      = "This text is twice as big.";
                    textPoint = new Point(50, 75);
                    textSize  = font.MeasureString(text);

                    // draw a box with the same size the text should appear as
                    Display.Primitives.DrawRect(Color.White, new Rectangle(textPoint, textSize));

                    font.DrawText(textPoint, text);
                    font.Size = 12;

                    // this draws a white background behind the text we want to Display.
                    text  = "F2: Toggle VSync   F5:  Toggle Windowed / Fullscreen      ";
                    text += "FPS: " + Display.FramesPerSecond.ToString("0.00") + "    ";

                    if (AgateApp.IsActive)
                    {
                        text += "Active";
                    }
                    else
                    {
                        text += "Not Active";
                    }

                    // figure out how big the displayed text will be
                    textSize = font.MeasureString(text);

                    // draw the white background
                    Display.Primitives.FillRect(Color.White, new Rectangle(new Point(0, 0), textSize));

                    // draw the text on top of the background
                    font.Color = Color.Black;
                    font.DrawText(text);                     // supplying no position arguments defaults to (0, 0)

                    // draw something which moves to let us know the program is running
                    Display.Primitives.FillRect(Color.Red, new Rectangle(
                                                    10, 200, 70 + (int)(50 * Math.Cos(frame / 10.0)), 50));

                    // do some bitmap font stuff
                    bitmapFont.DrawText(10, 350, "THIS IS BITMAP FONT TEXT.");

                    bitmapFont.Color = Color.Red;
                    bitmapFont.DrawText(10, 366, "THIS IS RED TEXT.");
                    bitmapFont.Color = Color.White;

                    bitmapFont.Size = 32;
                    bitmapFont.DrawText(10, 382, "THIS IS BIGG.");

                    Display.Primitives.FillRect(Color.Blue, new Rectangle(95, 425, 10, 10));
                    bitmapFont.TextAlignment = OriginAlignment.Center;
                    bitmapFont.DrawText(100, 430, "CHECK");
                    bitmapFont.TextAlignment = OriginAlignment.TopLeft;

                    Display.Primitives.FillRect(Color.Green, new Rectangle(-10, -10, 20, 20));

                    // and we're done.
                    Display.EndFrame();
                    AgateApp.KeepAlive();

                    frame++;

                    // toggle full screen if the user pressed F5;
                    if (Input.Unhandled.Keys[KeyCode.F5])
                    {
                        System.Diagnostics.Debug.Print("IsFullscreen: {0}", Display.CurrentWindow.IsFullScreen);

                        if (Display.CurrentWindow.IsFullScreen == false)
                        {
                            fullWind = DisplayWindow.CreateFullScreen("Font Tester", 800, 600);
                        }
                        else
                        {
                            fullWind.Dispose();
                            Display.RenderTarget = wind.FrameBuffer;
                        }

                        Input.Unhandled.Keys.ReleaseAll();
                        System.Diagnostics.Debug.Print("IsFullscreen: {0}", Display.CurrentWindow.IsFullScreen);
                    }
                    else if (Input.Unhandled.Keys[KeyCode.F2])
                    {
                        Display.RenderState.WaitForVerticalBlank = !Display.RenderState.WaitForVerticalBlank;
                        Input.Unhandled.Keys.Release(KeyCode.F2);
                    }
                    else if (Input.Unhandled.Keys[KeyCode.Escape])
                    {
                        Display.Dispose();
                        return;
                    }
                }
            }
        }
Exemple #8
0
 static Level()
 {
     mandrillFont = FontSurface.BitmapMonospace("Resources" + "/" + "monkey_x2.png", new Size(12, 28));
     tileset      = new Surface("Resources" + "/" + "slashem-revised.png"); //System.IO.Path.DirectorySeparatorChar
 }