Esempio n. 1
0
 static void Postfix(SGNavigationButton __instance, DropshipType shipType, List <SGNavFlyoutButton> ___FlyoutButtonList, LocalizableText ___text)
 {
     Mod.Log.Trace?.Write($"SGNB:SSATSD - entered shipType:{shipType} for ID: {__instance.ID}");
     if (__instance.ID != DropshipLocation.CPT_QUARTER && !___text.text.Contains("CMD Staff"))
     {
         foreach (SGNavFlyoutButton flyoutButton in ___FlyoutButtonList)
         {
             flyoutButton.gameObject.SetActive(false);
         }
     }
 }
Esempio n. 2
0
 static void Postfix(SGNavigationButton __instance, PointerEventData eventData, List <SGNavFlyoutButton> ___FlyoutButtonList, LocalizableText ___text)
 {
     Mod.Log.Trace?.Write($"SGNB:OPE - entered.");
     if (__instance.ID != DropshipLocation.CPT_QUARTER && !___text.text.Contains("CMD Staff"))
     {
         foreach (SGNavFlyoutButton flyoutButton in ___FlyoutButtonList)
         {
             flyoutButton.gameObject.SetActive(false);
         }
     }
 }
Esempio n. 3
0
 static void Postfix(SGNavigationButton __instance, LocalizableText ___text, List <SGNavFlyoutButton> ___FlyoutButtonList, int ___flyoutButtonCount)
 {
     Mod.Log.Trace?.Write($"SGNB:RFTP - entered button {___text.GetParsedText()} with {___flyoutButtonCount} flyout buttons for ID: {__instance.ID}");
     if (__instance.ID != DropshipLocation.CPT_QUARTER && !___text.text.Contains("CMD Staff"))
     {
         foreach (SGNavFlyoutButton flyoutButton in ___FlyoutButtonList)
         {
             flyoutButton.gameObject.SetActive(false);
         }
     }
 }
Esempio n. 4
0
            static void Prefix(SGNavigationButton __instance, DropshipMenuType buttonID, LocalizableText ___text, SGNavigationList ___buttonParent)
            {
                Mod.Log.Debug?.Write($"SGNB:FC - button clicked for ID: {__instance.ID} for menuType:{buttonID} with transition:{SimGameCameraController.TransitionInProgress}");
                // Skip if there's already a transition in progress
                if (SimGameCameraController.TransitionInProgress)
                {
                    return;
                }

                ClickedID = buttonID;
            }
Esempio n. 5
0
            public static void Prefix(SGNavigationButton __instance, PointerEventData eventData, SGNavigationList ___buttonParent)
            {
                try
                {
                    Logger.Debug($"[SGNavigationButton_OnPointerEnter_PREFIX] Collapse all submenus before opening this one's");

                    // Note that this method isn't used in vanilla. I patched it above to be actually useful...
                    ___buttonParent.CollapseSet(false);
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                }
            }
Esempio n. 6
0
 static bool Prefix(SGNavigationButton __instance, SimGameState ___simState)
 {
     try {
         Faction           owner      = ___simState.CurSystem.Owner;
         SimGameReputation reputation = ___simState.GetReputation(owner);
         bool flag = true;
         if (reputation <= SimGameReputation.LOATHED)
         {
             flag = false;
         }
         if (flag)
         {
             __instance.AddFlyoutButton("Store", DropshipMenuType.Shop);
         }
         return(false);
     }
     catch (Exception e) {
         Logger.LogError(e);
         return(true);
     }
 }
Esempio n. 7
0
            public static bool Prefix(SGNavigationButton __instance, PointerEventData eventData)
            {
                try
                {
                    Logger.Debug($"[SGNavigationButton_OnPointerExit_PREFIX] Prevent collapsing of submenu due to the 1px gap...");
                    Logger.Info($"[SGNavigationButton_OnPointerExit_PREFIX] eventData.position.x: {eventData.position.x}");
                    Logger.Info($"[SGNavigationButton_OnPointerExit_PREFIX] Screen.width: {Screen.width}");

                    // Note that the values are resolution dependent! BUT the bug seems to only occur on resultions with width 1920, so still ok to check hard values here...
                    //if ((eventData.delta.x == 1f || eventData.delta.x == -1f) && eventData.position.x == 317)
                    if (Screen.width == 1920 && eventData.position.x == 317)
                    {
                        Logger.Debug($"[SGNavigationButton_OnPointerExit_PREFIX] Gap hit! Skipping original method...");
                        return(false);
                    }
                    return(true);
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                    return(true);
                }
            }
Esempio n. 8
0
            public static void Prefix(SGNavigationButton __instance, bool isCollapsed)
            {
                try
                {
                    //Logger.Debug($"[SGNavigationButton_CollapseSet_PREFIX] Simulating OnPointerEnter | OnPointerExit depending on parameter isCollapsed ({isCollapsed})");
                    Logger.Sleep();

                    PointerEventData dummyPointerEventData = new PointerEventData(EventSystem.current);
                    if (isCollapsed)
                    {
                        __instance.OnPointerEnter(dummyPointerEventData);
                    }
                    else
                    {
                        __instance.OnPointerExit(dummyPointerEventData);
                    }
                    Logger.Wake();
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                }
            }
Esempio n. 9
0
            static void Postfix(SGNavigationList __instance, HBSRadioSet ___radioSet, SGNavigationButton ___argoButton)
            {
                if (__instance.navParent != null)
                {
                    Mod.Log.Info?.Write($"SGNL:Start - adding new button.");
                    SimGameState simulation = UnityGameInstance.BattleTechGame.Simulation;

                    try {
                        // Create the store button
                        Mod.Log.Info?.Write(" - Creating store button");
                        GameObject storeButtonGO = GameObject.Instantiate(___argoButton.gameObject);
                        storeButtonGO.SetActive(true);
                        storeButtonGO.transform.position = ___argoButton.gameObject.transform.position;
                        storeButtonGO.transform.SetParent(___argoButton.gameObject.transform.parent);
                        storeButtonGO.transform.localScale = Vector3.one;
                        storeButtonGO.transform.SetSiblingIndex(1);

                        storeButton = storeButtonGO.GetComponent <SGNavigationButton>();
                        Traverse storeButtonT = Traverse.Create(storeButton).Field("id");
                        storeButtonT.SetValue(DropshipLocation.SHIP);
                        storeButton.SetupElement(__instance, ___radioSet, "Store",
                                                 LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.DropshipRoomCaptainsQuartersIcon, simulation);

                        // Create the staff button
                        Mod.Log.Info?.Write(" - Creating staff button");
                        GameObject staffButtonGO = GameObject.Instantiate(___argoButton.gameObject);
                        staffButtonGO.SetActive(true);
                        staffButtonGO.transform.position = ___argoButton.gameObject.transform.position;
                        staffButtonGO.transform.SetParent(___argoButton.gameObject.transform.parent);
                        staffButtonGO.transform.localScale = Vector3.one;
                        staffButtonGO.transform.SetSiblingIndex(7);

                        staffButton = staffButtonGO.GetComponent <SGNavigationButton>();
                        Traverse staffButtonT = Traverse.Create(staffButton).Field("id");
                        staffButtonT.SetValue(DropshipLocation.CMD_CENTER);

                        staffButton.SetupElement(__instance, ___radioSet, "CMD Staff",
                                                 LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.DropshipRoomCommandCenterIcon, simulation);
                        staffButton.AddFlyoutButton("Darius", DropshipMenuType.Darius);
                        staffButton.AddFlyoutButton("Yang", DropshipMenuType.Yang);
                        staffButton.AddFlyoutButton("Sumire", DropshipMenuType.Sumire);
                        staffButton.AddFlyoutButton("Farah", DropshipMenuType.Farah);
                        if (simulation.GetCharacterStatus(SimGameState.SimGameCharacterType.ALEXANDER))
                        {
                            staffButton.AddFlyoutButton("Alexander", DropshipMenuType.Alexander);
                        }

                        // Create the memorial button
                        Mod.Log.Info?.Write(" - Creating memorial button");
                        GameObject memorialButtonGO = GameObject.Instantiate(___argoButton.gameObject);
                        memorialButtonGO.SetActive(true);
                        memorialButtonGO.transform.position = ___argoButton.gameObject.transform.position;
                        memorialButtonGO.transform.SetParent(___argoButton.gameObject.transform.parent);
                        memorialButtonGO.transform.localScale = Vector3.one;
                        memorialButtonGO.transform.SetSiblingIndex(9);

                        memorialButton = memorialButtonGO.GetComponent <SGNavigationButton>();
                        Traverse memorialButtonT = Traverse.Create(memorialButton).Field("id");
                        memorialButtonT.SetValue(DropshipLocation.BARRACKS);

                        memorialButton.SetupElement(__instance, ___radioSet, "Memorial",
                                                    LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.DropshipRoomBarracksIcon, simulation);
                        //memorialButton.AddFlyoutButton("Memorial Wall", DropshipMenuType.MemorialWall);
                    } catch (Exception e) {
                        Mod.Log.Info?.Write("Error: " + e.Message);
                    }
                }
            }
Esempio n. 10
0
            static void Postfix(SGNavigationButton __instance, SGNavigationList ___buttonParent, LocalizableText ___text)
            {
                Mod.Log.Debug?.Write($"SGNB:OC - button clicked for ID: {__instance.ID}");
                SimGameState simulation = UnityGameInstance.BattleTechGame.Simulation;

                switch (__instance.ID)
                {
                case DropshipLocation.CMD_CENTER:
                    QueueOrForceActivation(DropshipMenuType.Contract, __instance.ID, ___buttonParent.navParent, simulation);
                    if (SGNavigationButton_FlyoutClicked.ClickedID != DropshipMenuType.INVALID_UNSET)
                    {
                        if (___text.text.Contains("CMD Staff"))
                        {
                            switch (SGNavigationButton_FlyoutClicked.ClickedID)
                            {
                            case DropshipMenuType.Darius:
                            case DropshipMenuType.Alexander:
                                QueueOrForceActivation(SGNavigationButton_FlyoutClicked.ClickedID, DropshipLocation.CMD_CENTER, ___buttonParent.navParent, simulation);
                                break;

                            case DropshipMenuType.Yang:
                                QueueOrForceActivation(SGNavigationButton_FlyoutClicked.ClickedID, DropshipLocation.MECH_BAY, ___buttonParent.navParent, simulation);
                                break;

                            case DropshipMenuType.Sumire:
                                QueueOrForceActivation(SGNavigationButton_FlyoutClicked.ClickedID, DropshipLocation.NAVIGATION, ___buttonParent.navParent, simulation);
                                break;

                            case DropshipMenuType.Farah:
                                QueueOrForceActivation(SGNavigationButton_FlyoutClicked.ClickedID, DropshipLocation.ENGINEERING, ___buttonParent.navParent, simulation);
                                break;

                            default:
                                break;
                            }
                        }
                        else if (___text.text.Contains("Memorial"))
                        {
                            QueueOrForceActivation(SGNavigationButton_FlyoutClicked.ClickedID, DropshipLocation.BARRACKS, ___buttonParent.navParent, simulation);
                        }
                        SGNavigationButton_FlyoutClicked.ClickedID = DropshipMenuType.INVALID_UNSET;
                    }
                    break;

                case DropshipLocation.BARRACKS:
                    QueueOrForceActivation(DropshipMenuType.Mechwarrior, __instance.ID, ___buttonParent.navParent, simulation);
                    break;

                case DropshipLocation.ENGINEERING:
                    QueueOrForceActivation(DropshipMenuType.ShipUpgrade, __instance.ID, ___buttonParent.navParent, simulation);
                    break;

                case DropshipLocation.MECH_BAY:
                    QueueOrForceActivation(DropshipMenuType.MechBay, __instance.ID, ___buttonParent.navParent, simulation);
                    break;

                case DropshipLocation.NAVIGATION:
                    QueueOrForceActivation(DropshipMenuType.Navigation, __instance.ID, ___buttonParent.navParent, simulation);
                    break;

                default:
                    break;
                }

                if (___text.text.Contains("Store"))
                {
                    if (simulation.CurRoomState != DropshipLocation.SHOP)
                    {
                        ___buttonParent.ArgoButtonFlyoutChangeRoom(DropshipLocation.SHOP);
                    }
                    QueueOrForceActivation(DropshipMenuType.Shop, DropshipLocation.SHOP, ___buttonParent.navParent, simulation);
                }
                else if (___text.text.Contains("Memorial"))
                {
                    if (simulation.CurRoomState != DropshipLocation.BARRACKS)
                    {
                        ___buttonParent.ArgoButtonFlyoutChangeRoom(DropshipLocation.BARRACKS);
                    }
                    QueueOrForceActivation(DropshipMenuType.MemorialWall, DropshipLocation.BARRACKS, ___buttonParent.navParent, simulation);
                }
            }