QTfrontend/net/hwmap.h
author alfadur
Thu, 26 Sep 2019 22:31:06 +0300
changeset 15446 a6699f4a3d16
parent 11744 ac58a063d26a
child 16055 ce4b50823a95
permissions -rw-r--r--
fix typo
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
     1
/*
1066
1f1b3686a2b0 Update copyright headers a bit
unc0rr
parents: 184
diff changeset
     2
 * Hedgewars, a free turn based strategy game
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
     3
 * Copyright (c) 2006 Igor Ulyanov <iulyanov@gmail.com>
11046
47a8c19ecb60 more copyright fixes
sheepluva
parents: 10959
diff changeset
     4
 * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
     5
 *
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 180
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 180
diff changeset
     7
 * it under the terms of the GNU General Public License as published by
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 180
diff changeset
     8
 * the Free Software Foundation; version 2 of the License
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
     9
 *
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 180
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 180
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 180
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 180
diff changeset
    13
 * GNU General Public License for more details.
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    14
 *
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 180
diff changeset
    15
 * You should have received a copy of the GNU General Public License
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 180
diff changeset
    16
 * along with this program; if not, write to the Free Software
10108
c68cf030eded update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents: 9998
diff changeset
    17
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    18
 */
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    19
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    20
#ifndef _HWMAP_INCLUDED
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    21
#define _HWMAP_INCLUDED
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    22
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    23
#include <QByteArray>
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    24
#include <QString>
10161
c092f92aee23 Move preview rendering into HWMap
unc0rr
parents: 10150
diff changeset
    25
#include <QPixmap>
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    26
177
c67c15e6fae3 prepare uniting tcp classes
displacer
parents: 170
diff changeset
    27
#include "tcpBase.h"
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    28
3133
1ab5f18f4df8 prg's maze generator
nemo
parents: 2377
diff changeset
    29
enum MapGenerator
1ab5f18f4df8 prg's maze generator
nemo
parents: 2377
diff changeset
    30
{
10391
ce3ccc45d790 Add separate option for perlin gen
unc0rr
parents: 10161
diff changeset
    31
    MAPGEN_REGULAR = 0,
ce3ccc45d790 Add separate option for perlin gen
unc0rr
parents: 10161
diff changeset
    32
    MAPGEN_MAZE = 1,
ce3ccc45d790 Add separate option for perlin gen
unc0rr
parents: 10161
diff changeset
    33
    MAPGEN_PERLIN = 2,
ce3ccc45d790 Add separate option for perlin gen
unc0rr
parents: 10161
diff changeset
    34
    MAPGEN_DRAWN = 3,
11744
ac58a063d26a Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents: 11046
diff changeset
    35
    MAPGEN_FORTS = 4,
ac58a063d26a Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents: 11046
diff changeset
    36
    MAPGEN_MAP = 5
3133
1ab5f18f4df8 prg's maze generator
nemo
parents: 2377
diff changeset
    37
};
1ab5f18f4df8 prg's maze generator
nemo
parents: 2377
diff changeset
    38
177
c67c15e6fae3 prepare uniting tcp classes
displacer
parents: 170
diff changeset
    39
class HWMap : public TCPBase
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    40
{
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    41
        Q_OBJECT
2377
f3fab2b09e0c And in frontend
nemo
parents: 1797
diff changeset
    42
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    43
    public:
8070
66bc20d089fc Okay, remove previous request only if it has same parent
unc0rr
parents: 8069
diff changeset
    44
        HWMap(QObject *parent = 0);
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    45
        virtual ~HWMap();
10959
1225f42f61e2 Pass ScriptParams to preview to support techracer. Proof of concept for techracer, generate a preview for m=4
nemo
parents: 10472
diff changeset
    46
        void getImage(const QString & seed, int templateFilter, MapGenerator mapgen, int maze_size, const QByteArray & drawMapData, QString & script, QString & scriptparam, int feature_size);
8069
bb7671829935 - Only allow one engine instance running at the moment
unc0rr
parents: 6952
diff changeset
    47
        bool couldBeRemoved();
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    48
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    49
    protected:
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    50
        virtual QStringList getArguments();
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    51
        virtual void onClientDisconnect();
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    52
        virtual void SendToClientFirst();
177
c67c15e6fae3 prepare uniting tcp classes
displacer
parents: 170
diff changeset
    53
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    54
    signals:
10161
c092f92aee23 Move preview rendering into HWMap
unc0rr
parents: 10150
diff changeset
    55
        void ImageReceived(const QPixmap & newImage);
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    56
        void HHLimitReceived(int hhLimit);
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    57
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    58
    private:
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    59
        QString m_seed;
10150
fa5c83fd0ad9 Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents: 10108
diff changeset
    60
        QString m_script;
10959
1225f42f61e2 Pass ScriptParams to preview to support techracer. Proof of concept for techracer, generate a preview for m=4
nemo
parents: 10472
diff changeset
    61
        QString m_scriptparam;
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    62
        int templateFilter;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    63
        MapGenerator m_mapgen;
10472
8d04cebedb16 Partially hook up feature size so horrorcat has something to test.
nemo
parents: 10391
diff changeset
    64
        int m_maze_size;  // going to try and deprecate this one
8d04cebedb16 Partially hook up feature size so horrorcat has something to test.
nemo
parents: 10391
diff changeset
    65
        int m_feature_size;
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    66
        QByteArray m_drawMapData;
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    67
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    68
    private slots:
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    69
};
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    70
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    71
#endif // _HWMAP_INCLUDED