fix(editor): stopped relying on QSound which doesn't exist in Qt6
This commit is contained in:
parent
7a160cdde8
commit
b31e90ef68
1 changed files with 12 additions and 4 deletions
|
@ -14,9 +14,10 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <numbers>
|
#include <numbers>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <qsoundeffect.h>
|
||||||
#include <reactphysics3d/collision/RaycastInfo.h>
|
#include <reactphysics3d/collision/RaycastInfo.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <QSound>
|
#include <QSoundEffect>
|
||||||
|
|
||||||
#include "datatypes/cframe.h"
|
#include "datatypes/cframe.h"
|
||||||
#include "datatypes/vector.h"
|
#include "datatypes/vector.h"
|
||||||
|
@ -52,6 +53,13 @@ void MainGLWidget::initializeGL() {
|
||||||
renderInit(NULL, width(), height());
|
renderInit(NULL, width(), height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void playSound(QString path) {
|
||||||
|
QSoundEffect *sound = new QSoundEffect;
|
||||||
|
sound->setSource(QUrl::fromLocalFile(path));
|
||||||
|
sound->play();
|
||||||
|
sound->connect(sound, &QSoundEffect::playingChanged, [=]() { /* Thank you QSound source code! */ sound->deleteLater(); return false; });
|
||||||
|
}
|
||||||
|
|
||||||
extern int vpx, vpy;
|
extern int vpx, vpy;
|
||||||
|
|
||||||
void MainGLWidget::resizeGL(int w, int h) {
|
void MainGLWidget::resizeGL(int w, int h) {
|
||||||
|
@ -245,7 +253,7 @@ void MainGLWidget::handleLinearTransform(QMouseEvent* evt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mainWindow()->editSoundEffects && (oldSize != part->size) && QFile::exists("./assets/excluded/switch.wav"))
|
if (mainWindow()->editSoundEffects && (oldSize != part->size) && QFile::exists("./assets/excluded/switch.wav"))
|
||||||
QSound::play("./assets/excluded/switch.wav");
|
playSound("./assets/excluded/switch.wav");
|
||||||
|
|
||||||
syncPartPhysics(std::dynamic_pointer_cast<Part>(editorToolHandles->adornee->lock()));
|
syncPartPhysics(std::dynamic_pointer_cast<Part>(editorToolHandles->adornee->lock()));
|
||||||
}
|
}
|
||||||
|
@ -320,7 +328,7 @@ void MainGLWidget::wheelEvent(QWheelEvent* evt) {
|
||||||
camera.processMovement(evt->angleDelta().y() < 0 ? DIRECTION_BACKWARDS : DIRECTION_FORWARD, 0.25f);
|
camera.processMovement(evt->angleDelta().y() < 0 ? DIRECTION_BACKWARDS : DIRECTION_FORWARD, 0.25f);
|
||||||
|
|
||||||
if (mainWindow()->editSoundEffects && QFile::exists("./assets/excluded/SWITCH3.wav"))
|
if (mainWindow()->editSoundEffects && QFile::exists("./assets/excluded/SWITCH3.wav"))
|
||||||
QSound::play("./assets/excluded/SWITCH3.wav");
|
playSound("./assets/excluded/SWITCH3.wav");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainGLWidget::mouseMoveEvent(QMouseEvent* evt) {
|
void MainGLWidget::mouseMoveEvent(QMouseEvent* evt) {
|
||||||
|
@ -386,7 +394,7 @@ void MainGLWidget::mousePressEvent(QMouseEvent* evt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mainWindow()->editSoundEffects && QFile::exists("./assets/excluded/electronicpingshort.wav"))
|
if (mainWindow()->editSoundEffects && QFile::exists("./assets/excluded/electronicpingshort.wav"))
|
||||||
QSound::play("./assets/excluded/electronicpingshort.wav");
|
playSound("./assets/excluded/electronicpingshort.wav");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue