Exemplo n.º 1
0
        /// <summary>
        /// Executes this command
        /// </summary>
        public override void Execute()
        {
            var sb = new List <string>();

            //Just do a look on the room
            if (Subject == null)
            {
                sb.AddRange(OriginLocation.RenderToLook(Actor));
            }
            else
            {
                var lookTarget = (ILookable)Subject;
                sb.AddRange(lookTarget.RenderToLook(Actor));
            }

            var messagingObject = new MessageCluster(sb, new string[] { "$A$ looks at you." }, new string[] { }, new string[] { "$A$ looks around the room." }, new string[] { });

            messagingObject.ExecuteMessaging(Actor, (IEntity)Subject, null, OriginLocation, null);
        }
Exemplo n.º 2
0
        internal long Add(long scheduleId, OriginLocation location)
        {
            var databaseId = GetNewId();
            var row        = Table.NewRow();

            row["Id"]                   = databaseId;
            row["ScheduleId"]           = scheduleId;
            row["LocationId"]           = _lookup.Find(location.Location);
            row["Sequence"]             = location.Sequence;
            row["WorkingDeparture"]     = (object)location.WorkingDeparture ?? DBNull.Value;
            row["PublicDeparture"]      = (object)location.PublicDeparture ?? DBNull.Value;
            row["Platform"]             = location.Platform;
            row["Line"]                 = location.Line;
            row["Activities"]           = location.Activities;
            row["EngineeringAllowance"] = location.EngineeringAllowance;
            row["PathingAllowance"]     = location.PathingAllowance;
            row["PerformanceAllowance"] = location.PerformanceAllowance;
            Table.Rows.Add(row);
            return(databaseId);
        }
        public void PushOriginMatrix(OriginLocation origin, GUIRenderLayer layer)
        {
            switch (origin)
            {
            case OriginLocation.LowerLeft:     // where we start
                layer.PushMatrix(Matrix4.Identity);
                break;

            case OriginLocation.MiddleLeft:
                layer.PushTranslation(0, PixelSize.Y, 0);
                break;

            case OriginLocation.UpperLeft:
                layer.PushTranslation(0, PixelSize.Y * 2, 0);
                break;

            case OriginLocation.UpperCenter:
                layer.PushTranslation(PixelSize.X, PixelSize.Y, 0);
                break;

            case OriginLocation.UpperRight:
                layer.PushTranslation(PixelSize.X * 2, PixelSize.Y * 2, 0);
                break;

            case OriginLocation.MiddleRight:
                layer.PushTranslation(PixelSize.X * 2, PixelSize.Y, 0);
                break;

            case OriginLocation.LowerRight:
                layer.PushTranslation(PixelSize.X * 2, 0, 0);
                break;

            case OriginLocation.LowerCenter:
                layer.PushTranslation(PixelSize.X, 0, 0);
                break;

            case OriginLocation.Center:
                layer.PushTranslation(PixelSize.X, PixelSize.Y, 0);
                break;
            }
        }
Exemplo n.º 4
0
        protected OriginLocation GetLowerAnchor(OriginLocation anchor)
        {
            switch (anchor)
            {
            case OriginLocation.Center:
            case OriginLocation.UpperCenter:
            case OriginLocation.LowerCenter:
                return(OriginLocation.LowerCenter);

            case OriginLocation.LowerLeft:
            case OriginLocation.MiddleLeft:
            case OriginLocation.UpperLeft:
            default:
                return(OriginLocation.LowerLeft);

            case OriginLocation.LowerRight:
            case OriginLocation.MiddleRight:
            case OriginLocation.UpperRight:
                return(OriginLocation.LowerRight);
            }
        }
Exemplo n.º 5
0
        public static OriginLocation GetMiddleAnhcor(OriginLocation anchor)
        {
            switch (anchor)
            {
            case OriginLocation.MiddleLeft:
            case OriginLocation.MiddleRight:
            case OriginLocation.Center:
                return(anchor);

            case OriginLocation.UpperLeft:
            case OriginLocation.LowerLeft:
                return(OriginLocation.MiddleLeft);

            case OriginLocation.UpperRight:
            case OriginLocation.LowerRight:
                return(OriginLocation.MiddleRight);

            default:
                return(OriginLocation.Center);
            }
        }
Exemplo n.º 6
0
        public UIImage(string texture, RelativePoint origin, OriginLocation anchor = OriginLocation.Center, RelativeSize _width = null, RelativeSize _height = null) : base()
        {
            IgnoreMouse = true;

            RelativeSize height = _height;
            RelativeSize width  = _width;

            DefaultMaterial = new GUIMaterial(texture, Color.White);
            CheckMaterial();

            if (CurrentMaterial == null || CurrentMaterial.DiffuseTexture == null || CurrentMaterial.DiffuseTexture.PixelSize.X == 0 || CurrentMaterial.DiffuseTexture.PixelSize.Y == 0)
            {
                return;
            }

            if (width == null && height == null)
            {
                // going raw.
                width           = new RelativeSize();
                width.Raw       = true;
                width.Paramater = CurrentMaterial.DiffuseTexture.PixelSize.X;

                height           = new RelativeSize();
                height.Raw       = true;
                height.Paramater = CurrentMaterial.DiffuseTexture.PixelSize.Y;
            }
            else if (width == null)
            {
                width = RelativeTools.GetRelativeWidthInAspect(height, CurrentMaterial.DiffuseTexture.PixelSize.X, CurrentMaterial.DiffuseTexture.PixelSize.Y);
            }
            else if (height == null)
            {
                height = RelativeTools.GetRelativeHeightInAspect(width, CurrentMaterial.DiffuseTexture.PixelSize.X, CurrentMaterial.DiffuseTexture.PixelSize.Y);
            }

            Rect = new RelativeRect(origin.X, origin.Y, width, height, anchor);
        }
        protected static Vector2 GetChildOrigin(Vector2 cellOrigin, Vector2 cellSize, float actualHeight, OriginLocation anchor)
        {
            float halfX = cellSize.X * 0.5f;
            float halfY = cellSize.Y * 0.5f;

            float cellY      = cellOrigin.Y;
            float cellHeight = cellSize.Y;

            if (actualHeight < cellSize.Y)
            {
                cellY     += ((cellSize.Y - actualHeight) * 0.5f);
                halfY      = actualHeight * 0.5f;
                cellHeight = actualHeight;
            }

            switch (anchor)
            {
            case OriginLocation.Center:
                return(new Vector2(cellOrigin.X + halfX, cellY + halfY));

            case OriginLocation.MiddleLeft:
                return(new Vector2(cellOrigin.X, cellY + halfY));

            case OriginLocation.UpperLeft:
                return(new Vector2(cellOrigin.X, cellY + cellHeight));

            case OriginLocation.UpperCenter:
                return(new Vector2(cellOrigin.X + halfX, cellY + cellHeight));

            case OriginLocation.UpperRight:
                return(new Vector2(cellOrigin.X + cellSize.X, cellY + cellHeight));

            case OriginLocation.MiddleRight:
                return(new Vector2(cellOrigin.X + cellSize.X, cellY + halfY));

            case OriginLocation.LowerRight:
                return(new Vector2(cellOrigin.X + cellSize.X, cellY));

            case OriginLocation.LowerCenter:
                return(new Vector2(cellOrigin.X + halfX, cellY));

            default:
                return(cellOrigin);
            }
        }
Exemplo n.º 8
0
 public virtual void SetAnchor(OriginLocation anchor)
 {
     AnchorLocation = anchor;
 }
Exemplo n.º 9
0
 public virtual void Set(RelativePoint origin, RelativeSizeXY size, OriginLocation anchor)
 {
     SetLocation(origin.X, origin.Y);
     SetSize(size.Width, size.Height);
     AnchorLocation = anchor;
 }
Exemplo n.º 10
0
 public virtual void Set(RelativeLoc x, RelativeLoc y, RelativeSize w, RelativeSize h, OriginLocation anchor)
 {
     SetLocation(x, y);
     SetSize(w, h);
     AnchorLocation = anchor;
 }
Exemplo n.º 11
0
 public static void SetOriginLocation(OriginLocation origin)
 {
     IL.ilOriginFunc((uint)origin);
 }
Exemplo n.º 12
0
 // Initialising the origin location
 public Animator(OriginLocation location)
 {
     originLocation = location;
 }
Exemplo n.º 13
0
        public override void ProcessMouseEvent(Vector2 location, InputManager.LogicalButtonState buttons)
        {
            if (Math.Abs(buttons.WheelTick) > 0 && TextLabels.Count > 1)
            {
                SetSelectedIndex(SelectedIndex + buttons.WheelTick);
            }

            if (!buttons.PrimaryClick || ParentCanvas == null || ParentCanvas.PopupEnabled() || TextLabels.Count < 2)
            {
                return;
            }

            float width  = Rect.GetPixelSize().X;
            float height = Rect.GetPixelSize().Y;

            Vector2 origin = Rect.GetPixelOrigin();

            float availableDist = width - (height * 2);

            if (location.X < origin.X + height || location.X > origin.X + availableDist + height)
            {
                return;
            }

            Vector2 thisOrigin = GetScreenOrigin();

            float thisCenterY = thisOrigin.Y + (height * 0.5f);

            float totalheight = (MenuCommon.ButtonSpacing.Paramater + (height * 1)) * TextLabels.Count;

            totalheight += MenuCommon.ButtonSpacing.Paramater * 1;

            float halfHeight = totalheight * 0.5f;

            float screenHeight = ParentCanvas.BoundWindow.Height;

            // see where the popup will land on the screen.

            OriginLocation originAllignment = OriginLocation.LowerLeft;

            if (totalheight > screenHeight)  // it won't fit, center it
            {
                originAllignment = OriginLocation.MiddleLeft;
            }
            else
            {
                if (thisCenterY - halfHeight > 0 && thisCenterY + halfHeight <= screenHeight)
                {
                    originAllignment = OriginLocation.MiddleLeft; // it'll fit centered, that looks better
                }
                else
                {
                    // it won't fit centered, so put it on the other side of the screen from where the button is
                    if (thisCenterY > halfHeight)
                    {
                        originAllignment = OriginLocation.UpperLeft;
                    }
                    else
                    {
                        originAllignment = OriginLocation.LowerLeft;
                    }
                }
            }

            if (originAllignment == OriginLocation.UpperLeft)
            {
                thisOrigin.Y += height;
            }
            else if (originAllignment == OriginLocation.MiddleLeft)
            {
                thisOrigin.Y += height * 0.5f;
            }

            RelativeRect rect = new RelativeRect(new RelativeLoc(thisOrigin.X, RelativeLoc.Edge.Raw), new RelativeLoc(thisOrigin.Y, RelativeLoc.Edge.Raw), RelativeSize.FixedPixelSize(width), RelativeSize.FixedPixelSize(totalheight), originAllignment);

            var popup = new UIPanel(rect, ThemeManager.GetThemeAsset("ui/SelectorPopupBackground.png"));

            popup.FillMode    = UIFillModes.SmartStprite;
            popup.IgnoreMouse = false;

            VerticalLayoutGroup vertgroup = MenuCommon.SetupCommonColumn(new RelativeRect(RelativeLoc.XCenter, RelativeLoc.YCenter, RelativeSize.ThreeQuarterWidth, rect.Height, OriginLocation.Center));

            vertgroup.FirstElementHasSpacing = true;

            foreach (var label in TextLabels)
            {
                MenuButton button = new MenuButton(new RelativeRect(), label);
                button.Tag      = label;
                button.Clicked += PopupButton_Clicked;
                if (label == GetText())
                {
                    button.Check();
                }

                vertgroup.AddChild(button);
            }
            popup.AddChild(vertgroup);

            ParentCanvas.SetPopupElement(popup);
        }
Exemplo n.º 14
0
 public GraphicHandler DrawTexture(Texture2D source, int x, int y, int width, int height, float rotation, OriginLocation Origin = OriginLocation.Middle)
 {
     switch (Origin)
     {
         case OriginLocation.Middle:
             this.spriteBatch.Draw(source, new Vector2(x, y), new Rectangle(0, 0, width, height), Color.White, rotation, new Vector2(width / 2, height / 2), new Vector2(xScale, yscale), SpriteEffects.None, 1.0f);
             break;
         case OriginLocation.TopLeft:
             this.spriteBatch.Draw(source, new Vector2(x, y), new Rectangle(0, 0, width, height), Color.White, rotation, Vector2.Zero, new Vector2(xScale, yscale), SpriteEffects.None, 1.0f);
             break;
         case OriginLocation.TopRight:
             this.spriteBatch.Draw(source, new Vector2(x, y), new Rectangle(0, 0, width, height), Color.White, rotation, new Vector2(width, 0), new Vector2(xScale, yscale), SpriteEffects.None, 1.0f);
             break;
         case OriginLocation.BottomLeft:
             this.spriteBatch.Draw(source, new Vector2(x, y), new Rectangle(0, 0, width, height), Color.White, rotation, new Vector2(0, height), new Vector2(xScale, yscale), SpriteEffects.None, 1.0f);
             break;
         case OriginLocation.BottomRight:
             this.spriteBatch.Draw(source, new Vector2(x, y), new Rectangle(0, 0, width, height), Color.White, rotation, new Vector2(width, height), new Vector2(xScale, yscale), SpriteEffects.None, 1.0f);
             break;
         case OriginLocation.MiddleTop:
             this.spriteBatch.Draw(source, new Vector2(x, y), new Rectangle(0, 0, width, height), Color.White, rotation, new Vector2(width / 2, 0), new Vector2(xScale, yscale), SpriteEffects.None, 1.0f);
             break;
         case OriginLocation.MiddleBottom:
             this.spriteBatch.Draw(source, new Vector2(x, y), new Rectangle(0, 0, width, height), Color.White, rotation, new Vector2(width / 2, height), new Vector2(xScale, yscale), SpriteEffects.None, 1.0f);
             break;
         case OriginLocation.MiddleLeft:
             this.spriteBatch.Draw(source, new Vector2(x, y), new Rectangle(0, 0, width, height), Color.White, rotation, new Vector2(0, height / 2), new Vector2(xScale, yscale), SpriteEffects.None, 1.0f);
             break;
         case OriginLocation.MiddleRight:
             this.spriteBatch.Draw(source, new Vector2(x, y), new Rectangle(0, 0, width, height), Color.White, rotation, new Vector2(width, height / 2), new Vector2(xScale, yscale), SpriteEffects.None, 1.0f);
             break;
         default:
             break;
     }
     return this;
 }
Exemplo n.º 15
0
 public GraphicHandler DrawActiveTexture(int x, int y, int width, int height, float rotation, OriginLocation Origin = OriginLocation.Middle)
 {
     DrawTexture(this.ActiveTexture, x, y, width, height, rotation, Origin);
     return this;
 }
Exemplo n.º 16
0
        /// <summary>
        /// Reads ILImage struct information and populates relevent fields.
        /// Recursively (ew...) counts mips. Returns number of mips.
        /// </summary>
        /// <param name="BasePointer">Pointer to ILImage struct.</param>
        /// <param name="toplevel">True only when first called. All recursive stuff is False.</param>
        /// <returns>Number of mipmaps.</returns>
        private unsafe int CountMipsAndGetDetails(uint *BasePointer, bool toplevel = true)
        {
            int mipcount = 1;

            // KFreon: Read image dimensions
            int W     = (int)*BasePointer++;
            int H     = (int)*BasePointer++;
            int Depth = (int)*BasePointer++;


            // KFreon: Go to byte* land.
            byte *bytePtr        = (byte *)BasePointer;
            uint  BPP            = *bytePtr++;
            int   BitsPerChannel = *bytePtr++;

            bytePtr += 2;  // KFreon: Fix alignment

            // KFreon: Go back to uint* land.
            BasePointer = (uint *)bytePtr;
            uint BitsPerPScanLine = (uint)*BasePointer++;

            if (IntPtr.Size == 8)  // KFreon: x64 alignment?
            {
                BasePointer++;
            }

            // KFreon: Round and round the mulberry bush...
            uint *dataPtr = (uint *)(BasePointer += (IntPtr.Size / 4));

            int            datasize  = (int)*BasePointer++;
            int            PlaneSize = (int)*BasePointer++;
            DataFormat     memform   = (DataFormat)(*BasePointer++);
            DataType       datatyp   = (DataType)(*BasePointer++);
            OriginLocation origin    = (OriginLocation)(*BasePointer++);

            if (IntPtr.Size == 8)  // KFreon: x64 alignment?
            {
                BasePointer++;
            }

            // KFreon: Skip palette
            BasePointer += 7;     // x86 = 1C, x64 = 28

            if (IntPtr.Size == 8) // KFreon: Alignment or no idea...
            {
                BasePointer += 3;
            }

            int         duration  = (int)*(BasePointer++);
            CubeMapFace cubeflags = (CubeMapFace)(*BasePointer++);


            #region CHECK MIPS
            long *th = (long *)BasePointer;
            th = (long *)*th;

            // KFreon: If there's a mip left, read it and increment mip count recursivly (Ugh...)
            if (th != (uint *)0)
            {
                mipcount += CountMipsAndGetDetails((uint *)th, false);
            }
            #endregion

            BasePointer++;        // KFreon: Alignment?

            if (IntPtr.Size == 8) // KFreon: x64 alignment?
            {
                BasePointer++;
            }

            int Next        = (int)*BasePointer++;
            int Faces       = (int)*BasePointer++;
            int Layers      = (int)*BasePointer++;
            int animlist    = (int)*BasePointer++;
            int animsize    = (int)*BasePointer++;
            int profile     = (int)*BasePointer++;
            int profilesize = (int)*BasePointer++;
            int offx        = (int)*BasePointer++;
            int offy        = (int)*BasePointer++;


            // KFreon: Imma byte this pointer
            bytePtr = (byte *)BasePointer;
            int dxtcdataPtr = (int)*bytePtr++;
            bytePtr += 3; // KFreon: Alignment


            // KFreon: Uint gonna byte me!
            BasePointer = (uint *)bytePtr;

            if (IntPtr.Size == 8)  // KFreon: uhh....
            {
                BasePointer += 8;
            }

            CompressedDataFormat surface = (CompressedDataFormat)(*BasePointer++);
            int dxtcsize = (int)*BasePointer++;

            // KFreon: Set original image properties
            if (toplevel)
            {
                Width         = W;
                Height        = H;
                BitsPerPixel  = (int)BPP;
                Channels      = BitsPerChannel;
                DataSize      = datasize;
                MemoryFormat  = memform;
                DataType      = datatyp;
                SurfaceFormat = surface;
            }

            return(mipcount);
        }
Exemplo n.º 17
0
Arquivo: IL.cs Projeto: Kolky/open3mod
 public static void SetOriginLocation(OriginLocation origin) {
     ilOriginFunc((uint) origin);
 }
Exemplo n.º 18
0
        public UILabel(int font, string text, Color color, RelativePoint origin, RelativeSize height, RelativeSize width = null, OriginLocation anchor = OriginLocation.Center, TextFittingModes mode = TextFittingModes.ByHeightExtend) : base()
        {
            IgnoreMouse = true;
            FittingMode = mode;
            Text        = text;
            Font        = font;

            if (width == null)
            {
                width = RelativeSize.FullWidth;
            }

            DefaultMaterial.Color = color;
            Rect = new RelativeRect(origin.X, origin.Y, width, height, anchor);
        }
Exemplo n.º 19
0
 public RelativeRect(RelativeLoc x, RelativeLoc y, RelativeSize w, RelativeSize h, OriginLocation anchor)
 {
     Set(x, y, w, h);
     AnchorLocation = anchor;
 }
Exemplo n.º 20
0
        public override void Resize(int x, int y)
        {
            LastParentSize.X = x;
            LastParentSize.Y = y;

            Inited = true;

            Rect.Resize(x, y);

            if (Columns == 0 || Rows == 0)
            {
                return; // must have at least one of each
            }
            PixelSize = Rect.GetPixelSize();

            AvalableSize.X = PixelSize.X - (CellPadding * (Columns + 1));
            AvalableSize.Y = PixelSize.Y - (CellPadding * (Rows + 1));

            CellSize    = new Vector2(AvalableSize.X / Columns, AvalableSize.Y / Rows);
            ColSpanSize = new Vector2(PixelSize.X - (CellPadding * 2), CellSize.Y);

            if (CellSize.X < 2 || CellSize.Y < 2)
            {
                return; // there isn't enough room to do anything
            }
            foreach (var child in Children)
            {
                GridLayoutInfo info = child.LayoutTag as GridLayoutInfo;
                if (info == null)
                {
                    continue;
                }

                Vector2 thisCellSize = CellSize;

                var colInfo = ColSpanRows.Find((i) => i.StartRow == info.Row);
                if (colInfo != null)
                {
                    thisCellSize.X = ColSpanSize.X;
                    thisCellSize.Y = (ColSpanSize.Y * colInfo.Lenght) + (CellPadding * (colInfo.Lenght - 1));
                }

                OriginLocation location   = child.Rect.AnchorLocation;
                float          itemHeight = thisCellSize.Y;

                if ((colInfo == null || colInfo.Lenght == 1) && (MaxChildSize > 0 && thisCellSize.Y > MaxChildSize))                 // if the cell is larger than one high, they can't clamp it
                {
                    itemHeight = MaxChildSize;
                    location   = OriginTools.GetMiddleAnhcor(location);
                }

                // compute where the child's origin needs to be for it's anchor relative to the cell
                Vector2 childOrigin = GetChildOrigin(GetCellOrigin(info.Row, colInfo != null ? 0 : info.Col, colInfo != null ? colInfo.Lenght : 1), thisCellSize, itemHeight, location);

                child.Rect.X.RelativeTo = RelativeLoc.Edge.Raw;
                child.Rect.X.Paramater  = childOrigin.X;

                child.Rect.Y.RelativeTo = RelativeLoc.Edge.Raw;
                child.Rect.Y.Paramater  = childOrigin.Y;

                child.Rect.Width.Mode      = RelativeSize.SizeModes.Raw;
                child.Rect.Width.Paramater = thisCellSize.X;

                child.Rect.Height.Mode      = RelativeSize.SizeModes.Raw;
                child.Rect.Height.Paramater = itemHeight;

                // have the child size itself and it's children to it's new location
                child.Resize(PixelSize);
            }
        }