Пример #1
0
            public IDisposable SetDataProvider(ZipArchive dataArchive)
            {
                var backup  = _extraDataProvider;
                var created = new ExtraDataProvider(dataArchive);

                _extraDataProvider = created;
                return(new ActionAsDisposable(() => {
                    created.Dispose();
                    _extraDataProvider = backup;
                }));
            }
Пример #2
0
            public IDisposable SetDataProvider(string jsonFilename)
            {
                var backup  = _extraDataProvider;
                var created = new ExtraDataProvider(jsonFilename);

                _extraDataProvider = created;
                return(new ActionAsDisposable(() => {
                    created.Dispose();
                    _extraDataProvider = backup;
                }));
            }
            public CmTexturesScriptTexture(Table v, [CanBeNull] ExtraDataProvider data, [NotNull] RaceTexturesContext texturesContext,
                                           [NotNull] Action <string, byte[]> saveCallback)
            {
                _data            = data;
                _texturesContext = texturesContext;
                _saveCallback    = saveCallback;
                _scale           = v[@"scale"].As(1d);

                ActionExtension.InvokeInMainThread(() => {
                    _canvas = new Cell {
                        Width      = v[@"width"].As(256d),
                        Height     = v[@"height"].As(256d),
                        Background = new SolidColorBrush(GetColor(v, "background", Colors.Transparent))
                    };
                });
            }
Пример #4
0
        private string ReadCmTexturesScript(out ExtraDataProvider dataProvider)
        {
            if (!File.Exists(CmTexturesScriptFilename))
            {
                dataProvider = null;
                return(null);
            }

            try {
                dataProvider = new ExtraDataProvider(CmTexturesScriptFilename);
                return(File.ReadAllText(CmTexturesScriptFilename));
            } catch (Exception e) {
                NonfatalError.Notify("Can’t load car’s textures description", e);
                dataProvider = null;
                return(null);
            }
        }