public async Task <ModViewModel?> GetAsync(uint gameId, uint modId, CancellationToken ct = default) { var gameDomain = (await _nexusModsGameQueries.GetAsync(gameId, ct))?.DomainName ?? "ERROR"; var key = $"mod({gameId}, {modId})"; if (!_cache.TryGetValue(key, _jsonSerializer, out ModViewModel? cacheEntry)) { var response = await _httpClientFactory.CreateClient("NexusMods.API").GetAsync( $"v1/games/{gameDomain}/mods/{modId}.json", HttpCompletionOption.ResponseHeadersRead, ct); if (response.IsSuccessStatusCode && response.StatusCode != HttpStatusCode.NoContent) { var content = await response.Content.ReadAsStreamAsync(ct); var mod = await _jsonSerializer.DeserializeAsync <ModDTO?>(content, ct); if (mod is not null) { cacheEntry = new ModViewModel((uint)mod.ModId, mod.Name); var cacheEntryOptions = new DistributedCacheEntryOptions().SetSize(1).SetAbsoluteExpiration(TimeSpan.FromHours(8)); await _cache.SetAsync(key, cacheEntry, cacheEntryOptions, _jsonSerializer, ct); } } } return(cacheEntry); }
public void LoadFromMod(ModViewModel mod) { settingInternally = true; try { tbxAbsolute.Text = mod.Absolute.ToString(); //lbAddModifier.SelectedValue = entry.ModAddAbilityModifier.Value; lbConditions.SelectedValue = mod.ModConditions.Value; CheckEnumList.SetValue(lbDamageEdit.ItemsSource, mod.DamageTypeFilter.DamageType.Value); CheckEnumList.SetValue(lbConditions.ItemsSource, mod.ModConditions.Value); RadioEnumList.SetValue(lbAttackFilter.ItemsSource, mod.DamageTypeFilter.AttackKind.Value); RadioEnumList.SetValue(lbAddModifier.ItemsSource, mod.ModAddAbilityModifier.Value); RadioEnumList.SetValue(lbModType.ItemsSource, mod.ModType.Value); lbModType.SelectedValue = mod.ModType.Value; tbxMultiplier.Text = mod.Multiplier.ToString(); tbxOffset.Text = mod.Offset.ToString(); txbModifierLimit.Text = mod.ModifierLimit.ToString(); tmRepeats.TimeMeasure = mod.Repeats.TimeMeasure; tmRepeats.Amount = mod.Repeats.Count; ckRequiresConsumed.IsChecked = mod.RequiresConsumption; ckRequiresEquipped.IsChecked = mod.RequiresEquipped; SelectCombo(cbTargetName, mod.TargetName); SelectCombo(cbVantageSkillFilter, mod.VantageSkillFilter); ckbAddsAdvantage.IsChecked = mod.AddsAdvantage; ckbAddsDisadvantage.IsChecked = mod.AddsDisadvantage; } finally { settingInternally = false; } }
public IActionResult Details(string Id) { var mod = this.modService.GetById(Id); var user = this.userService.GetUserByName(this.User.Identity.Name); bool voted = false; if (mod == null) { return(this.View("MissingMod")); } if (user != null) { voted = this.voteService.CheckIfVoted(mod.Id, user.Id); } var model = new ModViewModel { Id = mod.Id, Name = mod.Name, CreatedOn = mod.CreatedOn, Version = mod.Version, Description = mod.Description, MainPicturePath = mod.MainPicturePath, Views = mod.Views, VoteCount = mod.VoteCount, TotalDownloadCount = mod.TotalDownloadCount, Visible = mod.Visible, Voted = voted, UserName = mod.User.UserName, UserId = mod.UserId, GameId = mod.GameId, Game = mod.Game.Name, Pictures = mod.Pictures.Select(x => x.FilePath).ToList(), }; model.Comments = mod.Comments.Select(x => new CommentsViewModel { Id = x.Id, Content = x.Content, CreatedOn = x.CreatedOn, UserId = x.UserId, UserName = x.User.UserName, ModId = x.ModId, }).OrderByDescending(x => x.CreatedOn).ToList(); model.Files = mod.Files.Select(x => new FileViewModel { Id = x.Id, Name = x.Name, Description = x.Description, FileSize = x.FileSize, FilePath = x.FilePath, Status = x.Status, DownlaodCount = x.DownlaodCount, ModId = x.ModId, }).ToList(); this.modService.ViewUp(mod.Id); return(this.View(model)); }
public ModViewModel GetModById(int id) { Mod mod = _modRepo.GetById(id); ModViewModel mappedMod = _mapper.Map <ModViewModel>(mod); return(mappedMod); }
public ModViewModel GetModByTitle(string title) { Mod mod = _modRepo.GetAll().SingleOrDefault(m => m.Title.ToLower() == title.ToLower()); ModViewModel mappedMod = _mapper.Map <ModViewModel>(mod); return(mappedMod); }
public void TestExistingListLoad() { ItemViewModel breastplate = TestStorageHelper.GetExistingItem("Breastplate"); Assert.IsNotNull(breastplate); Assert.IsFalse(breastplate.consumable); Assert.AreEqual(400, breastplate.costValue); Assert.AreEqual(5, breastplate.equipTime.Count); Assert.AreEqual(TimeMeasure.minutes, breastplate.equipTime.TimeMeasure); Assert.AreEqual(1, breastplate.unequipTime.Count); Assert.AreEqual(TimeMeasure.minutes, breastplate.unequipTime.TimeMeasure); Assert.AreEqual(15, breastplate.minStrengthToCarry); ModViewModel modViewModel = breastplate.FindMod("AC 15+Dex"); Assert.IsNotNull(modViewModel); Assert.AreEqual(15, modViewModel.Absolute); Assert.AreEqual(ModType.playerProperty, (ModType)modViewModel.ModType.Value); Assert.AreEqual(0, modViewModel.Offset); Assert.AreEqual(1, modViewModel.Multiplier); Assert.AreEqual(Ability.dexterity, modViewModel.AddAbilityModifier); Assert.AreEqual(2, modViewModel.ModifierLimit); Assert.AreEqual("ArmorClass", modViewModel.TargetName); Assert.IsTrue(modViewModel.RequiresEquipped); Assert.IsFalse(modViewModel.RequiresConsumption); Assert.IsFalse(modViewModel.AddsAdvantage); Assert.IsFalse(modViewModel.AddsDisadvantage); Assert.AreEqual(DamageType.None, (DamageType)Convert.ToInt32(modViewModel.DamageTypeFilter.DamageType.Value)); Assert.AreEqual(AttackKind.Any, (AttackKind)Convert.ToInt32(modViewModel.DamageTypeFilter.AttackKind.Value)); }
public void Update() { foreach (ListViewItem li in Mods) { ModViewModel mv = (ModViewModel)li.DataContext; mv.Update(); } }
public IActionResult EditMod(ModViewModel mod) { _modService.UpdateMod(mod); var mods = _modService.GetAllMods(); var users = _userService.GetAllUsers(); ViewData["Users"] = users; return(View("ListMods", mods)); }
public AuxiliariesRootViewModel( ModViewModel modVM, ResourcePackViewModel resourcePackVM, ShaderPackViewModel shaderPackVM) { ModVM = modVM; ResourcePackVM = resourcePackVM; ShaderPackVM = shaderPackVM; }
public AuxiliariesRootViewModel( ModViewModel modVM, ResourcePackViewModel resourcePackVM, SkinViewModel skinVM) { ModVM = modVM; ResourcePackVM = resourcePackVM; SkinVM = skinVM; }
public Mod GetMod(string ModID) { RestRequest request = new RestRequest("/mod/" + ModID, Method.GET); var respMod = GetClient().Execute(request); ModViewModel mod = JsonConvert.DeserializeObject <ModViewModel>(respMod.Content); GetModInfo(mod.Data); return(mod.Data); }
public IActionResult GetModById(int modId) { ModViewModel mod = _modService.GetModById(modId); if (mod != null) { var user = _userService.GetAllUsers().SingleOrDefault(u => u.Id == mod.UserId); ViewData["Creator"] = user; return(View("Details", mod)); } return(View("Error")); }
public IActionResult EditMod(int modId) { ModViewModel mod = _modService.GetModById(modId); UserViewModel creator = _userService.GetAllUsers().SingleOrDefault(u => u.Id == mod.UserId); if (User.Identity.Name != creator.UserName) { return(View("Error")); } ViewData["Creator"] = creator; return(View(mod)); }
private void Window_Loaded(object sender, RoutedEventArgs e) { ModViewModels = new ObservableCollection <ModViewModel> { new ModViewModel(27962, "Timer", "Display your in-game time on the screen.", "Display your setup time at the top right of the screen during gameplay. Can be toggled off in the gameplay menu.", false, false, @"images\placeholder.png", UriKind.Relative), new ModViewModel(86687, "Remove Quickload Restriction", "Quickload any old quicksave.", "Lets you quickload any previously made quicksave. Make a copy of Documents/Teardown/quicksave.bin and rename it back later, to make multiple saves.", false, false, @"images\placeholder.png", UriKind.Relative, "Only quickload on the same map as you made the quicksave on."), new ModViewModel(19648, "Menubutton Protection", "Dangerous menubuttons need to be double pressed.", "The gameplay menubuttons: restart, abandon and quickload have to be pressed twice to activate.", false, false, @"images\placeholder.png", UriKind.Relative), new ModViewModel(15513, "Menubutton Protection Advanced", "Confirm window for dangerous menubuttons.", "A Confirm window for the gameplay menubuttons: restart, abandon and quickload. Can be toggled off untill the next start of the game.", false, false, @"images\placeholder.png", UriKind.Relative), new ModViewModel(03666, "Speedometer", "Display your velocity on the screen.", "Display your total velocity at the top left of the screen during gameplay.", true, false, @"images\placeholder.png", UriKind.Relative), new ModViewModel(88059, "Speedometer Advanced", "Display all your velocity parameters on the screen.", "Display your x, y, z and total velocity at the top left of the screen during gameplay.", true, false, @"images\placeholder.png", UriKind.Relative), new ModViewModel(53521, "Remove Startscreens", "Remove the startscreens when launching the game.", "Remove the logo and warning message when launching the game.", false, false, @"images\placeholder.png", UriKind.Relative), new ModViewModel(36909, "Decrease Render Scale Slider", "Decrease the minimum value of the Render Scale slider.", "Decrease the minimum value of the Render Scale slider in the option menu to 25%.", false, false, @"images\placeholder.png", UriKind.Relative), new ModViewModel(81936, "Increase FOV Slider", "Increase the maximum value of the FOV slider.", "Increase the maximum value of the FOV slider in the option menu to 130.", true, false, @"images\placeholder.png", UriKind.Relative), }; Details = ModViewModels[0]; ModListBox.ItemsSource = ModViewModels; ModListBox.SelectedItem = Details; DetailsContentControl.Content = Details; }
public void SetMod(ModViewModel model) { CurrentModViewModel = model; if (model != null) { SelectedMod.Visibility = Visibility.Visible; NoModSelected.Visibility = Visibility.Collapsed; SelectedMod.DataContext = model; } else { SelectedMod.Visibility = Visibility.Collapsed; NoModSelected.Visibility = Visibility.Visible; SelectedMod.DataContext = null; } }
private void StartGame(object sender, RoutedEventArgs e) { List <Data.Mod> mods = new List <Data.Mod>(); foreach (ListViewItem i in Mods.Mods) { ModViewModel vm = (ModViewModel)i.DataContext; if (vm != null && vm.Selected) { ModVersionViewModel vm2 = (ModVersionViewModel)vm.SelectedVersion.DataContext; if (vm2 != null) { mods.Add(vm2.mod); } } } ProgressHandler progressHandler = new ProgressHandler(); progressHandler.OnComplete += (object o, EventArgs ex) => { if (Configuration.GetString("UseSteam") == "true" && App.Game.GameConfiguration.SteamAppID != "") { Process p = new Process(); p.StartInfo.FileName = Configuration.GetPath("Steam") + System.IO.Path.DirectorySeparatorChar + "Steam.exe"; p.StartInfo.Arguments = "-applaunch " + App.Game.GameConfiguration.SteamAppID; p.Start(); } else { Process p = new Process(); p.StartInfo.FileName = App.Game.GamePath + System.IO.Path.DirectorySeparatorChar + App.Game.GameConfiguration.SelectFile; p.Start(); } }; Thread thread = new Thread(delegate() { App.Game.ApplyMods(mods, progressHandler); }); ModAPI.Windows.SubWindows.OperationPending window = new ModAPI.Windows.SubWindows.OperationPending("Lang.Windows.OperationPending", "ApplyMods", progressHandler, null, true); if (!window.Completed) { window.ShowSubWindow(); window.Show(); } thread.Start(); }
public IActionResult DeleteMod(int modId) { var mods = _modService.GetAllMods(); var users = _userService.GetAllUsers(); ModViewModel mod = mods.SingleOrDefault(m => m.Id == modId); UserViewModel creator = users.SingleOrDefault(u => u.Id == mod.UserId); if (User.Identity.Name != creator.UserName && !User.IsInRole("admin")) { return(View("Error")); } _modService.RemoveMod(modId); mods = _modService.GetAllMods(); ViewData["Users"] = users; return(View("ListMods", mods)); }
public IActionResult GiveOrRemoveCacoward(ModViewModel mod) { if (mod.HasCacoward) { mod.HasCacoward = false; } else if (!mod.HasCacoward) { mod.HasCacoward = true; } _modService.UpdateMod(mod); var mods = _modService.GetAllMods(); var users = _userService.GetAllUsers(); ViewData["Users"] = users; return(View("ListMods", mods)); }
public void SelectNewestVersions() { foreach (ListViewItem item in _Mods) { ModViewModel vm = (ModViewModel)item.DataContext; List <int> v = vm.versions.Keys.ToList(); v.Sort(); v.Reverse(); foreach (ListViewItem li in vm.Versions) { ModVersionViewModel versionModel = (ModVersionViewModel)li.DataContext; if (Mod.Header.ParseModVersion(versionModel.mod.header.GetVersion()) == v[0]) { vm.SelectedVersion = li; break; } } } _SelectNewestModVersions = false; }
public IActionResult GetModByTitle(string title) { if (title != null && title.Trim() != "") { var users = _userService.GetAllUsers(); List <ModViewModel> mods = new List <ModViewModel>(); ModViewModel mod = _modService.GetModByTitle(title); if (mod != null) { mods.Add(mod); ViewData["Users"] = users; return(View("ListMods", mods)); } else { return(View("ModNotFound")); } } return(View("Error")); }
public void SaveToMod(ModViewModel mod, string propertyName) { if (settingInternally) { return; } mod.Absolute = MathUtils.GetDouble(tbxAbsolute.Text); mod.AddsAdvantage = ckbAddsAdvantage.IsChecked ?? false; mod.AddsDisadvantage = ckbAddsDisadvantage.IsChecked ?? false; mod.ModifierLimit = MathUtils.GetInt(txbModifierLimit.Text); mod.Multiplier = MathUtils.GetDouble(tbxMultiplier.Text, 1); //mod.Name = vm.Name; mod.Offset = MathUtils.GetDouble(tbxOffset.Text); mod.Repeats = new DndTimeSpan(tmRepeats.TimeMeasure, (int)tmRepeats.Amount); mod.RequiresConsumption = ckRequiresConsumed.IsChecked == true; mod.RequiresEquipped = ckRequiresEquipped.IsChecked == true; mod.DamageTypeFilter.AttackKind.Value = RadioEnumList.CalcValue(lbAttackFilter.ItemsSource, typeof(AttackType)); mod.AddAbilityModifier = (Ability)RadioEnumList.CalcValue(lbAddModifier.ItemsSource, typeof(Ability)); mod.DamageTypeFilter.DamageType.Value = CheckEnumList.CalcValue(lbDamageEdit.ItemsSource, typeof(DamageType)); mod.ModConditions.Value = CheckEnumList.CalcValue(lbConditions.ItemsSource, typeof(Conditions)); if (cbTargetName.SelectedValue != null) { mod.TargetName = cbTargetName.SelectedValue.ToString(); } else { mod.TargetName = string.Empty; } mod.ModType.Value = RadioEnumList.CalcValue(lbModType.ItemsSource, typeof(ModType));; if (cbVantageSkillFilter.SelectedValue != null) { mod.VantageSkillFilter = (Skills)cbVantageSkillFilter.SelectedValue; } else { mod.VantageSkillFilter = Skills.none; } }
private void BtnTest_Click(object sender, RoutedEventArgs e) { ModViewModel modViewModel = (ModViewModel)TryFindResource("vm"); if ((ModType)modViewModel.ModType.Value == ModType.condition) { modViewModel.ModType.Value = ModType.incomingAttack; } else { modViewModel.ModType.Value = ModType.condition; } if ((Conditions)modViewModel.ModConditions.Value == Conditions.Charmed) { modViewModel.ModConditions.Value = Conditions.Invisible; } else { modViewModel.ModConditions.Value = Conditions.Charmed; } modViewModel.RequiresConsumption = !modViewModel.RequiresConsumption; }
protected void FindMods() { try { if (Loading) { return; } string path = System.IO.Path.GetFullPath(Configuration.GetPath("mods") + System.IO.Path.DirectorySeparatorChar + App.Game.GameConfiguration.ID); if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } string[] Keys = LoadedFiles.Keys.ToArray(); for (int i = 0; i < Keys.Length; i++) { string file = Keys[i]; if (!System.IO.File.Exists(file)) { Mod mod = LoadedFiles[file]; string id = LoadedFiles[file].ID + "-" + LoadedFiles[file].header.GetVersion(); Mod.Mods.Remove(id); for (int j = 0; j < _Mods.Count; j++) { ModViewModel vm = (ModViewModel)_Mods[j].DataContext; if (vm.versions.Values.Contains(mod)) { vm.versions.Remove(Mod.Header.ParseModVersion(mod.header.GetVersion())); if (vm.versions.Count == 0) { _Mods.RemoveAt(j); } break; } } LoadedFiles.Remove(file); } } string[] files = System.IO.Directory.GetFiles(path); List <string> ToLoad = new List <string>(); foreach (string file in files) { string fileName = System.IO.Path.GetFileName(file); if (!LoadedFiles.ContainsKey(file) && validation.IsMatch(fileName)) { ToLoad.Add(file); } } if (ToLoad.Count > 0) { Loading = true; ProgressHandler progressHandler = new ProgressHandler(); Thread t = new Thread(delegate() { LoadMods(ToLoad, progressHandler); }); progressHandler.Task = "LoadingMods"; progressHandler.OnComplete += (s, e) => MainWindow.Instance.Dispatcher.Invoke((Action) delegate() { UpdateMods(); }); ModAPI.Utils.Schedule.AddTask("GUI", "OperationPending", null, new object[] { "LoadingMods", progressHandler, null, true }); t.Start(); } } catch (Exception e) { System.Console.WriteLine(e.ToString()); } }
public void SetMod(ModViewModel model) { CurrentModViewModel = model; if (model != null) { SelectedMod.Visibility = System.Windows.Visibility.Visible; NoModSelected.Visibility = System.Windows.Visibility.Collapsed; SelectedMod.DataContext = model; } else { SelectedMod.Visibility = System.Windows.Visibility.Collapsed; NoModSelected.Visibility = System.Windows.Visibility.Visible; SelectedMod.DataContext = null; } }
public void UpdateMod(ModViewModel mod) { _modRepo.Update(_mapper.Map <Mod>(mod)); }
protected void UpdateMods() { foreach (KeyValuePair <string, Mod> kv in Mod.Mods) { bool add = true; ModViewModel alreadyVM = null; foreach (ListViewItem i in _Mods) { ModViewModel vm = ((ModViewModel)i.DataContext); if (vm.versions.Values.Contains(kv.Value)) { add = false; } if (vm.ID == kv.Value.ID) { alreadyVM = vm; } } if (add) { Mod mod = kv.Value; if (alreadyVM != null) { alreadyVM.versions.Add(Mod.Header.ParseModVersion(mod.header.GetVersion()), mod); alreadyVM.OnPropertyChanged("Version"); alreadyVM.OnPropertyChanged("Name"); } else { ListViewItem item = new ListViewItem(); StackPanel outerPanel = new StackPanel(); outerPanel.Orientation = Orientation.Horizontal; outerPanel.Margin = new Thickness(-5, 0, 0, 0); CheckBox checkBox = new CheckBox(); checkBox.SetBinding(CheckBox.IsCheckedProperty, "Selected"); outerPanel.Children.Add(checkBox); StackPanel panel = new StackPanel(); TextBlock textBlock = new TextBlock(); textBlock.SetBinding(TextBlock.TextProperty, "Name"); textBlock.Style = (Style)Application.Current.FindResource("HeaderLabel"); panel.Children.Add(textBlock); TextBlock textBlock2 = new TextBlock(); textBlock2.SetBinding(TextBlock.TextProperty, "Version"); textBlock2.FontSize = 12; textBlock2.Style = (Style)Application.Current.FindResource("NormalLabel"); panel.Children.Add(textBlock2); outerPanel.Children.Add(panel); ModViewModel mvm = new ModViewModel(mod); item.DataContext = mvm; item.Content = outerPanel; _Mods.Add(item); } } } foreach (ListViewItem item in _Mods) { ModViewModel vm = (ModViewModel)item.DataContext; vm.Initialized(); } _FirstBatchLoaded = true; if (_SelectNewestModVersions) { SelectNewestVersions(); } }
private void UninstallButton_Click(object sender, RoutedEventArgs e) { ModViewModel modViewModel = DetailsContentControl.Content as ModViewModel; modViewModel.IsInstalled = false; }
protected void UpdateMods() { foreach (KeyValuePair<string, Mod> kv in Mod.Mods) { bool add = true; ModViewModel alreadyVM = null; foreach (ListViewItem i in _Mods) { ModViewModel vm = ((ModViewModel)i.DataContext); if (vm.versions.Values.Contains(kv.Value)) { add = false; } if (vm.ID == kv.Value.ID) { alreadyVM = vm; } } if (add) { Mod mod = kv.Value; if (alreadyVM != null) { alreadyVM.versions.Add(Mod.Header.ParseModVersion(mod.header.GetVersion()), mod); alreadyVM.OnPropertyChanged("Version"); alreadyVM.OnPropertyChanged("Name"); } else { ListViewItem item = new ListViewItem(); StackPanel outerPanel = new StackPanel(); outerPanel.Orientation = Orientation.Horizontal; outerPanel.Margin = new Thickness(-5, 0, 0, 0); CheckBox checkBox = new CheckBox(); checkBox.SetBinding(CheckBox.IsCheckedProperty, "Selected"); outerPanel.Children.Add(checkBox); StackPanel panel = new StackPanel(); TextBlock textBlock = new TextBlock(); textBlock.SetBinding(TextBlock.TextProperty, "Name"); panel.Children.Add(textBlock); TextBlock textBlock2 = new TextBlock(); textBlock2.SetBinding(TextBlock.TextProperty, "Version"); textBlock2.FontSize = 14; panel.Children.Add(textBlock2); outerPanel.Children.Add(panel); ModViewModel mvm = new ModViewModel(mod); item.DataContext = mvm; item.Content = outerPanel; _Mods.Add(item); } } } foreach (ListViewItem item in _Mods) { ModViewModel vm = (ModViewModel)item.DataContext; vm.Initialized(); } _FirstBatchLoaded = true; if (_SelectNewestModVersions) SelectNewestVersions(); }