public static void ClearSelected(GUI_Base root)
        {
            int i = 0;

            XNA_GUI.GUIElements.GUI_Base slider = null;
            string test = string.Format(c_sliderName, i);

            if (test == null)
            {
                return;
            }
            while ((slider = root.GetChildByName(string.Format(c_sliderName, i))) != null)
            {
                root.RemoveChild(slider);
                GUI_Base cancelButton = root.GetChildByName(string.Format("Cancel Button {0}", i));
                root.RemoveChild(cancelButton);
                GUI_Base name = root.GetChildByName(string.Format("Label {0}", i));
                root.RemoveChild(name);

                i++;
            }

            s_root = null;

            TextLabel planetName   = (TextLabel)root.GetChildByName("Planet Name");
            TextLabel defenseLabel = (TextLabel)root.GetChildByName("Defense Fleets");
            TextLabel production   = (TextLabel)root.GetChildByName("Production");

            planetName.DisplayText   = "No Planet Selected";
            defenseLabel.DisplayText = "No Planet";
            production.DisplayText   = "Production: No Planet";
            s_previousSelected       = null;
        }
        public static void RemoveSingeRoute(int dispatchIndex)
        {
            GUI_Base slider = s_root.GetChildByName(string.Format("Deployment Route {0}", dispatchIndex));

            s_root.RemoveChild(slider);
            slider = null;
            GUI_Base cancelButton = s_root.GetChildByName(string.Format("Cancel Button {0}", dispatchIndex));

            s_root.RemoveChild(cancelButton);
            cancelButton = null;
            GUI_Base name = s_root.GetChildByName(string.Format("Label {0}", dispatchIndex));

            s_root.RemoveChild(name);
            name = null;

            dispatchIndex++;
            SliderBar s = null;

            while ((s = (SliderBar)s_root.GetChildByName(string.Format("Deployment Route {0}", dispatchIndex))) != null)
            {
                s.ControlName = string.Format("Deployment Route {0}", dispatchIndex - 1);
                GUI_Base button = s_root.GetChildByName(string.Format("Cancel Button {0}", dispatchIndex));
                button.ControlName = string.Format("Cancel Button {0}", dispatchIndex - 1);
                GUI_Base label = s_root.GetChildByName(string.Format("Label {0}", dispatchIndex));
                label.ControlName = string.Format("Label {0}", dispatchIndex - 1);
                dispatchIndex++;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Unload your graphics content.  If unloadAllContent is true, you should
        /// unload content from both ResourceManagementMode pools.  Otherwise, just
        /// unload ResourceManagementMode.Manual content.  Manual content will get
        /// Disposed by the GraphicsDevice during a Reset.
        /// </summary>
        /// <param name="unloadAllContent">Which type of content to unload.</param>
        protected override void UnloadGraphicsContent(bool unloadAllContent)
        {
            if (unloadAllContent)
            {
                // TODO: Unload any ResourceManagementMode.Automatic content
                content.Unload();
            }

            // TODO: Unload any ResourceManagementMode.Manual content
            GUI_Base.DeviceLost();
            BaseEntity.DeviceLost();
        }
Beispiel #4
0
        /// <summary>
        /// Load your graphics content.  If loadAllContent is true, you should
        /// load content from both ResourceManagementMode pools.  Otherwise, just
        /// load ResourceManagementMode.Manual content.
        /// </summary>
        /// <param name="loadAllContent">Which type of content to load.</param>
        protected override void LoadGraphicsContent(bool loadAllContent)
        {
            graphics.PreferMultiSampling = true;
            if (loadAllContent)
            {
                GUI_Base.Initialize(graphics, content, @".\GUIResources\");
                BaseEntity.Initalize(content, graphics.GraphicsDevice, @".\");
            }

            // TODO: Load any ResourceManagementMode.Manual content

            currentState = GameState.MainMenu;
            GUI_Base.DeviceReset(graphics, content);
            BaseEntity.DeviceReset(graphics.GraphicsDevice, content);
        }
        public static void MakeSelected(Planet picked, GUI_Base root, Player viewing)
        {
            //If required, remove the existing routes.
            //this only happens when we move from one planet selected to another.
            if (s_previousSelected != null)
            {
                ClearSelected(root);
            }
            s_root             = root;
            s_previousSelected = picked;

            //How much information is the player going to be able to see?
            bool playerControledPlanet = viewing.ControlsPlanet(picked);
            bool visibleToPlayer;

            if (playerControledPlanet == true)
            {
                visibleToPlayer = true;
            }
            else
            {
                visibleToPlayer = viewing.CanSeePlanet(picked);
            }

            TextLabel planetName   = (TextLabel)root.GetChildByName("Planet Name");
            TextLabel defenseLabel = (TextLabel)root.GetChildByName("Defense Fleets");
            TextLabel production   = (TextLabel)root.GetChildByName("Production");

            planetName.DisplayText   = picked.Name;
            defenseLabel.DisplayText = "Deffense Fleets: " + picked.DefenseFleets.ToString();

            if (visibleToPlayer == true)
            {
                production.DisplayText = string.Format("Production: {0} per min", (int)picked.Production);
            }
            else
            {
                production.DisplayText = "No Data Available";
            }

            if (playerControledPlanet == true)
            {
                List <float> depolymentRates = picked.DispatchRates;
                for (int i = 0; i < depolymentRates.Count; i++)
                {
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(string.Format(c_sliderXMLTemplate, i, 40 + (c_SliderSpacingPercent * i), (int)(100 * depolymentRates[i])));
                    SliderBar s = new SliderBar(doc.GetElementsByTagName("ScrollBar")[0], root, null);
                    root.AddChild(s);
                    if (i != 0)
                    {
                        doc.LoadXml(string.Format(c_cancelRouteButton, i, 40 + (c_SliderSpacingPercent * i)));
                        Button b = new Button(doc.GetElementsByTagName("Button")[0], root, picked);
                        root.AddChild(b);

                        doc.LoadXml(string.Format(c_TestLabel, i, 40 + (c_SliderSpacingPercent * i) - 3, picked.DeploymentRoutes[i - 1].Desitnation.Name));
                        TextLabel label = new TextLabel(doc.GetElementsByTagName("TextLabel")[0], root, null);
                        root.AddChild(label);
                    }
                }
            }
        }