Elaztek Developer Hub
Blamite Game Engine - blam!  00406.12.10.23.1457.blamite
The core library for the Blamite Game Engine.
license_prompt.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 
7 
19 {
20 private:
21  bool show_license_key_failed = false;
22 
23 public:
27  void Draw()
28  {
29  char access_key[255];
30 
31  //License input
32  if (show)
33  {
34  //std::cout << "No access key present, prompting for key" << endl;
35  ImGui::OpenPopup(" Access Restricted");
37  {
38  static char key1[255] = "haloman30@CUND82443161A";
39  static char key2[255] = "00000000000000000000000";
40  static char key3[255] = "haloman30@CUND82443161A";
41  static char key4[255] = "haloman30@CUND82443161A";
42  static char key_generic[255] = "altkey";
43 
44  ImGui::Text("You are attempting to launch a development build of the engine.\nTo continue, you must input "
45  "your developer access key.\nThis can be found on the Gitlab repository.");
47 
48  ImGui::InputText("Access Key", access_key, IM_ARRAYSIZE(access_key));
49  ImGui::SameLine(); Blam::UI::ImGUI::Widgets::ShowHelpMarker("Please enter your Access key in this box, then "
50  "click 'Accept'. If the key is valid, the game will continue normally.");
51 
52  /*if (ImGui::Button("Accept", ImVec2(120, 0)))
53  {
54  string strAKey(access_key);
55  string strKey1(key1);
56  string strKey2(key2);
57  string strKey3(key3);
58  string strKey4(key4);
59  string strKeyGeneric(key_generic);
60 
61  //bool license_valid = (strAKey == strKey1);
62  //▄█▀ █▬█ █ ▀█▀
63  //▄█▀ █▄█ █▀
64 
65  //Here we check the inputted access code. It goes down the line to see if it matches one of them. Ideally we can get a more elegant system but for now this works enough
66  if (access_key == strKey1)
67  {
68  show_license_startup_prompt = false;
69  std::cout << "Valid key entered, starting game" << endl;
70  show_license_key_failed = false;
71  }
72  else
73  {
74  if (access_key == strKeyGeneric)
75  {
76  show_license_startup_prompt = false;
77  std::cout << "Valid key entered, starting game" << endl;
78  show_license_key_failed = false;
79  }
80  else
81  {
82  if (access_key == strKey2)
83  {
84  show_license_startup_prompt = false;
85  std::cout << "Valid key entered, starting game" << endl;
86  show_license_key_failed = false;
87  }
88  else
89  {
90  if (access_key == strKey3)
91  {
92  show_license_startup_prompt = false;
93  std::cout << "Valid key entered, starting game" << endl;
94  show_license_key_failed = false;
95  }
96  else
97  {
98  if (access_key == strKey4)
99  {
100  show_license_startup_prompt = false;
101  std::cout << "Valid key entered, starting game" << endl;
102  show_license_key_failed = false;
103  }
104  else
105  {
106  show_license_startup_prompt = false;
107  std::cout << "Invald key entered!" << endl;
108  show_license_key_failed = true;
109  }
110  }
111  }
112  }
113  }
114 
115  }*/
116 
117 
118  std::string strAKey(access_key);
119  std::string strKey1(key1);
120  std::string strKey2(key2);
121  std::string strKey3(key3);
122  std::string strKey4(key4);
123  std::string strKeyGeneric(key_generic);
124 
125  if (ImGui::Button("Accept", ImVec2(120, 0)))
126  {
127  //bool license_valid = (strAKey == strKey1);
128  //▄█▀ █▬█ █ ▀█▀
129  //▄█▀ █▄█ █▀
130 
131  //Here we check the inputted access code. It goes down the line to see if it matches one of them. Ideally we can get a more elegant system but for now this works enough
132  if (access_key == strKey1)
133  {
134  show = false;
135  Blam::Logger::LogEvent("Valid key entered, starting game");
136  show_license_key_failed = false;
137  }
138  else if (access_key == strKeyGeneric)
139  {
140  show = false;
141  Blam::Logger::LogEvent("Valid key entered, starting game");
142  show_license_key_failed = false;
143  }
144  else if (access_key == strKey2)
145  {
146  show = false;
147  Blam::Logger::LogEvent("Valid key entered, starting game");
148  show_license_key_failed = false;
149  }
150  else if (access_key == strKey3)
151  {
152  show = false;
153  Blam::Logger::LogEvent("Valid key entered, starting game");
154  show_license_key_failed = false;
155  }
156  else if (access_key == strKey4)
157  {
158  show = false;
159  Blam::Logger::LogEvent("Valid key entered, starting game");
160  show_license_key_failed = false;
161  }
162  else
163  {
164  show = false;
165  Blam::Logger::LogEvent("Invald key entered!");
166  show_license_key_failed = true;
167  }
168  }
169 
170  ImGui::EndPopup();
171  }
172  }
173 
174  if (show_license_key_failed)
175  {
176  ImGui::OpenPopup(" Wrong Access Key");
177 
179  {
181  ImGui::Text("Click 'Retry' to try again.");
182  ImGui::Text("Click 'Cancel' to exit the game.");
184 
185  if (ImGui::Button("Retry", ImVec2(120, 0)))
186  {
187  show_license_key_failed = false;
188  show = true;
189  }
190 
191  ImGui::SameLine();
192 
193  if (ImGui::Button("Cancel", ImVec2(120, 0)))
194  {
195  Blam::Logger::LogEvent("Exiting game.");
196  exit(0);
197  }
198 
199  ImGui::EndPopup();
200  }
201  }
202  }
203 };
Blam::Logger::LogEvent
BLAM void LogEvent(std::string message)
Logs a message to the log and/or console.
Definition: aliases.cpp:130
ImGui::EndPopup
IMGUI_API void EndPopup()
Definition: imgui.cpp:7675
logger.h
BlamImGuiWindow::show
bool show
Controls whether or not the group should be shown. May not be used in all groups.
Definition: imgui.h:34
ImGui::BeginPopupModal
IMGUI_API bool BeginPopupModal(const char *name, bool *p_open=NULL, ImGuiWindowFlags flags=0)
Definition: imgui.cpp:7647
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::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
NULL
Add a fourth parameter to bake specific font ranges NULL
Definition: README.txt:57
BlamImGuiWindow_LicensePrompt
Dialog to prompt for developer key authentication.
Definition: license_prompt.hpp:18
Blam::UI::ImGUI::Widgets::ShowHelpMarker
BLAM void ShowHelpMarker(const char *desc)
Shows a help indicator.
Definition: widgets.cpp:7
ImGui::OpenPopup
IMGUI_API void OpenPopup(const char *str_id)
Definition: imgui.cpp:7453
widgets.h
ImGui::Text
IMGUI_API void Text(const char *fmt,...) IM_FMTARGS(1)
Definition: imgui_widgets.cpp:238
BlamImGuiWindow_LicensePrompt::Draw
void Draw()
Displays the access key dialog.
Definition: license_prompt.hpp:27
IM_ARRAYSIZE
#define IM_ARRAYSIZE(_ARR)
Definition: imgui.h:75
ImGuiWindowFlags_AlwaysAutoResize
@ ImGuiWindowFlags_AlwaysAutoResize
Definition: imgui.h:720
imgui.h
ImGui::Separator
IMGUI_API void Separator()
Definition: imgui_widgets.cpp:1284
ImGui::Button
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0))
Definition: imgui_widgets.cpp:644