feat(editor): added sound effects toggle button and resize sound effects

This commit is contained in:
maelstrom 2025-04-07 21:22:06 +02:00
parent f88e4e2416
commit 6bb01dda36
4 changed files with 55 additions and 13 deletions

View file

@ -216,6 +216,8 @@ void MainGLWidget::handleLinearTransform(QMouseEvent* evt) {
if (snappingFactor()) diff = frame.Rotation() * (glm::round(glm::vec3(frame.Inverse().Rotation() * diff) / snappingFactor()) * snappingFactor()); 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); // printf("Post-snap: (%f, %f, %f)\n", diff.x, diff.y, diff.z);
Data::Vector3 oldSize = part->size;
switch (mainWindow()->selectedTool) { switch (mainWindow()->selectedTool) {
case TOOL_MOVE: { case TOOL_MOVE: {
// Add difference // Add difference
@ -244,6 +246,9 @@ void MainGLWidget::handleLinearTransform(QMouseEvent* evt) {
Logger::error("Invalid tool was set to be handled by handleLinearTransform\n"); Logger::error("Invalid tool was set to be handled by handleLinearTransform\n");
} }
if (mainWindow()->editSoundEffects && (oldSize != part->size) && QFile::exists("./assets/excluded/switch.wav"))
QSound::play("./assets/excluded/switch.wav");
syncPartPhysics(std::dynamic_pointer_cast<Part>(editorToolHandles->adornee->lock())); syncPartPhysics(std::dynamic_pointer_cast<Part>(editorToolHandles->adornee->lock()));
} }
@ -375,7 +380,7 @@ void MainGLWidget::mousePressEvent(QMouseEvent* evt) {
default: return; default: return;
} }
if (QFile::exists("./assets/excluded/electronicpingshort.wav")) if (mainWindow()->editSoundEffects && QFile::exists("./assets/excluded/electronicpingshort.wav"))
QSound::play("./assets/excluded/electronicpingshort.wav"); QSound::play("./assets/excluded/electronicpingshort.wav");
return; return;

View file

@ -129,6 +129,13 @@ MainWindow::MainWindow(QWidget *parent)
ui->actionGridSnap1->setChecked(true); ui->actionGridSnap1->setChecked(true);
snappingMode = GridSnappingMode::SNAP_1_STUD; snappingMode = GridSnappingMode::SNAP_1_STUD;
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);
connect(ui->actionToggleSimulation, &QAction::triggered, this, [&]() { connect(ui->actionToggleSimulation, &QAction::triggered, this, [&]() {
simulationPlaying = !simulationPlaying; simulationPlaying = !simulationPlaying;
if (simulationPlaying) { if (simulationPlaying) {

View file

@ -46,6 +46,7 @@ public:
SelectedTool selectedTool; SelectedTool selectedTool;
GridSnappingMode snappingMode; GridSnappingMode snappingMode;
bool editSoundEffects = true;
Ui::MainWindow *ui; Ui::MainWindow *ui;
private: private:

View file

@ -40,7 +40,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1027</width> <width>935</width>
<height>30</height> <height>30</height>
</rect> </rect>
</property> </property>
@ -118,9 +118,9 @@
</layout> </layout>
</widget> </widget>
</widget> </widget>
<widget class="QToolBar" name="toolBar"> <widget class="QToolBar" name="fileTools">
<property name="windowTitle"> <property name="windowTitle">
<string>toolBar</string> <string>File Tools</string>
</property> </property>
<attribute name="toolBarArea"> <attribute name="toolBarArea">
<enum>TopToolBarArea</enum> <enum>TopToolBarArea</enum>
@ -132,9 +132,9 @@
<addaction name="actionOpen"/> <addaction name="actionOpen"/>
<addaction name="actionSave"/> <addaction name="actionSave"/>
</widget> </widget>
<widget class="QToolBar" name="toolBar_2"> <widget class="QToolBar" name="transformTools">
<property name="windowTitle"> <property name="windowTitle">
<string>toolBar_2</string> <string>Transform Tools</string>
</property> </property>
<attribute name="toolBarArea"> <attribute name="toolBarArea">
<enum>TopToolBarArea</enum> <enum>TopToolBarArea</enum>
@ -148,7 +148,7 @@
<addaction name="actionToolRotate"/> <addaction name="actionToolRotate"/>
<addaction name="actionToggleSpace"/> <addaction name="actionToggleSpace"/>
</widget> </widget>
<widget class="QToolBar" name="toolBar_3"> <widget class="QToolBar" name="editTools">
<property name="windowTitle"> <property name="windowTitle">
<string>toolBar_3</string> <string>toolBar_3</string>
</property> </property>
@ -164,9 +164,9 @@
<addaction name="actionPaste"/> <addaction name="actionPaste"/>
<addaction name="actionPasteInto"/> <addaction name="actionPasteInto"/>
</widget> </widget>
<widget class="QToolBar" name="toolBar_4"> <widget class="QToolBar" name="snappingOptions">
<property name="windowTitle"> <property name="windowTitle">
<string>toolBar_4</string> <string>Snapping Options</string>
</property> </property>
<attribute name="toolBarArea"> <attribute name="toolBarArea">
<enum>TopToolBarArea</enum> <enum>TopToolBarArea</enum>
@ -178,9 +178,9 @@
<addaction name="actionGridSnap05"/> <addaction name="actionGridSnap05"/>
<addaction name="actionGridSnapOff"/> <addaction name="actionGridSnapOff"/>
</widget> </widget>
<widget class="QToolBar" name="toolBar_5"> <widget class="QToolBar" name="simulationControls">
<property name="windowTitle"> <property name="windowTitle">
<string>toolBar_5</string> <string>Simulation Controls</string>
</property> </property>
<attribute name="toolBarArea"> <attribute name="toolBarArea">
<enum>TopToolBarArea</enum> <enum>TopToolBarArea</enum>
@ -190,9 +190,9 @@
</attribute> </attribute>
<addaction name="actionToggleSimulation"/> <addaction name="actionToggleSimulation"/>
</widget> </widget>
<widget class="QToolBar" name="toolBar_6"> <widget class="QToolBar" name="surfaceTools">
<property name="windowTitle"> <property name="windowTitle">
<string>toolBar_6</string> <string>Surface Tools</string>
</property> </property>
<attribute name="toolBarArea"> <attribute name="toolBarArea">
<enum>TopToolBarArea</enum> <enum>TopToolBarArea</enum>
@ -207,6 +207,18 @@
<addaction name="actionToolInlets"/> <addaction name="actionToolInlets"/>
<addaction name="actionToolUniversal"/> <addaction name="actionToolUniversal"/>
</widget> </widget>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionToggleEditSounds"/>
</widget>
<action name="actionAddPart"> <action name="actionAddPart">
<property name="icon"> <property name="icon">
<iconset> <iconset>
@ -646,6 +658,23 @@
<enum>QAction::MenuRole::NoRole</enum> <enum>QAction::MenuRole::NoRole</enum>
</property> </property>
</action> </action>
<action name="actionToggleEditSounds">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset theme="audio-volume-high"/>
</property>
<property name="text">
<string>Toggle Edit Sounds</string>
</property>
<property name="toolTip">
<string>Toggles edit sound effects</string>
</property>
<property name="menuRole">
<enum>QAction::MenuRole::NoRole</enum>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>