Advanced Strategic Command
nextcampaignmap.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Advanced Strategic Command; http://www.asc-hq.de
3  Copyright (C) 1994-2010 Martin Bickel and Marc Schellenberger
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; see the file COPYING. If not, write to the
17  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  Boston, MA 02111-1307 USA
19 */
20 
21 
22 #include "../paradialog.h"
23 #include "../loaders.h"
24 #include "../windowing.h"
25 
27 {
28  private:
29  ASCString file;
30  public:
31  NextCampaignMap(PG_Widget* parent, const PG_Rect& r );
32  GameMap* getMap();
33  bool search( int id );
34 };
35 
36 const char* waiting = "-- searching, please wait -- ";
37 
38 NextCampaignMap :: NextCampaignMap(PG_Widget* parent, const PG_Rect& r ) : ConfigurableWindow( parent, r, "continuecampaign" )
39 {
40  setup();
41  setLabelText( "Title", waiting);
42  setLabelText( "CodeWord", waiting);
43  setLabelText( "Filename", waiting);
44 
45  PG_Button* b = dynamic_cast<PG_Button*>( FindChild( "GO", true ) );
46  if ( b )
47  b->sigClick.connect( sigc::hide( sigc::mem_fun( *this, &NextCampaignMap::QuitModal )));
48 
49 }
50 
52 {
54  if ( mci.filename.length() ) {
55  setLabelText( "Title", mci.title );
56  setLabelText( "CodeWord", mci.codeword );
57  setLabelText( "Filename", mci.filename );
58  file = mci.filename;
59  return true;
60  } else {
61  errorMessage("The next campaign map is not available");
62  return false;
63  }
64 }
65 
67 {
69 };
70 
71 
73 {
74  NextCampaignMap ncm( NULL, PG_Rect(50,50,500,300) );
75  ncm.Show();
76  if ( ncm.search( id ) ) {
77  ncm.RunModal();
78  return ncm.getMap();
79  } else
80  return NULL;
81 }
82 
GameMap * nextCampaignMap(int id)
GameMap * getMap()
Loki::Functor< GameMap *, LOKI_TYPELIST_1(const ASCString &) > MapLoadingFunction
Definition: loaders.h:57
static GameMap * loadmap(const ASCString &name)
Definition: loaders.cpp:1039
NextCampaignMap(PG_Widget *parent, const PG_Rect &r)
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
bool search(int id)
GameMap * mapLoadingExceptionChecker(const ASCString &filename, MapLoadingFunction loader)
Definition: loaders.cpp:1539
const char * waiting
ASCString codeword
Definition: loaders.h:161
void errorMessage(const ASCString &string)
MapConinuationInfo findNextCampaignMap(int id)
Definition: loaders.cpp:1682
ASCString filename
Definition: loaders.h:162
void setLabelText(const ASCString &widgetName, const ASCString &text, PG_Widget *parent=NULL)
Definition: windowing.cpp:685
ASCString title
Definition: loaders.h:160
The map. THE central structure of ASC, which holds everything not globally available together...
Definition: gamemap.h:182