Beispiel #1
0
        public AniView(AssetViewContext context)
        {
            _cursor = new Cursor(Path.Combine(context.Game.ContentManager.FileSystem.RootDirectory, context.Entry.FilePath));
            context.Game.SetCursor(_cursor);

            AddDisposeAction(() => context.Game.SetCursor("Arrow"));
        }
Beispiel #2
0
        public IniView(AssetViewContext context)
        {
            var iniDataContext = new IniDataContext(context.Entry.FileSystem, context.Game.SageGame);

            iniDataContext.LoadIniFile(context.Entry);

            using (var stream = context.Entry.Open())
            {
                using (var reader = new StreamReader(stream))
                {
                    _iniString = reader.ReadToEnd();
                }
            }

            _subObjects = new List <IniEntry>();

            foreach (var objectDefinition in iniDataContext.Objects)
            {
                _subObjects.Add(new IniEntry(objectDefinition.Name, () => new ObjectDefinitionView(context, objectDefinition)));
            }

            foreach (var particleSystem in iniDataContext.ParticleSystems)
            {
                _subObjects.Add(new IniEntry(particleSystem.Name, () => new ParticleSystemView(context, particleSystem)));
            }

            // If we can't show this file in object view, default to text view.
            _currentView = _subObjects.Count == 0 ? ViewMode.TextView : ViewMode.ObjectView;
        }
Beispiel #3
0
        public ImageView(AssetViewContext context)
        {
            _context      = context;
            _textureViews = new Dictionary <TextureViewDescription, TextureView>();

            _texture = GetTexture(context);
        }
Beispiel #4
0
 public TxtView(AssetViewContext context)
 {
     using (var fileStream = context.Entry.Open())
         using (var streamReader = new StreamReader(fileStream))
         {
             _text = streamReader.ReadToEnd();
         }
 }
Beispiel #5
0
        public AptView(AssetViewContext context)
            : base(context)
        {
            var aptWindow = context.Game.ContentManager.Load <AptWindow>(context.Entry.FilePath);

            context.Game.Scene2D.AptWindowManager.PushWindow(aptWindow);

            AddDisposeAction(() => context.Game.Scene2D.AptWindowManager.PopWindow());
        }
Beispiel #6
0
        public MapView(AssetViewContext context)
            : base(context)
        {
            _game         = context.Game;
            _game.Scene3D = _game.ContentManager.Load <Scene3D>(context.Entry.FilePath);

            _scriptStateContent = new StringBuilder();

            _game.Scripting.OnUpdateFinished += OnScriptingUpdateFinished;

            AddDisposeAction(() => _game.Scripting.OnUpdateFinished -= OnScriptingUpdateFinished);
        }
Beispiel #7
0
        public WndView(AssetViewContext context)
            : base(context)
        {
            var window = context.Game.ContentManager.Load <Window>(context.Entry.FilePath, new Content.LoadOptions {
                CacheAsset = false
            });

            context.Game.Scene2D.WndWindowManager.PushWindow(window);

            _rootControl = window.Root;

            AddDisposeAction(() => context.Game.Scene2D.WndWindowManager.PopWindow());
        }
Beispiel #8
0
        public RuView(AssetViewContext context)
            : base(context)
        {
            using (var fileStream = context.Entry.Open())
                using (var streamReader = new StreamReader(fileStream))
                {
                    _ruText = streamReader.ReadToEnd();
                }

            var game = context.Game;

            //load the corresponding .dat file
            var movieName = context.Entry.FilePath.Split('/')[0].Split('_')[0];
            var datPath   = movieName + ".dat";
            var datEntry  = game.ContentManager.FileSystem.GetFile(datPath);
            var imageMap  = ImageMap.FromFileSystemEntry(datEntry);

            var shape = Geometry.FromFileSystemEntry(context.Entry);

            var shapeRenderer = new ShapeRenderer(
                shape,
                game.ContentManager,
                imageMap,
                movieName);

            void onRendering2D(object sender, Rendering2DEventArgs e)
            {
                shapeRenderer.Render(e.DrawingContext);
            }

            game.Rendering2D += onRendering2D;

            AddDisposeAction(() => game.Rendering2D -= onRendering2D);

            void onClientSizeChanged(object sender, EventArgs e)
            {
                shapeRenderer.Update(
                    game.GraphicsDevice,
                    game.Panel.ClientBounds.Size);
            }

            game.Panel.ClientSizeChanged += onClientSizeChanged;

            AddDisposeAction(() => game.Panel.ClientSizeChanged -= onClientSizeChanged);
        }
Beispiel #9
0
        public IniView(AssetViewContext context)
        {
            var iniDataContext = new IniDataContext(context.Entry.FileSystem);

            iniDataContext.LoadIniFile(context.Entry);

            _subObjects = new List <IniEntry>();

            foreach (var objectDefinition in iniDataContext.Objects)
            {
                _subObjects.Add(new IniEntry(objectDefinition.Name, () => new ObjectDefinitionView(context, objectDefinition)));
            }

            foreach (var particleSystem in iniDataContext.ParticleSystems)
            {
                _subObjects.Add(new IniEntry(particleSystem.Name, () => new ParticleSystemView(context, particleSystem)));
            }
        }
Beispiel #10
0
        public WavView(AssetViewContext context)
        {
            _source = context.Game.Audio.PlayFile(context.Entry.FilePath, true);

            AddDisposeAction(() => _source.Dispose());
        }
Beispiel #11
0
 protected virtual Texture GetTexture(AssetViewContext context)
 {
     return(AddDisposable(new ImageSharpTexture(context.Entry.Open()).CreateDeviceTexture(
                              context.GraphicsDevice,
                              context.GraphicsDevice.ResourceFactory)));
 }
Beispiel #12
0
        //private ContentView _selectedContentView;

        public ManifestView(AssetViewContext context)
        {
            _gameStream = new GameStream(context.Entry, context.Game);
        }
Beispiel #13
0
 public BmpView(AssetViewContext context)
     : base(context)
 {
 }
Beispiel #14
0
        public W3dView(AssetViewContext context)
            : base(context)
        {
            var game = context.Game;

            var modelInstance = game.ContentManager
                                .Load <Model>(context.Entry.FilePath)
                                .CreateInstance(game.GraphicsDevice);

            void onUpdating(object sender, GameUpdatingEventArgs e) => modelInstance.Update(e.GameTime);

            game.Updating += onUpdating;
            AddDisposeAction(() => game.Updating -= onUpdating);

            void onBuildingRenderList(object sender, BuildingRenderListEventArgs e)
            {
                modelInstance.SetWorldMatrix(Matrix4x4.Identity);
                modelInstance.BuildRenderList(e.RenderList, e.Camera);
            }

            game.BuildingRenderList += onBuildingRenderList;
            AddDisposeAction(() => game.BuildingRenderList -= onBuildingRenderList);

            var enclosingBoundingBox = GetEnclosingBoundingBox(modelInstance);

            var cameraController = new ArcballCameraController(
                enclosingBoundingBox.GetCenter(),
                Vector3.Distance(enclosingBoundingBox.Min, enclosingBoundingBox.Max));

            game.Scene3D = new Scene3D(
                game,
                cameraController,
                null,
                null,
                Array.Empty <Terrain.Road>(),
                null,
                new GameObjectCollection(game.ContentManager),
                new WaypointCollection(),
                new WaypointPathCollection(),
                WorldLighting.CreateDefault(),
                Array.Empty <Player>(),
                Array.Empty <Team>());

            var animations = new List <AnimationInstance>(modelInstance.AnimationInstances);

            var w3dFile = W3dFile.FromFileSystemEntry(context.Entry);

            // If this is a skin file, load "external" animations.
            var externalAnimations = new List <AnimationInstance>();

            if (w3dFile.HLod != null && w3dFile.HLod.Header.Name.EndsWith("_SKN", StringComparison.OrdinalIgnoreCase))
            {
                var namePrefix   = w3dFile.HLod.Header.Name.Substring(0, w3dFile.HLod.Header.Name.LastIndexOf('_') + 1);
                var parentFolder = Path.GetDirectoryName(w3dFile.FilePath);
                var pathPrefix   = Path.Combine(parentFolder, namePrefix);
                foreach (var animationFileEntry in context.Entry.FileSystem.GetFiles(parentFolder))
                {
                    if (!animationFileEntry.FilePath.StartsWith(pathPrefix, StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }

                    var animationModel = game.ContentManager.Load <Model>(animationFileEntry.FilePath);
                    foreach (var animation in animationModel.Animations)
                    {
                        var externalAnimationInstance = new AnimationInstance(modelInstance, animation);
                        modelInstance.AnimationInstances.Add(externalAnimationInstance);
                        externalAnimations.Add(externalAnimationInstance);
                    }
                }
            }

            _subObjects = new List <W3dItem>();

            _subObjects.Add(new W3dModelItem());

            foreach (var animation in animations)
            {
                _subObjects.Add(new W3dAnimationItem(animation, "Animation"));
            }

            foreach (var animation in externalAnimations)
            {
                _subObjects.Add(new W3dAnimationItem(animation, "External Animation"));
            }

            ActivateItem(_subObjects[0]);
        }
Beispiel #15
0
 public DdsView(AssetViewContext context)
     : base(context)
 {
 }
Beispiel #16
0
 public CsfView(AssetViewContext context)
 {
     _csfFile = CsfFile.FromFileSystemEntry(context.Entry);
 }
Beispiel #17
0
        public SoundView(AssetViewContext context)
        {
            _source = context.Game.Audio.GetStream(context.Entry.FilePath);

            AddDisposeAction(() => _source.Dispose());
        }
Beispiel #18
0
 public ConstView(AssetViewContext context)
 {
     _constFile = ConstantData.FromFileSystemEntry(context.Entry);
 }
Beispiel #19
0
 protected abstract Texture GetTexture(AssetViewContext context);
Beispiel #20
0
 protected GameView(AssetViewContext context)
 {
     Context = context;
 }
Beispiel #21
0
 protected override Texture GetTexture(AssetViewContext context)
 {
     return(context.Game.ContentManager.Load <Texture>(context.Entry.FilePath));
 }
Beispiel #22
0
 public TgaView(AssetViewContext context)
     : base(context)
 {
 }
Beispiel #23
0
 protected override Texture GetTexture(AssetViewContext context)
 {
     return(AddDisposable(new ImageSharpTexture(context.Entry.FullFilePath).CreateDeviceTexture(
                              context.GraphicsDevice,
                              context.GraphicsDevice.ResourceFactory)));
 }