File indexing completed on 2024-04-28 04:04:39
0001 /* 0002 This file is part of the game 'KTron' 0003 0004 SPDX-FileCopyrightText: 1998-2000 Matthias Kiefer <matthias.kiefer@gmx.de> 0005 SPDX-FileCopyrightText: 2005 Benjamin C. Meyer <ben at meyerhome dot net> 0006 SPDX-FileCopyrightText: 2008-2009 Stas Verberkt <legolas at legolasweb dot nl> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 0010 */ 0011 0012 #ifndef KTRON_H 0013 #define KTRON_H 0014 0015 #include <QAction> 0016 #include <KXmlGuiWindow> 0017 #include <QKeyEvent> 0018 0019 #include "tron.h" 0020 0021 #define ID_STATUS_BASE 40 0022 #define MESSAGE_TIME 2000 0023 0024 class General; 0025 class QLabel; 0026 0027 /** 0028 * @short The main window of KTron 0029 */ 0030 class KTron : public KXmlGuiWindow { 0031 0032 Q_OBJECT 0033 0034 public: 0035 explicit KTron(QWidget *parent=nullptr); 0036 ~KTron() override; 0037 0038 private: 0039 void updateStatusbar(); 0040 0041 protected: 0042 /** calls tron->updatePixmap to draw frame in the new colors */ 0043 void paletteChange(const QPalette &oldPalette); 0044 void closeEvent(QCloseEvent *) override; 0045 /** Key hits */ 0046 void keyPressEvent(QKeyEvent *) override; 0047 void keyReleaseEvent(QKeyEvent *) override; 0048 0049 public Q_SLOTS: 0050 void close(); 0051 0052 private Q_SLOTS: 0053 void loadSettings(); 0054 /** updates players points in statusbar and checks if someone has won */ 0055 void changeStatus(); 0056 void updateScore(); 0057 void showSettings(); 0058 void showHighscores(); 0059 void optionsConfigureKeys(); 0060 void blockPause(bool block); 0061 // Triggers keys 0062 void triggerKey0Up(bool); 0063 void triggerKey0Down(bool); 0064 void triggerKey0Left(bool); 0065 void triggerKey0Right(bool); 0066 void triggerKey0Accelerate(bool); 0067 void triggerKey1Up(bool); 0068 void triggerKey1Down(bool); 0069 void triggerKey1Left(bool); 0070 void triggerKey1Right(bool); 0071 void triggerKey1Accelerate(bool); 0072 0073 private: 0074 Tron *m_tron; 0075 QAction *m_player0Up; 0076 QAction *m_player0Down; 0077 QAction *m_player0Left; 0078 QAction *m_player0Right; 0079 QAction *m_player0Accelerate; 0080 QAction *m_player1Up; 0081 QAction *m_player1Down; 0082 QAction *m_player1Left; 0083 QAction *m_player1Right; 0084 QAction *m_player1Accelerate; 0085 QAction *m_pauseButton; 0086 General *m_generalConfigDialog; 0087 QLabel *m_statusBarLabel[3]; 0088 }; 0089 0090 #endif // KTRON_H 0091