예제 #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);
        }
예제 #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);
 }
예제 #3
0
        public void LoadContent(ContentLoader content)
        {
            myEffect = content.ContentManager.Load<ParticleEffect>(name);

            myEffect.LoadContent(content.ContentManager);
            myEffect.Initialise();
            myRenderer.LoadContent(content.ContentManager);
        }
예제 #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);
            }
        }
예제 #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);
        }
예제 #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);
        }
예제 #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();
 }
예제 #8
0
        public override void Load(ContentLoader contentLoader = null)
        {
            if (contentLoader == null)
                return;

            using (var stream = new MemoryStream(this.Data))
            {
                contentLoader(stream);
            }
        }
예제 #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);
            }
        }
예제 #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);
 }
예제 #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);
        }
예제 #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);
        }
예제 #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);
                }
            };
        }
예제 #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);
        }
예제 #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;

        }
예제 #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);
        }
예제 #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.
    }
예제 #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));
            }
        }
예제 #19
0
파일: Control.cs 프로젝트: xupefei/EAGSS
 public virtual void LoadContent(ContentLoader content, ScreenManager screenManager)
 {
 }
예제 #20
0
 private void Start()
 {
     ContentLoader.RegisterLoadCallback(LoadShapes);
 }
예제 #21
0
 public void DisposeContentLoader()
 {
     ContentLoader.DisposeIfInitialized();
 }
예제 #22
0
 public void PlaySoundOnClick()
 {
     new Command(() => ContentLoader.Load <Sound>("DefaultSound").Play()).Add(
         new MouseButtonTrigger());
 }
예제 #23
0
 public void PlaySoundLeft()
 {
     ContentLoader.Load <Sound>("DefaultSound").Play(1, -1);
 }
예제 #24
0
        private static void PlayClickedSound()
        {
            var clickSound = ContentLoader.Load <Sound>(GameSounds.MenuPageFlip.ToString());

            clickSound.Play();
        }
예제 #25
0
 public void PlaySound()
 {
     ContentLoader.Load <Sound>("DefaultSound").Play();
 }
예제 #26
0
 protected override void Preview(string contentName)
 {
     new LevelDebugRenderer(ContentLoader.Load <Level>(contentName));
 }
예제 #27
0
 public Sprite(string texture) :
     this(ContentLoader.LoadTexture(texture), Alignments.Center)
 {
 }
예제 #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);
    }
예제 #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);
        }
    }
예제 #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);
        }
예제 #31
0
 private void Start()
 {
     ContentLoader.RegisterLoadCallback(LoadBuildings);
 }
예제 #32
0
 protected override void OnInit(ContentLoader loader)
 {
     loader.SetLoadContextParameters(new AddressableLoaderParameters {
         behaviour = LoaderBehaviour.Asset
     });
 }
예제 #33
0
파일: EAGSS.cs 프로젝트: xupefei/EAGSS
        protected override void Initialize()
        {
            Content = new ContentLoader(Services);

            base.Initialize();
        }
예제 #34
0
 public Sprite(string texture, Alignments alignment) :
     this(ContentLoader.LoadTexture(texture), alignment)
 {
 }
예제 #35
0
파일: FadeBox.cs 프로젝트: xupefei/EAGSS
 public override void LoadContent(ContentLoader content, ScreenManager screenManager)
 {
     base.LoadContent(content, screenManager);
 }
예제 #36
0
 public override void Load(ContentLoader contentLoader)
 {
     throw new NotImplementedException();
 }
예제 #37
0
 public void SetUp()
 {
     verdana = Font.Default;
     tahoma  = ContentLoader.Load <Font>("Tahoma30");
 }
예제 #38
0
        private static void PlayClickedSound()
        {
            var sound = ContentLoader.Load <Sound>(GameSounds.MenuButtonClick.ToString());

            sound.Play();
        }
예제 #39
0
 public void PlaySoundVerySilent()
 {
     ContentLoader.Load <Sound>("DefaultSound").Play(0.1f);
 }
예제 #40
0
파일: BitmapFont.cs 프로젝트: xupefei/EAGSS
        /// <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);
        }
예제 #41
0
        public void PlaySoundAndDispose()
        {
            var sound = ContentLoader.Load <Sound>("DefaultSound");

            sound.Dispose();
        }
예제 #42
0
 public abstract void Load(string path, ContentLoader contentLoader);
예제 #43
0
 protected override sealed void CreateScene()
 {
     Scene = ContentLoader.Load <Scene>(GameMenus.TowerSelectionPanel.ToString());
     Hide();
     SetupButtonsAndAttachEvents();
 }
예제 #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]) });
 }
예제 #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;
 }
예제 #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());
            }
        }
예제 #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();
        }
예제 #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;
        }
예제 #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();
        }
예제 #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);
예제 #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();
            }
        }
예제 #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);
        }
예제 #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));
        }
예제 #57
0
 public override void LoadContent()
 {
     base.LoadContent();
     inventorySprite = ContentLoader.InvSprite(1);
 }
예제 #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);
        }
예제 #59
0
 /// <summary>
 /// Loads the specified content loader.
 /// </summary>
 /// <param name="contentLoader">The content loader.</param>
 public abstract void Load(ContentLoader contentLoader = null);
예제 #60
0
 public override void LoadContent()
 {
     itemSprite = ContentLoader.ItemSprite(11);
 }