Elaztek Developer Hub
Blamite Game Engine - blam!  00406.12.10.23.1457.blamite
The core library for the Blamite Game Engine.
discord_rpc_tester.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #include <time.h>
6 
9 #include "version_data.h"
10 
21 {
22 public:
23  void Draw()
24  {
25  if (!show)
26  {
27  return;
28  }
29 
30  ImGui::Begin("Discord Rich Presence Tester", &show, ImGuiWindowFlags_AlwaysAutoResize);
31 
32  static char state[127] = "Forge World";
33  static char details[127] = "Using the Forge";
34  static char large_img_key[31] = "infinity_icon_for_discord_rpc";
35  static char small_img_key[31] = "blam_icon3";
36  static char large_img_tooltip[127] = "sample tooltip for infinity icon";
37  static char small_img_tooltip[127] = ENGINE_VERSION;
38  static char party_id[127] = "derp";
39  static char join_secret[127] = "4b2fdce12f639de8bfa7e3591b71a0d679d7c93f";
40  static char spectate_secret[127] = "e7eb30d2ee025ed05c71ea495f770b76454ee4e0";
41  static int player_count = 1;
42  static int max_players = 8;
43  static int instance = 1;
44  static int64_t time_start = time(0);
45  static int time_end = 60;
46  static bool use_start_time = true;
47  static bool use_end_time = false;
48 
49  ImGui::Text("This tool is used to manually update Discord Rich Presence for testing purposes.\n");
50 
53  ImGui::InputText("Large Image Key", large_img_key, IM_ARRAYSIZE(large_img_key));
54  ImGui::InputText("Small Image Key", small_img_key, IM_ARRAYSIZE(small_img_key));
55  ImGui::InputText("Large Image Tooltip", large_img_key, IM_ARRAYSIZE(large_img_tooltip));
56  ImGui::InputText("Small Image Tooltip", small_img_key, IM_ARRAYSIZE(small_img_tooltip));
57  ImGui::InputText("Party ID", party_id, IM_ARRAYSIZE(party_id));
58  ImGui::InputText("Join Secret", join_secret, IM_ARRAYSIZE(join_secret));
59  ImGui::InputText("Spectate Secret", spectate_secret, IM_ARRAYSIZE(spectate_secret));
60  ImGui::InputInt("Player Count", &player_count);
61  ImGui::InputInt("Max Players", &max_players);
62  ImGui::Checkbox("Use Start Time", &use_start_time);
63  ImGui::Checkbox("Use End Time", &use_end_time);
64  ImGui::InputInt("End Time (seconds)", &time_end);
65  ImGui::InputInt("Instance", &instance);
66 
68 
69  if (ImGui::Button("Update", ImVec2(120, 0)))
70  {
71  DiscordRichPresence presence;
72  memset(&presence, 0, sizeof(presence));
73 
74  presence.state = state;
75  presence.details = details;
76 
77  if (use_start_time)
78  {
79  presence.startTimestamp = time(0);
80  }
81 
82  if (use_end_time)
83  {
84  presence.endTimestamp = time(0) + time_end;
85  }
86 
87  presence.largeImageKey = large_img_key;
88  presence.smallImageKey = small_img_key;
89  presence.largeImageText = large_img_tooltip;
90  presence.smallImageText = small_img_tooltip;
91  presence.partyId = party_id;
92  presence.partySize = player_count;
93  presence.partyMax = max_players;
94  presence.joinSecret = join_secret;
95  presence.spectateSecret = spectate_secret;
96  presence.instance = instance;
98  }
99 
101 
102  if (ImGui::Button("DiscordReady", ImVec2(120, 0)))
103  {
105  }
106 
107  ImGui::SameLine();
108 
109  if (ImGui::Button("DiscordError", ImVec2(120, 0)))
110  {
112  }
113 
114  ImGui::SameLine();
115 
116  if (ImGui::Button("DiscordDisconnected", ImVec2(120, 0)))
117  {
119  }
120 
121  if (ImGui::Button("DiscordJoinGame", ImVec2(120, 0)))
122  {
124  }
125 
126  ImGui::SameLine();
127 
128  if (ImGui::Button("DiscordSpectateGame", ImVec2(120, 0)))
129  {
131  }
132 
133  ImGui::SameLine();
134 
135  if (ImGui::Button("DiscordJoinRequest", ImVec2(120, 0)))
136  {
138  }
139 
140  ImGui::End();
141  }
142 };
ImGui::Checkbox
IMGUI_API bool Checkbox(const char *label, bool *v)
Definition: imgui_widgets.cpp:974
BlamImGuiWindow::show
bool show
Controls whether or not the group should be shown. May not be used in all groups.
Definition: imgui.h:34
BlamImGuiWindow_DiscordRPCTester
Class for the Discord Rich Presence test dialog.
Definition: discord_rpc_tester.hpp:20
version_data.h
Blam::DiscordRPC::DummyEvent
BLAM void DummyEvent(int id)
Triggers a dummy event.
Definition: discord_rpc.cpp:130
ImGui::InputText
IMGUI_API bool InputText(const char *label, char *buf, size_t buf_size, ImGuiInputTextFlags flags=0, ImGuiInputTextCallback callback=NULL, void *user_data=NULL)
Definition: imgui_widgets.cpp:3068
ImGui::End
IMGUI_API void End()
Definition: imgui.cpp:6016
BlamImGuiWindow_DiscordRPCTester::Draw
void Draw()
Draws the contents of the group.
Definition: discord_rpc_tester.hpp:23
ImGui::SameLine
IMGUI_API void SameLine(float offset_from_start_x=0.0f, float spacing=-1.0f)
Definition: imgui.cpp:7147
BlamImGuiWindow
Class representing an ImGUI window.
Definition: imgui.h:31
ImVec2
Definition: imgui.h:179
ImGui::Begin
IMGUI_API bool Begin(const char *name, bool *p_open=NULL, ImGuiWindowFlags flags=0)
Definition: imgui.cpp:5397
ENGINE_VERSION
#define ENGINE_VERSION
Definition: version_data.h:31
discord_rpc.h
ImGui::Text
IMGUI_API void Text(const char *fmt,...) IM_FMTARGS(1)
Definition: imgui_widgets.cpp:238
int64_t
long long int64_t
Definition: stdint.h:14
state
sock planetquake com All rights reserved Quake III Arena is a registered trademark of id Inc This level may be electronically distributed only at NO CHARGE to the recipient in its current state
Definition: chiropteraDM.txt:94
IM_ARRAYSIZE
#define IM_ARRAYSIZE(_ARR)
Definition: imgui.h:75
engine_definitions.h
ImGuiWindowFlags_AlwaysAutoResize
@ ImGuiWindowFlags_AlwaysAutoResize
Definition: imgui.h:720
imgui.h
ImGui::Separator
IMGUI_API void Separator()
Definition: imgui_widgets.cpp:1284
Blam::DiscordRPC::UpdatePresence
BLAM void UpdatePresence(DiscordRichPresence discordPresence)
Update the current Discord presence.
Definition: discord_rpc.cpp:103
ImGui::Button
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0))
Definition: imgui_widgets.cpp:644
ImGui::InputInt
IMGUI_API bool InputInt(const char *label, int *v, int step=1, int step_fast=100, ImGuiInputTextFlags flags=0)
Definition: imgui_widgets.cpp:3031
details
const char * details
Definition: error_notice.cpp:17