Exemple #1
0
        private void CreateObject()
        {
            G2DPanel frame = new G2DPanel();

            frame.Bounds          = new Rectangle(0, 0, 800, 600);
            frame.Border          = GoblinEnums.BorderFactory.LineBorder;
            frame.Transparency    = 1.0f; // Ranges from 0 (fully transparent) to 1 (fully opaque)
            frame.BackgroundColor = Color.Black;

            SpriteFont textBoxFont = Content.Load <SpriteFont>("TextBoxFont");
            SpriteFont textFont    = Content.Load <SpriteFont>("TextFont");



            G2DLabel label = new G2DLabel();

            label.TextFont  = textFont;
            label.TextColor = Color.Yellow;
            label.Bounds    = new Rectangle(10, 100, 780, 200);
            label.Text      = "Type Target ID and Press Enter";

            textF           = new G2DTextField();
            textF.TextFont  = textBoxFont;
            textF.TextColor = Color.Black;
            textF.Bounds    = new Rectangle(10, 200, 780, 200);
            textF.Editable  = false;
            textF.Text      = "";


            frame.AddChild(label);
            frame.AddChild(textF);
            scene.UIRenderer.Add2DComponent(frame);
        }
Exemple #2
0
        public void Initialize(Scene scene, ActionPerformed gameListener, ActionPerformed modeListener)
        {
            // Create the main panel which holds all other GUI components
            frame                  = new G2DPanel();
            frame.Bounds           = new Rectangle(30, 305, 480, 280);
            frame.Border           = GoblinEnums.BorderFactory.LineBorder;
            frame.Transparency     = 0.7f; // Ranges from 0 (fully transparent) to 1 (fully opaque)
            frame.TextTransparency = 1.0f;

            uiFont = State.Content.Load <SpriteFont>("UIFont");

            G2DLabel gameLabel = new G2DLabel("Game Mode:");

            gameLabel.TextFont = uiFont;
            gameLabel.Bounds   = new Rectangle(4, 4, 100, 48);

            // Create radio buttons for selecting the game mode
            gameAdd          = new G2DRadioButton("Add");
            gameAdd.TextFont = uiFont;
            gameAdd.Bounds   = new Rectangle(18, 70, 150, 50);
            // Make the Addition mode as the selected one first
            gameAdd.DoClick();

            gameEdit          = new G2DRadioButton("Edit");
            gameEdit.TextFont = uiFont;
            gameEdit.Bounds   = new Rectangle(170, 70, 150, 50);

            gamePlay          = new G2DRadioButton("Play");
            gamePlay.TextFont = uiFont;
            gamePlay.Bounds   = new Rectangle(310, 70, 150, 50);

            ButtonGroup gameGroup = new ButtonGroup();

            gameGroup.Add(gameAdd);
            gameGroup.Add(gameEdit);
            gameGroup.Add(gamePlay);
            gameGroup.AddActionPerformedHandler(gameListener);

            frame.AddChild(gameLabel);
            frame.AddChild(gameAdd);
            frame.AddChild(gameEdit);
            frame.AddChild(gamePlay);

            G2DSeparator separator1 = new G2DSeparator();

            separator1.Bounds = new Rectangle(5, 129, 470, 5);

            frame.AddChild(separator1);

            modeLabel          = new G2DLabel("Add Mode:");
            modeLabel.TextFont = uiFont;
            modeLabel.Bounds   = new Rectangle(4, 140, 100, 48);

            modeRadio1          = new G2DRadioButton("Single");
            modeRadio1.TextFont = uiFont;
            modeRadio1.Bounds   = new Rectangle(20, 206, 200, 50);
            modeRadio1.DoClick();

            modeRadio2          = new G2DRadioButton("Line");
            modeRadio2.TextFont = uiFont;
            modeRadio2.Bounds   = new Rectangle(220, 206, 250, 50);

            ButtonGroup addGroup = new ButtonGroup();

            addGroup.Add(modeRadio1);
            addGroup.Add(modeRadio2);
            addGroup.AddActionPerformedHandler(modeListener);

            frame.AddChild(modeLabel);
            frame.AddChild(modeRadio1);
            frame.AddChild(modeRadio2);

            // Initially, make the GUI panel invisible
            frame.Visible = false;
            frame.Enabled = false;

            scene.UIRenderer.Add2DComponent(frame);
        }
Exemple #3
0
        public void createBuilding2DGUI()
        {
            markerLabels = new List <G2DLabel>();


            // Create the main panel which holds all other GUI components
            buildingInfoPanel        = new G2DPanel();
            buildingInfoPanel.Bounds = new Rectangle(530, 5, 265, 475);
            //frame.Bounds = new Rectangle(615, 350, 170, 220);
            buildingInfoPanel.Border       = GoblinEnums.BorderFactory.LineBorder;
            buildingInfoPanel.Transparency = 0.4f;  // Ranges from 0 (fully transparent) to 1 (fully opaque)

            nameLabel          = new G2DLabel("Name");
            nameLabel.TextFont = uiFont;
            nameLabel.Bounds   = new Rectangle(25, 5, 230, 20);
            nameLabel.Text     = "Name:";
            nameLabel.Visible  = true;

            nameField          = new G2DTextField("Enter text here", 200);
            nameField.TextFont = uiFont;
            nameField.Text     = "Enter text here";
            nameField.SelectAll();
            nameField.Enabled  = false;
            nameField.Editable = false;
            nameField.Bounds   = new Rectangle(25, 25, 230, 20);
            nameField.Visible  = true;
            nameField.setFocused(false);

            addressLabel          = new G2DLabel("Address:");
            addressLabel.TextFont = uiFont;
            addressLabel.Bounds   = new Rectangle(25, 45, 230, 20);
            addressLabel.Text     = "Address:";
            addressLabel.Visible  = true;

            addressField          = new G2DTextField("Enter text here", 200);
            addressField.TextFont = uiFont;
            addressField.Text     = "Enter text here";
            addressField.SelectAll();
            addressField.Enabled  = false;
            addressField.Editable = false;
            addressField.Bounds   = new Rectangle(25, 65, 230, 20);
            addressField.Visible  = true;
            addressField.setFocused(false);

            storiesLabel          = new G2DLabel("Number of Stories:");
            storiesLabel.TextFont = uiFont;
            storiesLabel.Bounds   = new Rectangle(25, 85, 230, 20);
            storiesLabel.Text     = "Number of Stories:";
            storiesLabel.Visible  = true;

            storiesField          = new G2DTextField("Enter text here", 200);
            storiesField.TextFont = uiFont;
            storiesField.Text     = "Enter text here";
            storiesField.SelectAll();
            storiesField.Enabled  = false;
            storiesField.Editable = false;
            storiesField.Bounds   = new Rectangle(25, 105, 230, 20);
            storiesField.Visible  = true;
            storiesField.setFocused(false);

            toxicSitesLabel          = new G2DLabel("Toxic Site Report:");
            toxicSitesLabel.TextFont = uiFont;
            toxicSitesLabel.Bounds   = new Rectangle(25, 125, 230, 20);
            toxicSitesLabel.Text     = "Toxic Site Report:";
            toxicSitesLabel.Visible  = true;

            toxicSitesField          = new G2DTextField("Enter text here", 200);
            toxicSitesField.TextFont = uiFont;
            toxicSitesField.Text     = "Enter text here";
            toxicSitesField.SelectAll();
            toxicSitesField.Enabled  = false;
            toxicSitesField.Editable = false;
            toxicSitesField.Bounds   = new Rectangle(25, 145, 230, 20);
            toxicSitesField.Visible  = true;
            toxicSitesField.setFocused(false);

            airRightsLabel          = new G2DLabel("Air Rights Information:");
            airRightsLabel.TextFont = uiFont;
            airRightsLabel.Bounds   = new Rectangle(25, 165, 230, 20);
            airRightsLabel.Text     = "Air Rights Information:";
            airRightsLabel.Visible  = true;

            airRightsField          = new G2DTextField("Enter text here", 200);
            airRightsField.TextFont = uiFont;
            airRightsField.Text     = "Enter text here";
            airRightsField.SelectAll();
            airRightsField.Enabled  = false;
            airRightsField.Editable = false;
            airRightsField.Bounds   = new Rectangle(25, 185, 230, 20);
            airRightsField.Visible  = true;
            airRightsField.setFocused(false);

            yearBuiltLabel          = new G2DLabel("Year Constructed:");
            yearBuiltLabel.TextFont = uiFont;
            yearBuiltLabel.Bounds   = new Rectangle(25, 205, 230, 20);
            yearBuiltLabel.Text     = "Year Constructed:";
            yearBuiltLabel.Visible  = true;

            yearBuiltField          = new G2DTextField("Enter text here", 200);
            yearBuiltField.TextFont = uiFont;
            yearBuiltField.Text     = "Enter text here";
            yearBuiltField.SelectAll();
            yearBuiltField.Enabled  = false;
            yearBuiltField.Editable = false;
            yearBuiltField.Bounds   = new Rectangle(25, 225, 230, 20);
            yearBuiltField.Visible  = true;
            yearBuiltField.setFocused(false);

            typeLabel          = new G2DLabel("Zone Type:");
            typeLabel.TextFont = uiFont;
            typeLabel.Bounds   = new Rectangle(25, 245, 230, 20);
            typeLabel.Text     = "Zone Type:";
            typeLabel.Visible  = true;

            typeField          = new G2DTextField("Enter text here", 200);
            typeField.TextFont = uiFont;
            typeField.Text     = "Enter text here";
            typeField.SelectAll();
            typeField.Enabled  = false;
            typeField.Editable = false;
            typeField.Bounds   = new Rectangle(25, 265, 230, 20);
            typeField.Visible  = true;
            typeField.setFocused(false);

            classLabel          = new G2DLabel("Building Class:");
            classLabel.TextFont = uiFont;
            classLabel.Bounds   = new Rectangle(25, 285, 230, 20);
            classLabel.Text     = "Building Class:";
            classLabel.Visible  = true;

            classField          = new G2DTextField("Enter text here", 200);
            classField.TextFont = uiFont;
            classField.Text     = "Enter text here";
            classField.SelectAll();
            classField.Enabled  = false;
            classField.Editable = false;
            classField.Bounds   = new Rectangle(25, 305, 230, 20);
            classField.Visible  = true;
            classField.setFocused(false);

            saleDateLabel          = new G2DLabel("Sale Date:");
            saleDateLabel.TextFont = uiFont;
            saleDateLabel.Bounds   = new Rectangle(25, 325, 230, 20);
            saleDateLabel.Text     = "Sale Date:";
            saleDateLabel.Visible  = true;

            saleDateField          = new G2DTextField("Enter text here", 200);
            saleDateField.TextFont = uiFont;
            saleDateField.Text     = "Enter text here";
            saleDateField.SelectAll();
            saleDateField.Enabled  = false;
            saleDateField.Editable = false;
            saleDateField.Bounds   = new Rectangle(25, 345, 230, 20);
            saleDateField.Visible  = true;
            saleDateField.setFocused(false);

            descriptionLabel          = new G2DLabel("Notes:");
            descriptionLabel.TextFont = uiFont;
            descriptionLabel.Bounds   = new Rectangle(25, 365, 230, 20);
            descriptionLabel.Text     = "Notes:";
            descriptionLabel.Visible  = true;

            descriptionField          = new G2DTextField("Enter text here", 200);
            descriptionField.TextFont = uiFont;
            descriptionField.Text     = "Enter text here";
            descriptionField.SelectAll();
            descriptionField.Enabled  = false;
            descriptionField.Editable = false;
            descriptionField.Bounds   = new Rectangle(25, 385, 230, 80);
            descriptionField.Visible  = true;
            descriptionField.setFocused(false);



            /*G2DTextField buildingInfoField = new G2DTextField("Enter text here", 200);
             * buildingInfoField.TextFont = uiFont;
             * buildingInfoField.Text = "Enter text here";
             * buildingInfoField.SelectAll();
             * buildingInfoField.Enabled = true;
             * buildingInfoField.Editable = true;
             * buildingInfoField.Bounds = new Rectangle(5, 25, 230, 90);
             * buildingInfoField.Visible = true;
             * buildingInfoField.setFocused(true);*/



            buildingInfoPanel.AddChild(nameLabel);
            buildingInfoPanel.AddChild(nameField);
            buildingInfoPanel.AddChild(addressLabel);
            buildingInfoPanel.AddChild(addressField);
            buildingInfoPanel.AddChild(storiesLabel);
            buildingInfoPanel.AddChild(storiesField);
            buildingInfoPanel.AddChild(toxicSitesLabel);
            buildingInfoPanel.AddChild(toxicSitesField);
            buildingInfoPanel.AddChild(airRightsLabel);
            buildingInfoPanel.AddChild(airRightsField);
            buildingInfoPanel.AddChild(yearBuiltLabel);
            buildingInfoPanel.AddChild(yearBuiltField);
            buildingInfoPanel.AddChild(typeLabel);
            buildingInfoPanel.AddChild(typeField);
            buildingInfoPanel.AddChild(classLabel);
            buildingInfoPanel.AddChild(classField);
            buildingInfoPanel.AddChild(saleDateLabel);
            buildingInfoPanel.AddChild(saleDateField);
            buildingInfoPanel.AddChild(descriptionLabel);
            buildingInfoPanel.AddChild(descriptionField);

            for (int i = 0; i < 10; i++)
            {
                G2DLabel thisMarkerLabel = new G2DLabel("Marker " + i);
                thisMarkerLabel.TextFont = uiFont;
                thisMarkerLabel.Bounds   = new Rectangle(5, 25 + i * 40, 230, 20);
                thisMarkerLabel.Text     = ">>";
                thisMarkerLabel.Visible  = false;
                markerLabels.Add(thisMarkerLabel);
            }
            for (int i = 0; i < 10; i++)
            {
                markerLabels[i].Visible = false;
                buildingInfoPanel.AddChild(markerLabels[i]);
            }
            scene.UIRenderer.Add2DComponent(buildingInfoPanel);
            buildingInfoPanel.Visible = false;


            // Create an action listener
            //TestActionListener listener = new TestActionListener();
        }
Exemple #4
0
        public void createGradient2DGUI()
        {
            gradientPanel.Bounds       = new Rectangle(5, 495, 173, 100);
            gradientPanel.Border       = GoblinEnums.BorderFactory.LineBorder;
            gradientPanel.Transparency = 0.4f;  // Ranges from 0 (fully transparent) to 1 (fully opaque)

            gradientNameLabel                     = new G2DLabel("Gradient Name");
            gradientNameLabel.TextFont            = uiFont;
            gradientNameLabel.Bounds              = new Rectangle(60, 5, 60, 20);
            gradientNameLabel.Text                = "";
            gradientNameLabel.Visible             = true;
            gradientNameLabel.HorizontalAlignment = GoblinEnums.HorizontalAlignment.Center;

            gradientNameLabel2                     = new G2DLabel("Gradient Name 2");
            gradientNameLabel2.TextFont            = uiFont;
            gradientNameLabel2.Bounds              = new Rectangle(60, 25, 60, 20);
            gradientNameLabel2.Text                = "";
            gradientNameLabel2.Visible             = false;
            gradientNameLabel2.HorizontalAlignment = GoblinEnums.HorizontalAlignment.Center;

            firstGradientLabel                 = new G2DLabel("1st Gradient");
            firstGradientLabel.TextFont        = uiFont;
            firstGradientLabel.Bounds          = new Rectangle(25, 55, 20, 20);
            firstGradientLabel.BackgroundColor = Color.Green;
            firstGradientLabel.DrawBackground  = true;
            firstGradientLabel.Text            = "";
            firstGradientLabel.Visible         = true;

            firstGradientValueLabel                     = new G2DLabel("1st Gradient Value");
            firstGradientValueLabel.TextFont            = uiFont;
            firstGradientValueLabel.Bounds              = new Rectangle(15, 75, 40, 20);
            firstGradientValueLabel.Text                = "";
            firstGradientValueLabel.TextColor           = Color.Green;
            firstGradientValueLabel.Visible             = true;
            firstGradientValueLabel.HorizontalAlignment = GoblinEnums.HorizontalAlignment.Center;

            secondGradientLabel                 = new G2DLabel("1st Gradient");
            secondGradientLabel.TextFont        = uiFont;
            secondGradientLabel.Bounds          = new Rectangle(50, 55, 20, 20);
            secondGradientLabel.BackgroundColor = Color.YellowGreen;
            secondGradientLabel.DrawBackground  = true;
            secondGradientLabel.Text            = "";
            secondGradientLabel.Visible         = true;

            thirdGradientLabel                 = new G2DLabel("1st Gradient");
            thirdGradientLabel.TextFont        = uiFont;
            thirdGradientLabel.Bounds          = new Rectangle(75, 55, 20, 20);
            thirdGradientLabel.BackgroundColor = Color.Yellow;
            thirdGradientLabel.DrawBackground  = true;
            thirdGradientLabel.Text            = "";
            thirdGradientLabel.Visible         = true;

            thirdGradientValueLabel                     = new G2DLabel("1st Gradient Value");
            thirdGradientValueLabel.TextFont            = uiFont;
            thirdGradientValueLabel.Bounds              = new Rectangle(65, 75, 40, 20);
            thirdGradientValueLabel.Text                = "";
            thirdGradientValueLabel.TextColor           = Color.Yellow;
            thirdGradientValueLabel.Visible             = true;
            thirdGradientValueLabel.HorizontalAlignment = GoblinEnums.HorizontalAlignment.Center;

            fourthGradientLabel                 = new G2DLabel("1st Gradient");
            fourthGradientLabel.TextFont        = uiFont;
            fourthGradientLabel.Bounds          = new Rectangle(100, 55, 20, 20);
            fourthGradientLabel.BackgroundColor = Color.Orange;
            fourthGradientLabel.DrawBackground  = true;
            fourthGradientLabel.Text            = "";
            fourthGradientLabel.Visible         = true;

            fifthGradientLabel                 = new G2DLabel("1st Gradient");
            fifthGradientLabel.TextFont        = uiFont;
            fifthGradientLabel.Bounds          = new Rectangle(125, 55, 20, 20);
            fifthGradientLabel.BackgroundColor = Color.Red;
            fifthGradientLabel.DrawBackground  = true;
            fifthGradientLabel.Text            = "";
            fifthGradientLabel.Visible         = true;

            fifthGradientValueLabel                     = new G2DLabel("1st Gradient Value");
            fifthGradientValueLabel.TextFont            = uiFont;
            fifthGradientValueLabel.Bounds              = new Rectangle(115, 75, 40, 20);
            fifthGradientValueLabel.Text                = "";
            fifthGradientValueLabel.TextColor           = Color.Red;
            fifthGradientValueLabel.Visible             = true;
            fifthGradientValueLabel.HorizontalAlignment = GoblinEnums.HorizontalAlignment.Center;

            gradientPanel.AddChild(gradientNameLabel);
            gradientPanel.AddChild(gradientNameLabel2);
            gradientPanel.AddChild(firstGradientLabel);
            gradientPanel.AddChild(secondGradientLabel);
            gradientPanel.AddChild(thirdGradientLabel);
            gradientPanel.AddChild(fourthGradientLabel);
            gradientPanel.AddChild(fifthGradientLabel);
            gradientPanel.AddChild(firstGradientValueLabel);
            gradientPanel.AddChild(thirdGradientValueLabel);
            gradientPanel.AddChild(fifthGradientValueLabel);

            scene.UIRenderer.Add2DComponent(gradientPanel);
            gradientPanel.Visible = false;
        }
Exemple #5
0
        private void Create2DGUI()
        {
            // Create the main panel which holds all other GUI components
            G2DPanel frame = new G2DPanel();

            frame.Bounds       = new Rectangle(325, State.Height - 180, 150, 170);
            frame.Border       = GoblinEnums.BorderFactory.LineBorder;
            frame.Transparency = 0.7f;  // Ranges from 0 (fully transparent) to 1 (fully opaque)

            label = "User Interfaces";

            // Loads the fonts used for rendering UI labels and slider labels
            uiFont     = Content.Load <SpriteFont>("UIFont");
            sliderFont = Content.Load <SpriteFont>("SliderFont");

            // Create four Radio Buttons
            G2DRadioButton radio1 = new G2DRadioButton("User Interfaces");

            radio1.TextFont = uiFont;
            radio1.Bounds   = new Rectangle(10, 5, 80, 20);
            radio1.DoClick(); // make this radio button selected initially
            radio1.ActionPerformedEvent += new ActionPerformed(HandleActionPerformed);

            G2DRadioButton radio2 = new G2DRadioButton("Computer Graphics");

            radio2.TextFont              = uiFont;
            radio2.Bounds                = new Rectangle(10, 25, 80, 20);
            radio2.ActionPerformedEvent += new ActionPerformed(HandleActionPerformed);

            G2DRadioButton radio3 = new G2DRadioButton("Augmented Reality");

            radio3.TextFont              = uiFont;
            radio3.Bounds                = new Rectangle(10, 45, 80, 20);
            radio3.ActionPerformedEvent += new ActionPerformed(HandleActionPerformed);

            sliderRadio                       = new G2DRadioButton("Slider Control");
            sliderRadio.TextFont              = uiFont;
            sliderRadio.Bounds                = new Rectangle(10, 65, 80, 20);
            sliderRadio.ActionPerformedEvent += new ActionPerformed(HandleActionPerformed);

            // Create a slider
            G2DSlider slider = new G2DSlider();

            slider.TextFont           = sliderFont;
            slider.Bounds             = new Rectangle(5, 100, 140, 30);
            slider.Maximum            = 40;
            slider.MajorTickSpacing   = 20;
            slider.MinorTickSpacing   = 5;
            slider.PaintTicks         = true;
            slider.PaintLabels        = true;
            slider.StateChangedEvent += new StateChanged(HandleStateChanged);

            // Create a ButtonGroup object which controls the radio
            // button selections
            ButtonGroup group = new ButtonGroup();

            group.Add(radio1);
            group.Add(radio2);
            group.Add(radio3);
            group.Add(sliderRadio);

            // Create a Button
            G2DButton button = new G2DButton("I Love");

            button.TextFont              = uiFont;
            button.Bounds                = new Rectangle(50, 145, 50, 20);
            button.ActionPerformedEvent += new ActionPerformed(HandleActionPerformed);

            // Add all of the components to the main panel
            frame.AddChild(radio1);
            frame.AddChild(radio2);
            frame.AddChild(radio3);
            frame.AddChild(sliderRadio);
            frame.AddChild(button);
            frame.AddChild(slider);

            scene.UIRenderer.Add2DComponent(frame);
        }