Exemplo n.º 1
0
        public NewDatabase()
        {
            LicensingStatus = new Observable <LicensingStatus>();
            InitializeComponent();
            var req = ApplicationModel.DatabaseCommands.ForDefaultDatabase().CreateRequest("/license/status", "GET");

            req.ReadResponseJsonAsync().ContinueOnSuccessInTheUIThread(doc =>
            {
                LicensingStatus.Value = ((RavenJObject)doc).Deserialize <LicensingStatus>(new DocumentConvention());
                var hasPeriodic       = (bool)new BundleNameToActiveConverter().Convert(LicensingStatus.Value, typeof(bool), "PeriodicBackup",
                                                                                        CultureInfo.InvariantCulture);
                if (hasPeriodic)
                {
                    Bundles.Add("PeriodicBackup");
                }
            });


            Bundles  = new List <string>();
            KeyDown += (sender, args) =>
            {
                if (args.Key == Key.Escape)
                {
                    DialogResult = false;
                }
            };
        }
Exemplo n.º 2
0
        public bool AddBundle(string gameName, string bundleName, byte[] bytes, AssetBundle bundle = null)
        {
            if (bundle == null)
            {
                bundle = AssetBundle.LoadFromMemory(bytes);
                if (bundle == null)
                {
                    Debug.LogErrorFormat("Error while loading bundle {0} for {1} game", bundleName, gameName);
                    return(false);
                }
            }

            if (!Bundles.ContainsKey(gameName))
            {
                Bundles.Add(gameName, new Dictionary <string, AssetBundle>());
                Cache.Add(gameName, new Dictionary <string, string>());
            }
            if (Bundles[gameName].ContainsKey(bundleName))
            {
                RemoveBundle(gameName, bundleName);
            }

            Bundles[gameName].Add(bundleName, bundle);
            Cache[gameName].Add(bundleName, bytes.Base64GetString());

            UpdateAssetBundlesCache();
            return(true);
        }
        protected override void PostDialogOpened(IDialogParameters pms)
        {
            entryVM = pms.GetValue <EntryViewModel>("Entry");
            RaisePropertyChanged("FileVisibility");
            RaisePropertyChanged("FolderVisibility");
            RaisePropertyChanged("Name");
            RaisePropertyChanged("Icon");
            RaisePropertyChanged("Type");
            RaisePropertyChanged("Size");
            RaisePropertyChanged("EntryPath");
            RaisePropertyChanged("HashedName");
            RaisePropertyChanged("FolderContains");

            IEntry entry = entryVM.Owner;

            if (entry is FileEntry)
            {
                var bundles = (entry as FileEntry).BundleEntries;
                foreach (var pair in bundles)
                {
                    var e = new PackageFileViewModel(pair.Value);
                    Bundles.Add(e);
                }
            }
        }
Exemplo n.º 4
0
        public override void ReadFrom(string gameDirectory)
        {
            var tracksDirectory = Path.Combine(gameDirectory, "TRACKS");

            foreach (var bundleFile in Directory.EnumerateFiles(tracksDirectory, "L2R*.BUN"))
            {
                Bundles.Add(ReadLocationBundle(bundleFile));
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Mount a bundle.
        /// </summary>
        /// <param name="bundle"></param>
        public void MountBundle(VfsBundle bundle)
        {
            if (Bundles.Exists(b => b.ID == bundle.ID))
            {
                throw new Exception($"Bundle [{bundle.ID}] is already mounted to [{Path}].");
            }

            Bundles.Add(bundle);
        }
Exemplo n.º 6
0
        public override void ReadFrom(string gameDirectory)
        {
            var tracksHighExists = Directory.Exists(Path.Combine(gameDirectory, "TracksHigh"));
            var tracksDirectory  = Path.Combine(gameDirectory, tracksHighExists ? "TracksHigh" : "Tracks");

            foreach (var bundleFile in Directory.EnumerateFiles(tracksDirectory, "L5R?.BUN"))
            {
                Bundles.Add(ReadLocationBundle(bundleFile));
            }
        }
Exemplo n.º 7
0
        private void LoadBundle(XElement element)
        {
            string                   id             = string.Empty;
            string                   name           = string.Empty;
            int                      value          = 0;
            List <string>            bundleProducts = new List <string>();
            List <IRule>             bundleRules    = new List <IRule>();
            IEnumerator <XAttribute> attributes     = element.Attributes().GetEnumerator();

            while (attributes.MoveNext())
            {
                if (attributes.Current.Name == ID_KEY)
                {
                    id = attributes.Current.Value;
                }
            }
            IEnumerator <XElement> elements = element.Elements().GetEnumerator();

            while (elements.MoveNext())
            {
                switch (elements.Current.Name.LocalName)
                {
                case NAME_KEY:
                    name = elements.Current.Value;
                    break;

                case VALUE_KEY:
                    value = int.Parse(elements.Current.Value);
                    break;

                case PRODUCTS_KEY:
                    IEnumerator <XElement> productIDs = elements.Current.Elements().GetEnumerator();
                    while (productIDs.MoveNext())
                    {
                        if (productIDs.Current.Name.LocalName == PRODUCT_ID_KEY)
                        {
                            bundleProducts.Add(productIDs.Current.Value);
                        }
                    }
                    break;

                case RULES_KEY:
                    IEnumerator <XElement> rules = elements.Current.Elements().GetEnumerator();
                    while (rules.MoveNext())
                    {
                        bundleRules.Add(LoadRule(rules.Current));
                    }
                    break;

                default:
                    break;
                }
            }
            Bundles.Add(id, new Bundle(name, value, bundleProducts, bundleRules));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Mount a bundle to the bundle. Yes, seriously.
        /// </summary>
        /// <param name="bundle"></param>
        public VfsBundle MountBundle(VfsBundle bundle)
        {
            if (Bundles.Exists(b => b.ID == bundle.ID))
            {
                throw new Exception($"Bundle [{bundle.ID}] is already mounted to bundle {Name}.");
            }

            Bundles.Add(bundle);

            return(Bundles.Find(b => b.ID == bundle.ID));
        }
        protected void RegisterBundle(EBundleType bundleType, string virtualPath, string[] cdnPaths)
        {
            Bundle registerBundle = null;

            switch (bundleType)
            {
            case EBundleType.Style: registerBundle = new StyleBundle(virtualPath).Include(cdnPaths); break;

            case EBundleType.Script: registerBundle = new ScriptBundle(virtualPath).Include(cdnPaths); break;
            }
            Bundles.Add(registerBundle);
        }
Exemplo n.º 10
0
        public void AddItem(LockerItem lockerItem, BaseItem baseItem)
        {
            Items.Add(lockerItem);

            if (baseItem is EquipItem ei)
            {
                Equips.Add(ei);
            }
            else if (baseItem is BundleItem bi)
            {
                Bundles.Add(bi);
            }
            else if (baseItem is PetItem pi)
            {
                Pets.Add(pi);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        ///     Load a single bundle
        /// </summary>
        /// <param name="filename"></param>
        public void LoadBundle(string filename)
        {
            if (Bundles.ContainsKey(filename))
                return;

            var bundle = new Bundle(filename);

            foreach (var item in bundle.Items)
            {
                if (!Items.ContainsKey(item.Key))
                    Items.Add(item.Key, new List<BundleItem>());

                Items[item.Key].Add(item.Value);
            }

            Bundles.Add(filename, bundle);
        }
Exemplo n.º 12
0
        private void Checked(object sender, RoutedEventArgs e)
        {
            var checkbox = sender as CheckBox;

            if (checkbox == null)
            {
                return;
            }
            Bundles.Add(checkbox.Name);

            var border = FindName(checkbox.Name + "Settings") as Border;

            if (border != null)
            {
                border.Visibility = Visibility.Visible;
            }
        }
Exemplo n.º 13
0
        public NewDatabase()
        {
            HasAuth         = new Observable <bool>();
            LicensingStatus = new Observable <LicensingStatus>();
            InitializeComponent();
            var req = ApplicationModel.DatabaseCommands.ForSystemDatabase().CreateRequest("/license/status", "GET");

            req.ReadResponseJsonAsync().ContinueOnSuccessInTheUIThread(doc =>
            {
                LicensingStatus.Value = ((RavenJObject)doc).Deserialize <LicensingStatus>(new DocumentConvention());
                var hasPeriodic       = (bool)new BundleNameToActiveConverter().Convert(LicensingStatus.Value, typeof(bool), "PeriodicBackup",
                                                                                        CultureInfo.InvariantCulture);
                if (hasPeriodic)
                {
                    Bundles.Add("PeriodicBackup");
                }
            });

            req = ApplicationModel.DatabaseCommands.ForSystemDatabase().CreateRequest("/plugins/status".NoCache(), "GET");

            req.ReadResponseJsonAsync().ContinueOnSuccessInTheUIThread(item =>
            {
                var plugins = ((RavenJObject)item).Deserialize <PluginsStatus>(new DocumentConvention());

                if (plugins == null || plugins.Plugins.Contains("Raven.Bundles.Authorization") == false)
                {
                    return;
                }

                HasAuth.Value = true;
            });


            Bundles  = new List <string>();
            KeyDown += (sender, args) =>
            {
                if (args.Key == Key.Escape)
                {
                    DialogResult = false;
                }
            };
        }
Exemplo n.º 14
0
        public bool AddBundle(SpecificVersion bundle)
        {
            if (bundle == null)
            {
                throw new ArgumentNullException(nameof(bundle));
            }

            lock (Bundles) {
                if (!HasBundle(bundle))
                {
                    if (!Bundles.ContainsKey(bundle.Name))
                    {
                        Bundles.Add(bundle.Name, new List <string>());
                    }
                    Bundles[bundle.Name].Add(bundle.VersionData);
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 15
0
        /// <summary>
        ///     Load a single bundle
        /// </summary>
        /// <param name="filename"></param>
        public void LoadBundle(string filename)
        {
            if (Bundles.ContainsKey(filename))
            {
                return;
            }

            var bundle = new Bundle(filename);

            foreach (var item in bundle.Items)
            {
                if (!Items.ContainsKey(item.Key))
                {
                    Items.Add(item.Key, new List <IWitcherFile>());
                }

                Items[item.Key].Add(item.Value);
            }

            Bundles.Add(filename, bundle);
        }
Exemplo n.º 16
0
        /// <summary>
        ///     Load a single bundle
        /// </summary>
        /// <param name="filename"></param>
        public void LoadBundle(string filename)
        {
            if (Bundles.ContainsKey(filename))
            {
                return;
            }

            var bundle = new Bundle(filename);

            Dictionary <string, BundleItem> itemsDict = bundle.Items.ToDictionary(_ => _.DepotPath, _ => _);

            foreach (var item in itemsDict)
            {
                if (!Items.ContainsKey(item.Key))
                {
                    Items.Add(item.Key, new List <IWitcherFile>());
                }

                Items[item.Key].Add(item.Value);
            }

            Bundles.Add(filename, bundle);
        }
Exemplo n.º 17
0
 private void Refresh()
 {
     Bundles.Clear();
     database.Refresh();
     database.Bundles.ForEach(x => Bundles.Add(x));
 }