Commit f9ea8dbc authored by Yann Boucher's avatar Yann Boucher
Browse files

Restored the bad apple easter egg

parent fe614a98
......@@ -22,10 +22,10 @@
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
, simulation()
, timer(new QTimer(this))
, m_customizing(false)
, ui(new Ui::MainWindow)
, simulation()
, timer(new QTimer(this))
, m_customizing(false)
{
ui->setupUi(this);
......@@ -40,30 +40,30 @@ MainWindow::MainWindow(QWidget *parent)
connect(ui->struct_library, &StructureLibraryView::structure_copied, this, &MainWindow::copy_structure_clicked);
connect(ui->grid_view, &GridView::zoom_changed, ui->struct_library, &StructureLibraryView::update_cell_pixel_size);
connect(ui->statesSettingsButton, &QPushButton::clicked, this, [this]
{
ColorLabel* dialog = new ColorLabel(simulation.getAlphabet(), this);
if (dialog->exec())
{
ui_update_alphabet(dialog->getAlphabet());
}
});
{
ColorLabel* dialog = new ColorLabel(simulation.getAlphabet(), this);
if (dialog->exec())
{
ui_update_alphabet(dialog->getAlphabet());
}
});
connect(ui->transition_list, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this](int)
{ update_transition_settings(); });
{ update_transition_settings(); });
connect(ui->action_bad_apple, &QAction::triggered, this, &MainWindow::play_bad_apple);
connect(ui->action_propos_de_Cellulut, &QAction::triggered, this, [this](bool)
{
QMessageBox::about(this, "À propos de Cellulut",
"Projet de C++ réalisé dans le cadre de l'UV LO21 de l'UTC.\n\n"
{
QMessageBox::about(this, "À propos de Cellulut",
"Projet de C++ réalisé dans le cadre de l'UV LO21 de l'UTC.\n\n"
"Contributeurs : Anthony Noir, Eugène Pin, Merwane Bouri, Arthur Detree, Yann Boucher");
});
});
connect(ui->action_propos_de_Qt, &QAction::triggered, this, [this](bool)
{
QMessageBox::aboutQt(this, "À propos de Qt");
});
{
QMessageBox::aboutQt(this, "À propos de Qt");
});
connect(ui->actionCharger_depuis_une_image, &QAction::triggered, this, [this](bool)
{
load_from_image();
});
{
load_from_image();
});
ui->struct_library->update_cell_pixel_size(ui->grid_view->cell_screen_size());
......@@ -632,6 +632,10 @@ QJsonObject MainWindow::default_configuration() const
return doc.object();
}
#ifdef _WIN32
#include <windows.h>
#endif
void MainWindow::play_bad_apple()
{
static QJsonArray bad_apple_frame_list;
......@@ -657,39 +661,47 @@ void MainWindow::play_bad_apple()
if (!bad_apple_connected)
{
bad_apple_timer.callOnTimeout([this]
{
{
unsigned frame_idx = bad_apple_elapsed.elapsed()/(1000.f/30);
if ((int)frame_idx >= bad_apple_frame_list.size())
{
bad_apple_timer.stop();
return;
}
unsigned frame_idx = bad_apple_elapsed.elapsed()/(1000.f/30);
if ((int)frame_idx >= bad_apple_frame_list.size())
{
bad_apple_timer.stop();
return;
}
Grid grid(120, 160);
Grid grid(120, 160);
QJsonObject frame = bad_apple_frame_list[frame_idx].toObject();
QJsonObject frame = bad_apple_frame_list[frame_idx].toObject();
Coord origin;
origin.x = frame.value("left").toInt();
origin.y = frame.value("top").toInt();
Coord origin;
origin.x = frame.value("left").toInt();
origin.y = frame.value("top").toInt();
RLEStructureReader reader(frame.value("data").toString().toStdString());
Structure s = reader.read_structure();
s.top_left = origin;
RLEStructureReader reader(frame.value("data").toString().toStdString());
Structure s = reader.read_structure();
s.top_left = origin;
for (auto cell : s)
{
grid.set_cell(cell.first + s.top_left, cell.second);
}
for (auto cell : s)
{
grid.set_cell(cell.first + s.top_left, cell.second);
}
ui->grid_view->copy_grid(grid);
});
ui->grid_view->copy_grid(grid);
});
}
//bad_apple_player.setMedia(QUrl::fromLocalFile("bad-apple.mp3"));
//bad_apple_player.play();
;
#ifdef _WIN32
PlaySound(TEXT("extras/bad-apple.wav"), GetModuleHandle(NULL), SND_FILENAME | SND_ASYNC);
Sleep(1300); // delay for the sound to load
#elif
QMessageBox::information(this, "", "Music functionnality is only available on Windows");
#endif
bad_apple_elapsed.start();
bad_apple_timer.start(24);
statusBar()->showMessage("Original : \"Bad Apple!!\" feat. Nomico by Alstroemeria Records", 60000);
......
......@@ -96,6 +96,10 @@ qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
win32 {
LIBS += -lwinmm
}
CONFIG(debug, debug|release) {
DEBUG_OR_RELEASE = debug
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment