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 dist/1.4/Assemblies/RimRPC.dll
Binary file not shown.
30 changes: 17 additions & 13 deletions dist/About/About.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>

<ModMetaData>
<name>RimRPC - RichPresence</name>
<author>Weilbyte</author>
<supportedVersions>
<li>1.0</li>
<li>1.1</li>
<li>1.2</li>
<li>1.3</li>
</supportedVersions>
<description>Discord Rich Presence for RimWorld!
1.2 support is here!</description>
<url></url>
<packageId>weilbyte.rimrpc</packageId>
</ModMetaData>
<name>RimRPC - RichPresence</name>
<author>Weilbyte</author>
<supportedVersions>
<li>1.0</li>
<li>1.1</li>
<li>1.2</li>
<li>1.3</li>
<li>1.4</li>
</supportedVersions>
<description>
Discord Rich Presence for RimWorld!
1.4 support is here!
</description>
<url>https://github.com/Weilbyte/RWRichPresence</url>
<packageId>weilbyte.rimrpc</packageId>
</ModMetaData>
25 changes: 14 additions & 11 deletions dist/About/LoadFolders.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<loadFolders>
<v1.1>
<li>1.1</li>
</v1.1>
<v1.2>
<li>1.2</li>
</v1.2>
<v1.3>
<li>1.3</li>
</v1.3>
</loadFolders>
<loadFolders>
<v1.1>
<li>1.1</li>
</v1.1>
<v1.2>
<li>1.2</li>
</v1.2>
<v1.3>
<li>1.3</li>
</v1.3>
<v1.4>
<li>1.4</li>
</v1.4>
</loadFolders>
10 changes: 10 additions & 0 deletions dist/Languages/English/Keyed/RimRPC.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,25 @@
<RPC_CategoryLabel>RimRPC</RPC_CategoryLabel>
<RPC_ColonyLabel>Colony name</RPC_ColonyLabel>
<RPC_ColonistCountLabel>Colonist count</RPC_ColonistCountLabel>
<RPC_BiomeLabel>Current biome</RPC_BiomeLabel>
<RPC_YearLabel>Current year</RPC_YearLabel>
<RPC_YearShortLabel>Shorten year text</RPC_YearShortLabel>
<RPC_QuadrumLabel>Current quadrum</RPC_QuadrumLabel>
<RPC_DayLabel>Current day</RPC_DayLabel>
<RPC_HourLabel>Hour of current day</RPC_HourLabel>
<RPC_TimeLabel>Game session length (Requires restart)</RPC_TimeLabel>
<RPC_UpdateLabel>Manually update presence</RPC_UpdateLabel>

<CustomTopCheckbox>Custom text (Top)</CustomTopCheckbox>
<CustomBottomCheckbox>Custom text (Bottom)</CustomBottomCheckbox>
<CustomTopLabel>Text</CustomTopLabel>
<CustomBottomLabel>Text </CustomBottomLabel>

<RPC_MainMenu>Main Menu</RPC_MainMenu>
<RPC_Day>Day</RPC_Day>
<RPC_Colonists>Colonists</RPC_Colonists>
<RPC_Hour>h</RPC_Hour>
<RPC_Years>Year</RPC_Years>
<RPC_ShortYears>y</RPC_ShortYears>
<RPC_Playing>Playing!</RPC_Playing>
</LanguageData>
28 changes: 28 additions & 0 deletions dist/Languages/Russian/Keyed/RimRPC.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8" ?>
<LanguageData>
<RPC_CategoryLabel>RimRPC</RPC_CategoryLabel>
<RPC_ColonyLabel>Отображение названия колонии</RPC_ColonyLabel>
<RPC_ColonistCountLabel>Отоброжение количества колонистов</RPC_ColonistCountLabel>
<RPC_BiomeLabel>Отображение биома</RPC_BiomeLabel>
<RPC_YearLabel>Отображение года</RPC_YearLabel>
<RPC_YearShortLabel>Сокращать отображение года</RPC_YearShortLabel>
<RPC_QuadrumLabel>Отображение квадрума</RPC_QuadrumLabel>
<RPC_DayLabel>Отображение дня</RPC_DayLabel>
<RPC_HourLabel>Отображение часа</RPC_HourLabel>
<RPC_TimeLabel>Длина игровой сессии (Требуется рестарт)</RPC_TimeLabel>
<RPC_UpdateLabel>Принудительное обновление RPC</RPC_UpdateLabel>

<CustomTopCheckbox>Произвольный текст (Вверх)</CustomTopCheckbox>
<CustomBottomCheckbox>Произвольный текст (Низ)</CustomBottomCheckbox>
<CustomTopLabel>Текст</CustomTopLabel>
<CustomBottomLabel>Текст</CustomBottomLabel>

<RPC_MainMenu>В главном меню</RPC_MainMenu>
<RPC_Day>День</RPC_Day>
<RPC_Biome>Биом</RPC_Biome>
<RPC_Colonists>колонистов</RPC_Colonists>
<RPC_Hour>ч</RPC_Hour>
<RPC_Years>Год</RPC_Years>
<RPC_ShortYears>г</RPC_ShortYears>
<RPC_Playing>Играю!</RPC_Playing>
</LanguageData>
32 changes: 32 additions & 0 deletions src/Details.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Verse;

namespace RimRPC
{
internal class Details
{
public static string GetDetails(string[] args)
{
var _colonyname = args[0];
var _colonistnumber = args[1];

if (RWRPCMod.Settings.RpcCustomTop)
return RWRPCMod.Settings.RpcCustomTopText;

if (RWRPCMod.Settings.RpcColony)
{
if (RWRPCMod.Settings.RpcColonistCount)
{
return _colonyname + " (" + _colonistnumber + ")";
}
return _colonyname;
}

if (RWRPCMod.Settings.RpcColonistCount)
{
return _colonistnumber + " RPC_Colonists".Translate();
}

return null;
}
}
}
78 changes: 28 additions & 50 deletions src/DiscordRPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ namespace RimRPC
{
internal class DiscordRPC
{
//DLL Imports here. Make sure the discord-rpc.dll is in the game's mono folder or else the game will crash.
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void ReadyCallback();

Expand All @@ -22,65 +21,44 @@ internal class DiscordRPC
public delegate void SpectateCallback(string secret);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void RequestCallback(DiscordRPC.JoinRequest request);
public delegate void RequestCallback(JoinRequest request);

public struct EventHandlers
{
public DiscordRPC.ReadyCallback readyCallback;

public DiscordRPC.DisconnectedCallback disconnectedCallback;

public DiscordRPC.ErrorCallback errorCallback;

public DiscordRPC.JoinCallback joinCallback;

public DiscordRPC.SpectateCallback spectateCallback;

public DiscordRPC.RequestCallback requestCallback;
public ReadyCallback ReadyCallback;
public DisconnectedCallback DisconnectedCallback;
public ErrorCallback ErrorCallback;
public JoinCallback JoinCallback;
public SpectateCallback SpectateCallback;
public RequestCallback RequestCallback;
}

[Serializable]
public struct RichPresence
{
public string state;

public string details;

public long startTimestamp;

public long endTimestamp;

public string largeImageKey;

public string largeImageText;

public string smallImageKey;

public string smallImageText;

public string partyId;

public int partySize;

public int partyMax;

public string matchSecret;

public string joinSecret;

public string spectateSecret;

public bool instance;
public string State;
public string Details;
public long StartTimestamp;
public long EndTimestamp;
public string LargeImageKey;
public string LargeImageText;
public string SmallImageKey;
public string SmallImageText;
public string PartyId;
public int PartySize;
public int PartyMax;
public string MatchSecret;
public string JoinSecret;
public string SpectateSecret;
public bool Instance;
}

[Serializable]
public struct JoinRequest
{
public string userId;

public string username;

public string avatar;
public string UserId;
public string Username;
public string Avatar;
}

public enum Reply
Expand All @@ -91,7 +69,7 @@ public enum Reply
}

[DllImport("0discord-rpc", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Discord_Initialize")]
public static extern void Initialize(string applicationId, ref DiscordRPC.EventHandlers handlers, bool autoRegister, string optionalSteamId);
public static extern void Initialize(string applicationId, ref EventHandlers handlers, bool autoRegister, string optionalSteamId);

[DllImport("0discord-rpc", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Discord_Shutdown")]
public static extern void Shutdown();
Expand All @@ -100,9 +78,9 @@ public enum Reply
public static extern void RunCallbacks();

[DllImport("0discord-rpc", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Discord_UpdatePresence")]
public static extern void UpdatePresence(ref DiscordRPC.RichPresence presence);
public static extern void UpdatePresence(ref RichPresence presence);

[DllImport("0discord-rpc", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Discord_Respond")]
public static extern void Respond(string userId, DiscordRPC.Reply reply);
public static extern void Respond(string userId, Reply reply);
}
}
10 changes: 6 additions & 4 deletions src/MapCompHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace RimRPC
{
internal class MapCompHandler : MapComponent
{
private int cooldown = 0;
private int _cooldown;

public MapCompHandler(Map map) : base(map)
{
Expand All @@ -13,12 +13,14 @@ public MapCompHandler(Map map) : base(map)

public override void MapComponentTick()
{
cooldown = cooldown + 1;
if (cooldown > 1250) //Update is called every 1250 ticks (Twice an in-game hour, or every 20.5 seconds real-time)
_cooldown++;

if (_cooldown > 1250) //Update is called every 1250 ticks (Twice an in-game hour, or every 20.5 seconds real-time)
{
StateHandler.PushState(map);
cooldown = 0;
_cooldown = 0;
}

base.MapComponentTick();
}
}
Expand Down
15 changes: 5 additions & 10 deletions src/MapCompInjector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@ internal class MapCompInjector : MonoBehaviour
public void FixedUpdate()
{
if (Current.ProgramState != ProgramState.Playing)
{
return;
}
else
{
foreach (var map in Find.Maps.Where(m => m.GetComponent<MapCompHandler>() == null))
{
map.components.Add(new MapCompHandler(map));
Log.Message("RichPresence :: Injected handler to existing map!");
}

Destroy(this);
foreach (var map in Find.Maps.Where(m => m.GetComponent<MapCompHandler>() == null))
{
map.components.Add(new MapCompHandler(map));
}

Destroy(this);
}
}
}
Loading