示例#1
0
        public override void Load(IResourceCache cache, ResourcePath path)
        {
            if (!cache.ContentFileExists(path))
            {
                throw new FileNotFoundException("Content file does not exist for font");
            }

            switch (GameController.Mode)
            {
            case GameController.DisplayMode.Headless:
                break;

            case GameController.DisplayMode.Godot:
                if (!cache.TryGetDiskFilePath(path, out string diskPath))
                {
                    throw new InvalidOperationException("Fonts can only be loaded from disk.");
                }

                var res = Godot.ResourceLoader.Load(diskPath);
                if (!(res is Godot.DynamicFontData fontData))
                {
                    throw new InvalidDataException("Path does not point to a font.");
                }

                FontData = fontData;
                break;

            case GameController.DisplayMode.Clyde:
                FontFaceHandle = IoCManager.Resolve <IFontManagerInternal>().Load(cache.ContentFileRead(path).ToArray());
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#2
0
        public override void Load(IResourceCache cache, ResourcePath path)
        {
            if (!cache.ContentFileExists(path))
            {
                throw new FileNotFoundException("Content file does not exist for font");
            }

            FontFaceHandle = IoCManager.Resolve <IFontManagerInternal>().Load(cache.ContentFileRead(path).ToArray());
        }
示例#3
0
        public override void Load(IResourceCache cache, ResourcePath path)
        {
            if (!cache.TryContentFileRead(path, out var stream))
            {
                throw new FileNotFoundException("Content file does not exist for font");
            }

            using (stream)
            {
                FontFaceHandle = IoCManager.Resolve <IFontManagerInternal>().Load(stream);
            }
        }