mirror of
https://github.com/overte-org/overte.git
synced 2025-08-11 01:53:10 +02:00
Merge pull request #2403 from Atlante45/fix_models_upload
Fix models upload
This commit is contained in:
commit
5d361a1bd0
4 changed files with 23 additions and 11 deletions
|
@ -138,9 +138,8 @@ Menu::Menu() :
|
||||||
this,
|
this,
|
||||||
SLOT(goTo()));
|
SLOT(goTo()));
|
||||||
|
|
||||||
addDisabledActionAndSeparator(fileMenu, "Upload/Browse");
|
addDisabledActionAndSeparator(fileMenu, "Upload Avatar Model");
|
||||||
addActionToQMenuAndActionHash(fileMenu, MenuOption::UploaderAvatarHead, 0, Application::getInstance(), SLOT(uploadFST()));
|
addActionToQMenuAndActionHash(fileMenu, MenuOption::UploadFST, 0, Application::getInstance(), SLOT(uploadFST()));
|
||||||
addActionToQMenuAndActionHash(fileMenu, MenuOption::UploaderAvatarSkeleton, 0, Application::getInstance(), SLOT(uploadFST()));
|
|
||||||
|
|
||||||
addDisabledActionAndSeparator(fileMenu, "Settings");
|
addDisabledActionAndSeparator(fileMenu, "Settings");
|
||||||
addActionToQMenuAndActionHash(fileMenu, MenuOption::SettingsImport, 0, this, SLOT(importSettings()));
|
addActionToQMenuAndActionHash(fileMenu, MenuOption::SettingsImport, 0, this, SLOT(importSettings()));
|
||||||
|
@ -715,7 +714,6 @@ void Menu::editPreferences() {
|
||||||
QPushButton headBrowseButton(BROWSE_BUTTON_TEXT);
|
QPushButton headBrowseButton(BROWSE_BUTTON_TEXT);
|
||||||
connect(&headBrowseButton, SIGNAL(clicked()), &headBrowser, SLOT(browse()));
|
connect(&headBrowseButton, SIGNAL(clicked()), &headBrowser, SLOT(browse()));
|
||||||
connect(&headBrowser, SIGNAL(selected(QString)), &headURLEdit, SLOT(setText(QString)));
|
connect(&headBrowser, SIGNAL(selected(QString)), &headURLEdit, SLOT(setText(QString)));
|
||||||
headURLEdit.setReadOnly(true);
|
|
||||||
headURLEdit.setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
headURLEdit.setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
||||||
headURLEdit.setPlaceholderText(DEFAULT_HEAD_MODEL_URL.toString());
|
headURLEdit.setPlaceholderText(DEFAULT_HEAD_MODEL_URL.toString());
|
||||||
headModelLayout.addWidget(&headURLEdit);
|
headModelLayout.addWidget(&headURLEdit);
|
||||||
|
@ -728,7 +726,6 @@ void Menu::editPreferences() {
|
||||||
QPushButton SkeletonBrowseButton(BROWSE_BUTTON_TEXT);
|
QPushButton SkeletonBrowseButton(BROWSE_BUTTON_TEXT);
|
||||||
connect(&SkeletonBrowseButton, SIGNAL(clicked()), &skeletonBrowser, SLOT(browse()));
|
connect(&SkeletonBrowseButton, SIGNAL(clicked()), &skeletonBrowser, SLOT(browse()));
|
||||||
connect(&skeletonBrowser, SIGNAL(selected(QString)), &skeletonURLEdit, SLOT(setText(QString)));
|
connect(&skeletonBrowser, SIGNAL(selected(QString)), &skeletonURLEdit, SLOT(setText(QString)));
|
||||||
skeletonURLEdit.setReadOnly(true);
|
|
||||||
skeletonURLEdit.setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
skeletonURLEdit.setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
||||||
skeletonURLEdit.setPlaceholderText(DEFAULT_BODY_MODEL_URL.toString());
|
skeletonURLEdit.setPlaceholderText(DEFAULT_BODY_MODEL_URL.toString());
|
||||||
skeletonModelLayout.addWidget(&skeletonURLEdit);
|
skeletonModelLayout.addWidget(&skeletonURLEdit);
|
||||||
|
|
|
@ -295,8 +295,7 @@ namespace MenuOption {
|
||||||
const QString StopAllScripts = "Stop All Scripts";
|
const QString StopAllScripts = "Stop All Scripts";
|
||||||
const QString TestPing = "Test Ping";
|
const QString TestPing = "Test Ping";
|
||||||
const QString TransmitterDrive = "Transmitter Drive";
|
const QString TransmitterDrive = "Transmitter Drive";
|
||||||
const QString UploaderAvatarHead = "Upload Avatar Head";
|
const QString UploadFST = "Upload FST file";
|
||||||
const QString UploaderAvatarSkeleton = "Upload Avatar Skeleton";
|
|
||||||
const QString Visage = "Visage";
|
const QString Visage = "Visage";
|
||||||
const QString Quit = "Quit";
|
const QString Quit = "Quit";
|
||||||
const QString Voxels = "Voxels";
|
const QString Voxels = "Voxels";
|
||||||
|
|
|
@ -24,6 +24,7 @@ static const QString NAME_FIELD = "name";
|
||||||
static const QString FILENAME_FIELD = "filename";
|
static const QString FILENAME_FIELD = "filename";
|
||||||
static const QString TEXDIR_FIELD = "texdir";
|
static const QString TEXDIR_FIELD = "texdir";
|
||||||
static const QString LOD_FIELD = "lod";
|
static const QString LOD_FIELD = "lod";
|
||||||
|
static const QString HEAD_SPECIFIC_FIELD = "bs";
|
||||||
|
|
||||||
static const QString MODEL_URL = "/api/v1/models";
|
static const QString MODEL_URL = "/api/v1/models";
|
||||||
|
|
||||||
|
@ -32,6 +33,7 @@ static const int MAX_SIZE = 10 * 1024 * 1024; // 10 MB
|
||||||
FstReader::FstReader() :
|
FstReader::FstReader() :
|
||||||
_lodCount(-1),
|
_lodCount(-1),
|
||||||
_texturesCount(-1),
|
_texturesCount(-1),
|
||||||
|
_isHead(false),
|
||||||
_readyToSend(false),
|
_readyToSend(false),
|
||||||
_dataMultiPart(new QHttpMultiPart(QHttpMultiPart::FormDataType))
|
_dataMultiPart(new QHttpMultiPart(QHttpMultiPart::FormDataType))
|
||||||
{
|
{
|
||||||
|
@ -81,13 +83,15 @@ bool FstReader::zip() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// according to what is read, we modify the command
|
// according to what is read, we modify the command
|
||||||
if (line.first() == NAME_FIELD) {
|
if (line[1] == HEAD_SPECIFIC_FIELD) {
|
||||||
|
_isHead = true;
|
||||||
|
} else if (line[1] == NAME_FIELD) {
|
||||||
QHttpPart textPart;
|
QHttpPart textPart;
|
||||||
textPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data;"
|
textPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data;"
|
||||||
" name=\"model_name\"");
|
" name=\"model_name\"");
|
||||||
textPart.setBody(line[1].toUtf8());
|
textPart.setBody(line[1].toUtf8());
|
||||||
_dataMultiPart->append(textPart);
|
_dataMultiPart->append(textPart);
|
||||||
} else if (line.first() == FILENAME_FIELD) {
|
} else if (line[1] == FILENAME_FIELD) {
|
||||||
QFileInfo fbx(QFileInfo(fst).path() + "/" + line[1]);
|
QFileInfo fbx(QFileInfo(fst).path() + "/" + line[1]);
|
||||||
if (!fbx.exists() || !fbx.isFile()) { // Check existence
|
if (!fbx.exists() || !fbx.isFile()) { // Check existence
|
||||||
qDebug() << "[ERROR] FBX file " << fbx.absoluteFilePath() << " doesn't exist.";
|
qDebug() << "[ERROR] FBX file " << fbx.absoluteFilePath() << " doesn't exist.";
|
||||||
|
@ -101,7 +105,7 @@ bool FstReader::zip() {
|
||||||
if (!addPart(_zipDir.path() + "/" + line[1], "fbx")) {
|
if (!addPart(_zipDir.path() + "/" + line[1], "fbx")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (line.first() == TEXDIR_FIELD) { // Check existence
|
} else if (line[1] == TEXDIR_FIELD) { // Check existence
|
||||||
QFileInfo texdir(QFileInfo(fst).path() + "/" + line[1]);
|
QFileInfo texdir(QFileInfo(fst).path() + "/" + line[1]);
|
||||||
if (!texdir.exists() || !texdir.isDir()) {
|
if (!texdir.exists() || !texdir.isDir()) {
|
||||||
qDebug() << "[ERROR] Texture directory " << texdir.absolutePath() << " doesn't exist.";
|
qDebug() << "[ERROR] Texture directory " << texdir.absolutePath() << " doesn't exist.";
|
||||||
|
@ -110,7 +114,7 @@ bool FstReader::zip() {
|
||||||
if (!addTextures(texdir)) { // Recursive compress and copy
|
if (!addTextures(texdir)) { // Recursive compress and copy
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (line.first() == LOD_FIELD) {
|
} else if (line[1] == LOD_FIELD) {
|
||||||
QFileInfo lod(QFileInfo(fst).path() + "/" + line[1]);
|
QFileInfo lod(QFileInfo(fst).path() + "/" + line[1]);
|
||||||
if (!lod.exists() || !lod.isFile()) { // Check existence
|
if (!lod.exists() || !lod.isFile()) { // Check existence
|
||||||
qDebug() << "[ERROR] FBX file " << lod.absoluteFilePath() << " doesn't exist.";
|
qDebug() << "[ERROR] FBX file " << lod.absoluteFilePath() << " doesn't exist.";
|
||||||
|
@ -127,6 +131,17 @@ bool FstReader::zip() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QHttpPart textPart;
|
||||||
|
textPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data;"
|
||||||
|
" name=\"model_category\"");
|
||||||
|
if (_isHead) {
|
||||||
|
textPart.setBody("head");
|
||||||
|
} else {
|
||||||
|
textPart.setBody("skeleton");
|
||||||
|
}
|
||||||
|
_dataMultiPart->append(textPart);
|
||||||
|
|
||||||
_readyToSend = true;
|
_readyToSend = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ private:
|
||||||
int _lodCount;
|
int _lodCount;
|
||||||
int _texturesCount;
|
int _texturesCount;
|
||||||
int _totalSize;
|
int _totalSize;
|
||||||
|
bool _isHead;
|
||||||
bool _readyToSend;
|
bool _readyToSend;
|
||||||
|
|
||||||
QHttpMultiPart* _dataMultiPart;
|
QHttpMultiPart* _dataMultiPart;
|
||||||
|
|
Loading…
Reference in a new issue