diff --git a/UI/CModelEditorWindow.cpp b/UI/CModelEditorWindow.cpp index e80ee930..9ac3a654 100644 --- a/UI/CModelEditorWindow.cpp +++ b/UI/CModelEditorWindow.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include "WColorPicker.h" #include @@ -832,3 +833,28 @@ void CModelEditorWindow::on_CameraModeButton_clicked() pCam->SetOrbitDistance(Pos.Distance(Target)); } } + +void CModelEditorWindow::on_actionConvert_DDS_to_TXTR_triggered() +{ + QString Input = QFileDialog::getOpenFileName(this, "DirectDraw Surface (*.dds)", "", "*.dds"); + if (Input.isEmpty()) return; + + TString TexFilename = TO_TSTRING(Input); + CTexture *Tex = CTextureDecoder::LoadDDS(CFileInStream(TexFilename.ToStdString(), IOUtil::LittleEndian)); + TString OutName = TexFilename.GetFilePathWithoutExtension() + ".txtr"; + + if ((Tex->TexelFormat() != eDXT1) || (Tex->NumMipMaps() > 1)) + QMessageBox::warning(this, "Error", "Can't convert DDS to TXTR! Save your texture as a DXT1 DDS with no mipmaps, then try again."); + + else + { + CFileOutStream Out(OutName.ToStdString(), IOUtil::BigEndian); + if (!Out.IsValid()) QMessageBox::warning(this, "Error", "Couldn't open output TXTR!"); + + else + { + CTextureEncoder::EncodeTXTR(Out, Tex, eGX_CMPR); + QMessageBox::information(this, "Success", "Successfully converted to TXTR!"); + } + } +} diff --git a/UI/CModelEditorWindow.h b/UI/CModelEditorWindow.h index ecd68142..5a22a429 100644 --- a/UI/CModelEditorWindow.h +++ b/UI/CModelEditorWindow.h @@ -117,6 +117,8 @@ private slots: void on_CameraModeButton_clicked(); + void on_actionConvert_DDS_to_TXTR_triggered(); + signals: void Closed(); }; diff --git a/UI/CModelEditorWindow.ui b/UI/CModelEditorWindow.ui index ff716819..3bd2aabd 100644 --- a/UI/CModelEditorWindow.ui +++ b/UI/CModelEditorWindow.ui @@ -2443,6 +2443,7 @@ Textures + @@ -2504,6 +2505,11 @@ Save as... + + + Convert DDS to TXTR + +