void PopulateDropList(String[] TextList)
        {
            DepopulateDropList();
            float CumulativeY = pDrawCoords.Y + (LocalAtlas.Atlas.Bounds.Height / 2) + 10;

            foreach (String Label in TextList)
            {
                TAtlasInfo ButtonAtlas = new TAtlasInfo();
                ButtonAtlas.Atlas         = ButtonScripts.CreateDynamicCustomButton(Label, BoxWidth);
                ButtonAtlas.DivDimensions = new Point(2, 1);
                Button B = new Button(Name + "_DROPOPTION_" + Label, new Vector2(pDrawCoords.X, CumulativeY), ButtonAtlas, LayerDepth - 0.001f);
                B.SubscribeToEvent(EventNames.ButtonPressFunction, typeof(Button).GetMethod("SetTopText"), new object[] { Label });
                B.CenterOrigin = false;
                B.Enabled      = DroppedDown;
                MyDropEntities.Add(B);
                Stickers.Add(B);
                Shell.UpdateQueue.Add(B);
                CumulativeY       += (LocalAtlas.Atlas.Bounds.Height / 2) + 10;
                DropBackingTexture = VNFUtils.GetNovelTextureOfColour(Shell.DefaultShell, new Color(50, 50, 50, 255), new Point(BoxWidth + 10, (int)(CumulativeY - (pDrawCoords.Y + (LocalAtlas.Atlas.Bounds.Height / 2) + 10))));
            }
        }
 public EssenseGlow(String Name, Vector2 Location, TAtlasInfo?Atlas, float Depth) : base(Name, Location, Atlas, Depth)
 {
     pOrigin = (VNFUtils.ConvertPoint(HitBox.Size) / 2) + SCDist;
     FindSofia();
 }
Exemplo n.º 3
0
        private static TAtlasInfo ParseTextureAtlas(String[] EntrySegment, Hashtable StemAtlasTemps, Shell MyShell)
        {
            TAtlasInfo TexAssembly = new TAtlasInfo();
            object     DirIndex    = EntityFactory.ParseRealData(EntrySegment[1]);

            if (!(DirIndex is String || DirIndex is string))
            {
                throw new ManifestReaderException("Manifest is invalid: Texture atlases must be String indexed at point of load.");
            }
            TexAssembly.ReferenceHash = (String)DirIndex;
            Texture2D Current = null;

            if (EntrySegment[2].ToUpper().StartsWith("ATL:"))
            {
                String[] ATLParams      = VNFUtils.Strings.SplitAtExclosed(EntrySegment[2].Remove(0, 4), ',', '\"');
                object   AtlasStemIndex = EntityFactory.ParseRealData(ATLParams[0]);
                if (StemAtlasTemps.ContainsKey(AtlasStemIndex))
                {
                    Texture2D Stem     = (Texture2D)StemAtlasTemps[AtlasStemIndex];
                    int[]     RectDims = new int[4];
                    try
                    {
                        for (int i = 1; i <= 4; i++)
                        {
                            RectDims[i - 1] = Convert.ToInt32(ATLParams[i]);
                        }
                    }
                    catch (FormatException) { throw new ManifestReaderException("Manifest is invalid: Texture extraction bounds are in an incorrect format."); }
                    Task <Texture2D> NewGTask = new Task <Texture2D>(() =>
                    {
                        return(VNFUtils.ExtractTexture(MyShell, Stem, new Rectangle(RectDims[0], RectDims[1], RectDims[2], RectDims[3])));
                    });
                    try
                    {
                        Monitor.Enter(MyShell.LoadGraphicsQueue);
                        MyShell.LoadGraphicsQueue.Enqueue(NewGTask);
                    }
                    finally { Monitor.Exit(MyShell.LoadGraphicsQueue); }
                    NewGTask.Wait();
                    Current = NewGTask.GetAwaiter().GetResult();
                    NewGTask.Dispose();
                    Shell.WriteLine("Extracted texture from atlas " + AtlasStemIndex.ToString() + " to " + DirIndex.ToString() + ".");
                }
                else
                {
                    throw new ManifestReaderException("Manifest is invalid: Attempted to derive texture from an index that did not correspond to a loaded atlas sheet.");
                }
            }
            else
            {
                String ContentFilePath = EntrySegment[2].Trim('\"');
                Current = MyShell.Content.Load <Texture2D>(ContentFilePath);
                Shell.WriteLine("Loaded texture " + ContentFilePath + " to " + DirIndex.ToString() + ".");
            }
            TexAssembly.Atlas = Current;
            for (int i = 3; i < EntrySegment.Length; i++)
            {
                if (EntrySegment[i].ToUpper().StartsWith("DIV:"))
                {
                    String[] Divs = EntrySegment[i].Remove(0, 4).Split(',');
                    int      X    = 1;
                    int      Y    = 1;
                    try
                    {
                        X = Convert.ToInt32(Divs[0]);
                        Y = Convert.ToInt32(Divs[1]);
                    }
                    catch (FormatException) { throw new ManifestReaderException("Manifest is invalid: Texture division sizes are in an incorrect format."); }
                    TexAssembly.DivDimensions = new Point(X, Y);
                }
                else if (EntrySegment[i].ToUpper().StartsWith("FL:"))
                {
                    if (TexAssembly.FrameLookup == null)
                    {
                        TexAssembly.FrameLookup = new Hashtable();
                    }
                    String[] FLParams  = EntrySegment[i].Remove(0, 3).Split(':');
                    object   FrameKey  = EntityFactory.ParseRealData(FLParams[0]);
                    String[] FrameDivs = FLParams[1].Split(',');
                    int      X;
                    int      Y;
                    try
                    {
                        X = Convert.ToInt32(FrameDivs[0]);
                        Y = Convert.ToInt32(FrameDivs[1]);
                    }
                    catch (FormatException) { throw new ManifestReaderException("Manifest is invalid: Texture division sizes are in an incorrect format."); }
                    TexAssembly.FrameLookup.Add(FrameKey, new Point(X, Y));
                }
            }
            return(TexAssembly);
        }
 public override void Update()
 {
     if (Enabled)
     {
         MouseState M = Mouse.GetState();
         if (Engaged)
         {
             pAtlasCoordinates.X = 2;
             Camera  MyCam = new Camera("");
             Vector2 FullyAdjustedMouseCoords = new Vector2();
             if (UsePseudoMouse)
             {
                 FullyAdjustedMouseCoords = PseudoMouse;
             }
             else
             {
                 FullyAdjustedMouseCoords = Shell.CoordNormalize(VNFUtils.ConvertPoint(M.Position));
             }
             if (!CameraImmune)
             {
                 if (CustomCamera != null)
                 {
                     MyCam = CustomCamera;
                 }
                 else if (Shell.AutoCamera != null)
                 {
                     MyCam = Shell.AutoCamera;
                 }
                 FullyAdjustedMouseCoords = MyCam.TranslateCoordsToEquivalent(FullyAdjustedMouseCoords);
             }
             Vector2 MouseDerived = CalculatePerpendicularIntersection(EndpointA, EndpointB, FullyAdjustedMouseCoords);
             float   GreatestX    = EndpointB.X >= EndpointA.X ? EndpointB.X : EndpointA.X;
             float   LeastX       = EndpointB.X >= EndpointA.X ? EndpointA.X : EndpointB.X;
             float   GreatestY    = EndpointB.Y >= EndpointA.Y ? EndpointB.Y : EndpointA.Y;
             float   LeastY       = EndpointB.Y >= EndpointA.Y ? EndpointA.Y : EndpointB.Y;
             if (MouseDerived.X > GreatestX)
             {
                 MouseDerived.X = GreatestX;
             }
             if (MouseDerived.X < LeastX)
             {
                 MouseDerived.X = LeastX;
             }
             if (MouseDerived.Y > GreatestY)
             {
                 MouseDerived.Y = GreatestY;
             }
             if (MouseDerived.Y < LeastY)
             {
                 MouseDerived.Y = LeastY;
             }
             pDrawCoords = MouseDerived;
             if (M.LeftButton != ButtonState.Pressed)
             {
                 Engaged = false;
             }
         }
         else
         {
             if (MouseInBounds())
             {
                 pAtlasCoordinates.X = 1;
             }
             else
             {
                 pAtlasCoordinates.X = 0;
             }
         }
     }
     else
     {
         pAtlasCoordinates.X = 0;
         Enabled             = false;
     }
     base.Update();
 }
 public float Output()
 {
     return((float)(VNFUtils.GetLinearDistance(EndpointA, pDrawCoords) / VNFUtils.GetLinearDistance(EndpointA, EndpointB)));
 }
            public void UpdateFunctionality(WorldEntity BehaviourOwner)
            {
                IScrollBar SB = (IScrollBar)BehaviourOwner;

                if (!SB.HideBar)
                {
                    MouseState M = Mouse.GetState();
                    if (SB.Enabled)
                    {
                        Vector2 COffsetV    = new Vector2();
                        Vector2 CZoomFactor = new Vector2(1, 1);
                        if (!((WorldEntity)SB).CameraImmune)
                        {
                            if (((WorldEntity)SB).CustomCamera != null)
                            {
                                COffsetV    = ((WorldEntity)SB).CustomCamera.OffsetVector;
                                CZoomFactor = ((WorldEntity)SB).CustomCamera.ZoomFactor;
                            }
                            else if (Shell.AutoCamera != null)
                            {
                                COffsetV    = Shell.AutoCamera.OffsetVector;
                                CZoomFactor = Shell.AutoCamera.ZoomFactor;
                            }
                        }
                        Vector2 FullyAdjustedMouseCoords = new Vector2();
                        if (BehaviourOwner.UsePseudoMouse)
                        {
                            FullyAdjustedMouseCoords = BehaviourOwner.PseudoMouse - COffsetV;
                        }
                        else
                        {
                            FullyAdjustedMouseCoords = ((Shell.CoordNormalize(VNFUtils.ConvertPoint(M.Position) / CZoomFactor) - COffsetV));
                        }
                        int MY = (int)FullyAdjustedMouseCoords.Y;
                        if (M.ScrollWheelValue != LastMouseScroll && SB.DetectScrollRectangle.Contains(FullyAdjustedMouseCoords) && !SB.Engaged)
                        {
                            if (((WorldEntity)SB).DrawCoords.Y >= SB.MinHeight && ((WorldEntity)SB).DrawCoords.Y <= SB.MaxHeight)
                            {
                                ((WorldEntity)SB).QuickMoveTo(new Vector2(((WorldEntity)SB).DrawCoords.X, ((WorldEntity)SB).DrawCoords.Y + -(int)(((float)(M.ScrollWheelValue - LastMouseScroll) * (float)(SB.ScrollFrameHeight)) / (2 * (float)SB.TotalScrollHeight))));
                            }
                            if (((WorldEntity)SB).DrawCoords.Y < SB.MinHeight)
                            {
                                ((WorldEntity)SB).QuickMoveTo(new Vector2(((WorldEntity)SB).DrawCoords.X, SB.MinHeight));
                            }
                            else if (((WorldEntity)SB).DrawCoords.Y > SB.MaxHeight)
                            {
                                ((WorldEntity)SB).QuickMoveTo(new Vector2(((WorldEntity)SB).DrawCoords.X, SB.MaxHeight));
                            }
                        }
                        LastMouseScroll = M.ScrollWheelValue;
                        if (SB.Engaged)
                        {
                            ((WorldEntity)SB).SetAtlasFrame(new Point(2, ((WorldEntity)SB).AtlasCoordinates.Y));
                            if (MY < SB.MinHeight)
                            {
                                ((WorldEntity)SB).QuickMoveTo(new Vector2(((WorldEntity)SB).DrawCoords.X, SB.MinHeight));
                            }
                            else if (MY > SB.MaxHeight)
                            {
                                ((WorldEntity)SB).QuickMoveTo(new Vector2(((WorldEntity)SB).DrawCoords.X, SB.MaxHeight));
                            }
                            else if (MY >= SB.MinHeight && MY <= SB.MaxHeight)
                            {
                                ((WorldEntity)SB).QuickMoveTo(new Vector2(((WorldEntity)SB).DrawCoords.X, MY));
                            }
                            if (M.LeftButton != ButtonState.Pressed)
                            {
                                SB.Engaged = false;
                            }
                        }
                        else
                        {
                            if (((WorldEntity)SB).MouseInBounds())
                            {
                                ((WorldEntity)SB).SetAtlasFrame(new Point(1, ((WorldEntity)SB).AtlasCoordinates.Y));
                            }
                            else
                            {
                                ((WorldEntity)SB).SetAtlasFrame(new Point(0, ((WorldEntity)SB).AtlasCoordinates.Y));
                            }
                        }
                    }
                    else
                    {
                        ((WorldEntity)SB).SetAtlasFrame(new Point(0, ((WorldEntity)SB).AtlasCoordinates.Y));
                        SB.Engaged      = false;
                        LastMouseScroll = M.ScrollWheelValue;
                    }
                }
            }
Exemplo n.º 7
0
        /// <summary>
        /// Returns or sets the value of a member or method of a given class from a String input.
        /// </summary>
        /// <param name="PathTree">The class/method/member path.</param>
        /// <param name="PresumptiveEntity">An initial WorldEntity instance on which to perform the path tree search.</param>
        /// <param name="ExplicitSet">If non-null, the specified instance member will be set to this object or value.</param>
        /// <returns></returns>
        public static Object ReturnMemberOrFuncValue(String PathTree, WorldEntity PresumptiveEntity, Object ExplicitSet)
        {
            String DP     = PathTree.TrimEnd(';');
            String TempDP = VNFUtils.Strings.ReplaceExclosed(DP, "(", "@", '\"');

            TempDP = VNFUtils.Strings.ReplaceExclosed(TempDP, ")", "@", '\"');
            TempDP = VNFUtils.Strings.ReplaceExclosedOutestTier(TempDP, ".", "&", '@');
            int Index = 0;

            foreach (Char c in DP)
            {
                if (TempDP[Index] == '@' && (c == '(' || c == ')'))
                {
                    TempDP = TempDP.Remove(Index) + c + TempDP.Remove(0, Index + 1);
                }
                Index++;
            }
            DP = TempDP;
            Type   SuperType       = typeof(ScriptProcessor);
            Object InstancedObject = null;

            if (DP.ToUpper().StartsWith("TYPEOF("))
            {
                String TypeNameString = DP.Remove(DP.IndexOf(')')).Remove(0, 7);
                InstancedObject = VNFUtils.TypeOfNameString(TypeNameString, true);
                DP = DP.Remove(0, DP.IndexOf(')') + 2);
            }
            String StaticMemberTree = DP;

            if (PresumptiveEntity is null && InstancedObject is null)
            {
                if (DP.Contains("&"))
                {
                    String TypeToFind = DP;
                    TypeToFind = TypeToFind.Remove(TypeToFind.LastIndexOf('&'));
                    if (!TypeToFind.StartsWith("VNFramework&") && !TypeToFind.StartsWith("System&"))
                    {
                        TypeToFind = "VNFramework&" + TypeToFind;
                    }
                    String TrueTTF = VNFUtils.Strings.ReplaceExclosed(TypeToFind, "&", ".", '\"');
                    TrueTTF = TrueTTF.Replace("\\+", "+");
                    Type Find = typeof(Shell).Assembly.GetType(TrueTTF);
                    if (Find == null)
                    {
                        Find = Type.GetType(TrueTTF);
                    }
                    if (Find == null)
                    {
                        Find = typeof(System.Type).Assembly.GetType(TrueTTF);
                    }
                    if (Find != null)
                    {
                        SuperType = Find;
                    }
                    String TTFPreStaticSearch = TypeToFind;
                    while (!(SuperType.IsAbstract && SuperType.IsSealed))
                    {
                        if (SuperType == typeof(Shell))
                        {
                            InstancedObject = Shell.DefaultShell;
                            break;
                        }
                        TypeToFind = TypeToFind.Remove(TypeToFind.LastIndexOf('&'));
                        if (TypeToFind == "VNFramework" || TypeToFind.Length == 0)
                        {
                            TypeToFind = TTFPreStaticSearch;
                            break;
                        }
                        Find = Type.GetType(VNFUtils.Strings.ReplaceExclosed(TypeToFind, "&", ".", '\"'));
                        if (Find != null)
                        {
                            SuperType = Find;
                        }
                        else
                        {
                            SuperType = null;
                            break;
                        }
                    }
                    if (!DP.StartsWith("VNFramework&") && TypeToFind.StartsWith("VNFramework&"))
                    {
                        TypeToFind = TypeToFind.Remove(0, 12);
                    }
                    if (TypeToFind.Length > 0)
                    {
                        if (DP.StartsWith(TypeToFind))
                        {
                            StaticMemberTree = DP.Remove(0, TypeToFind.Length);
                        }
                    }
                    StaticMemberTree = StaticMemberTree.TrimStart('&');
                }
            }