Ejemplo n.º 1
0
        private void _save(string path = null)
        {
            _async.SetAndRunOperation(new GrfThread(delegate {
                try {
                    Progress = -1;

                    LuaParser accId = new LuaParser(new byte[0], true, p => new Lub(p).Decompile(), EncodingService.DisplayEncoding, EncodingService.DisplayEncoding);
                    Dictionary <string, string> accIdT = new Dictionary <string, string>();
                    accId.Tables["ACCESSORY_IDs"]      = accIdT;

                    LuaParser accName = new LuaParser(new byte[0], true, p => new Lub(p).Decompile(), EncodingService.DisplayEncoding, EncodingService.DisplayEncoding);
                    Dictionary <string, string> accNameT = new Dictionary <string, string>();
                    accName.Tables["AccNameTable"]       = accNameT;

                    foreach (var item in _obItems.Where(item => item.Id > 0).Where(item => !String.IsNullOrEmpty(item.AccId)))
                    {
                        accIdT[item.AccId] = item.Id.ToString(CultureInfo.InvariantCulture);
                    }

                    if (path == null)
                    {
                        _multiGrf.Clear();
                        string file = TemporaryFilesManager.GetTemporaryFilePath("tmp2_{0:0000}.lua");
                        _writeAccName(file, EncodingService.DisplayEncoding);
                        _multiGrf.SetData(ProjectConfiguration.SyncAccName, File.ReadAllBytes(file));

                        file = TemporaryFilesManager.GetTemporaryFilePath("tmp2_{0:0000}.lua");
                        accId.Write(file, EncodingService.DisplayEncoding);
                        _multiGrf.SetData(ProjectConfiguration.SyncAccId, File.ReadAllBytes(file));
                        _multiGrf.SaveAndReload();
                    }
                    else
                    {
                        Directory.CreateDirectory(path);
                        _writeAccName(GrfPath.Combine(path, "accname.lub"), EncodingService.DisplayEncoding);
                        accId.Write(GrfPath.Combine(path, "accessoryid.lub"), EncodingService.DisplayEncoding);
                    }
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }
                finally {
                    Progress = 100f;
                }
            }, this, 200));
        }
Ejemplo n.º 2
0
        private void _buttonFindErrors_Click(object sender, RoutedEventArgs e)
        {
            List <ValidationErrorView> errors = new List <ValidationErrorView>();

            _asyncOperation.SetAndRunOperation(new GrfThread(() => _validation.FindResourceErrors(errors), _validation, 200, errors, true, true), _updateErrors);
        }