Exemplo n.º 1
0
        public SpinBox(DwarfGUI gui, GUIComponent parent, string label, float value, float minValue, float maxValue, SpinMode mode)
            : base(gui, parent)
        {
            Increment = 1.0f;
            SpinValue = value;
            MinValue = minValue;
            MaxValue = maxValue;
            Mode = mode;
            Layout = new GridLayout(GUI, this, 1, 4);
            PlusButton = new Button(GUI, Layout, "", GUI.DefaultFont, Button.ButtonMode.ImageButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomIn))
            {
                KeepAspectRatio = true,
                DontMakeSmaller = true
            };
            MinusButton = new Button(GUI, Layout, "", GUI.DefaultFont, Button.ButtonMode.ImageButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomOut))
            {
                KeepAspectRatio = true,
                DontMakeSmaller = true
            };
            ValueBox = new LineEdit(GUI, Layout, value.ToString())
            {
                IsEditable = false
            };
            Layout.SetComponentPosition(ValueBox, 0, 0, 2, 1);
            Layout.SetComponentPosition(PlusButton, 3, 0, 1, 1);
            Layout.SetComponentPosition(MinusButton, 2, 0, 1, 1);

            PlusButton.OnClicked += PlusButton_OnClicked;
            MinusButton.OnClicked += MinusButton_OnClicked;
            OnValueChanged += SpinBox_OnValueChanged;
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
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);
        }