Skip to content

Commit

Permalink
Add directory support to Py plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
ForserX committed Mar 2, 2025
1 parent 3a54eb6 commit 360869b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Editors/LevelEditor/Plugins/PluginPython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ xr_string CPluginPython::RunCommand(const xr_string& command)
PROCESS_INFORMATION pi;
xr_string cmd = "cmd /C " + command;

// Óêàçûâàåì ðàáî÷èé êàòàëîã
string_path Root;
FS.update_path(Root, "$fs_root$", "");

// Ñîçäàåì ïðîöåññ
if (!CreateProcessA(nullptr, const_cast<char*>(cmd.c_str()), nullptr, nullptr, TRUE, CREATE_NO_WINDOW, nullptr, nullptr, &si, &pi))
if (!CreateProcessA(nullptr, const_cast<char*>(cmd.c_str()), nullptr, nullptr, TRUE, CREATE_NO_WINDOW, nullptr, Root, &si, &pi))
{
CloseHandle(hRead);
CloseHandle(hWrite);
Expand All @@ -59,6 +63,7 @@ xr_string CPluginPython::RunCommand(const xr_string& command)
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);

output = Platform::ANSI_TO_UTF8(output);
return output;
}

Expand Down
16 changes: 16 additions & 0 deletions src/Editors/LevelEditor/Plugins/PluginsUIRun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ void CPluginUIRun::Draw()
continue;
}

xr_string TestPath = Desc;
TestPath = TestPath.RemoveWhitespaces();
if (FS.pathes.contains(TestPath.c_str()))
{
string_path FullPath = {};
FS.update_path(FullPath, TestPath.c_str(), "");
if (FullPath[strlen(FullPath) - 1] == '\\')
{
FullPath[strlen(FullPath) - 1] = '\0';
}

xr_string FixedPath = std::filesystem::absolute(FullPath).string().c_str();
xr_strcpy(InputPlugin->InputArgsValues[Arg], FixedPath.c_str());
continue;
}

ImGui::Text(Desc.c_str());
ImGui::InputText(("##" + Arg).c_str(), InputPlugin->InputArgsValues[Arg], 256);

Expand Down

0 comments on commit 360869b

Please sign in to comment.