Inheritance: XGControl
Example #1
0
        public frmSettings(AzmythGame game, GraphicsDeviceManager graphics)
            : base(new Rectangle(0, 0, 300, 300), true)
        {
            Game = game;
            m_graphicsManager = graphics;

            Rectangle = new Rectangle((game.GraphicsDevice.Viewport.Width / 2)-150, (game.GraphicsDevice.Viewport.Height / 2) - 120, 300, 240);

            XnaGUIManager.Controls.Add(this);

            pnlMain = new XGPanel(new Rectangle(0, 0, 300, 240));
            lstResolutions = new XGListBox(new Rectangle(10, 10, 280, 150));

            foreach (DisplayMode mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
            {
                if(mode.Width >= 800 && mode.Height >=600)
                lstResolutions.Items.Add(mode.Width + " x " + mode.Height);
            }

            lstResolutions.SelectedIndex = 0;
            chkFullScreen = new XGCheckBox(new Rectangle(10, 170, 25, 25), "Fullscreen");
            chkFullScreen.Checked = false;

            btnApply = new XGButton(new Rectangle(300-220, 200, 100, 30), "Apply", this.btnApply_Clicked);
            btnExit = new XGButton(new Rectangle(300-110, 200, 100, 30), "Exit", this.btnExit_Clicked);

            Children.Add(pnlMain);
            pnlMain.Children.Add(lstResolutions);
            pnlMain.Children.Add(chkFullScreen);
            pnlMain.Children.Add(btnApply);
            pnlMain.Children.Add(btnExit);
        }
Example #2
0
        public frmCreateWorld(AzmythGame game)
            : base(new Rectangle(0, 0, 300, 300), true)
        {
            Game = game;
            m_viewport = game.GraphicsDevice.Viewport;

            Rectangle = new Rectangle(0, 0, m_viewport.Width, m_viewport.Height);

            m_world = new World(new VectorID(1, 1), new Random().Next(500, 9999));

            XnaGUIManager.Controls.Add(this);

            pnlMain             = new XGPanel(        new Rectangle(20, 20, 600, 600));
            pnlTitle            = new XGPanel(        new Rectangle(20, 20, 600, 600));
            lblTitle            = new XGLabel(        new Rectangle(20, 30, 50, 30), "Generate a New Adventure");
            lblSeed             = new XGLabel(        new Rectangle(20, 40, 50, 30), "Seed:");
            txtSeed             = new XGTextBox(      new Rectangle(80, 40, 100, 30));
            btnRandomSeed       = new XGButton(       new Rectangle(190, 40, 125, 30), "Random Seed", this.btnRandomSeed_Clicked);
            lblWorldName        = new XGLabel(        new Rectangle(20, 20, 100, 30), "Name:");
            txtWorldName        = new XGTextBox(      new Rectangle(140, 20, pnlMain.Rectangle.Width- 300 , 30));
            btnRandomName       = new XGButton(       new Rectangle(pnlMain.Rectangle.Width, 20, 125, 30), "Random Name", this.btnRandomName_Clicked);
            lblTerrainNoise     = new XGLabel(        new Rectangle(20, 80, 200, 30), "Terrain Noise");
            lstTerrainNoise     = new XGListBox(      new Rectangle(20, 110, 200, 60));
            lblRiverNoise       = new XGLabel(        new Rectangle(250, 80, 200, 30), "River Noise");
            lstRiverNoise       = new XGListBox(      new Rectangle(250, 110, 200, 60));
            lblCharacteristics  = new XGLabel(        new Rectangle(20, 180, 150, 30), "Terrain Characteristics");
            sldContinentSize    = new XGLabeledSlider(new Rectangle(20, 210, 425, 30), 150, "Continent Size", 2, ((0.1f-m_world.ContinentSize) * 100), 0, 10);
            sldCoastLine        = new XGLabeledSlider(new Rectangle(20, 240, 425, 30), 150, "Coast Line", 2, m_world.CoastLine, m_world.TerrainHeight * -1, m_world.TerrainHeight);
            sldShoreLine        = new XGLabeledSlider(new Rectangle(20, 270, 425, 30), 150, "Shore Line", 2, m_world.ShoreLine * 100, 1, 100);
            sldTreeLine         = new XGLabeledSlider(new Rectangle(20, 300, 425, 30), 150, "Tree Line", 2, m_world.TreeLine * 100, 2, 100);
            mapMiniMap          = new XGMiniMap(      new Rectangle(0, 0, 100, 100), m_world, 3);
            btnCreateWorld      = new XGButton(       new Rectangle(m_viewport.Width - 210, m_viewport.Height - 40, 200, 30), "Create World", this.btnCreateWorld_Clicked);

            sldContinentSize.ValueLabelFormat = "0";
            sldCoastLine.ValueLabelFormat = "0";
            sldShoreLine.ValueLabelFormat = "0";
            sldTreeLine.ValueLabelFormat = "0";

            pnlMain.CanFocus = false;
            lblWorldName.CanFocus = false;
            lblCharacteristics.CanFocus = false;
            mapMiniMap.CanFocus = false;

            nameGenerator = new MarkovNameGenerator("Acalia,Aldaire,Aldebron,Vulcan,Earth,Romulus,Andor,Adair,Adara,Adriel,Alaire,Alixandra,Altair,Amara,Anatola,Arcadia,Aurelia,Aurelian,Aurelius,Avalon,Bastian,Breen,Briallan,Brielle,Briseis,Cambria,Caspian,Cassia,Cassiel,Cassiopeia,Cassius,Chaniel,Cora,Corbin,Cyprian,Dagen,Daire,Darius,Destin,Devlin,Devlyn,Drake,Drystan,Eira,Eirian,Eliron,Elysia,Eoin,Evadne,Evanth,Fineas,Finian,Fyodor,Gaerwn,Gareth,Gavriel,Ginerva,Griffin,Guinevere,Hadriel,Hannelore,Hermione,Hesperos,Iagan,Ianthe,Ignacia,Ignatius,Iseult,Isolde,Jessalyn,Kara,Katriel,Kerensa,Korbin,Kyler,Kyra,Kyrielle,Leala,Leila,Leira,Lilith,Liora,Liriene,Liron,Lucien,Lyra,Maia,Marius,Mathieu,Maylea,Meira,Mireille,Mireya,Natania,Neirin,Nerys,Nuriel,Nyfain,Nyssa,Oisin,Oleisa,Oralie,Orinthea,Orion,Orpheus,Ozara,Peregrine,Persephone,Perseus,Petronela,Phelan,Pryderi,Pyralia,Pyralis,Qadira,Quinevere,Quintessa,Raisa,Remus,Renfrew,Rhyan,Rhydderch,Riona,Saira,Saoirse,Sarai,Sarielle,Sebastian,Seraphim,Seraphina,Serian,Sirius,Sorcha,Severin,Tavish,Tearlach,Terra,Thalia,Thaniel,Theia,Torian,Torin,Tressa,Tristana,Ulyssia,Uriela,Urien,Vanora,Vasilis,Vespera,Xanthus,Xara,Xylia,Yadira,Yakira,Yeira,Yeriel,Yestin,Yseult,Zaira,Zaniel,Zarek,Zephyr,Zora,Zorion".Split(','), 3);

            txtSeed.Text = m_world.Seed.ToString();
            lblTitle.Alignment = GUIAlignment.HCenter | GUIAlignment.VCenter;
            txtWorldName.Text = Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(nameGenerator.Next());

            lstTerrainNoise.Items.Add(liAzmyth);
            lstTerrainNoise.Items.Add(liPerlin);
            lstTerrainNoise.Items.Add(liSimplex);

            lstTerrainNoise.SelectedIndex = 0;

            lstRiverNoise.Items.Add(liAzmyth);
            lstRiverNoise.Items.Add(liPerlin);
            lstRiverNoise.Items.Add(liSimplex);

            lstRiverNoise.SelectedIndex = 0;

            Children.Add(pnlMain);
            Children.Add(pnlTitle);
            pnlTitle.Children.Add(lblTitle);
            pnlMain.Children.Add(lblSeed);
            pnlMain.Children.Add(txtSeed);
            pnlMain.Children.Add(btnRandomSeed);
            pnlMain.Children.Add(lblWorldName);
            pnlMain.Children.Add(txtWorldName);
            pnlMain.Children.Add(btnRandomName);
            pnlMain.Children.Add(lblCharacteristics);
            pnlMain.Children.Add(sldContinentSize);
            pnlMain.Children.Add(sldCoastLine);
            pnlMain.Children.Add(sldShoreLine);
            pnlMain.Children.Add(sldTreeLine);
            pnlMain.Children.Add(lblTerrainNoise);
            pnlMain.Children.Add(lstTerrainNoise);
            pnlMain.Children.Add(lblRiverNoise);
            pnlMain.Children.Add(lstRiverNoise);
            pnlMain.Children.Add(mapMiniMap);
            pnlMain.Children.Add(btnCreateWorld);

            focusControl = pnlMain;

            pnlMain.ActivateFirst();

            XnaGUIManager.ActivateNext();
        }