Skip to content

Commit

Permalink
Merge pull request #3 from CapitaineToinon/Dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
CapitaineToinon committed Mar 26, 2018
2 parents a162f08 + 77f8229 commit 942600d
Show file tree
Hide file tree
Showing 45 changed files with 2,027 additions and 1,377 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
/**
* Magic code original made in Visual Basic by Wulf2k :
* https://github.com/Wulf2k/DS-EventHook/blob/master/DS-EventHook/asm.vb
* Converts Assembly code to raw bytes
*/
using System;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Livesplit.DarkSouls100Tracker.Logic
namespace CapitaineToinon
{
class AssemblyGenerator
public class AssemblyGenerator
{
private byte[] bytes;
public Int32 pos;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F712B647-05A2-4A9A-8DA8-D88ABF5BF40F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AssemblyGenerator</RootNamespace>
<AssemblyName>AssemblyGenerator</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyGenerator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2005
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CapitaineToinon.AssemblyGenerator", "CapitaineToinon.AssemblyGenerator.csproj", "{F712B647-05A2-4A9A-8DA8-D88ABF5BF40F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F712B647-05A2-4A9A-8DA8-D88ABF5BF40F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F712B647-05A2-4A9A-8DA8-D88ABF5BF40F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F712B647-05A2-4A9A-8DA8-D88ABF5BF40F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F712B647-05A2-4A9A-8DA8-D88ABF5BF40F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {22ACC36E-D2B0-4FDD-90EA-37692D690E34}
EndGlobalSection
EndGlobal
36 changes: 36 additions & 0 deletions CapitaineToinon.AssemblyGenerator/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Les informations générales relatives à un assembly dépendent de
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
// associées à un assembly.
[assembly: AssemblyTitle("CapitaineToinon.AssemblyGenerator")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CapitaineToinon.AssemblyGenerator")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
[assembly: ComVisible(false)]

// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
[assembly: Guid("f712b647-05a2-4a9a-8da8-d88abf5bf40f")]

// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
//
// Version principale
// Version secondaire
// Numéro de build
// Révision
//
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
43 changes: 43 additions & 0 deletions CapitaineToinon.DarkSouls100Tracker.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2015
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DarkSoulsMemory", "CapitaineToinon.DarkSoulsMemory\DarkSoulsMemory.csproj", "{5DB2B8D5-6B2F-4615-950E-45596F8ADF61}"
ProjectSection(ProjectDependencies) = postProject
{F712B647-05A2-4A9A-8DA8-D88ABF5BF40F} = {F712B647-05A2-4A9A-8DA8-D88ABF5BF40F}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CapitaineToinon.AssemblyGenerator", "CapitaineToinon.AssemblyGenerator\CapitaineToinon.AssemblyGenerator.csproj", "{F712B647-05A2-4A9A-8DA8-D88ABF5BF40F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveSplit.DarkSouls100Tracker", "Livesplit.DarkSoulsTracker\LiveSplit.DarkSouls100Tracker.csproj", "{B709C220-558D-4040-986F-9C383B06CFB5}"
ProjectSection(ProjectDependencies) = postProject
{5DB2B8D5-6B2F-4615-950E-45596F8ADF61} = {5DB2B8D5-6B2F-4615-950E-45596F8ADF61}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5DB2B8D5-6B2F-4615-950E-45596F8ADF61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5DB2B8D5-6B2F-4615-950E-45596F8ADF61}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5DB2B8D5-6B2F-4615-950E-45596F8ADF61}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5DB2B8D5-6B2F-4615-950E-45596F8ADF61}.Release|Any CPU.Build.0 = Release|Any CPU
{F712B647-05A2-4A9A-8DA8-D88ABF5BF40F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F712B647-05A2-4A9A-8DA8-D88ABF5BF40F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F712B647-05A2-4A9A-8DA8-D88ABF5BF40F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F712B647-05A2-4A9A-8DA8-D88ABF5BF40F}.Release|Any CPU.Build.0 = Release|Any CPU
{B709C220-558D-4040-986F-9C383B06CFB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B709C220-558D-4040-986F-9C383B06CFB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B709C220-558D-4040-986F-9C383B06CFB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B709C220-558D-4040-986F-9C383B06CFB5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {85E8B6F2-319E-4639-BE93-12F5020F2EDF}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions CapitaineToinon.DarkSoulsMemory/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1"/>
</startup>
</configuration>
87 changes: 87 additions & 0 deletions CapitaineToinon.DarkSoulsMemory/DarkSoulsMemory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using System;
using System.Diagnostics;
using System.Threading;

namespace CapitaineToinon.DarkSoulsMemory
{
public class DarkSoulsMemory
{
public event EventHandler OnGameProgressUpdated;

private DarkSoulsProcess darksouls;
private Stopwatch stopwatch;
private Thread mainThread;
private CancellationTokenSource tokenSource;

public bool IsRunning
{
get
{
return (mainThread != null && mainThread.IsAlive);
}
}

public DarkSoulsMemory()
{
this.darksouls = new DarkSoulsProcess();
}

~DarkSoulsMemory()
{
this.darksouls.OnGameProgressUpdated -= Darksouls_OnGameProgressUpdated;
}

private void Darksouls_OnGameProgressUpdated(object sender, EventArgs e)
{
OnGameProgressUpdated?.Invoke(sender, e);
}

private void MainThreadFunction(ref CancellationTokenSource source)
{
long lastCall = 0;
stopwatch = new Stopwatch();
stopwatch.Start();

while (!source.Token.IsCancellationRequested)
{
if (stopwatch.ElapsedMilliseconds - lastCall > Constants.MAIN_THREAD_REFRESH_MS)
{
darksouls.Next();
lastCall = stopwatch.ElapsedMilliseconds;
}
}

// Thread got canceled
}

public void Start()
{
this.darksouls.OnGameProgressUpdated += Darksouls_OnGameProgressUpdated;
tokenSource = new CancellationTokenSource();
if (mainThread == null || !mainThread.IsAlive)
{
mainThread = new Thread(() => MainThreadFunction(ref tokenSource))
{
IsBackground = true
};
mainThread.Start();
}
}

public void Stop()
{
this.darksouls.OnGameProgressUpdated -= Darksouls_OnGameProgressUpdated;
if (tokenSource != null && !tokenSource.Token.IsCancellationRequested && mainThread.IsAlive)
{
tokenSource.Cancel();
}
}

public void Quit()
{
if (mainThread != null)
mainThread.Abort();
darksouls.Quit();
}
}
}
Loading

0 comments on commit 942600d

Please sign in to comment.