Blamite Game Engine - Blam (Core)
discord_rpc_tester.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <time.h>
4 
6 #include "../../debug_ui.h"
8 #include "version_data.h"
9 
10 namespace Blam::DebugUI::Windows
11 {
22  {
23  public:
28 
33 
34  void Draw()
35  {
36  //discord rich presence ui
37  if (show)
38  {
39  //ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
40 
41  //ImGui::PopStyleVar();
42 
43  ImGui::Begin("Discord Rich Presence Tester", &show, ImGuiWindowFlags_AlwaysAutoResize);
44 
45  static char state[127] = "Forge World";
46  static char details[127] = "Using the Forge";
47  static char large_img_key[31] = "infinity_icon_for_discord_rpc";
48  static char small_img_key[31] = "blam_icon3";
49  static char large_img_tooltip[127] = "sample tooltip for infinity icon";
50  static char small_img_tooltip[127] = ENGINE_VERSION;
51  static char party_id[127] = "derp";
52  static char join_secret[127] = "4b2fdce12f639de8bfa7e3591b71a0d679d7c93f";
53  static char spectate_secret[127] = "e7eb30d2ee025ed05c71ea495f770b76454ee4e0";
54  static int player_count = 1;
55  static int max_players = 8;
56  static int instance = 1;
57  static int64_t time_start = time(0);
58  static int time_end = 60;
59  static bool use_start_time = true;
60  static bool use_end_time = false;
61 
62 
63  ImGui::Text("This tool is used to manually update Discord Rich Presence for testing purposes.\n");
64 
65  ImGui::InputText("State", state, IM_ARRAYSIZE(state));
66  ImGui::InputText("Details", details, IM_ARRAYSIZE(details));
67  ImGui::InputText("Large Image Key", large_img_key, IM_ARRAYSIZE(large_img_key));
68  ImGui::InputText("Small Image Key", small_img_key, IM_ARRAYSIZE(small_img_key));
69  ImGui::InputText("Large Image Tooltip", large_img_key, IM_ARRAYSIZE(large_img_tooltip));
70  ImGui::InputText("Small Image Tooltip", small_img_key, IM_ARRAYSIZE(small_img_tooltip));
71  ImGui::InputText("Party ID", party_id, IM_ARRAYSIZE(party_id));
72  ImGui::InputText("Join Secret", join_secret, IM_ARRAYSIZE(join_secret));
73  ImGui::InputText("Spectate Secret", spectate_secret, IM_ARRAYSIZE(spectate_secret));
74  ImGui::InputInt("Player Count", &player_count);
75  ImGui::InputInt("Max Players", &max_players);
76  ImGui::Checkbox("Use Start Time", &use_start_time);
77  ImGui::Checkbox("Use End Time", &use_end_time);
78  ImGui::InputInt("End Time (seconds)", &time_end);
79  ImGui::InputInt("Instance", &instance);
80  //ImGui::SameLine(); ShowHelpMarker("Input the IP address to test in this box.\nYou may use a DNS host (dns.domain.com) or a direct IP (1.2.3.4)");
81 
82  ImGui::Separator();
83  if (ImGui::Button("Update", ImVec2(120, 0)))
84  {
85  DiscordRichPresence presence;
86  memset(&presence, 0, sizeof(presence));
87 
88  presence.state = state;
89  presence.details = details;
90  if (use_start_time)
91  {
92  presence.startTimestamp = time(0);
93  }
94  if (use_end_time)
95  {
96  presence.endTimestamp = time(0) + time_end;
97  }
98  presence.largeImageKey = large_img_key;
99  presence.smallImageKey = small_img_key;
100  presence.largeImageText = large_img_tooltip;
101  presence.smallImageText = small_img_tooltip;
102  presence.partyId = party_id;
103  presence.partySize = player_count;
104  presence.partyMax = max_players;
105  presence.joinSecret = join_secret;
106  presence.spectateSecret = spectate_secret;
107  presence.instance = instance;
109  }
110  ImGui::Separator();
111 
112  if (ImGui::Button("DiscordReady", ImVec2(120, 0)))
113  {
115  }
116  ImGui::SameLine();
117  if (ImGui::Button("DiscordError", ImVec2(120, 0)))
118  {
120  }
121  ImGui::SameLine();
122  if (ImGui::Button("DiscordDisconnected", ImVec2(120, 0)))
123  {
125  }
126 
127  if (ImGui::Button("DiscordJoinGame", ImVec2(120, 0)))
128  {
130  }
131  ImGui::SameLine();
132  if (ImGui::Button("DiscordSpectateGame", ImVec2(120, 0)))
133  {
135  }
136  ImGui::SameLine();
137  if (ImGui::Button("DiscordJoinRequest", ImVec2(120, 0)))
138  {
140  }
141 
142  ImGui::End();
143 
144  }
145  }
146  };
147 }
Blam::DebugUI::Windows::DiscordRPCTester::Draw
void Draw()
Draws the contents of the group.
Definition: discord_rpc_tester.hpp:34
m_discord.h
details
LPSTR details
Definition: error_notice.cpp:15
version_data.h
Blam::DiscordRPC::DummyEvent
BLAM void DummyEvent(int id)
Triggers a dummy event.
Definition: discord.cpp:129
ENGINE_VERSION
#define ENGINE_VERSION
Definition: version_data.h:19
Blam::DebugUI::Windows::DiscordRPCTester::~DiscordRPCTester
~DiscordRPCTester()
Empty destructor.
Definition: discord_rpc_tester.hpp:32
Blam::DebugUI::ImGUIDrawingGroup::show
bool show
Controls whether or not the group should be shown. May not be used in all groups.
Definition: debug_ui.h:441
Blam::DebugUI::ImGUIDrawingGroup
Class representing an ImGUI drawing group/draw list item.
Definition: debug_ui.h:408
Blam::DebugUI::Windows::DiscordRPCTester
Class for the Discord Rich Presence test dialog.
Definition: discord_rpc_tester.hpp:21
Blam::DebugUI::Windows::DiscordRPCTester::DiscordRPCTester
DiscordRPCTester()
Empty constructor.
Definition: discord_rpc_tester.hpp:27
engine_definitions.h
Blam::DebugUI::Windows
Legacy namespace to contain data for the legacy ImGUI console.
Definition: debug_ui.h:493
Text
@ Text
Master text object that wraps around both BitmapText and DWText.
Definition: render_stack.h:73
Blam::DiscordRPC::UpdatePresence
BLAM void UpdatePresence(DiscordRichPresence discordPresence)
Update the current Discord presence.
Definition: discord.cpp:102