Skip to content

Commit

Permalink
Portal Demo Timer
Browse files Browse the repository at this point in the history
Adjusted stuff nekz told me and added a demo time sum tool
  • Loading branch information
Traderain committed Nov 22, 2016
1 parent 6aac886 commit ced28ba
Show file tree
Hide file tree
Showing 12 changed files with 404 additions and 29 deletions.
Binary file modified .vs/VolvoWrench/v14/.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion VolvoWrench.sln.DotSettings.user
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeStyle/LiveTemplatesUseVar/PreferVar/@EntryValue">False</s:Boolean>

<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer&gt;&#xD;
&lt;Assembly Path="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Drawing.dll" /&gt;&#xD;
&lt;/AssemblyExplorer&gt;</s:String></wpf:ResourceDictionary>
4 changes: 2 additions & 2 deletions VolvoWrench/DG/Roadmap.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- Portal 2 Demo Parser
- Statefile decompressor
- Statefile decompressor
- Demo doctor fix
- Statistics : Nearly done
- HTML Display instead of the richtextbox
1 change: 1 addition & 0 deletions VolvoWrench/Demo stuff/L4D2Branch/L4D2BranchParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public L4D2BranchDemoInfo Parse(string filename)
else
{
info.PortalDemoInfo = PortalStuff.DemoParser.ParseDemo(filename);

}
return info;
}
Expand Down
110 changes: 110 additions & 0 deletions VolvoWrench/Demo stuff/L4D2Branch/PortalStuff/Demo Timer.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

108 changes: 108 additions & 0 deletions VolvoWrench/Demo stuff/L4D2Branch/PortalStuff/Demo Timer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace VolvoWrench.Demo_stuff.L4D2Branch.PortalStuff
{
public partial class DemoTimer : Form
{
public List<DemoDescription> FileList;
public int TickSum;
public TimeSpan TimeSum;

public DemoTimer()
{
InitializeComponent();
FileList = new List<DemoDescription>();
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
AllowDrop = true;
}

private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog of = new OpenFileDialog();
of.Filter = @"Demo files (.dem) | *.dem";
of.Multiselect = true;
if (of.ShowDialog() == DialogResult.OK)
{
UpdateDgv(of.FileNames.Where(x => File.Exists(x) && Path.GetExtension(x) == ".dem").ToArray());
}
}

private void DemoTimer_DragDrop(object sender, DragEventArgs e)
{
var dropfiles = ((string[])e.Data.GetData(DataFormats.FileDrop)).Where(x => File.Exists(x) && Path.GetExtension(x) == ".dem").ToArray();
UpdateDgv(dropfiles);
}

private void DemoTimer_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;
}

public void UpdateDgv(string[] files)
{
TickSum = 0;
TimeSum = TimeSpan.FromSeconds(0);
FileList = new List<DemoDescription>();
foreach (var s in files)
{
var r = CrossDemoParser.Parse(s);
if (r.Type == Parseresult.Portal || r.Type == Parseresult.L4D2Branch)
{
var dd = new DemoDescription
{
File = Path.GetFileNameWithoutExtension(s),
Map = r.L4D2BranchInfo.Header.GameDirectory + "/" + r.L4D2BranchInfo.PortalDemoInfo.MapName,
Player = r.L4D2BranchInfo.PortalDemoInfo.PlayerName,
TotalTicks = r.L4D2BranchInfo.PortalDemoInfo.TotalTicks.ToString(),
StartTick = r.L4D2BranchInfo.PortalDemoInfo.StartAdjustmentTick + "(" + r.L4D2BranchInfo.PortalDemoInfo.StartAdjustmentType + ")",
StopTick = r.L4D2BranchInfo.PortalDemoInfo.EndAdjustmentTick + "(" + r.L4D2BranchInfo.PortalDemoInfo.EndAdjustmentType + ")",
AdjustedTicks = r.L4D2BranchInfo.PortalDemoInfo.AdjustedTicks.ToString(),
Time = TimeSpan.FromSeconds(r.L4D2BranchInfo.PortalDemoInfo.AdjustedTicks*(1f/((int)Math.Ceiling((double) r.L4D2BranchInfo.Header.PlaybackFrames/r.L4D2BranchInfo.Header.PlaybackTime)))).ToString("g")
};
TickSum += r.L4D2BranchInfo.PortalDemoInfo.AdjustedTicks;
TimeSum += TimeSpan.FromSeconds(r.L4D2BranchInfo.PortalDemoInfo.AdjustedTicks*(1f/((int)Math.Ceiling((double) r.L4D2BranchInfo.Header.PlaybackFrames/r.L4D2BranchInfo.Header.PlaybackTime))));
FileList.Add(dd);
}
}
var k = new DemoDescription();
k.File = "- TOTAL -";
k.AdjustedTicks = TickSum.ToString();
k.Time = TimeSum.ToString("g");
FileList.Add(k);
dataGridView1.DataSource = FileList.Select(x => new {File = x.File,
Map = x.Map,
Player = x.Player,
TotalTicks = x.TotalTicks,
StartTick = x.StartTick,
StopTick = x.StopTick,
AdjustedTicks = x.AdjustedTicks,
Time = x.Time}).ToArray();
for (var i = 0; i < dataGridView1.Columns.Count; i++)
{
dataGridView1.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns[i].ReadOnly = true;
}
}
}

public struct DemoDescription
{
public string File;
public string Map;
public string Player;
public string TotalTicks;
public string StartTick;
public string StopTick;
public string AdjustedTicks;
public string Time;
}
}
123 changes: 123 additions & 0 deletions VolvoWrench/Demo stuff/L4D2Branch/PortalStuff/Demo Timer.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,25 @@ public string PlayerName
set;
}

public List<KeyValuePair<string, int>> Flags
{
get;
set;
}

public int SignOnLen
{
get;
set;
}

public GameHandler()
protected GameHandler()
{
this.MapStartAdjustType = "Map Start";
this.MapEndAdjustType = "Map End";
this.Maps = new List<string>();
this.Flags = new List<KeyValuePair<string, int>>();

}

public static GameHandler getGameHandler(string gameDir, string map)
Expand Down
Loading

0 comments on commit ced28ba

Please sign in to comment.