mirror of
https://github.com/QuantumLeaps/qpcpp.git
synced 2025-01-28 06:02:56 +08:00
49 lines
1.5 KiB
C++
49 lines
1.5 KiB
C++
|
#include <QtGui>
|
||
|
#include "gui.h"
|
||
|
//-----------------
|
||
|
#include "qp_port.h"
|
||
|
#include "game.h"
|
||
|
#include "bsp.h"
|
||
|
|
||
|
Q_DEFINE_THIS_FILE
|
||
|
|
||
|
//............................................................................
|
||
|
Gui *Gui::instance;
|
||
|
|
||
|
//............................................................................
|
||
|
Gui::Gui(QWidget *parent)
|
||
|
: QDialog(parent)
|
||
|
{
|
||
|
instance = this; // only one instance for the Gui
|
||
|
|
||
|
setupUi(this);
|
||
|
|
||
|
static quint8 const c_offColor[] = { 15U, 15U, 15U };
|
||
|
m_display->init(BSP_SCREEN_WIDTH, 2U,
|
||
|
BSP_SCREEN_HEIGHT, 2U,
|
||
|
c_offColor);
|
||
|
}
|
||
|
//............................................................................
|
||
|
void Gui::onBtnPressed() { // slot
|
||
|
m_button->setIcon(QPixmap(":/res/EK-BTN_DWN.png"));
|
||
|
static QP::QEvt const fireEvt(GAME::PLAYER_TRIGGER_SIG);
|
||
|
QP::QF::PUBLISH(&fireEvt, (void*)0);
|
||
|
}
|
||
|
//............................................................................
|
||
|
void Gui::onBtnReleased() { // slot
|
||
|
m_button->setIcon(QPixmap(":/res/EK-BTN_UP.png"));
|
||
|
}
|
||
|
//............................................................................
|
||
|
void Gui::onQuit() { // slot
|
||
|
BSP_terminate(0);
|
||
|
}
|
||
|
//............................................................................
|
||
|
void Gui::wheelEvent(QWheelEvent *e) {
|
||
|
if (e->delta() >= 0) {
|
||
|
BSP_moveShipUp();
|
||
|
}
|
||
|
else {
|
||
|
BSP_moveShipDown();
|
||
|
}
|
||
|
}
|