Compare commits
2 commits
530789f0b3
...
b31e90ef68
Author | SHA1 | Date | |
---|---|---|---|
b31e90ef68 | |||
7a160cdde8 |
3 changed files with 19 additions and 6 deletions
|
@ -14,9 +14,10 @@
|
|||
#include <memory>
|
||||
#include <numbers>
|
||||
#include <optional>
|
||||
#include <qsoundeffect.h>
|
||||
#include <reactphysics3d/collision/RaycastInfo.h>
|
||||
#include <vector>
|
||||
#include <QSound>
|
||||
#include <QSoundEffect>
|
||||
|
||||
#include "datatypes/cframe.h"
|
||||
#include "datatypes/vector.h"
|
||||
|
@ -52,6 +53,13 @@ void MainGLWidget::initializeGL() {
|
|||
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;
|
||||
|
||||
void MainGLWidget::resizeGL(int w, int h) {
|
||||
|
@ -212,9 +220,7 @@ void MainGLWidget::handleLinearTransform(QMouseEvent* evt) {
|
|||
|
||||
// Apply snapping in the current frame
|
||||
glm::vec3 diff = centerPoint - (glm::vec3)editorToolHandles->adornee->lock()->position();
|
||||
// printf("\n=======\nPre-snap: (%f, %f, %f)\n", diff.x, diff.y, diff.z);
|
||||
if (snappingFactor()) diff = frame.Rotation() * (glm::round(glm::vec3(frame.Inverse().Rotation() * diff) / snappingFactor()) * snappingFactor());
|
||||
// printf("Post-snap: (%f, %f, %f)\n", diff.x, diff.y, diff.z);
|
||||
|
||||
Data::Vector3 oldSize = part->size;
|
||||
|
||||
|
@ -247,7 +253,7 @@ void MainGLWidget::handleLinearTransform(QMouseEvent* evt) {
|
|||
}
|
||||
|
||||
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()));
|
||||
}
|
||||
|
@ -318,6 +324,13 @@ void MainGLWidget::handleCursorChange(QMouseEvent* evt) {
|
|||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
void MainGLWidget::wheelEvent(QWheelEvent* evt) {
|
||||
camera.processMovement(evt->angleDelta().y() < 0 ? DIRECTION_BACKWARDS : DIRECTION_FORWARD, 0.25f);
|
||||
|
||||
if (mainWindow()->editSoundEffects && QFile::exists("./assets/excluded/SWITCH3.wav"))
|
||||
playSound("./assets/excluded/SWITCH3.wav");
|
||||
}
|
||||
|
||||
void MainGLWidget::mouseMoveEvent(QMouseEvent* evt) {
|
||||
handleCameraRotate(evt);
|
||||
handleObjectDrag(evt);
|
||||
|
@ -381,7 +394,7 @@ void MainGLWidget::mousePressEvent(QMouseEvent* evt) {
|
|||
}
|
||||
|
||||
if (mainWindow()->editSoundEffects && QFile::exists("./assets/excluded/electronicpingshort.wav"))
|
||||
QSound::play("./assets/excluded/electronicpingshort.wav");
|
||||
playSound("./assets/excluded/electronicpingshort.wav");
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ protected:
|
|||
void handleCursorChange(QMouseEvent* evt);
|
||||
std::optional<HandleFace> raycastHandle(glm::vec3 pointDir);
|
||||
|
||||
void wheelEvent(QWheelEvent* evt) override;
|
||||
void mouseMoveEvent(QMouseEvent* evt) override;
|
||||
void mousePressEvent(QMouseEvent* evt) override;
|
||||
void mouseReleaseEvent(QMouseEvent* evt) override;
|
||||
|
|
|
@ -131,7 +131,6 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
connect(ui->actionToggleEditSounds, &QAction::triggered, this, [&](bool state) {
|
||||
editSoundEffects = state;
|
||||
printf("%d\n", editSoundEffects);
|
||||
ui->actionToggleEditSounds->setIcon(QIcon::fromTheme(editSoundEffects ? "audio-volume-high" : "audio-volume-muted"));
|
||||
});
|
||||
ui->actionToggleEditSounds->setChecked(true);
|
||||
|
|
Loading…
Add table
Reference in a new issue