Exemplo n.º 1
0
        public override void LoadContent(ContentLoader content)
        {
            Texture2D lightTx = content.Load<Texture2D>("Lightning");
            int lightX = (graphics.GraphicsDevice.Viewport.Width - lightTx.Width <= 0 ? 100 : ((graphics.GraphicsDevice.Viewport.Width - lightTx.Width + 100) / 2));

            Texture2D introTx = content.Load<Texture2D>("intro2");
            int introX = (graphics.GraphicsDevice.Viewport.Width - introTx.Width <= 0 ? 0 : ((graphics.GraphicsDevice.Viewport.Width - introTx.Width)/2));
            int introY = (graphics.GraphicsDevice.Viewport.Height - introTx.Height <= 0 ? 0 : ((graphics.GraphicsDevice.Viewport.Height - introTx.Height) / 2));
            myIntro = new IntroSprite(introTx,
                new Vector2(0, 0),
                new Vector2(graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height));
            for (int i = 0; i < myClouds.Length; i++)
            {
                myClouds[i] = new CloudSprite(content.Load<Texture2D>("cloudX"),
                new Vector2(-i*300, 0), i);
                mySprites.Add(myClouds[i]);
            }
            myLightning = new LightningSprite(lightTx,
                content.Load<SoundEffect>("lightningS"),
                new Vector2(lightX, 0),
                myClouds,
                this);
            mySprites.Add(myIntro);
            mySprites.Add(myLightning);
            spriteBatch = new SpriteBatch(GraphicsDevice);
        }
Exemplo n.º 2
0
 private static void ShowFailToLoadContentMessage(string contentName,
     ContentLoader.ContentNotFound ex)
 {
     Logger.Warning("Content " + ex.Message + " in " + contentName + " not found");
     var verdana = ContentLoader.Load<Font>("Verdana12");
     new FontText(verdana, "Content " + ex.Message + " in " + contentName + " not found",
         Rectangle.One);
 }
Exemplo n.º 3
0
        public void LoadContent(ContentLoader content)
        {
            myEffect = content.ContentManager.Load<ParticleEffect>(name);

            myEffect.LoadContent(content.ContentManager);
            myEffect.Initialise();
            myRenderer.LoadContent(content.ContentManager);
        }
Exemplo n.º 4
0
        public override void Load(ContentLoader contentLoader = null)
        {
            using (var file = File.OpenRead(this.PackFile.Location))
            {
                file.Seek(this.DataOffset, SeekOrigin.Begin);

                CompressedContentLoader(contentLoader)(file);
            }
        }
Exemplo n.º 5
0
        public WavingFlagSample()
            : base()
        {
            this.Window.Title = "Snowball Waving Flag Sample";

            this.graphicsDevice = new GraphicsDevice(this.Window);
            this.Services.AddService(typeof(IGraphicsDevice), this.graphicsDevice);

            this.contentLoader = new ContentLoader(this.Services);
        }
Exemplo n.º 6
0
        public override void LoadContent(ContentLoader content)
        {
            //Load some particle effects
            sparkler = new ParticleFX(graphics, "wand");
            sparkler.LoadContent(content);
            sparkler.Visible = false;

            explosion = new ParticleFX(graphics, "BasicExplosion");
            explosion.LoadContent(content);
        }
Exemplo n.º 7
0
 public Engine()
 {
     graphics = new GraphicsDeviceManager(this);
     Content.RootDirectory = "Content";
     ContentLoader = new ContentLoader(this.Content);
     input = new InputHandler(graphics);
     this.graphics.PreferredBackBufferWidth =  GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
     this.graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
     this.graphics.ApplyChanges();
 }
Exemplo n.º 8
0
        public override void Load(ContentLoader contentLoader = null)
        {
            if (contentLoader == null)
                return;

            using (var stream = new MemoryStream(this.Data))
            {
                contentLoader(stream);
            }
        }
Exemplo n.º 9
0
        public override void Load(ContentLoader contentLoader = null)
        {
            using (var stream = CompressionStream.DecompressFile(this.Location))
            {
                stream.SkipUntil(c => c == '\0');

                if (contentLoader != null)
                    contentLoader(stream);
            }
        }
Exemplo n.º 10
0
 private static void ShowFailToLoadContentMessage(string contentName,
     ContentLoader.ContentNameShouldNotHaveExtension ex)
 {
     Logger.Warning("Content " + contentName +
         " has an '.' in the contentName. This is not allowed for it will be viewed as an extension");
     var verdana = ContentLoader.Load<Font>("Verdana12");
     new FontText(verdana,
         "Content " + contentName +
             " has an '.' in the contentName. This is not allowed for it will be viewed as an extension",
         Rectangle.One);
 }
Exemplo n.º 11
0
        public TextBlockSample()
            : base()
        {
            this.Window.Title = "TextBlock Sample";

            this.graphicsDevice = new GraphicsDevice(this.Window);
            this.Services.AddService(typeof(IGraphicsDevice), this.graphicsDevice);

            this.contentLoader = new ContentLoader(this.Services);
            this.Services.AddService(typeof(IContentLoader), this.contentLoader);
        }
Exemplo n.º 12
0
        public GamePadReader()
            : base()
        {
            this.Window.Title = "Snowball GamePad Reader";

            this.gamePad = new GamePad(GamePadIndex.One);

            this.graphicsDevice = new GraphicsDevice(this.Window);
            this.Services.AddService(typeof(IGraphicsDevice), this.graphicsDevice);

            this.contentLoader = new ContentLoader(this.Services);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Creates a compressed ContentLoader.
        /// </summary>
        /// <param name="loader">The loader.</param>
        /// <returns></returns>
        public static ContentLoader CompressedContentLoader(ContentLoader loader)
        {
            if (loader == null)
                return stream => { };

            return stream =>
            {
                using (var compressed = CompressionStream.DecompressStream(stream, true))
                {
                    loader(compressed);
                }
            };
        }
Exemplo n.º 14
0
        public WalkingWizardSample()
            : base()
        {
            this.Window.Title = "Snowball Walking Wizard Sample";

            this.graphicsDevice = new GraphicsDevice(this.Window);

            // Add the GraphicsDevice to the list of services. This is how ContentLoader finds the GraphicsDevice.
            this.Services.AddService(typeof(IGraphicsDevice), this.graphicsDevice);

            this.keyboard = new Keyboard();

            this.content = new ContentLoader(this.Services);
        }
Exemplo n.º 15
0
        public void LoadContentViewById(int id, EditContentViewModel model)
        {
            model.Heading = "Edit Page";
            model.EditURL = "editcontent";

            var contentLoader = new ContentLoader();
            model.ContentPage.Details = contentLoader.GetDetailsById(id);

            var ext = _context.ContentPageExtensions.FirstOrDefault(ex => ex.ContentPageId == id);
            Mapper.Map(ext, model.ContentPage);

            model.ShowFieldEditor = model.ContentPage.Details.SchemaId > -1;

            // If we are editing a draft, we actually need to be editing the parent page, but keep the drafts contents (html, css, meta, etc).
            // To accomplish this, we can simply change the id of the page we're editing in memory, to the parent page.
            model.BasePageId = model.ContentPage.Details.IsRevision
                ? Convert.ToInt32(model.ContentPage.Details.ParentContentPageId)
                : model.ContentPage.Details.ContentPageId;

            var user = GetCurrentUser();
            model.UseWordWrap = user.ContentAdminWordWrap;
            model.SiteUrl = HTTPUtils.GetFullyQualifiedApplicationPath();

            // Check to see if there is a newer version available
            var newerVersionId = GetNewerVersionId(model.BasePageId, model.ContentPage.Details.PublishDate, model.ContentPage.Details.ContentPageId);
            if (newerVersionId != 0)
            {
                model.IsNewerVersion = true;
                model.NewerVersionId = newerVersionId;
            }

            model.Templates = contentLoader.GetAllContentTemplates();
            model.Revisions = GetPageRevisions(model.BasePageId);

            // Get list of schemas for drop down
            model.Schemas = contentLoader.GetAllSchemata();

            // Grab the formatted nav list for the category drop down
            model.NavList = _navigationUtils.GetNavList();

            model.ParentNavIdsToDisable = contentLoader.GetNavItemsForContentPage(model.ContentPage.Details.ContentPageId);
            model.BookmarkTitle = model.ContentPage.Details.Title;

        }
Exemplo n.º 16
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            IsMouseVisible = true;

            InputController input = new InputController(this);
            Components.Add(input);
            Services.AddService(typeof(InputController), input);

            fontLoader = new ContentLoader<SpriteFont>(this);
            Services.AddService(typeof(ContentLoader<SpriteFont>), fontLoader);

            imageLoader = new ContentLoader<Texture2D>(this);
            Services.AddService(typeof(ContentLoader<Texture2D>), imageLoader);

            soundLoader = new ContentLoader<SoundEffectInstance>(this);
            Services.AddService(typeof(ContentLoader<SoundEffectInstance>), soundLoader);
        }
Exemplo n.º 17
0
    protected readonly Stack<MapDataStore> recycledBlocks; // Object pool!

    protected BlockMesher() {
        // Make queues
        requestQueue = new Util.UniqueQueue<DFCoord, Request>();
        recycledBlocks = new Stack<MapDataStore>();
        resultQueue = new Queue<Result>();

        // Load meshes
        contentLoader = new ContentLoader();
        System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
        watch.Start();
        contentLoader.ParseContentIndexFile(Application.streamingAssetsPath + "/index.txt");
        contentLoader.FinalizeTextureAtlases();
        watch.Stop();
        Debug.Log("Took a total of " + watch.ElapsedMilliseconds + "ms to load all XML files.");

        // Load materials
        materials = new Dictionary<MatPairStruct, RemoteFortressReader.MaterialDefinition>();
        foreach (RemoteFortressReader.MaterialDefinition material in DFConnection.Instance.NetMaterialList.material_list)
        {
            materials[material.mat_pair] = material;
        }
        System.GC.Collect(); //force a garbage collect after initial load.
    }
Exemplo n.º 18
0
        public override void LoadContent(ContentLoader content)
        {
            slides = new List<Texture2D>();
            spriteBatch = new SpriteBatch(graphics.GraphicsDevice);

            String[] files = Directory.GetFiles("Slideshow");
            foreach (String file in files)
            {
                try
                {
                    Stream stream = new FileStream(file, FileMode.Open);
                    slides.Add(Texture2D.FromStream(graphics.GraphicsDevice, stream));
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                }
            }

            if (slides.Count == 0)
            {
                slides.Add(new Texture2D(graphics.GraphicsDevice, 1, 1));
            }
        }
Exemplo n.º 19
0
 public virtual void LoadContent(ContentLoader content, ScreenManager screenManager)
 {
 }
Exemplo n.º 20
0
 private void Start()
 {
     ContentLoader.RegisterLoadCallback(LoadShapes);
 }
Exemplo n.º 21
0
 public void DisposeContentLoader()
 {
     ContentLoader.DisposeIfInitialized();
 }
Exemplo n.º 22
0
 public void PlaySoundOnClick()
 {
     new Command(() => ContentLoader.Load <Sound>("DefaultSound").Play()).Add(
         new MouseButtonTrigger());
 }
Exemplo n.º 23
0
 public void PlaySoundLeft()
 {
     ContentLoader.Load <Sound>("DefaultSound").Play(1, -1);
 }
Exemplo n.º 24
0
        private static void PlayClickedSound()
        {
            var clickSound = ContentLoader.Load <Sound>(GameSounds.MenuPageFlip.ToString());

            clickSound.Play();
        }
Exemplo n.º 25
0
 public void PlaySound()
 {
     ContentLoader.Load <Sound>("DefaultSound").Play();
 }
Exemplo n.º 26
0
 protected override void Preview(string contentName)
 {
     new LevelDebugRenderer(ContentLoader.Load <Level>(contentName));
 }
Exemplo n.º 27
0
 public Sprite(string texture) :
     this(ContentLoader.LoadTexture(texture), Alignments.Center)
 {
 }
Exemplo n.º 28
0
    internal void UpdateImprovement(RemoteFortressReader.ItemImprovement improvement)
    {
        Color matColor     = ContentLoader.GetColor(improvement.material);
        float textureIndex = ContentLoader.GetPatternIndex(improvement.material);
        float shapeIndex   = ContentLoader.GetShapeIndex(improvement.material);

        image = improvement.image;

        if (actualModel != null)
        {
            Destroy(actualModel);
            actualModel = null;
        }


        GameObject prefab = null;

        switch (improvement.type)
        {
        case ImprovementType.ART_IMAGE:
            prefab = DecorationManager.Instance.Image;
            break;

        case ImprovementType.BANDS:
        case ImprovementType.COVERED:
            prefab = DecorationManager.Instance.GetShape(improvement.shape);
            break;

        case ImprovementType.RINGS_HANGING:
            prefab = DecorationManager.Instance.Ring;
            break;

        case ImprovementType.SPIKES:
            prefab = DecorationManager.Instance.Spike;
            break;

        default:
            break;
        }

        if (prefab == null)
        {
            gameObject.SetActive(false);
            return;
        }

        actualModel = Instantiate(prefab, transform, false);

        meshFilter   = actualModel.GetComponentInChildren <MeshFilter>();
        meshRenderer = actualModel.GetComponentInChildren <MeshRenderer>();
        if (improvement.type == ImprovementType.ART_IMAGE)
        {
            meshFilter.sharedMesh = ImageManager.Instance.CreateMesh(improvement.image, ImageManager.Direction.Front);
        }
        else
        {
            originalMaterial            = meshRenderer.sharedMaterial;
            meshRenderer.sharedMaterial = ContentLoader.getFinalMaterial(originalMaterial, matColor.a);
        }

        MaterialPropertyBlock prop = new MaterialPropertyBlock();

        prop.SetColor("_MatColor", matColor);
        prop.SetFloat("_MatIndex", textureIndex);
        prop.SetFloat("_ShapeIndex", shapeIndex);
        meshRenderer.SetPropertyBlock(prop);
        gameObject.SetActive(true);
    }
Exemplo n.º 29
0
    public void UpdateMaterial(Item itemInput, UnitDefinition unit = null)
    {
        originalItem = itemInput;
        if (phantom)
        {
            return;
        }
        if (meshRenderer == null)
        {
            meshRenderer = GetComponentInChildren <MeshRenderer>();
        }

        //This means that it's just a placeholder on a body part.
        if (meshRenderer == null)
        {
            phantom = true;
            return;
        }
        if (originalMaterial == null)
        {
            originalMaterial = meshRenderer.sharedMaterial;
        }

        Color partColor    = ContentLoader.GetColor(itemInput);
        float textureIndex = ContentLoader.GetPatternIndex(itemInput.material);

        meshRenderer.sharedMaterial = ContentLoader.getFinalMaterial(originalMaterial, partColor.a);

        if (itemInput.type.mat_type == 53 && originalMaterial.shader.name == "Art/SingleImage") //plant. We have colored sprites for these.
        {
            partColor = new Color(0.5f, 0.5f, 0.5f, 0.5f);
        }

        if (((ItemFlags)(itemInput.flags1) & ItemFlags.rotten) == ItemFlags.rotten)
        {
            partColor = new Color(0, 0, 0, 0.5f);
        }



        MaterialPropertyBlock prop = new MaterialPropertyBlock();

        prop.SetColor("_MatColor", partColor);
        prop.SetFloat("_MatIndex", textureIndex);
        if (unit != null)
        {
            prop.SetColor("_JobColor", unit.profession_color);
        }
        if (ImageManager.Instance != null)
        {
            prop.SetFloat("_SpriteIndex", ImageManager.Instance.GetItemTile(itemInput.type));
        }
        meshRenderer.SetPropertyBlock(prop);


        UpdateImprovements(gameObject, itemInput);

        var image = GetComponentInChildren <ItemImage>();

        if (image != null)
        {
            image.UpdateImage(itemInput);
        }
    }
Exemplo n.º 30
0
        protected virtual IList GetPagesCollection(Func <IEnumerable <ContentReference> > retrieveMethod,
                                                   Type itemType)
        {
            Func <IEnumerable <IContent> > loadPages = () => retrieveMethod().Select(x => ContentLoader.Get <IContent>(x));

            var result = GetPagesCollection(loadPages, itemType);

            return(result);
        }
Exemplo n.º 31
0
 private void Start()
 {
     ContentLoader.RegisterLoadCallback(LoadBuildings);
 }
Exemplo n.º 32
0
 protected override void OnInit(ContentLoader loader)
 {
     loader.SetLoadContextParameters(new AddressableLoaderParameters {
         behaviour = LoaderBehaviour.Asset
     });
 }
Exemplo n.º 33
0
        protected override void Initialize()
        {
            Content = new ContentLoader(Services);

            base.Initialize();
        }
Exemplo n.º 34
0
 public Sprite(string texture, Alignments alignment) :
     this(ContentLoader.LoadTexture(texture), alignment)
 {
 }
Exemplo n.º 35
0
 public override void LoadContent(ContentLoader content, ScreenManager screenManager)
 {
     base.LoadContent(content, screenManager);
 }
Exemplo n.º 36
0
 public override void Load(ContentLoader contentLoader)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 37
0
 public void SetUp()
 {
     verdana = Font.Default;
     tahoma  = ContentLoader.Load <Font>("Tahoma30");
 }
Exemplo n.º 38
0
        private static void PlayClickedSound()
        {
            var sound = ContentLoader.Load <Sound>(GameSounds.MenuButtonClick.ToString());

            sound.Play();
        }
Exemplo n.º 39
0
 public void PlaySoundVerySilent()
 {
     ContentLoader.Load <Sound>("DefaultSound").Play(0.1f);
 }
Exemplo n.º 40
0
        /// <summary>
        /// Create a new font from the info in the specified font descriptor (XML) file
        /// </summary>
        /// <param name="game">current game</param>
        /// <param name="strFontFilename">font file (.xml)</param>
        public BitmapFont(EAGSS game, string strFontFilename)
        {
            content = game.Content;

            m_dictBitmapID2BitmapInfo = new Dictionary<int, BitmapInfo>();
            m_dictBitmapID2Texture = new Dictionary<int, Texture2D>();

            m_dictUnicode2GlyphInfo = new Dictionary<char, GlyphInfo>();
            m_dictKern = new Dictionary<char, Dictionary<char, int>>();

            var xd = new XmlDocument();
            xd.Load(new MemoryStream(content.Load<byte[]>(strFontFilename)));
            LoadFontXML(xd.ChildNodes);
        }
Exemplo n.º 41
0
        public void PlaySoundAndDispose()
        {
            var sound = ContentLoader.Load <Sound>("DefaultSound");

            sound.Dispose();
        }
Exemplo n.º 42
0
 public abstract void Load(string path, ContentLoader contentLoader);
Exemplo n.º 43
0
 protected override sealed void CreateScene()
 {
     Scene = ContentLoader.Load <Scene>(GameMenus.TowerSelectionPanel.ToString());
     Hide();
     SetupButtonsAndAttachEvents();
 }
Exemplo n.º 44
0
 public static void Start()
 {
     sht = ContentLoader.LoadSpriteSheet("Editor/TestImages/Floors1.png", new Vector2(16, 16));
     new Object2D("SliderTest", Screen.Resolution / 2, new Vector2(50, 50), 0, new Component2D[] { new Image2DComponent(sht.Sheet[0][1]) });
 }
Exemplo n.º 45
0
 public void CreateContentLoader()
 {
     ContentLoader.Use <FakeContentLoader>();
 }
 /// <summary>
 /// Used when loaded from json
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="spriteSheetToLoad"></param>
 /// <param name="size"></param>
 /// <param name="offset"></param>
 public GuiImageComponent(GuiComponent parent, int spriteSheetToLoad, Point size, Vector2 offset = new Vector2()) : base(offset, size, parent)
 {
     _componentType = EngineComponentTypes.UiComponents.ImageComponent;
     _spriteSheet   = ContentLoader.GetSpriteSheet(spriteSheetToLoad);
     _size          = size;
 }
Exemplo n.º 47
0
 public override void LoadContent(ContentLoader content)
 {
 }
        void HandleXnaInitialize()
        {
            try
            {
                CreateManagers();

                mScrollBarControlLogic.Managers = mManagers;

                string targetFntFileName = CreateAndSaveFonts();

                // Implement the default content loader since we're not providing
                // a custom one:
                var contentLoader = new ContentLoader();
                contentLoader.SystemManagers = mManagers;
                LoaderManager.Self.ContentLoader = contentLoader;
                LoaderManager.Self.Initialize(null, targetFntFileName, XnaControl.Services, mManagers);
                ToolComponentManager.Self.ReactToXnaInitialize(mManagers);
            }
            catch (Exception e)
            {
                throw new Exception("Error initializing XNA\n\n" + e.ToString());
            }
        }
Exemplo n.º 49
0
		public EngineScreenManager(Game game)
			: base(game) {
			// Content loader
			ContentLoader = new ContentLoader("Content", Game.GraphicsDevice, Game.Services);
		}
        public void CustomInitialize()
        {
            mTimeManager = new TimeManager();


            mManagers = new SystemManagers();
            mManagers.Initialize(GraphicsDevice);
            mManagers.Name = "Image Region Selection";
            Assembly assembly = Assembly.GetAssembly(typeof(GraphicsDeviceControl));// Assembly.GetCallingAssembly();

            string targetFntFileName = FileManager.UserApplicationDataForThisApplication + "Font18Arial.fnt";
            string targetPngFileName = FileManager.UserApplicationDataForThisApplication + "Font18Arial_0.png";
            FileManager.SaveEmbeddedResource(
                assembly,
                "XnaAndWinforms.Content.Font18Arial.fnt",
                targetFntFileName);

            FileManager.SaveEmbeddedResource(
                assembly,
                "XnaAndWinforms.Content.Font18Arial_0.png",
                targetPngFileName);



            var contentLoader = new ContentLoader();
            contentLoader.SystemManagers = mManagers;

            LoaderManager.Self.ContentLoader = contentLoader;
            LoaderManager.Self.Initialize("Content/InvalidTexture.png", targetFntFileName, Services, mManagers);

            CreateNewSelector();

            mCursor = new InputLibrary.Cursor();
            mCursor.Initialize(this);

            mKeyboard = new InputLibrary.Keyboard();
            mKeyboard.Initialize(this);

            mCameraPanningLogic = new CameraPanningLogic(this, mManagers, mCursor, mKeyboard);
            mCameraPanningLogic.Panning += HandlePanning;



            MouseWheel += new MouseEventHandler(MouseWheelRegion);
            ZoomNumbers = new Zooming.ZoomNumbers();
        }
Exemplo n.º 51
0
        public void LoadContent(ContentLoader contentManager)
        {
            var texture = contentManager.LoadTexture(_cursorTextureInfo.MainFolder, _cursorTextureInfo.AssetName);
			_cursorSprite = new Sprite(texture);
            _cursorTextureScale = ConvertUnits.ToDisplayUnits(Size) / texture.Width;
        }
Exemplo n.º 52
0
        /// <summary>
        /// Writes .pcmap file to the specified path. This contains informations about objects and textures used in a binary format.
        /// </summary>
        /// <param name="path"></param>
        public void WriteBinaryMapFile(string path)
        {
            FileStream   stream       = File.Open(path, FileMode.OpenOrCreate);
            BinaryWriter binaryWriter = new BinaryWriter(stream);

            /// HEADER ///
            binaryWriter.Write(HeaderString);
            binaryWriter.Write(HeaderVersion);

            /// MAP PROPERTIES ///

            binaryWriter.Write(BackgroundR);
            binaryWriter.Write(BackgroundG);
            binaryWriter.Write(BackgroundB);

            /// OBJECTS ///
            binaryWriter.Write(Objects.Count);

            foreach (MapObjectJSON obj in Objects)
            {
                binaryWriter.Write(obj.Name);
                binaryWriter.Write(obj.Layer);
                binaryWriter.Write(obj.PositionX);
                binaryWriter.Write(obj.PositionY);

                // Object creation information
                binaryWriter.Write(obj.Info.ClassName);

                // Object UUID
                binaryWriter.Write(Guid.NewGuid().ToString());

                // Properties
                binaryWriter.Write(obj.Properties.Count);

                foreach (KeyValuePair <string, GameObjectProperty> pair in obj.Properties)
                {
                    // Property name
                    binaryWriter.Write(pair.Key);

                    // Property value
                    binaryWriter.Write((int)pair.Value.propertyType);

                    switch (pair.Value.propertyType)
                    {
                    case PropertyType.INT:
                        binaryWriter.Write((int)pair.Value.GetAsInt32());
                        break;

                    case PropertyType.BOOL:
                        binaryWriter.Write((bool)pair.Value.GetAsBool());
                        break;

                    case PropertyType.DOUBLE:
                        binaryWriter.Write((double)pair.Value.GetAsDouble());
                        break;

                    case PropertyType.FLOAT:
                        binaryWriter.Write((float)pair.Value.GetAsFloat());
                        break;

                    case PropertyType.STRING:
                        binaryWriter.Write(pair.Value.GetAsString());
                        break;
                    }
                }

                // Components
                binaryWriter.Write(obj.Components.Count);

                foreach (ComponentInfo component in obj.Components)
                {
                    // Class name used to load component
                    binaryWriter.Write(component.ClassName);

                    // Component UUID
                    binaryWriter.Write(Guid.NewGuid().ToString());

                    // Component Properties
                    binaryWriter.Write(component.Properties.Count);

                    foreach (KeyValuePair <string, ComponentProperty> pair in component.Properties)
                    {
                        // Property name
                        binaryWriter.Write(pair.Key);

                        // Property value
                        binaryWriter.Write((int)pair.Value.propertyType);

                        switch (pair.Value.propertyType)
                        {
                        case PropertyType.INT:
                            binaryWriter.Write((int)pair.Value.GetAsInt32());
                            break;

                        case PropertyType.BOOL:
                            binaryWriter.Write((bool)pair.Value.GetAsBool());
                            break;

                        case PropertyType.DOUBLE:
                            binaryWriter.Write((double)pair.Value.GetAsDouble());
                            break;

                        case PropertyType.FLOAT:
                            binaryWriter.Write((float)pair.Value.GetAsFloat());
                            break;

                        case PropertyType.STRING:
                            binaryWriter.Write(pair.Value.GetAsString());
                            break;
                        }
                    }
                }
            }

            /// ASSET INFORMATION (directory tree of any used assets such as textures for the game to pre-load)

            List <string> assetKeys = new List <string>();

            foreach (MapObjectJSON obj in Objects)
            {
                if (obj.Info.AnimationProperty != Util.GetEngineNull())
                {
                    Animation animation = ContentLoader.GetAnimation(obj.Properties[obj.Info.AnimationProperty].CurrentValue);

                    if (animation != null)
                    {
                        foreach (KeyFrame keyFrame in animation.KeyFrames)
                        {
                            foreach (KeyValuePair <string, SpriteJson> spritePair in keyFrame.SpriteBoxes)
                            {
                                if (!assetKeys.Contains(spritePair.Value.textureKey))
                                {
                                    assetKeys.Add(spritePair.Value.textureKey);
                                }
                            }
                        }
                    }
                }

                foreach (ComponentInfo component in obj.Components)
                {
                    if (component.AnimationProperty != Util.GetEngineNull())
                    {
                        Animation animation = ContentLoader.GetAnimation(component.Properties[component.AnimationProperty].CurrentValue);

                        if (animation != null)
                        {
                            foreach (KeyFrame keyFrame in animation.KeyFrames)
                            {
                                foreach (KeyValuePair <string, SpriteJson> spritePair in keyFrame.SpriteBoxes)
                                {
                                    if (!assetKeys.Contains(spritePair.Value.textureKey))
                                    {
                                        assetKeys.Add(spritePair.Value.textureKey);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            binaryWriter.Write(assetKeys.Count);

            foreach (string assetKey in assetKeys)
            {
                binaryWriter.Write(assetKey);
            }


            binaryWriter.Dispose();
            stream.Dispose();
        }
Exemplo n.º 53
0
 /// <summary>
 /// Should load all content for this game
 /// </summary>
 /// <param name="content">A ContentLoader to load content</param>
 public abstract void LoadContent(ContentLoader content);
Exemplo n.º 54
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(Game.GraphicsDevice);

            content = Game.Content;

            bitmapFont = new BitmapFont(Game, "fonts\\FZHei_17_Bold.xml");
            bitmapFont.Reset(Game.GraphicsDevice);

            transitionEffect = content.Load<Effect>("effects\\disappear.fxc");
            transitionShader = content.Load<Texture2D>("shaders\\default.png");

            // Tell each of the screens to load their content.
            foreach (GameScreen screen in screens)
            {
                screen.InitializeControls();
                screen.LoadContent();
            }
        }
Exemplo n.º 55
0
        private void NavigateAsync(Uri oldValue, Uri newValue, NavigationType navigationType)
        {
            Debug.WriteLine("Navigating from '{0}' to '{1}'", oldValue, newValue);

            // set IsLoadingContent state
            SetValue(IsLoadingContentPropertyKey, true);

            // cancel previous load content task (if any)
            // note: no need for thread synchronization, this code always executes on the UI thread
            if (_tokenSource != null)
            {
                _tokenSource.Cancel();
                _tokenSource = null;
            }

            // push previous source onto the history stack (only for new navigation types)
            if (oldValue != null)
            {
                switch (navigationType)
                {
                case NavigationType.New:
                    _history.Push(oldValue);
                    _future.Clear();
                    break;

                case NavigationType.Back:
                    _future.Push(oldValue);
                    break;

                case NavigationType.Forward:
                    _history.Push(oldValue);
                    break;
                }
            }

            object newContent = null;

            if (newValue != null)
            {
                // content is cached on uri without fragment
                var newValueNoFragment = NavigationHelper.RemoveFragment(newValue);

                if (navigationType == NavigationType.Refresh || !_contentCache.TryGetValue(newValueNoFragment, out newContent))
                {
                    var localTokenSource = new CancellationTokenSource();
                    _tokenSource = localTokenSource;
                    // load the content (asynchronous!)
                    var scheduler = TaskScheduler.FromCurrentSynchronizationContext();

#if DEBUG
                    var task = ContentLoader.LoadContentAsync(newValue, _tokenSource.Token);
#else
                    Task <object> task;
                    try {
                        task = ContentLoader.LoadContentAsync(newValue, _tokenSource.Token);
                    } catch (Exception e) {
                        SetNavigationFailedContent(newValue, navigationType, e);
                        return;
                    }
#endif

                    task.ContinueWith(t => {
                        try {
                            if (t.IsCanceled || localTokenSource.IsCancellationRequested)
                            {
                                Debug.WriteLine("Cancelled navigation to '{0}'", newValue);
                            }
                            else if (t.IsFaulted)
                            {
                                SetNavigationFailedContent(newValue, navigationType, t.Exception);
                            }
                            else
                            {
                                newContent = t.Result;
                                if (ShouldKeepContentAlive(newContent))
                                {
                                    // keep the new content in memory
                                    Debug.WriteLine("KEEP CONTENT ALIVE: " + newValue);
                                    _contentCache[newValueNoFragment] = newContent;
                                }

                                SetContent(newValue, navigationType, newContent, false);
                            }
                        } finally {
                            // clear global tokenSource to avoid a Cancel on a disposed object
                            if (_tokenSource == localTokenSource)
                            {
                                _tokenSource = null;
                            }

                            // and dispose of the local tokensource
                            localTokenSource.Dispose();
                        }
                    }, scheduler);
                    return;
                }
            }

            // newValue is null or newContent was found in the cache
            SetContent(newValue, navigationType, newContent, false);
        }
Exemplo n.º 56
0
        public ActionResult Index()
        {
            ContentViewViewModel model = null;

            //Remove query string
            var thisUri = new Uri(Request.Url.GetLeftPart(UriPartial.Path));

            // Check for content pages before returning a 404
            var title = GetPageTitle(thisUri);

            // If url has a subdirectory, try the master url list to see if it is a child page
            bool hasSubDirectory = title.Contains("/");

            if (hasSubDirectory)
            {
                model = GetSubDirectoryModel(title);
            }

            // If not a subdirectory try based on permalink / title
            if (model == null || model.ThePage == null)
            {
                model = new ContentViewViewModel {
                    ThePage = ContentLoader.GetDetailsByTitle(title)
                };
            }

            // If we found a hit, return the view, otherwise 404
            if (model.ThePage != null)
            {
                model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template);
                model.PageData    = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent);

                if (UserUtils.UserIsAdmin())
                {
                    var userName = UserUtils.CurrentMembershipUsername();
                    var user     = Context.Users.First(usr => usr.Username == userName);

                    var pageModel         = new EditContentViewModel();
                    var editContentHelper = new EditContentHelper(Context);
                    editContentHelper.LoadContentViewById(model.ThePage.ContentPageId, pageModel);

                    pageModel.BookmarkTitle = model.ThePage.Title;
                    pageModel.IsBookmarked  =
                        Context.Bookmarks.Any(
                            bookmark =>
                            bookmark.Title == title && bookmark.Url == Request.RawUrl &&
                            bookmark.UserId == user.UserId);


                    ViewBag.PageModel = pageModel;
                }

                ViewBag.IsPage      = true;
                ViewBag.PageId      = model.ThePage.ContentPageId;
                ViewBag.IsPublished = model.ThePage.IsActive;
                ViewBag.OGType      = model.ThePage.OGType ?? "website";
                ViewBag.MetaDesc    = model.ThePage.MetaDescription ?? "";
                ViewBag.Title       = model.ThePage.Title;
                ViewBag.OGTitle     = model.ThePage.Title ?? model.ThePage.OGTitle;
                ViewBag.OGImage     = model.ThePage.OGImage ?? "";

                // Set the page Canonical Tag and OGURl
                ViewBag.Canonical = GetCanonical(model.ThePage);
                ViewBag.OGUrl     = model.ThePage.OGUrl ?? ViewBag.Canonical;

                ViewBag.Index  = model.ThePage.NoIndex ? "noindex" : "index";
                ViewBag.Follow = model.ThePage.NoFollow ? "nofollow" : "follow";

                return(View(model.TheTemplate.ViewLocation, model));
            }

            model = new ContentViewViewModel {
                ThePage = ContentLoader.GetDetailsByTitle("404")
            };

            model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template);
            model.PageData    = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent);

            ViewBag.IsPage      = true;
            ViewBag.PageId      = model.ThePage.ContentPageId;
            ViewBag.IsPublished = model.ThePage.IsActive;
            ViewBag.Title       = model.ThePage.Title;
            ViewBag.Index       = "noindex";
            ViewBag.Follow      = "nofollow";

            HttpContext.Response.StatusCode = 404;
            Response.TrySkipIisCustomErrors = true;
            return(View(model.TheTemplate.ViewLocation, model));
        }
Exemplo n.º 57
0
 public override void LoadContent()
 {
     base.LoadContent();
     inventorySprite = ContentLoader.InvSprite(1);
 }
Exemplo n.º 58
0
        private void NavigateSync(Uri oldValue, Uri newValue, NavigationType navigationType)
        {
            Debug.WriteLine("Navigating from '{0}' to '{1}'", oldValue, newValue);

            // set IsLoadingContent state
            SetValue(IsLoadingContentPropertyKey, true);

            // cancel previous load content task (if any)
            // note: no need for thread synchronization, this code always executes on the UI thread
            if (_tokenSource != null)
            {
                _tokenSource.Cancel();
                _tokenSource = null;
            }

            // push previous source onto the history stack (only for new navigation types)
            if (oldValue != null)
            {
                switch (navigationType)
                {
                case NavigationType.New:
                    _history.Push(oldValue);
                    _future.Clear();
                    break;

                case NavigationType.Back:
                    _future.Push(oldValue);
                    break;

                case NavigationType.Forward:
                    _history.Push(oldValue);
                    break;
                }
            }

            object newContent = null;

            if (newValue != null)
            {
                // content is cached on uri without fragment
                var newValueNoFragment = NavigationHelper.RemoveFragment(newValue);

                if (navigationType == NavigationType.Refresh || !_contentCache.TryGetValue(newValueNoFragment, out newContent))
                {
#if !DEBUG
                    try {
#endif
                    newContent = ContentLoader.LoadContent(newValue);

                    if (ShouldKeepContentAlive(newContent))
                    {
                        // keep the new content in memory
                        Debug.WriteLine("KEEP CONTENT ALIVE: " + newValue);
                        _contentCache[newValueNoFragment] = newContent;
                    }

                    SetContent(newValue, navigationType, newContent, false);
#if !DEBUG
                }
                catch (Exception e) {
                    // raise failed event
                    var failedArgs = new NavigationFailedEventArgs {
                        Frame   = this,
                        Source  = newValue,
                        Error   = e?.InnerException,
                        Handled = false
                    };

                    OnNavigationFailed(failedArgs);

                    // if not handled, show error as content
                    newContent = failedArgs.Handled ? null : failedArgs.Error;

                    SetContent(newValue, navigationType, newContent, true);
                }
#endif
                }
            }

            // newValue is null or newContent was found in the cache
            SetContent(newValue, navigationType, newContent, false);
        }
Exemplo n.º 59
0
 /// <summary>
 /// Loads the specified content loader.
 /// </summary>
 /// <param name="contentLoader">The content loader.</param>
 public abstract void Load(ContentLoader contentLoader = null);
Exemplo n.º 60
0
 public override void LoadContent()
 {
     itemSprite = ContentLoader.ItemSprite(11);
 }