1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "backends/base-backend.h"
24 
25 #include "graphics/pixelbuffer.h"
26 #include "graphics/scalerplugin.h"
27 
28 #ifndef DISABLE_DEFAULT_EVENT_MANAGER
29 #include "backends/events/default/default-events.h"
30 #endif
31 
32 #ifndef DISABLE_DEFAULT_AUDIOCD_MANAGER
33 #include "backends/audiocd/default/default-audiocd.h"
34 #endif
35 
36 
37 #include "gui/message.h"
38 
setScaler(const char * name,int factor)39 bool BaseBackend::setScaler(const char *name, int factor) {
40 	if (!name)
41 		return false;
42 
43 	if (!scumm_stricmp(name, "default"))
44 		return setScaler(getDefaultScaler(), factor);
45 
46 	const PluginList &scalerPlugins = ScalerMan.getPlugins();
47 
48 	for (uint scalerIndex = 0; scalerIndex < scalerPlugins.size(); scalerIndex++) {
49 		if (!scumm_stricmp(scalerPlugins[scalerIndex]->get<ScalerPluginObject>().getName(), name)) {
50 			return setScaler(scalerIndex, factor);
51 		}
52 	}
53 
54 	return false;
55 }
56 
displayMessageOnOSD(const Common::U32String & msg)57 void BaseBackend::displayMessageOnOSD(const Common::U32String &msg) {
58 	// Display the message for 1.5 seconds
59 	GUI::TimedMessageDialog dialog(msg, 1500);
60 	dialog.runModal();
61 }
62 
initBackend()63 void BaseBackend::initBackend() {
64 	// Init audio CD manager
65 #ifndef DISABLE_DEFAULT_AUDIOCD_MANAGER
66 	if (!_audiocdManager)
67 		_audiocdManager = new DefaultAudioCDManager();
68 #endif
69 
70 	OSystem::initBackend();
71 }
72 
fillScreen(uint32 col)73 void BaseBackend::fillScreen(uint32 col) {
74 	Graphics::Surface *screen = lockScreen();
75 	if (screen)
76 		screen->fillRect(Common::Rect(screen->w, screen->h), col);
77 	unlockScreen();
78 }
79 
initBackend()80 void EventsBaseBackend::initBackend() {
81 	// Init Event manager
82 #ifndef DISABLE_DEFAULT_EVENT_MANAGER
83 	if (!_eventManager)
84 		_eventManager = new DefaultEventManager(this);
85 #endif
86 
87 	BaseBackend::initBackend();
88 }
89