Beispiel #1
0
        public void AddAppearance(OxHelpers.ElementState type, Texture2D[] appearance)
        {
            if (appearance.Length == 9)
            {
                for (int i = 0; i < 9; i++)
                {
                    Texture2D currentTexture = appearance[i];
                    Texture2D safeTexture    = new Texture2D(currentTexture.width, currentTexture.height);
                    safeTexture.SetPixels(currentTexture.GetPixels());
                    safeTexture.Apply();
                    appearances[((int)type), i] = safeTexture;
                }

                float centerWidth = appearance[(int)OxHelpers.Alignment.Center].width, rightWidth = appearance[(int)OxHelpers.Alignment.Right].width, leftWidth = appearance[(int)OxHelpers.Alignment.Left].width;
                float centerHeight = appearance[(int)OxHelpers.Alignment.Center].height, topHeight = appearance[(int)OxHelpers.Alignment.Top].height, bottomHeight = appearance[(int)OxHelpers.Alignment.Bottom].height;
                float percentWidth  = centerWidth / (centerWidth + rightWidth + leftWidth);
                float percentHeight = centerHeight / (centerHeight + topHeight + bottomHeight);

                centerPercentWidth  = percentWidth;
                centerPercentHeight = percentHeight;

                origInfo[(int)type].originalWidth      = leftWidth + centerWidth + rightWidth;
                origInfo[(int)type].originalHeight     = topHeight + centerHeight + bottomHeight;
                origInfo[(int)type].originalSideWidth  = leftWidth + rightWidth;
                origInfo[(int)type].percentRight       = rightWidth / origInfo[(int)type].originalSideWidth;
                origInfo[(int)type].originalSideHeight = topHeight + bottomHeight;
                origInfo[(int)type].percentTop         = topHeight / origInfo[(int)type].originalSideHeight;
            }
        }
Beispiel #2
0
        public void ClearAppearance(OxHelpers.ElementState type)
        {
            for (int i = 0; i < 9; i++)
            {
                appearances[((int)type), i] = null;
            }

            origInfo[(int)type].originalWidth      = 0;
            origInfo[(int)type].originalHeight     = 0;
            origInfo[(int)type].originalSideWidth  = 0;
            origInfo[(int)type].percentRight       = 0;
            origInfo[(int)type].originalSideHeight = 0;
            origInfo[(int)type].percentTop         = 0;
        }
Beispiel #3
0
 protected OxHelpers.ElementState GetTexturableState()
 {
     OxHelpers.ElementState availableState = currentState;
     if (appearances[((int)availableState), ((int)OxHelpers.Alignment.Center)] == null)
     {
         if (appearances[((int)OxHelpers.ElementState.Normal), ((int)OxHelpers.Alignment.Center)] != null)
         {
             availableState = OxHelpers.ElementState.Normal;
         }
         if (appearances[((int)OxHelpers.ElementState.Highlighted), ((int)OxHelpers.Alignment.Center)] != null)
         {
             availableState = OxHelpers.ElementState.Highlighted;
         }
         if (appearances[((int)OxHelpers.ElementState.Down), ((int)OxHelpers.Alignment.Center)] != null)
         {
             availableState = OxHelpers.ElementState.Down;
         }
     }
     return(availableState);
 }