import asset dialogs remembers last used directories
This commit is contained in:
parent
e7e6c2c514
commit
83a9ecd363
|
@ -1,4 +1,4 @@
|
|||
#LumixEngine
|
||||
#Lumix Engine
|
||||
=========
|
||||
|
||||
<a href="https://scan.coverity.com/projects/5919">
|
||||
|
|
|
@ -1591,6 +1591,7 @@ ImportAssetDialog::ImportAssetDialog(Lumix::WorldEditor& editor, Metadata& metad
|
|||
m_source[0] = '\0';
|
||||
m_output_dir[0] = '\0';
|
||||
m_texture_output_dir[0] = '\0';
|
||||
Lumix::copyString(m_last_dir, m_editor.getEngine().getPathManager().getBasePath());
|
||||
}
|
||||
|
||||
|
||||
|
@ -1621,7 +1622,7 @@ bool ImportAssetDialog::checkTexture(const char* source_dir,
|
|||
<< path
|
||||
<< " not found, please locate it");
|
||||
|
||||
if (!PlatformInterface::getOpenFilename(new_path, sizeof(new_path), "All\0*.*\0")) return false;
|
||||
if (!PlatformInterface::getOpenFilename(new_path, sizeof(new_path), "All\0*.*\0", nullptr)) return false;
|
||||
|
||||
Lumix::string old_path_str(path, m_editor.getAllocator());
|
||||
Lumix::string new_path_str(new_path, m_editor.getAllocator());
|
||||
|
@ -1862,10 +1863,16 @@ void ImportAssetDialog::onGUI()
|
|||
ImGui::SameLine();
|
||||
if (ImGui::Button("..."))
|
||||
{
|
||||
PlatformInterface::getOpenFilename(m_source, sizeof(m_source), "All\0*.*\0");
|
||||
PlatformInterface::getOpenFilename(m_source, sizeof(m_source), "All\0*.*\0", m_source);
|
||||
checkSource();
|
||||
}
|
||||
|
||||
if (m_is_importing || m_is_converting)
|
||||
{
|
||||
ImGui::EndDock();
|
||||
return;
|
||||
}
|
||||
|
||||
if (isImage(m_source))
|
||||
{
|
||||
if (ImGui::Checkbox("Convert to raw", &m_convert_to_raw))
|
||||
|
@ -1885,7 +1892,8 @@ void ImportAssetDialog::onGUI()
|
|||
ImGui::SameLine();
|
||||
if (ImGui::Button("...###browseoutput"))
|
||||
{
|
||||
PlatformInterface::getOpenDirectory(m_output_dir, sizeof(m_output_dir));
|
||||
auto* base_path = m_editor.getEngine().getPathManager().getBasePath();
|
||||
PlatformInterface::getOpenDirectory(m_output_dir, sizeof(m_output_dir), base_path);
|
||||
}
|
||||
|
||||
if (ImGui::Button("Import texture"))
|
||||
|
@ -1896,9 +1904,9 @@ void ImportAssetDialog::onGUI()
|
|||
return;
|
||||
}
|
||||
|
||||
if (m_importer.GetScene())
|
||||
auto* scene = m_importer.GetScene();
|
||||
if (scene)
|
||||
{
|
||||
auto* scene = m_importer.GetScene();
|
||||
ImGui::Checkbox("Import model", &m_import_model);
|
||||
if (m_import_model)
|
||||
{
|
||||
|
@ -1961,7 +1969,10 @@ void ImportAssetDialog::onGUI()
|
|||
ImGui::SameLine();
|
||||
if (ImGui::Button("...###browseoutput"))
|
||||
{
|
||||
PlatformInterface::getOpenDirectory(m_output_dir, sizeof(m_output_dir));
|
||||
if (PlatformInterface::getOpenDirectory(m_output_dir, sizeof(m_output_dir), m_last_dir))
|
||||
{
|
||||
Lumix::copyString(m_last_dir, m_output_dir);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::InputText(
|
||||
|
@ -1969,8 +1980,11 @@ void ImportAssetDialog::onGUI()
|
|||
ImGui::SameLine();
|
||||
if (ImGui::Button("...###browsetextureoutput"))
|
||||
{
|
||||
PlatformInterface::getOpenDirectory(
|
||||
m_texture_output_dir, sizeof(m_texture_output_dir));
|
||||
if (PlatformInterface::getOpenDirectory(
|
||||
m_texture_output_dir, sizeof(m_texture_output_dir), m_last_dir))
|
||||
{
|
||||
Lumix::copyString(m_last_dir, m_output_dir);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_output_dir[0] != '\0')
|
||||
|
|
|
@ -61,6 +61,7 @@ class LUMIX_EDITOR_API ImportAssetDialog
|
|||
Lumix::BinaryArray m_mesh_mask;
|
||||
char m_import_message[1024];
|
||||
char m_message[1024];
|
||||
char m_last_dir[Lumix::MAX_PATH_LENGTH];
|
||||
char m_source[Lumix::MAX_PATH_LENGTH];
|
||||
char m_output_dir[Lumix::MAX_PATH_LENGTH];
|
||||
char m_texture_output_dir[Lumix::MAX_PATH_LENGTH];
|
||||
|
|
|
@ -578,33 +578,73 @@ namespace PlatformInterface
|
|||
}
|
||||
|
||||
|
||||
bool getOpenFilename(char* out, int max_size, const char* filter)
|
||||
bool getOpenFilename(char* out, int max_size, const char* filter, const char* starting_file)
|
||||
{
|
||||
OPENFILENAME ofn;
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = NULL;
|
||||
if (starting_file)
|
||||
{
|
||||
char* to = out;
|
||||
for (const char* from = starting_file; *from; ++from, ++to)
|
||||
{
|
||||
if (to - out > max_size - 1) break;
|
||||
*to = *to == '/' ? '\\' : *from;
|
||||
}
|
||||
*to = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
out[0] = '\0';
|
||||
}
|
||||
ofn.lpstrFile = out;
|
||||
ofn.lpstrFile[0] = '\0';
|
||||
ofn.nMaxFile = max_size;
|
||||
ofn.lpstrFilter = filter;
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrFileTitle = NULL;
|
||||
ofn.nMaxFileTitle = 0;
|
||||
ofn.lpstrInitialDir = NULL;
|
||||
ofn.lpstrInitialDir = nullptr;
|
||||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_NONETWORKBUTTON;
|
||||
|
||||
return GetOpenFileName(&ofn) == TRUE;
|
||||
auto x= GetOpenFileName(&ofn);
|
||||
auto err =GetLastError();
|
||||
auto err2 =CommDlgExtendedError();
|
||||
return x == TRUE;
|
||||
}
|
||||
|
||||
|
||||
bool getOpenDirectory(char* out, int max_size)
|
||||
bool getOpenDirectory(char* out, int max_size, const char* starting_dir)
|
||||
{
|
||||
bool ret = false;
|
||||
IFileDialog *pfd;
|
||||
if (SUCCEEDED(CoCreateInstance(
|
||||
CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd))))
|
||||
{
|
||||
if (starting_dir)
|
||||
{
|
||||
PIDLIST_ABSOLUTE pidl;
|
||||
WCHAR wstarting_dir[MAX_PATH];
|
||||
WCHAR* wc = wstarting_dir;
|
||||
for (const char* c = starting_dir; *c && wc - wstarting_dir < MAX_PATH - 1; ++c, ++wc)
|
||||
{
|
||||
*wc = *c == '/' ? '\\' : *c;
|
||||
}
|
||||
*wc = 0;
|
||||
|
||||
HRESULT hresult = ::SHParseDisplayName(wstarting_dir, 0, &pidl, SFGAO_FOLDER, 0);
|
||||
if (SUCCEEDED(hresult))
|
||||
{
|
||||
IShellItem *psi;
|
||||
hresult = ::SHCreateShellItem(NULL, NULL, pidl, &psi);
|
||||
if (SUCCEEDED(hresult))
|
||||
{
|
||||
pfd->SetFolder(psi);
|
||||
}
|
||||
ILFree(pidl);
|
||||
}
|
||||
}
|
||||
|
||||
DWORD dwOptions;
|
||||
if (SUCCEEDED(pfd->GetOptions(&dwOptions)))
|
||||
{
|
||||
|
|
|
@ -96,12 +96,12 @@ namespace PlatformInterface
|
|||
LUMIX_EDITOR_API void getKeyName(int key, char* out, int max_size);
|
||||
LUMIX_EDITOR_API void setCursor(Cursor cursor);
|
||||
|
||||
LUMIX_EDITOR_API bool getOpenFilename(char* out, int max_size, const char* filter);
|
||||
LUMIX_EDITOR_API bool getOpenFilename(char* out, int max_size, const char* filter, const char* starting_file);
|
||||
LUMIX_EDITOR_API bool getSaveFilename(char* out,
|
||||
int max_size,
|
||||
const char* filter,
|
||||
const char* default_extension);
|
||||
LUMIX_EDITOR_API bool getOpenDirectory(char* out, int max_size);
|
||||
LUMIX_EDITOR_API bool getOpenDirectory(char* out, int max_size, const char* starting_dir);
|
||||
LUMIX_EDITOR_API bool shellExecuteOpen(const char* path);
|
||||
|
||||
LUMIX_EDITOR_API bool deleteFile(const char* path);
|
||||
|
|
|
@ -442,7 +442,7 @@ public:
|
|||
void loadAndExecuteCommands()
|
||||
{
|
||||
char filename[Lumix::MAX_PATH_LENGTH];
|
||||
if (PlatformInterface::getOpenFilename(filename, Lumix::lengthOf(filename), "JSON files\0*.json\0"))
|
||||
if (PlatformInterface::getOpenFilename(filename, Lumix::lengthOf(filename), "JSON files\0*.json\0", nullptr))
|
||||
{
|
||||
m_editor->executeUndoStack(Lumix::Path(filename));
|
||||
}
|
||||
|
|
|
@ -1775,7 +1775,7 @@ void ShaderEditor::loadNodeConnections(Lumix::InputBlob& blob, Node& node)
|
|||
void ShaderEditor::load()
|
||||
{
|
||||
char path[Lumix::MAX_PATH_LENGTH];
|
||||
if (!PlatformInterface::getOpenFilename(path, Lumix::lengthOf(path), "Shader edit data\0*.sed\0"))
|
||||
if (!PlatformInterface::getOpenFilename(path, Lumix::lengthOf(path), "Shader edit data\0*.sed\0", nullptr))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1289,7 +1289,7 @@ void TerrainEditor::onGUI()
|
|||
if (ImGui::Button("Select mask"))
|
||||
{
|
||||
char filename[Lumix::MAX_PATH_LENGTH];
|
||||
if (PlatformInterface::getOpenFilename(filename, Lumix::lengthOf(filename), "All\0*.*\0"))
|
||||
if (PlatformInterface::getOpenFilename(filename, Lumix::lengthOf(filename), "All\0*.*\0", nullptr))
|
||||
{
|
||||
int image_width;
|
||||
int image_height;
|
||||
|
|
|
@ -1624,7 +1624,6 @@ struct PipelineImpl : public Pipeline
|
|||
rots[bone_index].toMatrix(bone_mtx[bone_index]);
|
||||
bone_mtx[bone_index].translate(poss[bone_index]);
|
||||
bone_mtx[bone_index] = bone_mtx[bone_index] * bone.inv_bind_matrix;
|
||||
//bone_mtx[bone_index].transpose();
|
||||
}
|
||||
bgfx::setUniform(m_bone_matrices_uniform, bone_mtx, pose.getCount());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue