Put extern variable in dedicated namespace

This commit is contained in:
rainmakerv2 2024-12-18 07:46:36 +08:00
parent dda7d5ca3a
commit f4239c5b63
3 changed files with 13 additions and 5 deletions

View File

@ -26,7 +26,9 @@
#include "common/discord_rpc_handler.h"
#endif
bool isGameRunning = false;
namespace QtExternal {
static bool isGameRunning = false;
}
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
ui->setupUi(this);
@ -554,7 +556,9 @@ void MainWindow::CreateConnects() {
}
void MainWindow::StartGame() {
isGameRunning = true;
using namespace QtExternal;
QtExternal::isGameRunning = true;
BackgroundMusicPlayer::getInstance().stopMusic();
QString gamePath = "";
int table_mode = Config::getTableMode();

View File

@ -22,7 +22,10 @@
#include "main_window_ui.h"
#include "pkg_viewer.h"
extern bool isGameRunning;
namespace QtExternal {
extern bool isGameRunning;
}
class GameListFrame;
class MainWindow : public QMainWindow {

View File

@ -376,11 +376,12 @@ void SettingsDialog::OnCursorStateChanged(s16 index) {
}
void SettingsDialog::GammaSliderChange(int value) {
using namespace QtExternal;
float Gammafloat = static_cast<float>((value / 1000.0f));
ui->GammaLabel->setText(QString::number(Gammafloat, 'f', 3));
// presenter crashes if game is running, set isGameRunning to off when stop game is implemented
if (isGameRunning) {
// GetGammaRef crashes if no game is running, set isGameRunning to false when MainWindow::StopGame is implemented
if (QtExternal::isGameRunning) {
presenter->GetGammaRef() = Gammafloat;
}
}