コード例 #1
0
        public void SetTopText(String Text)
        {
            pOutputText = Text;
            TAtlasInfo CustomAtlas = new TAtlasInfo();

            CustomAtlas.Atlas         = ButtonScripts.CreateDynamicTextCheckbox(Text, BoxWidth);
            CustomAtlas.DivDimensions = new Point(2, 2);
            LocalAtlas = CustomAtlas;
        }
コード例 #2
0
        public DropMenu(String Name, Vector2 Location, float Depth, int Width, String DefaultText, String[] DropList, Boolean InitialToggle) : base(Name, Location, null, Depth, InitialToggle)
        {
            BoxWidth = Width;
            TAtlasInfo CustomAtlas = new TAtlasInfo();

            CustomAtlas.Atlas         = ButtonScripts.CreateDynamicTextCheckbox(DefaultText, BoxWidth);
            CustomAtlas.DivDimensions = new Point(2, 2);
            LocalAtlas = CustomAtlas;
            PopulateDropList(DropList);
        }
コード例 #3
0
        protected override void LoadContent()
        {
            WriteLine("VNF is loading content...");
            // Create a new SpriteBatch, which can be used to draw textures.
            pSpriteBatch = new SpriteBatch(GraphicsDevice);
            TrueDisplay  = new RenderTarget2D(
                GraphicsDevice,
                1280,
                720,
                false,
                GraphicsDevice.PresentationParameters.BackBufferFormat,
                DepthFormat.Depth24);

            SysFont = Content.Load <SpriteFont>("Fonts/SysFont");
            Default = Content.Load <SpriteFont>("Fonts/Default");
            King    = Content.Load <SpriteFont>("Fonts/Zenda");

            TAtlasInfo BarAtlas = new TAtlasInfo();

            BarAtlas.Atlas         = Content.Load <Texture2D>("Textures/Preload/LoadingBar");
            BarAtlas.DivDimensions = new Point(1, 1);
            TAtlasInfo CoverAtlas = new TAtlasInfo();

            CoverAtlas.Atlas         = Content.Load <Texture2D>("Textures/Preload/LoadingCover");
            CoverAtlas.DivDimensions = new Point(1, 1);

            Vector2 AssumedScreenSize = new Vector2(1280, 720);

            LoadBar   = new WorldEntity("LOADBAR", new Vector2((AssumedScreenSize.X / 2) - 250, (AssumedScreenSize.Y / 2) + 100), BarAtlas, 0.5f);
            LoadCover = new WorldEntity("LOADCOVER", new Vector2((AssumedScreenSize.X / 2) + 243, (AssumedScreenSize.Y / 2) + 107), CoverAtlas, 1f);
            LoadCover.SetManualOrigin(new Vector2(486, 0));
            LoadText = new TextEntity("LOADTEXT", "[F:SYSFONT]Loading content...", new Vector2((AssumedScreenSize.X / 2) - 250, (AssumedScreenSize.Y / 2) + 200), 1f);
            LoadText.BufferLength = 500;
            LoadText.TypeWrite    = false;

            RenderQueue.Add(LoadBar);
            RenderQueue.Add(LoadCover);
            RenderQueue.Add(LoadText);

            LoadGraphicsQueue = new Queue();
            LoadPercentage    = 0f;

            LoadOperation = new Task <object[]>(AsyncLoad);
            LoadOperation.Start();
        }
コード例 #4
0
        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))));
            }
        }
コード例 #5
0
        protected object[] AsyncLoad()
        {
            WriteLine("Preload complete, loading remaining content...");
            ScriptProcessor.ScriptCache = new Hashtable();

            TestAtlas.Atlas         = Content.Load <Texture2D>("Textures/Entities/LethalHexWalk1");
            TestAtlas.DivDimensions = new Point(1, 1);

            TAtlasInfo InsertAtlas = new TAtlasInfo();

            InsertAtlas.Atlas         = Content.Load <Texture2D>("Textures/Logos/MatmutLogo");
            InsertAtlas.DivDimensions = new Point(1, 1);
            AtlasDirectory.Add("MATMUTLOGO", InsertAtlas);
            InsertAtlas               = new TAtlasInfo();
            InsertAtlas.Atlas         = Content.Load <Texture2D>("Textures/Environment/Backdrops/MatmutBG");
            InsertAtlas.DivDimensions = new Point(1, 1);
            AtlasDirectory.Add("MATMUTBG", InsertAtlas);

            InsertAtlas = new TAtlasInfo();
            InsertAtlas.DivDimensions = new Point(1, 1);
            InsertAtlas.SetManualSR(new Rectangle(new Point(0, 0), new Point(320, 180)));
            AtlasDirectory.Add("THUMBBLANK", InsertAtlas);

            Hashtable Manifests = ManifestReader.ReadManifestFile(BootManifest);

            object[] Resources        = ManifestReader.ParseManifest((String)Manifests[BootManifestReadTitle], this);
            String   FirstScript      = "";
            Boolean  RunFirstAsUnique = true;

            WriteLine("Reading application metainfo...");
            if (((Hashtable)Resources[0]).ContainsKey("startatscript"))
            {
                FirstScript = (String)((Hashtable)Resources[0])["startatscript"];
            }
            if (((Hashtable)Resources[0]).ContainsKey("useunique"))
            {
                RunFirstAsUnique = (Boolean)((Hashtable)Resources[0])["useunique"];
            }
            WriteLine("Ingesting utility scripts...");
            ManifestReader.IngestScriptFile("vnf_utils.esa");
            WriteLine("Ingesting application scripts...");
            int i = 0;

            foreach (String Script in ((ArrayList)Resources[1]))
            {
                ManifestReader.IngestScriptFile(Script);
                i++;
                Monitor.Enter(LPLockObj);
                LoadPercentage = (float)(0.95f + (0.05 * (i / ((ArrayList)Resources[1]).Count)));
                Monitor.Exit(LPLockObj);
            }
            WriteLine("Integrating loaded resources...");
            foreach (object key in ((Hashtable)Resources[2]).Keys)
            {
                Fonts.Add(key, (SpriteFont)((Hashtable)Resources[2])[key]);
            }
            foreach (object key in ((Hashtable)Resources[3]).Keys)
            {
                SFXDirectory.Add(key, (SoundEffect)((Hashtable)Resources[3])[key]);
            }
            foreach (object key in ((Hashtable)Resources[4]).Keys)
            {
                SongDirectory.Add(key, (Song)((Hashtable)Resources[4])[key]);
            }
            foreach (String key in ((Hashtable)Resources[5]).Keys)
            {
                AtlasDirectory.Add(key, (TAtlasInfo)((Hashtable)Resources[5])[key]);
            }
            ArrayList ADKeys = new ArrayList();

            foreach (String K in AtlasDirectory.Keys)
            {
                ADKeys.Add(K);
            }
            foreach (String K in ADKeys)
            {
                TAtlasInfo Copy = ((TAtlasInfo)AtlasDirectory[K]);
                Copy.ReferenceHash = K;
                AtlasDirectory[K]  = Copy;
            }
            TestLongRect              = Content.Load <Texture2D>("Textures/Entities/UI/Elements/TestLongRect");
            ButtonAtlas.Atlas         = Content.Load <Texture2D>("Textures/Entities/UI/Buttons/ButtonDefault");
            ButtonAtlas.DivDimensions = new Point(2, 1);
            Monitor.Enter(LPLockObj);
            LoadPercentage = 1;
            Monitor.Exit(LPLockObj);
            WriteLine("Content load complete.");
            return(new object[] { FirstScript, RunFirstAsUnique });
        }
コード例 #6
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);
        }