2008-05-25 11:20:28 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INTERFACE_MANAGER_H
|
|
|
|
#define INTERFACE_MANAGER_H
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "graphics/surface.h"
|
|
|
|
#include "common/system.h"
|
2008-05-25 17:06:10 +00:00
|
|
|
|
2008-06-07 20:50:39 +00:00
|
|
|
#include "graphics/surface.h"
|
|
|
|
#include "graphics/fontman.h"
|
|
|
|
|
2008-06-28 16:49:39 +00:00
|
|
|
#include "gui/dialog.h"
|
2008-06-25 22:30:28 +00:00
|
|
|
#include "gui/ThemeParser.h"
|
2008-05-25 11:20:28 +00:00
|
|
|
#include "graphics/VectorRenderer.h"
|
|
|
|
|
|
|
|
namespace GUI {
|
|
|
|
|
2008-06-07 20:50:39 +00:00
|
|
|
struct WidgetDrawData;
|
|
|
|
|
2008-06-28 16:49:39 +00:00
|
|
|
struct WidgetDrawData {
|
|
|
|
Common::Array<Graphics::DrawStep*> _steps;
|
|
|
|
|
|
|
|
bool _cached;
|
|
|
|
Graphics::Surface *_surfaceCache;
|
|
|
|
uint32 _cachedW, _cachedH;
|
|
|
|
|
|
|
|
~WidgetDrawData() {
|
|
|
|
for (uint i = 0; i < _steps.size(); ++i)
|
|
|
|
delete _steps[i];
|
|
|
|
|
|
|
|
_steps.clear();
|
|
|
|
|
|
|
|
if (_surfaceCache) {
|
|
|
|
_surfaceCache->free();
|
|
|
|
delete _surfaceCache;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-07-02 18:11:41 +00:00
|
|
|
class ThemeRenderer : public Theme {
|
2008-06-09 21:16:26 +00:00
|
|
|
|
2008-06-10 11:25:00 +00:00
|
|
|
typedef Common::String String;
|
2008-06-28 16:49:39 +00:00
|
|
|
typedef GUI::Dialog Dialog;
|
|
|
|
|
|
|
|
friend class GUI::Dialog;
|
|
|
|
friend class GUI::GuiObject;
|
2008-05-25 11:20:28 +00:00
|
|
|
|
2008-06-24 19:48:01 +00:00
|
|
|
static const char *kDrawDataStrings[];
|
2008-06-28 16:49:39 +00:00
|
|
|
static const int kMaxDialogDepth = 4;
|
2008-06-24 19:48:01 +00:00
|
|
|
|
2008-05-25 11:20:28 +00:00
|
|
|
public:
|
2008-07-03 10:26:55 +00:00
|
|
|
enum GraphicsMode {
|
2008-05-28 15:03:30 +00:00
|
|
|
kGfxDisabled = 0,
|
|
|
|
kGfxStandard16bit,
|
|
|
|
kGfxAntialias16bit
|
2008-05-28 14:27:22 +00:00
|
|
|
};
|
2008-06-28 16:49:39 +00:00
|
|
|
|
2008-06-07 20:50:39 +00:00
|
|
|
enum DrawData {
|
2008-06-12 11:26:11 +00:00
|
|
|
kDDMainDialogBackground,
|
|
|
|
kDDSpecialColorBackground,
|
|
|
|
kDDPlainColorBackground,
|
|
|
|
kDDDefaulBackground,
|
|
|
|
|
|
|
|
kDDButtonIdle,
|
|
|
|
kDDButtonHover,
|
2008-07-03 19:42:04 +00:00
|
|
|
kDDButtonDisabled,
|
2008-06-12 11:26:11 +00:00
|
|
|
|
|
|
|
kDDSurface,
|
|
|
|
|
|
|
|
kDDSliderFull,
|
|
|
|
kDDSliderEmpty,
|
|
|
|
|
|
|
|
kDDCheckboxEnabled,
|
|
|
|
kDDCheckboxDisabled,
|
|
|
|
|
|
|
|
kDDTab,
|
|
|
|
|
2008-06-12 19:06:37 +00:00
|
|
|
kDDScrollbarBase,
|
|
|
|
kDDScrollbarButtonTop,
|
|
|
|
kDDScrollbarButtonBottom,
|
|
|
|
kDDScrollbarHandle,
|
2008-06-12 11:26:11 +00:00
|
|
|
|
|
|
|
kDDPopUp,
|
|
|
|
kDDCaret,
|
|
|
|
kDDSeparator,
|
2008-06-07 20:50:39 +00:00
|
|
|
kDrawDataMAX
|
|
|
|
};
|
|
|
|
|
2008-07-03 10:26:55 +00:00
|
|
|
ThemeRenderer(Common::String themeName, GraphicsMode mode);
|
2008-05-28 14:27:22 +00:00
|
|
|
|
2008-07-02 18:11:41 +00:00
|
|
|
~ThemeRenderer() {
|
2008-05-28 14:27:22 +00:00
|
|
|
freeRenderer();
|
|
|
|
freeScreen();
|
2008-06-29 19:59:16 +00:00
|
|
|
unloadTheme();
|
2008-06-25 22:30:28 +00:00
|
|
|
delete _parser;
|
2008-05-25 11:20:28 +00:00
|
|
|
}
|
|
|
|
|
2008-07-02 18:11:41 +00:00
|
|
|
// virtual methods from Theme
|
|
|
|
bool init();
|
2008-07-03 10:26:55 +00:00
|
|
|
void deinit();
|
|
|
|
void clearAll();
|
|
|
|
|
2008-07-02 18:11:41 +00:00
|
|
|
void refresh() {}
|
2008-07-03 19:42:04 +00:00
|
|
|
void enable();
|
|
|
|
void disable();
|
2008-07-02 18:11:41 +00:00
|
|
|
void openDialog() {}
|
|
|
|
void closeAllDialogs() {}
|
2008-07-03 10:26:55 +00:00
|
|
|
|
|
|
|
|
2008-07-03 19:42:04 +00:00
|
|
|
void updateScreen(); //{}
|
2008-07-02 18:11:41 +00:00
|
|
|
void resetDrawArea() {}
|
|
|
|
|
2008-07-03 10:26:55 +00:00
|
|
|
void openDialog(bool top) {}
|
2008-06-07 20:50:39 +00:00
|
|
|
|
|
|
|
/** Font management */
|
|
|
|
const Graphics::Font *getFont(FontStyle font) const { return _font; }
|
|
|
|
int getFontHeight(FontStyle font = kFontStyleBold) const { if (_initOk) return _font->getFontHeight(); return 0; }
|
|
|
|
int getStringWidth(const Common::String &str, FontStyle font) const { if (_initOk) return _font->getStringWidth(str); return 0; }
|
|
|
|
int getCharWidth(byte c, FontStyle font) const { if (_initOk) return _font->getCharWidth(c); return 0; }
|
|
|
|
|
|
|
|
/** Widget drawing */
|
2008-06-10 11:25:00 +00:00
|
|
|
void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background = kWidgetBackgroundPlain, WidgetStateInfo state = kStateEnabled) {}
|
2008-06-12 19:06:37 +00:00
|
|
|
void drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state = kStateEnabled, uint16 hints = 0);
|
2008-06-10 11:25:00 +00:00
|
|
|
void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state = kStateEnabled, int alpha = 256, bool themeTrans = false) {}
|
2008-06-12 19:06:37 +00:00
|
|
|
void drawSlider(const Common::Rect &r, int width, WidgetStateInfo state = kStateEnabled);
|
|
|
|
void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state = kStateEnabled);
|
2008-06-10 11:25:00 +00:00
|
|
|
void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state = kStateEnabled) {}
|
2008-06-12 19:06:37 +00:00
|
|
|
void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState, WidgetStateInfo state = kStateEnabled);
|
2008-06-10 11:25:00 +00:00
|
|
|
void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state = kStateEnabled, TextAlign align = kTextAlignLeft) {}
|
|
|
|
void drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state = kStateEnabled) {}
|
2008-06-12 11:26:11 +00:00
|
|
|
void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state = kStateEnabled);
|
2008-05-28 14:27:22 +00:00
|
|
|
|
2008-07-02 18:11:41 +00:00
|
|
|
void drawDialogBackground(const Common::Rect &r, uint16 hints, WidgetStateInfo state) {}
|
|
|
|
void drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font) {}
|
|
|
|
void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state) {}
|
|
|
|
|
|
|
|
bool addDirtyRect(Common::Rect r, bool backup = false, bool special = false) {
|
|
|
|
_dirtyScreen.push_back(r);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// custom stuff - tanoku
|
2008-06-18 00:15:21 +00:00
|
|
|
DrawData getDrawDataId(Common::String &name) {
|
2008-06-24 19:48:01 +00:00
|
|
|
for (int i = 0; i < kDrawDataMAX; ++i)
|
|
|
|
if (name.compareToIgnoreCase(kDrawDataStrings[i]) == 0)
|
|
|
|
return (DrawData)i;
|
|
|
|
|
|
|
|
return (DrawData)-1;
|
2008-06-18 00:15:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void addDrawStep(Common::String &drawDataId, Graphics::DrawStep *step);
|
2008-06-24 19:48:01 +00:00
|
|
|
bool addDrawData(DrawData data_id, bool cached);
|
2008-06-18 00:15:21 +00:00
|
|
|
|
2008-06-25 22:30:28 +00:00
|
|
|
ThemeParser *parser() {
|
|
|
|
return _parser;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ready() {
|
|
|
|
return _initOk && _themeOk;
|
|
|
|
}
|
|
|
|
|
2008-07-03 10:26:55 +00:00
|
|
|
// REMOVED: theme name is looked up in NewGUI and passed to the constructor
|
|
|
|
/* bool loadTheme() {
|
2008-06-28 16:49:39 +00:00
|
|
|
ConfMan.registerDefault("gui_theme", "default");
|
|
|
|
Common::String style(ConfMan.get("gui_theme"));
|
|
|
|
|
|
|
|
if (style.compareToIgnoreCase("default") == 0)
|
|
|
|
style = "modern";
|
|
|
|
|
|
|
|
return loadTheme(style);
|
2008-07-03 10:26:55 +00:00
|
|
|
} */
|
2008-06-28 16:49:39 +00:00
|
|
|
|
2008-06-26 13:50:16 +00:00
|
|
|
bool loadTheme(Common::String themeName);
|
2008-07-03 10:26:55 +00:00
|
|
|
void setGraphicsMode(GraphicsMode mode);
|
2008-07-02 18:11:41 +00:00
|
|
|
|
2008-05-25 11:20:28 +00:00
|
|
|
protected:
|
2008-05-28 14:30:51 +00:00
|
|
|
template<typename PixelType> void screenInit();
|
2008-05-28 14:27:22 +00:00
|
|
|
|
2008-06-26 13:50:16 +00:00
|
|
|
bool loadThemeXML(Common::String themeName);
|
|
|
|
bool loadDefaultXML();
|
2008-06-25 22:30:28 +00:00
|
|
|
|
2008-06-28 16:49:39 +00:00
|
|
|
void unloadTheme() {
|
|
|
|
if (!_themeOk)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (int i = 0; i < kDrawDataMAX; ++i) {
|
|
|
|
delete _widgets[i];
|
|
|
|
_widgets[i] = 0;
|
|
|
|
}
|
2008-07-03 19:42:04 +00:00
|
|
|
|
|
|
|
_themeOk = false;
|
2008-06-28 16:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void screenChange() {}
|
2008-07-02 18:11:41 +00:00
|
|
|
void renderDirtyScreen();
|
2008-06-28 16:49:39 +00:00
|
|
|
|
2008-05-28 14:27:22 +00:00
|
|
|
void freeRenderer() {
|
2008-05-28 14:37:29 +00:00
|
|
|
delete _vectorRenderer;
|
|
|
|
_vectorRenderer = 0;
|
2008-05-28 14:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void freeScreen() {
|
2008-05-28 14:37:29 +00:00
|
|
|
if (_screen != 0) {
|
2008-05-28 14:27:22 +00:00
|
|
|
_screen->free();
|
|
|
|
delete _screen;
|
2008-05-28 14:37:29 +00:00
|
|
|
_screen = 0;
|
2008-05-28 14:27:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-29 12:08:53 +00:00
|
|
|
bool needRedraw() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void redrawDialogStack();
|
2008-06-28 16:49:39 +00:00
|
|
|
|
2008-06-12 11:26:11 +00:00
|
|
|
bool isWidgetCached(DrawData type, const Common::Rect &r);
|
|
|
|
void drawCached(DrawData type, const Common::Rect &r);
|
|
|
|
|
|
|
|
inline void drawDD(DrawData type, const Common::Rect &r);
|
2008-06-28 16:49:39 +00:00
|
|
|
|
2008-07-02 18:11:41 +00:00
|
|
|
// TODO
|
|
|
|
void restoreBackground(Common::Rect r, bool special = false) {}
|
|
|
|
|
|
|
|
int getTabSpacing() const {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getTabPadding() const {
|
|
|
|
return 3;
|
2008-06-28 16:49:39 +00:00
|
|
|
}
|
2008-06-12 11:26:11 +00:00
|
|
|
|
2008-05-28 14:27:22 +00:00
|
|
|
OSystem *_system;
|
2008-05-25 11:20:28 +00:00
|
|
|
Graphics::VectorRenderer *_vectorRenderer;
|
2008-06-25 22:30:28 +00:00
|
|
|
GUI::ThemeParser *_parser;
|
2008-05-28 14:27:22 +00:00
|
|
|
|
2008-06-28 16:49:39 +00:00
|
|
|
Graphics::Surface *_screen;
|
|
|
|
|
2008-05-28 14:27:22 +00:00
|
|
|
int _bytesPerPixel;
|
2008-07-03 10:26:55 +00:00
|
|
|
GraphicsMode _graphicsMode;
|
2008-06-07 20:50:39 +00:00
|
|
|
|
|
|
|
Common::String _fontName;
|
|
|
|
const Graphics::Font *_font;
|
|
|
|
|
|
|
|
WidgetDrawData *_widgets[kDrawDataMAX];
|
2008-06-29 12:08:53 +00:00
|
|
|
Common::Array<Common::Rect> _dirtyScreen;
|
2008-06-07 20:50:39 +00:00
|
|
|
|
|
|
|
bool _initOk;
|
2008-06-25 22:30:28 +00:00
|
|
|
bool _themeOk;
|
2008-06-07 20:50:39 +00:00
|
|
|
bool _caching;
|
2008-07-03 19:42:04 +00:00
|
|
|
bool _enabled;
|
2008-07-03 10:26:55 +00:00
|
|
|
|
|
|
|
Common::String _themeName;
|
2008-05-25 11:20:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end of namespace GUI.
|
|
|
|
|
2008-05-25 17:06:10 +00:00
|
|
|
#endif
|