Chronos 0.0
A advanced 2D rendering and animation system
Loading...
Searching...
No Matches
Chronos::Editor::EditorManager Class Reference

#include <editorManager.hpp>

Collaboration diagram for Chronos::Editor::EditorManager:

Public Member Functions

void init (Chronos::Manager::Manager *manager)
 
void addElements ()
 

Private Member Functions

void MenuBar ()
 
void ShapeWindow ()
 
void TextureWindow ()
 
void TextWindow ()
 
void AnimationWindow ()
 
void SettingsWindow ()
 
void TotalCodeGenerationWindow ()
 
void ShapeDetailsWindow ()
 
void TextureDetailsWindow ()
 
void TextDetailsWindow ()
 
void KeyframeDetailsWindow ()
 
void DebugMetricsWindow ()
 
void DebugLogWindow ()
 
int getKeyframeNo (float *valuePointer)
 
bool doesKeyframeExist (float *valuePointer)
 
void keyframeCheckbox (float *valuePointer, std::string name)
 
void updateKeyframes ()
 

Private Attributes

Chronos::Manager::Managermanager
 
bool pinMenuBar = true
 
bool showShapeWindow = false
 
bool showTextureWindow = false
 
bool showTextWindow = false
 
bool showAnimationWindow = false
 
bool showSettingsWindow = false
 
bool showGeneratedCodeWindow = false
 
bool showShapeDetailsWindow = false
 
bool showTextureDetailsWindow = false
 
bool showTextDetailsWindow = false
 
bool showKeyframeDetailsWindow = false
 
bool showDebugMetricsWindow = false
 
bool showDebugLogWindow = false
 
Chronos::Manager::ShapeParams newShapeParams
 
int newShapeFill = 0
 
int currentShapeTextureSelection = 0
 
char currentShapeTextureName [200] = "Select Texture"
 
int currentShapeSelection = 0
 
char newTexturePath [200]
 
char newTextureName [200]
 
int currentTextureSelection = 0
 
Chronos::Engine::TextParams newTextParams
 
std::string currentFontSelection = "consolas"
 
int currentFontSizeSelection = 6
 
int currentTextSelection = 0
 
Chronos::Manager::ShapeParams shapeDetailsShapeParams
 
int shapeDetailsShapeNo = 0
 
Chronos::Engine::TextParams textDetailsTextParams
 
int textDetailsTextNo = 0
 
int textureDetailsCurrentSelection = 0
 
char windowTitle [200] = GAME_NAME
 
std::string presentMode = "mailbox"
 
float bgColor [3] = { 0, 0, 0 }
 
bool fullScreen = false
 
bool isWindowFullscreen = false
 
std::string msaaSamples = "1"
 
std::unordered_map< float *, int > floatPointerToKeyframeNo
 
float * currentKeyframeValuePointer = nullptr
 

Detailed Description

Definition at line 27 of file editorManager.hpp.

Member Function Documentation

◆ addElements()

void Chronos::Editor::EditorManager::addElements ( )

Definition at line 29 of file editorManager.cpp.

30{
32 this->MenuBar();
33 this->ShapeWindow();
34 this->TextureWindow();
35 this->TextWindow();
36 this->AnimationWindow();
37 this->SettingsWindow();
39 this->ShapeDetailsWindow();
41 this->TextDetailsWindow();
43 this->DebugMetricsWindow();
44 this->DebugLogWindow();
45#ifdef CHRONOS_PROFILING
46 this->ProfilingWindow();
47#endif
48 this->updateKeyframes();
49
50 LOG(4, "Elements added to the editor.")
51}
#define LOG(LEVEL, MESSAGE)
Definition logging.hpp:60

References AnimationWindow(), DebugLogWindow(), DebugMetricsWindow(), KeyframeDetailsWindow(), LOG, MenuBar(), Chronos::Editor::setImGuiStyle(), SettingsWindow(), ShapeDetailsWindow(), ShapeWindow(), TextDetailsWindow(), TextureDetailsWindow(), TextureWindow(), TextWindow(), TotalCodeGenerationWindow(), and updateKeyframes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AnimationWindow()

void Chronos::Editor::EditorManager::AnimationWindow ( )
private

Definition at line 640 of file editorManager.cpp.

641{
642 if (this->showAnimationWindow) {
643 ImGui::Begin("Animation", &this->showAnimationWindow);
644 ImGui::SeparatorText("Animation");
645 ImGui::End();
646 }
647}
Here is the caller graph for this function:

◆ DebugLogWindow()

void Chronos::Editor::EditorManager::DebugLogWindow ( )
private

Definition at line 604 of file editorManager.cpp.

605{
606 if (this->showDebugLogWindow) {
607 ImGui::ShowDebugLogWindow(&this->showDebugLogWindow);
608 }
609}
Here is the caller graph for this function:

◆ DebugMetricsWindow()

void Chronos::Editor::EditorManager::DebugMetricsWindow ( )
private

Definition at line 597 of file editorManager.cpp.

598{
599 if (this->showDebugMetricsWindow) {
600 ImGui::ShowMetricsWindow(&this->showDebugMetricsWindow);
601 }
602}
Here is the caller graph for this function:

◆ doesKeyframeExist()

bool Chronos::Editor::EditorManager::doesKeyframeExist ( float *  valuePointer)
private

Definition at line 675 of file editorManager.cpp.

676{
677 if (this->getKeyframeNo(valuePointer) == -1)
678 return false;
679 return true;
680}
int getKeyframeNo(float *valuePointer)

◆ getKeyframeNo()

int Chronos::Editor::EditorManager::getKeyframeNo ( float *  valuePointer)
private

Definition at line 662 of file editorManager.cpp.

663{
664 if (!valuePointer) {
665 throw std::runtime_error("Value Pointer is null");
666 }
667 if (this->floatPointerToKeyframeNo.find(valuePointer)
668 == this->floatPointerToKeyframeNo.end()) {
669 return -1;
670 } else {
671 return this->floatPointerToKeyframeNo[valuePointer];
672 }
673}
std::unordered_map< float *, int > floatPointerToKeyframeNo

◆ init()

void Chronos::Editor::EditorManager::init ( Chronos::Manager::Manager manager)
inline

Definition at line 29 of file editorManager.hpp.

30 {
31 this->manager = manager;
32 }
Chronos::Manager::Manager * manager

References manager.

Here is the caller graph for this function:

◆ keyframeCheckbox()

void Chronos::Editor::EditorManager::keyframeCheckbox ( float *  valuePointer,
std::string  name 
)
private

Definition at line 682 of file editorManager.cpp.

684{
685 bool isAnimated = this->doesKeyframeExist(valuePointer);
686 bool currentChange = isAnimated;
687 ImGui::Checkbox(name.c_str(), &currentChange);
688 if (currentChange != isAnimated) {
689 LOG(3,
690 "Animate checkbox changed for valuePointer ["
691 + std::to_string((long long)valuePointer) + "]");
692 if (currentChange) {
693 int keyframeNo = this->manager->addKeyframeVariable(
694 { { 0, *valuePointer }, { 100, *valuePointer } });
695 this->floatPointerToKeyframeNo[valuePointer] = keyframeNo;
696 LOG(3,
697 "Added keyframe for valuePointer ["
698 + std::to_string((long long)valuePointer)
699 + "] with keyframeNo [" + std::to_string(keyframeNo) + "]")
700 } else {
701 int keyframeNo = this->getKeyframeNo(valuePointer);
702 if (keyframeNo == -1) {
703 throw std::runtime_error("Could not find keyframe number!!!");
704 }
705 this->manager->removeKeyframeVariable(keyframeNo);
706 this->floatPointerToKeyframeNo.erase(valuePointer);
707 LOG(3,
708 "Removed keyframe for valuePointer ["
709 + std::to_string((long long)valuePointer)
710 + "] with keyframeNo [" + std::to_string(keyframeNo) + "]")
711 }
712 }
713 if (currentChange) {
714 ImGui::SameLine();
715 if (ImGui::Button("Keyframe Details")) {
716 this->showKeyframeDetailsWindow = true;
717 this->currentKeyframeValuePointer = valuePointer;
718 }
719 }
720}
bool doesKeyframeExist(float *valuePointer)
int addKeyframeVariable(std::vector< std::pair< float, float > > keyframes)
Definition chronos.hpp:457
void removeKeyframeVariable(int keyframeNo)
Definition chronos.hpp:462

References LOG.

◆ KeyframeDetailsWindow()

void Chronos::Editor::EditorManager::KeyframeDetailsWindow ( )
private

Definition at line 649 of file editorManager.cpp.

650{
651 if (this->showKeyframeDetailsWindow) {
652 ImGui::Begin("Keyframe Details", &this->showKeyframeDetailsWindow);
653 ImGui::SeparatorText("Keyframe Details");
654 ImGui::Text("Current Value pointer: %p",
655 (void*)this->currentKeyframeValuePointer);
656 int keyframeNo = this->getKeyframeNo(this->currentKeyframeValuePointer);
657 ImGui::Text("Keyframe Number: %d", keyframeNo);
658 ImGui::End();
659 }
660}
Here is the caller graph for this function:

◆ MenuBar()

void Chronos::Editor::EditorManager::MenuBar ( )
private

Definition at line 53 of file editorManager.cpp.

54{
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);
62 ImGui::MenuItem(
63 "Generated Code", NULL, &this->showGeneratedCodeWindow);
64#ifdef CHRONOS_PROFILING
65 ImGui::MenuItem("Profiling", NULL, &this->showProfilingWindow);
66#endif
67 ImGui::EndMainMenuBar();
68 }
69 } else {
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);
77 ImGui::MenuItem(
78 "Generated Code", NULL, &this->showGeneratedCodeWindow);
79 ImGui::EndMenuBar();
80 }
81 ImGui::End();
82 }
83}
Here is the caller graph for this function:

◆ SettingsWindow()

void Chronos::Editor::EditorManager::SettingsWindow ( )
private

Definition at line 396 of file editorManager.cpp.

397{
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__);
406
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);
411 LOG(1,
412 "Window title updated to [" + std::string(this->windowTitle)
413 + "]")
414 }
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")
428 }
429
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";
434 }
435 if (ImGui::Selectable(
436 "immediate", this->presentMode == "immediate")) {
437 this->presentMode = "immediate";
438 }
439 if (ImGui::Selectable("fifo", this->presentMode == "fifo")) {
440 this->presentMode = "fifo";
441 }
442 if (ImGui::Selectable(
443 "fifo_relaxed", this->presentMode == "fifo_relaxed")) {
444 this->presentMode = "fifo_relaxed";
445 }
446 ImGui::EndCombo();
447 }
448 if (ImGui::Button("Update Present Mode")) {
450 LOG(1, "Present mode updated to [" + this->presentMode + "]")
451 }
452
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;
459 }
460 }
461 if (ImGui::Button("Update MSAA Samples")) {
462 this->manager->changeMSAA(this->msaaSamples);
463 LOG(1, "MSAA Samples updated to [" + this->msaaSamples + "]")
464 }
465
466 ImGui::SeparatorText("Background Color");
467 ImGui::ColorEdit3("Background Color", this->bgColor);
468 if (ImGui::Button("Update Background Color")) {
470 this->bgColor[0], this->bgColor[1], this->bgColor[2]);
471 LOG(1,
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]) + "]")
476 }
477
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);
482
483 ImGui::End();
484 }
485}
int changeBackgroundColor(float r, float g, float b)
Changes the background color of the window.
Definition manager.cpp:57
GLFWwindow * getWindow()
Gets a reference to the GLFWWindow.
Definition manager.cpp:25
void changePresentMode(std::string presentMode)
Changes the present mode of the swapchain.
Definition chronos.hpp:356
std::vector< std::string > getMSAAModes()
Definition chronos.hpp:361
void changeMSAA(std::string mode)
Definition chronos.hpp:366

References LOG.

Here is the caller graph for this function:

◆ ShapeDetailsWindow()

void Chronos::Editor::EditorManager::ShapeDetailsWindow ( )
private

Definition at line 487 of file editorManager.cpp.

488{
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");
494 } else {
495 ImGui::InputText(
496 "Shape Name", this->shapeDetailsShapeParams.shapeName, 200);
497 ImGui::DragFloat("X(-1 to 1)", &this->shapeDetailsShapeParams.x,
498 0.01f, -1.0f, 1.0f);
499 ImGui::SameLine();
500 this->keyframeCheckbox(&this->shapeDetailsShapeParams.x, "X");
501 ImGui::DragFloat("Y(-1 to 1)", &this->shapeDetailsShapeParams.y,
502 0.01f, -1.0f, 1.0f);
503 ImGui::SameLine();
504 this->keyframeCheckbox(&this->shapeDetailsShapeParams.y, "Y");
505 ImGui::DragFloat("X Size", &this->shapeDetailsShapeParams.xSize,
506 0.01f, 0.0f, FLT_MAX);
507 ImGui::SameLine();
508 this->keyframeCheckbox(
509 &this->shapeDetailsShapeParams.xSize, "X size");
510 ImGui::DragFloat("Y Size", &this->shapeDetailsShapeParams.ySize,
511 0.01f, 0.0f, FLT_MAX);
512 ImGui::SameLine();
513 this->keyframeCheckbox(
514 &this->shapeDetailsShapeParams.ySize, "Y size");
515 ImGui::DragFloat("Rotation",
516 &this->shapeDetailsShapeParams.rotation, 0.01f, 0.0f, FLT_MAX);
517 ImGui::SameLine();
518 this->keyframeCheckbox(
519 &this->shapeDetailsShapeParams.rotation, "Rotation(degrees)");
520 ImGui::ColorEdit3(
521 "Color", this->shapeDetailsShapeParams.color.data());
522 this->manager->updateShape(
524 }
525 ImGui::End();
526 }
527}
void keyframeCheckbox(float *valuePointer, std::string name)
Chronos::Manager::ShapeParams shapeDetailsShapeParams
void updateShape(int objectNo, Chronos::Manager::ShapeParams shapeParams)
Updates the polygon(any) with the new parameters.
std::vector< std::pair< int, Chronos::Manager::ShapeParams > > getShapeDetails()
std::array< float, 3 > color
Here is the caller graph for this function:

◆ ShapeWindow()

void Chronos::Editor::EditorManager::ShapeWindow ( )
private

Definition at line 85 of file editorManager.cpp.

86{
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 :
95 nameShapeDetails) {
96 if (!strcmp(this->newShapeParams.shapeName,
97 shapeDetail.second.shapeName)) {
98 ImGui::Text("Name Already Exists");
99 doesNameExist = true;
100 break;
101 }
102 }
103 ImGui::SeparatorText("Fill");
104 ImGui::RadioButton("Color", &this->newShapeFill, 0);
105 ImGui::RadioButton("Texture", &this->newShapeFill, 1);
106 ImGui::SeparatorText("Properties");
107 ImGui::DragFloat(
108 "X(-1 to 1)", &this->newShapeParams.x, 0.01f, -1.0f, 1.0f);
109 ImGui::DragFloat(
110 "Y(-1 to 1)", &this->newShapeParams.y, 0.01f, -1.0f, 1.0f);
111 ImGui::DragFloat(
112 "X Size", &this->newShapeParams.xSize, 0.01f, 0.0f, FLT_MAX);
113 ImGui::DragFloat(
114 "Y Size", &this->newShapeParams.ySize, 0.01f, 0.0f, FLT_MAX);
115 ImGui::DragFloat(
116 "Rotation", &this->newShapeParams.rotation, 0.01f, 0.0f, FLT_MAX);
117 switch (this->newShapeFill) {
118 case 0:
119 ImGui::ColorEdit3("Color", this->newShapeParams.color.data());
120 break;
121 case 1:
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");
127 } else {
128 for (Chronos::Manager::TextureDetails textureDetail :
129 details) {
130 bool isSelected = currentShapeTextureSelection
131 == textureDetail.textureNo;
132 if (ImGui::Selectable(textureDetail.textureName.c_str(),
133 isSelected)) {
135 = textureDetail.textureNo;
137 textureDetail.textureName.c_str());
138 LOG(1,
139 "Texture selected for shapeNo ["
140 + std::to_string(
142 + "], textureName ["
144 }
145 if (isSelected) {
146 ImGui::SetItemDefaultFocus();
147 }
148 }
149 }
150 ImGui::EndCombo();
151 }
152 }
153 if (!doesNameExist) {
154 if (ImGui::Button("Add Shape")) {
155 switch (this->newShapeFill) {
156 case 0:
157 this->manager->addShape(this->newShapeParams);
158 LOG(1,
159 "Colored shape added with shapeName ["
160 + std::string(this->newShapeParams.shapeName) + "]")
161 break;
162 case 1:
163 this->manager->addShape(this->newShapeParams,
165 LOG(1,
166 "Textured shape added with shapeName ["
167 + std::string(this->newShapeParams.shapeName) + "]")
168 break;
169 }
170 }
171 }
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");
178 } else {
179 for (int i = 0; i < static_cast<int>(shapeDetails.size());
180 i++) {
181 if (ImGui::Selectable(shapeDetails[i].second.shapeName,
182 this->currentShapeSelection == i)) {
183 this->currentShapeSelection = i;
184 }
185 }
186 }
187 ImGui::EndListBox();
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;
194 = shapeDetails[currentShapeSelection].first;
196 = shapeDetails[currentShapeSelection].second;
197 }
198 ImGui::SameLine();
199 if (ImGui::Button("Remove Shape")) {
200 this->manager->removeObject(
201 shapeDetails[currentShapeSelection].first);
202 }
203 }
204 }
205
206 ImGui::End();
207 }
208}
Chronos::Manager::ShapeParams newShapeParams
void removeObject(int objectNo)
Definition manager.cpp:68
int addShape(Chronos::Manager::ShapeParams shapeParams, int texture)
Adds a textured rectangle to the window.
std::vector< TextureDetails > getTextureDetails()
Returns the details of all textures defined.
Holds some details about the texture.
Definition chronos.hpp:90

References LOG.

Here is the caller graph for this function:

◆ TextDetailsWindow()

void Chronos::Editor::EditorManager::TextDetailsWindow ( )
private

Definition at line 563 of file editorManager.cpp.

564{
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");
572 } else {
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");
579 }
580
581 ImGui::DragFloat("X(-1 to 1)", &this->textDetailsTextParams.x,
582 0.01f, -1.0f, 1.0f);
583 ImGui::DragFloat("Y(-1 to 1)", &this->textDetailsTextParams.y,
584 0.01f, -1.0f, 1.0f);
585 ImGui::DragFloat("Rotation", &this->textDetailsTextParams.rotation,
586 0.01f, 0.0f, FLT_MAX);
587 ImGui::DragFloat("Scale", &this->textDetailsTextParams.scale, 0.01f,
588 0.0f, FLT_MAX);
589 ImGui::ColorEdit3(
590 "Color", this->textDetailsTextParams.color.data());
591 this->manager->updateText(
593 }
594 ImGui::End();
595 }
596}
Chronos::Engine::TextParams textDetailsTextParams
std::vector< std::pair< int, Chronos::Engine::TextParams > > getTextDetails()
Returns the details of all text defined.
void updateText(int objectNo, Chronos::Engine::TextParams params)
Updates the text with the new parameters.
std::array< float, 3 > color
Here is the caller graph for this function:

◆ TextureDetailsWindow()

void Chronos::Editor::EditorManager::TextureDetailsWindow ( )
private

Definition at line 529 of file editorManager.cpp.

530{
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");
538 } else {
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");
550 ImGui::Image(
551 (ImTextureID)
552 textureDetails[this->textureDetailsCurrentSelection]
553 .descriptorSet,
554 ImVec2(
555 textureDetails[this->textureDetailsCurrentSelection].width,
556 textureDetails[this->textureDetailsCurrentSelection]
557 .height));
558 }
559 ImGui::End();
560 }
561}
Here is the caller graph for this function:

◆ TextureWindow()

void Chronos::Editor::EditorManager::TextureWindow ( )
private

Definition at line 210 of file editorManager.cpp.

211{
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();
220 for (Chronos::Manager::TextureDetails textureDetail :
221 nameTextureDetails) {
222 if (!strcmp(
223 this->newTextureName, textureDetail.textureName.c_str())) {
224 ImGui::Text("Name Already Exists");
225 doesTextureExist = true;
226 break;
227 }
228 if (std::string(this->newTextureName).size() == '\0') {
229 ImGui::Text("Name Cannot be empty");
230 doesTextureExist = true;
231 break;
232 }
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;
237 break;
238 }
239 }
240
241 if (!doesTextureExist) {
242 if (ImGui::Button("Add Texture")) {
243 this->manager->addTexture(
244 this->newTexturePath, this->newTextureName);
245 this->newTexturePath[0] = '\0';
246 LOG(1,
247 "Texture added with textureName ["
248 + std::string(this->newTextureName)
249 + "] and texturePath [" + this->newTexturePath + "]")
250 }
251 }
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");
258 } else {
259 for (int i = 0; i < static_cast<int>(details.size()); i++) {
260 if (ImGui::Selectable(details[i].textureName.c_str(),
263 }
264 }
265 }
266 ImGui::EndListBox();
267 }
268 if (details.size() > 0) {
269 if (ImGui::Button("Remove Texture")) {
270 this->manager->removeTexture(
271 details[currentTextureSelection].textureNo);
272 LOG(1,
273 "Texture removed with textureNo ["
274 + std::to_string(
275 details[currentTextureSelection].textureNo)
276 + "]")
277 }
278 ImGui::SameLine();
279 if (ImGui::Button("View Texture Details")) {
280 this->showTextureDetailsWindow = true;
281 LOG(1,
282 "Texture selected for editing with textureNo ["
283 + std::to_string(this->textureDetailsCurrentSelection)
284 + "]")
285 }
286 }
287 ImGui::End();
288 }
289}
void removeTexture(int textureNo)
Removes the texture from the window.
int addTexture(std::string texturePath, std::string textureName)
Loads a texture from file.

References LOG.

Here is the caller graph for this function:

◆ TextWindow()

void Chronos::Editor::EditorManager::TextWindow ( )
private

Definition at line 291 of file editorManager.cpp.

292{
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;
300 ImGui::DragFloat(
301 "X(-1 to 1)", &this->newTextParams.x, 0.01f, -1.0f, 1.0f);
302 ImGui::DragFloat(
303 "Y(-1 to 1)", &this->newTextParams.y, 0.01f, -1.0f, 1.0f);
304 ImGui::DragFloat(
305 "Rotation", &this->newTextParams.rotation, 0.01f, 0.0f, FLT_MAX);
306 ImGui::DragFloat(
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 + "]")
315 }
316 if (ImGui::Selectable("consolas_bold",
317 this->currentFontSelection == "consolas_bold")) {
318 this->currentFontSelection = "consolas_bold";
319 LOG(1, "Font selected [" + this->currentFontSelection + "]")
320 }
321 if (ImGui::Selectable(
322 "arial", this->currentFontSelection == "arial")) {
323 this->currentFontSelection = "arial";
324 LOG(1, "Font selected [" + this->currentFontSelection + "]")
325 }
326 if (ImGui::Selectable(
327 "arial_bold", this->currentFontSelection == "arial_bold")) {
328 this->currentFontSelection = "arial_bold";
329 LOG(1, "Font selected [" + this->currentFontSelection + "]")
330 }
331 if (ImGui::Selectable(
332 "times", this->currentFontSelection == "times")) {
333 this->currentFontSelection = "times";
334 LOG(1, "Font selected [" + this->currentFontSelection + "]")
335 }
336 if (ImGui::Selectable(
337 "times_bold", this->currentFontSelection == "times_bold")) {
338 this->currentFontSelection = "times_bold";
339 LOG(1, "Font selected [" + this->currentFontSelection + "]")
340 }
341 ImGui::EndCombo();
342 }
343 ImGui::DragInt("Font Size", &this->currentFontSizeSelection, 1, 6, 50);
344 if (this->newTextParams.text.size() == 0) {
345 ImGui::Text("Text Cannot be empty");
346 } else {
347 if (ImGui::Button("Add Text")) {
348 this->manager->addText(this->newTextParams,
350 LOG(1,
351 "Text added with text [" + this->newTextParams.text + "]")
352 }
353 }
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");
360 } else {
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;
365 }
366 }
367 }
368 ImGui::EndListBox();
369 if (textDetails.size() > 0) {
370 if (ImGui::Button("Edit Text")) {
371 this->showTextDetailsWindow = true;
373 = textDetails[currentTextSelection].first;
375 = textDetails[currentTextSelection].second;
376 LOG(1,
377 "Text selected for editing with textNo ["
378 + std::to_string(this->textDetailsTextNo) + "]")
379 }
380 ImGui::SameLine();
381 if (ImGui::Button("Remove Text")) {
382 this->manager->removeObject(
383 textDetails[currentTextSelection].first);
384 LOG(1,
385 "Text removed with textNo ["
386 + std::to_string(
387 textDetails[currentTextSelection].first)
388 + "]")
389 }
390 }
391 }
392 ImGui::End();
393 }
394}
Chronos::Engine::TextParams newTextParams
int addText(Chronos::Engine::TextParams params, std::string fontType, int fontSize)
Adds text to the window.

References LOG.

Here is the caller graph for this function:

◆ TotalCodeGenerationWindow()

void Chronos::Editor::EditorManager::TotalCodeGenerationWindow ( )
private

Definition at line 628 of file editorManager.cpp.

629{
630 if (this->showGeneratedCodeWindow) {
631 ImGui::Begin("Generated Code", &this->showGeneratedCodeWindow);
632 ImGui::SeparatorText("Generated Code");
633 std::string code = Chronos::Editor::generateCode(this->manager);
634 ImGui::InputTextMultiline("Code", code.data(), code.size(),
635 ImVec2(800, 600), ImGuiInputTextFlags_ReadOnly);
636 ImGui::End();
637 }
638}
std::string generateCode(Chronos::Manager::Manager *manager)

References Chronos::Editor::generateCode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateKeyframes()

void Chronos::Editor::EditorManager::updateKeyframes ( )
private

Definition at line 722 of file editorManager.cpp.

723{
724 for (auto& [key, value] : this->floatPointerToKeyframeNo) {
725 *key = this->manager->keyframeGetVariable(value);
726 LOG(4,
727 "Updated keyframe value for keyframeNo [" + std::to_string(value)
728 + "] to [" + std::to_string(*key) + "]")
729 }
730}
float keyframeGetVariable(int keyframeNo)
Definition chronos.hpp:487

References LOG.

Here is the caller graph for this function:

Member Data Documentation

◆ bgColor

float Chronos::Editor::EditorManager::bgColor[3] = { 0, 0, 0 }
private

Definition at line 113 of file editorManager.hpp.

113{ 0, 0, 0 };

◆ currentFontSelection

std::string Chronos::Editor::EditorManager::currentFontSelection = "consolas"
private

Definition at line 95 of file editorManager.hpp.

◆ currentFontSizeSelection

int Chronos::Editor::EditorManager::currentFontSizeSelection = 6
private

Definition at line 96 of file editorManager.hpp.

◆ currentKeyframeValuePointer

float* Chronos::Editor::EditorManager::currentKeyframeValuePointer = nullptr
private

Definition at line 120 of file editorManager.hpp.

◆ currentShapeSelection

int Chronos::Editor::EditorManager::currentShapeSelection = 0
private

Definition at line 86 of file editorManager.hpp.

◆ currentShapeTextureName

char Chronos::Editor::EditorManager::currentShapeTextureName[200] = "Select Texture"
private

Definition at line 85 of file editorManager.hpp.

◆ currentShapeTextureSelection

int Chronos::Editor::EditorManager::currentShapeTextureSelection = 0
private

Definition at line 84 of file editorManager.hpp.

◆ currentTextSelection

int Chronos::Editor::EditorManager::currentTextSelection = 0
private

Definition at line 97 of file editorManager.hpp.

◆ currentTextureSelection

int Chronos::Editor::EditorManager::currentTextureSelection = 0
private

Definition at line 91 of file editorManager.hpp.

◆ floatPointerToKeyframeNo

std::unordered_map<float*, int> Chronos::Editor::EditorManager::floatPointerToKeyframeNo
private

Definition at line 119 of file editorManager.hpp.

◆ fullScreen

bool Chronos::Editor::EditorManager::fullScreen = false
private

Definition at line 114 of file editorManager.hpp.

◆ isWindowFullscreen

bool Chronos::Editor::EditorManager::isWindowFullscreen = false
private

Definition at line 115 of file editorManager.hpp.

◆ manager

Chronos::Manager::Manager* Chronos::Editor::EditorManager::manager
private

Definition at line 36 of file editorManager.hpp.

◆ msaaSamples

std::string Chronos::Editor::EditorManager::msaaSamples = "1"
private

Definition at line 116 of file editorManager.hpp.

◆ newShapeFill

int Chronos::Editor::EditorManager::newShapeFill = 0
private

Definition at line 83 of file editorManager.hpp.

◆ newShapeParams

Chronos::Manager::ShapeParams Chronos::Editor::EditorManager::newShapeParams
private

Definition at line 82 of file editorManager.hpp.

◆ newTextParams

Chronos::Engine::TextParams Chronos::Editor::EditorManager::newTextParams
private

Definition at line 94 of file editorManager.hpp.

◆ newTextureName

char Chronos::Editor::EditorManager::newTextureName[200]
private

Definition at line 90 of file editorManager.hpp.

◆ newTexturePath

char Chronos::Editor::EditorManager::newTexturePath[200]
private

Definition at line 89 of file editorManager.hpp.

◆ pinMenuBar

bool Chronos::Editor::EditorManager::pinMenuBar = true
private

Definition at line 37 of file editorManager.hpp.

◆ presentMode

std::string Chronos::Editor::EditorManager::presentMode = "mailbox"
private

Definition at line 112 of file editorManager.hpp.

◆ shapeDetailsShapeNo

int Chronos::Editor::EditorManager::shapeDetailsShapeNo = 0
private

Definition at line 101 of file editorManager.hpp.

◆ shapeDetailsShapeParams

Chronos::Manager::ShapeParams Chronos::Editor::EditorManager::shapeDetailsShapeParams
private

Definition at line 100 of file editorManager.hpp.

◆ showAnimationWindow

bool Chronos::Editor::EditorManager::showAnimationWindow = false
private

Definition at line 42 of file editorManager.hpp.

◆ showDebugLogWindow

bool Chronos::Editor::EditorManager::showDebugLogWindow = false
private

Definition at line 52 of file editorManager.hpp.

◆ showDebugMetricsWindow

bool Chronos::Editor::EditorManager::showDebugMetricsWindow = false
private

Definition at line 51 of file editorManager.hpp.

◆ showGeneratedCodeWindow

bool Chronos::Editor::EditorManager::showGeneratedCodeWindow = false
private

Definition at line 44 of file editorManager.hpp.

◆ showKeyframeDetailsWindow

bool Chronos::Editor::EditorManager::showKeyframeDetailsWindow = false
private

Definition at line 49 of file editorManager.hpp.

◆ showSettingsWindow

bool Chronos::Editor::EditorManager::showSettingsWindow = false
private

Definition at line 43 of file editorManager.hpp.

◆ showShapeDetailsWindow

bool Chronos::Editor::EditorManager::showShapeDetailsWindow = false
private

Definition at line 46 of file editorManager.hpp.

◆ showShapeWindow

bool Chronos::Editor::EditorManager::showShapeWindow = false
private

Definition at line 39 of file editorManager.hpp.

◆ showTextDetailsWindow

bool Chronos::Editor::EditorManager::showTextDetailsWindow = false
private

Definition at line 48 of file editorManager.hpp.

◆ showTextureDetailsWindow

bool Chronos::Editor::EditorManager::showTextureDetailsWindow = false
private

Definition at line 47 of file editorManager.hpp.

◆ showTextureWindow

bool Chronos::Editor::EditorManager::showTextureWindow = false
private

Definition at line 40 of file editorManager.hpp.

◆ showTextWindow

bool Chronos::Editor::EditorManager::showTextWindow = false
private

Definition at line 41 of file editorManager.hpp.

◆ textDetailsTextNo

int Chronos::Editor::EditorManager::textDetailsTextNo = 0
private

Definition at line 105 of file editorManager.hpp.

◆ textDetailsTextParams

Chronos::Engine::TextParams Chronos::Editor::EditorManager::textDetailsTextParams
private

Definition at line 104 of file editorManager.hpp.

◆ textureDetailsCurrentSelection

int Chronos::Editor::EditorManager::textureDetailsCurrentSelection = 0
private

Definition at line 108 of file editorManager.hpp.

◆ windowTitle

char Chronos::Editor::EditorManager::windowTitle[200] = GAME_NAME
private

Definition at line 111 of file editorManager.hpp.


The documentation for this class was generated from the following files: