Beispiel #1
0
        public void Load(Subsystem subsystem)
        {
            switch (subsystem)
            {
            case Subsystem.Core:
                LoadFiles(
                    @"Data\INI\Default\GameData.ini",
                    @"Data\INI\GameData.ini",
                    @"Data\INI\Mouse.ini",
                    @"Maps\MapCache.ini");
                break;

            case Subsystem.ObjectCreation:
                LoadFiles(
                    @"Data\INI\Default\Object.ini",
                    @"Data\INI\Locomotor.ini");
                _iniDataContext.LoadIniFiles(@"Data\INI\Object");
                break;

            case Subsystem.Players:
                LoadFiles(
                    @"Data\INI\Default\PlayerTemplate.ini",
                    @"Data\INI\PlayerTemplate.ini");
                break;

            case Subsystem.Terrain:
                LoadFiles(
                    @"Data\INI\Default\Terrain.ini",
                    @"Data\INI\Terrain.ini",
                    @"Data\INI\Default\Roads.ini",
                    @"Data\INI\Roads.ini");
                break;

            case Subsystem.ParticleSystems:
                LoadFiles(@"Data\INI\ParticleSystem.ini");
                break;

            case Subsystem.Wnd:
                LoadFiles(
                    @"Data\INI\WindowTransitions.ini",
                    @"Data\English\HeaderTemplate.ini",
                    @"Data\INI\ControlBarScheme.ini");
                break;

            case Subsystem.Multiplayer:
                LoadFiles(@"Data\INI\Multiplayer.ini");
                break;

            case Subsystem.LinearCampaign:
                LoadFiles(@"Data\INI\Campaign.ini");
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(subsystem), subsystem, null);
            }
        }
Beispiel #2
0
        public WndFileContentViewModel(FileSystemEntry file)
            : base(file)
        {
            _fileSystem = file.FileSystem;

            _csfFile = CsfFile.FromFileSystemEntry(_fileSystem.GetFile(@"Data\English\generals.csf"));

            var iniDataContext = new IniDataContext(_fileSystem);

            iniDataContext.LoadIniFiles(@"Data\INI\MappedImages\HandCreated\");
            iniDataContext.LoadIniFiles(@"Data\INI\MappedImages\TextureSize_512\");
            _mappedImages = iniDataContext.MappedImages;

            var wndFile = WndFile.FromFileSystemEntry(file);

            ContainerView = new NonInheritingCanvas
            {
                Width  = wndFile.RootWindow.ScreenRect.CreationResolution.Width,
                Height = wndFile.RootWindow.ScreenRect.CreationResolution.Height,
            };
            AddWindow(wndFile.RootWindow);
        }
Beispiel #3
0
        public Entity InstantiateObject(string typeName)
        {
            // TODO: Don't do this every time.
            IniDataContext.LoadIniFiles(@"Data\INI\Object");

            var objectDefinition = IniDataContext.Objects.FirstOrDefault(x => x.Name == typeName);

            if (objectDefinition != null)
            {
                return(Entity.FromObjectDefinition(objectDefinition));
            }
            else
            {
                // TODO
                return(null);
            }
        }
Beispiel #4
0
        public ContentManager(
            Game game,
            FileSystem fileSystem,
            GraphicsDevice graphicsDevice,
            SageGame sageGame,
            WndCallbackResolver wndCallbackResolver)
        {
            _game       = game;
            _fileSystem = fileSystem;

            GraphicsDevice = graphicsDevice;

            SageGame = sageGame;

            IniDataContext = new IniDataContext(fileSystem);

            IniDataContext.LoadIniFiles(@"Data\INI\Default\Object.ini");
            IniDataContext.LoadIniFiles(@"Data\INI\Object");

            _contentLoaders = new Dictionary <Type, ContentLoader>
            {
                { typeof(Model), AddDisposable(new ModelLoader()) },
                { typeof(Scene3D), AddDisposable(new MapLoader()) },
                { typeof(Texture), AddDisposable(new TextureLoader(graphicsDevice)) },
                { typeof(Window), AddDisposable(new WindowLoader(this, wndCallbackResolver)) },
                { typeof(AptWindow), AddDisposable(new AptLoader()) },
                { typeof(WavFile), AddDisposable(new WavLoader()) },
            };

            _cachedObjects = new Dictionary <string, object>();

            EffectLibrary = AddDisposable(new EffectLibrary(graphicsDevice));

            TranslationManager = new TranslationManager(fileSystem, sageGame);

            _cachedFonts = new Dictionary <FontKey, Font>();

            var linearClampSamplerDescription = SamplerDescription.Linear;

            linearClampSamplerDescription.AddressModeU = SamplerAddressMode.Clamp;
            linearClampSamplerDescription.AddressModeV = SamplerAddressMode.Clamp;
            linearClampSamplerDescription.AddressModeW = SamplerAddressMode.Clamp;
            LinearClampSampler = AddDisposable(
                graphicsDevice.ResourceFactory.CreateSampler(ref linearClampSamplerDescription));

            var pointClampSamplerDescription = SamplerDescription.Point;

            pointClampSamplerDescription.AddressModeU = SamplerAddressMode.Clamp;
            pointClampSamplerDescription.AddressModeV = SamplerAddressMode.Clamp;
            pointClampSamplerDescription.AddressModeW = SamplerAddressMode.Clamp;
            PointClampSampler = AddDisposable(
                graphicsDevice.ResourceFactory.CreateSampler(ref pointClampSamplerDescription));

            NullTexture = AddDisposable(graphicsDevice.ResourceFactory.CreateTexture(TextureDescription.Texture2D(1, 1, 1, 1, PixelFormat.R8_G8_B8_A8_UNorm, TextureUsage.Sampled)));

            _cachedNullStructuredBuffers = new Dictionary <uint, DeviceBuffer>();

            SolidWhiteTexture = AddDisposable(graphicsDevice.CreateStaticTexture2D(
                                                  1,
                                                  1,
                                                  new TextureMipMapData(
                                                      new byte[] { 255, 255, 255, 255 },
                                                      4, 4, 1, 1),
                                                  PixelFormat.R8_G8_B8_A8_UNorm));

            WndImageLoader = AddDisposable(new WndImageLoader(this, new MappedImageLoader(this)));
        }
Beispiel #5
0
        public ContentManager(
            Game game,
            FileSystem fileSystem,
            GraphicsDevice graphicsDevice,
            SageGame sageGame,
            WndCallbackResolver wndCallbackResolver)
        {
            _game       = game;
            _fileSystem = fileSystem;

            GraphicsDevice = graphicsDevice;

            SageGame = sageGame;

            string language = LanguageUtility.ReadCurrentLanguage(game.Definition, fileSystem.RootDirectory);

            IniDataContext = new IniDataContext(fileSystem);

            IniDataContext.LoadIniFiles(@"Data\INI\Default\Object.ini");
            IniDataContext.LoadIniFiles(@"Data\INI\Object");
            IniDataContext.LoadIniFiles(@"Data\INI\multiplayer.ini");
            IniDataContext.LoadIniFile(@"Data\INI\PlayerTemplate.ini");

            IniDataContext.LoadIniFile(@"maps\MapCache.ini");

            _contentLoaders = new Dictionary <Type, ContentLoader>
            {
                { typeof(Model), AddDisposable(new ModelLoader()) },
                { typeof(Scene3D), AddDisposable(new MapLoader()) },
                { typeof(Texture), AddDisposable(new TextureLoader(graphicsDevice)) },
                { typeof(Window), AddDisposable(new WindowLoader(this, wndCallbackResolver, language)) },
                { typeof(AptWindow), AddDisposable(new AptLoader()) },
                { typeof(WavFile), AddDisposable(new WavLoader()) },
            };

            _cachedObjects = new Dictionary <string, object>();

            EffectLibrary = AddDisposable(new EffectLibrary(graphicsDevice));

            TranslationManager = new TranslationManager(fileSystem, sageGame, language);

            _cachedFonts = new Dictionary <FontKey, Font>();

            var linearClampSamplerDescription = SamplerDescription.Linear;

            linearClampSamplerDescription.AddressModeU = SamplerAddressMode.Clamp;
            linearClampSamplerDescription.AddressModeV = SamplerAddressMode.Clamp;
            linearClampSamplerDescription.AddressModeW = SamplerAddressMode.Clamp;
            LinearClampSampler = AddDisposable(
                graphicsDevice.ResourceFactory.CreateSampler(ref linearClampSamplerDescription));

            var pointClampSamplerDescription = SamplerDescription.Point;

            pointClampSamplerDescription.AddressModeU = SamplerAddressMode.Clamp;
            pointClampSamplerDescription.AddressModeV = SamplerAddressMode.Clamp;
            pointClampSamplerDescription.AddressModeW = SamplerAddressMode.Clamp;
            PointClampSampler = AddDisposable(
                graphicsDevice.ResourceFactory.CreateSampler(ref pointClampSamplerDescription));

            NullTexture = AddDisposable(graphicsDevice.ResourceFactory.CreateTexture(TextureDescription.Texture2D(1, 1, 1, 1, PixelFormat.R8_G8_B8_A8_UNorm, TextureUsage.Sampled)));

            _cachedNullStructuredBuffers = new Dictionary <uint, DeviceBuffer>();

            SolidWhiteTexture = AddDisposable(graphicsDevice.CreateStaticTexture2D(
                                                  1,
                                                  1,
                                                  new TextureMipMapData(
                                                      new byte[] { 255, 255, 255, 255 },
                                                      4, 4, 1, 1),
                                                  PixelFormat.R8_G8_B8_A8_UNorm));

            WndImageLoader = AddDisposable(new WndImageLoader(this, new MappedImageLoader(this)));

            _fallbackFonts = new FontCollection();
            var assembly   = Assembly.GetExecutingAssembly();
            var fontStream = assembly.GetManifestResourceStream($"OpenSage.Content.Fonts.{_fallbackEmbeddedFont}-Regular.ttf");

            _fallbackFonts.Install(fontStream);
            fontStream = assembly.GetManifestResourceStream($"OpenSage.Content.Fonts.{_fallbackEmbeddedFont}-Bold.ttf");
            _fallbackFonts.Install(fontStream);
        }