Example #1
0
        ComboBox CreateOptionsBox(string label, string tooltip, FormLayout layout)
        {
            ComboBox box = new ComboBox(GUI, layout)
            {
                ToolTip = tooltip
            };

            box.AddValue(VeryLow);
            box.AddValue(Low);
            box.AddValue(Medium);
            box.AddValue(High);
            box.AddValue(VeryHigh);
            box.CurrentIndex = 2;
            box.CurrentValue = Medium;
            layout.AddItem(label, box);
            return(box);
        }
Example #2
0
        public void CreateGUI()
        {
            Settings = new WorldSettings()
            {
                Width            = 512,
                Height           = 512,
                Name             = GetRandomWorldName(),
                NumCivilizations = 5,
                NumFaults        = 3,
                NumRains         = 1000,
                NumVolcanoes     = 3,
                RainfallScale    = 1.0f,
                SeaLevel         = 0.17f,
                TemperatureScale = 1.0f
            };
            Input = new InputManager();
            GUI   = new DwarfGUI(Game, Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Default),
                                 Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Title),
                                 Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Small),
                                 Input);
            MainPanel = new Panel(GUI, GUI.RootComponent)
            {
                LocalBounds =
                    new Rectangle(128, 64, Game.GraphicsDevice.Viewport.Width - 256,
                                  Game.GraphicsDevice.Viewport.Height - 128)
            };

            Layout = new GridLayout(GUI, MainPanel, 8, 6)
            {
                HeightSizeMode = GUIComponent.SizeMode.Fit,
                WidthSizeMode  = GUIComponent.SizeMode.Fit
            };

            NameLabel = new Label(GUI, Layout, "World Name: ", GUI.DefaultFont);
            Layout.SetComponentPosition(NameLabel, 0, 0, 1, 1);

            NameEdit = new LineEdit(GUI, Layout, Settings.Name);
            Layout.SetComponentPosition(NameEdit, 1, 0, 4, 1);
            NameEdit.OnTextModified += NameEdit_OnTextModified;

            NameRandomButton = new Button(GUI, Layout, "Random", GUI.DefaultFont, Button.ButtonMode.PushButton, null);
            Layout.SetComponentPosition(NameRandomButton, 5, 0, 1, 1);
            NameRandomButton.OnClicked += NameRandomButton_OnClicked;

            OptionsView = new ScrollView(GUI, Layout)
            {
                DrawBorder = true
            };
            Layout.SetComponentPosition(OptionsView, 0, 1, 6, 6);

            OptionsLayout = new FormLayout(GUI, OptionsView)
            {
                WidthSizeMode  = GUIComponent.SizeMode.Fit,
                HeightSizeMode = GUIComponent.SizeMode.Fit
            };

            ComboBox sizeBox = CreateOptionsBox("World Size", "Size of the world to generate", OptionsLayout);

            sizeBox.OnSelectionModified += sizeBox_OnSelectionModified;
            sizeBox.InvokeSelectionModified();

            ComboBox nativeBox = CreateOptionsBox("Natives", "Number of native civilizations", OptionsLayout);

            nativeBox.OnSelectionModified += nativeBox_OnSelectionModified;
            nativeBox.InvokeSelectionModified();

            ComboBox faultBox = CreateOptionsBox("Faults", "Number of straights, seas, etc.", OptionsLayout);

            faultBox.OnSelectionModified += faultBox_OnSelectionModified;
            faultBox.InvokeSelectionModified();

            ComboBox rainBox = CreateOptionsBox("Rainfall", "Amount of moisture in the world.", OptionsLayout);

            rainBox.OnSelectionModified += rainBox_OnSelectionModified;
            rainBox.InvokeSelectionModified();

            ComboBox erosionBox = CreateOptionsBox("Erosion", "More or less eroded landscape.", OptionsLayout);

            erosionBox.OnSelectionModified += erosionBox_OnSelectionModified;
            erosionBox.InvokeSelectionModified();

            ComboBox seaBox = CreateOptionsBox("Sea Level", "Height of the sea.", OptionsLayout);

            seaBox.OnSelectionModified += seaBox_OnSelectionModified;
            seaBox.InvokeSelectionModified();

            ComboBox temp = CreateOptionsBox("Temperature", "Average temperature.", OptionsLayout);

            temp.OnSelectionModified += temp_OnSelectionModified;
            temp.InvokeSelectionModified();

            BackButton = new Button(GUI, Layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow))
            {
                ToolTip = "Back to the main menu."
            };
            Layout.SetComponentPosition(BackButton, 0, 7, 1, 1);
            BackButton.OnClicked += BackButton_OnClicked;

            AcceptButton = new Button(GUI, Layout, "Next", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.RightArrow))
            {
                ToolTip = "Generate a world with these settings"
            };
            AcceptButton.OnClicked += AcceptButton_OnClicked;
            Layout.SetComponentPosition(AcceptButton, 5, 7, 1, 1);
        }
Example #3
0
 ComboBox CreateOptionsBox(string label, string tooltip, FormLayout layout)
 {
     ComboBox box = new ComboBox(GUI, layout)
     {
         ToolTip = tooltip
     };
     box.AddValue(VeryLow);
     box.AddValue(Low);
     box.AddValue(Medium);
     box.AddValue(High);
     box.AddValue(VeryHigh);
     box.CurrentIndex = 2;
     box.CurrentValue = Medium;
     layout.AddItem(label, box);
     return box;
 }
Example #4
0
        public void CreateGUI()
        {
            Settings = new WorldSettings()
            {
                Width = 512,
                Height = 512,
                Name = GetRandomWorldName(),
                NumCivilizations = 5,
                NumFaults = 3,
                NumRains = 1000,
                NumVolcanoes = 3,
                RainfallScale = 1.0f,
                SeaLevel = 0.17f,
                TemperatureScale = 1.0f
            };
            Input = new InputManager();
            GUI = new DwarfGUI(Game, Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Default),
                                      Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Title),
                                      Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Small),
                                      Input);
            MainPanel = new Panel(GUI, GUI.RootComponent)
            {
                LocalBounds =
                    new Rectangle(128, 64, Game.GraphicsDevice.Viewport.Width - 256,
                        Game.GraphicsDevice.Viewport.Height - 128)
            };

            Layout = new GridLayout(GUI, MainPanel, 8, 6)
            {
                HeightSizeMode = GUIComponent.SizeMode.Fit,
                WidthSizeMode = GUIComponent.SizeMode.Fit
            };

            NameLabel = new Label(GUI, Layout, "World Name: ", GUI.DefaultFont);
            Layout.SetComponentPosition(NameLabel, 0, 0, 1, 1);

            NameEdit = new LineEdit(GUI, Layout, Settings.Name);
            Layout.SetComponentPosition(NameEdit, 1, 0, 4, 1);
            NameEdit.OnTextModified += NameEdit_OnTextModified;

            NameRandomButton = new Button(GUI, Layout, "Random", GUI.DefaultFont, Button.ButtonMode.PushButton, null);
            Layout.SetComponentPosition(NameRandomButton, 5, 0, 1, 1);
            NameRandomButton.OnClicked += NameRandomButton_OnClicked;

            OptionsView = new ScrollView(GUI, Layout)
            {
                DrawBorder = true
            };
            Layout.SetComponentPosition(OptionsView, 0, 1, 6, 6);

            OptionsLayout = new FormLayout(GUI, OptionsView)
            {
                WidthSizeMode = GUIComponent.SizeMode.Fit,
                HeightSizeMode = GUIComponent.SizeMode.Fit
            };

            ComboBox sizeBox = CreateOptionsBox("World Size", "Size of the world to generate", OptionsLayout);
            sizeBox.OnSelectionModified += sizeBox_OnSelectionModified;
            sizeBox.InvokeSelectionModified();

            ComboBox nativeBox = CreateOptionsBox("Natives", "Number of native civilizations", OptionsLayout);
            nativeBox.OnSelectionModified += nativeBox_OnSelectionModified;
            nativeBox.InvokeSelectionModified();

            ComboBox faultBox = CreateOptionsBox("Faults",  "Number of straights, seas, etc.", OptionsLayout);
            faultBox.OnSelectionModified += faultBox_OnSelectionModified;
            faultBox.InvokeSelectionModified();

            ComboBox rainBox = CreateOptionsBox("Rainfall", "Amount of moisture in the world.", OptionsLayout);
            rainBox.OnSelectionModified += rainBox_OnSelectionModified;
            rainBox.InvokeSelectionModified();

            ComboBox erosionBox = CreateOptionsBox("Erosion", "More or less eroded landscape.", OptionsLayout);
            erosionBox.OnSelectionModified += erosionBox_OnSelectionModified;
            erosionBox.InvokeSelectionModified();

            ComboBox seaBox = CreateOptionsBox("Sea Level", "Height of the sea.", OptionsLayout);
            seaBox.OnSelectionModified += seaBox_OnSelectionModified;
            seaBox.InvokeSelectionModified();

            ComboBox temp = CreateOptionsBox("Temperature", "Average temperature.", OptionsLayout);
            temp.OnSelectionModified += temp_OnSelectionModified;
            temp.InvokeSelectionModified();

            BackButton = new Button(GUI, Layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow))
            {
                ToolTip = "Back to the main menu."
            };
            Layout.SetComponentPosition(BackButton, 0, 7, 1, 1);
            BackButton.OnClicked += BackButton_OnClicked;

            AcceptButton = new Button(GUI, Layout, "Next", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.RightArrow))
            {
                ToolTip = "Generate a world with these settings"
            };
            AcceptButton.OnClicked += AcceptButton_OnClicked;
            Layout.SetComponentPosition(AcceptButton, 5, 7, 1, 1);
        }