Esempio n. 1
0
        public static void SyncPlanetItemControl(
            GameSession game,
            string panelName,
            OrbitalObjectInfo orbital)
        {
            PlanetInfo planetInfo = game.GameDatabase.GetPlanetInfo(orbital.ID);

            if (planetInfo == null)
            {
                return;
            }
            game.GameDatabase.GetMoons(orbital.ID);
            string        propertyValue        = App.Localize("@UI_PLANET_TYPE_" + planetInfo.Type.ToUpperInvariant());
            Vector4       color                = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
            AIColonyIntel colonyIntelForPlanet = game.GameDatabase.GetColonyIntelForPlanet(game.LocalPlayer.ID, planetInfo.ID);

            if (colonyIntelForPlanet != null)
            {
                PlayerInfo playerInfo = game.GameDatabase.GetPlayerInfo(colonyIntelForPlanet.OwningPlayerID);
                color.X = playerInfo.PrimaryColor.X * (float)byte.MaxValue;
                color.Y = playerInfo.PrimaryColor.Y * (float)byte.MaxValue;
                color.Z = playerInfo.PrimaryColor.Z * (float)byte.MaxValue;
                color.W = (float)byte.MaxValue;
            }
            game.UI.AddItem(panelName, string.Empty, orbital.ID, string.Empty);
            string itemGlobalId = game.UI.GetItemGlobalID(panelName, string.Empty, orbital.ID, string.Empty);
            string panelId      = game.UI.Path(itemGlobalId, "expand_button");

            game.UI.SetVisible(panelId, false);
            bool flag = game.GameDatabase.CanColonizePlanet(game.LocalPlayer.ID, planetInfo.ID, game.GameDatabase.GetStratModifier <int>(StratModifiers.MaxColonizableHazard, game.LocalPlayer.ID)) || colonyIntelForPlanet != null && colonyIntelForPlanet.PlayerID == game.LocalPlayer.ID;

            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_idle.idle.h_good"), (flag ? 1 : 0) != 0);
            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_idle.idle.h_bad"), (!flag ? 1 : 0) != 0);
            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_idle.mouse_over.h_good"), (flag ? 1 : 0) != 0);
            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_idle.mouse_over.h_bad"), (!flag ? 1 : 0) != 0);
            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_sel.idle.h_good"), (flag ? 1 : 0) != 0);
            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_sel.idle.h_bad"), (!flag ? 1 : 0) != 0);
            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_sel.mouse_over.h_good"), (flag ? 1 : 0) != 0);
            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_sel.mouse_over.h_bad"), (!flag ? 1 : 0) != 0);
            FleetUI.SyncSelectablePlanetListControl(game, itemGlobalId, "header_idle.idle", orbital.Name, color, false);
            FleetUI.SyncSelectablePlanetListControl(game, itemGlobalId, "header_idle.mouse_over", orbital.Name, color, false);
            FleetUI.SyncSelectablePlanetListControl(game, itemGlobalId, "header_sel.idle", orbital.Name, color, true);
            FleetUI.SyncSelectablePlanetListControl(game, itemGlobalId, "header_sel.mouse_over", orbital.Name, color, true);
            game.UI.SetPropertyString(game.UI.Path(itemGlobalId, "planetItemPlanetType"), "text", propertyValue);
            game.UI.AutoSize(game.UI.Path(itemGlobalId, "expanded"));
        }
Esempio n. 2
0
        public static void SyncPlanetListControl(
            GameSession game,
            string panelName,
            int systemId,
            IEnumerable <int> orbitalObjects)
        {
            bool flag = game.GameDatabase.IsSurveyed(game.LocalPlayer.ID, systemId);

            game.UI.ClearItems(panelName);
            List <OrbitalObjectInfo> list        = game.GameDatabase.GetStarSystemOrbitalObjectInfos(systemId).ToList <OrbitalObjectInfo>();
            Dictionary <int, float>  DistanceMap = new Dictionary <int, float>();

            foreach (OrbitalObjectInfo orbitalObjectInfo in list)
            {
                DistanceMap.Add(orbitalObjectInfo.ID, orbitalObjectInfo.OrbitalPath.Scale.Y);
            }
            list.Sort((Comparison <OrbitalObjectInfo>)((x, y) =>
            {
                int num = (x.ParentID.HasValue ? DistanceMap[x.ParentID.Value] : x.OrbitalPath.Scale.Y).CompareTo(y.ParentID.HasValue ? DistanceMap[y.ParentID.Value] : y.OrbitalPath.Scale.Y);
                if (num == 0)
                {
                    if (x.ParentID.HasValue && y.ParentID.HasValue)
                    {
                        return(x.OrbitalPath.Scale.Y.CompareTo(y.OrbitalPath.Scale.Y));
                    }
                    if (x.ParentID.HasValue)
                    {
                        return(1);
                    }
                    if (y.ParentID.HasValue)
                    {
                        return(-1);
                    }
                }
                return(num);
            }));
            if (orbitalObjects.Contains <int>(FleetUI.StarItemID))
            {
                Vector4        color          = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
                StarSystemInfo starSystemInfo = game.GameDatabase.GetStarSystemInfo(systemId);
                game.UI.AddItem(panelName, string.Empty, FleetUI.StarItemID, string.Empty);
                string itemGlobalId = game.UI.GetItemGlobalID(panelName, string.Empty, FleetUI.StarItemID, string.Empty);
                FleetUI.SyncSelectablePlanetListControl(game, itemGlobalId, "header_idle.idle", starSystemInfo.Name, color, false);
                FleetUI.SyncSelectablePlanetListControl(game, itemGlobalId, "header_idle.mouse_over", starSystemInfo.Name, color, false);
                FleetUI.SyncSelectablePlanetListControl(game, itemGlobalId, "header_sel.idle", starSystemInfo.Name, color, true);
                FleetUI.SyncSelectablePlanetListControl(game, itemGlobalId, "header_sel.mouse_over", starSystemInfo.Name, color, true);
                string panelId = game.UI.Path(panelName, itemGlobalId, "expand_button");
                game.UI.SetVisible(panelId, false);
            }
            if (flag)
            {
                foreach (OrbitalObjectInfo orbital in list)
                {
                    if (orbital.ID != FleetUI.StarItemID && orbitalObjects.Contains <int>(orbital.ID))
                    {
                        FleetUI.SyncPlanetItemControl(game, panelName, orbital);
                    }
                }
            }
            game.UI.AutoSize(panelName);
        }