public void ModNotExists() { var path = Path.Combine(_game.Directory.FullName, "Mods\\ModC"); Assert.ThrowsException <PetroglyphModException>(() => ModFactory.CreateMod(_game, ModType.Default, path, false)); }
//Some structure to hold collections of mods. And a way to access them public ModInventory() { //Allocate memory equipedMods = new Dictionary <ShipModEnum.ModType, ShipMod>(); availableMods = new Stack <ShipMod>(); equippedBuffs = new List <BuffMod>(); ModFactory factory = new ModFactory(); lootTable = new BuffLootTable(); //Build initial inventory of core system mods. ShipMod movementMod = factory.BuildMod(ShipModEnum.ModType.MovementCore); equipedMods.Add(movementMod.ShipModType, movementMod); ShipMod boostMod = factory.BuildMod(ShipModEnum.ModType.BoostCore); availableMods.Push(boostMod); ShipMod dodgeRollMod = factory.BuildMod(ShipModEnum.ModType.DodgeRollCore); availableMods.Push(dodgeRollMod); ShipMod shootMod = factory.BuildMod(ShipModEnum.ModType.ShooterCore); availableMods.Push(shootMod); Debug.Log("Available mods size: " + availableMods.Count); //Movement Mod must be enabled at start. highestUnlockedTier = 1; }
/// <summary> /// Initializes the module item if needed. /// </summary> private void InitModuleItem(ModuleItem moduleItem) { if (!moduleItem.IsInitialized) { moduleItem.IsInitialized = true; try { if (environment.ModuleViews.TryGetValue(moduleItem.FilePath, out ModView modView)) { moduleItem.Descr = CorrectItemDescr(modView.Descr); moduleItem.ModView = modView; } else if (File.Exists(moduleItem.FilePath)) { modView = ModFactory.GetModView(moduleItem.FilePath); modView.AppDirs = environment.AppDirs; moduleItem.Descr = CorrectItemDescr(modView.Descr); moduleItem.ModView = modView; environment.ModuleViews[moduleItem.FilePath] = modView; } else { moduleItem.Descr = string.Format(ServerShellPhrases.ModuleNotFound, moduleItem.FileName); moduleItem.ModView = null; } } catch (Exception ex) { moduleItem.Descr = ex.Message; moduleItem.ModView = null; } } }
public List <Result> Query(Query query) { querystr = query.Search; string[] querylist = querystr.Split(' '); querylist = QueryToLower(querylist); var results = new List <Result>(); switch (querylist.Length) { case 0: // 当没有输入任何内容的时候(仅输入了插件名di),返回全部模块的简介 results = DictToResultList(mods); break; case 1: // 当输入了模块名的时候,模糊匹配输入值,如果精确匹配到模块名,则输出对应模块的帮助信息. results = DictToResultList(GetMatchingItems(mods, querylist[0])); if (IsCompeteMatchingItems(mods, querylist[0])) { results.AddRange(DictToResultList(ModFactory.GetHelp(querylist[0]))); } break; case 2: // 当输入模块名与对应模块的参数的时候,模糊匹配参数值,如果精确匹配到参数值,输出历史记录. var helpdict = ModFactory.GetHelp(querylist[0]); results = DictToResultList(GetMatchingItems(helpdict, querylist[1])); if (IsCompeteMatchingItems(helpdict, querylist[1])) { var loginfos = db.ReadLog(querylist[0], querylist[1]); foreach (var loginfo in loginfos) { results.AddRange(DictToResultList(new Dictionary <string, string>() { { loginfo.output, loginfo.input } }, loginfo.score, "log")); } } break; case 3: default: //当输入了模块名与对应模块的参数以及带处理字符串的时候,输出对应待处理字符串的处理结果,并且模糊匹配待处理字符串输出历史记录 string[] querylist2 = JoinQuery(querylist); results = DictToResultList(ModFactory.RunMod(querylist2[0], querylist2), action: "log"); // error = ModFactory.RunMod(querylist2[0], querylist2).Count().ToString(); var loginfoswithinput = db.ReadLog(querylist2[0].ToLower(), querylist2[1], querylist2[2]); foreach (var loginfo in loginfoswithinput) { results.AddRange(DictToResultList(new Dictionary <string, string>() { { loginfo.output, loginfo.input } }, loginfo.score, "log")); } break; } // results.Add(new Result() { Title = error }); return(results); }
private void UpdateGue() { // Confirmation UpdateWindow updateWindow = new UpdateWindow(_localVersion, _remoteLatestVersion, _remoteUpdateList) { Owner = this }; updateWindow.ShowDialog(); if (!updateWindow.IsOK) { return; } if (IsGameRunning()) { CustomMessageBox.Show(this, string.Format("Mise à jour impossible : le jeu est en cours d'exécution.{0}{0}Quitte d'abord le jeu (si nécessaire via Gestionnaire des tâches => fin de tâche sur game.dat)", Environment.NewLine), "Mise à jour", MessageBoxButton.OK, MessageBoxImage.Error); return; } // Basculement sur le mod Original + pas de map pack ModFactory.AllGamesBackToOriginal(); ModFactory.AllGamesNoMapPack(); // On "se souvient" Properties.Settings.Default["JustUpdated"] = true; Properties.Settings.Default.Save(); // On copie l'exécutable dans un dossier temporaire pour l'exécuter depuis là (sinon on ne pourrait pas mettre à jour l'installeur) string tempFolderPath = Path.GetTempPath(); string executablePath = _pathToExe + "\\Setup.exe"; string tempPath = Path.GetTempPath() + Path.GetFileName(executablePath); if (File.Exists(tempPath)) { try { File.Delete(tempPath); } catch { CustomMessageBox.Show(this, "Impossible de générer le fichier temporaire", "Mise à jour annulée", MessageBoxButton.OK, MessageBoxImage.Error); return; } } File.Copy(executablePath, tempPath); Process process = new Process(); process.StartInfo.FileName = tempPath; process.StartInfo.Arguments = "-maj " + Process.GetCurrentProcess().Id.ToString(); process.Start(); // Quitter Close(); }
public void ModCreation() { var path = Path.Combine(_game.Directory.FullName, "Mods\\ModA"); var mod = ModFactory.CreateMod(_game, ModType.Default, path, false); Assert.IsNotNull(mod); Assert.AreEqual(ModType.Default, mod.Type); Assert.IsInstanceOfType(mod, typeof(Mod)); Assert.AreEqual(path, ((Mod)mod).Directory.FullName); }
/// <summary> /// Gets the user interface of the driver. /// </summary> public ModView GetModuleView(string dllPath) { if (!moduleViews.TryGetValue(dllPath, out ModView modView)) { modView = ModFactory.GetModView(dllPath); modView.AppDirs = AppDirs; moduleViews[dllPath] = modView; } return(modView); }
private void Items_CurrentChanging(object sender, System.ComponentModel.CurrentChangingEventArgs e) { // Annuler l'événement si nécessaire if (!this.IsLoaded || tabControl.SelectedIndex < 0 || _tabState == TabStateEnum.Change1) { if (e.IsCancelable) { e.Cancel = true; } return; } // 2ème étape du changement if (_tabState == TabStateEnum.Change2) { _tabState = TabStateEnum.Normal; return; } // Se souvenir de l'onglet sélectionner et annuler l'action (elle sera refaite manuellement après animation) int previousIndex = tabControl.SelectedIndex; if (e.IsCancelable) { e.Cancel = true; } // Démarrer l'animation de sortie ModFactory.ChangeTabAnimation(_currentGameName, 0); // Mettre à jour le statut _tabState = TabStateEnum.Change1; // Attendre la fin de l'animation Task.Factory.StartNew(() => { Thread.Sleep(Convert.ToInt32(CHANGE_TAB_ANIMATION_DURATION_IN_SECONDS * 1000)); }).ContinueWith(antecedent => { // Stuff pour que l'animation fonctionne tabControl.SelectedIndex = -1; _tabState = TabStateEnum.Change2; tabControl.SelectedIndex = previousIndex; // Prendre note du changement de jeu _currentGameName = ((TabItem)tabControl.Items.GetItemAt(tabControl.SelectedIndex)).Name; // Afficher et lancer l'animation ModFactory.Refresh(_currentGameName, true); ModFactory.ChangeTabAnimation(_currentGameName, 1); }, _uiScheduler); }
protected IEnumerable <IMod> SearchDiskMods() { var modsDir = Directory.GetDirectories("Mods").FirstOrDefault(); if (modsDir is null || !modsDir.Exists) { return(Enumerable.Empty <IMod>()); } var modFolders = modsDir.EnumerateDirectories() .Where(x => !x.Attributes.HasFlag(FileAttributes.Hidden)).ToList(); return(modFolders.SelectMany(folder => ModFactory.CreateModAndVariants(this, ModType.Default, folder, true))); }
public void CreateGame() { _game = new Foc(new DirectoryInfo(Path.Combine(TestScenariosPath, "FiveMods")), GameType.Disk); _modA = ModFactory.CreateMod(_game, ModType.Default, Path.Combine(_game.Directory.FullName, "Mods\\ModA"), false); _modB = ModFactory.CreateMod(_game, ModType.Default, Path.Combine(_game.Directory.FullName, "Mods\\ModB"), false); _modC = ModFactory.CreateMod(_game, ModType.Default, Path.Combine(_game.Directory.FullName, "Mods\\ModC"), false); _modD = ModFactory.CreateMod(_game, ModType.Default, Path.Combine(_game.Directory.FullName, "Mods\\ModD"), false); _modE = ModFactory.CreateMod(_game, ModType.Default, Path.Combine(_game.Directory.FullName, "Mods\\ModE"), false); _game.AddMod(_modA); _game.AddMod(_modB); _game.AddMod(_modC); _game.AddMod(_modD); _game.AddMod(_modE); }
private void buttonOK_Click(object sender, RoutedEventArgs e) { // Resolution if (_resolutionGeneralsChanged) { string[] resolution = ((ComboBoxItem)comboBoxGenerals.SelectedItem).Content.ToString().Split('x'); IniHelper.LineChanger(string.Format("Resolution = {0} {1}", resolution[0], resolution[1]), _pathToOptionIniGenerals, _optionIniResolutionGenerals.ResolutionNoLigne); } if (_resolutionHeureHChanged) { string[] resolution = ((ComboBoxItem)comboBoxHeureH.SelectedItem).Content.ToString().Split('x'); IniHelper.LineChanger(string.Format("Resolution = {0} {1}", resolution[0], resolution[1]), _pathToOptionIniHeureH, _optionIniResolutionHeureH.ResolutionNoLigne); } // Scroll if (_scrollChanged) { IniHelper.LineChanger(String.Format("ScrollFactor = {0}", sliderScrollFactor.Value), _pathToOptionIniGenerals, _optionIniResolutionGenerals.ScrollFactorNoLigne); IniHelper.LineChanger(String.Format("ScrollFactor = {0}", sliderScrollFactor.Value), _pathToOptionIniHeureH, _optionIniResolutionHeureH.ScrollFactorNoLigne); } // Settings int newCameraHeight = (int)sliderCameraHeight.Value; double newCameraSpeed = Math.Round(sliderCameraSpeed.Value / 100, 1); bool gregWareFullscreen = (bool)radioButtonFullscreenModeGregware.IsChecked; bool scrollWasd = (bool)checkBoxMiscScrollWasd.IsChecked; Properties.Settings.Default["ZoomMaxCameraHeight"] = newCameraHeight; Properties.Settings.Default["ZoomCameraAdjustSpeed"] = newCameraSpeed; Properties.Settings.Default["FullscreenModeGregware"] = gregWareFullscreen; Properties.Settings.Default["ScrollGregware"] = scrollWasd; Properties.Settings.Default.Save(); // Camera if (newCameraHeight != _zoomCameraHeightInitialValue || newCameraSpeed != _zoomCameraSpeedInitialValue) { ModFactory.AllGamesRefreshForceZoom(); } // Fullscreen mode if (gregWareFullscreen != _fullScreenModeGregwareInitialValue) { ModFactory.AllGamesRefreshFullscreenMode(); } // Fermer la fenêtre Close(); }
private void settingsCleanMaps_Click(object sender, RoutedEventArgs e) { if (CustomMessageBox.Show(this, string.Format("Tu es sur le point de supprimer toutes les maps ajoutées manuellement ou téléchargées depuis le jeu. Continuer ?", Environment.NewLine), "Nettoyage des maps", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes) { return; } if (IsGameRunning()) { CustomMessageBox.Show(this, string.Format("Nettoyage des maps impossible : le jeu est en cours d'exécution.{0}{0}Quitte d'abord le jeu (si nécessaire via Gestionnaire des tâches => fin de tâche sur game.dat)", Environment.NewLine), "Nettoyage des maps", MessageBoxButton.OK, MessageBoxImage.Error); return; } // Se placer sur aucun MapPack ModFactory.AllGamesNoMapPack(); // Supprimer les maps restantes try { foreach (string path in Directory.GetDirectories(_pathToMapsGenerals)) { DirectoryInfo di = new DirectoryInfo(path); ModFactory.SetAttributesNormal(di); di.Delete(true); } foreach (string path in Directory.GetDirectories(_pathToMapsZeroHour)) { DirectoryInfo di = new DirectoryInfo(path); ModFactory.SetAttributesNormal(di); di.Delete(true); } CustomMessageBox.Show(this, "Maps nettoyées avec succès :-)", "Nettoyage des maps", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { CustomMessageBox.Show(this, string.Format("Erreur lors de la suppression des maps.{0}{0}{1}", Environment.NewLine, ex.Message), "Nettoyage des maps", MessageBoxButton.OK, MessageBoxImage.Error); } }
private IEnumerable <IMod> SearchSteamMods() { var mods = new List <IMod>(); mods.AddRange(SearchDiskMods()); var workshopsPath = FileUtilities.NormalizePath(Path.Combine(Directory.FullName, @"..\..\..\workshop\content\32470\")); var workshopsDir = new DirectoryInfo(workshopsPath); if (!workshopsDir.Exists) { return(mods); } var modDirs = workshopsDir.EnumerateDirectories(); var workshopMods = modDirs.SelectMany(folder => ModFactory.CreateModAndVariants(this, ModType.Workshops, folder, true)); mods.AddRange(workshopMods); return(mods); }
/* * For use when player levels up and all core systems are unlocked. * Generates 3 random buff mods to be returned to the UI for user selection. */ public List <BuffMod> GenerateBuffOptions(int currentTier)//pass buff Loot table? //Randomness? { Debug.Log("Generating some buffs"); ModFactory factory = new ModFactory(); List <BuffMod> choices = new List <BuffMod>(); BuffMod mod1 = lootTable.RollBuff(); Debug.Log(mod1); choices.Add(mod1); BuffMod mod2 = lootTable.RollBuff(); Debug.Log(mod2); choices.Add(mod2); BuffMod mod3 = lootTable.RollBuff(); Debug.Log(mod3); choices.Add(mod3); return(choices); }
private void buttonLaunchGame_Click(object sender, RoutedEventArgs e) { if (Properties.Settings.Default.ChangingGeneralsMod || Properties.Settings.Default.ChangingHeureHMod || canvasLoading.Visibility == Visibility.Visible) { return; } if (IsGameRunning()) { return; } // Désactiver la form DesactiverWindow(); // Créer un thread pour éviter les problèmes UI Task.Factory.StartNew(() => { // Execute game string gameExePath = ModFactory.GetGameExecutable(_currentGameName); Process gameProcess = Process.Start(gameExePath); }); }
private void MetroWindow_Loaded(object sender, RoutedEventArgs e) { DataContext = this; // Faire la collection pour le tab TabItem tabItemGenerals = new TabItem { Header = "GENERALS", Name = "Generals" }; ScrollViewer svGenerals = new ScrollViewer { Name = "svGenerals", HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(0, 0, 0, 0), VerticalScrollBarVisibility = ScrollBarVisibility.Auto }; tabItemGenerals.Content = svGenerals; Grid gridGenerals = new Grid { Name = "gridButtonsGenerals" }; svGenerals.Content = gridGenerals; TabItem tabItemHeureH = new TabItem { Header = "HEURE H", Name = "HeureH" }; ScrollViewer svHeureH = new ScrollViewer { Name = "svHeureH", HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(0, 0, 0, 0), VerticalScrollBarVisibility = ScrollBarVisibility.Auto }; tabItemHeureH.Content = svHeureH; Grid gridHeureH = new Grid { Name = "gridButtonsHeureH" }; svHeureH.Content = gridHeureH; TabItems = new List <TabItem>(); TabItems.Add(tabItemGenerals); TabItems.Add(tabItemHeureH); TabItemsCollectionView = new ListCollectionView(TabItems); // Load mods _currentGameName = "HeureH"; ModFactory.Init(this, new List <string> { "Generals", "HeureH" }, new List <string> { _pathToMapsGenerals, _pathToMapsZeroHour }, _pathToExe, _uiScheduler, new List <Grid> { gridGenerals, gridHeureH }, new List <double> { Convert.ToInt32(_currentGameName.Equals("Generals")), Convert.ToInt32(_currentGameName.Equals("HeureH")) }, new List <ComboBox> { comboBoxMapsGenerals, comboBoxMapsHeureH }, new List <CheckBox> { checkBoxGentoolGenerals, checkBoxGentoolHeureH }, new List <CheckBox> { checkBoxForceZoomGenerals, checkBoxForceZoomHeureH }); // Evenements sur changement de tab tabControl.SelectionChanged += tabControl_SelectionChanged; // Sélectionner le bon jeu tabControl.SelectedIndex = 1; // Réappliquer les sélection après update if ((bool)Properties.Settings.Default["JustUpdated"]) { ModFactory.AllGamesRefreshForceZoom(); ModFactory.AllGamesRefreshFullscreenMode(); ModFactory.AllGamesRefreshGentool(); Properties.Settings.Default["JustUpdated"] = false; Properties.Settings.Default.Save(); } // Démarrer l'affichage ModFactory.Refresh(_currentGameName); // Démarrer le détecteur de lancement MonitorGameRunning(); }
public void Init(PluginInitContext context) { this.mods = ModFactory.GetModsDesc(); this.db = new DataBase(context.CurrentPluginMetadata.PluginDirectory); }