Blamite Game Engine - Blam (Core)
license_prompt.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 #include "../../debug_ui.h"
6 
8 {
20  {
21  private:
22  bool show_license_key_failed = false;
23 
24  public:
29 
34 
38  void Draw()
39  {
40  char access_key[255];
41 
42 
43  //License input
44  if (show)
45  {
46  //std::cout << "No access key present, prompting for key" << endl;
47  ImGui::OpenPopup(" Access Restricted");
48  if (ImGui::BeginPopupModal(" Access Restricted", NULL, ImGuiWindowFlags_AlwaysAutoResize))
49  {
50  static char key1[255] = "haloman30@CUND82443161A";
51  static char key2[255] = "00000000000000000000000";
52  static char key3[255] = "haloman30@CUND82443161A";
53  static char key4[255] = "haloman30@CUND82443161A";
54  static char key_generic[255] = "altkey";
55 
56 
57  ImGui::Text("You are attempting to launch a development build of the engine.\nTo continue, you must input your developer access key.\nThis can be found on the Gitlab repository.");
58  ImGui::Separator();
59 
60  ImGui::InputText("Access Key", access_key, IM_ARRAYSIZE(access_key));
61  ImGui::SameLine(); Blam::DebugUI::Widgets::ShowHelpMarker("Please enter your Access key in this box, then click 'Accept'. If the key is valid, the game will continue normally.");
62 
63 
64  /*
65  if (ImGui::Button("Accept", ImVec2(120, 0)))
66  {
67  string strAKey(access_key);
68  string strKey1(key1);
69  string strKey2(key2);
70  string strKey3(key3);
71  string strKey4(key4);
72  string strKeyGeneric(key_generic);
73 
74  //bool license_valid = (strAKey == strKey1);
75  //▄█▀ █▬█ █ ▀█▀
76  //▄█▀ █▄█ █▀
77 
78  //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
79  if (access_key == strKey1)
80  {
81  show_license_startup_prompt = false;
82  std::cout << "Valid key entered, starting game" << endl;
83  show_license_key_failed = false;
84  }
85  else
86  {
87  if (access_key == strKeyGeneric)
88  {
89  show_license_startup_prompt = false;
90  std::cout << "Valid key entered, starting game" << endl;
91  show_license_key_failed = false;
92  }
93  else
94  {
95  if (access_key == strKey2)
96  {
97  show_license_startup_prompt = false;
98  std::cout << "Valid key entered, starting game" << endl;
99  show_license_key_failed = false;
100  }
101  else
102  {
103  if (access_key == strKey3)
104  {
105  show_license_startup_prompt = false;
106  std::cout << "Valid key entered, starting game" << endl;
107  show_license_key_failed = false;
108  }
109  else
110  {
111  if (access_key == strKey4)
112  {
113  show_license_startup_prompt = false;
114  std::cout << "Valid key entered, starting game" << endl;
115  show_license_key_failed = false;
116  }
117  else
118  {
119  show_license_startup_prompt = false;
120  std::cout << "Invald key entered!" << endl;
121  show_license_key_failed = true;
122  }
123  }
124  }
125  }
126  }
127 
128  }
129  */
130 
131  std::string strAKey(access_key);
132  std::string strKey1(key1);
133  std::string strKey2(key2);
134  std::string strKey3(key3);
135  std::string strKey4(key4);
136  std::string strKeyGeneric(key_generic);
137 
138  if (ImGui::Button("Accept", ImVec2(120, 0)))
139  {
140 
141 
142  //bool license_valid = (strAKey == strKey1);
143  //▄█▀ █▬█ █ ▀█▀
144  //▄█▀ █▄█ █▀
145 
146  //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
147  if (access_key == strKey1)
148  {
149  show = false;
150  Blam::Logger::LogEvent("Valid key entered, starting game");
151  show_license_key_failed = false;
152  }
153  else if (access_key == strKeyGeneric)
154  {
155  show = false;
156  Blam::Logger::LogEvent("Valid key entered, starting game");
157  show_license_key_failed = false;
158  }
159  else if (access_key == strKey2)
160  {
161  show = false;
162  Blam::Logger::LogEvent("Valid key entered, starting game");
163  show_license_key_failed = false;
164  }
165  else if (access_key == strKey3)
166  {
167  show = false;
168  Blam::Logger::LogEvent("Valid key entered, starting game");
169  show_license_key_failed = false;
170  }
171  else if (access_key == strKey4)
172  {
173  show = false;
174  Blam::Logger::LogEvent("Valid key entered, starting game");
175  show_license_key_failed = false;
176  }
177  else
178  {
179  show = false;
180  Blam::Logger::LogEvent("Invald key entered!");
181  show_license_key_failed = true;
182  }
183  }
184 
185  ImGui::EndPopup();
186  }
187  }
188 
189  if (show_license_key_failed)
190  {
191  ImGui::OpenPopup(" Wrong Access Key");
192 
193  if (ImGui::BeginPopupModal(" Wrong Access Key", NULL, ImGuiWindowFlags_AlwaysAutoResize))
194  {
195 
196  ImGui::Separator();
197  ImGui::Text("Click 'Retry' to try again.");
198  ImGui::Text("Click 'Cancel' to exit the game.");
199  ImGui::Separator();
200 
201  if (ImGui::Button("Retry", ImVec2(120, 0)))
202  {
203  show_license_key_failed = false;
204  show = true;
205  }
206  ImGui::SameLine();
207  if (ImGui::Button("Cancel", ImVec2(120, 0)))
208  {
209  Blam::Logger::LogEvent("Exiting game.");
210  exit(0);
211  }
212 
213  ImGui::EndPopup();
214  }
215  }
216  }
217  };
218 }
Blam::DebugUI::Widgets::ShowHelpMarker
BLAM void ShowHelpMarker(const char *desc)
Shows a help indicator.
Definition: widgets.cpp:5
Blam::Logger::LogEvent
BLAM void LogEvent(std::string message)
Logs a message to the log and/or console.
Definition: aliases.cpp:33
logger.h
Blam::DebugUI::Windows::LicensePrompt::Draw
void Draw()
Displays the access key dialog.
Definition: license_prompt.hpp:38
Blam::DebugUI::Windows::LicensePrompt
Dialog to prompt for developer key authentication.
Definition: license_prompt.hpp:19
widgets.h
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::LicensePrompt::~LicensePrompt
~LicensePrompt()
Empty destructor.
Definition: license_prompt.hpp:33
Blam::DebugUI::Windows::LicensePrompt::LicensePrompt
LicensePrompt()
Empty constructor.
Definition: license_prompt.hpp:28
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