internal static string CreateIntPropStr(int val, DisplayType displayType, DemoInfo demoInfo) { switch (displayType) { case DisplayType.Int: return(val.ToString()); case DisplayType.Bool: return((val != 0).ToString()); case DisplayType.AreaBits: return(Convert.ToString(val, 2).PadLeft(AreaBitsNumBits, '0')); case DisplayType.Color: // pretty sure this is rgba return($"0x{val:X8}"); case DisplayType.Handle: return(((EHandle)val).ToString()); case DisplayType.DT_BaseEntity__m_CollisionGroup: return(demoInfo.CollisionsGroupList[val].ToString()); case DisplayType.DT_BasePlayer__m_fFlags: return($"({demoInfo.PlayerMfFlagChecker.ToFlagString(val)})"); default: return(EntityPropertyEnumManager.CreateEnumPropStr(val, displayType)); // must be last } }
public void PopulateViews(DemoInfo demoInfo) { foreach (var component in _components) { component.PopulateViews(demoInfo); } }
void RunSelectedDemo() { //load demo sample DemoInfo selectedDemoInfo = this.lstDemoList.SelectedItem as DemoInfo; if (selectedDemoInfo == null) { return; } //------------------------------------------------------------ if (selectedDemoInfo.demoBaseTypeKind == 1) { DemoBase2 selectedDemo = (DemoBase2)Activator.CreateInstance(selectedDemoInfo.DemoType); RunDemo(selectedDemo); } else { DemoBase selectedDemo = (DemoBase)Activator.CreateInstance(selectedDemoInfo.DemoType); RunDemo(selectedDemo); } //------------------------------------------------------------ //LayoutFarm.UI.UISurfaceViewportControl viewport; //Form formCanvas; //CreateReadyForm( // out viewport, // out formCanvas); //selectedDemo.StartDemo(new SampleViewport(viewport)); //viewport.TopDownRecalculateContent(); ////================================================== //viewport.PaintMe(); //ShowFormLayoutInspector(viewport); }
public SamplesConfiguration() { DemoInfo badgeDemo = new DemoInfo() { Name = "Getting Started", Category = "Badge", Description = "The Badge control is used to notify users about new or unread messages, notifications, or the status of something.", DemoView = typeof(Views.Badge.BadgeView) }; badgeDemo.Documentation.AddRange(new List <Documentation>() { new Documentation() { Content = "SfBadge - API", Uri = new Uri("https://help.syncfusion.com"), } }); var badge = new ControlInfo() { Control = DemoControl.SfBadge, ControlCategory = ControlCategory.Notification, Description = "The Badge control is used to notify users about new or unread messages, notifications, or the status of something.", Glyph = "\uE706" }; badge.Demos.Add(badgeDemo); var controlInfos = new List <ControlInfo>() { badge, }; DemoHelper.ControlInfos.AddRange(controlInfos); }
private void PopulatePuRunsListView(DemoInfo demoInfo) { var cutByTimeItem = new MenuItem(); cutByTimeItem.Header = "Cut by Time (Ctrl+T)"; cutByTimeItem.Command = _cutByPuRunCommand; cutByTimeItem.Click += (obj, args) => OnCutByTimeFromPuRunContextClicked(); var eventsContextMenu = new ContextMenu(); eventsContextMenu.Items.Add(cutByTimeItem); _puRunsListView.Items.Clear(); foreach (var puRun in demoInfo.PuRuns) { var item = new ListViewItem(); item.Content = puRun; item.ContextMenu = eventsContextMenu; _puRunsListView.Items.Add(item); } if (demoInfo.PuRuns.Count > 0) { _puRunsListView.SelectedIndex = 0; } }
public void SetupSurveySelect(DemoInfo info) { welcome.gameObject.SetActive(false); infoTitle.gameObject.SetActive(true); infoText.gameObject.SetActive(true); infoImage.gameObject.SetActive(true); if (info.name == "Survey") { buttons[0].gameObject.SetActive(false); buttons[1].gameObject.SetActive(false); buttons[2].gameObject.SetActive(false); buttons[3].gameObject.SetActive(true); } else if (info.name == "Welcome") { welcome.gameObject.SetActive(true); infoTitle.gameObject.SetActive(false); infoText.gameObject.SetActive(false); infoImage.gameObject.SetActive(false); buttons[0].gameObject.SetActive(false); buttons[1].gameObject.SetActive(false); buttons[2].gameObject.SetActive(false); buttons[3].gameObject.SetActive(false); } else { buttons[0].gameObject.SetActive(true); buttons[1].gameObject.SetActive(true); buttons[2].gameObject.SetActive(true); buttons[3].gameObject.SetActive(false); } }
public void PopulateViews(DemoInfo demoInfo) { foreach(var component in _components) { component.PopulateViews(demoInfo); } }
private void selectDemo(DemoInfo info) { PopupUI popup = PopupUI.Instance; // Set demo title, info text, and image selectedDemo = info; infoName.text = info.name; infoTitle.text = info.demoTitle; infoText.text = info.demoText; infoImage.sprite = info.demoImage; // Set popup text popup.popupText = ""; foreach (string text in info.demoPopupInfo) { popup.popupText += text + "\n"; } // Set button image highlight for selected demo button foreach (DemoInfo _ in demoList) { _.select.image.sprite = null; } info.select.image.sprite = info.select.spriteState.highlightedSprite; SetupSurveySelect(info); }
private void selectDemo(DemoInfo info) { TextMeshProUGUI infoTitle = GameObject.FindGameObjectWithTag("InfoTitle").GetComponentInChildren <TextMeshProUGUI>(); TextMeshProUGUI infoText = GameObject.FindGameObjectWithTag("InfoText").GetComponentInChildren <TextMeshProUGUI>(); Image infoImage = GameObject.FindGameObjectWithTag("InfoImage").GetComponent <Image>(); PopupUI popup = PopupUI.Instance; // Set demo title, info text, and image selectedDemo = info; infoTitle.text = info.demoTitle; infoText.text = info.demoText; infoImage.sprite = info.demoImage; // Set popup text popup.popupText = ""; foreach (string text in info.demoPopupInfo) { popup.popupText += text + "\n"; } // Set button image highlight for selected demo button foreach (DemoInfo _ in demoList) { _.select.image.sprite = null; } info.select.image.sprite = info.select.spriteState.highlightedSprite; }
public void PopulateViews(DemoInfo demoInfo) { var showStats = demoInfo.Analyzed; _statsPanel.Visibility = showStats ? Visibility.Visible : Visibility.Collapsed; _noStatsPanel.Visibility = showStats ? Visibility.Collapsed : Visibility.Visible; if (!showStats) { ShowMatchInfo(false); ShowTeamStats(false); ShowPlayerStats(false); ShowMatchSelector(false); return; } if (demoInfo.MatchStats.Count == 0) { ShowMatchInfo(false); ShowTeamStats(false); ShowPlayerStats(false); ShowMatchSelector(false); return; } _matchSelectionComboBox.Items.Clear(); for (var i = 0; i < demoInfo.MatchStats.Count; ++i) { _matchSelectionComboBox.Items.Add("Match #" + (i + 1).ToString()); } _matchSelectionComboBox.SelectedIndex = 0; ShowMatchSelector(demoInfo.MatchStats.Count > 1); PopulateViews(demoInfo.MatchStats[0]); }
public static byte MessageTypeToByte(MessageType m, DemoInfo demoInfo) { if (demoInfo.MessageTypesReverseLookup.TryGetValue(m, out int i)) { return((byte)i); } throw new ArgumentException($"no message found for {m}"); }
// gets the byte value associated with this packet type public static byte PacketTypeToByte(DemoInfo demoInfo, PacketType p) { if (demoInfo.PacketTypesReverseLookup.TryGetValue(p, out int i)) { return((byte)i); } throw new ArgumentException($"no packet id found for {p}"); }
private void copyPlayConsoleCommand_Click(object sender, RoutedEventArgs e) { int iSelectedIndex = dataFromDemoFolder.SelectedIndex; DemoInfo currentlySelectedRow = dataFromDemoFolder.SelectedItem as DemoInfo; Clipboard.SetDataObject("playdemo garrysmod\\demos\\" + currentlySelectedRow.fileName); MessageBox.Show("Console command copied to clipboard! Paste into your GMod console"); }
public SearchResultFileDisplayInfo(string fileName, string matchCount, string patterns, uint fileIndex, DemoInfo demo) { FileName = fileName; MatchCount = matchCount; Patterns = patterns; FileIndex = fileIndex; Demo = demo; }
// src_main/common/netmessages.cpp SVC_ServerInfo::WriteToBuffer protected override void Parse(ref BitStreamReader bsr) { NetworkProtocol = bsr.ReadUShort(); ServerCount = bsr.ReadUInt(); IsHltv = bsr.ReadBool(); IsDedicated = bsr.ReadBool(); if (DemoInfo.IsLeft4Dead() && DemoInfo.Game >= SourceGame.L4D2_2147) { UnknownBit = bsr.ReadBool(); } ClientCrc = bsr.ReadSInt(); if (DemoInfo.NewDemoProtocol) // unknown field, could be before ClientCrc { Unknown = bsr.ReadUInt(); } MaxServerClasses = bsr.ReadUShort(); if (NetworkProtocol == 24) { MapMD5 = bsr.ReadBytes(16); } else { MapCrc = bsr.ReadUInt(); // network protocol < 18 according to p2 leak, but doesn't add up for l4d2 and p2 } PlayerCount = bsr.ReadByte(); MaxClients = bsr.ReadByte(); TickInterval = bsr.ReadFloat(); Platform = (char)bsr.ReadByte(); GameDirBitIndex = bsr.AbsoluteBitIndex; GameDir = bsr.ReadNullTerminatedString(); MapName = bsr.ReadNullTerminatedString(); SkyName = bsr.ReadNullTerminatedString(); HostName = bsr.ReadNullTerminatedString(); if (DemoInfo.IsLeft4Dead() && DemoInfo.Game >= SourceGame.L4D2_2147) { MissionName = bsr.ReadNullTerminatedString(); MutationName = bsr.ReadNullTerminatedString(); } if (NetworkProtocol == 24) { HasReplay = bsr.ReadBool(); // protocol version >= 16 } // there's a good change that the first SvcServerInfo parsed is parsed correctly // prevent the interval from being overwritten by subsequent, incorrectly detected, SvcServerInfo messages // TODO: check if changing tickrate mid game sends another SvcServerInfo if (!DemoInfo.HasParsedTickInterval) { DemoInfo.TickInterval = TickInterval; DemoInfo.HasParsedTickInterval = true; } // this packet always(?) appears before the creation of any tables DemoRef.StringTablesManager.ClearCurrentTables(); // init baselines here DemoRef.EntBaseLines = new EntityBaseLines(DemoRef, MaxServerClasses); }
public async Task <bool> SetDeviceDemo(DemoInfo config) { string jsonIgnoreNullValues = JsonConvert.SerializeObject(config, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); return(true); }
public async void SetDemoClicked() { DemoInfo config = new DemoInfo(); config.request = "set"; config.demo = 1; config.info = "demo"; var deviceRes = await deviceService.SetDeviceDemo(config); }
public void PopulateViews(DemoInfo demoInfo) { if (!demoInfo.Analyzed) { _scoresListView.ItemsSource = null; _scoresListView.SelectedIndex = -1; _teamScoresListView.ItemsSource = null; _teamScoresListView.SelectedIndex = -1; _groupBox.Content = _scoresListView; return; } var activeListView = demoInfo.TeamGameType ? _teamScoresListView : _scoresListView; _groupBox.Content = activeListView; var cutByTimeItem = new MenuItem(); cutByTimeItem.Header = "Cut by Time (Ctrl+T)"; cutByTimeItem.Command = _cutByScoreCommand; cutByTimeItem.Click += (obj, args) => OnCutByTimeClicked(); App.AddKeyBinding(activeListView, Key.T, _cutByScoreCommand, (obj, args) => OnCutByTimeClicked()); var contextMenu = new ContextMenu(); contextMenu.Items.Add(cutByTimeItem); var scores = new ObservableCollection <ListViewItem>(); if (demoInfo.TeamGameType) { foreach (var score in demoInfo.TeamScores) { var item = new ListViewItem(); item.Content = score; item.ContextMenu = contextMenu; scores.Add(item); } } else { foreach (var score in demoInfo.Scores) { var item = new ListViewItem(); item.Content = score; item.ContextMenu = contextMenu; scores.Add(item); } } activeListView.ItemsSource = scores; if (scores.Count > 0) { activeListView.SelectedIndex = 0; } }
public SearchResultCutDisplayInfo(string fileName, string gs, string start, string end, string patterns, UDT_DLL.udtPatternMatch match, DemoInfo demo) { FileName = fileName; GSIndex = gs; StartTime = start; EndTime = end; Patterns = patterns; Match = match; Demo = demo; }
protected override void Parse(ref BitStreamReader bsr) { EntryCount = bsr.ReadByte(); uint bitLen = DemoInfo.Game == SourceGame.PORTAL_1_1910503 ? bsr.ReadVarUInt32() : bsr.ReadUInt(DemoInfo.IsLeft4Dead2() ? 18 : 17); _data = bsr.SplitAndSkip(bitLen); // todo }
public SamplesConfiguration() { DemoInfo badgeDemo = new DemoInfo() { Name = "Getting Started", Category = "Badge", Description = "The Badge control is used to notify users about new or unread messages, notifications, or the status of something.", DemoView = typeof(Views.Badge.BadgeView), ShowInfoPanel = true }; List <Documentation> documentations = new List <Documentation>(); documentations.Add(new Documentation() { Content = "Badge - API Reference", Uri = new Uri("https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Notifications.SfBadge.html") }); documentations.Add(new Documentation() { Content = "Badge - Getting Started", Uri = new Uri("https://help.syncfusion.com/winui/badge/getting-started") }); documentations.Add(new Documentation() { Content = "Badge - Alignment and Positioning", Uri = new Uri("https://help.syncfusion.com/winui/badge/alignment-positioning") }); documentations.Add(new Documentation() { Content = "Badge - Custom Alignment and Positioning", Uri = new Uri("https://help.syncfusion.com/winui/badge/alignment-positioning#custom-alignment-and-positioning-of-badge") }); documentations.Add(new Documentation() { Content = "Badge - Customization", Uri = new Uri("https://help.syncfusion.com/winui/badge/badge-customization") }); badgeDemo.Documentation.AddRange(documentations); var badge = new ControlInfo() { Control = DemoControl.SfBadge, ControlCategory = ControlCategory.Notification, Description = "The Badge control is used to notify users about new or unread messages, notifications, or the status of something.", Glyph = "\uE706" }; badge.Demos.Add(badgeDemo); var controlInfos = new List <ControlInfo>() { badge, }; DemoHelper.ControlInfos.AddRange(controlInfos); }
/// <summary> /// Handles filepath of a demo and adds it to the data grid /// </summary> /// <param name="sPath">Full file path + filename + extension of the demo file to read</param> public void processDemoAndAddToList(string sPath) { Dictionary <string, string> serverIpToName = new Dictionary <string, string>(); // Regular IPs serverIpToName["192.184.57.2:27015"] = "Serious TTT West"; serverIpToName["172.106.104.11:27015"] = "Serious TTT East"; serverIpToName["192.184.57.6:27015"] = "Serious TTT Vanilla"; serverIpToName["172.106.104.13:27015"] = "Serious TTT Vanilla 2"; serverIpToName["172.106.104.14:27015"] = "SGM Deathrun East"; // URL redirects serverIpToName["west.seriousttt.com"] = "Serious TTT West"; serverIpToName["east.seriousttt.com"] = "Serious TTT East"; serverIpToName["vanilla.seriousttt.com"] = "Serious TTT Vanilla"; serverIpToName["vanilla2.seriousttt.com"] = "Serious TTT Vanilla 2"; serverIpToName["east.seriousdr.com"] = "SGM Deathrun East"; if (!File.Exists(sPath)) { MessageBox.Show("The demo file could not be found (File not found)", "ERROR: File not found", MessageBoxButton.OK, MessageBoxImage.Error); return; // Stop! } var demoReader = new DemoReader(sPath); demoReader.ReadHeader(); string sServerName; if (serverIpToName.ContainsKey(demoReader.Header.ServerName)) { sServerName = serverIpToName[demoReader.Header.ServerName]; } else { sServerName = demoReader.Header.ServerName + " | (ERROR RESOLVING IP TO SERIOUS GMOD SERVER NAME"; } string[] explodedFilePath = sPath.Split('\\'); string sFileName = explodedFilePath[explodedFilePath.Length - 1]; // The last '\' is the file name DemoInfo demoInfo = new DemoInfo(); demoInfo.fileName = sFileName; demoInfo.server = sServerName; demoInfo.mapName = demoReader.Header.MapName; demoInfo.demoStart = File.GetCreationTime(sPath).ToString(); demoInfo.demoEnd = File.GetLastWriteTime(sPath).ToString(); dataFromDemoFolder.Items.Add(demoInfo); }
void RunSelectedDemo() { //load demo sample DemoInfo selectedDemoInfo = this.lstDemoList.SelectedItem as DemoInfo; if (selectedDemoInfo == null) { return; } App selectedDemo = (App)Activator.CreateInstance(selectedDemoInfo.DemoType); RunDemo(selectedDemo); }
private Button createLevelButton(DemoInfo info, Transform parent, Vector3 position) { GameObject buttonObj = Instantiate(selectButtonPrefab); buttonObj.transform.SetParent(parent); buttonObj.GetComponent <RectTransform>().anchoredPosition3D = position; buttonObj.name = info.name + " Button"; TMPro.TextMeshProUGUI text = buttonObj.GetComponentInChildren <TMPro.TextMeshProUGUI>(); text.text = info.name; Button button = buttonObj.GetComponent <Button>(); button.onClick.AddListener(delegate { selectDemo(info); }); return(button); }
//private string root; protected void Page_Load(object sender, EventArgs e) { // prevent invalid ViewState errors in Firefox if (Request.Browser.Browser == "Firefox") { Response.Cache.SetNoStore(); } if (!IsPostBack) { Repeater1.DataBind(); Repeater2.DataBind(); DemoInfo.DataBind(); SandboxInfo.DataBind(); } }
public static MessageType ByteToSvcMessageType(byte b, DemoInfo demoInfo) { var tab = demoInfo.MessageTypes; if (tab == null) { return(MessageType.Unknown); } else if (b > tab.Count) { return(MessageType.Invalid); } else { return(tab[b]); } }
// gets the packet type associated with this byte value public static PacketType ByteToPacketType(DemoInfo demoInfo, byte b) { var tab = demoInfo.PacketTypes; if (tab == null) { return(PacketType.Unknown); } else if (b >= tab.Count) { return(PacketType.Invalid); } else { return(tab[b]); } }
public static UserMessageType ByteToUserMessageType(DemoInfo demoInfo, byte b) { var tab = demoInfo.UserMessageTypes; if (tab == null) { return(UserMessageType.Unknown); } else if (b >= tab.Count) { return(UserMessageType.Invalid); } else { return(tab[b]); } }
public void PopulateViews(DemoInfo demoInfo) { if (!demoInfo.Analyzed) { _commandsListView.ItemsSource = null; _commandsListView.SelectedIndex = -1; return; } var cutByTimeItem = new MenuItem(); cutByTimeItem.Header = "Cut by Time (Ctrl+T)"; cutByTimeItem.Command = _cutByCommandCommand; cutByTimeItem.Click += (obj, args) => OnCutByTimeFromCommandContextClicked(); var copyItem = new MenuItem(); copyItem.Header = "Copy to Clipboard (Ctrl+C)"; copyItem.Command = _copyCommand; copyItem.Click += (obj, args) => OnCopyContextClicked(); App.AddKeyBinding(_commandsListView, Key.T, _cutByCommandCommand, (obj, args) => OnCutByTimeFromCommandContextClicked()); App.AddKeyBinding(_commandsListView, Key.C, _copyCommand, (obj, args) => OnCopyContextClicked()); var commandsContextMenu = new ContextMenu(); commandsContextMenu.Items.Add(cutByTimeItem); commandsContextMenu.Items.Add(copyItem); var commands = new ObservableCollection <ListViewItem>(); foreach (var command in demoInfo.Commands) { var item = new ListViewItem(); item.Content = command; item.ContextMenu = commandsContextMenu; commands.Add(item); } _commandsListView.ItemsSource = commands; if (commands.Count > 0) { _commandsListView.SelectedIndex = 0; } }
public SamplesConfiguration() { // Showcase & Updated // Showcase & New //What's New DemoInfo showCaseSample1 = new DemoInfo() { Name = "Getting Started", Category = "Getting Started", Description = "This sample showcases how to display data in the encoded machine-readable format using supported symbol types either in a one-dimensional or two-dimensional pattern.", DemoType = DemoTypes.None, DemoView = typeof(Views.BarcodeDemoPage) }; showCaseSample1.Documentation.AddRange(new List <Documentation>() { new Documentation() { Content = "Barcode - API", Uri = new Uri("https://help.syncfusion.com"), } }); // Updated var demos = new List <DemoInfo>() { showCaseSample1 }; var controlInfo = new ControlInfo() { Control = DemoControl.Barcode, Description = "The Barcode is a data visualization control to generate and display data in a machine-readable format using supported symbol types.", Glyph = "\uE709", ControlBadge = ControlBadge.None, ControlCategory = ControlCategory.DataVisualization }; controlInfo.Demos.AddRange(demos); DemoHelper.ControlInfos.Add(controlInfo); }
protected override void Parse(ref BitStreamReader bsr) { TableName = bsr.ReadNullTerminatedString(); MaxEntries = (short)bsr.ReadUShort(); NumEntries = (int)bsr.ReadUInt(BitUtils.HighestBitIndex(MaxEntries) + 1); uint dataLen = bsr.ReadUInt(DemoInfo.IsLeft4Dead2() ? 21 : 20); UserDataFixedSize = bsr.ReadBool(); UserDataSize = (int)(UserDataFixedSize ? bsr.ReadUInt(12) : 0); UserDataSizeBits = (int)(UserDataFixedSize ? bsr.ReadUInt(4) : 0); if (DemoRef.Header.NetworkProtocol >= 15) { Flags = (StringTableFlags)bsr.ReadUInt(DemoInfo.NewDemoProtocol ? 2 : 1); } DemoRef.StringTablesManager.CreateStringTable(this); TableUpdates = new StringTableUpdates(DemoRef, TableName, NumEntries, true); TableUpdates.ParseStream(bsr.SplitAndSkip(dataLen)); }
private static void ExtractGameStateEvents(udtParserContextRef context, uint demoIdx, ref DemoInfo info) { uint gsEventCount = 0; IntPtr gsEvents = IntPtr.Zero; if(udtGetDemoDataInfo(context, demoIdx, udtParserPlugIn.GameState, ref gsEvents, ref gsEventCount) != udtErrorCode.None) { App.GlobalLogError("Calling udtGetDemoDataInfo for game states failed"); return; } const string space = " "; for(uint i = 0; i < gsEventCount; ++i) { var address = new IntPtr(gsEvents.ToInt64() + i * sizeof(udtParseDataGameState)); var data = (udtParseDataGameState)Marshal.PtrToStructure(address, typeof(udtParseDataGameState)); info.GameStateFileOffsets.Add(data.FileOffset); var firstSnapTime = App.FormatMinutesSeconds(data.FirstSnapshotTimeMs / 1000); var lastSnapTime = App.FormatMinutesSeconds(data.LastSnapshotTimeMs / 1000); info.GameStateSnapshotTimesMs.Add(Tuple.Create(data.FirstSnapshotTimeMs, data.LastSnapshotTimeMs)); info.Generic.Add(Tuple.Create("GameState #" + (i + 1).ToString(), "")); info.Generic.Add(Tuple.Create(space + "File Offset", FormatBytes(data.FileOffset))); info.Generic.Add(Tuple.Create(space + "Server Time Range", firstSnapTime + " - " + lastSnapTime)); info.Generic.Add(Tuple.Create(space + "Demo Taker", FormatDemoTaker(data))); AddMatches(info, data, space); AddPlayers(info, data, space); AddKeyValuePairs(info, data, space); } }
private void PopulateStats(DemoInfo demoInfo) { for(int i = 0; i < MaxXstats2Displayed; ++i) { var info2 = _xstats2WidgetInfos[i]; var visibility = Visibility.Collapsed; info2.WeaponStatsGroupBox.Visibility = visibility; info2.DamageStatsGroupBox.Visibility = visibility; } _xstats2SorryNothingFound.Visibility = demoInfo.Xstats2Infos.Count > 0 ? Visibility.Collapsed : Visibility.Visible; int statsCount = Math.Min(demoInfo.Xstats2Infos.Count, MaxXstats2Displayed); for(int i = 0; i < statsCount; ++i) { var info = demoInfo.Xstats2Infos[i]; var info2 = _xstats2WidgetInfos[i]; var visibility = info.WeaponStats.Count > 0 ? Visibility.Visible : Visibility.Collapsed; info2.WeaponStatsGroupBox.Visibility = visibility; info2.WeaponStatsGroupBox.Header = "Weapon Stats for Player " + info.WeaponStatsPlayerName; info2.WeaponStatsListView.Items.Clear(); foreach(var weaponStat in info.WeaponStats) { info2.WeaponStatsListView.Items.Add(weaponStat); } info2.DamageStatsGroupBox.Visibility = visibility; info2.DamageStatsGroupBox.Header = "Additional Stats for Player " + info.WeaponStatsPlayerName; info2.DamageStatsListView.Items.Clear(); foreach(var extraStats in info.DamageAndArmorStats) { info2.DamageStatsListView.Items.Add(extraStats); } } }
private void PopulatePuRunsListView(DemoInfo demoInfo) { var cutByTimeItem = new MenuItem(); cutByTimeItem.Header = "Cut by Time (Ctrl+T)"; cutByTimeItem.Command = _cutByPuRunCommand; cutByTimeItem.Click += (obj, args) => OnCutByTimeFromPuRunContextClicked(); var eventsContextMenu = new ContextMenu(); eventsContextMenu.Items.Add(cutByTimeItem); _puRunsListView.Items.Clear(); foreach(var puRun in demoInfo.PuRuns) { var item = new ListViewItem(); item.Content = puRun; item.ContextMenu = eventsContextMenu; _puRunsListView.Items.Add(item); } if(demoInfo.PuRuns.Count > 0) { _puRunsListView.SelectedIndex = 0; } }
public void PopulateViews(DemoInfo demoInfo) { if(!demoInfo.Analyzed) { _fragEventsListView.Items.Clear(); return; } var cutByTimeItem = new MenuItem(); cutByTimeItem.Header = "Cut by Time (Ctrl+T)"; cutByTimeItem.Command = _cutByFragCommand; cutByTimeItem.Click += (obj, args) => OnCutByTimeFromFragsContextClicked(); var copyItem = new MenuItem(); copyItem.Header = "Copy to Clipboard (Ctrl+C)"; copyItem.Command = _copyFragCommand; copyItem.Click += (obj, args) => OnCopyFromFragsContextClicked(); var eventsContextMenu = new ContextMenu(); eventsContextMenu.Items.Add(cutByTimeItem); _fragEventsListView.Items.Clear(); foreach(var fragEvent in demoInfo.FragEvents) { var item = new ListViewItem(); item.Content = fragEvent; item.ContextMenu = eventsContextMenu; _fragEventsListView.Items.Add(item); } if(demoInfo.FragEvents.Count > 0) { _fragEventsListView.SelectedIndex = 0; } }
public void PopulateViews(DemoInfo demoInfo) { // Nothing to do. }
public void PopulateViews(DemoInfo demoInfo) { if(!demoInfo.Analyzed) { _chatEventsListView.ItemsSource = null; _chatEventsListView.SelectedIndex = -1; return; } var cutByTimeItem = new MenuItem(); cutByTimeItem.Header = "Cut by Time (Ctrl+T)"; cutByTimeItem.Command = _cutByTimeCommand; cutByTimeItem.Click += (obj, args) => OnCutByTimeFromChatContextClicked(); var copyItem = new MenuItem(); copyItem.Header = "Copy to Clipboard (Ctrl+C)"; copyItem.Command = _copyChatCommand; copyItem.Click += (obj, args) => OnCopyFromChatContextClicked(); var eventsContextMenu = new ContextMenu(); eventsContextMenu.Items.Add(cutByTimeItem); eventsContextMenu.Items.Add(copyItem); var chatEvents = new ObservableCollection<ListViewItem>(); foreach(var chatEvent in demoInfo.ChatEvents) { var item = new ListViewItem(); item.Content = chatEvent; item.ContextMenu = eventsContextMenu; chatEvents.Add(item); } _chatEventsListView.ItemsSource = chatEvents; if(chatEvents.Count > 0) { _chatEventsListView.SelectedIndex = 0; } }
private static List<DemoInfo> ParseDemosImpl(ref udtParseArg parseArg, List<string> filePaths, int maxThreadCount, int inputIndexBase) { var errorCodeArray = new Int32[filePaths.Count]; var filePathArray = new IntPtr[filePaths.Count]; for(var i = 0; i < filePaths.Count; ++i) { filePathArray[i] = Marshal.StringToHGlobalAnsi(Path.GetFullPath(filePaths[i])); } var pinnedPlugIns = new PinnedObject(PlugInArray); parseArg.PlugInCount = (UInt32)PlugInArray.Length; parseArg.PlugIns = pinnedPlugIns.Address; var pinnedFilePaths = new PinnedObject(filePathArray); var pinnedErrorCodes = new PinnedObject(errorCodeArray); var multiParseArg = new udtMultiParseArg(); multiParseArg.FileCount = (UInt32)filePathArray.Length; multiParseArg.FilePaths = pinnedFilePaths.Address; multiParseArg.OutputErrorCodes = pinnedErrorCodes.Address; multiParseArg.MaxThreadCount = (UInt32)maxThreadCount; udtParserContextGroupRef contextGroup = IntPtr.Zero; var result = udtParseDemoFiles(ref contextGroup, ref parseArg, ref multiParseArg); pinnedPlugIns.Free(); pinnedFilePaths.Free(); pinnedErrorCodes.Free(); for(var i = 0; i < filePathArray.Length; ++i) { Marshal.FreeHGlobal(filePathArray[i]); } if(result != udtErrorCode.None && result != udtErrorCode.OperationCanceled) { udtDestroyContextGroup(contextGroup); App.GlobalLogError("Failed to parse demos: " + GetErrorCodeString(result)); return null; } uint contextCount = 0; if(udtGetContextCountFromGroup(contextGroup, ref contextCount) != udtErrorCode.None) { udtDestroyContextGroup(contextGroup); return null; } var infoList = new List<DemoInfo>(); for(uint i = 0; i < contextCount; ++i) { udtParserContextRef context = IntPtr.Zero; if(udtGetContextFromGroup(contextGroup, i, ref context) != udtErrorCode.None) { udtDestroyContextGroup(contextGroup); return null; } uint demoCount = 0; if(udtGetDemoCountFromContext(context, ref demoCount) != udtErrorCode.None) { udtDestroyContextGroup(contextGroup); return null; } for(uint j = 0; j < demoCount; ++j) { uint inputIdx = 0; if(udtGetDemoInputIndex(context, j, ref inputIdx) != udtErrorCode.None) { continue; } var errorCode = errorCodeArray[(int)inputIdx]; if(errorCode != (Int32)udtErrorCode.None) { if(errorCode != (Int32)udtErrorCode.Unprocessed && errorCode != (Int32)udtErrorCode.OperationCanceled) { var fileName = Path.GetFileName(filePaths[(int)inputIdx]); var errorCodeString = GetErrorCodeString((udtErrorCode)errorCode); App.GlobalLogError("Failed to parse demo file {0}: {1}", fileName, errorCodeString); } continue; } var filePath = filePaths[(int)inputIdx]; var protocol = udtGetProtocolByFilePath(filePath); var info = new DemoInfo(); info.Analyzed = true; info.InputIndex = inputIndexBase + (int)inputIdx; info.FilePath = Path.GetFullPath(filePath); info.Protocol = UDT_DLL.GetProtocolAsString(protocol); ExtractDemoInfo(context, j, ref info); infoList.Add(info); } } udtDestroyContextGroup(contextGroup); // Keep the original input order. infoList.Sort((a, b) => a.InputIndex - b.InputIndex); return infoList; }
private static void ExtractObituaries(udtParserContextRef context, uint demoIdx, ref DemoInfo info) { uint obituaryEventCount = 0; IntPtr obituaryEvents = IntPtr.Zero; if(udtGetDemoDataInfo(context, demoIdx, udtParserPlugIn.Obituaries, ref obituaryEvents, ref obituaryEventCount) != udtErrorCode.None) { App.GlobalLogError("Calling udtGetDemoDataInfo for obituaries failed"); return; } for(uint i = 0; i < obituaryEventCount; ++i) { var address = new IntPtr(obituaryEvents.ToInt64() + i * sizeof(udtParseDataObituary)); var data = (udtParseDataObituary)Marshal.PtrToStructure(address, typeof(udtParseDataObituary)); int totalSeconds = data.ServerTimeMs / 1000; int minutes = totalSeconds / 60; int seconds = totalSeconds % 60; var time = string.Format("{0}:{1}", minutes, seconds.ToString("00")); var attacker = Marshal.PtrToStringAnsi(data.AttackerName) ?? "N/A"; var target = Marshal.PtrToStringAnsi(data.TargetName) ?? "N/A"; var mod = Marshal.PtrToStringAnsi(data.MeanOfDeathName) ?? "N/A"; var item = new FragEventDisplayInfo(data.GameStateIndex, time, attacker, target, mod); info.FragEvents.Add(item); } }
private static void ExtractDemoInfo(udtParserContextRef context, uint demoIdx, ref DemoInfo info) { ExtractChatEvents(context, demoIdx, ref info); ExtractGameStateEvents(context, demoIdx, ref info); ExtractObituaries(context, demoIdx, ref info); }
private static void ExtractChatEvents(udtParserContextRef context, uint demoIdx, ref DemoInfo info) { uint chatEventCount = 0; IntPtr chatEvents = IntPtr.Zero; if(udtGetDemoDataInfo(context, demoIdx, udtParserPlugIn.Chat, ref chatEvents, ref chatEventCount) != udtErrorCode.None) { App.GlobalLogError("Calling udtGetDemoDataInfo for chat messages failed"); return; } for(uint i = 0; i < chatEventCount; ++i) { var address = new IntPtr(chatEvents.ToInt64() + i * sizeof(udtParseDataChat)); var data = (udtParseDataChat)Marshal.PtrToStructure(address, typeof(udtParseDataChat)); int totalSeconds = data.ServerTimeMs / 1000; int minutes = totalSeconds / 60; int seconds = totalSeconds % 60; var time = string.Format("{0}:{1}", minutes, seconds.ToString("00")); var player = Marshal.PtrToStringAnsi(data.PlayerNameNoCol) ?? "N/A"; var message = Marshal.PtrToStringAnsi(data.MessageNoCol) ?? "N/A"; var item = new ChatEventDisplayInfo(data.GameStateIndex, time, player, message); info.ChatEvents.Add(item); } }
private static void AddPlayers(DemoInfo info, udtParseDataGameState data, string space) { for(uint i = 0; i < data.PlayerCount; ++i) { var address = new IntPtr(data.Players.ToInt64() + i * sizeof(udtGameStatePlayerInfo)); var player = (udtGameStatePlayerInfo)Marshal.PtrToStructure(address, typeof(udtGameStatePlayerInfo)); var desc = space + "Client Number " + player.Index.ToString(); var startTime = FormatMinutesSecondsFromMs(player.FirstSnapshotTimeMs); var endTime = FormatMinutesSecondsFromMs(player.LastSnapshotTimeMs); var time = startTime + " - " + endTime; var name = SafeGetString(player.FirstName, "N/A"); var value = string.Format("{0}, {1}, team {2}", name, time, GetTeamName(player.FirstTeam)); info.Generic.Add(Tuple.Create(desc, value)); } }
private static void AddMatches(DemoInfo info, udtParseDataGameState data, string space) { var matchCount = data.MatchCount; if(matchCount == 0) { return; } info.Generic.Add(Tuple.Create(space + "Matches", data.MatchCount.ToString())); for(uint i = 0; i < matchCount; ++i) { var matchAddress = new IntPtr(data.Matches.ToInt64() + i * sizeof(udtMatchInfo)); var matchData = (udtMatchInfo)Marshal.PtrToStructure(matchAddress, typeof(udtMatchInfo)); var desc = space + "Match #" + (i + 1).ToString(); var start = FormatMinutesSecondsFromMs(matchData.MatchStartTimeMs); var end = FormatMinutesSecondsFromMs(matchData.MatchEndTimeMs); var val = start + " - " + end; info.Generic.Add(Tuple.Create(desc, val)); } }
private static void AddKeyValuePairs(DemoInfo info, udtParseDataGameState data, string space) { for(uint i = 0; i < data.KeyValuePairCount; ++i) { var address = new IntPtr(data.KeyValuePairs.ToInt64() + i * sizeof(udtGameStateKeyValuePair)); var kvPair = (udtGameStateKeyValuePair)Marshal.PtrToStructure(address, typeof(udtGameStateKeyValuePair)); var key = SafeGetString(kvPair.Name, "N/A"); var value = SafeGetString(kvPair.Value, "N/A"); info.Generic.Add(Tuple.Create(space + key, value)); } }
Page CreateDescriptionPage(Page demoPage, DemoInfo info) { if (info == null) return null; HtmlViewerPage result = new HtmlViewerPage(); AssignPageTitle(result, PageDescriptionName); result.ObtainSourceDelegate = () => { string htmlString = LoadDescriptionHtml(demoPage, ".html"); if (String.IsNullOrEmpty(htmlString)) return null; return new HtmlWebViewSource() { Html = ProcessHtmlString(htmlString) }; }; result.Icon = LoadPageIcon(DescriptionIcon); return result; }