Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Source/3rdPartyLibs/DiscordRpc.dll
Binary file not shown.
56 changes: 56 additions & 0 deletions Source/Discord/Discord.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?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>{1BEF94C6-3E4A-4E00-A148-216CDF6C464F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Discord</RootNamespace>
<AssemblyName>Discord</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</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>
</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>
</PropertyGroup>
<ItemGroup>
<Reference Include="DiscordRpc">
<HintPath>..\3rdPartyLibs\DiscordRpc.dll</HintPath>
</Reference>
<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="OrDiscord.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>CD $(SolutionDir)
CD ..\
XCOPY "Source\3rdPartyLibs\DiscordRpc.dll" "Program\" /S /Y</PostBuildEvent>
</PropertyGroup>
</Project>
53 changes: 53 additions & 0 deletions Source/Discord/OrDiscord.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System;
using System.Reflection;
using System.Security.Principal;
using System.Threading.Tasks;
using DiscordRpc;
/* DISCORD RICH PRESENCE
* In this file, you can specify the texts for the rich presence, and the client ID for Discord App.
* https://discord.com/rich-presence
* https://discord.com/developers/docs/rich-presence/how-to
*
* This class uses the following open-source library: https://github.com/Jimmacle/discord-rpc.net (DiscordRpc.dll)
*
*
*/
namespace Discord
{
public class OrDiscord
{
//private DiscordRpc.EventHandlers handlers; // EVENT HANDLERS
//private DiscordRpc.RichPresence presence; // DISCORD RICH PRESENCE PROPERTIES - List of properties: DiscordRpc.cs - Line 62
private string CLIENT_ID = "789239264336543814"; // APP CLIENT ID (Working Discord app, configured on the Discord side.)
private RichPresence Client;

public OrDiscord()
{
Client = new RichPresence();
Client.Initialize(CLIENT_ID);
this.UpdateStatus(false);
}
public void Dispose()
{
this.Client.Dispose();
}
private long getCurrentTime() //UNIX FORMAT - for DISCORD API needs.
{
TimeSpan timeSpan = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0);
return (long)timeSpan.TotalSeconds;

}

public void UpdateStatus(bool inGame, string startAt = "", string HeadTo = "")
{
if (inGame == true) {
Client.Update(new RichPresenceBuilder().WithState(startAt + " - " + HeadTo, "Driving train between:").WithArtwork("in-game-image", "Open Rails (MSTS) - Train Simulator", "orts-image", "").WithTimeInfo(DateTime.Now,null));
}
else{
Client.Update(new RichPresenceBuilder().WithState("", "In Main Menu").WithArtwork("orts-image", "Open Rails (MSTS) - Train Simulator","",""));
}

}

}
}
36 changes: 36 additions & 0 deletions Source/Discord/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;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Discord")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Discord")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1bef94c6-3e4a-4e00-a148-216cdf6c464f")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions Source/Menu/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
using System.Threading;
using System.Windows.Forms;
using Path = ORTS.Menu.Path;
using Discord;

namespace ORTS
{
Expand Down Expand Up @@ -113,6 +114,8 @@ internal string RunActivityProgram

GettextResourceManager catalog = new GettextResourceManager("Menu");

OrDiscord orDiscord = new OrDiscord();

#region Main Form
public MainForm()
{
Expand Down Expand Up @@ -260,6 +263,7 @@ orderby tool.Text
LoadFolderList();
Initialized = true;
}
orDiscord.UpdateStatus(false);
}

private void LoadDocuments(List<ToolStripItem> docs, string folderPath, string code = null)
Expand Down Expand Up @@ -603,6 +607,7 @@ void buttonStart_Click(object sender, EventArgs e)
if (SelectedTimetableTrain != null)
DialogResult = DialogResult.OK;
}
orDiscord.UpdateStatus(true, comboBoxStartAt.Text, comboBoxHeadTo.Text);
}

void buttonResume_Click(object sender, EventArgs e)
Expand Down
4 changes: 4 additions & 0 deletions Source/Menu/Menu.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Discord\Discord.csproj">
<Project>{1bef94c6-3e4a-4e00-a148-216cdf6c464f}</Project>
<Name>Discord</Name>
</ProjectReference>
<ProjectReference Include="..\Orts.ExternalDevices\Orts.ExternalDevices.csproj">
<Project>{0da86c52-ffb5-4cd6-a2c0-08f1610e6399}</Project>
<Name>Orts.ExternalDevices</Name>
Expand Down
14 changes: 12 additions & 2 deletions Source/ORTS.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.16
# Visual Studio Version 16
VisualStudioVersion = 16.0.31729.503
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RunActivity", "RunActivity\RunActivity.csproj", "{9BE44F64-417D-4AA6-AF4D-2A6A0CBC814D}"
EndProject
Expand Down Expand Up @@ -57,6 +57,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orts.ExternalDevices", "Ort
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher64", "Launcher64\Launcher64.csproj", "{B558F620-3BF7-4371-B7A1-9EE8D828DE21}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Discord", "Discord\Discord.csproj", "{1BEF94C6-3E4A-4E00-A148-216CDF6C464F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -281,6 +283,14 @@ Global
{B558F620-3BF7-4371-B7A1-9EE8D828DE21}.Release|Any CPU.Build.0 = Release|x64
{B558F620-3BF7-4371-B7A1-9EE8D828DE21}.Release|x64.ActiveCfg = Release|x64
{B558F620-3BF7-4371-B7A1-9EE8D828DE21}.Release|x64.Build.0 = Release|x64
{1BEF94C6-3E4A-4E00-A148-216CDF6C464F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1BEF94C6-3E4A-4E00-A148-216CDF6C464F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1BEF94C6-3E4A-4E00-A148-216CDF6C464F}.Debug|x64.ActiveCfg = Debug|Any CPU
{1BEF94C6-3E4A-4E00-A148-216CDF6C464F}.Debug|x64.Build.0 = Debug|Any CPU
{1BEF94C6-3E4A-4E00-A148-216CDF6C464F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1BEF94C6-3E4A-4E00-A148-216CDF6C464F}.Release|Any CPU.Build.0 = Release|Any CPU
{1BEF94C6-3E4A-4E00-A148-216CDF6C464F}.Release|x64.ActiveCfg = Release|Any CPU
{1BEF94C6-3E4A-4E00-A148-216CDF6C464F}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down