File indexing completed on 2024-04-14 04:00:28

0001 /*
0002     SPDX-FileCopyrightText: 2007 Paolo Capriotti <p.capriotti@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef SIMPLEMENU_H
0008 #define SIMPLEMENU_H
0009 
0010 #include <QObject>
0011 
0012 class WelcomeScreen;
0013 class Controller;
0014 class SeaView;
0015 class ChatWidget;
0016 class Button;
0017 class QTcpSocket;
0018 class Entity;
0019 class Protocol;
0020 class QUrl;
0021 
0022 class SimpleMenu : public QObject
0023 {
0024 Q_OBJECT
0025     WelcomeScreen* m_screen;
0026     
0027     Button* m_local_game_btn;
0028     Button* m_server_btn;
0029     Button* m_client_btn;
0030     
0031     Protocol* m_protocol;
0032     QString m_nickname;
0033     
0034     enum State
0035     {
0036         READY,
0037         DONE_LOCAL_GAME,
0038         DONE_SERVER,
0039         DONE_CLIENT,
0040     } m_state;
0041     
0042     Entity* m_player1;
0043     Entity* m_player2;
0044     
0045     void finalize(State, const QString& nick, QTcpSocket* socket = nullptr);
0046 public:
0047     SimpleMenu(QWidget* parent, WelcomeScreen* screen);
0048     
0049     void setupController(Controller* controller, Entity* old_opponent,
0050         SeaView* sea, ChatWidget* chat);
0051     void createClientWithUrl(const QUrl& url);
0052     
0053     Entity* player(int p) { return p == 0 ? m_player1 : m_player2; }
0054     
0055     static const char* iconLocal;
0056     static const char* iconServer;
0057     static const char* iconClient;
0058 public Q_SLOTS:
0059     void localGame();
0060     
0061     void createServer();
0062     void createClient();
0063 Q_SIGNALS:
0064     void done();
0065 };
0066 
0067 #endif // SIMPLEMENU_H