NK-100 - 'Open In' button

This commit is contained in:
Émeryc
2023-07-16 17:15:55 -04:00
parent 752f9ac8f8
commit 439e104c86
4 changed files with 24 additions and 1 deletions

View File

@@ -426,9 +426,16 @@ void EditorSelectionPanel::DrawWrenScriptPanel(Ref<Nuake::WrenScript> wrenFile)
{
auto filePath = wrenFile->GetFile()->GetAbsolutePath();
std::string fileContent = Nuake::FileSystem::ReadFile(filePath, true);
ImGui::Text("Content");
ImGui::SameLine(ImGui::GetWindowWidth()-90);
if(ImGui::Button("Open In..."))
{
Nuake::OS::OpenIn(filePath);
}
ImGui::Separator();
ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + ImGui::GetWindowWidth());
ImGui::Text(fileContent.c_str(), ImGui::GetWindowWidth());

View File

@@ -181,6 +181,16 @@ namespace Nuake
OS::ShowInFileExplorer(file->GetAbsolutePath());
}
if(file->GetExtension() == ".wren")
{
ImGui::Separator();
if(ImGui::MenuItem("Open In..."))
{
OS::OpenIn(file->GetAbsolutePath());
}
}
if(file->GetExtension() != ".project")
{
ImGui::Separator();

View File

@@ -10,6 +10,11 @@ int OS::GetTime()
return static_cast<int>(std::chrono::system_clock::now().time_since_epoch().count());
}
void OS::OpenIn(const std::string& filePath)
{
ShellExecuteA(nullptr, "open", filePath.c_str(), nullptr, nullptr, SW_SHOWDEFAULT);
}
void OS::ShowInFileExplorer(const std::string& filePath)
{
ShellExecuteA(nullptr, "open", "explorer.exe", ("/select," + std::string(filePath)).c_str(), nullptr, SW_SHOWDEFAULT);

View File

@@ -8,6 +8,7 @@ namespace Nuake
{
public:
static int GetTime();
static void OpenIn(const std::string& filePath);
static void ShowInFileExplorer(const std::string& filePath);
};
}