public override void GetTextToShow(ArcenDoubleCharacterBuffer buffer)
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalPlayerSide();

                if (localSide == null)
                {
                    return;
                }
                buffer.Add("<sprite name=\"Metal\">");
                buffer.Add(localSide.StoredMetal.IntValue.ToString("#,##0"));

                if (localSide.LastFrame_TotalMetalFlowRequested > 0)
                {
                    buffer.Add("   (");
                    int amountSpentLastFrame = localSide.LastFrame_MetalSpent.IntValue;
                    int incomeLastFrame      = localSide.LastFrame_MetalProduced.GetNearestIntPreferringHigher();
                    int netIncome            = incomeLastFrame - amountSpentLastFrame;
                    if (netIncome > 0)
                    {
                        buffer.Add("+");
                    }
                    buffer.Add(netIncome);
                    buffer.Add(" net)");
                    if (localSide.LastFrame_MetalFlowRequestPortionMet < FInt.One &&
                        localSide.LastFrame_MetalProduced > FInt.Zero)
                    {
                        buffer.Add(" (");
                        int framesLeft  = (localSide.LastFrame_TotalMetalFlowProjectedRequests / localSide.LastFrame_MetalProduced).GetNearestIntPreferringHigher();
                        int secondsLeft = (framesLeft * World_AIW2.Instance.SimulationProfile.SecondsPerFrameSim).GetNearestIntPreferringHigher();
                        buffer.Add(Engine_Universal.ToHoursAndMinutesString(secondsLeft));
                        buffer.Add(" est)");   //estimated time left
                        buffer.Add("\n required: ").Add(localSide.LastFrame_TotalMetalFlowProjectedRequests.IntValue).Add("\nproduced: ").Add(localSide.LastFrame_MetalProduced.GetNearestIntPreferringHigher());
                    }
                }
            }
            public override void GetTextToShow(ArcenDoubleCharacterBuffer Buffer)
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalPlayerSide();

                if (localSide == null)
                {
                    return;
                }
                Buffer.Add("<sprite name=\"Hacking\">").Add(localSide.StoredHacking.IntValue.ToString("#,##0"));
                GameEntity hacker = localSide.Entities.GetFirstMatching(EntityRollupType.KingUnits);

                if (hacker == null || hacker.ActiveHack == null)
                {
                    return;
                }
                GameEntity target = World_AIW2.Instance.GetEntityByID(hacker.ActiveHack_Target);

                if (target == null)
                {
                    return;
                }
                int secondsSoFar  = hacker.ActiveHack_DurationThusFar;
                int totalDuration = hacker.ActiveHack.Implementation.GetTotalSecondsToHack(target, hacker);
                int secondsLeft   = totalDuration - secondsSoFar;

                Buffer.Add("\n").Add(Engine_Universal.ToHoursAndMinutesString(secondsLeft));
            }
 public override void GetTextToShow(ArcenDoubleCharacterBuffer buffer)
 {
     if (!Engine_Universal.DebugOutputOn)
     {
         return;
     }
     World_AIW2.Instance.DoForSides(delegate(WorldSide side)
     {
         if (side.Type != WorldSideType.AI)
         {
             return(DelReturn.Continue);
         }
         FInt threshold = side.GetSpecificBudgetThreshold(AIBudgetType.CPA);
         FInt perSecond = side.GetSpecificBudgetStrengthGainPerSecond(AIBudgetType.CPA);
         if (perSecond <= FInt.Zero)
         {
             return(DelReturn.Continue);
         }
         FInt currentAmount = side.StoredStrengthByBudget[AIBudgetType.CPA];
         FInt amountLeft    = threshold - currentAmount;
         FInt secondsLeft   = amountLeft / perSecond;
         buffer.Add("Next CPA in ");
         buffer.Add(Engine_Universal.ToHoursAndMinutesString(secondsLeft.IntValue));
         buffer.Add(" (").Add(currentAmount.ReadableString).Add("/").Add(threshold.ReadableString).Add(")");
         return(DelReturn.Break);
     });
 }
            public override void GetTextToShow(ArcenDoubleCharacterBuffer buffer)
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalSide();

                if (localSide == null)
                {
                    return;
                }
                buffer.Add("Metal: ");
                buffer.Add(localSide.StoredMetal.IntValue.ToString("#,##0"));
                if (localSide.LastFrame_TotalMetalFlowRequested > 0)
                {
                    buffer.Add("\n");
                    FInt percentProduced = localSide.LastFrame_MetalFlowRequestPortionMet * 100;
                    buffer.Add(percentProduced.IntValue);
                    buffer.Add("%");
                    if (localSide.LastFrame_MetalFlowRequestPortionMet < FInt.One &&
                        localSide.LastFrame_MetalProduced > FInt.Zero)
                    {
                        buffer.Add(" (");
                        int framesLeft  = (localSide.LastFrame_TotalMetalFlowProjectedRequests / localSide.LastFrame_MetalProduced).GetNearestIntPreferringHigher();
                        int secondsLeft = (framesLeft * World_AIW2.Instance.SimulationProfile.SecondsPerFrameSim).GetNearestIntPreferringHigher();
                        buffer.Add(Engine_Universal.ToHoursAndMinutesString(secondsLeft));
                        buffer.Add(")");
                        buffer.Add("\n").Add(localSide.LastFrame_TotalMetalFlowProjectedRequests.IntValue).Add(" / ").Add(localSide.LastFrame_MetalProduced.ReadableString);
                    }
                }
            }
            public override void GetTextToShow(ArcenDoubleCharacterBuffer buffer)
            {
                base.GetTextToShow(buffer);

                buffer.Add(SaveGame.saveName);
                buffer.Add("\n In Game Time : ");
                buffer.Add(Engine_Universal.ToHoursAndMinutesString(SaveGame.secondsSinceGameStart));
            }
Example #6
0
            public override void HandleClick()
            {
                string path = Engine_Universal.CurrentPlayerDataDirectory + "Save/" + this.SaveName + Engine_Universal.SaveExtension;

                if (!File.Exists(path))
                {
                    return;
                }
                Engine_Universal.LoadGame(this.SaveName);
                Instance.Close();
            }
            public override void GetTextToShow(ArcenDoubleCharacterBuffer buffer)
            {
                base.GetTextToShow(buffer);
                buffer.Add(SaveGame.campaignName);
                buffer.Add("\n Map: ");
                buffer.Add(SaveGame.mapType);

                buffer.Add("\n");
                buffer.Add(SaveGame.difficulty);
                buffer.Add(" / ");
                buffer.Add(SaveGame.masterAIType);

                buffer.Add("\n ElapsedTime: ");
                buffer.Add(Engine_Universal.ToHoursAndMinutesString(SaveGame.secondsSinceGameStart));
                buffer.Add("\n ");
                buffer.Add(SaveGame.lastModified.ToString());
            }
            public override MouseHandlingResult HandleClick()
            {
                bool   debug       = false;
                string SaveName    = this.SaveGame.ToString();
                string oldSaveName = this.SaveGame.saveName;
                string path        = Engine_Universal.CurrentPlayerDataDirectory + "Save/" + SaveName + Engine_Universal.SaveExtension;
                string oldPath     = Engine_Universal.CurrentPlayerDataDirectory + "Save/" + oldSaveName + Engine_Universal.SaveExtension;

                //if ( path.Contains( " " ) )
                //{
                //    path = "\"" + path + "\"";
                //}
                if (debug)
                {
                    ArcenDebugging.ArcenDebugLogSingleLine("Trying to load from " + path, Verbosity.DoNotShow);
                }
                if (File.Exists(path))
                {
                    SFXItemTable.TryPlayItemByName_GUIOnly("ButtonStartGame");
                    Window_SaveGameMenu.Instance.OverallCampaignName = this.SaveGame.campaignName;
                    Engine_Universal.LoadGame(SaveName);
                    Instance.Close();
                }
                else if (File.Exists(oldPath))
                {
                    SFXItemTable.TryPlayItemByName_GUIOnly("ButtonStartGame");
                    Window_SaveGameMenu.Instance.OverallCampaignName = this.SaveGame.campaignName;
                    Engine_Universal.LoadGame(oldSaveName);
                    Instance.Close();
                }
                else
                {
                    ArcenDebugging.ArcenDebugLogSingleLine("File does not exist" + Environment.NewLine + "path=" + path + Environment.NewLine + "oldPath=" + oldPath, Verbosity.DoNotShow);
                    return(MouseHandlingResult.PlayClickDeniedSound);
                }
                return(MouseHandlingResult.DoNotPlayClickSound);
            }
 public override void GetTextToShow(ArcenDoubleCharacterBuffer Buffer)
 {
     Buffer.Add("Time:");
     Buffer.Add(Engine_Universal.ToHoursAndMinutesString(World_AIW2.Instance.GameSecond));
 }
        public static void HandleInner(Int32 Int1, string InputActionInternalName)
        {
            if (ArcenUI.Instance.ShowingConsole)
            {
                return;
            }
            switch (InputActionInternalName)
            {
                #region Development Tools
            case "DebugGenerateMap":
                if (World.Instance.IsLoaded)
                {
                    return;
                }
                ArcenSocket.Instance.Shutdown();
                Engine_AIW2.Instance.InnerDoStartNewWorldOKLogic();
                break;

            case "DebugSendNextWave":
            {
                if (!World.Instance.IsLoaded)
                {
                    return;
                }
                GameCommand command = GameCommand.Create(GameCommandType.Debug_SendNextWave);
                World_AIW2.Instance.QueueGameCommand(command);
            }
            break;

            case "DebugIncreaseAIP":
            {
                if (!World.Instance.IsLoaded)
                {
                    return;
                }
                GameCommand command = GameCommand.Create(GameCommandType.Debug_IncreaseAIP);
                World_AIW2.Instance.QueueGameCommand(command);
            }
            break;

            case "DebugGiveSomeMetal":
            {
                if (!World.Instance.IsLoaded)
                {
                    return;
                }
                GameCommand command = GameCommand.Create(GameCommandType.Debug_GiveMetal);
                World_AIW2.Instance.QueueGameCommand(command);
            }
            break;

            case "DebugGiveScience":
            {
                if (!World.Instance.IsLoaded)
                {
                    return;
                }
                GameCommand command = GameCommand.Create(GameCommandType.Debug_GiveScience);
                World_AIW2.Instance.QueueGameCommand(command);
            }
            break;

            case "DebugConnectToLocalServer":
                ArcenSocket.Instance.OpenAsClient(Window_MainMenu.Instance.TargetIP, (ushort)GameSettings.Current.NetworkPort);
                break;

            case "ReloadExternalDefinitions":
                Engine_Universal.OnReloadAllExternalDefinitions();
                break;

            case "ReloadExternalConstantsAndLanguageOnly":
                Engine_Universal.OnReloadExternalConstantsAndLanguageOnly();
                break;

                #endregion
            case "ToggleGalaxyMap":
                if (Engine_Universal.RunStatus == RunStatus.GameStart)
                {
                    return;
                }
                switch (Engine_AIW2.Instance.CurrentGameViewMode)
                {
                case GameViewMode.MainGameView:
                    Engine_AIW2.Instance.PresentationLayer.ReactToLeavingPlanetView(Engine_AIW2.Instance.NonSim_GetPlanetBeingCurrentlyViewed());
                    Engine_AIW2.Instance.SetCurrentGameViewMode(GameViewMode.GalaxyMapView);
                    break;

                case GameViewMode.GalaxyMapView:
                    Engine_AIW2.Instance.SetCurrentGameViewMode(GameViewMode.MainGameView);
                    Engine_AIW2.Instance.PresentationLayer.ReactToEnteringPlanetView(Engine_AIW2.Instance.NonSim_GetPlanetBeingCurrentlyViewed());
                    break;
                }
                break;

            case "TogglePause":
            {
                if (Engine_Universal.RunStatus == RunStatus.GameStart)
                {
                    return;
                }
                GameCommand command = GameCommand.Create(GameCommandType.TogglePause);
                World_AIW2.Instance.QueueGameCommand(command);
            }
            break;

            case "ScoutAll":
            {
                if (Engine_Universal.RunStatus == RunStatus.GameStart)
                {
                    return;
                }
                GameCommand command = GameCommand.Create(GameCommandType.Debug_RevealAll);
                World_AIW2.Instance.QueueGameCommand(command);
            }
            break;

            case "ScrapUnits":
            {
                if (!World.Instance.IsLoaded)
                {
                    return;
                }
                GameCommand command = GameCommand.Create(GameCommandType.ScrapUnits);
                Engine_AIW2.Instance.DoForSelected(delegate(GameEntity ship)
                    {
                        command.RelatedEntityIDs.Add(ship.PrimaryKeyID);
                        return(DelReturn.Continue);
                    });
                if (command.RelatedEntityIDs.Count > 0)
                {
                    World_AIW2.Instance.QueueGameCommand(command);
                }
            }
            break;

            case "ToggleFRD":
            {
                if (!World.Instance.IsLoaded)
                {
                    return;
                }
                GameCommand command = GameCommand.Create(GameCommandType.SetBehavior);
                command.SentWithToggleSet_SetOrdersForProducedUnits = Engine_AIW2.Instance.SettingOrdersForProducedUnits;
                bool foundSomeOff = false;
                Engine_AIW2.Instance.DoForSelected(delegate(GameEntity selected)
                    {
                        if (selected.EntitySpecificOrders.Behavior != EntityBehaviorType.Attacker)
                        {
                            foundSomeOff = true;
                        }
                        return(DelReturn.Continue);
                    });
                EntityBehaviorType targetType = EntityBehaviorType.Stationary;
                if (foundSomeOff)
                {
                    targetType = EntityBehaviorType.Attacker;
                }
                command.RelatedMagnitude = (int)targetType;
                Engine_AIW2.Instance.DoForSelected(delegate(GameEntity ship)
                    {
                        command.RelatedEntityIDs.Add(ship.PrimaryKeyID);
                        return(DelReturn.Continue);
                    });
                if (command.RelatedEntityIDs.Count > 0)
                {
                    World_AIW2.Instance.QueueGameCommand(command);
                }
            }
            break;

            case "ToggleSettingOrdersForProducedUnits":
                Engine_AIW2.Instance.SettingOrdersForProducedUnits = !Engine_AIW2.Instance.SettingOrdersForProducedUnits;
                break;

            case "ToggleCombatSideBooleanFlag":
            {
                Planet      planet  = Engine_AIW2.Instance.NonSim_GetPlanetBeingCurrentlyViewed();
                CombatSide  side    = planet.Combat.GetSideForWorldSide(World_AIW2.Instance.GetLocalSide());
                GameCommand command = GameCommand.Create(GameCommandType.ChangeCombatSideBooleanFlag);
                command.RelatedSide                  = side.WorldSide;
                command.RelatedPlanetIndex           = planet.PlanetIndex;
                command.RelatedCombatSideBooleanFlag = (CombatSideBooleanFlag)Int1;
                command.RelatedBool                  = !side.BooleanFlags[command.RelatedCombatSideBooleanFlag];
                World_AIW2.Instance.QueueGameCommand(command);
            }
            break;

            case "SelectAllMobileMilitary":
            case "SelectController":
            case "SelectSpaceDock":
            {
                if (!World.Instance.IsLoaded)
                {
                    return;
                }
                WorldSide localSide = World_AIW2.Instance.GetLocalSide();
                if (localSide == null)
                {
                    return;
                }
                Planet planet = Engine_AIW2.Instance.NonSim_GetPlanetBeingCurrentlyViewed();
                if (planet == null)
                {
                    return;
                }
                EntityRollupType rollup   = EntityRollupType.None;
                MetalFlowPurpose flowType = MetalFlowPurpose.None;
                switch (InputActionInternalName)
                {
                case "SelectAllMobileMilitary":
                    rollup = EntityRollupType.MobileCombatants;
                    break;

                case "SelectController":
                    rollup = EntityRollupType.Controllers;
                    break;

                case "SelectSpaceDock":
                    rollup   = EntityRollupType.HasAnyMetalFlows;
                    flowType = MetalFlowPurpose.BuildingShipsInternally;
                    break;

                default:
                    return;
                }

                bool unselectingInstead = false;
                if (Engine_AIW2.Instance.PresentationLayer.GetAreInputFlagsActive(ArcenInputFlags.Additive))
                {
                }
                else if (Engine_AIW2.Instance.PresentationLayer.GetAreInputFlagsActive(ArcenInputFlags.Subtractive))
                {
                    unselectingInstead = true;
                }
                else
                {
                    Engine_AIW2.Instance.ClearSelection();
                }

                for (int i = 0; i < planet.Combat.Sides.Count; i++)
                {
                    CombatSide side = planet.Combat.Sides[i];
                    if (!side.WorldSide.ControlledByPlayerAccounts.Contains(PlayerAccount.Local.PlayerPrimaryKeyID))
                    {
                        continue;
                    }
                    side.Entities.DoForEntities(rollup, delegate(GameEntity entity)
                        {
                            if (flowType != MetalFlowPurpose.None &&
                                entity.TypeData.MetalFlows[flowType] == null)
                            {
                                return(DelReturn.Continue);
                            }
                            if (unselectingInstead)
                            {
                                entity.Unselect();
                            }
                            else
                            {
                                entity.Select();
                            }
                            return(DelReturn.Continue);
                        });
                }
            }
            break;

            case "IncreaseFrameSize":
            case "DecreaseFrameSize":
            {
                GameCommand command = GameCommand.Create(GameCommandType.ChangeFrameSize);
                command.RelatedMagnitude = 1;
                if (InputActionInternalName == "DecreaseFrameSize")
                {
                    command.RelatedMagnitude = -command.RelatedMagnitude;
                }
                World_AIW2.Instance.QueueGameCommand(command);
            }
            break;

            case "IncreaseFrameFrequency":
            case "DecreaseFrameFrequency":
            {
                GameCommand command = GameCommand.Create(GameCommandType.ChangeFrameFrequency);
                command.RelatedMagnitude = 1;
                if (InputActionInternalName == "DecreaseFrameFrequency")
                {
                    command.RelatedMagnitude = -command.RelatedMagnitude;
                }
                World_AIW2.Instance.QueueGameCommand(command);
            }
            break;

            case "ShowShipRanges_Selected":
                ArcenInput_AIW2.ShouldShowShipRanges_Selected = true;
                break;

            case "ShowShipRanges_Hovered":
                ArcenInput_AIW2.ShouldShowShipRanges_Hovered = true;
                break;

            case "ShowShipRanges_All":
                ArcenInput_AIW2.ShouldShowShipRanges_All = true;
                break;

            case "ShowShipOrders":
                ArcenInput_AIW2.ShouldShowShipOrders = true;
                break;

            case "SelectBuilder":
            {
                if (!World.Instance.IsLoaded)
                {
                    return;
                }
                WorldSide localSide = World_AIW2.Instance.GetLocalSide();
                if (localSide == null)
                {
                    return;
                }
                Planet planet = Engine_AIW2.Instance.NonSim_GetPlanetBeingCurrentlyViewed();
                if (planet == null)
                {
                    return;
                }

                GameEntity currentBuilder = null;
                if (Engine_AIW2.Instance.GetHasSelection())
                {
                    currentBuilder = Window_InGameBuildMenu.GetEntityToUseForBuildMenu();
                    if (currentBuilder == null)
                    {
                        Engine_AIW2.Instance.ClearSelection();
                    }
                }

                CombatSide side         = planet.Combat.GetSideForWorldSide(localSide);
                bool       foundCurrent = false;
                GameEntity newBuilder   = null;
                GameEntity firstBuilder = null;
                side.Entities.DoForEntities(GameEntityCategory.Ship, delegate(GameEntity entity)
                    {
                        if (entity.TypeData.BuildMenus == null || entity.TypeData.BuildMenus.Count <= 0)
                        {
                            return(DelReturn.Continue);
                        }
                        if (firstBuilder == null)
                        {
                            firstBuilder = entity;
                        }
                        if (entity == currentBuilder)
                        {
                            foundCurrent = true;
                        }
                        else if (foundCurrent)
                        {
                            newBuilder = entity;
                            return(DelReturn.Break);
                        }
                        return(DelReturn.Continue);
                    });
                if (newBuilder == null && firstBuilder != null)
                {
                    newBuilder = firstBuilder;
                }
                if (newBuilder != null)
                {
                    newBuilder.Select();
                    if (!Window_InGameBuildMenu.Instance.IsOpen)
                    {
                        Window_InGameCommandsMenu.bToggleBuildMenu.Instance.HandleClick();
                    }
                }
            }
            break;

            case "OpenTechMenu":
            case "OpenSystemMenu":
            case "ClearMenus":
                if (!World.Instance.IsLoaded)
                {
                    return;
                }
                ToggleableWindowController window;
                switch (InputActionInternalName)
                {
                case "OpenTechMenu":
                    window = Window_InGameTechMenu.Instance;
                    break;

                case "OpenSystemMenu":
                    window = Window_InGameEscapeMenu.Instance;
                    break;

                case "ClearMenus":
                    window = null;
                    break;

                default:
                    return;
                }
                bool closing = window == null || window.IsOpen;
                Engine_AIW2.Instance.ClearSelection();
                Window_InGameBottomMenu.Instance.CloseAllExpansions();
                if (!closing)
                {
                    Window_InGameBottomMenu.bToggleMasterMenu.Instance.HandleClick();

                    switch (InputActionInternalName)
                    {
                    case "OpenTechMenu":
                        Window_InGameMasterMenu.bToggleTechMenu.Instance.HandleClick();
                        break;

                    case "OpenSystemMenu":
                        Window_InGameMasterMenu.bToggleEscapeMenu.Instance.HandleClick();
                        break;

                    default:
                        return;
                    }
                }
                break;
            }
        }
        public override void UpdateContent(ArcenUIWrapperedUnityImage Image, ArcenUI_Image.SubImageGroup SubImages, SubTextGroup SubTexts)
        {
            GameEntityTypeData typeData = this.TypeToBuild;

            if (typeData == null)
            {
                return;
            }

            WorldSide  localSide       = World_AIW2.Instance.GetLocalPlayerSide();
            Planet     planet          = Engine_AIW2.Instance.NonSim_GetPlanetBeingCurrentlyViewed();
            CombatSide localCombatSide = planet.Combat.GetSideForWorldSide(localSide);

            int debugStage = -1;

            try
            {
                debugStage = 1;

                debugStage = 2;
                SubImages[INDEX_ICON_NO_FLAIR].WrapperedImage.UpdateWith(null, true);
                SubImages[INDEX_ICON_FLAIR_ONLY].WrapperedImage.UpdateWith(typeData.GUISprite_Icon_White, true);

                // uncomment if you want a crazy experiment with icons varying in size over time
                //float size = ( World_AIW2.Instance.GameSecond * 10 ) % 100;
                //if ( size < 1 )
                //    size = 1;
                //SubImages[INDEX_ICON_FLAIR_ONLY].WrapperedImage.SetSize( size, size / 2 );

                // uncomment if you want to try vertically centering non-flair icons instead of leaving the gap at the bottom
                //if ( typeData.GUISprite_Flair == null )
                //    SubImages[INDEX_ICON_FLAIR_ONLY].WrapperedImage.SetOffset( 0, 5 );

                debugStage = 4;
                SubImages[INDEX_FLAIR].WrapperedImage.UpdateWith(typeData.GUISprite_Flair, true);

                debugStage = 5;
                bool showFuel = typeData.BalanceStats.SquadFuelConsumption > 0 && localSide.NetFuel < typeData.BalanceStats.SquadFuelConsumption;
                SubImages[INDEX_FUEL].WrapperedImage.UpdateToShowOrHide(showFuel);

                debugStage = 6;
                bool showPower = typeData.BalanceStats.SquadPowerConsumption > 0 && localCombatSide.NetPower < typeData.BalanceStats.SquadPowerConsumption;
                SubImages[INDEX_POWER].WrapperedImage.UpdateToShowOrHide(showPower);

                debugStage = 7;
                bool showScience  = false;
                bool showLocked   = false;
                bool showUnlocked = false;

                if (this.ButtonMode == Mode.Tech)
                {
                    if (typeData.TechPrereq == null)
                    {
                        // shouldn't really be on the tech menu anyway
                    }
                    else
                    {
                        if (localSide.GetHasResearched(typeData.TechPrereq))
                        {
                            showUnlocked = true;
                        }
                        else if (localSide.GetCanResearch(typeData.TechPrereq, true, false) != ArcenRejectionReason.Unknown)
                        {
                            showLocked = true;
                        }
                        else if (localSide.GetCanResearch(typeData.TechPrereq, false, false) != ArcenRejectionReason.Unknown)
                        {
                            showScience = true;
                        }
                    }
                }

                SubImages[INDEX_SCIENCE].WrapperedImage.UpdateToShowOrHide(showScience);

                //uncomment if you want a crazy experiemnt replacing this icon with a fuel icon
                //SubImages[INDEX_SCIENCE].WrapperedImage.SetBundleAndPathInBundle( "arcenui", "assets/icons/officialgui/resources/fuel.png" );

                SubImages[INDEX_LOCKED].WrapperedImage.UpdateToShowOrHide(showLocked);
                Image.SetColor(showLocked ? ColorMath.LightGray : ColorMath.White);
                SubImages[INDEX_UNLOCKED].WrapperedImage.UpdateToShowOrHide(showUnlocked);

                debugStage = 8;
                bool showActiveKeyboardColumnIndicator = false;
                if (this.ButtonMode == Mode.Build)
                {
                    showActiveKeyboardColumnIndicator = this.ColumnIndex == Window_InGameBuildTypeIconMenu.Instance.CurrentTypeIndex;
                }
                else if (this.ButtonMode == Mode.Tech)
                {
                    showActiveKeyboardColumnIndicator = this.ColumnIndex == Window_InGameTechTypeIconMenu.Instance.CurrentTypeIndex;
                }
                SubImages[INDEX_ACTIVE_KEYBOARD_COLUMN].WrapperedImage.UpdateToShowOrHide(showActiveKeyboardColumnIndicator);

                debugStage = 15;
                int markLevel = typeData.Balance_MarkLevel.Ordinal;
                if (markLevel < 0 || markLevel > 5)
                {
                    markLevel = 0;
                }
                SubImages[INDEX_MARK_LEVEL].WrapperedImage.UpdateWith(markLevel <= 0 ? null : Window_InGameOutlineSidebar.Sprite_MarkLevels[markLevel], true);
            }
            catch (Exception e)
            {
                ArcenDebugging.ArcenDebugLog("Exception in UpdateContent (image) at stage " + debugStage + ":" + e.ToString(), Verbosity.ShowAsError);
            }

            debugStage = -1;
            try
            {
                debugStage = 1;
                ArcenUIWrapperedTMProText text = SubTexts[TEXT_INDEX_UPPER_LEFT].Text;

                debugStage = 2;
                ArcenDoubleCharacterBuffer buffer = text.StartWritingToBuffer();

                if (typeData != null)
                {
                    switch (this.ButtonMode)
                    {
                    case Mode.Build:
                    case Mode.Queue:
                        if (planet != null)
                        {
                            int remainingCap = localCombatSide.GetRemainingCap(typeData);

                            text.SetFontSize(12);
                            buffer.Add(remainingCap);

                            if (remainingCap <= 0)
                            {
                                text.SetColor(ColorMath.LightRed);
                            }
                            else
                            {
                                text.SetColor(ColorMath.White);
                            }
                        }
                        break;

                    case Mode.Tech:
                        if (typeData.TechPrereq == null)
                        {
                            break;
                        }
                        if (localSide.GetHasResearched(typeData.TechPrereq))
                        {
                            break;
                        }
                        int cost = typeData.TechPrereq.ScienceCost;
                        buffer.Add(cost);
                        if (cost > localSide.StoredScience)
                        {
                            text.SetColor(ColorMath.LightRed);
                        }
                        else
                        {
                            text.SetColor(ColorMath.White);
                        }
                        break;
                    }
                }

                text.FinishWritingToBuffer();

                debugStage = 3;
                text       = SubTexts[TEXT_INDEX_ABOVE_BUTTON].Text;

                debugStage = 4;
                buffer     = text.StartWritingToBuffer();

                if (this.ButtonMode == Mode.Queue)
                {
                    GameEntity builder = null;
                    Engine_AIW2.Instance.DoForSelected(SelectionCommandScope.CurrentPlanet_UnlessViewingGalaxy, delegate(GameEntity selected)
                    {
                        if (selected.TypeData != this.TypeDoingTheBuilding)
                        {
                            return(DelReturn.Continue);
                        }
                        if (builder != null)
                        {
                            // only show time display when there's only one builder, otherwise it's not clear what should be shown
                            builder = null;
                            return(DelReturn.Break);
                        }
                        builder = selected;
                        return(DelReturn.Continue);
                    });
                    debugStage = 5;
                    if (builder != null && builder.BuildQueue != null)
                    {
                        BuildQueueItem item = builder.BuildQueue.GetQueueItemFor(typeData);
                        if (item != null)
                        {
                            bool showTimer = item.MetalSpentOnCurrentIteration > 0 && item.NumberBuiltThisLoop < item.NumberToBuildEachLoop;
                            if (showTimer)
                            {
                                FInt metalLeft = typeData.BalanceStats.SquadMetalCost - item.MetalSpentOnCurrentIteration;
                                FInt metalRate = builder.TypeData.MetalFlows[MetalFlowPurpose.BuildingShipsInternally].EffectiveThroughput;
                                if (metalLeft > 0 && metalRate > 0)
                                {
                                    FInt secondsLeft = metalLeft / metalRate;
                                    buffer.Add(Engine_Universal.ToHoursAndMinutesString(secondsLeft.IntValue));
                                }
                            }
                        }
                    }
                }

                debugStage = 6;
                text.FinishWritingToBuffer();
            }
            catch (Exception e)
            {
                ArcenDebugging.ArcenDebugLog("Exception in UpdateContent (text) at stage " + debugStage + ":" + e.ToString(), Verbosity.ShowAsError);
            }
        }
Example #12
0
 public override void HandleClick()
 {
     Engine_Universal.ForceClose();
 }
 public override MouseHandlingResult HandleClick()
 {
     Engine_Universal.ForceClose();
     return(MouseHandlingResult.None);
 }