Fixed Actor Editor to allow selection of files from within mods/[not 'public']/... without it giving a silly relative path
This was SVN commit r6416.
This commit is contained in:
parent
92f42ee6c9
commit
dba26306e0
@ -16,7 +16,7 @@
|
||||
#include "AtlasUI/Misc/DLLInterface.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
|
||||
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int)
|
||||
#else
|
||||
int main()
|
||||
#endif
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "AtlasUI/Misc/DLLInterface.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
|
||||
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int)
|
||||
#else
|
||||
int main()
|
||||
#endif
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "AtlasUI/Misc/DLLInterface.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
|
||||
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int)
|
||||
#else
|
||||
int main()
|
||||
#endif
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "AtlasUI/Misc/DLLInterface.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
|
||||
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int)
|
||||
#else
|
||||
int main()
|
||||
#endif
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "AtlasUI/Misc/DLLInterface.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
|
||||
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int)
|
||||
#else
|
||||
int main()
|
||||
#endif
|
||||
|
@ -391,7 +391,7 @@ void ActorEditor::OnCreateEntity(wxCommandEvent& WXUNUSED(event))
|
||||
// Create the XML data to be written
|
||||
// TODO: Native line endings
|
||||
wxString xml =
|
||||
_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n")
|
||||
_T("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n")
|
||||
_T("\r\n")
|
||||
_T("<Entity Parent=\"") + parentName + _T("\">\r\n")
|
||||
_T("\t<Actor>") + actorFilename.GetFullPath(wxPATH_UNIX) + _T("</Actor>\r\n")
|
||||
|
@ -117,14 +117,15 @@ void FieldEditCtrl_Dialog::StartEdit(wxWindow* parent, wxRect WXUNUSED(rect), lo
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
FieldEditCtrl_File::FieldEditCtrl_File(const wxString& rootDir, const wxString& fileMask)
|
||||
: m_FileMask(fileMask)
|
||||
: m_RootDir(rootDir), m_FileMask(fileMask)
|
||||
{
|
||||
// Make the rootDir path absolute (where rootDir is relative to binaries/system):
|
||||
// Make the rootDir path absolute (where rootDir is relative to binaries/system),
|
||||
// defaulting to the 'public' mod:
|
||||
wxFileName path (_T("mods/public/") + rootDir);
|
||||
wxASSERT(path.IsOk());
|
||||
path.MakeAbsolute(Datafile::GetDataDirectory());
|
||||
wxASSERT(path.IsOk());
|
||||
m_RememberedDir = m_RootDir = path.GetPath();
|
||||
m_RememberedDir = path.GetPath();
|
||||
}
|
||||
|
||||
void FieldEditCtrl_File::StartEdit(wxWindow* parent, wxRect rect, long row, int col)
|
||||
|
@ -66,14 +66,14 @@ private:
|
||||
class FieldEditCtrl_File : public FieldEditCtrl
|
||||
{
|
||||
public:
|
||||
// rootDir is relative to mods/public, and must end with a /
|
||||
// rootDir is relative to mods/*/, and must end with a /
|
||||
FieldEditCtrl_File(const wxString& rootDir, const wxString& fileMask);
|
||||
|
||||
protected:
|
||||
void StartEdit(wxWindow* parent, wxRect rect, long row, int col);
|
||||
|
||||
private:
|
||||
wxString m_RootDir;
|
||||
wxString m_RootDir; // relative to mods/*/
|
||||
wxString m_FileMask;
|
||||
wxString m_RememberedDir;
|
||||
};
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
#include "QuickFileCtrl.h"
|
||||
|
||||
#include "General/Datafile.h"
|
||||
|
||||
#include "wx/filename.h"
|
||||
|
||||
const int verticalPadding = 2;
|
||||
@ -102,7 +104,14 @@ public:
|
||||
wxFileName oldFilename (parent->m_TextCtrl->GetValue()); // TODO: use wxPATH_UNIX?
|
||||
if (oldFilename.IsOk())
|
||||
{
|
||||
oldFilename.MakeAbsolute(m_RootDir);
|
||||
// XXX: this assumes the file was in the 'public' mod, which is
|
||||
// often untrue and will quite annoy users
|
||||
wxFileName path (_T("mods/public/") + m_RootDir);
|
||||
wxASSERT(path.IsOk());
|
||||
path.MakeAbsolute(Datafile::GetDataDirectory());
|
||||
wxASSERT(path.IsOk());
|
||||
|
||||
oldFilename.MakeAbsolute(path.GetPath());
|
||||
defaultDir = oldFilename.GetPath();
|
||||
defaultFile = oldFilename.GetFullName();
|
||||
}
|
||||
@ -124,9 +133,17 @@ public:
|
||||
wxFileName filename (dlg.GetPath());
|
||||
*parent->m_RememberedDir = filename.GetPath();
|
||||
|
||||
filename.MakeRelativeTo(m_RootDir);
|
||||
wxString filenameRel (filename.GetFullPath(wxPATH_UNIX));
|
||||
|
||||
// The file should be in ".../mods/*/$m_RootDir/..." for some unknown '*'
|
||||
// So assume it is, and just find the substring after the m_RootDir
|
||||
// (XXX: This is pretty bogus because of case-insensitive filenames etc)
|
||||
wxString filenameStr (filename.GetFullPath(wxPATH_UNIX));
|
||||
int idx = filenameStr.Find(m_RootDir);
|
||||
if (idx < 0)
|
||||
{
|
||||
wxLogError(_T("Selected file (%s) must be in a \"%s\" directory"), filenameStr.c_str(), m_RootDir.c_str());
|
||||
return;
|
||||
}
|
||||
wxString filenameRel (filenameStr.Mid(idx + m_RootDir.Len()));
|
||||
parent->m_TextCtrl->SetValue(filenameRel);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user