1 ////////////////////////////////////////////////////////////////////////////////////////
2 //
3 // Nestopia - NES/Famicom emulator written in C++
4 //
5 // Copyright (C) 2003-2008 Martin Freij
6 //
7 // This file is part of Nestopia.
8 //
9 // Nestopia is free software; you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation; either version 2 of the License, or
12 // (at your option) any later version.
13 //
14 // Nestopia is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with Nestopia; if not, write to the Free Software
21 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22 //
23 ////////////////////////////////////////////////////////////////////////////////////////
24 
25 #ifndef NST_MANAGER_PREFERENCES_H
26 #define NST_MANAGER_PREFERENCES_H
27 
28 #pragma once
29 
30 #include "NstApplicationInstance.hpp"
31 #include "NstCollectionBitSet.hpp"
32 #include "NstObjectHeap.hpp"
33 #include "../core/api/NstApiMachine.hpp"
34 
35 namespace Nestopia
36 {
37 	namespace Window
38 	{
39 		class Preferences;
40 	}
41 
42 	namespace Managers
43 	{
44 		class Preferences : Manager
45 		{
46 		public:
47 
48 			Preferences(Emulator&,const Configuration&,Window::Menu&);
49 			~Preferences();
50 
51 			enum Type
52 			{
53 				START_IN_FULLSCREEN,
54 				SUPPRESS_WARNINGS,
55 				FIRST_UNLOAD_ON_EXIT,
56 				CONFIRM_EXIT,
57 				RUN_IN_BACKGROUND,
58 				AUTOSTART_EMULATION,
59 				SAVE_LOGFILE,
60 				ALLOW_MULTIPLE_INSTANCES,
61 				SAVE_LAUNCHER,
62 				CONFIRM_RESET,
63 				SAVE_CHEATS,
64 				SAVE_NETPLAY_GAMELIST,
65 				SAVE_WINDOWPOS,
66 				SAVE_LAUNCHERSIZE,
67 				SAVE_SETTINGS,
68 				NUM_SETTINGS,
69 				DISABLE_STATUSMSG
70 			};
71 
72 			enum Priority
73 			{
74 				PRIORITY_NORMAL,
75 				PRIORITY_ABOVE_NORMAL,
76 				PRIORITY_HIGH
77 			};
78 
79 			void Save(Configuration&) const;
80 
81 		private:
82 
83 			typedef Application::Instance Instance;
84 
85 			void UpdateSettings();
86 			void UpdateMenuColor() const;
87 			void OnCmdOptions(uint);
88 			void OnEmuEvent(Emulator::Event,Emulator::Data);
89 			void OnAppEvent(Instance::Event,const void*);
90 
91 			struct
92 			{
93 				Collection::BitSet flags;
94 				Priority priority;
95 				Nes::Machine::FavoredSystem favoredSystem;
96 				bool alwaysAskSystem;
97 				bool disableStatusMsg;
98 			}   settings;
99 
100 			Object::Heap<Window::Preferences> dialog;
101 			bool inFullscreen;
102 
103 		public:
104 
operator [](Type type) const105 			bool operator [] (Type type) const
106 			{
107 				return settings.flags[type];
108 			}
109 
GetPriority() const110 			Priority GetPriority() const
111 			{
112 				return settings.priority;
113 			}
114 
GetFavoredSystem() const115 			Nes::Machine::FavoredSystem GetFavoredSystem() const
116 			{
117 				return settings.favoredSystem;
118 			}
119 
GetAlwaysAskProfile() const120 			Nes::Machine::AskProfile GetAlwaysAskProfile() const
121 			{
122 				return settings.alwaysAskSystem ? Nes::Machine::ASK_PROFILE : Nes::Machine::DONT_ASK_PROFILE;
123 			}
124 
GetDisableStatusMsg() const125 			bool GetDisableStatusMsg() const
126 			{
127 				return settings.disableStatusMsg;
128 			}
129 		};
130 	}
131 }
132 
133 #endif
134