Exemplo n.º 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);
        }
Exemplo n.º 2
0
        private static string ConstructKerningText(DisplayWindow wind, FontSurface font)
        {
            return("THIS IMPLEMENTATION NEEDS FIXING");

            //	var bmp = font.Impl as AgateLib.DisplayLib.BitmapFont.BitmapFontImpl;

            //	FontMetrics metrics = bmp.FontMetrics.Clone();

            //	StringBuilder text = new StringBuilder();

            //	int count = 0;
            //	int maxLine = wind.Width / font.FontHeight();

            //	foreach (char first in metrics.Keys)
            //	{
            //		foreach (var kern in metrics[first].KerningPairs)
            //		{
            //			text.Append(first);
            //			text.Append(kern.Key);
            //			text.Append(" ");

            //			count += 2;

            //			if (count > maxLine)
            //			{
            //				text.AppendLine();
            //				count = 0;
            //			}
            //		}
            //	}

            //	string displayText = text.ToString();
            //	return displayText;
        }
Exemplo n.º 3
0
        public void Init()
        {
            ff = new Font("times");

            ff.AddFontSurface(new FontSettings(8, FontStyles.None),
                              FontSurface.FromImpl(new FakeFontSurface()
            {
                Height = 8
            }));

            ff.AddFontSurface(new FontSettings(8, FontStyles.Bold),
                              FontSurface.FromImpl(new FakeFontSurface {
                Height = 8
            }));

            ff.AddFontSurface(new FontSettings(10, FontStyles.None),
                              FontSurface.FromImpl(new FakeFontSurface {
                Height = 10
            }));

            ff.AddFontSurface(new FontSettings(10, FontStyles.Bold),
                              FontSurface.FromImpl(new FakeFontSurface {
                Height = 10
            }));
        }
Exemplo n.º 4
0
        private void FontTests(FontSurface fontSurface, out Rectangle drawRect)
        {
            Point drawPoint = new Point(10, 10);
            Size  fontsize  = fontSurface.StringDisplaySize(text);

            drawRect = new Rectangle(drawPoint, fontsize);

            fontSurface.DrawText(drawPoint, text);
        }
Exemplo n.º 5
0
 public void DebugPrint(int x, int y, string debugText)
 {
     if (debugFontSurface == null)
     {
         debugFontSurface       = new FontSurface("Arial", 12);
         debugFontSurface.Color = Color.Black;
     }
     debugFontSurface.DrawText(destX: x, destY: y, text: debugText);
 }
Exemplo n.º 6
0
        public DialogUI(Dialog s, FontSurface fnt)
        {
            initialDialog = s;
            //   previousDialog = s.Clone();
            currentDialog = s;
//            allDialogs = new Dictionary<String, Dialog>() { { s.speaker + s.lines[0], s } };
            allDialogItems = new List <DialogItem>(s.options);
            font           = fnt;
        }
Exemplo n.º 7
0
        protected override void Initialize()
        {
            surf  = new Surface("jellybean.png");
            surf2 = new Surface("jellybean.png");
            font  = new FontSurface("Arial", 14);

            surf.SetScale(6.0, 6.0);
            font.SetScale(3.0, 3.0);
            surf2.SetScale(6.0, 6.0);
        }
Exemplo n.º 8
0
        public void Main(string[] args)
        {
            Core.Initialize();

            List <AgateDriverInfo> drivers = Registrar.DisplayDrivers;

            frmPerformanceTester frm = new frmPerformanceTester();

            frm.Show();

            Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));

            List <TestMethod> tests = new List <TestMethod>();

            tests.Add(FilledRectTest);
            tests.Add(DrawRectTest);
            tests.Add(DrawSurfaceTestColored);
            tests.Add(DrawSurfaceTestPlain);
            tests.Add(StretchTestColored);
            tests.Add(StretchTestPlain);

            foreach (AgateDriverInfo info in drivers)
            {
                Trace.WriteLine(string.Format("Starting driver {0}...", info.FriendlyName));
                Trace.Indent();
                double fps;

                Display.Initialize((DisplayTypeID)info.DriverTypeID);
                Display.VSync = false;

                DisplayWindow wind = DisplayWindow.CreateWindowed("Performance Test", 300, 300);
                font = new FontSurface("Arial", 11);

                for (int i = 0; i < tests.Count; i++)
                {
                    TestResult r = Execute(tests[i]);

                    r.Driver = info.FriendlyName;

                    frm.AddTestResult(r);
                }

                if (Display.CurrentWindow.IsClosed)
                {
                    Display.Dispose();
                    frm.Dispose();
                    return;
                }

                Display.Dispose();
            }

            frm.Visible = false;
            frm.ShowDialog();
        }
Exemplo n.º 9
0
 public SimpleUI(Screen s, FontSurface fnt)
 {
     initialScreen = s;
     //   previousScreen = s.Clone();
     currentScreen = s;
     allScreens    = new Dictionary <String, Screen>()
     {
         { s.title, s }
     };
     allMenuItems = new List <MenuItem>(s.menu);
     font         = fnt;
 }
Exemplo n.º 10
0
        private FontSurface ConstructUnkernedFont(FontSurface font)
        {
            var bmp = font.Impl as AgateLib.DisplayLib.BitmapFont.BitmapFontImpl;

            FontMetrics metrics = bmp.FontMetrics.Clone();

            foreach (var glyph in metrics.Keys)
            {
                metrics[glyph].KerningPairs.Clear();
            }

            return(FontSurface.FromImpl(new BitmapFontImpl(bmp.Surface, metrics, "Unkerned " + bmp.FontName)));
        }
Exemplo n.º 11
0
        public void CreateFont()
        {
            if (string.IsNullOrEmpty(FontFamily))
            {
                return;
            }
            if (font != null)
            {
                font.Dispose();
            }

            font = new FontSurface(mOptions);

            Draw();
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
        public void Run(string[] args)
        {
            using (var wind = new DisplayWindowBuilder(args)
                              .BackbufferSize(800, 600)
                              .QuitOnClose()
                              .Build())
            {
                Input.Unhandled.KeyDown += Keyboard_KeyDown;

                FontState state = new FontState
                {
                    Size  = 14,
                    Style = FontStyles.None,
                };

                FontSurface font = Font.AgateSans.Core.FontSurface(state);

                FontSurface unkerned = ConstructUnkernedFont(font);

                string text = ConstructKerningText(wind, font);

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

                    FontSurface thisFont = useKerning ? font : unkerned;

                    if (useKerning)
                    {
                        thisFont.DrawText(state, "Using kerning. (space to toggle)");
                    }
                    else
                    {
                        thisFont.DrawText(state, "No kerning used. (space to toggle)");
                    }

                    state.Color = Color.White;
                    thisFont.DrawText(state, new Vector2(0, thisFont.FontHeight(state)), text);

                    Display.EndFrame();
                    AgateApp.KeepAlive();
                }
            }
        }
Exemplo n.º 15
0
        void Run(string[] args)
        {
            using (AgateSetup setup = new AgateSetup(args))
            {
                setup.Initialize(true, false, false);
                if (setup.WasCanceled)
                {
                    return;
                }

                DisplayWindow wind = DisplayWindow.CreateWindowed
                                         ("Pong Example", displayWidth, displayHeight);

                font = new FontSurface("Sans Serif", 14);

                paddle[0]    = new Vector2(50, displayHeight / 2);
                paddle[1]    = new Vector2(playAreaWidth - 50 - paddleWidth, displayHeight / 2);
                ball         = new Vector2(playAreaWidth / 2, displayHeight / 2);
                ballvelocity = new Vector2(-70, 70);

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

                    DrawBorder();
                    DrawPaddles();
                    DrawBall();
                    DrawScore();

                    Display.EndFrame();
                    Core.KeepAlive();

                    if (Keyboard.Keys[KeyCode.Escape])
                    {
                        wind.Dispose();
                    }

                    float time_s = (float)Display.DeltaTime / 1000.0f;

                    UpdatePaddles(time_s);
                    UpdateBall(time_s);
                }
            }
        }
Exemplo n.º 16
0
        public void Main(string[] args)
        {
            using (AgateSetup setup = new AgateSetup(args))
            {
                setup.AskUser = true;
                setup.Initialize(true, false, false);
                if (setup.WasCanceled)
                {
                    return;
                }

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

                Display.BeginFrame();
                Display.Clear(Color.Navy);
                Display.EndFrame();
                Core.KeepAlive();

                BitmapFontOptions fontOptions = new BitmapFontOptions("Times", 18, FontStyle.Bold);
                fontOptions.UseTextRenderer = true;

                FontSurface font = new FontSurface(fontOptions);

                // TODO: Fix this
                //font.Save("testfont.xml");


                //FontSurface second = FontSurface.LoadBitmapFont("testfont.png", "testfont.xml");

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

                    font.DrawText("The quick brown fox jumps over the lazy dog.");

                    //second.DrawText(0, font.StringDisplayHeight("M"), "The quick brown fox jumps over the lazy dog.");

                    Display.EndFrame();
                    Core.KeepAlive();
                }
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Runs the application.
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public int Run(string[] args)
        {
            using (AgateSetup setup = new AgateSetup(args))
            {
                setup.Initialize(
                    InitParams.InitializeDisplay,
                    InitParams.InitializeAudio,
                    InitParams.InitializeJoysticks);

                if (setup.WasCanceled)
                {
                    return(1);
                }

                CreateDisplayWindow();

                font = new FontSurface("Arial", 12.0f);

                if (InitParams.ShowSplashScreen)
                {
                    DoSplash();
                }

                Initialize();

                while (MainWindow.IsClosed == false)
                {
                    Update(Display.DeltaTime);

                    Display.RenderTarget = mWindow;
                    Display.BeginFrame();

                    Render();

                    Display.EndFrame();
                    Core.KeepAlive();
                }
            }

            return(0);
        }
Exemplo n.º 18
0
        public void Run(string[] args)
        {
            using (new DisplayWindowBuilder(args)
                   .BackbufferSize(800, 600)
                   .QuitOnClose()
                   .Build())
            {
                Display.BeginFrame();
                Display.Clear(Color.Navy);
                Display.EndFrame();
                AgateApp.KeepAlive();

                BitmapFontOptions fontOptions = new BitmapFontOptions("Times", 18, FontStyles.None);
                fontOptions.TextRenderer = TextRenderEngine.TextRenderer;

                FontSurface surface = new FontSurface(BitmapFontUtil.ConstructFromOSFont(fontOptions));
                Font        font    = new FontBuilder("Times")
                                      .AddFontSurface(new FontSettings(18, FontStyles.None), surface)
                                      .Build();

                // TODO: Fix this
                //font.Save("testfont.xml");

                //FontSurface second = FontSurface.LoadBitmapFont("testfont.png", "testfont.xml");

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

                    font.DrawText("The quick brown fox jumped over the lazy dogs.");

                    //second.DrawText(0, font.StringDisplayHeight("M"), "The quick brown fox jumps over the lazy dog.");

                    Display.EndFrame();
                    AgateApp.KeepAlive();
                }
            }
        }
Exemplo n.º 19
0
        public void Main(string[] args)
        {
            using (AgateSetup setup = new AgateSetup("Resource Tester", args))
            {
                setup.InitializeAll();
                if (setup.WasCanceled)
                {
                    return;
                }

                AgateFileProvider.Resources.Add(new AgateLib.Utility.FileSystemProvider("Data"));

                AgateResourceCollection resources = new AgateResourceCollection("TestResourceFile.xml");

                DisplayWindow wind   = new DisplayWindow(resources, "main_window");
                Surface       surf   = new Surface(resources, "sample_surf");
                ISprite       sprite = new Sprite(resources, "sample_sprite");
                FontSurface   font   = new FontSurface(resources, "sample_font");

                sprite.StartAnimation();

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

                    font.DrawText(0, 0, "FPS: " + Display.FramesPerSecond.ToString());

                    surf.Draw(20, 20);

                    sprite.Update();
                    sprite.Draw(100, 100);

                    Display.EndFrame();
                    Core.KeepAlive();
                }
            }
        }
Exemplo n.º 20
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);
        }
Exemplo n.º 21
0
        public void CreateFont()
        {
            if (string.IsNullOrEmpty(Parameters.Family))
            {
                return;
            }
            font?.Dispose();

            FontBuilder fontBuilder = new FontBuilder(Parameters.Family);

            foreach (var fontSetting in FontSettings)
            {
                BitmapFontOptions options = CreateBitmapFontOptions(fontSetting);

                var fontSurface = new FontSurface
                                      (AgateLib.Platform.WinForms.Fonts.BitmapFontUtil.ConstructFromOSFont(options));

                fontBuilder.AddFontSurface(fontSetting, fontSurface);
            }

            font = fontBuilder.Build();

            Draw();
        }
Exemplo n.º 22
0
    //public TextStyler fontStyler;

    public void preload()
    {
        this.font      = new FontSurface("Arial", 11.0f);
        this.largeFont = new FontSurface("Arial", 22.0f);
        this.palogo    = new Sprite(spritesSrc, "palogo");
    }
Exemplo n.º 23
0
        public DialogUI(Dialog s, FontSurface fnt)
        {
            initialDialog = s;
            //   previousDialog = s.Clone();
            currentDialog = s;
//            allDialogs = new Dictionary<String, Dialog>() { { s.speaker + s.lines[0], s } };
            allDialogItems = new List<DialogItem>(s.options);
            font = fnt;
        }
Exemplo n.º 24
0
 public AgateLibDisplay()
 {
     this.debugFontSurface = null;
 }
Exemplo n.º 25
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
 }
Exemplo n.º 26
0
 public SimpleUI(Screen s, FontSurface fnt)
 {
     initialScreen = s;
     //   previousScreen = s.Clone();
     currentScreen = s;
     allScreens = new Dictionary<String, Screen>() { { s.title, s } };
     allMenuItems = new List<MenuItem>(s.menu);
     font = fnt;
 }
Exemplo n.º 27
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);
        }
Exemplo n.º 28
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
 }
Exemplo n.º 29
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;
                    }
                }
            }
        }
Exemplo n.º 30
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;
                    }
                }
            }
        }