1 /* 2 This file is part of the game 'KTron' 3 4 SPDX-FileCopyrightText: 1998-2000 Matthias Kiefer <matthias.kiefer@gmx.de> 5 SPDX-FileCopyrightText: 2005 Benjamin C. Meyer <ben at meyerhome dot net> 6 SPDX-FileCopyrightText: 2008-2009 Stas Verberkt <legolas at legolasweb dot nl> 7 8 SPDX-License-Identifier: GPL-2.0-or-later 9 10 */ 11 12 #ifndef KTRON_H 13 #define KTRON_H 14 15 #include <QAction> 16 #include <KXmlGuiWindow> 17 #include <QKeyEvent> 18 19 #include "tron.h" 20 21 #define ID_STATUS_BASE 40 22 #define MESSAGE_TIME 2000 23 24 class General; 25 class QLabel; 26 27 /** 28 * @short The main window of KTron 29 */ 30 class KTron : public KXmlGuiWindow { 31 32 Q_OBJECT 33 34 public: 35 explicit KTron(QWidget *parent=nullptr); 36 ~KTron() override; 37 38 private: 39 void updateStatusbar(); 40 41 protected: 42 /** calls tron->updatePixmap to draw frame in the new colors */ 43 void paletteChange(const QPalette &oldPalette); 44 void closeEvent(QCloseEvent *) override; 45 /** Key hits */ 46 void keyPressEvent(QKeyEvent *) override; 47 void keyReleaseEvent(QKeyEvent *) override; 48 49 public Q_SLOTS: 50 void close(); 51 52 private Q_SLOTS: 53 void loadSettings(); 54 /** updates players points in statusbar and checks if someone has won */ 55 void changeStatus(); 56 void updateScore(); 57 void showSettings(); 58 void showHighscores(); 59 void optionsConfigureKeys(); 60 void blockPause(bool block); 61 // Triggers keys 62 void triggerKey0Up(bool); 63 void triggerKey0Down(bool); 64 void triggerKey0Left(bool); 65 void triggerKey0Right(bool); 66 void triggerKey0Accelerate(bool); 67 void triggerKey1Up(bool); 68 void triggerKey1Down(bool); 69 void triggerKey1Left(bool); 70 void triggerKey1Right(bool); 71 void triggerKey1Accelerate(bool); 72 73 private: 74 Tron *m_tron; 75 QAction *m_player0Up; 76 QAction *m_player0Down; 77 QAction *m_player0Left; 78 QAction *m_player0Right; 79 QAction *m_player0Accelerate; 80 QAction *m_player1Up; 81 QAction *m_player1Down; 82 QAction *m_player1Left; 83 QAction *m_player1Right; 84 QAction *m_player1Accelerate; 85 QAction *m_pauseButton; 86 General *m_generalConfigDialog; 87 QLabel *m_statusBarLabel[3]; 88 }; 89 90 #endif // KTRON_H 91 92