예제 #1
0
        // c'tor
        public ColorPalette()
        {
            // Create elements for the color buttons.
            // Start with a blob of common parameters.
            UIGridElement.ParamBlob blob = new UIGridElement.ParamBlob();
            blob.width           = 1.0f;
            blob.height          = 1.0f;
            blob.edgeSize        = 0.5f;
            blob.selectedColor   = Color.White;
            blob.unselectedColor = Color.White;
            blob.normalMapName   = @"QuarterRound4NormalMap";

            int numColors = (int)Classification.Colors.SIZEOF - 1;

            buttonHitBoxes = new AABB2D[numColors];
            for (int i = 0; i < numEntries; i++)
            {
                buttonHitBoxes[i] = new AABB2D();
            }

            for (int i = 0; i < numEntries; i++)
            {
                buttons[i]     = new UIGrid2DTextureElement(blob, null);
                buttons[i].NoZ = false;

                // Set initial size.
                textureSize[i] = inactiveSize;

                buttons[i].BaseColor = Classification.ColorVector4(GetColorFromIndex(i));
            }

            camera = new UiCamera();
        }
예제 #2
0
            }   // end of UpdateObj c'tor

            public override void Render(Camera camera)
            {
                // We don't want UI objects being thrown into the regular shadow pass but
                // since they're in the same renderlist we just have to deal with it.  It
                // seems to make more sense here to test and bail than to test every single
                // shadow casting object.

                if (active && (InGame.inGame.renderEffects == InGame.RenderEffect.Normal))
                {
                    // Set up standard UI lighting for any wrapped objects.

                    string oldRig = BokuGame.bokuGame.shaderGlobals.PushLightRig(ShaderGlobals.UIRigName);
                    effect.Parameters["EyeLocation"].SetValue(new Vector4(shared.camera.ActualFrom, 1.0f));

                    effect.Parameters["Shininess"].SetValue(1.0f);
                    effect.Parameters["ShadowAttenuation"].SetValue(0.5f);

                    // Temp disable of blur
                    float dof_maxBlur = effect.Parameters["DOF_MaxBlur"].GetValueSingle();
                    effect.Parameters["DOF_MaxBlur"].SetValue(0.0f);

                    // Temporarily disable any batching. We want our stuff
                    // rendered immediatately.
                    bool batch = InGame.inGame.PushBatching(false);
                    // Make sure we render the best version we have.
                    FBXModel.LockLowLOD = FBXModel.LockLOD.kHigh;
                    // Render our children using the shared UI camera.
                    UiCamera c = shared.camera as UiCamera;
                    c.Offset = Vector3.Zero;
                    for (int i = 0; i < renderList.Count; i++)
                    {
                        RenderObject obj = renderList[i];
                        obj.Render(shared.camera);
                    }
                    FBXModel.LockLowLOD = FBXModel.LockLOD.kAny;
                    InGame.inGame.PopBatching(batch);

                    // Restore the real DOF_MaxBlur.
                    effect.Parameters["DOF_MaxBlur"].SetValue(dof_maxBlur);

                    BokuGame.bokuGame.shaderGlobals.PopLightRig(oldRig);
                }
            }
예제 #3
0
        /// <summary>
        /// Based on the size of each element and the margins, calculate its position.
        /// </summary>
        public void CalcPositions(UiCamera camera)
        {
            Vector2 cur = new Vector2(0, currentY);

            // Lay out the textures left to right.
            for (int i = 0; i < numEntries; i++)
            {
                texturePosition[i] = cur;
                cur.X += textureSize[i] + swatchMargin;
            }

            // Calculate the overall width so that we can center the palette on the screen.
            float width    = cur.X - swatchMargin;
            float leftEdge = -width / 2.0f;

            // Calc position of each button.
            texturePosition[0].X = leftEdge + textureSize[0] / 2.0f;
            for (int i = 1; i < numEntries; i++)
            {
                texturePosition[i].X = texturePosition[i - 1].X + textureSize[i - 1] / 2.0f + textureSize[i] / 2.0f + swatchMargin;
            }

            // Calculate the hit boxes for each button
            for (int i = 0; i < numEntries; i++)
            {
                // Since the color boxes are perfectly square and of unit size, we can use the scalar size value
                // to determine the button's actual dimensions.
                // Also, the texture position represents the center of the button, so we need to adjust for our
                // actual button position (the top left).
                Vector2 buttonPosition = texturePosition[i] -
                                         new Vector2(textureSize[i] / 2.0f, -textureSize[i] / 2.0f);
                Point   topLeftCoord = camera.WorldToScreenCoords(new Vector3(buttonPosition, 0.0f));
                Vector2 textureBottomRightPosition =
                    new Vector2(textureSize[i], -textureSize[i]) + buttonPosition;
                Point bottomRightCoord = camera.WorldToScreenCoords(
                    new Vector3(textureBottomRightPosition, 0.0f));
                buttonHitBoxes[i].Set(
                    new Vector2(topLeftCoord.X, topLeftCoord.Y),
                    new Vector2(bottomRightCoord.X, bottomRightCoord.Y)
                    );
            }
        }   // end of ColorPalette CalcPositions()
예제 #4
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);
            };

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

            //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);
            }



            // 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"));
        }