Ejemplo n.º 1
0
        /// <summary>
        /// Load a font.
        /// </summary>
        /// <param name="ttfFontPath">An Adfectus asset path to the font to load. Only ttf format is supported.</param>
        /// <param name="fontSize">The font size to load.</param>
        /// <param name="pixelSize">The font's pixel size to load.</param>
        public unsafe void LoadFont(string ttfFontPath, int fontSize, int pixelSize)
        {
            _beforeStartOperations.Enqueue(() =>
            {
                ImGuiIOPtr io        = ImGui.GetIO();
                OtherAsset font      = Engine.AssetLoader.Get <OtherAsset>(ttfFontPath);
                fixed(void *fontData = &font.Content[0])
                {
                    _loadedFonts.Add(ttfFontPath, io.Fonts.AddFontFromMemoryTTF((IntPtr)fontData, fontSize, pixelSize));
                }

                // Clear the file.
                Engine.AssetLoader.Destroy(ttfFontPath);

                // Upload the font.
                uint newFontTexture = Engine.GraphicsManager.CreateTexture();

                // Get font texture from ImGui
                io.Fonts.GetTexDataAsRGBA32(out byte *pixelData, out int width, out int height, out int bytesPerPixel);

                // Copy the data to a managed array
                byte[] pixels = new byte[width * height * bytesPerPixel];
                Marshal.Copy(new IntPtr(pixelData), pixels, 0, pixels.Length);

                // Create and register the texture.
                Engine.GraphicsManager.BindTexture(newFontTexture);
                Engine.GraphicsManager.UploadToTexture(pixels, new Vector2(width, height), TextureInternalFormat.Rgba, TexturePixelFormat.Rgba);

                // Let ImGui know where to find the texture.
                io.Fonts.SetTexID(new IntPtr(newFontTexture));
                io.Fonts.ClearTexData();
            });
        }
        public void SSG_Other_asset_should_map_to_OtherAsset_correctly()
        {
            SSG_Asset_Other other = new SSG_Asset_Other
            {
                AssetDescription = "assetDesc",
                TypeDescription  = "typeDesc"
            };

            OtherAsset asset = _mapper.Map <OtherAsset>(other);

            Assert.AreEqual("assetDesc", asset.Description);
            Assert.AreEqual("typeDesc", asset.TypeDescription);
        }
Ejemplo n.º 3
0
    private PlacementDataAsset CreateAsset(string assetType, string name, JObject data)
    {
        PlacementDataAsset asset;

        switch (assetType)
        {
        case "ActAsset_Chara":
        {
            asset = new CharaAsset();
            break;
        }

        case "ActAsset_Point":
        {
            asset = new PointAsset();
            break;
        }

        case "ActAsset_Trigger":
        {
            asset = new TriggerAsset();
            break;
        }

        case "ActAsset_BgmArea":
        {
            asset = new BgmAreaAsset();
            break;
        }

        case "ActAsset_MoveArea":
        {
            asset = new MoveAreaAsset();
            break;
        }

        default:
        {
            asset = new OtherAsset(assetType);
            break;
        }
        }

        asset.Name = name;
        asset.Data = data;

        return(asset);
    }
Ejemplo n.º 4
0
        private void LoadFile(OtherAsset f)
        {
            _status = "Loading...";

            byte[] data = f.Content;
            if (!PngFormat.IsPng(data))
            {
                _status = $"The provided file {f.Name} is not a PNG file.";
                return;
            }

            byte[] pixels = PngFormat.Decode(data, out PngFileHeader header);
            byte[] output = PngFormat.Encode(pixels, header.Width, header.Height);

            bool saved = Engine.AssetLoader.Save(output, "Player" + "/" + f.Name, false);

            _status = saved ? "Done!" : "Error when saving the file. Check logs.";
        }
Ejemplo n.º 5
0
        public void OtherAsset_should_map_to_AssetOtherEntity_correctly()
        {
            var otherAsset = new OtherAsset()
            {
                TypeDescription      = "TypeDescription",
                ReferenceDescription = "referenceDescription",
                ReferenceValue       = "referenceValue",
                Description          = "description",
                Notes  = "notes",
                Owners = new List <AssetOwner>()
                {
                    new AssetOwner()
                    {
                    }
                },

                ReferenceDates = new List <ReferenceDate>()
                {
                    new ReferenceDate()
                    {
                        Index = 0, Key = "start date", Value = new DateTimeOffset(new DateTime(2012, 1, 1))
                    },
                    new ReferenceDate()
                    {
                        Index = 1, Key = "end date", Value = new DateTimeOffset(new DateTime(2014, 1, 1))
                    }
                }
            };
            AssetOtherEntity assetEntity = _mapper.Map <AssetOtherEntity>(otherAsset);

            Assert.AreEqual("TypeDescription", assetEntity.TypeDescription);
            Assert.AreEqual("description", assetEntity.AssetDescription);
            Assert.AreEqual("referenceDescription referenceValue", assetEntity.Description);
            Assert.AreEqual("notes", assetEntity.Notes);
            Assert.AreEqual(1, assetEntity.StatusCode);
            Assert.AreEqual(0, assetEntity.StateCode);
            Assert.AreEqual(new DateTime(2012, 1, 1), assetEntity.Date1);
            Assert.AreEqual(new DateTime(2014, 1, 1), assetEntity.Date2);
            Assert.AreEqual("start date", assetEntity.Date1Label);
            Assert.AreEqual("end date", assetEntity.Date2Label);
        }