mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-21 20:08:40 +03:00
Now uses embedded resources
This commit is contained in:
@@ -51,6 +51,8 @@
|
||||
|
||||
#include <src/UI/ImUI.h>
|
||||
|
||||
#include <src/Resource/StaticResources.h>
|
||||
|
||||
namespace Nuake {
|
||||
Ref<UI::UserInterface> userInterface;
|
||||
ImFont* normalFont;
|
||||
@@ -64,6 +66,9 @@ namespace Nuake {
|
||||
_audioWindow = new AudioWindow();
|
||||
|
||||
BuildFonts();
|
||||
|
||||
using namespace Nuake::StaticResources;
|
||||
ImGui::LoadIniSettingsFromMemory((const char*)StaticResources::Resources_default_layout_ini);
|
||||
}
|
||||
|
||||
void EditorInterface::Init()
|
||||
|
||||
@@ -266,10 +266,6 @@ void EditorSelectionPanel::DrawMaterialPanel(Ref<Nuake::Material> material)
|
||||
{
|
||||
textureID = material->m_Albedo->GetID();
|
||||
}
|
||||
else
|
||||
{
|
||||
textureID = TextureManager::Get()->GetTexture("default")->GetID();
|
||||
}
|
||||
|
||||
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image1"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)))
|
||||
{
|
||||
@@ -304,10 +300,6 @@ void EditorSelectionPanel::DrawMaterialPanel(Ref<Nuake::Material> material)
|
||||
{
|
||||
textureID = material->m_Normal->GetID();
|
||||
}
|
||||
else
|
||||
{
|
||||
textureID = TextureManager::Get()->GetTexture("default")->GetID();
|
||||
}
|
||||
|
||||
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image3"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 1), ImVec4(1, 1, 1, 1)))
|
||||
{
|
||||
@@ -339,10 +331,6 @@ void EditorSelectionPanel::DrawMaterialPanel(Ref<Nuake::Material> material)
|
||||
{
|
||||
textureID = material->m_AO->GetID();
|
||||
}
|
||||
else
|
||||
{
|
||||
textureID = TextureManager::Get()->GetTexture("default")->GetID();
|
||||
}
|
||||
|
||||
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image2"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(1, 1, 1, 1), ImVec4(1, 1, 1, 1)))
|
||||
{
|
||||
@@ -374,10 +362,6 @@ void EditorSelectionPanel::DrawMaterialPanel(Ref<Nuake::Material> material)
|
||||
{
|
||||
textureID = material->m_Metalness->GetID();
|
||||
}
|
||||
else
|
||||
{
|
||||
textureID = TextureManager::Get()->GetTexture("default")->GetID();
|
||||
}
|
||||
|
||||
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image4"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 1), ImVec4(1, 1, 1, 1)))
|
||||
{
|
||||
@@ -412,10 +396,6 @@ void EditorSelectionPanel::DrawMaterialPanel(Ref<Nuake::Material> material)
|
||||
{
|
||||
textureID = material->m_Roughness->GetID();
|
||||
}
|
||||
else
|
||||
{
|
||||
textureID = TextureManager::Get()->GetTexture("default")->GetID();
|
||||
}
|
||||
|
||||
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image5"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)))
|
||||
{
|
||||
|
||||
@@ -71,11 +71,47 @@ namespace Nuake
|
||||
ImGui::PushFont(FontManager::GetFont(Icons));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
|
||||
const char* icon = ICON_FA_FOLDER;
|
||||
const std::string id = ICON_FA_FOLDER + std::string("##") + directory->name;
|
||||
if (ImGui::Button(id.c_str(), ImVec2(100, 100)))
|
||||
const std::string id = std::string("##") + directory->name;
|
||||
|
||||
ImVec2 prevCursor = ImGui::GetCursorPos();
|
||||
ImVec2 prevScreenPos = ImGui::GetCursorScreenPos();
|
||||
const bool selected = ImGui::Selectable(id.c_str(), Editor->Selection.Directory == directory, ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick, ImVec2(100, 150));
|
||||
if (selected)
|
||||
{
|
||||
m_CurrentDirectory = directory;
|
||||
if (ImGui::IsMouseDoubleClicked(0))
|
||||
{
|
||||
m_CurrentDirectory = directory;
|
||||
}
|
||||
|
||||
Editor->Selection = EditorSelection(directory);
|
||||
}
|
||||
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip(directory->name.c_str());
|
||||
|
||||
|
||||
ImGui::SetCursorPos(prevCursor);
|
||||
ImGui::Image((ImTextureID)TextureManager::Get()->GetTexture("Resources/Images/folder_icon.png")->GetID(), ImVec2(100, 100), ImVec2(0, 1), ImVec2(1, 0));
|
||||
|
||||
|
||||
auto imguiStyle = ImGui::GetStyle();
|
||||
|
||||
ImVec2 startOffset = ImVec2(imguiStyle.CellPadding.x / 2.0f, 0);
|
||||
ImVec2 offsetEnd = ImVec2(startOffset.x, imguiStyle.CellPadding.y / 2.0f);
|
||||
ImU32 rectColor = IM_COL32(255, 255, 255, 16);
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(prevScreenPos + ImVec2(0, 100) - startOffset, prevScreenPos + ImVec2(100, 150) + offsetEnd, rectColor, 1.0f);
|
||||
std::string visibleName = directory->name;
|
||||
const uint32_t MAX_CHAR_NAME = 35;
|
||||
if (directory->name.size() > MAX_CHAR_NAME)
|
||||
{
|
||||
visibleName = std::string(directory->name.begin(), directory->name.begin() + MAX_CHAR_NAME - 3) + "...";
|
||||
}
|
||||
|
||||
ImGui::TextWrapped(visibleName.c_str());
|
||||
|
||||
ImGui::SetCursorPosY(prevCursor.y + 150 - ImGui::GetTextLineHeight());
|
||||
ImGui::TextColored({ 1, 1, 1, 0.5f }, "Folder");
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
const std::string hoverMenuId = std::string("item_hover_menu") + std::to_string(drawId);
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseReleased(1))
|
||||
@@ -168,8 +204,6 @@ namespace Nuake
|
||||
RefreshFileBrowser();
|
||||
}
|
||||
|
||||
|
||||
ImGui::Text(directory->name.c_str());
|
||||
ImGui::PopFont();
|
||||
}
|
||||
|
||||
@@ -197,98 +231,169 @@ namespace Nuake
|
||||
{
|
||||
ImGui::PushFont(EditorInterface::bigIconFont);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, {0.f, 0.f});
|
||||
std::string fileExtension = file->GetExtension();
|
||||
if (fileExtension == ".png" || fileExtension == ".jpg")
|
||||
|
||||
ImVec2 prevCursor = ImGui::GetCursorPos();
|
||||
ImVec2 prevScreenPos = ImGui::GetCursorScreenPos();
|
||||
std::string id = std::string("##") + file->GetAbsolutePath();
|
||||
const bool selected = ImGui::Selectable(id.c_str(), Editor->Selection.File == file, ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick, ImVec2(100, 150));
|
||||
|
||||
bool shouldOpenScene = false;
|
||||
if (selected)
|
||||
{
|
||||
Ref<Texture> texture = TextureManager::Get()->GetTexture(file->GetAbsolutePath());
|
||||
ImGui::ImageButton((void*)texture->GetID(), ImVec2(100, 100), ImVec2(0, 1), ImVec2(1, 0));
|
||||
if (ImGui::IsMouseDoubleClicked(0))
|
||||
{
|
||||
if (file->GetFileType() == FileType::Map)
|
||||
{
|
||||
OS::OpenTrenchbroomMap(file->GetAbsolutePath());
|
||||
}
|
||||
|
||||
if (file->GetFileType() == FileType::Scene)
|
||||
{
|
||||
shouldOpenScene = true;
|
||||
}
|
||||
}
|
||||
|
||||
Editor->Selection = EditorSelection(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char* icon = ICON_FA_FILE;
|
||||
if (fileExtension == ".shader" || fileExtension == ".wren")
|
||||
icon = ICON_FA_FILE_CODE;
|
||||
if (fileExtension == ".map")
|
||||
icon = ICON_FA_BROOM;
|
||||
if (fileExtension == ".ogg" || fileExtension == ".mp3" || fileExtension == ".wav")
|
||||
icon = ICON_FA_FILE_AUDIO;
|
||||
if (fileExtension == ".gltf" || fileExtension == ".obj")
|
||||
icon = ICON_FA_FILE_IMAGE;
|
||||
|
||||
std::string fullName = icon + std::string("##") + file->GetAbsolutePath();
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip(file->GetName().c_str());
|
||||
|
||||
bool pressed = false;
|
||||
if (fileExtension == ".material")
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
|
||||
pressed = ImGui::ImageButton(fullName.c_str(), (void*)ThumbnailManager::Get().GetThumbnail(file->GetRelativePath())->GetID(), ImVec2(100, 100), ImVec2(0, 1), ImVec2(1, 0));
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
|
||||
pressed = ImGui::Button(fullName.c_str(), ImVec2(100, 100));
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
if (Editor->Selection.File == file)
|
||||
{
|
||||
ThumbnailManager::Get().MarkThumbnailAsDirty(file->GetRelativePath());
|
||||
}
|
||||
|
||||
if(pressed)
|
||||
{
|
||||
Editor->Selection = EditorSelection(file);
|
||||
}
|
||||
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0))
|
||||
{
|
||||
OS::OpenTrenchbroomMap(file->GetAbsolutePath());
|
||||
}
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
if (ImGui::BeginDragDropSource())
|
||||
{
|
||||
char pathBuffer[256];
|
||||
std::strncpy(pathBuffer, file->GetAbsolutePath().c_str(), sizeof(pathBuffer));
|
||||
std::string dragType;
|
||||
if (fileExtension == ".wren")
|
||||
{
|
||||
char pathBuffer[256];
|
||||
std::strncpy(pathBuffer, file->GetAbsolutePath().c_str(), sizeof(pathBuffer));
|
||||
std::string dragType;
|
||||
if (fileExtension == ".wren")
|
||||
{
|
||||
dragType = "_Script";
|
||||
}
|
||||
else if (fileExtension == ".map")
|
||||
{
|
||||
dragType = "_Map";
|
||||
}
|
||||
else if (fileExtension == ".material")
|
||||
{
|
||||
dragType = "_Material";
|
||||
}
|
||||
else if (fileExtension == ".obj" || fileExtension == ".mdl" || fileExtension == ".gltf" || fileExtension == ".md3" || fileExtension == ".fbx" || fileExtension == ".glb")
|
||||
{
|
||||
dragType = "_Model";
|
||||
}
|
||||
else if (fileExtension == ".interface")
|
||||
{
|
||||
dragType = "_Interface";
|
||||
}
|
||||
else if (fileExtension == ".prefab")
|
||||
{
|
||||
dragType = "_Prefab";
|
||||
}
|
||||
else if (fileExtension == ".png" || fileExtension == ".jpg")
|
||||
{
|
||||
dragType = "_Image";
|
||||
}
|
||||
else if (fileExtension == ".wav" || fileExtension == ".ogg")
|
||||
{
|
||||
dragType = "_AudioFile";
|
||||
}
|
||||
|
||||
ImGui::SetDragDropPayload(dragType.c_str(), (void*)(pathBuffer), sizeof(pathBuffer));
|
||||
ImGui::Text(file->GetName().c_str());
|
||||
ImGui::EndDragDropSource();
|
||||
dragType = "_Script";
|
||||
}
|
||||
else if (fileExtension == ".map")
|
||||
{
|
||||
dragType = "_Map";
|
||||
}
|
||||
else if (fileExtension == ".material")
|
||||
{
|
||||
dragType = "_Material";
|
||||
}
|
||||
else if (fileExtension == ".obj" || fileExtension == ".mdl" || fileExtension == ".gltf" || fileExtension == ".md3" || fileExtension == ".fbx" || fileExtension == ".glb")
|
||||
{
|
||||
dragType = "_Model";
|
||||
}
|
||||
else if (fileExtension == ".interface")
|
||||
{
|
||||
dragType = "_Interface";
|
||||
}
|
||||
else if (fileExtension == ".prefab")
|
||||
{
|
||||
dragType = "_Prefab";
|
||||
}
|
||||
else if (fileExtension == ".png" || fileExtension == ".jpg")
|
||||
{
|
||||
dragType = "_Image";
|
||||
}
|
||||
else if (fileExtension == ".wav" || fileExtension == ".ogg")
|
||||
{
|
||||
dragType = "_AudioFile";
|
||||
}
|
||||
|
||||
ImGui::SetDragDropPayload(dragType.c_str(), (void*)(pathBuffer), sizeof(pathBuffer));
|
||||
ImGui::Text(file->GetName().c_str());
|
||||
ImGui::EndDragDropSource();
|
||||
}
|
||||
|
||||
|
||||
Ref<Texture> textureImage =TextureManager::Get()->GetTexture("Resources/Images/folder_icon.png");
|
||||
|
||||
const auto textureMgr = TextureManager::Get();
|
||||
const auto fileType = file->GetFileType();
|
||||
if (fileType == FileType::Material)
|
||||
{
|
||||
textureImage = ThumbnailManager::Get().GetThumbnail(file->GetRelativePath());
|
||||
}
|
||||
else if (fileType == FileType::Image)
|
||||
{
|
||||
const std::string path = file->GetAbsolutePath();
|
||||
textureImage = textureMgr->GetTexture(path);
|
||||
}
|
||||
else if (fileType == FileType::Project)
|
||||
{
|
||||
textureImage = textureMgr->GetTexture("Resources/Images/logo.png");
|
||||
}
|
||||
|
||||
ImGui::SetCursorPos(prevCursor);
|
||||
ImGui::Image((ImTextureID)textureImage->GetID(), ImVec2(100, 100), ImVec2(0, 1), ImVec2(1, 0));
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
auto imguiStyle = ImGui::GetStyle();
|
||||
|
||||
ImVec2 startOffset = ImVec2(imguiStyle.CellPadding.x / 2.0f, 0);
|
||||
ImVec2 offsetEnd = ImVec2(startOffset.x, imguiStyle.CellPadding.y / 2.0f);
|
||||
ImU32 rectColor = IM_COL32(255, 255, 255, 16);
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(prevScreenPos + ImVec2(0, 100) - startOffset, prevScreenPos + ImVec2(100, 150) + offsetEnd, rectColor, 1.0f);
|
||||
std::string visibleName = file->GetName();
|
||||
const uint32_t MAX_CHAR_NAME = 35;
|
||||
if (file->GetName().size() > MAX_CHAR_NAME)
|
||||
{
|
||||
visibleName = std::string(file->GetName().begin(), file->GetName().begin() + MAX_CHAR_NAME - 3) + "...";
|
||||
}
|
||||
|
||||
ImGui::TextWrapped(visibleName.c_str());
|
||||
|
||||
ImGui::SetCursorPosY(prevCursor.y + 150 - ImGui::GetTextLineHeight());
|
||||
ImGui::TextColored({ 1, 1, 1, 0.5f }, file->GetFileTypeAsString().c_str());
|
||||
|
||||
//if (fileExtension == ".png" || fileExtension == ".jpg")
|
||||
//{
|
||||
//
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// const char* icon = ICON_FA_FILE;
|
||||
// if (fileExtension == ".shader" || fileExtension == ".wren")
|
||||
// icon = ICON_FA_FILE_CODE;
|
||||
// if (fileExtension == ".map")
|
||||
// icon = ICON_FA_BROOM;
|
||||
// if (fileExtension == ".ogg" || fileExtension == ".mp3" || fileExtension == ".wav")
|
||||
// icon = ICON_FA_FILE_AUDIO;
|
||||
// if (fileExtension == ".gltf" || fileExtension == ".obj")
|
||||
// icon = ICON_FA_FILE_IMAGE;
|
||||
//
|
||||
// std::string fullName = icon + std::string("##") + file->GetAbsolutePath();
|
||||
//
|
||||
// bool pressed = false;
|
||||
// if (fileExtension == ".material")
|
||||
// {
|
||||
// ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
|
||||
// pressed = ImGui::ImageButton(fullName.c_str(), (void*)ThumbnailManager::Get().GetThumbnail(file-//>GetRelativePath())->GetID(), ImVec2(100, 100), ImVec2(0, 1), ImVec2(1, 0));
|
||||
// ImGui::PopStyleVar();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
|
||||
// pressed = ImGui::Button(fullName.c_str(), ImVec2(100, 100));
|
||||
// ImGui::PopStyleVar();
|
||||
// }
|
||||
//
|
||||
if (Editor->Selection.File == file)
|
||||
{
|
||||
ThumbnailManager::Get().MarkThumbnailAsDirty(file->GetRelativePath());
|
||||
}
|
||||
//
|
||||
// if(pressed)
|
||||
// {
|
||||
// Editor->Selection = EditorSelection(file);
|
||||
// }
|
||||
//
|
||||
// if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0))
|
||||
// {
|
||||
// OS::OpenTrenchbroomMap(file->GetAbsolutePath());
|
||||
// }
|
||||
//}
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
|
||||
const std::string hoverMenuId = std::string("item_hover_menu") + std::to_string(drawId);
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseReleased(1))
|
||||
@@ -298,7 +403,7 @@ namespace Nuake
|
||||
}
|
||||
|
||||
const std::string openSceneId = "Open Scene" + std::string("##") + hoverMenuId;
|
||||
bool shouldOpenScene = false;
|
||||
|
||||
|
||||
const std::string renameId = "Rename" + std::string("##") + hoverMenuId;
|
||||
bool shouldRename = false;
|
||||
@@ -385,11 +490,6 @@ namespace Nuake
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0))
|
||||
{
|
||||
shouldOpenScene = file->GetExtension() == ".scene";
|
||||
}
|
||||
|
||||
// Open Scene Popup
|
||||
|
||||
if (shouldOpenScene)
|
||||
@@ -407,6 +507,7 @@ namespace Nuake
|
||||
return;
|
||||
}
|
||||
|
||||
FileSystem::SetRootDirectory(projectPath + "/");
|
||||
scene->Path = FileSystem::AbsoluteToRelative(projectPath);
|
||||
Engine::LoadScene(scene);
|
||||
}
|
||||
@@ -445,8 +546,6 @@ namespace Nuake
|
||||
RefreshFileBrowser();
|
||||
}
|
||||
|
||||
|
||||
ImGui::Text(file->GetName().c_str());
|
||||
ImGui::PopFont();
|
||||
}
|
||||
|
||||
@@ -793,6 +892,7 @@ namespace Nuake
|
||||
}
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
ImGui::EndChild();
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Nuake
|
||||
class LoadingSplash
|
||||
{
|
||||
private:
|
||||
const std::string NUAKE_LOGO_PATH = "resources/Images/logo_white.png";
|
||||
const std::string NUAKE_LOGO_PATH = "Resources/Images/logo_white.png";
|
||||
Ref<Nuake::Texture> _NuakeLogo;
|
||||
|
||||
public:
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include "EditorInterface.h"
|
||||
#include "FileSystemUI.h"
|
||||
|
||||
#include <src/UI/ImUI.h>
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
ProjectPreview::ProjectPreview(const std::string& path)
|
||||
@@ -43,7 +45,7 @@ namespace Nuake
|
||||
}
|
||||
else
|
||||
{
|
||||
ProjectIcon = TextureManager::Get()->GetTexture("resources/Images/nuake-logo.png");
|
||||
ProjectIcon = TextureManager::Get()->GetTexture("Resources/Images/nuake-logo.png");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -124,6 +126,17 @@ namespace Nuake
|
||||
ImGui::Image((ImTextureID)_NuakeLogo->GetID(), imguiSize, ImVec2(0, 1), ImVec2(1, 0));
|
||||
}
|
||||
|
||||
//ImGui::SameLine();
|
||||
|
||||
std::string versionInfo = "pre-alpha ";
|
||||
#ifdef NK_DEBUG
|
||||
versionInfo += "debug build";
|
||||
#endif
|
||||
#ifdef NK_DIST
|
||||
versionInfo += "dist build";
|
||||
#endif
|
||||
ImGui::TextColored({1, 1, 1, 0.5}, versionInfo.c_str());
|
||||
// ImGui::TextColored({ 1, 1, 1, 0.5 }, "239d9479");
|
||||
// Add padding under logo
|
||||
ImGui::Dummy(ImVec2(10, 16));
|
||||
|
||||
@@ -179,7 +192,6 @@ namespace Nuake
|
||||
|
||||
void WelcomeWindow::DrawProjectItem(const uint32_t itemIndex)
|
||||
{
|
||||
|
||||
const ProjectPreview& project = _Projects[itemIndex];
|
||||
const uint32_t itemHeight = 120;
|
||||
const float cursorYStart = ImGui::GetCursorPosY();
|
||||
@@ -194,16 +206,14 @@ namespace Nuake
|
||||
// Channel number is like z-order. Widgets in higher channels are rendered above widgets in lower channels.
|
||||
draw_list->ChannelsSetCurrent(1);
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0, 0, 0, 0));
|
||||
bool result = ImGui::Selectable(selectableName.c_str(), isSelected, ImGuiSelectableFlags_AllowItemOverlap, ImVec2(ImGui::GetContentRegionAvail().x, itemHeight));
|
||||
if (isSelected)
|
||||
//ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0, 0, 0, 0));
|
||||
bool result = ImGui::Selectable(selectableName.c_str(), SelectedProject == itemIndex, ImGuiSelectableFlags_AllowOverlap, ImVec2(ImGui::GetContentRegionAvail().x, itemHeight));
|
||||
if (result)
|
||||
{
|
||||
ImVec2 p_min = ImGui::GetItemRectMin();
|
||||
ImVec2 p_max = ImGui::GetItemRectMax();
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(p_min, p_max, IM_COL32(10.0f, 182.0f, 255.f, 255.0f), 8.0f);
|
||||
SelectedProject = itemIndex;
|
||||
}
|
||||
|
||||
ImGui::PopStyleColor();
|
||||
//ImGui::PopStyleColor();
|
||||
|
||||
draw_list->ChannelsMerge();
|
||||
|
||||
@@ -217,7 +227,10 @@ namespace Nuake
|
||||
const ImVec2 iconSize = ImVec2(100, 100);
|
||||
ImGui::SetCursorPos(ImVec2(padding.x / 2.0, padding.y / 2.0) + ImVec2(0, cursorYStart));
|
||||
|
||||
ImGui::Image((ImTextureID)project.ProjectIcon->GetID(), iconSize, ImVec2(0, 1), ImVec2(1, 0));
|
||||
if (project.ProjectIcon)
|
||||
{
|
||||
ImGui::Image((ImTextureID)project.ProjectIcon->GetID(), iconSize, ImVec2(0, 1), ImVec2(1, 0));
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
ImGui::SetCursorPosX(padding.x + iconSize.x + padding.x);
|
||||
@@ -244,14 +257,14 @@ namespace Nuake
|
||||
const float buttonHeight = 36.0f;
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0, 0, 0, 0));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 16.0f);
|
||||
if (ImGui::BeginChild("Controls", ImVec2(200.0f, ImGui::GetContentRegionAvail().y), false))
|
||||
if (ImGui::BeginChild("Controls", ImVec2(250.0f, ImGui::GetContentRegionAvail().y), false))
|
||||
{
|
||||
ImGui::PopStyleVar();
|
||||
const ImVec2 buttonSize = ImVec2(ImGui::GetContentRegionAvail().x, buttonHeight);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.14f, 0.5f));
|
||||
const std::string buttonLabel = std::string(ICON_FA_FOLDER_PLUS) + " New Game Project...";
|
||||
if (ImGui::Button(buttonLabel.c_str(), buttonSize))
|
||||
if (Nuake::UI::PrimaryButton(buttonLabel.c_str(), { buttonSize.x, buttonSize.y }))
|
||||
{
|
||||
std::string selectedProject = FileDialog::SaveFile("Project file\0*.project");
|
||||
|
||||
@@ -287,34 +300,48 @@ namespace Nuake
|
||||
projectPreview.Name = project->Name;
|
||||
projectPreview.Description = project->Description;
|
||||
projectPreview.Path = project->FullPath;
|
||||
|
||||
projectPreview.ProjectIcon = nullptr;
|
||||
_Projects.push_back(projectPreview);
|
||||
}
|
||||
}
|
||||
ImGui::PopStyleVar(2);
|
||||
ImGui::Separator();
|
||||
|
||||
if (SelectedProject != -1)
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.16f, 0.5f));
|
||||
const std::string buttonLabelOpen = std::string(ICON_FA_FOLDER_OPEN) + " Load Selected Project";
|
||||
|
||||
bool hasProjectSelected = false;
|
||||
if (SelectedProject < std::size(_Projects) && SelectedProject >= 0)
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.16f, 0.5f));
|
||||
const std::string buttonLabelOpen = std::string(ICON_FA_FOLDER_OPEN) + " Load Selected Project";
|
||||
if (ImGui::Button(buttonLabelOpen.c_str(), buttonSize) || ImGui::IsMouseDoubleClicked(0))
|
||||
{
|
||||
assert(SelectedProject < std::size(_Projects));
|
||||
|
||||
SaveRecentFile();
|
||||
|
||||
queuedProjectPath = _Projects[SelectedProject].Path;;
|
||||
}
|
||||
ImGui::PopStyleVar(2);
|
||||
hasProjectSelected = true;
|
||||
}
|
||||
|
||||
if (!hasProjectSelected)
|
||||
{
|
||||
ImGui::BeginDisabled(true);
|
||||
}
|
||||
|
||||
if (Nuake::UI::SecondaryButton(buttonLabelOpen, { buttonSize.x, buttonSize.y }))
|
||||
{
|
||||
SaveRecentFile();
|
||||
|
||||
queuedProjectPath = _Projects[SelectedProject].Path;;
|
||||
}
|
||||
|
||||
if (!hasProjectSelected)
|
||||
{
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar(2);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.09f, 0.5f));
|
||||
const std::string buttonLabelDoc = std::string(ICON_FA_EXTERNAL_LINK_SQUARE_ALT) + " Documentation";
|
||||
if (ImGui::Button(buttonLabelDoc.c_str(), buttonSize))
|
||||
if (Nuake::UI::SecondaryButton(buttonLabelDoc, { buttonSize.x, buttonSize.y }))
|
||||
{
|
||||
OS::OpenURL("https://nuake.readthedocs.io/en/latest/index.html");
|
||||
}
|
||||
|
||||
@@ -32,14 +32,14 @@ namespace Nuake
|
||||
class WelcomeWindow
|
||||
{
|
||||
private:
|
||||
const std::string NUAKE_LOGO_PATH = "resources/Images/logo_white.png";
|
||||
const std::string NUAKE_LOGO_PATH = "Resources/Images/logo_white.png";
|
||||
Ref<Texture> _NuakeLogo;
|
||||
EditorInterface* _Editor;
|
||||
|
||||
const std::string _RecentProjectFilePath = "recent.json";
|
||||
const std::string _RecentProjectFileDefaultContent = "{ \"Projects\": [ ] }";
|
||||
|
||||
uint32_t SelectedProject = 0;
|
||||
int32_t SelectedProject = -1;
|
||||
std::vector<ProjectPreview> _Projects;
|
||||
std::string queuedProjectPath;
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user