55 if (this->pinMenuBar) {
56 if (ImGui::BeginMainMenuBar()) {
57 ImGui::MenuItem(
"Shape", NULL, &this->showShapeWindow);
58 ImGui::MenuItem(
"Texture", NULL, &this->showTextureWindow);
59 ImGui::MenuItem(
"Text", NULL, &this->showTextWindow);
60 ImGui::MenuItem(
"Animation", NULL, &this->showAnimationWindow);
61 ImGui::MenuItem(
"Settings", NULL, &this->showSettingsWindow);
63 "Generated Code", NULL, &this->showGeneratedCodeWindow);
64#ifdef CHRONOS_PROFILING
65 ImGui::MenuItem(
"Profiling", NULL, &this->showProfilingWindow);
67 ImGui::EndMainMenuBar();
70 ImGui::Begin(
"Editor",
nullptr, ImGuiWindowFlags_MenuBar);
71 if (ImGui::BeginMenuBar()) {
72 ImGui::MenuItem(
"Shape", NULL, &this->showShapeWindow);
73 ImGui::MenuItem(
"Texture", NULL, &this->showTextureWindow);
74 ImGui::MenuItem(
"Text", NULL, &this->showTextWindow);
75 ImGui::MenuItem(
"Animation", NULL, &this->showAnimationWindow);
76 ImGui::MenuItem(
"Settings", NULL, &this->showSettingsWindow);
78 "Generated Code", NULL, &this->showGeneratedCodeWindow);
87 if (this->showShapeWindow) {
88 ImGui::Begin(
"Shape", &this->showShapeWindow);
89 bool doesNameExist =
false;
90 ImGui::SeparatorText(
"Shape Name");
91 ImGui::InputText(
"Shape Name", this->newShapeParams.shapeName, 200);
92 std::vector<std::pair<int, Chronos::Manager::ShapeParams>>
93 nameShapeDetails = this->manager->getShapeDetails();
94 for (std::pair<int, Chronos::Manager::ShapeParams> shapeDetail :
96 if (!strcmp(this->newShapeParams.shapeName,
97 shapeDetail.second.shapeName)) {
98 ImGui::Text(
"Name Already Exists");
103 ImGui::SeparatorText(
"Fill");
104 ImGui::RadioButton(
"Color", &this->newShapeFill, 0);
105 ImGui::RadioButton(
"Texture", &this->newShapeFill, 1);
106 ImGui::SeparatorText(
"Properties");
108 "X(-1 to 1)", &this->newShapeParams.x, 0.01f, -1.0f, 1.0f);
110 "Y(-1 to 1)", &this->newShapeParams.y, 0.01f, -1.0f, 1.0f);
112 "X Size", &this->newShapeParams.xSize, 0.01f, 0.0f, FLT_MAX);
114 "Y Size", &this->newShapeParams.ySize, 0.01f, 0.0f, FLT_MAX);
116 "Rotation", &this->newShapeParams.rotation, 0.01f, 0.0f, FLT_MAX);
117 switch (this->newShapeFill) {
119 ImGui::ColorEdit3(
"Color", this->newShapeParams.color.data());
122 if (ImGui::BeginCombo(
"Select Texture", currentShapeTextureName)) {
123 std::vector<Chronos::Manager::TextureDetails> details
124 = this->manager->getTextureDetails();
125 if (details.size() == 0) {
126 ImGui::Selectable(
"No Textures");
130 bool isSelected = currentShapeTextureSelection
131 == textureDetail.textureNo;
132 if (ImGui::Selectable(textureDetail.textureName.c_str(),
134 currentShapeTextureSelection
135 = textureDetail.textureNo;
136 strcpy(currentShapeTextureName,
137 textureDetail.textureName.c_str());
139 "Texture selected for shapeNo ["
141 currentShapeTextureSelection)
143 + currentShapeTextureName +
"]")
146 ImGui::SetItemDefaultFocus();
153 if (!doesNameExist) {
154 if (ImGui::Button(
"Add Shape")) {
155 switch (this->newShapeFill) {
157 this->manager->addShape(this->newShapeParams);
159 "Colored shape added with shapeName ["
160 + std::string(this->newShapeParams.shapeName) +
"]")
163 this->manager->addShape(this->newShapeParams,
164 this->currentShapeTextureSelection);
166 "Textured shape added with shapeName ["
167 + std::string(this->newShapeParams.shapeName) +
"]")
172 ImGui::SeparatorText(
"Current Shapes");
173 if (ImGui::BeginListBox(
"Shapes")) {
174 std::vector<std::pair<int, Chronos::Manager::ShapeParams>>
175 shapeDetails = this->manager->getShapeDetails();
176 if (shapeDetails.size() == 0) {
177 ImGui::Selectable(
"No Shapes");
179 for (
int i = 0; i < static_cast<int>(shapeDetails.size());
181 if (ImGui::Selectable(shapeDetails[i].second.shapeName,
182 this->currentShapeSelection == i)) {
183 this->currentShapeSelection = i;
188 if (shapeDetails.size() > 0) {
189 ImGui::Text(
"Selected Shape: %d",
190 shapeDetails[currentShapeSelection].first);
191 if (ImGui::Button(
"Edit Shape")) {
192 this->showShapeDetailsWindow =
true;
193 this->shapeDetailsShapeNo
194 = shapeDetails[currentShapeSelection].first;
195 this->shapeDetailsShapeParams
196 = shapeDetails[currentShapeSelection].second;
199 if (ImGui::Button(
"Remove Shape")) {
200 this->manager->removeObject(
201 shapeDetails[currentShapeSelection].first);
212 if (this->showTextureWindow) {
213 ImGui::Begin(
"Texture", &this->showTextureWindow);
214 bool doesTextureExist =
false;
215 ImGui::SeparatorText(
"Add Textures");
216 ImGui::InputText(
"Texture Path", this->newTexturePath, 200);
217 ImGui::InputText(
"Texture Name", this->newTextureName, 200);
218 std::vector<Chronos::Manager::TextureDetails> nameTextureDetails
219 = this->manager->getTextureDetails();
221 nameTextureDetails) {
223 this->newTextureName, textureDetail.textureName.c_str())) {
224 ImGui::Text(
"Name Already Exists");
225 doesTextureExist =
true;
228 if (std::string(this->newTextureName).size() ==
'\0') {
229 ImGui::Text(
"Name Cannot be empty");
230 doesTextureExist =
true;
233 if (!std::string(this->newTexturePath).ends_with(
".jpg")
234 && !std::string(this->newTexturePath).ends_with(
".png")) {
235 ImGui::Text(
"Only jpg and png files are supported");
236 doesTextureExist =
true;
241 if (!doesTextureExist) {
242 if (ImGui::Button(
"Add Texture")) {
243 this->manager->addTexture(
244 this->newTexturePath, this->newTextureName);
245 this->newTexturePath[0] =
'\0';
247 "Texture added with textureName ["
248 + std::string(this->newTextureName)
249 +
"] and texturePath [" + this->newTexturePath +
"]")
252 ImGui::SeparatorText(
"Current Textures");
253 std::vector<Chronos::Manager::TextureDetails> details
254 = this->manager->getTextureDetails();
255 if (ImGui::BeginListBox(
"Textures")) {
256 if (details.size() == 0) {
257 ImGui::Selectable(
"No Textures");
259 for (
int i = 0; i < static_cast<int>(details.size()); i++) {
260 if (ImGui::Selectable(details[i].textureName.c_str(),
261 currentTextureSelection == i)) {
262 currentTextureSelection = i;
268 if (details.size() > 0) {
269 if (ImGui::Button(
"Remove Texture")) {
270 this->manager->removeTexture(
271 details[currentTextureSelection].textureNo);
273 "Texture removed with textureNo ["
275 details[currentTextureSelection].textureNo)
279 if (ImGui::Button(
"View Texture Details")) {
280 this->showTextureDetailsWindow =
true;
282 "Texture selected for editing with textureNo ["
283 + std::to_string(this->textureDetailsCurrentSelection)
293 if (this->showTextWindow) {
294 ImGui::Begin(
"Text", &this->showTextWindow);
295 ImGui::SeparatorText(
"Add Text");
296 char inputText[2048];
297 strcpy(inputText, this->newTextParams.text.c_str());
298 ImGui::InputText(
"Text", inputText, 2048);
299 this->newTextParams.text = inputText;
301 "X(-1 to 1)", &this->newTextParams.x, 0.01f, -1.0f, 1.0f);
303 "Y(-1 to 1)", &this->newTextParams.y, 0.01f, -1.0f, 1.0f);
305 "Rotation", &this->newTextParams.rotation, 0.01f, 0.0f, FLT_MAX);
307 "Scale", &this->newTextParams.scale, 0.01f, 0.0f, FLT_MAX);
308 ImGui::ColorEdit3(
"Color", this->newTextParams.color.data());
309 if (ImGui::BeginCombo(
310 "Select Font", this->currentFontSelection.c_str())) {
311 if (ImGui::Selectable(
312 "consolas", this->currentFontSelection ==
"consolas")) {
313 this->currentFontSelection =
"consolas";
314 LOG(1,
"Font selected [" + this->currentFontSelection +
"]")
316 if (ImGui::Selectable(
"consolas_bold",
317 this->currentFontSelection ==
"consolas_bold")) {
318 this->currentFontSelection =
"consolas_bold";
319 LOG(1,
"Font selected [" + this->currentFontSelection +
"]")
321 if (ImGui::Selectable(
322 "arial", this->currentFontSelection ==
"arial")) {
323 this->currentFontSelection =
"arial";
324 LOG(1,
"Font selected [" + this->currentFontSelection +
"]")
326 if (ImGui::Selectable(
327 "arial_bold", this->currentFontSelection ==
"arial_bold")) {
328 this->currentFontSelection =
"arial_bold";
329 LOG(1,
"Font selected [" + this->currentFontSelection +
"]")
331 if (ImGui::Selectable(
332 "times", this->currentFontSelection ==
"times")) {
333 this->currentFontSelection =
"times";
334 LOG(1,
"Font selected [" + this->currentFontSelection +
"]")
336 if (ImGui::Selectable(
337 "times_bold", this->currentFontSelection ==
"times_bold")) {
338 this->currentFontSelection =
"times_bold";
339 LOG(1,
"Font selected [" + this->currentFontSelection +
"]")
343 ImGui::DragInt(
"Font Size", &this->currentFontSizeSelection, 1, 6, 50);
344 if (this->newTextParams.text.size() == 0) {
345 ImGui::Text(
"Text Cannot be empty");
347 if (ImGui::Button(
"Add Text")) {
348 this->manager->addText(this->newTextParams,
349 this->currentFontSelection, this->currentFontSizeSelection);
351 "Text added with text [" + this->newTextParams.text +
"]")
354 ImGui::SeparatorText(
"Current Text");
355 if (ImGui::BeginListBox(
"Text")) {
356 std::vector<std::pair<int, Chronos::Engine::TextParams>> textDetails
357 = this->manager->getTextDetails();
358 if (textDetails.size() == 0) {
359 ImGui::Selectable(
"No Text");
361 for (
int i = 0; i < static_cast<int>(textDetails.size()); i++) {
362 if (ImGui::Selectable(textDetails[i].second.text.c_str(),
363 this->currentTextSelection == i)) {
364 this->currentTextSelection = i;
369 if (textDetails.size() > 0) {
370 if (ImGui::Button(
"Edit Text")) {
371 this->showTextDetailsWindow =
true;
372 this->textDetailsTextNo
373 = textDetails[currentTextSelection].first;
374 this->textDetailsTextParams
375 = textDetails[currentTextSelection].second;
377 "Text selected for editing with textNo ["
378 + std::to_string(this->textDetailsTextNo) +
"]")
381 if (ImGui::Button(
"Remove Text")) {
382 this->manager->removeObject(
383 textDetails[currentTextSelection].first);
385 "Text removed with textNo ["
387 textDetails[currentTextSelection].first)
398 if (this->showSettingsWindow) {
399 ImGui::Begin(
"Settings", &this->showSettingsWindow);
400 ImGui::SeparatorText(
"Build Information");
401 ImGui::Text(
"Engine name: %s",
"Chronos");
402 ImGui::Text(
"Build Version: %d.%d.%d", CHRONOS_VERSION_MAJOR,
403 CHRONOS_VERSION_MINOR, CHRONOS_VERSION_PATCH);
404 ImGui::Text(
"Build Date: %s", __DATE__);
405 ImGui::Text(
"Build Time: %s", __TIME__);
407 ImGui::SeparatorText(
"Window Settings");
408 ImGui::InputText(
"Window Title", this->windowTitle, 200);
409 if (ImGui::Button(
"Update Window Title")) {
410 glfwSetWindowTitle(this->manager->getWindow(), this->windowTitle);
412 "Window title updated to [" + std::string(this->windowTitle)
415 ImGui::Checkbox(
"Make Window Fullscreen", &this->fullScreen);
416 if (this->fullScreen && !this->isWindowFullscreen) {
417 GLFWwindow* window = this->manager->getWindow();
418 const GLFWvidmode* mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
419 glfwSetWindowMonitor(window, glfwGetPrimaryMonitor(), 0, 0,
420 mode->width, mode->height, mode->refreshRate);
421 this->isWindowFullscreen =
true;
422 LOG(1,
"Window set to fullscreen")
423 }
else if (!this->fullScreen && this->isWindowFullscreen) {
424 GLFWwindow* window = this->manager->getWindow();
425 glfwSetWindowMonitor(window,
nullptr, 0, 0, 800, 600, 0);
426 this->isWindowFullscreen =
false;
427 LOG(1,
"Window set to windowed mode")
430 ImGui::SeparatorText(
"Present Mode");
431 if (ImGui::BeginCombo(
"Present Mode", this->presentMode.c_str())) {
432 if (ImGui::Selectable(
"mailbox", this->presentMode ==
"mailbox")) {
433 this->presentMode =
"mailbox";
435 if (ImGui::Selectable(
436 "immediate", this->presentMode ==
"immediate")) {
437 this->presentMode =
"immediate";
439 if (ImGui::Selectable(
"fifo", this->presentMode ==
"fifo")) {
440 this->presentMode =
"fifo";
442 if (ImGui::Selectable(
443 "fifo_relaxed", this->presentMode ==
"fifo_relaxed")) {
444 this->presentMode =
"fifo_relaxed";
448 if (ImGui::Button(
"Update Present Mode")) {
449 this->manager->changePresentMode(this->presentMode);
450 LOG(1,
"Present mode updated to [" + this->presentMode +
"]")
453 ImGui::SeparatorText(
"MSAA Samples");
454 std::vector<std::string> msaaSamples = this->manager->getMSAAModes();
455 for (std::string sample : msaaSamples) {
456 if (ImGui::Selectable(
457 sample.c_str(), this->msaaSamples == sample)) {
458 this->msaaSamples = sample;
461 if (ImGui::Button(
"Update MSAA Samples")) {
462 this->manager->changeMSAA(this->msaaSamples);
463 LOG(1,
"MSAA Samples updated to [" + this->msaaSamples +
"]")
466 ImGui::SeparatorText(
"Background Color");
467 ImGui::ColorEdit3(
"Background Color", this->bgColor);
468 if (ImGui::Button(
"Update Background Color")) {
469 this->manager->changeBackgroundColor(
470 this->bgColor[0], this->bgColor[1], this->bgColor[2]);
472 "Background color updated to ["
473 + std::to_string(this->bgColor[0]) +
", "
474 + std::to_string(this->bgColor[1]) +
", "
475 + std::to_string(this->bgColor[2]) +
"]")
478 ImGui::SeparatorText(
"ImGui Debug Settings");
479 ImGui::Checkbox(
"Show Metrics", &this->showDebugMetricsWindow);
480 ImGui::Checkbox(
"Show Log", &this->showDebugLogWindow);
481 ImGui::Checkbox(
"Pin Menu Bar", &this->pinMenuBar);
489 if (this->showShapeDetailsWindow) {
490 ImGui::Begin(
"Shape Details", &this->showShapeDetailsWindow);
491 ImGui::SeparatorText(
"Shape Details");
492 if (this->manager->getShapeDetails().size() == 0) {
493 ImGui::Text(
"No Shapes");
496 "Shape Name", this->shapeDetailsShapeParams.shapeName, 200);
497 ImGui::DragFloat(
"X(-1 to 1)", &this->shapeDetailsShapeParams.x,
500 this->keyframeCheckbox(&this->shapeDetailsShapeParams.x,
"X");
501 ImGui::DragFloat(
"Y(-1 to 1)", &this->shapeDetailsShapeParams.y,
504 this->keyframeCheckbox(&this->shapeDetailsShapeParams.y,
"Y");
505 ImGui::DragFloat(
"X Size", &this->shapeDetailsShapeParams.xSize,
506 0.01f, 0.0f, FLT_MAX);
508 this->keyframeCheckbox(
509 &this->shapeDetailsShapeParams.xSize,
"X size");
510 ImGui::DragFloat(
"Y Size", &this->shapeDetailsShapeParams.ySize,
511 0.01f, 0.0f, FLT_MAX);
513 this->keyframeCheckbox(
514 &this->shapeDetailsShapeParams.ySize,
"Y size");
515 ImGui::DragFloat(
"Rotation",
516 &this->shapeDetailsShapeParams.rotation, 0.01f, 0.0f, FLT_MAX);
518 this->keyframeCheckbox(
519 &this->shapeDetailsShapeParams.rotation,
"Rotation(degrees)");
521 "Color", this->shapeDetailsShapeParams.color.data());
522 this->manager->updateShape(
523 this->shapeDetailsShapeNo, this->shapeDetailsShapeParams);
531 if (this->showTextureDetailsWindow) {
532 ImGui::Begin(
"Texture Details", &this->showTextureDetailsWindow);
533 ImGui::SeparatorText(
"Texture Details");
534 std::vector<Chronos::Manager::TextureDetails> textureDetails
535 = this->manager->getTextureDetails();
536 if (textureDetails.size() == 0) {
537 ImGui::Text(
"No Textures");
539 ImGui::Text(
"Texture Name: %s",
540 textureDetails[this->textureDetailsCurrentSelection]
541 .textureName.data());
542 ImGui::Text(
"Texture Path: %s",
543 textureDetails[this->textureDetailsCurrentSelection]
544 .texturePath.data());
545 ImGui::Text(
"Width: %d",
546 textureDetails[this->textureDetailsCurrentSelection].width);
547 ImGui::Text(
"Height: %d",
548 textureDetails[this->textureDetailsCurrentSelection].height);
549 ImGui::SeparatorText(
"Texture Preview");
552 textureDetails[this->textureDetailsCurrentSelection]
555 textureDetails[this->textureDetailsCurrentSelection].width,
556 textureDetails[this->textureDetailsCurrentSelection]
565 if (this->showTextDetailsWindow) {
566 ImGui::Begin(
"Text Details", &this->showTextDetailsWindow);
567 ImGui::SeparatorText(
"Text Details");
568 std::vector<std::pair<int, Chronos::Engine::TextParams>> textDetails
569 = this->manager->getTextDetails();
570 if (textDetails.size() == 0) {
571 ImGui::Text(
"No Text");
573 char inputText[2048];
574 strcpy(inputText, this->textDetailsTextParams.text.c_str());
575 ImGui::InputText(
"Text", inputText, 2048);
576 if (inputText[0] !=
'\0') {
577 this->textDetailsTextParams.text = inputText;
578 ImGui::Text(
"Text Field cannot be empty");
581 ImGui::DragFloat(
"X(-1 to 1)", &this->textDetailsTextParams.x,
583 ImGui::DragFloat(
"Y(-1 to 1)", &this->textDetailsTextParams.y,
585 ImGui::DragFloat(
"Rotation", &this->textDetailsTextParams.rotation,
586 0.01f, 0.0f, FLT_MAX);
587 ImGui::DragFloat(
"Scale", &this->textDetailsTextParams.scale, 0.01f,
590 "Color", this->textDetailsTextParams.color.data());
591 this->manager->updateText(
592 this->textDetailsTextNo, this->textDetailsTextParams);
683 float* valuePointer, std::string name)
685 bool isAnimated = this->doesKeyframeExist(valuePointer);
686 bool currentChange = isAnimated;
687 ImGui::Checkbox(name.c_str(), ¤tChange);
688 if (currentChange != isAnimated) {
690 "Animate checkbox changed for valuePointer ["
691 + std::to_string((
long long)valuePointer) +
"]");
693 int keyframeNo = this->manager->addKeyframeVariable(
694 { { 0, *valuePointer }, { 100, *valuePointer } });
695 this->floatPointerToKeyframeNo[valuePointer] = keyframeNo;
697 "Added keyframe for valuePointer ["
698 + std::to_string((
long long)valuePointer)
699 +
"] with keyframeNo [" + std::to_string(keyframeNo) +
"]")
701 int keyframeNo = this->getKeyframeNo(valuePointer);
702 if (keyframeNo == -1) {
703 throw std::runtime_error(
"Could not find keyframe number!!!");
705 this->manager->removeKeyframeVariable(keyframeNo);
706 this->floatPointerToKeyframeNo.erase(valuePointer);
708 "Removed keyframe for valuePointer ["
709 + std::to_string((
long long)valuePointer)
710 +
"] with keyframeNo [" + std::to_string(keyframeNo) +
"]")
715 if (ImGui::Button(
"Keyframe Details")) {
716 this->showKeyframeDetailsWindow =
true;
717 this->currentKeyframeValuePointer = valuePointer;
Holds some details about the texture.