diff --git a/OTM_GUI/OTM_File.cpp b/OTM_GUI/OTM_File.cpp index 714faf4..655886a 100644 --- a/OTM_GUI/OTM_File.cpp +++ b/OTM_GUI/OTM_File.cpp @@ -73,6 +73,17 @@ OTM_File::~OTM_File(void) } +bool OTM_File::FileSupported(void) +{ + wxString file_type = FileName.AfterLast( '.'); + if (file_type == L"zip") return true; + else if (file_type == L"tpf") return true; + else if (file_type == L"dds") return true; + + return false; +} + + int OTM_File::GetComment( wxString &tool_tip) { wxString file_type = FileName.AfterLast( '.'); diff --git a/OTM_GUI/OTM_File.h b/OTM_GUI/OTM_File.h index 8951438..cf9f669 100644 --- a/OTM_GUI/OTM_File.h +++ b/OTM_GUI/OTM_File.h @@ -29,6 +29,8 @@ public: OTM_File(OTM_Language &lang, const wxString &file); ~OTM_File(void); + bool FileSupported(void); + int GetComment( wxString &tool_tip); int GetContent( AddTextureClass *tex, bool add, bool force); diff --git a/OTM_GUI/OTM_GUI.cpp b/OTM_GUI/OTM_GUI.cpp index 5cb81ef..4625d92 100644 --- a/OTM_GUI/OTM_GUI.cpp +++ b/OTM_GUI/OTM_GUI.cpp @@ -267,11 +267,17 @@ void OTM_Frame::OnButtonOpen(wxCommandEvent& WXUNUSED(event)) OTM_GamePage *page = (OTM_GamePage*) Notebook->GetCurrentPage(); if (page==NULL) return; - wxString file_name = wxFileSelector( Language.ChooseFile, page->GetOpenPath(), "", "*.*", "textures (*.dds)|*.dds|zip (*.zip)|*.zip|tpf (*.tpf)|*.tpf", wxFD_OPEN | wxFD_FILE_MUST_EXIST, this); + + //wxString file_name = wxFileSelector( Language.ChooseFile, page->GetOpenPath(), "", "*.*", "textures (*.dds)|*.dds|zip (*.zip)|*.zip|tpf (*.tpf)|*.tpf", wxFD_OPEN | wxFD_FILE_MUST_EXIST, this); + wxString file_name = wxFileSelector( Language.ChooseFile, page->GetOpenPath(), "", "", "", wxFD_OPEN | wxFD_FILE_MUST_EXIST, this); if ( !file_name.empty() ) { page->SetOpenPath(file_name.BeforeLast( '/')); - page->AddTexture( file_name); + if (page->AddTexture( file_name)) + { + wxMessageBox(page->LastError, "ERROR", wxOK|wxICON_ERROR); + page->LastError.Empty(); + } } } diff --git a/OTM_GUI/OTM_GamePage.cpp b/OTM_GUI/OTM_GamePage.cpp index 8137d19..7616c5f 100644 --- a/OTM_GUI/OTM_GamePage.cpp +++ b/OTM_GUI/OTM_GamePage.cpp @@ -188,16 +188,14 @@ int OTM_GamePage::SetSavePath( const wxString &path) } -void OTM_GamePage::AddTexture( const wxString &file_name) +int OTM_GamePage::AddTexture( const wxString &file_name) { - if (NumberOfEntry>=MaxNumberOfEntry) return; + if (NumberOfEntry>=MaxNumberOfEntry) {LastError = Language.Error_Memory; return -1;} OTM_File file( Language, file_name); + if (!file.FileSupported()) {LastError << Language.Error_FileNotSupported << "\n" << file_name; return -1;} + wxString tool_tip; - if (file.GetComment( tool_tip)) - { - LastError = file.LastError; - file.LastError.Empty(); - } + file.GetComment( tool_tip); CheckBoxHSizers[NumberOfEntry] = new wxBoxSizer(wxHORIZONTAL); CheckBoxes[NumberOfEntry] = new wxCheckBox( this, -1, file_name); @@ -226,6 +224,8 @@ void OTM_GamePage::AddTexture( const wxString &file_name) Files.Add( file_name); NumberOfEntry++; MainSizer->Layout(); + + return 0; } int OTM_GamePage::GetSettings(void) diff --git a/OTM_GUI/OTM_GamePage.h b/OTM_GUI/OTM_GamePage.h index 0aadca3..5d10143 100644 --- a/OTM_GUI/OTM_GamePage.h +++ b/OTM_GUI/OTM_GamePage.h @@ -30,7 +30,7 @@ public: OTM_GamePage( wxNotebook *parent, const wxString &name, PipeStruct &pipe, OTM_Language &lang); virtual ~OTM_GamePage(void); - void AddTexture( const wxString &file_name); + int AddTexture( const wxString &file_name); int UpdateGame(void);