Advanced Strategic Command
fileselector.h
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 #ifndef FILESELECTOR_H
22 #define FILESELECTOR_H
23 
24 #include "selectionwindow.h"
25 #include "../paradialog.h"
26 #include "../graphics/blitter.h"
27 #include "../loaders.h"
28 
31 
32 class FileInfo
33 {
34  public:
38  int level;
39  FileInfo( const ASCString& filename, const ASCString& filelocation, time_t time, int directorylevel ) : name( filename), location( filelocation ), modificationTime( time ), level( directorylevel )
40  {}
42  {}
43 }
44 ;
45 
47  FileInfo fileInfo;
48  ASCString time;
49  bool fileInformationLoaded;
51  PG_Label* mapTitleLabel;
52  static Surface alternateImage;
53  public:
54  SavegameWidget( PG_Widget* parent, const PG_Point& pos, int width, const FileInfo* fi );
55  ASCString getName() const;
56  protected:
57  void display( SDL_Surface * surface, const PG_Rect & src, const PG_Rect & dst );
58 
59 };
60 
61 
63  ASCString filename;
64  ASCString wildcard;
65  bool saveFile;
66  bool overwriteMessage;
67  FileSelectionItemFactory* factory;
68 
69  protected:
70  void fileNameSelected( const ASCString& filename );
71  void fileNameEntered( ASCString filename );
72  public:
74  FileSelectionWindow( PG_Widget *parent, const PG_Rect &r, const ASCString& fileWildcard, bool save, bool overwriteMessage );
75  ASCString getFilename() { return filename; };
76 };
77 
78 
80  protected:
82  Items::iterator it;
83 
84  private:
85  Items items;
86 
87  public:
89  FileSelectionItemFactory( const ASCString& wildcard );
90 
91  static bool comp ( const FileInfo* i1, const FileInfo* i2 );
92 
93  void restart();
94 
95  int getLevel( const ASCString& name );
96 
97  SelectionWidget* spawnNextItem( PG_Widget* parent, const PG_Point& pos );
98 
99  sigc::signal<void,const ASCString& > filenameSelectedMouse;
100  sigc::signal<void,const ASCString& > filenameSelectedKeyb;
101  sigc::signal<void,const ASCString& > filenameMarked;
102 
103  void itemMarked( const SelectionWidget* widget );
104 
105  void itemSelected( const SelectionWidget* widget, bool mouse );
106 };
107 
108 extern ASCString selectFile( const ASCString& ext, bool load, bool overwriteMessage = true );
109 
110 
112  ASCString filename;
113  ASCString wildcard;
114  bool saveFile;
115  bool overwriteMessage;
117 
118  protected:
119  void fileNameSelected( const ASCString& filename );
120  void fileNameEntered( ASCString filename );
121  public:
123  SavegameSelectionWindow( PG_Widget *parent, const PG_Rect &r, const ASCString& fileWildcard, bool save, bool overwriteMessage );
124  ASCString getFilename() { return filename; };
125 };
126 
127 
129  protected:
131  Items::iterator it;
132 
133  private:
134  Items items;
135 
136  public:
138  SavegameSelectionItemFactory( const ASCString& wildcard );
139 
140  static bool comp ( const FileInfo* i1, const FileInfo* i2 );
141 
142  void restart();
143 
144  int getLevel( const ASCString& name );
145 
146  SelectionWidget* spawnNextItem( PG_Widget* parent, const PG_Point& pos );
147 
148  sigc::signal<void,const ASCString& > filenameSelectedMouse;
149  sigc::signal<void,const ASCString& > filenameSelectedKeyb;
150  sigc::signal<void,const ASCString& > filenameMarked;
151 
152  void itemMarked( const SelectionWidget* widget );
153 
154  void itemSelected( const SelectionWidget* widget, bool mouse );
155 };
156 
157 
158 
159 extern ASCString selectSavegame( const ASCString& ext, bool load, bool overwriteMessage = true );
160 
161 #endif
void display(SDL_Surface *surface, const PG_Rect &src, const PG_Rect &dst)
SelectionWidget * spawnNextItem(PG_Widget *parent, const PG_Point &pos)
void itemSelected(const SelectionWidget *widget, bool mouse)
Items::iterator it
Definition: fileselector.h:82
sigc::signal< void, const ASCString & > filenameSelectedKeyb
Definition: fileselector.h:100
void itemMarked(const SelectionWidget *widget)
void fileNameSelected(const ASCString &filename)
deallocating_vector< FileInfo * > Items
Definition: fileselector.h:81
time_t modificationTime
Definition: fileselector.h:37
sigc::signal< void, const ASCString & > filenameSelectedMouse
Definition: fileselector.h:99
static bool comp(const FileInfo *i1, const FileInfo *i2)
static bool comp(const FileInfo *i1, const FileInfo *i2)
SavegameSelectionItemFactory(const ASCString &wildcard)
deallocating_vector< FileInfo * > Items
Definition: fileselector.h:130
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
sigc::signal< void, const ASCString & > filenameSelectedMouse
Definition: fileselector.h:148
SavegameSelectionWindow(PG_Widget *parent, const PG_Rect &r, const ASCString &fileWildcard, bool save, bool overwriteMessage)
SavegameWidget(PG_Widget *parent, const PG_Point &pos, int width, const FileInfo *fi)
sigc::signal< void, const ASCString & > filenameMarked
Definition: fileselector.h:101
SelectionWidget * spawnNextItem(PG_Widget *parent, const PG_Point &pos)
int getLevel(const ASCString &name)
Adapter class for using Paragui Dialogs in ASC. This class transfers the event control from ASC to Pa...
Definition: paradialog.h:127
ASCString name
Definition: fileselector.h:35
FileInfo(const ASCString &filename, const ASCString &filelocation, time_t time, int directorylevel)
Definition: fileselector.h:39
void fileNameEntered(ASCString filename)
ASCString selectFile(const ASCString &ext, bool load, bool overwriteMessage=true)
void itemMarked(const SelectionWidget *widget)
FileSelectionItemFactory(const ASCString &wildcard)
FileInfo(const FileInfo &fi)
Definition: fileselector.h:41
sigc::signal< void, const ASCString & > filenameSelectedKeyb
Definition: fileselector.h:149
FileSelectionWindow(PG_Widget *parent, const PG_Rect &r, const ASCString &fileWildcard, bool save, bool overwriteMessage)
ASCString selectSavegame(const ASCString &ext, bool load, bool overwriteMessage=true)
void fileNameEntered(ASCString filename)
int getLevel(const ASCString &name)
ASCString getFilename()
Definition: fileselector.h:75
ASCString location
Definition: fileselector.h:36
sigc::signal< void, const ASCString & > filenameMarked
Definition: fileselector.h:150
ASCString getName() const
void fileNameSelected(const ASCString &filename)
void itemSelected(const SelectionWidget *widget, bool mouse)