Ejemplo n.º 1
0
 public void Save(Addon addon)
 {
     if(addon.IsValid())
     {
         AddonRepo.Save(addon);
     }
 }
Ejemplo n.º 2
0
        public Wiki(Addon addon, string lang)
        {
            Addon = addon;
            Lang = lang;

            parseLanguageFile();
            // create a directory structure to store this wiki.
            createDirectories();

            StartPage = new StartPage(this);
            HeroesPage = new HeroesPage(this);
            UnitsPage = new UnitsPage(this);
            ItemsPage = new ItemsPage(this);
        }
Ejemplo n.º 3
0
		public void setupNPCWatchers(Addon currAddon) {
			if (currAddon.npcWatchers.Count > 0) { return; }

			var dirs = Directory.GetDirectories(Path.Combine(currAddon.gamePath, "scripts", "npc"));
			foreach (var path in dirs) {
				var dirName = path.Substring(path.LastIndexOf('\\') + 1);
				//Console.WriteLine("dirName: " + dirName);
				if (dirName != "abilities" && dirName != "items" && dirName != "units" && dirName != "heroes") {
					continue;
				}
				FileSystemWatcher fsw = new FileSystemWatcher();
				currAddon.npcWatchers.Add(dirName, fsw);
				fsw.IncludeSubdirectories = true;
				fsw.Path = path;
				fsw.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName;
				fsw.Filter = "*.txt";
				fsw.EnableRaisingEvents = true;
				var lastUpdate = DateTime.Now;

				fsw.Changed += (s, e) => {
					//if (DateTime.Now.Subtract(lastUpdate).TotalSeconds > 2) {

					//}
					string[] items = new string[1];
					Console.WriteLine("dirName: " + dirName);
					items[0] = dirName;
					combine(items);

				};

				fsw.Created += (s, e) => {
					string[] items = new string[1];
					items[0] = dirName;
					combine(items);
				};

				fsw.Deleted += (s, e) => {
					string[] items = new string[1];
					items[0] = dirName;
					combine(items);
				};

				fsw.Renamed += (s, e) => {
					string[] items = new string[1];
					items[0] = dirName;
					combine(items);
				};
			}
		}
Ejemplo n.º 4
0
        public void LoadAddons()
        {
            string[] dirs = Directory.GetDirectories("Addons");
            Addons.Clear();
            foreach (string dir in dirs) {
                Addon addon = new Addon(dir);
                if (addon.Settings.GetBool("Enabled")) {
                    addon.LoadAssembly();
                    addon.CallHook("Initialize", Tray);
                }
                Addons.Add(addon);
            }

            LoadShortcuts();
        }
Ejemplo n.º 5
0
 public AddonControl(Addon addon)
 {
     InitializeComponent();
     Addon                     = addon;
     LabelName.Content         = addon.Details.Name;
     TextBlockDescription.Text = addon.Details.Description;
     ArchiveFilePath           = $"{System.IO.Path.GetTempPath()}{Addon.Details.Name}.zip";
     DownloadUrlPath           = $"{System.IO.Path.GetTempPath()}{Addon.Details.Name}{System.IO.Path.GetExtension(addon.Details.ImageUrl)}";
     Background.Source         = ChooseImage();
     //Background.Source= new BitmapImage(new Uri($"/Images/Backgrounds/bfa.jpg", UriKind.Relative));
     Height     = 215;
     Width      = 200;
     this.addon = addon;
     if (addon.Details.Installed)
     {
         Border.BorderThickness = new Thickness(2);
     }
 }
Ejemplo n.º 6
0
        public async Task UninstallDependencies(Addon addon)
        {
            var addonDependencies = GetDependencies(addon);

            foreach (var dependency in addonDependencies)
            {
                var dependencyAddon = GetAddon(dependency.DependencyId);
                if (dependencyAddon != null &&
                    _dependencyRepository
                    .GetDependentAddons(dependencyAddon)
                    .All(dep => dep.AddonId == addon.Id))
                {
                    await UninstallAddon(dependencyAddon, true);
                }
                _dependencyRepository.DeleteItem(dependency);
            }
            _dependencyRepository.DeleteItems(_dependencyRepository.GetDependentAddons(addon));
        }
Ejemplo n.º 7
0
        private bool SafeguardHasVaultCredentials(Addon addon)
        {
            var accountsPushedToSpp = false;

            var assetId = _configDb.AssetId;

            if (assetId != null && assetId > 0)
            {
                var addonAccounts = addon.VaultCredentials;
                var accounts      = _safeguardLogic.GetAssetAccounts(null, assetId.Value).ToArray();
                if (accounts.Any())
                {
                    accountsPushedToSpp = accounts.All(x => addonAccounts.ContainsKey(x.Name));
                }
            }

            return(accountsPushedToSpp);
        }
Ejemplo n.º 8
0
        internal static async Task RemoveFilesFor(Addon addon)
        {
            var folders = new List <string>(addon.SubFolders)
            {
                addon.FolderName
            };

            await RemoveFolders(addon.Game.AbsolutePath, folders);

            //var gameFolder = await StorageFolder.GetFolderFromPathAsync(addon.Game.AbsolutePath);
            //var addonFolder = await gameFolder.GetFolderAsync(addon.FolderName);
            //await addonFolder.DeleteAsync(StorageDeleteOption.PermanentDelete);
            //foreach (var folderName in addon.SubFolders)
            //{
            //    var folder = await gameFolder.GetFolderAsync(folderName);
            //    await folder.DeleteAsync(StorageDeleteOption.PermanentDelete);
            //}
        }
Ejemplo n.º 9
0
        private void button_actions_generate_Click(object sender, EventArgs e)
        {
            //  > Checks
            if (!(StringPath.GetExtension(textbox_settings_path.Text).Length == 0))
            {
                Notification.Error($"File '{textbox_settings_path.Text}' isn't a directory! Please specify a valid directory!");
                return;
            }

            Addon addon;

            try
            {
                addon = new Addon
                {
                    title = textbox_settings_title.Text,
                    type  = combobox_settings_type.SelectedItem.ToString(),
                    tags  = new string[]
                    {
                        combobox_settings_tag1.SelectedItem.ToString(),
                            combobox_settings_tag2.SelectedItem.ToString(),
                    },
                    ignore = ignore.ToArray(),
                };
            }
            catch (NullReferenceException)
            {
                Notification.Error("You didn't specified all fields, unable to generate the JSON file.");
                return;
            }

            string path = textbox_settings_path.Text + "/addon.json";
            JsonSerializerOptions options = new JsonSerializerOptions
            {
                WriteIndented = true,
            };

            File.WriteAllText(path, JsonSerializer.Serialize(addon, options));

            if (File.Exists(path))
            {
                Notification.Information("Success! File 'addon.json' has been generated!");
            }
        }
Ejemplo n.º 10
0
        internal static async Task <(string, List <string>)> UpdateAddonOld(Addon addon, Download download, StorageFile file, IProgressable progressable = null)
        {
            var extractFolderPath  = localFolder.Path + @"\" + file.Name.Replace(".zip", "");
            var subFoldersToDelete = new List <string>();

            try
            {
                ZipFile.ExtractToDirectory(file.Path, extractFolderPath);
                // int directoryCount = Directory.GetDirectories(extractFolderPath, "*", SearchOption.AllDirectories).Length;
                float fileCount = Directory.GetFiles(extractFolderPath, "*", SearchOption.AllDirectories).Length;

                var extractFolder = await StorageFolder.GetFolderFromPathAsync(extractFolderPath);

                var folders = await extractFolder.GetFoldersAsync();

                var gameFolder = await StorageFolder.GetFolderFromPathAsync(addon.Game.AbsolutePath);

                //var tasks = folders.SelectMany(folder => CopyFolderAsync2(folder, gameFolder));
                //await Task.WhenAll(tasks);
                var foldersAsList = new List <StorageFolder>(folders);
                subFoldersToDelete = foldersAsList.Select(f => f.Name)
                                     .Where(name => !name.Equals(addon.FolderName, StringComparison.OrdinalIgnoreCase))
                                     .ToList();
                if (Singleton <SettingsViewModel> .Instance.IsDeleteOldFilesBeforeUpdate ?? false)
                {
                    var subFolders = new List <string>(subFoldersToDelete)
                    {
                        addon.FolderName
                    };
                    await RemoveFolders(addon.Game.AbsolutePath, subFolders);
                }

                var counter = new Counter(progressable != null ? progressable : addon, Math.Max(fileCount, 1));
                foreach (var folder in folders)
                {
                    await CopyFolderAsync(folder, gameFolder, counter);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("[ERROR] UpdateAddon. " + e.Message + ", " + e.StackTrace);
            }
            return(extractFolderPath, subFoldersToDelete);
        }
Ejemplo n.º 11
0
        void CheckAddonDirectory(Addon addon, DirectoryInfo directory, Modpack modpack)
        {
            Directory.CreateDirectory(directory.FullName);
            HashSet <FileInfo> allFiles = new HashSet <FileInfo>(
                directory.GetFiles("*", SearchOption.AllDirectories),
                new FileSystemInfoEqualityComparer());

            List <AddonFile> filesToDownload = new List <AddonFile>();

            foreach (var f in addon.Files)
            {
                string   fPath = Path.Combine(ModpackDirectory.FullName, f.Path);
                FileInfo fi    = new FileInfo(fPath);
                if (fi.Exists)
                {
                    //long writeTime = ((DateTimeOffset)fi.LastWriteTimeUtc).ToUnixTimeSeconds();
                    if (fi.Length != f.Size /* || writeTime != f.LastChange*/)
                    {
                        Printer?.PrintLine($"\tSize differs: {fi.Length}/{f.Size} B ({f.Path})", VerboseLevel.REGULAR);
                        filesToDownload.Add(f);
                    }
                    allFiles.Remove(fi);
                }
                else
                {
                    Printer?.PrintLine($"\tFile not found: {f.Path}", VerboseLevel.REGULAR);
                    filesToDownload.Add(f);
                }
            }

            if (filesToDownload.Count > 0)
            {
                ConcurrentAddonDownloader downloader = new ConcurrentAddonDownloader(Printer);
                downloader.DownloadFiles(filesToDownload, modpack.Source, ModpackDirectory).GetAwaiter().GetResult();
            }

            foreach (var f in allFiles)
            {
                Printer?.PrintLine($"\tRedundant file: {f.FullName} - Deleting!", VerboseLevel.REGULAR);
                f.Delete();
            }

            DeleteEmptyDirectories(directory);
        }
Ejemplo n.º 12
0
        public static async Task UpdateAddon(Addon addon, Download download)
        {
            if (addon.IsIgnored)
            {
                return;
            }
            addon.Message  = "Downloading...";
            addon.Progress = 0;
            addon.Status   = Addon.UPDATING;

            var file = await Task.Run(() => Update.DLWithHttpProgress(addon, download));

            if (file == null)
            {
                addon.Status   = Addon.UNKNOWN;
                addon.Message  = string.Empty;
                addon.Progress = 0;
                return;
            }

            addon.Message  = "Extracting...";
            addon.Progress = 0;

            if (addon.ProjectUrl.Equals(Version.ELVUI))
            {
                var trash = await Task.Run(() => Update.UpdateAddonOld(addon, download, file));

                addon.CurrentDownload = download;
                await Update.AddSubFolders(addon, trash.Item2);

                addon.Message = string.Empty;
                await Task.Run(() => Update.Cleanup(file.Name, trash.Item1));
            }
            else
            {
                var subFolders = await Task.Run(() => Update.UpdateAddon2(addon, file));

                addon.CurrentDownload = download;
                await Update.AddSubFolders(addon, subFolders);

                addon.Message = string.Empty;
                await Task.Run(() => Update.Cleanup2(file.Name));
            }
        }
Ejemplo n.º 13
0
        private List <Addon> ParseDataToAddon(List <string> FileDataList)
        {
            Addon                  addon            = new Addon();
            List <Addon>           addons           = new List <Addon>();
            List <AddonCollection> addonCollections = new List <AddonCollection>();

            foreach (string FileData in FileDataList)
            {
                AddonCollection addonCollection = Newtonsoft.Json.JsonConvert.DeserializeObject <AddonCollection>(FileData);
                addonCollections.Add(addonCollection);
            }
            List <Addon> addonList = new List <Addon>();

            foreach (AddonCollection addonCollection in addonCollections)
            {
                addonList = addonList.Concat(addonCollection.Addons).ToList();
            }
            return(addonList);
        }
Ejemplo n.º 14
0
    public void FilterForAddon(Addon addon)
    {
        TMP_Dropdown dropdown = addonFilterDropdown.GetComponent <TMP_Dropdown>();

        if (addon != null)
        {
            for (int i = 0; i < dropdown.options.Count; i++)
            {
                if (dropdown.options[i].text == addon.info.Name)
                {
                    dropdown.value = i;
                    break;
                }
            }
        }

        addonFilter      = addon;
        shouldRepopulate = true;
    }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            var addon = new Addon();
            var manifest = new AddonManifest
                {
                  Author  = "Abraham Sultan",
                  Vendor = "Apprenda Inc.",
                  Version = "1.0.0.0",
                  IsEnabled = true,
                  Name = "AWS RDS",
                  Properties = new List<AddonProperty>()
                      {
                          new AddonProperty(){Key = "requireDevCredentials", Value = "true"}
                      }
                };

            var request = new AddonTestRequest { Manifest = manifest, DeveloperOptions = "" };
            addon.Test(request);
        }
Ejemplo n.º 16
0
        internal static async Task<List<Download>> DownloadVersionsFor(Addon addon)
        {
            if (string.IsNullOrEmpty(addon.ProjectUrl))
            {
                return new List<Download>();
            }

            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                return new List<Download>();
            }

            if (addon.ProjectUrl.Equals(ELVUI))
            {
                return await FromElvUI(addon);
            }

            return await FromCurse(addon);
        }
Ejemplo n.º 17
0
    public void Click()
    {
        UIMouseFollow follow = FindObjectOfType <UIMouseFollow>();

        if (myAddon == null)
        {
            if (follow.myItem != null)
            {
                SynthSphere sphere = null;
                try { sphere = (SynthSphere)follow.myItem; } catch (System.InvalidCastException) {  }
                try
                {
                    if (sphere != null && myIndex != 0)
                    {
                        Debug.Log("Only slot 1 may have a SynthSphere.");
                    }
                    else
                    {
                        myAddon = (Addon)Instantiate(follow.myItem);
                        modifySlot.myItem.data.addons[myIndex] = myAddon.stats;
                        follow.RemoveItem();
                    }
                }
                catch (System.InvalidCastException)
                {
                    Debug.Log("follow Item not an Addon");
                    return;
                }
            }
        }
        else
        {
            if (follow.myItem == null)
            {
                follow.AssignItem(myAddon);
                modifySlot.myItem.data.addons[myIndex] = new StatData();
                myAddon = null;
            }
        }

        FindObjectOfType <AddonsController>().OnEnable();
        FindObjectOfType <StatController>().OnEnable();
    }
Ejemplo n.º 18
0
 private async Task DecideFile(
     FileInfo local,
     File remote,
     Addon addon,
     ObservableCollection <IFileAction> actions)
 {
     if (!local.Exists)
     {
         this.log.Debug("{file} missing", local.FullName);
         await AddActionAsync(
             new Download(local, remote, addon, this.RepoRootUri, remote.LastChange) { Action = "Missing" },
             actions,
             remote.Size);
     }
     else if (local.Length != remote.Size)
     {
         this.log.Debug("{file} size: {local}, expected: {remote}", local.Name, local.Length, remote.Size);
         await AddActionAsync(
             new Download(local, remote, addon, this.RepoRootUri, remote.LastChange)
         {
             Action =
                 $"size is differrent, local: {local.Length}, remote: {remote.Size}"
         },
             actions,
             remote.Size);
     }
     else if (local.LastWriteTimeUtc.ToFileTimeUtc() != remote.LastChange)
     {
         this.log.Debug(
             "{file} date: {local}, expected: {remote}",
             local.Name,
             local.LastWriteTimeUtc.ToFileTimeUtc(),
             remote.Size);
         await AddActionAsync(
             new Download(local, remote, addon, this.RepoRootUri, remote.LastChange)
         {
             Action =
                 $"date is different, local: {local.LastWriteTimeUtc.ToFileTimeUtc()}, remote: {remote.LastChange}"
         },
             actions,
             remote.Size);
     }
 }
Ejemplo n.º 19
0
        /// <see cref="EntityBehavior.UpdateState"/>
        public override void UpdateState(Entity entity)
        {
            Addon addon = (Addon)entity;

            /// Cancel the construction of the addon if its main building has been destroyed in the meantime.
            if (addon.Biometrics.IsUnderConstruction && addon.CurrentMainBuilding == null)
            {
                addon.Biometrics.CancelConstruct();
            }

            if (addon.CurrentMainBuilding != null)
            {
                /// If the addon has a main building, then synchronize their owners.
                Building mainBuilding = addon.CurrentMainBuilding;
                if (addon.Owner == null && mainBuilding.Owner != null)
                {
                    mainBuilding.Owner.AddAddon(addon);
                }
                else if (addon.Owner != null && mainBuilding.Owner == null)
                {
                    addon.Owner.RemoveAddon(addon);
                }
                else if (addon.Owner != null && mainBuilding.Owner != null && addon.Owner != mainBuilding.Owner)
                {
                    addon.Owner.RemoveAddon(addon);
                    mainBuilding.Owner.AddAddon(addon);
                }

                if (addon.ActiveProductionLine != null)
                {
                    this.hasProducedSinceOnline.Write(0x01);
                }
            }
            else
            {
                /// If the addon has no main building, then it has to be neutral.
                if (addon.Owner != null)
                {
                    addon.Owner.RemoveAddon(addon);
                }
                this.hasProducedSinceOnline.Write(0x00);
            }
        }
Ejemplo n.º 20
0
        internal static void Display(int windowId)
        {
            try
            {
                title = Localizer.Format("#autoLOC_LTech_Settings_001");

                Rect rect = new Rect(position.width - 20, 4, 18, 18);
                _label    = "x";
                _tooltip  = Localizer.Format("#autoLOC_LTech_Settings_tt_001");
                _guiLabel = new GUIContent(_label, _tooltip);
                if (GUI.Button(rect, _guiLabel))
                {
                    if (HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedSceneIsFlight)
                    {
                        Addon.OnToolbarButtonToggle();
                    }
                    else
                    {
                        showWindow = false;
                    }
                }

                GUILayout.BeginVertical();

                DisplaySettings();

                DisplayActions();

                GUILayout.EndVertical();

                GUI.DragWindow(new Rect(0, 0, Screen.width, 30));
                Addon.RepositionWindow(ref position);
            }
            catch (Exception ex)
            {
                if (!Addon.FrameErrTripped)
                {
                    Log.Error($"WindowSettings.Display. Error: {ex.Message}\r\n\r\n{ex.StackTrace}");
                    Addon.FrameErrTripped = true;
                }
            }
        }
Ejemplo n.º 21
0
        private void DrawAddonDebug()
        {
            ImGui.InputText("Addon name", ref this.inputAddonName, 256);
            ImGui.InputInt("Addon Index", ref this.inputAddonIndex);

            if (ImGui.Button("Get Addon"))
            {
                this.resultAddon =
                    this.dalamud.Framework.Gui.GetAddonByName(
                        this.inputAddonName, this.inputAddonIndex);
            }

            if (ImGui.Button("Find Agent"))
            {
                this.findAgentInterfacePtr = this.dalamud.Framework.Gui.FindAgentInterface(this.inputAddonName);
            }

            if (this.resultAddon != null)
            {
                ImGui.TextUnformatted(
                    $"{this.resultAddon.Name} - 0x{this.resultAddon.Address.ToInt64():x}\n    v:{this.resultAddon.Visible} x:{this.resultAddon.X} y:{this.resultAddon.Y} s:{this.resultAddon.Scale}, w:{this.resultAddon.Width}, h:{this.resultAddon.Height}");
            }

            if (this.findAgentInterfacePtr != IntPtr.Zero)
            {
                ImGui.TextUnformatted(
                    $"Agent: 0x{this.findAgentInterfacePtr.ToInt64():x}");
                ImGui.SameLine();

                if (ImGui.Button("C"))
                {
                    ImGui.SetClipboardText(this.findAgentInterfacePtr.ToInt64().ToString("x"));
                }
            }

            if (ImGui.Button("Get Base UI object"))
            {
                var addr = this.dalamud.Framework.Gui.GetBaseUIObject().ToInt64().ToString("x");
                Log.Information("{0}", addr);
                ImGui.SetClipboardText(addr);
            }
        }
Ejemplo n.º 22
0
        public static void LoadAddonWeapons()
        {
            try
            {
                string addonsPath = Path.Combine("scripts", Constants.AddonFolder);
                if (Directory.Exists(addonsPath))
                {
                    string[] files = Directory.GetFiles(addonsPath, "*.xml", SearchOption.TopDirectoryOnly);
                    foreach (string file in files)
                    {
                        try
                        {
                            Addon tempAddon = XmlUtil.Deserialize <Addon>(File.ReadAllText(file));

                            foreach (AddonWeapon weapon in tempAddon.Weapons)
                            {
                                Weapons.Add(
                                    (WeaponHash)Game.GenerateHash(weapon.WeaponName),

                                    new AllowedWeapon(
                                        weapon.DisplayName,
                                        weapon.SlotType,
                                        weapon.AvailableComponents,
                                        Tuple.Create(weapon.AttachmentPositionOffset, weapon.AttachmentRotationOffset)
                                        )
                                    );
                            }

                            Constants.LuxuryComponents.AddRange(tempAddon.LuxuryComponents.ConvertAll(c => Game.GenerateHash(c)));
                        }
                        catch (Exception e)
                        {
                            UI.Notify($"~r~SPGunLocker addon reading error: {e.Message} ({file})");
                        }
                    }
                }
            }
            catch (Exception e)
            {
                UI.Notify($"~r~SPGunLocker addon loading error: {e.Message}");
            }
        }
Ejemplo n.º 23
0
        public static async Task FolderToGame(Game game, StorageFolder folder)
        {
            var tocFile = await Task.Run(() => Toc.FolderToTocFile(folder));

            if (tocFile == null || tocFile.IsKnownSubFolder)
            {
                return;
            }
            var a = new Addon(game, tocFile.StorageFolder.Name, tocFile.StorageFolder.Path)
            {
                Version     = tocFile.Version,
                GameVersion = tocFile.GameVersion,
                Title       = tocFile.Title
            };

            game.Addons.Add(a);
            await Task.Delay(500);

            await FindProjectUrlAndDownLoadVersionsFor(a);
        }
Ejemplo n.º 24
0
        private async Task SearchByAddon()
        {
            var selectedItem = addonsComboBox.SelectedItem;

            if (selectedItem == null)
            {
                MessageBox.Show("Wybierz parametr z listy!", "Uwaga", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            Addon  selectedAddon = (Addon)selectedItem;
            int    addonNumber   = selectedAddon.Id;
            string addonContent  = addonTextbox.Text;

            var productsList = await ProductsManager.GetProductsByAddon(addonContent, addonNumber);

            ListWindow listWindow = new ListWindow(productsList);

            listWindow.Show();
        }
Ejemplo n.º 25
0
        public static Addon MakeAddon(DirectoryInfo path)
        {
            var a = new Addon
            {
                Name  = path.Name,
                Files =
                    path.GetFiles("*", SearchOption.AllDirectories)
                    .Select(
                        x =>
                        new File()
                {
                    Path       = x.FullName.Substring(path.FullName.Length),
                    LastChange = x.LastWriteTimeUtc.ToFileTimeUtc(),
                    Size       = x.Length
                })
                    .ToList()
            };

            return(a);
        }
Ejemplo n.º 26
0
    public void SetAddonInfo(int addonNum)
    {
        if (addons[addonNum].activeSelf)
        {
            addonInfo.SetActive(true);
            addonInfo.transform.position  = addonCell[addonNum].transform.position + new Vector3(0, 200, 0);
            addonInfo.transform.position += new Vector3(-addonInfo.transform.position.x + Mathf.Min(addonInfo.transform.position.x, 1650), 0, 0);

            Addon      currentAddon = inventoryManager.addonList[addonNum];
            GameObject tmpObj       = addonInfo.transform.Find("AddonPrefab").gameObject;
            tmpObj.GetComponent <Image>().sprite = addonFrameQuality[(int)currentAddon.type * 4 + (int)currentAddon.quality];
            tmpObj.transform.Find("Sprite").gameObject.GetComponent <Image>().sprite            = currentAddon.sprite;
            tmpObj.transform.Find("Sprite").gameObject.GetComponent <RectTransform>().sizeDelta = currentAddon.sizeInventory;
            tmpObj.SetActive(true);
            addonInfo.transform.Find("Quality").GetComponent <Text>().text     = qualityString[(int)currentAddon.quality];
            addonInfo.transform.Find("Name").GetComponent <Text>().text        = currentAddon.name;
            addonInfo.transform.Find("Description").GetComponent <Text>().text = typeString[(int)currentAddon.type];
            addonInfo.transform.Find("Info").GetComponent <Text>().text        = currentAddon.addonInfo;
        }
    }
Ejemplo n.º 27
0
        private static string GetTocFile(Addon addon)
        {
            var addonFolderPath = Path.Combine(Config.Instance.WowFolderPath, @"Interface\Addons");

            addonFolderPath = Path.Combine(addonFolderPath, addon.Name);

            var tocFile = Path.Combine(addonFolderPath, addon.Name + ".toc");

            if (!File.Exists(tocFile))
            {
                // Search Toc File
                foreach (var file in Directory.GetFiles(addonFolderPath, "*.toc"))
                {
                    tocFile = file;
                    break;
                }
            }

            return(tocFile);
        }
Ejemplo n.º 28
0
        internal static async Task AddSubFolders(Addon addon, List <string> subFoldersToDelete)
        {
            var addons = addon.Game.Addons;

            foreach (var name in subFoldersToDelete)
            {
                var subAddon = addons.FirstOrDefault(a => a.FolderName.Equals(name));
                if (subAddon != null)
                {
                    addons.Remove(subAddon);
                }
            }
            if (subFoldersToDelete.Count > 0)
            {
                Singleton <Session> .Instance.KnownSubFolders.UnionWith(subFoldersToDelete);

                addon.AddSubFolders(subFoldersToDelete);
            }
            await Task.CompletedTask;
        }
Ejemplo n.º 29
0
    public Item GetItemFromInventory(int index)
    {
        InventoryPair pair = inventory[index];

        switch (pair.itemType)
        {
        case ItemType.Addon:
            Addon addon = UnityEngine.Object.Instantiate((Addon)GameController.Instance.itemDatabase.GetItem(addonInventory[pair.id].baseItemName));
            addon.stats = addonInventory[pair.id];
            return(addon);

        case ItemType.Weapon:
            Weapon weapon = UnityEngine.Object.Instantiate((Weapon)GameController.Instance.itemDatabase.GetItem(weaponInventory[pair.id].stats.baseItemName));
            weapon.data = weaponInventory[pair.id];
            return(weapon);
        }

        Debug.LogError(string.Format("Can't receive items of type '{0}'. Returning empty Item instead.", pair.itemType));
        return(new Item());
    }
Ejemplo n.º 30
0
        public static async Task FindProjectUrlAndDownLoadVersionsFor(Addon addon)
        {
            if (addon.IsIgnored ||
                addon.Status.Equals(Addon.DOWNLOADING_VERSIONS) ||
                addon.Status.Equals(Addon.UPDATING))
            {
                return;
            }
            addon.Progress = 0;
            addon.Status   = Addon.DOWNLOADING_VERSIONS;

            if (string.IsNullOrEmpty(addon.ProjectUrl))
            {
                addon.ProjectUrl = await Task.Run(() => Version.FindProjectUrlFor(addon));
            }
            var downloadsToBeAdded = await Task.Run(() => Version.DownloadVersionsFor(addon));

            //Debug.WriteLine(downloadsToBeAdded.Count);
            addon.InsertNewDownloads(downloadsToBeAdded);
        }
Ejemplo n.º 31
0
        private Image RenderItem(bool selected, DrawItemEventArgs e)
        {
            Bitmap   flag = new Bitmap(Width, ItemHeight);
            Graphics g    = Graphics.FromImage(flag);

            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            g.SmoothingMode     = SmoothingMode.HighQuality;
            g.PixelOffsetMode   = PixelOffsetMode.HighQuality;

            g.Clear(Color.Black);

            if (selected)
            {
                g.Clear(SkinManager.GetCmsSelectedItemColor());
            }
            else
            {
                g.Clear(SkinManager.GetApplicationBackgroundColor());
            }

            if (!(Items[e.Index] is Addon))
            {
                g.DrawString("Error: The type of the item data is invalid", e.Font, Brushes.Black, new PointF(0, 0));
                return(flag);
            }

            Addon data = (Addon)Items[e.Index];

            const int margin = 4;

            string title = $"{data.name.ToUpper()}";

            Font title_font = SkinManager.GetFont(14);
            Size title_size = TextRenderer.MeasureText(title, title_font);

            g.DrawString(title, title_font, SkinManager.GetSecondaryTextBrush(), new PointF(margin, 0.5f * margin));
            g.DrawString($"({data.module})", SkinManager.GetFont(12), SkinManager.GetSecondaryTextBrush(), new PointF((margin * 2.25f) + title_size.Width, 1.1f * margin));
            g.DrawString($"{data.dependencies.Count} dependencies", SkinManager.GetFont(12), SkinManager.GetSecondaryTextBrush(), new PointF((0.75f * margin) + 4, 6.0f * margin));

            return(flag);
        }
Ejemplo n.º 32
0
        public void compileCoffee(Addon addon)
        {
            var coffeeScriptDir = Path.Combine(addon.contentPath, "panorama", "scripts", "coffeescript");

            if (!Directory.Exists(coffeeScriptDir))
            {
                /*MetroMessageBox.Show(mainForm,
                 *      coffeeScriptDir + " " + strings.DirectoryDoesntExistCaption,
                 *      strings.DirectoryDoesntExistMsg,
                 *      MessageBoxButtons.OK,
                 *      MessageBoxIcon.Error);*/
                return;
            }

            if (mainForm.cse == null)
            {
                mainForm.cse = new CoffeeSharp.CoffeeScriptEngine();
            }

            var coffeePaths = Directory.GetFiles(coffeeScriptDir, "*.coffee", SearchOption.AllDirectories);

            foreach (var coffeePath in coffeePaths)
            {
                string coffeeCode = File.ReadAllText(coffeePath, Util.GetEncoding(coffeePath));
                string js         = mainForm.cse.Compile(coffeeCode, true);

                string relativePath = coffeePath.Substring(coffeePath.IndexOf("coffeescript") + 13);

                var jsPath = Path.Combine(addon.contentPath, "panorama", "scripts", relativePath);
                jsPath = jsPath.Replace(".coffee", ".js");

                // ensure the dir housing the new js file exists.
                string foldPath = jsPath.Substring(0, jsPath.LastIndexOf('\\') + 1);
                if (!Directory.Exists(foldPath))
                {
                    Directory.CreateDirectory(foldPath);
                }

                File.WriteAllText(jsPath, js, Encoding.UTF8);
            }
        }
Ejemplo n.º 33
0
        public ActionResult Edit(int id, FormCollection collection, HttpPostedFileBase Avatar)
        {
            // Get the addon
            Addon addonPick = GameonRepository.GetAddon(id);

            try
            {
                // Get the current avatar for the game and save to a temp var
                //   do this because the update will wipe out the original avatar
                var reserveAvatar = addonPick.Avatar;
                UpdateModel(addonPick, "Addon");
                GameonRepository.Save();

                // Check for a new image and update the avatar (since it got wiped out b/c of the update)
                if (Avatar != null && Avatar.ContentLength > 0 && (Avatar.ContentType == "image/jpeg" || Avatar.ContentType == "image/png"))
                {
                    var fileName = Path.GetFileName(Avatar.FileName);
                    var path     = Path.Combine(Server.MapPath("~/Content/ImageUploads/Games"), fileName);
                    Avatar.SaveAs(path);
                    var NewAvatar = "/Content/ImageUploads/Games/" + fileName;
                    GameonRepository.UpdateAvatar(id, NewAvatar, "Addon");
                }
                else if (Avatar == null)
                {
                    GameonRepository.UpdateAvatar(id, reserveAvatar, "Addon");
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                // Something bad happened, so bring back the form
                var viewModel = new AddonManagerViewModel()
                {
                    Addon = addonPick,
                    Games = new SelectList(gmdb.Games.ToList(), "IDNumber", "Title", addonPick.GameID)
                };

                return(View(viewModel));
            }
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Selects ConsoleColor based on AddonProgress property value.
        /// </summary>
        /// <param name="a"></param>
        /// <returns></returns>
        public static ConsoleColor GetColor(Addon a)
        {
            switch (a.Progress)
            {
            case AddonProgress.Searching:
                return(ConsoleColor.DarkYellow);

            case AddonProgress.Downloading:
                return(ConsoleColor.Yellow);

            case AddonProgress.Extracting:
                return(ConsoleColor.DarkYellow);

            case AddonProgress.NotSupported:
            case AddonProgress.Error:
                return(ConsoleColor.Red);

            default:
                return(ConsoleColor.White);
            }
        }
Ejemplo n.º 35
0
        private static string GetLine(Addon addon, string contString)
        {
            var tocFile = GetTocFile(addon);

            if (tocFile == string.Empty || !File.Exists(tocFile))
            {
                return(string.Empty);
            }
            foreach (var line in File.ReadAllLines(tocFile))
            {
                if (line.Contains(contString))
                {
                    var dIndex = line.IndexOf(":");
                    if (dIndex > 0)
                    {
                        return(line.Substring(dIndex + 1).Trim());
                    }
                }
            }
            return(string.Empty);
        }
		public LibraryManagerForm(MainForm mainForm) {
			this.mainForm = mainForm;
			addon = mainForm.currAddon;

			InitializeComponent();
			this.Text = "Library Manager - " + addon.name;

			foreach (KeyValuePair<string, Addon.Library> kv in addon.libraries) {
				Addon.Library lib = kv.Value;
				object[] objs = new object[] {
					lib.local,
					lib.remote,
				};

				int rowNum = metroGrid1.Rows.Add(objs);
				lib.gridRow = rowNum;
				lib.grid = metroGrid1;

				lib.checkForUpdates();
			}

		}
Ejemplo n.º 37
0
        private void uploadButton_Click()
        {
            Addon addon = new Addon();
            string addonname = addonNameTextbox.Text;
            string addontype = Convert.ToString(addonTypeComboBox.SelectedItem);
            string[] addontags = addonTagsList.SelectedItems.Cast<string>().ToArray();
            string[] addonignores = { };

            // JSON
            addon.setJsonDetails(addonname, addontype, addontags, addonignores, addonpath);

            // OUTPUT
            if (addon.createJsonFile())
            {
                if (addon.createGmaFile())
                {
                    if (addon.setImagePath(addonimagepath))
                    {
                        addon.uploadToWorkshop();
                    }
                }
            }
        }
Ejemplo n.º 38
0
 static void Main(string[] args)
 {
     Addon a = new Addon();
     Loading.OnLoadingComplete += a.start;
 }
Ejemplo n.º 39
0
		public void compileCoffee(Addon addon) {
			var coffeeScriptDir = Path.Combine(addon.contentPath, "panorama", "scripts", "coffeescript");

			if (!Directory.Exists(coffeeScriptDir)) {
				/*MetroMessageBox.Show(mainForm,
					coffeeScriptDir + " " + strings.DirectoryDoesntExistCaption,
					strings.DirectoryDoesntExistMsg,
					MessageBoxButtons.OK,
					MessageBoxIcon.Error);*/
				return;
			}

			if (mainForm.cse == null) {
				mainForm.cse = new CoffeeSharp.CoffeeScriptEngine();
			}

			var coffeePaths = Directory.GetFiles(coffeeScriptDir, "*.coffee", SearchOption.AllDirectories);

			foreach (var coffeePath in coffeePaths) {
				string coffeeCode = File.ReadAllText(coffeePath, Util.GetEncoding(coffeePath));
				string js = mainForm.cse.Compile(coffeeCode, true);

				string relativePath = coffeePath.Substring(coffeePath.IndexOf("coffeescript") + 13);

				var jsPath = Path.Combine(addon.contentPath, "panorama", "scripts", relativePath);
				jsPath = jsPath.Replace(".coffee", ".js");

				// ensure the dir housing the new js file exists.
				string foldPath = jsPath.Substring(0, jsPath.LastIndexOf('\\') + 1);
				if (!Directory.Exists(foldPath)) {
					Directory.CreateDirectory(foldPath);
				}

				File.WriteAllText(jsPath, js, Encoding.UTF8);
			}
		}
Ejemplo n.º 40
0
 public void Delete(Addon addon)
 {
     AddonRepo.Remove(addon);
 }
Ejemplo n.º 41
0
		internal void setupCoffeeWatcher(Addon addon) {
			var path = Path.Combine(addon.contentPath, "panorama", "scripts", "coffeescript");
			if (addon.coffeeWatcher != null || !Directory.Exists(path)) { return; }

			FileSystemWatcher fsw = new FileSystemWatcher();
			addon.coffeeWatcher = fsw;
			//addon.npcWatchers.Add(dirName, fsw);
			fsw.IncludeSubdirectories = true;
			fsw.Path = path;
			fsw.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName;
			fsw.Filter = "*.js";
			fsw.EnableRaisingEvents = true;
			var lastUpdate = DateTime.Now;

			fsw.Changed += (s, e) => {
				compileCoffee(addon);
			};

			fsw.Created += (s, e) => {
				compileCoffee(addon);
			};

			fsw.Deleted += (s, e) => {
				compileCoffee(addon);
			};

			fsw.Renamed += (s, e) => {
				compileCoffee(addon);
			};
		}