internal static unsafe void GetAllArchetypes(ArchetypeManager archetypeManager, out Dictionary <EntityArchetype, int> archetypeToIndex, out EntityArchetype[] archetypeArray) { List <EntityArchetype> list = new List <EntityArchetype>(); Archetype * lastArchetype = archetypeManager.m_LastArchetype; while (true) { if (lastArchetype == null) { archetypeToIndex = new Dictionary <EntityArchetype, int>(); int num = 0; while (true) { if (num >= list.Count) { archetypeArray = list.ToArray(); return; } archetypeToIndex.Add(list[num], num); num++; } } if (lastArchetype->EntityCount >= 0) { EntityArchetype item = new EntityArchetype { Archetype = lastArchetype }; list.Add(item); } lastArchetype = lastArchetype->PrevArchetype; } }
private void ExportCollectionButton_OnClick(object sender, RoutedEventArgs e) { try { var game = ProcessMonitor.RunningGameType; if (!game.HasValue) { return; } var collection = ArchetypeManager.GetCollection(game.Value); if (collection != null) { string export = ArchetypeManager.GetExportedDeck(game.Value, collection); if (WindowsHelper.TryCopyToClipboard(export, out string blockingWindowText)) { MessageBox.Show("Collection exported to clipboard", "Success"); } else { MessageBox.Show(blockingWindowText != null ? $"Unable to access clipboard.\nPlease close this window: {blockingWindowText}" : "Unable to access clipboard.", "Error"); } } else { MessageBox.Show("Something went wrong...", "Error"); } } catch (Exception ex) { Logger.LogError(ex.ToString()); MessageBox.Show($"Something went wrong...\n\n{ex.Message}", "Error"); } }
private void ExportPlayerDeckToFileMenuItem_OnClick(object sender, RoutedEventArgs e) { try { var deck = (((sender as MenuItem)?.CommandParameter as ContextMenu)?.PlacementTarget as ListViewItem)?.DataContext as Deck; if (deck == null) { return; } var export = new StringBuilder(); export.AppendLine($"### {deck.Name} ###"); export.Append(ArchetypeManager.GetExportedDeck(deck.GameType, deck.Cards)); SaveFileDialog saveDeck = new SaveFileDialog { Title = "Export Deck", FileName = string.Join("", deck.Name.Split(Path.GetInvalidFileNameChars())), InitialDirectory = Logger.GameDataDirectory, Filter = "Deck tracker deck file (*.dtdeck)|*.dtdeck", RestoreDirectory = true }; if (saveDeck.ShowDialog() == true) { File.WriteAllText(saveDeck.FileName, export.ToString()); MessageBox.Show($"{deck.Name} exported to\n{saveDeck.FileName}", "Success"); } } catch (Exception ex) { MessageBox.Show($"Something went wrong...\n{ex.Message}", "Error"); } }
private void LoadArchetypes() { string archetypeFile = ArchetypeManager.GetRelativeArchetype(this.File, this.Data.TemplateIndex); // try to fallback to default DATA path if (archetypeFile == null) { archetypeFile = ArchetypeManager.GetRelativeArchetype(Helper.Settings.Data.Data.General.DefaultDataDirectory); // user interaction required to get the path of the archetype file if (archetypeFile == null) { archetypeFile = this.ShowSolarArchetypeSelector(); } } // set data path based on archetype file and not system file this.DataPath = Helper.Template.Data.GetDataPath(archetypeFile, Helper.Template.Data.SolarArchetypeFile); if (this.Archetype == null) { this.Archetype = new ArchetypeManager(archetypeFile, Helper.Template.Data.SolarArchetypeFile); } this.SetAllBlockTypes(); }
protected override void OnExit(ExitEventArgs e) { ArchetypeManager.Stop(); ReplayUploader.Stop(); ProcessMonitor.Stop(); GameMessageDispatcher.Stop(); mutex.Dispose(); base.OnExit(e); }
public void ShowUniverseConnections(string file, List <TableBlock> blocks, ArchetypeManager archetype) { if (File.Exists(file)) { string path = Path.GetDirectoryName(file); ThreadStart threadStart = () => this.presenter.DisplayUniverse(path, Helper.Template.Data.SystemFile, blocks, archetype); Helper.Thread.Start(ref this.universeLoadingThread, threadStart, ThreadPriority.Normal, true); } }
//private PlayedDeck _opponentDeck; public MainWindow() { InitializeComponent(); _manager = ArchetypeManager.Instance; _manager.LoadDecks(); DeckView.DataContext = new ArchetypeDeckViewModel(_manager.Decks.First()); //// TODO watch for changes from "Toast" //_opponentDeck = new PlayedDeck(game.OpponentHero, game.Format ?? Hearthstone_Deck_Tracker.Enums.Format.All, game.Turns, game.OpponentCards); //// TODO also add format here, deal with "All" //ArchetypeSelection.ItemsSource = _manager.Decks.Select(d => d.Klass == _opponentDeck.Klass); //ArchetypeSelection.SelectedIndex = 0; //// TODO some indication of no match //var bestMatch = _manager.Find(_opponentDeck).FirstOrDefault(); //if (ArchetypeSelection.Items.Contains(bestMatch)) // ArchetypeSelection.SelectedItem = bestMatch; }
internal static unsafe void GetAllArchetypes(ArchetypeManager archetypeManager, out Dictionary<EntityArchetype, int> archetypeToIndex, out EntityArchetype[] archetypeArray) { var archetypeList = new List<EntityArchetype>(); var currentArcheType = archetypeManager.m_LastArchetype; while (currentArcheType != null) { if (currentArcheType->EntityCount >= 0) { archetypeList.Add(new EntityArchetype{Archetype = currentArcheType}); } currentArcheType = currentArcheType->PrevArchetype; } //todo: sort archetypes to get deterministic indices archetypeToIndex = new Dictionary<EntityArchetype, int>(); for (int i = 0; i < archetypeList.Count; ++i) { archetypeToIndex.Add(archetypeList[i],i); } archetypeArray = archetypeList.ToArray(); }
private async void ImportDeckButton_OnClick(object sender, RoutedEventArgs e) { var dialog = new ImportDeckDialog(); await this.ShowMetroDialogAsync(dialog); string deckList = await dialog.WaitForButtonPressAsync(); await this.HideMetroDialogAsync(dialog); var game = ProcessMonitor.RunningGameType; if (deckList == null || !game.HasValue) { return; } try { bool isUrl = Uri.TryCreate(deckList, UriKind.Absolute, out Uri uriResult) && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps); if (isUrl) { deckList = ArchetypeManager.DownloadDeck(deckList); if (deckList == null) { MessageBox.Show("Unable to download deck list", "Error"); return; } } if (ArchetypeManager.ImportDeck(game.Value, deckList)) { MessageBox.Show("Deck has been imported", "Success"); } else { MessageBox.Show("Something went wrong... Deck has not been imported", "Error"); } } catch (Exception ex) { Logger.LogError(ex.ToString()); MessageBox.Show($"Something went wrong...\n{ex.Message}", "Error"); } }
public ArchetypeDeckListView() { InitializeComponent(); _manager = ArchetypeManager.Instance; _manager.LoadDecks(); //DeckClassFilterSelection.ItemsSource = Enum.GetValues(typeof(PlayerClass)); //DeckClassFilterSelection.SelectedItem = PlayerClass.ANY; //DeckFormatFilterSelection.ItemsSource = Enum.GetValues(typeof(GameFormat)); //DeckFormatFilterSelection.SelectedItem = GameFormat.ANY; _viewModel = new ArchetypeDeckListViewModel(_manager.Decks); DataContext = _viewModel; //DeckList.ItemsSource = _manager.Decks; //var deck = _manager.Decks.FirstOrDefault(); //if (deck != null) //{ // DeckList.SelectedItem = SelectedDeck = deck; // RaiseDeckSelectEvent(); //} }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); if (e.Args.Contains("--debug")) { Logger.DebugMode = true; } AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler; mutex = new Mutex(true, "Local\\DeckTracker", out bool isNew); if (!isNew) { MessageBox.Show("Universal Deck Tracker is already running..."); Shutdown(); } JsonConvert.DefaultSettings = () => { var settings = new JsonSerializerSettings(); settings.Converters.Add(new StringEnumConverter()); return(settings); }; Logger.Initialize(); ConfigManager.Initialize(); ReplayUploader.Initialize(); ArchetypeManager.Initialize(); try { DeckClassifier.Initialize(); } catch (Exception exception) { MessageBox.Show(exception.Message); Shutdown(); } GameMessageDispatcher.Start(); ProcessMonitor.Start(); #if !DEBUG UpdateManager.StartUpdateCheck(); #endif }
private void ExportOpponentDecksMenuItem_OnClick(object sender, RoutedEventArgs e) { try { var deck = DecksListView.SelectedItem as Deck; var againstDeck = (((sender as MenuItem)?.CommandParameter as ContextMenu)?.PlacementTarget as ListViewItem)?.DataContext as AgainstDeck; if (deck == null || againstDeck == null) { return; } var export = new StringBuilder(); int count = 0; foreach (var game in againstDeck.Games) { if (!model.GameModes.First(mode => mode.Name == game.Mode).IsEnabled) { continue; } if (export.Length > 0) { export.AppendLine(); } export.AppendLine($"### {game.OpponentDeck.Name} ### {game.Start:F} ###"); export.Append(ArchetypeManager.GetExportedDeck(game.GameType, game.OpponentDeck.Cards)); count++; } if (WindowsHelper.TryCopyToClipboard(export.ToString(), out string blockingWindowText)) { MessageBox.Show($"{count} opponent decks have been exported to clipboard", "Success"); } else { MessageBox.Show(blockingWindowText != null ? $"Unable to access clipboard.\nPlease close this window: {blockingWindowText}" : "Unable to access clipboard.", "Error"); } } catch (Exception ex) { Logger.LogError(ex.ToString()); MessageBox.Show($"Something went wrong...\n{ex.Message}", "Error"); } }
internal static unsafe void GetAllArchetypes(ArchetypeManager archetypeManager, out Dictionary <EntityArchetype, int> archetypeToIndex, out EntityArchetype[] archetypeArray) { var archetypeList = new List <EntityArchetype>(); for (var i = archetypeManager.m_Archetypes.Count - 1; i >= 0; --i) { var archetype = archetypeManager.m_Archetypes.p[i]; if (archetype->EntityCount >= 0) { archetypeList.Add(new EntityArchetype { Archetype = archetype }); } } //todo: sort archetypes to get deterministic indices archetypeToIndex = new Dictionary <EntityArchetype, int>(); for (int i = 0; i < archetypeList.Count; ++i) { archetypeToIndex.Add(archetypeList[i], i); } archetypeArray = archetypeList.ToArray(); }
private void ExportPlayerDeckMenuItem_OnClick(object sender, RoutedEventArgs e) { try { var deck = (((sender as MenuItem)?.CommandParameter as ContextMenu)?.PlacementTarget as ListViewItem)?.DataContext as Deck; if (deck == null) { return; } var export = new StringBuilder(); export.AppendLine($"### {deck.Name} ###"); export.Append(ArchetypeManager.GetExportedDeck(deck.GameType, deck.Cards)); if (WindowsHelper.TryCopyToClipboard(export.ToString(), out string blockingWindowText)) { MessageBox.Show("Last played deck has been exported to clipboard", "Success"); } else { MessageBox.Show(blockingWindowText != null ? $"Unable to access clipboard.\nPlease close this window: {blockingWindowText}" : "Unable to access clipboard.", "Error"); } } catch (Exception ex) { MessageBox.Show($"Something went wrong...\n{ex.Message}", "Error"); } }
public static void SetObjectType(TableBlock block, ArchetypeManager archetypeManager) { switch (block.Block.Name.ToLowerInvariant()) { case "lightsource": block.ObjectType = ContentType.LightSource; return; case "object": { if (archetypeManager != null) { //get type of object based on archetype foreach (EditorINIOption option in block.Block.Options) { if (option.Name.Equals("archetype", StringComparison.OrdinalIgnoreCase)) { if (option.Values.Count > 0) { block.Archetype = archetypeManager.TypeOf(option.Values[0].Value.ToString()); if (block.Archetype != null) { block.ObjectType = block.Archetype.Type; return; } } break; } } } break; } case "zone": { string shape = "box"; int flags = 0; const int exclusionFlag = 0x10000 | 0x20000; // exclusion type 1 + exclusion type 2 foreach (EditorINIOption option in block.Block.Options) { if (option.Values.Count > 0) { string value = option.Values[0].Value.ToString(); switch (option.Name.ToLowerInvariant()) { case "lane_id": // overrides exclusion zones as those are set after the loop block.ObjectType = ContentType.ZonePathTradeLane; return; case "usage": string[] values = value.Split(new[] { ',' }); foreach (string valueEntry in values) { if (valueEntry.Equals("trade", StringComparison.OrdinalIgnoreCase)) { block.ObjectType = ContentType.ZonePathTrade; return; } } block.ObjectType = ContentType.ZonePath; return; case "vignette_type": switch (value.ToLowerInvariant()) { case "open": case "field": case "exclusion": block.ObjectType = ContentType.ZoneVignette; return; } break; case "shape": shape = value; break; case "property_flags": flags = Parser.ParseInt(value, 0); break; } } } bool isExclusion = (flags & exclusionFlag) != 0; // set type based on shape and flags switch (shape.ToLowerInvariant()) { case "sphere": block.ObjectType = isExclusion ? ContentType.ZoneSphereExclusion : ContentType.ZoneSphere; return; default: // ellipsoid block.ObjectType = isExclusion ? ContentType.ZoneEllipsoidExclusion : ContentType.ZoneEllipsoid; return; case "cylinder": block.ObjectType = isExclusion ? ContentType.ZoneCylinderExclusion : ContentType.ZoneCylinder; return; case "ring": block.ObjectType = ContentType.ZoneRing; // rings can't be used as exclusions return; case "box": block.ObjectType = isExclusion ? ContentType.ZoneBoxExclusion : ContentType.ZoneBox; return; } } } block.ObjectType = ContentType.None; }