Elaztek Developer Hub
Blamite Game Engine - blam!  00423.10.27.24.0533.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 
17 {
18 private:
19  bool show_license_key_failed = false;
20 
21 public:
25  void Draw()
26  {
27  char access_key[255];
28 
29  //License input
30  if (show)
31  {
32  //std::cout << "No access key present, prompting for key" << endl;
33  ImGui::OpenPopup(" Access Restricted");
35  {
36  static char key1[255] = "haloman30@CUND82443161A";
37  static char key2[255] = "00000000000000000000000";
38  static char key3[255] = "haloman30@CUND82443161A";
39  static char key4[255] = "haloman30@CUND82443161A";
40  static char key_generic[255] = "altkey";
41 
42  ImGui::Text("You are attempting to launch a development build of the engine.\nTo continue, you must input "
43  "your developer access key.\nThis can be found on the Gitlab repository.");
45 
46  ImGui::InputText("Access Key", access_key, IM_ARRAYSIZE(access_key));
47  ImGui::SameLine(); Blam::UI::ImGUI::Widgets::ShowHelpMarker("Please enter your Access key in this box, then "
48  "click 'Accept'. If the key is valid, the game will continue normally.");
49 
50  /*if (ImGui::Button("Accept", ImVec2(120, 0)))
51  {
52  string strAKey(access_key);
53  string strKey1(key1);
54  string strKey2(key2);
55  string strKey3(key3);
56  string strKey4(key4);
57  string strKeyGeneric(key_generic);
58 
59  //bool license_valid = (strAKey == strKey1);
60  //▄█▀ █▬█ █ ▀█▀
61  //▄█▀ █▄█ █▀
62 
63  //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
64  if (access_key == strKey1)
65  {
66  show_license_startup_prompt = false;
67  std::cout << "Valid key entered, starting game" << endl;
68  show_license_key_failed = false;
69  }
70  else
71  {
72  if (access_key == strKeyGeneric)
73  {
74  show_license_startup_prompt = false;
75  std::cout << "Valid key entered, starting game" << endl;
76  show_license_key_failed = false;
77  }
78  else
79  {
80  if (access_key == strKey2)
81  {
82  show_license_startup_prompt = false;
83  std::cout << "Valid key entered, starting game" << endl;
84  show_license_key_failed = false;
85  }
86  else
87  {
88  if (access_key == strKey3)
89  {
90  show_license_startup_prompt = false;
91  std::cout << "Valid key entered, starting game" << endl;
92  show_license_key_failed = false;
93  }
94  else
95  {
96  if (access_key == strKey4)
97  {
98  show_license_startup_prompt = false;
99  std::cout << "Valid key entered, starting game" << endl;
100  show_license_key_failed = false;
101  }
102  else
103  {
104  show_license_startup_prompt = false;
105  std::cout << "Invald key entered!" << endl;
106  show_license_key_failed = true;
107  }
108  }
109  }
110  }
111  }
112 
113  }*/
114 
115 
116  std::string strAKey(access_key);
117  std::string strKey1(key1);
118  std::string strKey2(key2);
119  std::string strKey3(key3);
120  std::string strKey4(key4);
121  std::string strKeyGeneric(key_generic);
122 
123  if (ImGui::Button("Accept", ImVec2(120, 0)))
124  {
125  //bool license_valid = (strAKey == strKey1);
126  //▄█▀ █▬█ █ ▀█▀
127  //▄█▀ █▄█ █▀
128 
129  //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
130  if (access_key == strKey1)
131  {
132  show = false;
133  Blam::Logger::LogEvent("Valid key entered, starting game");
134  show_license_key_failed = false;
135  }
136  else if (access_key == strKeyGeneric)
137  {
138  show = false;
139  Blam::Logger::LogEvent("Valid key entered, starting game");
140  show_license_key_failed = false;
141  }
142  else if (access_key == strKey2)
143  {
144  show = false;
145  Blam::Logger::LogEvent("Valid key entered, starting game");
146  show_license_key_failed = false;
147  }
148  else if (access_key == strKey3)
149  {
150  show = false;
151  Blam::Logger::LogEvent("Valid key entered, starting game");
152  show_license_key_failed = false;
153  }
154  else if (access_key == strKey4)
155  {
156  show = false;
157  Blam::Logger::LogEvent("Valid key entered, starting game");
158  show_license_key_failed = false;
159  }
160  else
161  {
162  show = false;
163  Blam::Logger::LogEvent("Invald key entered!");
164  show_license_key_failed = true;
165  }
166  }
167 
168  ImGui::EndPopup();
169  }
170  }
171 
172  if (show_license_key_failed)
173  {
174  ImGui::OpenPopup(" Wrong Access Key");
175 
177  {
179  ImGui::Text("Click 'Retry' to try again.");
180  ImGui::Text("Click 'Cancel' to exit the game.");
182 
183  if (ImGui::Button("Retry", ImVec2(120, 0)))
184  {
185  show_license_key_failed = false;
186  show = true;
187  }
188 
189  ImGui::SameLine();
190 
191  if (ImGui::Button("Cancel", ImVec2(120, 0)))
192  {
193  Blam::Logger::LogEvent("Exiting game.");
194  exit(0);
195  }
196 
197  ImGui::EndPopup();
198  }
199  }
200  }
201 };
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
BlamImGuiWindow_LicensePrompt
Dialog to prompt for developer key authentication.
Definition: license_prompt.hpp:16
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
NULL
Add a fourth parameter to bake specific font ranges NULL
Definition: README.txt:57
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:25
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