Added an action in the Model Editor for converting DDS to TXTR

This commit is contained in:
parax0 2015-11-26 03:55:27 -07:00
parent 6ceb1b9230
commit 2adddad4b6
3 changed files with 34 additions and 0 deletions

View File

@ -14,6 +14,7 @@
#include <Resource/factory/CMaterialLoader.h>
#include <Resource/factory/CTextureDecoder.h>
#include <Resource/cooker/CModelCooker.h>
#include <Resource/cooker/CTextureEncoder.h>
#include "WColorPicker.h"
#include <iostream>
@ -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!");
}
}
}

View File

@ -117,6 +117,8 @@ private slots:
void on_CameraModeButton_clicked();
void on_actionConvert_DDS_to_TXTR_triggered();
signals:
void Closed();
};

View File

@ -2443,6 +2443,7 @@
<string>Textures</string>
</property>
<addaction name="actionConvert_to_DDS"/>
<addaction name="actionConvert_DDS_to_TXTR"/>
</widget>
<widget class="QMenu" name="menuWindow">
<property name="title">
@ -2504,6 +2505,11 @@
<string>Save as...</string>
</property>
</action>
<action name="actionConvert_DDS_to_TXTR">
<property name="text">
<string>Convert DDS to TXTR</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>