Skip to content

Commit

Permalink
added a tab for the editor
Browse files Browse the repository at this point in the history
  • Loading branch information
DanPeled committed May 17, 2024
1 parent c7508d4 commit 8b38be2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 48 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@
# Executables
*.exe
*.out
*.app
*.app
imgui.ini
37 changes: 0 additions & 37 deletions imgui.ini

This file was deleted.

Binary file modified main
Binary file not shown.
31 changes: 22 additions & 9 deletions src/WoopWoop/Editor/Editor.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "Editor.hpp"
#include <SFML/Graphics.hpp>

#define DEBUG true
#define NO_OPEN (bool *)__null

namespace wpwp::Editor
{
Expand Down Expand Up @@ -30,6 +30,10 @@ namespace wpwp::Editor
{
#pragma region Entities List
#if DEBUG
static int selectedUUIDIndex = -1;
static Entity *selectedEntity = nullptr;
static std::vector<std::string> componentNames{};

ImGui::Begin("Entities");

// Convert UUIDs to const char* array
Expand All @@ -40,9 +44,6 @@ namespace wpwp::Editor
uuidschr.push_back(uuid.c_str());
}

static int selectedUUIDIndex = -1;
static Entity *selectedEntity = nullptr;
static std::vector<std::string> componentNames{};
if (ImGui::BeginCombo("Choose", (selectedUUIDIndex >= 0 &&
selectedUUIDIndex < uuidschr.size())
? uuidschr[selectedUUIDIndex]
Expand Down Expand Up @@ -99,12 +100,24 @@ namespace wpwp::Editor
sprite.setTexture(Engine::getInstance()->m_renderTexture.getTexture());
sf::Vector2u textureSize = sprite.getTexture()->getSize();
#if DEBUG
ImGui::Begin("SFML Window");

ImVec2 imageSize(textureSize.x, textureSize.y);
ImGui::Image(Engine::getInstance()->m_renderTexture, sf::Color::White, sf::Color::White);
Input::mouseOffset = sf::Vector2i(ImGui::GetWindowPos().x, ImGui::GetWindowPos().y);
ImGui::Begin("Screen View", NO_OPEN, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove);
ImGui::SetWindowSize(ImVec2(1280, 720));
ImGui::SetWindowPos(ImVec2(13, 4));
ImGui::BeginTabBar("View");
if (ImGui::BeginTabItem("Gamplay"))
{
Engine::getInstance()->m_isPaused = false;
ImGui::Image(Engine::getInstance()->m_renderTexture, sf::Color::White, sf::Color::White);
Input::mouseOffset = sf::Vector2i(ImGui::GetWindowPos().x, ImGui::GetWindowPos().y + 49);
ImGui::EndTabItem();
}

if (ImGui::BeginTabItem("Editor"))
{
Engine::getInstance()->m_isPaused = true;
ImGui::EndTabItem();
}
ImGui::EndTabBar();
ImGui::End();
#else
Engine::getInstance()->window.draw(sprite); // render usually to the screen if isn't in debug mode
Expand Down
3 changes: 2 additions & 1 deletion src/WoopWoop/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ namespace wpwp

checkForEvents();
updateSequence();

// #if DEBUG
// #endif
m_renderTexture.display();

window.clear();
Expand Down

0 comments on commit 8b38be2

Please sign in to comment.