Ejemplo n.º 1
0
        public static void Initialize()
        {
            //Note that the game will destroy the UI when you go to the main menu, so we'll have to rebuild it.
            //The best way to check if we need to initialize everything seem to be the following, though it's strange messy.
            if (IsInitialized)
            {
                return;
            }

            //This is the 'Customize UI' button that lets you customize the UI.
            _customizeButton = new QuickButton(UIPartyPortraitBar.Instance.transform.parent)
            {
                Caption       = "Customize UI",
                Name          = "CustomizeUI",
                LocalPosition = new Vector3(903.5f, 76.2f, 0f),
                LocalScale    = new Vector3(0.7f, 0.7f, 1f)
            };

            _customizeButton.Click += x => {
                SaveLayout(IEModOptions.Layout);
                ShowInterface(!IsInterfaceVisible);
            };

            //these may break in future version changes, but I doubt they'll break much.
            //since changing them will probably break some of the developer's code as well
            //to fix them, dump the UICamera hierarchy to file and see which names changed.
            //using Child(string) also tells you which names are broken because it throws an exception if it can't find something,
            //instead of silently returning null and letting you figure out where the problem came from.
            if (DefaultLayout == null)
            {
                DefaultLayout = new IEModOptions.LayoutOptions();
                SaveLayout(DefaultLayout);
            }

            DefaultActionBarAtlas =
                Attack.Child(0).Component <UISprite>().atlas.spriteMaterial.mainTexture;

            // turning off BB-version label in the upper right corner, cause it's annoying when you want to move portraits there
            UiCamera.Child("BBVersion").gameObject.SetActive(false);

            // UIAnchors on the ActionBarWindow that prevent it from being moved... (it's related to the partybar somehow?)
            // HUD -> Bottom -> ActionBarWindow -> destroy 3 UIAnchors
            foreach (var comp in ActionBarWindow.Components <UIAnchor>())
            {
                GameUtilities.DestroyComponent(comp);
            }

            var component = ConsoleWindow.Component <UIAnchor>();

            if (component)
            {
                GameUtilities.DestroyComponent(component);
            }

            // disable the minimize buttons for the log and the actionbar
            Bottom.Child("ConsoleMinimize").SetActive(false);
            Bottom.Child("ActionBarMinimize").gameObject.SetActive(false);

            // this UIPanel used to hide the clock when it was moved from far away from its original position
            // HUD -> Bottom -> ActionBarWindow -> ActionBarExpandedAnchor -> UIPanel
            ActionBarWindow.Component <UIPanel>().clipping = UIDrawCall.Clipping.None;

            // detaches the "GAME PAUSED" and "SLOW MO" from the Clock panel, to which it was attached for some reason...
            var gamePausedAnchors = UiCamera.Child("GamePaused").Components <UIAnchor>();

            gamePausedAnchors[0].widgetContainer = Hud.Component <UIPanel>().widgets[0];
            gamePausedAnchors[1].DisableY        = true;
            var slowMoAnchors = UiCamera.Child("GameSpeed").Components <UIAnchor>();

            slowMoAnchors[0].widgetContainer = Hud.Component <UIPanel>().widgets[0];
            slowMoAnchors[1].DisableY        = true;
            PartyBar.AddChild(new GameObject("IsInitialized"));
        }