File: ResolutionMap.h

package info (click to toggle)
freespace2-launcher-wxlauncher 0.11.0%2Bdfsg-1
  • links: PTS, VCS
  • area: contrib
  • in suites: stretch
  • size: 2,372 kB
  • ctags: 1,443
  • sloc: cpp: 13,446; python: 797; makefile: 13; sh: 12
file content (64 lines) | stat: -rw-r--r-- 2,144 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 Copyright (C) 2009-2013 wxLauncher Team
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#ifndef RESOLUTION_MAP_H
#define RESOLUTION_MAP_H

#include <wx/event.h>
#include <wx/list.h>

#include "global/ModDefaults.h"
#include "apis/EventHandlers.h"

/** Maps a mod shortname to its user-preferred resolution. */
// TODO FIXME: Once the refresh button for the mod list is added,
// then this map will need to be cleared whenever the user presses the button.

/** ResolutionMap has changed. */
LAUNCHER_DECLARE_EVENT_TYPE(EVT_RESOLUTION_MAP_CHANGED);

struct ResolutionData {
	ResolutionData() { } // required for wxHashMap, unfortunately
	ResolutionData(long width, long height) : width(width), height(height) { }
	bool IsValid() const {
		return (width >= DEFAULT_MOD_RESOLUTION_MIN_HORIZONTAL_RES) &&
			(height >= DEFAULT_MOD_RESOLUTION_MIN_VERTICAL_RES);
	}
	long width;
	long height;
};

WX_DECLARE_STRING_HASH_MAP(
	ResolutionData,
	PreferredResolutionMap);

class ResolutionMap {
public:
	static const ResolutionData* ResolutionRead(const wxString& shortname);
	static void ResolutionWrite(const wxString& shortname, const ResolutionData& resData);
	static bool HasEntryForActiveMod();
	
	static void RegisterResolutionMapChanged(wxEvtHandler *handler);
	static void UnRegisterResolutionMapChanged(wxEvtHandler *handler);
private:
	static void GenerateResolutionMapChanged();
	static EventHandlers resolutionMapChangedHandlers;
	static PreferredResolutionMap prefResMap;
};

#endif