Better loading of editor toolbox icons
This commit is contained in:
@@ -88,6 +88,7 @@ private:
|
|||||||
boost::filesystem::path fileOpenDialog();
|
boost::filesystem::path fileOpenDialog();
|
||||||
boost::filesystem::path fileSaveDialog();
|
boost::filesystem::path fileSaveDialog();
|
||||||
const std::string formatEntityName(EntityWrapper entity);
|
const std::string formatEntityName(EntityWrapper entity);
|
||||||
|
GLuint tryLoadTexture(std::string filePath);
|
||||||
|
|
||||||
// Entity file handling methods
|
// Entity file handling methods
|
||||||
void entityImport(World* world);
|
void entityImport(World* world);
|
||||||
|
|||||||
@@ -35,46 +35,30 @@ void EditorGUI::drawTools()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLuint translateIcon = 0;
|
// Translate widget button
|
||||||
try {
|
ImGui::ImageButton((void*)tryLoadTexture("Textures/Icons/Translate.png"), ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0));
|
||||||
translateIcon = ResourceManager::Load<Texture>("Textures/Icons/Translate.png")->m_Texture;
|
// Rotate widget button
|
||||||
} catch (const std::exception&) { }
|
ImGui::SameLine();
|
||||||
GLuint rotateIcon = 0;
|
ImGui::ImageButton((void*)tryLoadTexture("Textures/Icons/Rotate.png"), ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0));
|
||||||
try {
|
// Scale widget button
|
||||||
rotateIcon = ResourceManager::Load<Texture>("Textures/Icons/Rotate.png")->m_Texture;
|
ImGui::SameLine();
|
||||||
} catch (const std::exception&) { }
|
ImGui::ImageButton((void*)tryLoadTexture("Textures/Icons/Scale.png"), ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0));
|
||||||
GLuint scaleIcon = 0;
|
|
||||||
try {
|
|
||||||
scaleIcon = ResourceManager::Load<Texture>("Textures/Icons/Scale.png")->m_Texture;
|
|
||||||
} catch (const std::exception&) { }
|
|
||||||
|
|
||||||
ImGui::ImageButton((void*)translateIcon, ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0));
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::ImageButton((void*)rotateIcon, ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0));
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::ImageButton((void*)scaleIcon, ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0));
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::ItemSize(ImVec2(5, 0));
|
ImGui::ItemSize(ImVec2(5, 0));
|
||||||
|
|
||||||
|
// Play button
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
GLuint playIcon = 0;
|
|
||||||
try {
|
|
||||||
playIcon = ResourceManager::Load<Texture>("Textures/Icons/Play.png")->m_Texture;
|
|
||||||
} catch (const std::exception&) { }
|
|
||||||
GLuint pauseIcon = 0;
|
|
||||||
try {
|
|
||||||
pauseIcon = ResourceManager::Load<Texture>("Textures/Icons/Pause.png")->m_Texture;
|
|
||||||
} catch (const std::exception&) { }
|
|
||||||
|
|
||||||
static bool paused = false;
|
static bool paused = false;
|
||||||
if (ImGui::ImageButton((void*)playIcon, ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), (!paused) ? ImVec4(0, 1, 0, 1) : ImVec4(1, 1, 1, 1))) {
|
if (ImGui::ImageButton((void*)tryLoadTexture("Textures/Icons/Play.png"), ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), (!paused) ? ImVec4(0, 1, 0, 1) : ImVec4(1, 1, 1, 1))) {
|
||||||
Events::Resume e;
|
Events::Resume e;
|
||||||
e.World = m_World;
|
e.World = m_World;
|
||||||
m_EventBroker->Publish(e);
|
m_EventBroker->Publish(e);
|
||||||
paused = false;
|
paused = false;
|
||||||
}
|
}
|
||||||
|
// Pause button
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::ImageButton((void*)pauseIcon, ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), (paused) ? ImVec4(0, 1, 0, 1) : ImVec4(1, 1, 1, 1))) {
|
if (ImGui::ImageButton((void*)tryLoadTexture("Textures/Icons/Pause.png"), ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), (paused) ? ImVec4(0, 1, 0, 1) : ImVec4(1, 1, 1, 1))) {
|
||||||
Events::Pause e;
|
Events::Pause e;
|
||||||
e.World = m_World;
|
e.World = m_World;
|
||||||
m_EventBroker->Publish(e);
|
m_EventBroker->Publish(e);
|
||||||
@@ -526,6 +510,15 @@ const std::string EditorGUI::formatEntityName(EntityWrapper entity)
|
|||||||
return name.str();
|
return name.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLuint EditorGUI::tryLoadTexture(std::string filePath)
|
||||||
|
{
|
||||||
|
GLuint texture = 0;
|
||||||
|
try {
|
||||||
|
texture = ResourceManager::Load<Texture>(filePath)->m_Texture;
|
||||||
|
} catch (const std::exception&) { }
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
void EditorGUI::entityImport(World* world)
|
void EditorGUI::entityImport(World* world)
|
||||||
{
|
{
|
||||||
boost::filesystem::path filePath = fileOpenDialog();
|
boost::filesystem::path filePath = fileOpenDialog();
|
||||||
|
|||||||
Reference in New Issue
Block a user