Blamite Game Engine - blam!  00296.01.12.21.0102.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 
9 {
21  {
22  private:
23  bool show_license_key_failed = false;
24 
25  public:
30 
35 
39  void Draw()
40  {
41  char access_key[255];
42 
43 
44  //License input
45  if (show)
46  {
47  //std::cout << "No access key present, prompting for key" << endl;
48  ImGui::OpenPopup(" Access Restricted");
49  if (ImGui::BeginPopupModal(" Access Restricted", NULL, ImGuiWindowFlags_AlwaysAutoResize))
50  {
51  static char key1[255] = "haloman30@CUND82443161A";
52  static char key2[255] = "00000000000000000000000";
53  static char key3[255] = "haloman30@CUND82443161A";
54  static char key4[255] = "haloman30@CUND82443161A";
55  static char key_generic[255] = "altkey";
56 
57 
58  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.");
59  ImGui::Separator();
60 
61  ImGui::InputText("Access Key", access_key, IM_ARRAYSIZE(access_key));
62  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.");
63 
64 
65  /*
66  if (ImGui::Button("Accept", ImVec2(120, 0)))
67  {
68  string strAKey(access_key);
69  string strKey1(key1);
70  string strKey2(key2);
71  string strKey3(key3);
72  string strKey4(key4);
73  string strKeyGeneric(key_generic);
74 
75  //bool license_valid = (strAKey == strKey1);
76  //▄█▀ █▬█ █ ▀█▀
77  //▄█▀ █▄█ █▀
78 
79  //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
80  if (access_key == strKey1)
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 == strKeyGeneric)
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 == strKey2)
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  if (access_key == strKey3)
105  {
106  show_license_startup_prompt = false;
107  std::cout << "Valid key entered, starting game" << endl;
108  show_license_key_failed = false;
109  }
110  else
111  {
112  if (access_key == strKey4)
113  {
114  show_license_startup_prompt = false;
115  std::cout << "Valid key entered, starting game" << endl;
116  show_license_key_failed = false;
117  }
118  else
119  {
120  show_license_startup_prompt = false;
121  std::cout << "Invald key entered!" << endl;
122  show_license_key_failed = true;
123  }
124  }
125  }
126  }
127  }
128 
129  }
130  */
131 
132  std::string strAKey(access_key);
133  std::string strKey1(key1);
134  std::string strKey2(key2);
135  std::string strKey3(key3);
136  std::string strKey4(key4);
137  std::string strKeyGeneric(key_generic);
138 
139  if (ImGui::Button("Accept", ImVec2(120, 0)))
140  {
141 
142 
143  //bool license_valid = (strAKey == strKey1);
144  //▄█▀ █▬█ █ ▀█▀
145  //▄█▀ █▄█ █▀
146 
147  //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
148  if (access_key == strKey1)
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 == strKeyGeneric)
155  {
156  show = false;
157  Blam::Logger::LogEvent("Valid key entered, starting game");
158  show_license_key_failed = false;
159  }
160  else if (access_key == strKey2)
161  {
162  show = false;
163  Blam::Logger::LogEvent("Valid key entered, starting game");
164  show_license_key_failed = false;
165  }
166  else if (access_key == strKey3)
167  {
168  show = false;
169  Blam::Logger::LogEvent("Valid key entered, starting game");
170  show_license_key_failed = false;
171  }
172  else if (access_key == strKey4)
173  {
174  show = false;
175  Blam::Logger::LogEvent("Valid key entered, starting game");
176  show_license_key_failed = false;
177  }
178  else
179  {
180  show = false;
181  Blam::Logger::LogEvent("Invald key entered!");
182  show_license_key_failed = true;
183  }
184  }
185 
186  ImGui::EndPopup();
187  }
188  }
189 
190  if (show_license_key_failed)
191  {
192  ImGui::OpenPopup(" Wrong Access Key");
193 
194  if (ImGui::BeginPopupModal(" Wrong Access Key", NULL, ImGuiWindowFlags_AlwaysAutoResize))
195  {
196 
197  ImGui::Separator();
198  ImGui::Text("Click 'Retry' to try again.");
199  ImGui::Text("Click 'Cancel' to exit the game.");
200  ImGui::Separator();
201 
202  if (ImGui::Button("Retry", ImVec2(120, 0)))
203  {
204  show_license_key_failed = false;
205  show = true;
206  }
207  ImGui::SameLine();
208  if (ImGui::Button("Cancel", ImVec2(120, 0)))
209  {
210  Blam::Logger::LogEvent("Exiting game.");
211  exit(0);
212  }
213 
214  ImGui::EndPopup();
215  }
216  }
217  }
218  };
219 }
Blam::DebugUI::Widgets::ShowHelpMarker
BLAM void ShowHelpMarker(const char *desc)
Shows a help indicator.
Definition: widgets.cpp:7
Blam::Logger::LogEvent
BLAM void LogEvent(std::string message)
Logs a message to the log and/or console.
Definition: aliases.cpp:101
logger.h
Blam::DebugUI::Windows::LicensePrompt::Draw
void Draw()
Displays the access key dialog.
Definition: license_prompt.hpp:39
Blam::DebugUI::Windows::LicensePrompt
Dialog to prompt for developer key authentication.
Definition: license_prompt.hpp:20
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:362
Blam::DebugUI::ImGUIDrawingGroup
Class representing an ImGUI drawing group/draw list item.
Definition: debug_ui.h:359
Blam::DebugUI::Windows::LicensePrompt::~LicensePrompt
~LicensePrompt()
Empty destructor.
Definition: license_prompt.hpp:34
Blam::DebugUI::Windows::LicensePrompt::LicensePrompt
LicensePrompt()
Empty constructor.
Definition: license_prompt.hpp:29
debug_ui.h
Blam::DebugUI::Windows
Legacy namespace to contain data for the legacy ImGUI console.
Definition: debug_ui.h:434
Text
@ Text
Master text object that wraps around both BitmapText and DWText.
Definition: render_stack.h:73