public override void OnUpdate()
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalPlayerSide();

                if (localSide == null)
                {
                    return;
                }
                ArcenUI_ButtonSet elementAsType = (ArcenUI_ButtonSet)Element;

                //Window_InGameGalaxyMapDisplayModeMenu windowController = (Window_InGameGalaxyMapDisplayModeMenu)Element.Window.Controller;

                if (elementAsType.Buttons.Count <= 0)
                {
                    int x = 0;
                    for (int i = 0; i < GalaxyMapDisplayModeTable.Instance.Rows.Count; i++)
                    {
                        GalaxyMapDisplayMode mode   = GalaxyMapDisplayModeTable.Instance.Rows[i];
                        bItem   newButtonController = new bItem(mode);
                        Vector2 offset;
                        offset.x = x * elementAsType.ButtonWidth;
                        offset.y = 0;
                        Vector2 size;
                        size.x = elementAsType.ButtonWidth;
                        size.y = elementAsType.ButtonHeight;
                        elementAsType.AddButton(newButtonController, size, offset);
                        x++;
                    }
                }
            }
Ejemplo n.º 2
0
            public override void OnUpdate()
            {
                if (!Instance.NeedsUpdate)
                {
                    return;
                }
                Instance.NeedsUpdate = false;

                ArcenUI_ButtonSet elementAsType = (ArcenUI_ButtonSet)Element;

                elementAsType.ClearButtons();

                string directoryPath = Engine_Universal.CurrentPlayerDataDirectory + "Save/";

                string[] files = Directory.GetFiles(directoryPath, "*" + Engine_Universal.SaveExtension);

                for (int i = 0; i < files.Length; i++)
                {
                    string file     = files[i];
                    string saveName = Path.GetFileNameWithoutExtension(file);
                    AddSaveButton(elementAsType, saveName, i);
                }

                string newSaveName = "NewSave_" + (files.Length + 1);

                AddSaveButton(elementAsType, newSaveName, files.Length);

                elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared();
            }
Ejemplo n.º 3
0
            public override void OnUpdate()
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalPlayerSide();

                if (localSide == null)
                {
                    return;
                }
                ArcenUI_ButtonSet elementAsType = (ArcenUI_ButtonSet)Element;

                //Window_InGameTracingMenu windowController = (Window_InGameTracingMenu)Element.Window.Controller;

                if (elementAsType.Buttons.Count <= 0)
                {
                    int x = 0;
                    for (int flagInt = 1; flagInt < (int)ArcenTracingFlags.Length; flagInt <<= 1, x++)
                    {
                        ArcenTracingFlags flag = (ArcenTracingFlags)flagInt;
                        bItem             newButtonController = new bItem(flag);
                        Vector2           offset;
                        offset.x = x * elementAsType.ButtonWidth;
                        offset.y = 0;
                        Vector2 size;
                        size.x = elementAsType.ButtonWidth;
                        size.y = elementAsType.ButtonHeight;
                        elementAsType.AddButton(newButtonController, size, offset);
                    }
                }
            }
Ejemplo n.º 4
0
            public override void OnUpdate()
            {
                if (Instance.HasUpdatedSinceLastClose)
                {
                    return;
                }
                Instance.HasUpdatedSinceLastClose = true;

                ArcenUI_ButtonSet elementAsType = (ArcenUI_ButtonSet)Element;

                elementAsType.ClearButtons();

                string directoryPath = Engine_Universal.CurrentPlayerDataDirectory + "Save/";

                string[] files = Directory.GetFiles(directoryPath, "*" + Engine_Universal.SaveExtension);

                for (int i = 0; i < files.Length; i++)
                {
                    string          file                = files[i];
                    string          saveName            = Path.GetFileNameWithoutExtension(file);
                    bLoadGameButton newButtonController = new bLoadGameButton(saveName);
                    Vector2         offset;
                    offset.x = 0;
                    offset.y = i * elementAsType.ButtonHeight;
                    Vector2 size;
                    size.x = elementAsType.ButtonWidth;
                    size.y = elementAsType.ButtonHeight;
                    elementAsType.AddButton(newButtonController, size, offset);
                }

                elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared();
            }
            public override void OnUpdate()
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalPlayerSide();

                if (localSide == null)
                {
                    return;
                }
                ArcenUI_ButtonSet          elementAsType    = (ArcenUI_ButtonSet)Element;
                Window_InGameFormationMenu windowController = (Window_InGameFormationMenu)Element.Window.Controller;

                if (windowController.TimeOfLastRefresh < Engine_AIW2.Instance.TimeOfLastControlGroupChange)
                {
                    windowController.NeedRefresh = true;
                }

                if (windowController.LastControlGroupID != World_AIW2.Instance.CurrentActiveSelectionControlGroupPrimaryKeyID)
                {
                    windowController.NeedRefresh = true;
                }

                if (windowController.NeedRefresh)
                {
                    windowController.NeedRefresh        = false;
                    windowController.TimeOfLastRefresh  = DateTime.Now;
                    windowController.LastControlGroupID = World_AIW2.Instance.CurrentActiveSelectionControlGroupPrimaryKeyID;

                    elementAsType.ClearButtons();

                    int x = 0;

                    {
                        bClear  newButtonController = new bClear();
                        Vector2 offset;
                        offset.x = x * elementAsType.ButtonWidth;
                        offset.y = 0;
                        Vector2 size;
                        size.x = elementAsType.ButtonWidth;
                        size.y = elementAsType.ButtonHeight;
                        elementAsType.AddButton(newButtonController, size, offset);
                        x++;
                    }

                    for (int i = 0; i < FormationTypeDataTable.Instance.Rows.Count; i++)
                    {
                        FormationTypeData item = FormationTypeDataTable.Instance.Rows[i];
                        bItem             newButtonController = new bItem(item);
                        Vector2           offset;
                        offset.x = x * elementAsType.ButtonWidth;
                        offset.y = 0;
                        Vector2 size;
                        size.x = elementAsType.ButtonWidth;
                        size.y = elementAsType.ButtonHeight;
                        elementAsType.AddButton(newButtonController, size, offset);
                        x++;
                    }

                    elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared();
                }
            }
            public override void OnUpdate()
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalSide();

                if (localSide == null)
                {
                    return;
                }
                Planet                 planet           = Engine_AIW2.Instance.NonSim_GetPlanetBeingCurrentlyViewed();
                ArcenUI_ButtonSet      elementAsType    = (ArcenUI_ButtonSet)Element;
                Window_InGameBuildMenu windowController = (Window_InGameBuildMenu)Element.Window.Controller;

                if (windowController.EntityChangedSinceLastButtonSetUpdate_Menu)
                {
                    elementAsType.ClearButtons();

                    GameEntity entity = World_AIW2.Instance.GetEntityByID(windowController.EntityID);
                    if (entity != null)
                    {
                        List <BuildMenu> menus = entity.TypeData.BuildMenus;
                        int x = 0;
                        for (int i = 0; i < menus.Count; i++)
                        {
                            BuildMenu item = menus[i];
                            if (item.RequiresPresenceOf != null)
                            {
                                bool foundIt = false;
                                planet.Combat.DoForEntities(EntityRollupType.SpecialBuildMenuEnablers, delegate(GameEntity enabler)
                                {
                                    if (enabler.TypeData != item.RequiresPresenceOf)
                                    {
                                        return(DelReturn.Continue);
                                    }
                                    foundIt = true;
                                    return(DelReturn.Break);
                                });
                                if (!foundIt)
                                {
                                    continue;
                                }
                            }
                            bMenuSelectionItem newButtonController = new bMenuSelectionItem(entity.TypeData, i);
                            Vector2            offset;
                            offset.x = x * elementAsType.ButtonWidth;
                            offset.y = 0;
                            Vector2 size;
                            size.x = elementAsType.ButtonWidth;
                            size.y = elementAsType.ButtonHeight;
                            elementAsType.AddButton(newButtonController, size, offset);
                            x++;
                        }
                    }

                    elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared();

                    windowController.EntityChangedSinceLastButtonSetUpdate_Menu = false;
                    windowController.MenuIndexChangedSinceLastButtonSetUpdate   = true;
                }
            }
Ejemplo n.º 7
0
            public override void OnUpdate()
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalSide();

                if (localSide == null)
                {
                    return;
                }
                GameEntity launcher = localSide.Entities.GetFirstMatching(EntityRollupType.KingUnits);

                if (launcher == null)
                {
                    return;
                }
                ArcenUI_ButtonSet        elementAsType    = (ArcenUI_ButtonSet)Element;
                Window_InGameWarheadMenu windowController = (Window_InGameWarheadMenu)Element.Window.Controller;

                if (windowController.PlanetChangedSinceLastButtonSetUpdate)
                {
                    elementAsType.ClearButtons();

                    int x = 0;
                    for (int i = 0; i < GameEntityTypeDataTable.Instance.Rows.Count; i++)
                    {
                        GameEntityTypeData type = GameEntityTypeDataTable.Instance.Rows[i];
                        if (type.SpecialType != SpecialEntityType.Warhead)
                        {
                            continue;
                        }
                        bool foundIt = false;
                        for (int j = 0; j < launcher.WarheadContents.Count; j++)
                        {
                            if (launcher.WarheadContents[j].ContainedType != type)
                            {
                                continue;
                            }
                            foundIt = true;
                            break;
                        }
                        if (!foundIt)
                        {
                            continue;
                        }
                        bItem   newButtonController = new bItem(type);
                        Vector2 offset;
                        offset.x = x * elementAsType.ButtonWidth;
                        offset.y = 0;
                        Vector2 size;
                        size.x = elementAsType.ButtonWidth;
                        size.y = elementAsType.ButtonHeight;
                        elementAsType.AddButton(newButtonController, size, offset);
                        x++;
                    }

                    elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared();

                    windowController.PlanetChangedSinceLastButtonSetUpdate = false;
                }
            }
            private static void AddLoadButton(ArcenUI_ButtonSet elementAsType, SaveGameData saveGame, Vector2 offset, Vector2 size)
            {
                //Note we use a slightly different sized button for Load games as opposed to Campaign games
                //so we set the size elsewhere. We need to set the size earlier so we can correctly
                //know the changed button size when laying out the grid of games on screen
                bLoadGameButton newButtonController = new bLoadGameButton(saveGame);

                elementAsType.AddButton(newButtonController, size, offset);
            }
            private static void AddCampaignButton(ArcenUI_ButtonSet elementAsType, SaveGameData saveGame, Vector2 offset)
            {
                bCampaignGameButton newButtonController = new bCampaignGameButton(saveGame);
                Vector2             size;

                size.x = elementAsType.ButtonWidth;
                size.y = elementAsType.ButtonHeight;
                elementAsType.AddButton(newButtonController, size, offset);
            }
            private static void AddSaveButton(ArcenUI_ButtonSet elementAsType, SaveGameData saveGame, Vector2 offset)
            {
                //This adds a given save game
                bSaveGameButton newButtonController = new bSaveGameButton(saveGame);
                Vector2         size;

                size.x = elementAsType.ButtonWidth;
                size.y = elementAsType.ButtonHeight;
                elementAsType.AddButton(newButtonController, size, offset);
            }
            public override void OnUpdate()
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalPlayerSide();

                if (localSide == null)
                {
                    return;
                }
                ArcenUI_ButtonSet elementAsType = (ArcenUI_ButtonSet)Element;

                if (Window_InGameBuildTabMenu.Instance.EntityChangedSinceLastButtonSetUpdate_QueueControls)
                {
                    elementAsType.ClearButtons();

                    GameEntity entity = World_AIW2.Instance.GetEntityByID(Window_InGameBuildTabMenu.Instance.EntityID);
                    if (entity != null)
                    {
                        //float aspectRatioAdjustedButtonWidth = elementAsType.ButtonWidth;
                        //float aspectRatioAdjustedButtonHeight = elementAsType.ButtonHeight;
                        //if ( ArcenUI.Instance.PixelsPerPercent_X != ArcenUI.Instance.PixelsPerPercent_Y )
                        //    aspectRatioAdjustedButtonWidth *= ArcenUI.Instance.PixelsPerPercent_Y / ArcenUI.Instance.PixelsPerPercent_X;

                        float runningY = 0;
                        {
                            bTogglePause newButtonController = new bTogglePause();
                            Vector2      offset;
                            offset.x = 0;
                            offset.y = 0;
                            Vector2 size;
                            size.x = elementAsType.ButtonWidth;
                            size.y = elementAsType.ButtonHeight;
                            elementAsType.AddButton(newButtonController, size, offset);
                            runningY += size.y;
                        }
                        {
                            bToggleLoop newButtonController = new bToggleLoop();
                            Vector2     offset;
                            offset.x = 0;
                            offset.y = runningY;
                            Vector2 size;
                            size.x = elementAsType.ButtonWidth;
                            size.y = elementAsType.ButtonHeight;
                            elementAsType.AddButton(newButtonController, size, offset);
                            runningY += size.y;
                        }

                        elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared();

                        Window_InGameBuildTabMenu.Instance.EntityChangedSinceLastButtonSetUpdate_QueueControls = false;
                        Window_InGameBuildTabMenu.Instance.MenuIndexChangedSinceLastButtonSetUpdate            = true;
                    }
                }
            }
            public override void OnUpdate()
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalPlayerSide();

                if (localSide == null)
                {
                    return;
                }
                ArcenUI_ButtonSet      elementAsType    = (ArcenUI_ButtonSet)Element;
                Window_InGameRallyMenu windowController = (Window_InGameRallyMenu)Element.Window.Controller;

                if (windowController != null)
                {
                }                                   //prevent compiler warning

                if (windowController.NeedRefresh)
                {
                    windowController.NeedRefresh = false;
                    elementAsType.ClearButtons();

                    int x = 0;
                    for (int i = 0; i < localSide.ControlGroups.Count; i++)
                    {
                        ControlGroup controlGroup = localSide.ControlGroups[i];
                        if (controlGroup.EntityIDs.Count <= 0)
                        {
                            continue;
                        }
                        bItem   newButtonController = new bItem(controlGroup);
                        Vector2 offset;
                        offset.x = x * elementAsType.ButtonWidth;
                        offset.y = 0;
                        Vector2 size;
                        size.x = elementAsType.ButtonWidth;
                        size.y = elementAsType.ButtonHeight;
                        elementAsType.AddButton(newButtonController, size, offset);
                        x++;
                    }

                    {
                        bClear  newButtonController = new bClear();
                        Vector2 offset;
                        offset.x = 9 * elementAsType.ButtonWidth;
                        offset.y = 0;
                        Vector2 size;
                        size.x = elementAsType.ButtonWidth;
                        size.y = elementAsType.ButtonHeight;
                        elementAsType.AddButton(newButtonController, size, offset);
                    }

                    elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared();
                }
            }
            private static void AddHeaderButton(ArcenUI_ButtonSet elementAsType, String Name, Vector2 offset)
            {
                /* This is for the campaign header */
                bSaveGameButton newButtonController = new bSaveGameButton(Name);

                newButtonController.doNothing = true; //this is a button, but don't do anything when its pressed
                Vector2 size;

                size.x = elementAsType.ButtonWidth + 2; //make it a bit larger
                size.y = elementAsType.ButtonHeight + 3;
                elementAsType.AddButton(newButtonController, size, offset);
            }
Ejemplo n.º 14
0
            private static void AddSaveButton(ArcenUI_ButtonSet elementAsType, String saveName, int index)
            {
                bSaveGameButton newButtonController = new bSaveGameButton(saveName);
                Vector2         offset;

                offset.x = 0;
                offset.y = index * elementAsType.ButtonHeight;
                Vector2 size;

                size.x = elementAsType.ButtonWidth;
                size.y = elementAsType.ButtonHeight;
                elementAsType.AddButton(newButtonController, size, offset);
            }
Ejemplo n.º 15
0
            public override void OnUpdate()
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalPlayerSide();

                if (localSide == null)
                {
                    return;
                }
                Planet planet = Engine_AIW2.Instance.NonSim_GetPlanetBeingCurrentlyViewed();

                if (planet != null)
                {
                }                         //prevent compiler warning
                ArcenUI_ButtonSet elementAsType = (ArcenUI_ButtonSet)Element;

                if (elementAsType != null)
                {
                }                                //prevent compiler warning
                Window_InGameTechTabMenu windowController = (Window_InGameTechTabMenu)Element.Window.Controller;

                if (windowController != null)
                {
                }                                   //prevent compiler warning

                if (elementAsType.Buttons.Count <= 0)
                {
                    elementAsType.ClearButtons();

                    List <TechMenu> menus = TechMenuTable.Instance.Rows;
                    int             x     = 0;
                    for (int i = 0; i < menus.Count; i++)
                    {
                        TechMenu item = menus[i];
                        if (item.DoNotShowOnTechMenu)
                        {
                            continue;
                        }
                        bItem   newButtonController = new bItem(i);
                        Vector2 offset;
                        offset.x = x * elementAsType.ButtonWidth;
                        offset.y = 0;
                        Vector2 size;
                        size.x = elementAsType.ButtonWidth;
                        size.y = elementAsType.ButtonHeight;
                        elementAsType.AddButton(newButtonController, size, offset);
                        x++;
                    }

                    elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared();
                }
            }
            public override void OnUpdate()
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalPlayerSide();

                if (localSide == null)
                {
                    return;
                }
                ArcenUI_ButtonSet elementAsType = (ArcenUI_ButtonSet)Element;

                if (this.TimeOfLastUpdate < Engine_AIW2.Instance.TimeOfLastControlGroupChange)
                {
                    this.TimeOfLastUpdate = DateTime.Now;
                    elementAsType.ClearButtons();

                    int x = 0;
                    localSide.DoForControlGroups(delegate(ControlGroup group)
                    {
                        bControlGroupItem newButtonController = new bControlGroupItem(group);
                        Vector2 offset;
                        offset.x = x * elementAsType.ButtonWidth;
                        offset.y = 0;
                        Vector2 size;
                        size.x = elementAsType.ButtonWidth;
                        size.y = elementAsType.ButtonHeight;
                        elementAsType.AddButton(newButtonController, size, offset);
                        x++;
                        return(DelReturn.Continue);
                    });

                    {
                        bCreateControlGroup newButtonController = new bCreateControlGroup();
                        Vector2             offset;
                        offset.x = x * elementAsType.ButtonWidth;
                        offset.y = 0;
                        Vector2 size;
                        size.x = elementAsType.ButtonWidth;
                        size.y = elementAsType.ButtonHeight;
                        elementAsType.AddButton(newButtonController, size, offset);
                        x++;
                    }

                    elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared();
                }
            }
Ejemplo n.º 17
0
            public override void OnUpdate()
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalSide();

                if (localSide == null)
                {
                    return;
                }
                ArcenUI_ButtonSet elementAsType = (ArcenUI_ButtonSet)Element;

                //Window_InGameBottomMenu windowController = (Window_InGameBottomMenu)Element.Window.Controller;

                if (elementAsType.Buttons.Count <= 0)
                {
                    elementAsType.ClearButtons();

                    int numberOfButtons = 9;
                    for (int x = 0; x < numberOfButtons; x++)
                    {
                        bControlGroup newButtonController = new bControlGroup(x);
                        Vector2       offset;
                        offset.x = x * elementAsType.ButtonWidth;
                        offset.y = 0;
                        Vector2 size;
                        size.x = elementAsType.ButtonWidth;
                        size.y = elementAsType.ButtonHeight;
                        elementAsType.AddButton(newButtonController, size, offset);
                    }

                    {
                        bToggleMasterMenu newButtonController = new bToggleMasterMenu();
                        Vector2           offset;
                        offset.x = numberOfButtons * elementAsType.ButtonWidth;
                        offset.y = 0;
                        Vector2 size;
                        size.x = elementAsType.ButtonWidth;
                        size.y = elementAsType.ButtonHeight;
                        elementAsType.AddButton(newButtonController, size, offset);
                    }
                }
            }
            public override void OnUpdate()
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalSide();

                if (localSide == null)
                {
                    return;
                }
                ArcenUI_ButtonSet     elementAsType    = (ArcenUI_ButtonSet)Element;
                Window_InGameTechMenu windowController = (Window_InGameTechMenu)Element.Window.Controller;

                if (elementAsType.Buttons.Count <= 0)
                {
                    elementAsType.ClearButtons();

                    List <TechMenu> menus     = TechMenuTable.Instance.Rows;
                    int             menuIndex = 0;
                    for (int x = 0; x < menus.Count; x++)
                    {
                        TechMenu item = menus[x];
                        if (item.DoNotShowOnTechMenu)
                        {
                            continue;
                        }
                        bMenuSelectionItem newButtonController = new bMenuSelectionItem(x);
                        Vector2            offset;
                        offset.x = menuIndex * elementAsType.ButtonWidth;
                        offset.y = 0;
                        Vector2 size;
                        size.x = elementAsType.ButtonWidth;
                        size.y = elementAsType.ButtonHeight;
                        elementAsType.AddButton(newButtonController, size, offset);
                        menuIndex++;
                    }

                    windowController.MenuIndexChangedSinceLastButtonSetUpdate = true;
                }
            }
            public override void OnUpdate()
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalSide();

                if (localSide == null)
                {
                    return;
                }
                ArcenUI_ButtonSet             elementAsType    = (ArcenUI_ButtonSet)Element;
                Window_InGamePlanetActionMenu windowController = (Window_InGamePlanetActionMenu)Element.Window.Controller;

                if (windowController.PlanetChangedSinceLastButtonSetUpdate)
                {
                    elementAsType.ClearButtons();

                    Planet planet = World_AIW2.Instance.GetPlanetByIndex(windowController.PlanetIndex);
                    if (planet != null)
                    {
                        int x = 0;
                        for (CombatSideBooleanFlag flag = CombatSideBooleanFlag.None + 1; flag < CombatSideBooleanFlag.Length; flag++)
                        {
                            bCombatSideBooleanFlagToggle newButtonController = new bCombatSideBooleanFlagToggle(flag);
                            Vector2 offset;
                            offset.x = x * elementAsType.ButtonWidth;
                            offset.y = 0;
                            Vector2 size;
                            size.x = elementAsType.ButtonWidth;
                            size.y = elementAsType.ButtonHeight;
                            elementAsType.AddButton(newButtonController, size, offset);
                            x++;
                        }
                    }

                    elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared();

                    windowController.PlanetChangedSinceLastButtonSetUpdate = false;
                }
            }
            public override void OnUpdate()
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalPlayerSide();

                if (localSide == null)
                {
                    return;
                }
                ArcenUI_ButtonSet          elementAsType    = (ArcenUI_ButtonSet)Element;
                Window_InGameBuildTypeMenu windowController = (Window_InGameBuildTypeMenu)Element.Window.Controller;

                if (windowController != null)
                {
                }                                   //prevent compiler warning

                if (Window_InGameBuildTypeMenu.Instance.LastMenuIndex != Window_InGameBuildTabMenu.Instance.CurrentMenuIndex)
                {
                    Window_InGameBuildTypeMenu.Instance.LastMenuIndex = Window_InGameBuildTabMenu.Instance.CurrentMenuIndex;
                    elementAsType.ClearButtons();

                    GameEntity entity = World_AIW2.Instance.GetEntityByID(Window_InGameBuildTabMenu.Instance.EntityID);
                    if (entity != null && entity.TypeData.BuildMenus.Count > 0)
                    {
                        if (Window_InGameBuildTypeMenu.Instance.LastMenuIndex >= entity.TypeData.BuildMenus.Count)
                        {
                            Window_InGameBuildTypeMenu.Instance.LastMenuIndex   = 0;
                            Window_InGameBuildTabMenu.Instance.CurrentMenuIndex = 0;
                        }
                        BuildMenu menu = entity.TypeData.BuildMenus[Window_InGameBuildTypeMenu.Instance.LastMenuIndex];
                        if (menu != null)
                        {
                            int shownColumnCount = 0;
                            for (int x = 0; x < menu.Columns.Count; x++)
                            {
                                bool haveShownAnythingInThisColumn = false;
                                List <BuildMenuItem> column        = menu.Columns[x];
                                if (column.Count <= 0)
                                {
                                    continue;
                                }
                                for (int y = 0; y < column.Count; y++)
                                {
                                    BuildMenuItem item = column[y];
                                    haveShownAnythingInThisColumn = true;
                                    bItem newButtonController = new bItem(entity.TypeData, item);
                                    newButtonController.ItemMenuIndex = Window_InGameBuildTypeMenu.Instance.LastMenuIndex;
                                    newButtonController.ItemTypeIndex = x;
                                    newButtonController.ItemIndex     = y;
                                    Vector2 offset;
                                    offset.x = shownColumnCount * elementAsType.ButtonWidth;
                                    offset.y = 0;
                                    Vector2 size;
                                    size.x = elementAsType.ButtonWidth;
                                    size.y = elementAsType.ButtonHeight;
                                    elementAsType.AddButton(newButtonController, size, offset);
                                }
                                if (haveShownAnythingInThisColumn)
                                {
                                    shownColumnCount++;
                                }
                            }
                        }
                    }

                    elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared();
                }
            }
            /* These buttons are either Campaign Buttons or Load buttons.
             * I tried 2 different classes, but I couldn't figure out how
             * to make the old buttons disappear once I changed screens.
             * This way works though */
            public override void OnUpdate()
            {
                if (Instance.HasUpdatedSinceLastClose)
                {
                    return;
                }
                bool debug = false;

                Instance.HasUpdatedSinceLastClose = true;

                ArcenUI_ButtonSet elementAsType = (ArcenUI_ButtonSet)Element;

                elementAsType.ClearButtons();

                Dictionary <string, List <SaveGameData> > gameDict = SaveLoadMethods.parseOnDiskSaveGames();

                if (!Instance.showCampaignButtons)
                {
                    //these are Load Game buttons
                    if (Window_LoadGameMenu.Instance.campaignName == "")
                    {
                        ArcenDebugging.ArcenDebugLogSingleLine("WARNING: campaign name is null ", Verbosity.DoNotShow);
                    }
                    if (debug)
                    {
                        ArcenDebugging.ArcenDebugLogSingleLine("Showing saved games in LoadGames from campaign " + Window_LoadGameMenu.Instance.campaignName, Verbosity.DoNotShow);
                    }
                    //get the saved games for this campaign
                    List <SaveGameData> list = gameDict[Window_LoadGameMenu.Instance.campaignName];
                    //sort saved games by elapsed in game time
                    list.Sort(delegate(SaveGameData x, SaveGameData y)
                    {
                        return(-x.secondsSinceGameStart.CompareTo(y.secondsSinceGameStart));
                    });

                    //This code allows for multiple columns to automatically wrap
                    int     maxHeightPerColumn = 80;
                    int     xModForLoadButtons = -4; //Load buttons are a bit smaller than campaign buttons
                    int     yModForLoadButtons = -4;
                    int     gamesPerColumn     = (int)maxHeightPerColumn / (int)(elementAsType.ButtonHeight + yModForLoadButtons);
                    int     distBetweenColumns = 2;
                    Vector2 sizeForLoadButtons;
                    sizeForLoadButtons.x = elementAsType.ButtonWidth + xModForLoadButtons;
                    sizeForLoadButtons.y = elementAsType.ButtonHeight + yModForLoadButtons;
                    if (debug)
                    {
                        ArcenDebugging.ArcenDebugLogSingleLine("gamesPerColumn " + gamesPerColumn + "botton  height " + elementAsType.ButtonHeight + "maxHeight " + maxHeightPerColumn, Verbosity.DoNotShow);
                    }
                    for (int k = 0; k < list.Count; k++)
                    {
                        Vector2 offset;
                        offset.y = (k % gamesPerColumn) * (elementAsType.ButtonHeight + yModForLoadButtons);
                        offset.x = (k / gamesPerColumn) * (elementAsType.ButtonWidth + xModForLoadButtons) + distBetweenColumns * (k / gamesPerColumn);
                        AddLoadButton(elementAsType, list[k], offset, sizeForLoadButtons);
                    }
                }
                else
                {
                    //these are campaign buttons
                    List <SaveGameData> campaignList = new List <SaveGameData>();
                    foreach (KeyValuePair <string, List <SaveGameData> > entry in gameDict)
                    {
                        //Campaign buttons are sorted by "Last save Wall Clock date"
                        //Find the furthest-in game from each campaign to check for the
                        //Wall Clock time and add it to the campaignList
                        List <SaveGameData> list = entry.Value;
                        list.Sort(delegate(SaveGameData x, SaveGameData y)
                        {
                            return(-x.secondsSinceGameStart.CompareTo(y.secondsSinceGameStart));
                        });
                        campaignList.Add(list[0]);
                    }
                    //Now sort by Wall Clock
                    campaignList.Sort(delegate(SaveGameData x, SaveGameData y)
                    {
                        return(-x.lastModified.CompareTo(y.lastModified));
                    });

                    //Allow columns to wrap nicely
                    int maxHeightPerColumn = 80;
                    int gamesPerColumn     = (int)maxHeightPerColumn / (int)elementAsType.ButtonHeight;
                    int distBetweenColumns = 2;
                    for (int k = 0; k < campaignList.Count; k++)
                    {
                        Vector2 offset;
                        offset.y = (k % gamesPerColumn) * elementAsType.ButtonHeight;
                        offset.x = (k / gamesPerColumn) * elementAsType.ButtonWidth + distBetweenColumns * (k / gamesPerColumn);
                        AddCampaignButton(elementAsType, campaignList[k], offset);
                    }
                }
                elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared();
            }
            public override void OnUpdate()
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalSide();

                if (localSide == null)
                {
                    return;
                }
                ArcenUI_ButtonSet      elementAsType    = (ArcenUI_ButtonSet)Element;
                Window_InGameBuildMenu windowController = (Window_InGameBuildMenu)Element.Window.Controller;

                if (windowController.EntityChangedSinceLastButtonSetUpdate_Queue)
                {
                    elementAsType.ClearButtons();

                    GameEntity entity = World_AIW2.Instance.GetEntityByID(windowController.EntityID);
                    if (entity != null)
                    {
                        float runningX = 0;
                        {
                            bTogglePause newButtonController = new bTogglePause();
                            Vector2      offset;
                            offset.x = runningX;
                            offset.y = 0;
                            Vector2 size;
                            size.x = elementAsType.ButtonWidth / 2;
                            size.y = elementAsType.ButtonHeight;
                            elementAsType.AddButton(newButtonController, size, offset);
                            runningX += size.x;
                        }
                        {
                            bToggleLoop newButtonController = new bToggleLoop();
                            Vector2     offset;
                            offset.x = runningX;
                            offset.y = 0;
                            Vector2 size;
                            size.x = elementAsType.ButtonWidth / 2;
                            size.y = elementAsType.ButtonHeight;
                            elementAsType.AddButton(newButtonController, size, offset);
                            runningX += size.x;
                        }
                        if (entity.BuildQueue != null)
                        {
                            List <BuildQueueItem> items = entity.BuildQueue.Items;
                            for (int x = 0; x < items.Count; x++)
                            {
                                BuildQueueItem item = items[x];
                                bQueueItem     newButtonController = new bQueueItem(entity.TypeData, item, x);
                                Vector2        offset;
                                offset.x = runningX;
                                offset.y = 0;
                                Vector2 size;
                                size.x = elementAsType.ButtonWidth;
                                size.y = elementAsType.ButtonHeight;
                                elementAsType.AddButton(newButtonController, size, offset);
                                runningX += size.x;
                            }
                        }
                    }

                    elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared();

                    windowController.EntityChangedSinceLastButtonSetUpdate_Queue = false;
                    windowController.MenuIndexChangedSinceLastButtonSetUpdate    = true;
                }
            }
            public override void OnUpdate()
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalSide();

                if (localSide == null)
                {
                    return;
                }
                ArcenUI_ButtonSet      elementAsType    = (ArcenUI_ButtonSet)Element;
                Window_InGameBuildMenu windowController = (Window_InGameBuildMenu)Element.Window.Controller;

                if (windowController.MenuIndexChangedSinceLastButtonSetUpdate)
                {
                    elementAsType.ClearButtons();

                    GameEntity entity = World_AIW2.Instance.GetEntityByID(windowController.EntityID);
                    if (entity != null && entity.TypeData.BuildMenus.Count > 0)
                    {
                        if (windowController.LastMenuIndex >= entity.TypeData.BuildMenus.Count)
                        {
                            windowController.LastMenuIndex = 0;
                        }
                        BuildMenu menu = entity.TypeData.BuildMenus[windowController.LastMenuIndex];
                        if (menu != null)
                        {
                            int shownColumnCount = 0;
                            for (int x = 0; x < menu.Columns.Count; x++)
                            {
                                bool haveShownAnythingInThisColumn = false;
                                List <BuildMenuItem> column        = menu.Columns[x];
                                for (int y = 0; y < column.Count; y++)
                                {
                                    BuildMenuItem item = column[y];
                                    if (item.EntityDataOrNull != null && localSide.GetCanBuildAtAll(item.EntityDataOrNull) != ArcenRejectionReason.Unknown)
                                    {
                                        continue;
                                    }
                                    haveShownAnythingInThisColumn = true;
                                    bBuildItem newButtonController = new bBuildItem(entity.TypeData, item);
                                    newButtonController.ItemMenuIndex   = windowController.LastMenuIndex;
                                    newButtonController.ItemColumnIndex = x;
                                    newButtonController.ItemIndex       = y;
                                    Vector2 offset;
                                    offset.x = shownColumnCount * elementAsType.ButtonWidth;
                                    offset.y = y * elementAsType.ButtonHeight;
                                    Vector2 size;
                                    size.x = elementAsType.ButtonWidth;
                                    size.y = elementAsType.ButtonHeight;
                                    elementAsType.AddButton(newButtonController, size, offset);
                                }
                                if (haveShownAnythingInThisColumn)
                                {
                                    shownColumnCount++;
                                }
                            }
                        }
                    }

                    elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared();

                    windowController.MenuIndexChangedSinceLastButtonSetUpdate = false;
                }
            }
Ejemplo n.º 24
0
            public override void OnUpdate()
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalPlayerSide();

                if (localSide == null)
                {
                    return;
                }
                ArcenUI_ButtonSet elementAsType = (ArcenUI_ButtonSet)Element;

                //Window_InGameObjectivesWindow windowController = (Window_InGameObjectivesWindow)Element.Window.Controller;

                Instance.UpdatesSinceLastRefresh++;
                if (Instance.UpdatesSinceLastRefresh >= 5)
                {
                    Instance.UpdatesSinceLastRefresh = 0;

                    List <Objective> objectives = new List <Objective>();
                    for (ObjectiveType type = ObjectiveType.None + 1; type < ObjectiveType.Length; type++)
                    {
                        Objective objective = new Objective(type);
                        objective.ComputeCurrentState();
                        if (objective.State == ObjectiveState.NotApplicable)
                        {
                            continue;
                        }
                        objectives.Add(objective);
                    }

                    bool detectedChange = objectives.Count != Instance.LastComputedObjectives.Count;
                    if (!detectedChange)
                    {
                        for (int i = 0; i < objectives.Count; i++)
                        {
                            Objective newItem = objectives[i];
                            Objective oldItem = Instance.LastComputedObjectives[i];
                            if (newItem.GetMatches(oldItem))
                            {
                                continue;
                            }
                            detectedChange = true;
                            break;
                        }
                    }

                    if (detectedChange)
                    {
                        Instance.LastComputedObjectives = objectives;

                        elementAsType.ClearButtons();

                        for (int y = 0; y < Instance.LastComputedObjectives.Count; y++)
                        {
                            Objective  item = Instance.LastComputedObjectives[y];
                            bObjective newButtonController = new bObjective(item);
                            Vector2    offset;
                            offset.x = 0;
                            offset.y = y * elementAsType.ButtonHeight;
                            Vector2 size;
                            size.x = elementAsType.ButtonWidth;
                            size.y = elementAsType.ButtonHeight;
                            elementAsType.AddButton(newButtonController, size, offset);
                        }

                        this.WindowController.Window.SubContainer.Height = Instance.LastComputedObjectives.Count * elementAsType.ButtonHeight;

                        elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared();
                    }
                }
            }
Ejemplo n.º 25
0
            public override void OnUpdate()
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalPlayerSide();

                if (localSide == null)
                {
                    return;
                }
                Planet planet = Engine_AIW2.Instance.NonSim_GetPlanetBeingCurrentlyViewed();

                if (planet == null)
                {
                    return;
                }
                GameEntity hacker = localSide.Entities.GetFirstMatching(EntityRollupType.KingUnits);

                if (hacker == null)
                {
                    return;
                }
                ArcenUI_ButtonSet        elementAsType    = (ArcenUI_ButtonSet)Element;
                Window_InGameHackingMenu windowController = (Window_InGameHackingMenu)Element.Window.Controller;

                if (windowController != null)
                {
                }                                   //prevent compiler warning

                if (hacker.ActiveHack != Instance.LastObservedActiveHack)
                {
                    Instance.LastObservedActiveHack = hacker.ActiveHack;
                    windowController.PlanetChangedSinceLastButtonSetUpdate = true;
                }

                if (windowController.PlanetChangedSinceLastButtonSetUpdate)
                {
                    elementAsType.ClearButtons();

                    int x = 0;
                    for (int i = 0; i < HackingTypeTable.Instance.Rows.Count; i++)
                    {
                        HackingType type = HackingTypeTable.Instance.Rows[i];
                        planet.Combat.DoForEntities(EntityRollupType.Hackable, delegate(GameEntity entity)
                        {
                            if (!entity.TypeData.EligibleForHacks.Contains(type))
                            {
                                return(DelReturn.Continue);
                            }
                            if (!type.Implementation.GetCanBeHacked(entity, hacker))
                            {
                                return(DelReturn.Continue);
                            }
                            bItem newButtonController = new bItem(type, entity);
                            Vector2 offset;
                            offset.x = x * elementAsType.ButtonWidth;
                            offset.y = 0;
                            Vector2 size;
                            size.x = elementAsType.ButtonWidth;
                            size.y = elementAsType.ButtonHeight;
                            elementAsType.AddButton(newButtonController, size, offset);
                            x++;
                            return(DelReturn.Continue);
                        });
                    }

                    elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared();

                    windowController.PlanetChangedSinceLastButtonSetUpdate = false;
                }
            }
            public override void OnUpdate()
            {
                WorldSide localSide = World_AIW2.Instance.GetLocalSide();

                if (localSide == null)
                {
                    return;
                }
                ArcenUI_ButtonSet     elementAsType    = (ArcenUI_ButtonSet)Element;
                Window_InGameTechMenu windowController = (Window_InGameTechMenu)Element.Window.Controller;

                if (windowController.MenuIndexChangedSinceLastButtonSetUpdate)
                {
                    elementAsType.ClearButtons();

                    TechMenu menu = TechMenuTable.Instance.Rows[windowController.CurrentMenuIndex];
                    if (menu != null)
                    {
                        int shownColumnCount = 0;
                        for (int x = 0; x < menu.Columns.Count; x++)
                        {
                            bool haveShownAnythingInThisColumn = false;
                            List <TechTypeData> column         = menu.Columns[x];
                            for (int y = 0; y < column.Count; y++)
                            {
                                TechTypeData item = column[y];
                                if (item.NotOnMainTechMenu)
                                {
                                    continue;
                                }
                                if (item.Prerequisite != null)
                                {
                                    TechTypeData prereq   = item.Prerequisite;
                                    bool         foundOne = false;
                                    while (prereq != null)
                                    {
                                        if ((prereq.Prerequisite == null && !prereq.NotOnMainTechMenu) || localSide.GetHasResearched(prereq))
                                        {
                                            foundOne = true;
                                            break;
                                        }
                                        prereq = prereq.Prerequisite;
                                    }
                                    if (!foundOne)
                                    {
                                        continue;
                                    }
                                }
                                //if ( localSide.GetCanResearch( item ) != ArcenRejectionReason.Unknown &&
                                //     !localSide.UnlockedTechs.Contains( item ) )
                                //    continue;
                                haveShownAnythingInThisColumn = true;
                                bTechItem newButtonController = new bTechItem(item);
                                Vector2   offset;
                                offset.x = shownColumnCount * elementAsType.ButtonWidth;
                                offset.y = y * elementAsType.ButtonHeight;
                                Vector2 size;
                                size.x = elementAsType.ButtonWidth;
                                size.y = elementAsType.ButtonHeight;
                                elementAsType.AddButton(newButtonController, size, offset);
                            }
                            if (haveShownAnythingInThisColumn)
                            {
                                shownColumnCount++;
                            }
                        }
                    }

                    elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared();

                    windowController.MenuIndexChangedSinceLastButtonSetUpdate = false;
                }
            }
            public override void OnUpdate()
            {
                if (!Instance.NeedsUpdate)
                {
                    return;
                }
                Instance.NeedsUpdate = false;
                bool debug = false;

                if (debug)
                {
                    ArcenDebugging.ArcenDebugLogSingleLine("Reading directory to generate buttons", Verbosity.DoNotShow);
                }
                ArcenUI_ButtonSet elementAsType = (ArcenUI_ButtonSet)Element;

                elementAsType.ClearButtons();

                Dictionary <string, List <SaveGameData> > gameDict = SaveLoadMethods.parseOnDiskSaveGames();

                foreach (KeyValuePair <string, List <SaveGameData> > entry in gameDict)
                {
                    //Don't show any saves from other campaigns
                    if (entry.Key != Window_SaveGameMenu.Instance.OverallCampaignName || Window_SaveGameMenu.Instance.OverallCampaignName == "")
                    {
                        continue;
                    }
                    if (debug)
                    {
                        ArcenDebugging.ArcenDebugLogSingleLine("Parsing list from  " + entry.Key, Verbosity.DoNotShow);
                    }

                    List <SaveGameData> list = entry.Value;
                    //Sort the found saved games by elapsed in game time
                    list.Sort(delegate(SaveGameData x, SaveGameData y)
                    {
                        return(-x.secondsSinceGameStart.CompareTo(y.secondsSinceGameStart));
                    });

                    //Allow for multiple columns
                    int maxHeightPerColumn = 80;
                    int gamesPerColumn     = (int)maxHeightPerColumn / (int)elementAsType.ButtonHeight;
                    int distBetweenColumns = 5;

                    //This section here adds a big button at the top
                    //to display information about the campaign
                    Vector2 offset;
                    offset.y = 0;
                    offset.x = 40;
                    string output = getCampaignLabel(list[0]);
                    AddHeaderButton(elementAsType, output, offset);

                    int offsetForHeader = (int)elementAsType.ButtonHeight + 5;
                    //Now print the found saved games underneath the header
                    for (int k = 0; k < list.Count; k++)
                    {
                        offset.y = (k % gamesPerColumn) * elementAsType.ButtonHeight + offsetForHeader;
                        offset.x = (k / gamesPerColumn) * elementAsType.ButtonWidth + distBetweenColumns * (k / gamesPerColumn);
                        AddSaveButton(elementAsType, list[k], offset);
                    }
                }
                elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared();
            }