| 1 |
/* |
| 2 |
Copyright (C) 2009-2013 wxLauncher Team |
| 3 |
|
| 4 |
This program is free software; you can redistribute it and/or |
| 5 |
modify it under the terms of the GNU General Public License |
| 6 |
as published by the Free Software Foundation; either version 2 |
| 7 |
of the License, or (at your option) any later version. |
| 8 |
|
| 9 |
This program is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License |
| 15 |
along with this program; if not, write to the Free Software |
| 16 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 |
*/ |
| 18 |
|
| 19 |
#ifndef RESOLUTION_MAP_H |
| 20 |
#define RESOLUTION_MAP_H |
| 21 |
|
| 22 |
#include <wx/event.h> |
| 23 |
#include <wx/list.h> |
| 24 |
|
| 25 |
#include "global/ModDefaults.h" |
| 26 |
#include "apis/EventHandlers.h" |
| 27 |
|
| 28 |
/** Maps a mod shortname to its user-preferred resolution. */ |
| 29 |
// TODO FIXME: Once the refresh button for the mod list is added, |
| 30 |
// then this map will need to be cleared whenever the user presses the button. |
| 31 |
|
| 32 |
/** ResolutionMap has changed. */ |
| 33 |
LAUNCHER_DECLARE_EVENT_TYPE(EVT_RESOLUTION_MAP_CHANGED); |
| 34 |
|
| 35 |
struct ResolutionData { |
| 36 |
ResolutionData() { } // required for wxHashMap, unfortunately |
| 37 |
ResolutionData(long width, long height) : width(width), height(height) { } |
| 38 |
bool IsValid() const { |
| 39 |
return (width >= DEFAULT_MOD_RESOLUTION_MIN_HORIZONTAL_RES) && |
| 40 |
(height >= DEFAULT_MOD_RESOLUTION_MIN_VERTICAL_RES); |
| 41 |
} |
| 42 |
long width; |
| 43 |
long height; |
| 44 |
}; |
| 45 |
|
| 46 |
WX_DECLARE_STRING_HASH_MAP( |
| 47 |
ResolutionData, |
| 48 |
PreferredResolutionMap); |
| 49 |
|
| 50 |
class ResolutionMap { |
| 51 |
public: |
| 52 |
static const ResolutionData* ResolutionRead(const wxString& shortname); |
| 53 |
static void ResolutionWrite(const wxString& shortname, const ResolutionData& resData); |
| 54 |
static bool HasEntryForActiveMod(); |
| 55 |
|
| 56 |
static void RegisterResolutionMapChanged(wxEvtHandler *handler); |
| 57 |
static void UnRegisterResolutionMapChanged(wxEvtHandler *handler); |
| 58 |
private: |
| 59 |
static void GenerateResolutionMapChanged(); |
| 60 |
static EventHandlers resolutionMapChangedHandlers; |
| 61 |
static PreferredResolutionMap prefResMap; |
| 62 |
}; |
| 63 |
|
| 64 |
#endif |