NOISSUE Add Konami Code
Fun little thing for hiding extra debug options in the future.
This commit is contained in:
parent
ea151ca9d4
commit
303842a19e
@ -31,6 +31,10 @@ SET(MULTIMC_SOURCES
|
||||
ColorCache.cpp
|
||||
HoeDown.h
|
||||
|
||||
# Super secret!
|
||||
KonamiCode.h
|
||||
KonamiCode.cpp
|
||||
|
||||
# GUI - windows
|
||||
MainWindow.h
|
||||
MainWindow.cpp
|
||||
|
42
application/KonamiCode.cpp
Normal file
42
application/KonamiCode.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
#include "KonamiCode.h"
|
||||
|
||||
#include <array>
|
||||
#include <QDebug>
|
||||
|
||||
namespace {
|
||||
const std::array<Qt::Key, 10> konamiCode =
|
||||
{
|
||||
Qt::Key_Up, Qt::Key_Up,
|
||||
Qt::Key_Down, Qt::Key_Down,
|
||||
Qt::Key_Left, Qt::Key_Right,
|
||||
Qt::Key_Left, Qt::Key_Right,
|
||||
Qt::Key_B, Qt::Key_A
|
||||
};
|
||||
}
|
||||
|
||||
KonamiCode::KonamiCode(QObject* parent) : QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void KonamiCode::input(QEvent* event)
|
||||
{
|
||||
if( event->type() == QEvent::KeyPress )
|
||||
{
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent*>( event );
|
||||
auto key = Qt::Key(keyEvent->key());
|
||||
if(key == konamiCode[m_progress])
|
||||
{
|
||||
m_progress ++;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_progress = 0;
|
||||
}
|
||||
if(m_progress == konamiCode.size())
|
||||
{
|
||||
m_progress = 0;
|
||||
emit triggered();
|
||||
}
|
||||
}
|
||||
}
|
17
application/KonamiCode.h
Normal file
17
application/KonamiCode.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
||||
class KonamiCode : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KonamiCode(QObject *parent = 0);
|
||||
void input(QEvent *event);
|
||||
|
||||
signals:
|
||||
void triggered();
|
||||
|
||||
private:
|
||||
int m_progress = 0;
|
||||
};
|
@ -89,6 +89,7 @@
|
||||
#include <FolderInstanceProvider.h>
|
||||
#include <InstanceImportTask.h>
|
||||
#include "UpdateController.h"
|
||||
#include "KonamiCode.h"
|
||||
|
||||
// WHY: to hold the pre-translation strings together with the T pointer, so it can be retranslated without a lot of ugly code
|
||||
template <typename T>
|
||||
@ -631,6 +632,12 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
|
||||
connect(q, SIGNAL(activated()), qApp, SLOT(quit()));
|
||||
}
|
||||
|
||||
// Konami Code
|
||||
{
|
||||
secretEventFilter = new KonamiCode(this);
|
||||
connect(secretEventFilter, &KonamiCode::triggered, this, &MainWindow::konamiTriggered);
|
||||
}
|
||||
|
||||
// Add the news label to the news toolbar.
|
||||
{
|
||||
m_newsChecker.reset(new NewsChecker(BuildConfig.NEWS_RSS_URL));
|
||||
@ -806,6 +813,11 @@ MainWindow::~MainWindow()
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindow::konamiTriggered()
|
||||
{
|
||||
qDebug() << "Super Secret Mode ACTIVATED!";
|
||||
}
|
||||
|
||||
void MainWindow::skinJobFinished()
|
||||
{
|
||||
activeAccountChanged();
|
||||
@ -1064,6 +1076,7 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *ev)
|
||||
{
|
||||
if (ev->type() == QEvent::KeyPress)
|
||||
{
|
||||
secretEventFilter->input(ev);
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev);
|
||||
switch (keyEvent->key())
|
||||
{
|
||||
|
@ -38,6 +38,7 @@ class MinecraftLauncher;
|
||||
class BaseProfilerFactory;
|
||||
class GroupView;
|
||||
class ServerStatus;
|
||||
class KonamiCode;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
@ -176,6 +177,8 @@ private slots:
|
||||
|
||||
void droppedURLs(QList<QUrl> urls);
|
||||
|
||||
void konamiTriggered();
|
||||
|
||||
private:
|
||||
void addInstance(QString url = QString());
|
||||
void activateInstance(InstancePtr instance);
|
||||
@ -200,6 +203,7 @@ private:
|
||||
ServerStatus *m_statusRight = nullptr;
|
||||
QMenu *accountMenu = nullptr;
|
||||
QToolButton *accountMenuButton = nullptr;
|
||||
KonamiCode * secretEventFilter = nullptr;
|
||||
|
||||
unique_qobject_ptr<NetJob> skin_download_job;
|
||||
unique_qobject_ptr<NewsChecker> m_newsChecker;
|
||||
|
Loading…
Reference in New Issue
Block a user