Skip to content

Commit

Permalink
Update example program
Browse files Browse the repository at this point in the history
  • Loading branch information
antonpup committed Jan 20, 2024
1 parent 32d0583 commit 143fc0e
Showing 1 changed file with 3 additions and 66 deletions.
69 changes: 3 additions & 66 deletions Dota2GSI Example program/Dota2GSI Example program/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using Dota2GSI;
using Dota2GSI.EventMessages;
using Microsoft.Win32;
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;

namespace Dota2GSI_Example_program
Expand All @@ -14,18 +11,13 @@ class Program

static void Main(string[] args)
{
CreateGsifile();
_gsl = new GameStateListener(4000);

Process[] pname = Process.GetProcessesByName("Dota2");
if (pname.Length == 0)
if (!_gsl.GenerateGSIConfigFile("Example"))
{
Console.WriteLine("Dota 2 is not running. Please start Dota 2.");
Console.ReadLine();
Environment.Exit(0);
Console.WriteLine("Could not generate GSI configuration file.");
}

_gsl = new GameStateListener(4000);

// There are many callbacks that can be subscribed.
// This example shows a few.
// _gsl.NewGameState += OnNewGameState; // `NewGameState` can be used alongside `GameEvent`. Just not in this example.
Expand Down Expand Up @@ -246,60 +238,5 @@ static void OnNewGameState(GameState gs)

Console.WriteLine("Press ESC to quit");
}

private static void CreateGsifile()
{
RegistryKey regKey = Registry.CurrentUser.OpenSubKey(@"Software\Valve\Steam");

if (regKey != null)
{
string gsifolder = regKey.GetValue("SteamPath") +
@"\steamapps\common\dota 2 beta\game\dota\cfg\gamestate_integration";
Directory.CreateDirectory(gsifolder);
string gsifile = gsifolder + @"\gamestate_integration_testGSI.cfg";
if (File.Exists(gsifile))
return;

string[] contentofgsifile =
{
"\"Dota 2 Integration Configuration\"",
"{",
" \"uri\" \"http://localhost:4000\"",
" \"timeout\" \"5.0\"",
" \"buffer\" \"0.1\"",
" \"throttle\" \"0.1\"",
" \"heartbeat\" \"30.0\"",
" \"data\"",
" {",
" \"auth\" \"1\"",
" \"provider\" \"1\"",
" \"map\" \"1\"",
" \"player\" \"1\"",
" \"hero\" \"1\"",
" \"abilities\" \"1\"",
" \"items\" \"1\"",
" \"events\" \"1\"",
" \"buildings\" \"1\"",
" \"league\" \"1\"",
" \"draft\" \"1\"",
" \"wearables\" \"1\"",
" \"minimap\" \"1\"",
" \"roshan\" \"1\"",
" \"couriers\" \"1\"",
" \"neutralitems\" \"1\"",
" }",
"}",

};

File.WriteAllLines(gsifile, contentofgsifile);
}
else
{
Console.WriteLine("Registry key for steam not found, cannot create Gamestate Integration file");
Console.ReadLine();
Environment.Exit(0);
}
}
}
}

0 comments on commit 143fc0e

Please sign in to comment.