QTfrontend/mapContainer.h
author unc0rr
Sat, 25 Jun 2011 17:22:13 +0400
changeset 5307 dd53755e0fca
parent 5289 9d18b61bd3eb
permissions -rw-r--r--
Fix broken theme icon loading from user dir
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: 486
diff changeset
     2
 * Hedgewars, a free turn based strategy game
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 4941
diff changeset
     3
 * Copyright (c) 2006-2007 Igor Ulyanov <iulyanov@gmail.com>
088d40d8aba2 Happy 2011 :)
koda
parents: 4941
diff changeset
     4
 * Copyright (c) 2007-2011 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: 169
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 169
diff changeset
     7
 * it under the terms of the GNU General Public License as published by
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 169
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: 169
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 169
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 169
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 169
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: 169
diff changeset
    15
 * You should have received a copy of the GNU General Public License
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 169
diff changeset
    16
 * along with this program; if not, write to the Free Software
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 169
diff changeset
    17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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_CONTAINER_INCLUDED
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    21
#define _HWMAP_CONTAINER_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 <QWidget>
1209
7f6cb1d7be2a Start remaking multiplayer page
unc0rr
parents: 1066
diff changeset
    24
#include <QGridLayout>
249
ff85fa029541 map choose from files added
displacer
parents: 184
diff changeset
    25
#include <QComboBox>
1802
dd148e2506e2 Move template filter to map widget (by nemo)
unc0rr
parents: 1797
diff changeset
    26
#include <QLabel>
4489
c4ca9ced258b - Pass map drawing data to engine
unc0rr
parents: 4337
diff changeset
    27
#include <QByteArray>
4519
aee36896d46b exposing seed for editing and viewing
Henek
parents: 4513
diff changeset
    28
#include <QLineEdit>
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    29
1210
bfed1b89bc85 Add themes list to map selection widget
unc0rr
parents: 1209
diff changeset
    30
#include "hwmap.h"
4520
e7882bd1a894 Allow to draw maps in frontend and play them (only locally, some bugs to fix)
unc0rr
parents: 4519
diff changeset
    31
#include "drawmapscene.h"
1210
bfed1b89bc85 Add themes list to map selection widget
unc0rr
parents: 1209
diff changeset
    32
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    33
class QPushButton;
1209
7f6cb1d7be2a Start remaking multiplayer page
unc0rr
parents: 1066
diff changeset
    34
class IconedGroupBox;
5289
9d18b61bd3eb - Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents: 4976
diff changeset
    35
class QListView;
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    36
249
ff85fa029541 map choose from files added
displacer
parents: 184
diff changeset
    37
class MapFileErrorException
ff85fa029541 map choose from files added
displacer
parents: 184
diff changeset
    38
{
ff85fa029541 map choose from files added
displacer
parents: 184
diff changeset
    39
};
ff85fa029541 map choose from files added
displacer
parents: 184
diff changeset
    40
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    41
class HWMapContainer : public QWidget
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    42
{
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    43
  Q_OBJECT
320
1ee7f087195a - HWMapContainer sets and stores the theme
unc0rr
parents: 249
diff changeset
    44
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    45
 public:
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    46
  HWMapContainer(QWidget * parent=0);
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    47
  QString getCurrentSeed() const;
249
ff85fa029541 map choose from files added
displacer
parents: 184
diff changeset
    48
  QString getCurrentMap() const;
ff85fa029541 map choose from files added
displacer
parents: 184
diff changeset
    49
  QString getCurrentTheme() const;
1790
c84223511ca8 frontend's part of nemo patch
unc0rr
parents: 1366
diff changeset
    50
  int     getCurrentHHLimit() const;
4513
1dd97c710f5a added general scripts to multiplayer and added option for scripts to allow user set schemes or weapon sets.
Henek
parents: 4511
diff changeset
    51
  QString getCurrentScheme() const;
1dd97c710f5a added general scripts to multiplayer and added option for scripts to allow user set schemes or weapon sets.
Henek
parents: 4511
diff changeset
    52
  QString getCurrentWeapons() const;
1802
dd148e2506e2 Move template filter to map widget (by nemo)
unc0rr
parents: 1797
diff changeset
    53
  quint32 getTemplateFilter() const;
3133
1ab5f18f4df8 prg's maze generator
nemo
parents: 3008
diff changeset
    54
  MapGenerator get_mapgen(void) const;
4941
90572c338e60 Fix for my last commit (which was all nonsense)
unc0rr
parents: 4936
diff changeset
    55
  int getMazeSize(void) const;
3008
e57cafce4227 Frontend:
smxx
parents: 1802
diff changeset
    56
  bool getCurrentIsMission() const;
4489
c4ca9ced258b - Pass map drawing data to engine
unc0rr
parents: 4337
diff changeset
    57
  QByteArray getDrawnMapData();
4520
e7882bd1a894 Allow to draw maps in frontend and play them (only locally, some bugs to fix)
unc0rr
parents: 4519
diff changeset
    58
  DrawMapScene * getDrawMapScene();
4534
395278890955 Don't use std::string
unc0rr
parents: 4525
diff changeset
    59
  void mapDrawingFinished();
4720
a9f9c96db60c Allow people to see my clever seed names if I set to something other than random seed hash.
nemo
parents: 4699
diff changeset
    60
  QLineEdit* seedEdit;
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    61
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    62
 public slots:
4562
b55f78fd2bf6 - Simplify map container code a bit
unc0rr
parents: 4550
diff changeset
    63
  void askForGeneratedPreview();
320
1ee7f087195a - HWMapContainer sets and stores the theme
unc0rr
parents: 249
diff changeset
    64
  void setSeed(const QString & seed);
1ee7f087195a - HWMapContainer sets and stores the theme
unc0rr
parents: 249
diff changeset
    65
  void setMap(const QString & map);
1ee7f087195a - HWMapContainer sets and stores the theme
unc0rr
parents: 249
diff changeset
    66
  void setTheme(const QString & theme);
1797
fedd8649fdd9 Templates filter by nemo
unc0rr
parents: 1790
diff changeset
    67
  void setTemplateFilter(int);
3133
1ab5f18f4df8 prg's maze generator
nemo
parents: 3008
diff changeset
    68
  void setMapgen(MapGenerator m);
4941
90572c338e60 Fix for my last commit (which was all nonsense)
unc0rr
parents: 4936
diff changeset
    69
  void setMazeSize(int size);
4537
f95f7218531a Recieve and parse DRAWNMAP config
unc0rr
parents: 4534
diff changeset
    70
  void setDrawnMapData(const QByteArray & ar);
4941
90572c338e60 Fix for my last commit (which was all nonsense)
unc0rr
parents: 4936
diff changeset
    71
  void setAllMapParameters(const QString & map, MapGenerator m, int mazesize, const QString & seed, int tmpl);
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    72
325
17c860483407 New signals and slot for GameCFGWidget
unc0rr
parents: 320
diff changeset
    73
 signals:
17c860483407 New signals and slot for GameCFGWidget
unc0rr
parents: 320
diff changeset
    74
  void seedChanged(const QString & seed);
17c860483407 New signals and slot for GameCFGWidget
unc0rr
parents: 320
diff changeset
    75
  void mapChanged(const QString & map);
17c860483407 New signals and slot for GameCFGWidget
unc0rr
parents: 320
diff changeset
    76
  void themeChanged(const QString & theme);
1802
dd148e2506e2 Move template filter to map widget (by nemo)
unc0rr
parents: 1797
diff changeset
    77
  void newTemplateFilter(int filter);
3133
1ab5f18f4df8 prg's maze generator
nemo
parents: 3008
diff changeset
    78
  void mapgenChanged(MapGenerator m);
4941
90572c338e60 Fix for my last commit (which was all nonsense)
unc0rr
parents: 4936
diff changeset
    79
  void mazeSizeChanged(int s);
4511
df827e70ae63 Pretension to switch to draw map page
unc0rr
parents: 4489
diff changeset
    80
  void drawMapRequested();
4525
0a81be113e21 Try to send drawn map data to net server
unc0rr
parents: 4520
diff changeset
    81
  void drawnMapChanged(const QByteArray & data);
325
17c860483407 New signals and slot for GameCFGWidget
unc0rr
parents: 320
diff changeset
    82
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    83
 private slots:
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    84
  void setImage(const QImage newImage);
1790
c84223511ca8 frontend's part of nemo patch
unc0rr
parents: 1366
diff changeset
    85
  void setHHLimit(int hhLimit);
249
ff85fa029541 map choose from files added
displacer
parents: 184
diff changeset
    86
  void mapChanged(int index);
320
1ee7f087195a - HWMapContainer sets and stores the theme
unc0rr
parents: 249
diff changeset
    87
  void setRandomSeed();
1318
18da1c5e960d - Shut the client's tries to configure server up
unc0rr
parents: 1215
diff changeset
    88
  void setRandomTheme();
4337
85e02b1a8e8f merge 0.9.14.1 to trunk
nemo
parents: 4322
diff changeset
    89
  void setRandomMap();
85e02b1a8e8f merge 0.9.14.1 to trunk
nemo
parents: 4322
diff changeset
    90
  void setRandomStatic();
85e02b1a8e8f merge 0.9.14.1 to trunk
nemo
parents: 4322
diff changeset
    91
  void setRandomMission();
5289
9d18b61bd3eb - Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents: 4976
diff changeset
    92
  void themeSelected(const QModelIndex & current, const QModelIndex &);
1790
c84223511ca8 frontend's part of nemo patch
unc0rr
parents: 1366
diff changeset
    93
  void addInfoToPreview(QPixmap image);
4550
d300ea498486 added set button to seed edit so maps won't regenerate as often
Henek
parents: 4537
diff changeset
    94
  void seedEdited();
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    95
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    96
 protected:
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    97
  virtual void resizeEvent ( QResizeEvent * event );
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    98
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
    99
 private:
1209
7f6cb1d7be2a Start remaking multiplayer page
unc0rr
parents: 1066
diff changeset
   100
  QGridLayout mainLayout;
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
   101
  QPushButton* imageButt;
249
ff85fa029541 map choose from files added
displacer
parents: 184
diff changeset
   102
  QComboBox* chooseMap;
1209
7f6cb1d7be2a Start remaking multiplayer page
unc0rr
parents: 1066
diff changeset
   103
  IconedGroupBox* gbThemes;
5289
9d18b61bd3eb - Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents: 4976
diff changeset
   104
  QListView* lvThemes;
169
a78d4a552500 new more working, but still not completely working version :)
displacer
parents: 168
diff changeset
   105
  HWMap* pMap;
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
   106
  QString m_seed;
4550
d300ea498486 added set button to seed edit so maps won't regenerate as often
Henek
parents: 4537
diff changeset
   107
  QPushButton* seedSet;
4699
47d8a524780a hide seed...
koda
parents: 4562
diff changeset
   108
  QLabel* seedLabel;
1790
c84223511ca8 frontend's part of nemo patch
unc0rr
parents: 1366
diff changeset
   109
  int hhLimit;
1797
fedd8649fdd9 Templates filter by nemo
unc0rr
parents: 1790
diff changeset
   110
  int templateFilter;
1790
c84223511ca8 frontend's part of nemo patch
unc0rr
parents: 1366
diff changeset
   111
  QPixmap hhSmall;
1802
dd148e2506e2 Move template filter to map widget (by nemo)
unc0rr
parents: 1797
diff changeset
   112
  QLabel* lblFilter;
4941
90572c338e60 Fix for my last commit (which was all nonsense)
unc0rr
parents: 4936
diff changeset
   113
  QComboBox* cbTemplateFilter;
3133
1ab5f18f4df8 prg's maze generator
nemo
parents: 3008
diff changeset
   114
  QLabel *maze_size_label;
4941
90572c338e60 Fix for my last commit (which was all nonsense)
unc0rr
parents: 4936
diff changeset
   115
  QComboBox *cbMazeSize;
3133
1ab5f18f4df8 prg's maze generator
nemo
parents: 3008
diff changeset
   116
  MapGenerator mapgen;
4337
85e02b1a8e8f merge 0.9.14.1 to trunk
nemo
parents: 4322
diff changeset
   117
  int numMissions;
4520
e7882bd1a894 Allow to draw maps in frontend and play them (only locally, some bugs to fix)
unc0rr
parents: 4519
diff changeset
   118
  DrawMapScene drawMapScene;
331
6bfc326e4976 Selecting map works in net game
unc0rr
parents: 325
diff changeset
   119
4936
d65d438acd23 Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents: 4720
diff changeset
   120
  void intSetSeed(const QString & seed);
d65d438acd23 Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents: 4720
diff changeset
   121
  void intSetMap(const QString & map);
d65d438acd23 Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents: 4720
diff changeset
   122
  void intSetMapgen(MapGenerator m);
4941
90572c338e60 Fix for my last commit (which was all nonsense)
unc0rr
parents: 4936
diff changeset
   123
  void intSetTemplateFilter(int);
90572c338e60 Fix for my last commit (which was all nonsense)
unc0rr
parents: 4936
diff changeset
   124
  void intSetMazeSize(int size);
4562
b55f78fd2bf6 - Simplify map container code a bit
unc0rr
parents: 4550
diff changeset
   125
  void updatePreview();
164
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
   126
};
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
   127
92cff18a3ab6 first map preview added (still experimental)
displacer
parents:
diff changeset
   128
#endif // _HWMAP_CONTAINER_INCLUDED