scummvm/gui/theme.h
Vicent Marti 60ad4bd0d9 - Merged 75 revisions from trunk.
- Fixed new conflicts.
- Changed Theme loading to use the new ZipArchive class.
- Implemented ZipArchive::getAllNames()

Original log message from SVNMerge.py
================================
Merged revisions 34605,34613-34615,34617,34619-34624,34627-34628,34630-34639,34642-34649,34656-34661,34663-34664,34671-34672,34674-34676,34678-34685 via svnmerge from 
https://tanoku@scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk

........
  r34605 | Tanoku | 2008-09-20 12:32:59 +0200 (Sat, 20 Sep 2008) | 1 line
  
  Fixed "empty control statement" warning in FSDirectory::matchPattern().
........
  r34613 | lordhoto | 2008-09-20 16:53:31 +0200 (Sat, 20 Sep 2008) | 2 lines
  
  Updated theme file version, to reflect latest addition of new required entries/files.
........
  r34614 | wjpalenstijn | 2008-09-20 17:03:37 +0200 (Sat, 20 Sep 2008) | 1 line
  
  fix drawing order in saveload choosers (draw container before contents)
........
  r34615 | fingolfin | 2008-09-20 17:53:17 +0200 (Sat, 20 Sep 2008) | 1 line
  
  Little readability tweak
........
  r34617 | fingolfin | 2008-09-20 18:10:29 +0200 (Sat, 20 Sep 2008) | 1 line
  
  Fix for bug #2120602: 5ALL: Starting the launcher with -f triggers assertion
........
  r34619 | eriktorbjorn | 2008-09-20 18:21:27 +0200 (Sat, 20 Sep 2008) | 4 lines
  
  I think this is the correct fix for bug #2081347 ("MM: Charset out of
  bounds!"). If I understand correctly, version <= 2 games only have one (hard-
  coded) font, so when that's initialised we can set _curId to 0.
........
  r34620 | marcus_c | 2008-09-20 18:38:50 +0200 (Sat, 20 Sep 2008) | 1 line
  
  game.h is now in engines, not base.
........
  r34621 | marcus_c | 2008-09-20 18:47:31 +0200 (Sat, 20 Sep 2008) | 5 lines
  
  In the CD filesystem, nothing can be opened for writing, so just
  short-circuit any call to openForWriting().  Also, directories and
  non-existing files can't be opened for reading either, so just
  return 0 for those.
........
  r34622 | sev | 2008-09-21 12:23:22 +0200 (Sun, 21 Sep 2008) | 2 lines
  
  Patch #2054467: CRUISE: 64bits fixes
........
  r34623 | sev | 2008-09-21 13:17:22 +0200 (Sun, 21 Sep 2008) | 2 lines
  
  Add recent patch contributors. Reflect current ScummVM team in the credits
........
  r34624 | sev | 2008-09-21 13:18:16 +0200 (Sun, 21 Sep 2008) | 2 lines
  
  Reflect current team
........
  r34627 | lordhoto | 2008-09-22 19:33:30 +0200 (Mon, 22 Sep 2008) | 1 line
  
  Fixed full screen toggling via alt+enter.
........
  r34628 | fingolfin | 2008-09-22 22:55:27 +0200 (Mon, 22 Sep 2008) | 1 line
  
  Fix comments for random() funcs (thanks to salty-horse for pointing this out)
........
  r34630 | fingolfin | 2008-09-23 11:39:37 +0200 (Tue, 23 Sep 2008) | 1 line
  
  Moved ZipArchive implementation into unzip.cpp, added new ZipArchive::isOpen method
........
  r34631 | fingolfin | 2008-09-23 11:42:38 +0200 (Tue, 23 Sep 2008) | 1 line
  
  ImageManager: renamed remArchive() to removeArchive(); switched to using a SearchSet + ZipArchive to access ZIP files (code is much simpler now yet more flexible, yay)
........
  r34632 | fingolfin | 2008-09-23 11:50:03 +0200 (Tue, 23 Sep 2008) | 1 line
  
  Moved ZipArchive to namespace Common; moved unzip internals from unzip.h to unzip.cpp (to be cleaned up)
........
  r34633 | fingolfin | 2008-09-23 12:08:45 +0200 (Tue, 23 Sep 2008) | 1 line
  
  cleanup
........
  r34634 | fingolfin | 2008-09-23 12:10:29 +0200 (Tue, 23 Sep 2008) | 1 line
  
  Perform error checking when reading from a ZIP file
........
  r34635 | fingolfin | 2008-09-23 13:43:57 +0200 (Tue, 23 Sep 2008) | 1 line
  
  Fix for bug #1917981: Game crash when finishing Indy3 demo. At the same time, added a new paranoia check
........
  r34636 | Kirben | 2008-09-23 14:34:02 +0200 (Tue, 23 Sep 2008) | 1 line
  
  Add another French Windows version of Putt-Putt Enters the Race.
........
  r34637 | lordhoto | 2008-09-23 18:40:41 +0200 (Tue, 23 Sep 2008) | 2 lines
  
  Fix for bug #2120780 "GUI: gui-theme command-line option ignored", '-f' and '-g' command line switch behavior.
........
  r34638 | john_doe | 2008-09-24 01:16:47 +0200 (Wed, 24 Sep 2008) | 1 line
  
  Improved updateScreenAndWait; the mouse cursor is less jerky now in some scenes in Manhole:N&E
........
  r34639 | thebluegr | 2008-09-24 09:26:45 +0200 (Wed, 24 Sep 2008) | 1 line
  
  Readded missing special case for the storm animation in ITE. Fixes bug #2125675 - "ITE: Game locks up in storm clouds scene"
........
  r34642 | fingolfin | 2008-09-24 22:29:29 +0200 (Wed, 24 Sep 2008) | 1 line
  
  Changed Common::String to use a MemoryPool for its refcounts
........
  r34643 | fingolfin | 2008-09-24 22:31:14 +0200 (Wed, 24 Sep 2008) | 1 line
  
  cleanup
........
  r34644 | fingolfin | 2008-09-24 22:35:31 +0200 (Wed, 24 Sep 2008) | 1 line
  
  Changed builtin Common::String capacity to 24 (on 32 bit systems), to make sizeof(String) 32; reduces overall memory req by 200k on my system; overall # of mallocs after this + the refcount memory pool change is almost unchanged
........
  r34645 | sev | 2008-09-25 00:44:01 +0200 (Thu, 25 Sep 2008) | 2 lines
  
  Fix bugs #1981081: "ITE: No blinking disk icon" and #1971729: "IHNM: No Animation of Disk Icon"
........
  r34646 | fingolfin | 2008-09-25 10:06:18 +0200 (Thu, 25 Sep 2008) | 1 line
  
  SCUMM: Added a new ActorHE class, as well as a virtual Actor::prepareDrawActorCostume() method
........
  r34647 | fingolfin | 2008-09-25 10:19:51 +0200 (Thu, 25 Sep 2008) | 1 line
  
  SCUMM: Moved Actor::drawActorToBackBuf to class ActorHE
........
  r34648 | fingolfin | 2008-09-25 12:11:06 +0200 (Thu, 25 Sep 2008) | 1 line
  
  SCUMM: Moved more stuf from class Actor to ActorHE
........
  r34649 | fingolfin | 2008-09-25 12:14:50 +0200 (Thu, 25 Sep 2008) | 1 line
  
  cleanup
........
  r34656 | eriktorbjorn | 2008-09-27 19:25:40 +0200 (Sat, 27 Sep 2008) | 2 lines
  
  Fixed typos.
........
  r34657 | eriktorbjorn | 2008-09-27 19:47:22 +0200 (Sat, 27 Sep 2008) | 2 lines
  
  Allow quitting or returning to the launcher while cutscenes are playing.
........
  r34658 | eriktorbjorn | 2008-09-27 19:51:22 +0200 (Sat, 27 Sep 2008) | 2 lines
  
  Slight simplification of last commit.
........
  r34659 | fingolfin | 2008-09-27 20:32:01 +0200 (Sat, 27 Sep 2008) | 1 line
  
  Modified Common::SearchSet to take signed integer priorities, for convenience (so that one can add archives with less-than-default priority)
........
  r34660 | fingolfin | 2008-09-27 20:34:24 +0200 (Sat, 27 Sep 2008) | 1 line
  
  Fixed a nasty bug in SearchManager::addDirectory; made the 'char' constructor of Common::String explicit, to avoid such bugs in the future
........
  r34661 | drmccoy | 2008-09-27 22:04:04 +0200 (Sat, 27 Sep 2008) | 2 lines
  
  Added a spanish floppy version of Lost in Time, as supplied by goodoldgeorg in bug report #2105220
........
  r34663 | fingolfin | 2008-09-28 01:00:46 +0200 (Sun, 28 Sep 2008) | 1 line
  
  Changed Common::File to use SearchMan
........
  r34664 | fingolfin | 2008-09-28 01:27:01 +0200 (Sun, 28 Sep 2008) | 1 line
  
  SCUMM: Use FilesystemNode::openForReading instead of Common::File::open(FilesystemNode) in the detector
........
  r34671 | john_doe | 2008-09-28 22:02:01 +0200 (Sun, 28 Sep 2008) | 1 line
  
  Return 32000 in sfGetCdTime instead of 0; this fixes the Manhole intro/credits (until the function is actually implemented)
........
  r34672 | sev | 2008-09-28 23:07:41 +0200 (Sun, 28 Sep 2008) | 2 lines
  
  Add Italian C64 Zak
........
  r34674 | sev | 2008-09-28 23:53:14 +0200 (Sun, 28 Sep 2008) | 2 lines
  
  Fix bug #2043489: DRASCULA: Cannot disable speech
........
  r34675 | sev | 2008-09-29 00:07:16 +0200 (Mon, 29 Sep 2008) | 3 lines
  
  - Renamed withVoices to _subtitlesDisabled as it reflect the true meaning.
  - Allowed to disable subtitles from options dialogs including RTL.
........
  r34676 | sev | 2008-09-29 00:19:11 +0200 (Mon, 29 Sep 2008) | 2 lines
  
  Use better "silence" without clicks when speech is disabled.
........
  r34678 | fingolfin | 2008-09-29 12:29:01 +0200 (Mon, 29 Sep 2008) | 1 line
  
  Added FIXME to GP2x port
........
  r34679 | fingolfin | 2008-09-29 12:30:31 +0200 (Mon, 29 Sep 2008) | 1 line
  
  Add priority parameter to the SearchMan API
........
  r34680 | fingolfin | 2008-09-29 12:32:06 +0200 (Mon, 29 Sep 2008) | 1 line
  
  File::open no longer falls back to searching the current dir (if this causes any regressions, please report them; don't work around them, don't revert this change, without discussing it first)
........
  r34681 | fingolfin | 2008-09-29 12:49:36 +0200 (Mon, 29 Sep 2008) | 1 line
  
  Don't subclass ArjFile from Common::File (there seems to be no good reason for it). BTW, this code is an abomination and should be replaced by an Archive/SearchSet approach
........
  r34682 | fingolfin | 2008-09-29 13:01:25 +0200 (Mon, 29 Sep 2008) | 1 line
  
  Added const qualifiers
........
  r34683 | fingolfin | 2008-09-29 13:02:11 +0200 (Mon, 29 Sep 2008) | 1 line
  
  SCUMM HE: Fixed leak in Win32ResExtractor::extractResource_, use _filename instead of File::name
........
  r34684 | fingolfin | 2008-09-29 13:03:10 +0200 (Mon, 29 Sep 2008) | 1 line
  
  Added const qualifiers
........
  r34685 | fingolfin | 2008-09-29 13:07:39 +0200 (Mon, 29 Sep 2008) | 1 line
  
  Don't use File::name() needlessly (i.e. if you still know which file you just opened :)
........

svn-id: r34687
2008-09-29 19:23:36 +00:00

353 lines
11 KiB
C++

/* 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 GUI_THEME_H
#define GUI_THEME_H
#include "common/system.h"
#include "common/rect.h"
#include "common/str.h"
#include "common/fs.h"
#include "common/config-file.h"
#include "graphics/surface.h"
#include "graphics/fontman.h"
#define THEME_VERSION 24
#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_THEME_V23"
namespace GUI {
class ThemeEval;
/**
* Our theme renderer class.
*
* It is used to draw the different widgets and
* getting the layout of the widgets for different
* resolutions.
*/
class Theme {
public:
Theme();
virtual ~Theme();
//! Defined the align of the text
enum TextAlign {
kTextAlignLeft, //! Text should be aligned to the left
kTextAlignCenter, //! Text should be centered
kTextAlignRight //! Text should be aligned to the right
};
//! Vertical alignment of the text.
enum TextAlignVertical {
kTextAlignVBottom,
kTextAlignVCenter,
kTextAlignVTop
};
//! Widget background type
enum WidgetBackground {
kWidgetBackgroundNo, //! No background at all
kWidgetBackgroundPlain, //! Simple background, this may not include borders
kWidgetBackgroundBorder, //! Same as kWidgetBackgroundPlain just with a border
kWidgetBackgroundBorderSmall, //! Same as kWidgetBackgroundPlain just with a small border
kWidgetBackgroundEditText, //! Background used for edit text fields
kWidgetBackgroundSlider //! Background used for sliders
};
//! Dialog background type
enum DialogBackground {
kDialogBackgroundMain,
kDialogBackgroundSpecial,
kDialogBackgroundPlain,
kDialogBackgroundDefault
};
//! State of the widget to be drawn
enum State {
kStateDisabled, //! Indicates that the widget is disabled, that does NOT include that it is invisible
kStateEnabled, //! Indicates that the widget is enabled
kStateHighlight //! Indicates that the widget is highlighted by the user
};
typedef State WidgetStateInfo;
enum ScrollbarState {
kScrollbarStateNo,
kScrollbarStateUp,
kScrollbarStateDown,
kScrollbarStateSlider,
kScrollbarStateSinglePage
};
//! Font style selector
enum FontStyle {
kFontStyleBold = 0, //! A bold font. This is also the default font.
kFontStyleNormal = 1, //! A normal font.
kFontStyleItalic = 2, //! Italic styled font.
kFontStyleFixedNormal = 3, //! Fixed size font.
kFontStyleFixedBold = 4, //! Fixed size bold font.
kFontStyleFixedItalic = 5, //! Fixed size italic font.
kFontStyleMax
};
//! Function used to process areas other than the current dialog
enum ShadingStyle {
kShadingNone, //! No special post processing
kShadingDim, //! Dimming unused areas
kShadingLuminance //! Converting colors to luminance for unused areas
};
/**
* This initializes all the data needed by the theme renderer.
* It should just be called *once*, when first using the renderer.
*
* Other functions of the renderer should just be used after
* calling this function, else the result is undefined.
*
* If used again it should just be used after deinit,
* if there is need to use the renderer again.
*
* @see deinit
*/
virtual bool init() = 0;
/**
* Unloads all data used by the theme renderer.
*/
virtual void deinit() = 0;
/**
* Updates the renderer to changes to resolution,
* bit depth and other video related configuration.
*/
virtual void refresh() = 0;
/**
* Checks if the theme supplies its own cursor.
*
* @return true if using an own cursor
*/
virtual bool ownCursor() const { return false; }
/**
* Enables the theme renderer for use.
*
* This for examples displays the overlay, clears the
* renderer's temporary screen buffers and does other
* things to make the renderer for use.
*
* This will NOT back up the data on the overlay.
* So if you've got data in the overlay save it before
* calling this.
*
* Unlike init, this makes the renderer ready to draw
* something to the screen. And of course it relies on the data
* loaded by init.
*
* @see disable
* @see init
*/
virtual void enable() = 0;
/**
* Disables the theme renderer.
*
* This for example hides the overlay and undoes
* other things done by enable.
*
* Unlike uninit, this just makes the renderer unable
* to do any screen drawing, but still keeps all data
* loaded into memory.
*
* @see enable
* @see uninit
*/
virtual void disable() = 0;
/**
* Tells the theme renderer that a new dialog is opened.
*
* This can be used for internal caching and marking
* area of all but the not top dialog in a special way.
*
* TODO: This needs serious reworking, since at least for
* normal usage, a dialog opened with openDialog should always
* be the top dialog. Currently our themes have no good enough
* implementation to handle a single open dialog though, so we
* have to stay this way until we implement proper dialog
* 'caching'/handling.
*
* @param topDialog if true it indicates that this is the top dialog
*
* @see closeAllDialogs
*/
virtual void openDialog(bool topDialog, ShadingStyle shading = kShadingNone) = 0;
/**
* This indicates that all dialogs have been closed.
*
* @see openDialog
*/
virtual void closeAllDialogs() = 0;
/**
* Closes the topmost dialog, and redraws the screen
* accordingly.
*
* TODO: Make this purely virtual by making ThemeClassic
* and ThemeModern implement it too.
*
* @returns True if the dialog was sucessfully closed.
* If we weren't able to restore the screen after closing
* the dialog, we return false, which means we need to redraw
* the dialog stack from scratch.
*/
virtual void startBuffering() = 0;
virtual void finishBuffering() = 0;
/**
* Clear the complete GUI screen.
*/
virtual void clearAll() = 0;
/**
* Update the GUI screen aka overlay.
*
* This does NOT call OSystem::updateScreen,
* it just copies all (changed) data to the overlay.
*/
virtual void updateScreen() = 0;
virtual const Graphics::Font *getFont(FontStyle font = kFontStyleBold) const = 0;
virtual int getFontHeight(FontStyle font = kFontStyleBold) const = 0;
virtual int getStringWidth(const Common::String &str, FontStyle font = kFontStyleBold) const = 0;
virtual int getCharWidth(byte c, FontStyle font = kFontStyleBold) const = 0;
virtual void drawDialogBackground(const Common::Rect &r, DialogBackground type, WidgetStateInfo state = kStateEnabled) = 0;
virtual void drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state = kStateEnabled, TextAlign align = kTextAlignCenter, bool inverted = false, int deltax = 0, bool useEllipsis = true, FontStyle font = kFontStyleBold) = 0;
// this should ONLY be used by the debugger until we get a nicer solution
virtual void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state = kStateEnabled) = 0;
virtual void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background = kWidgetBackgroundPlain, WidgetStateInfo state = kStateEnabled) = 0;
virtual void drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state = kStateEnabled, uint16 hints = 0) = 0;
virtual void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state = kStateEnabled, int alpha = 256, bool themeTrans = false) = 0;
virtual void drawSlider(const Common::Rect &r, int width, WidgetStateInfo state = kStateEnabled) = 0;
virtual void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state = kStateEnabled) = 0;
virtual 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) = 0;
virtual void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState, WidgetStateInfo state = kStateEnabled) = 0;
virtual void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state = kStateEnabled, TextAlign align = kTextAlignLeft) = 0;
virtual void drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state = kStateEnabled) = 0;
virtual void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state = kStateEnabled) = 0;
virtual void restoreBackground(Common::Rect r, bool special = false) = 0;
virtual bool addDirtyRect(Common::Rect r, bool save = false, bool special = false) = 0;
virtual int getTabSpacing() const = 0;
virtual int getTabPadding() const = 0;
Graphics::TextAlignment convertAligment(TextAlign align) const {
switch (align) {
case kTextAlignLeft:
return Graphics::kTextAlignLeft;
break;
case kTextAlignRight:
return Graphics::kTextAlignRight;
break;
default:
break;
};
return Graphics::kTextAlignCenter;
}
TextAlign convertAligment(Graphics::TextAlignment align) const {
switch (align) {
case Graphics::kTextAlignLeft:
return kTextAlignLeft;
break;
case Graphics::kTextAlignRight:
return kTextAlignRight;
break;
default:
break;
}
return kTextAlignCenter;
}
bool isThemeLoadingRequired();
virtual ThemeEval *evaluator() = 0;
static bool themeConfigUseable(const Common::FilesystemNode &node, Common::String &themeName);
static bool themeConfigParseHeader(Common::String header, Common::String &themeName);
virtual const Common::String &getThemeFileName() const = 0;
virtual const Common::String &getThemeName() const = 0;
virtual int getGraphicsMode() const = 0;
/**
* Checks if the theme renderer supports drawing of images.
*
* @return true on support, else false
*/
virtual bool supportsImages() const { return false; }
//! Special image ids for images used in the GUI
enum kThemeImages {
kImageLogo = 0, //! ScummVM Logo used in the launcher
kImageLogoSmall //! ScummVM logo used in the GMM
};
/**
* Returns the given image.
*
* @param n id of the image, see kThemeImages
* @return 0 if no such image exists for the theme, else pointer to the image
*
* @see kThemeImages
*/
virtual const Graphics::Surface *getImageSurface(const kThemeImages n) const { return 0; }
protected:
const Graphics::Font *loadFont(const char *filename);
Common::String genCacheFilename(const char *filename);
public:
bool needThemeReload() { return ((_loadedThemeX != g_system->getOverlayWidth()) ||
(_loadedThemeY != g_system->getOverlayHeight())); }
private:
static const char *_defaultConfigINI;
int _loadedThemeX, _loadedThemeY;
};
} // end of namespace GUI
#endif // GUI_THEME_H