/* 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 CINE_GFX_H
#define CINE_GFX_H
#include "common/noncopyable.h"
#include "common/rect.h"
#include "common/stack.h"
#include "cine/object.h"
namespace Cine {
extern byte *collisionPage;
static const int kCollisionPageBgIdxAlias = 8;
/*! \brief Background with palette
*/
struct palBg {
byte *bg; ///< Background data
Cine::Palette pal; ///< Background color palette
char name[15]; ///< Background filename
/** @brief Default constructor. */
palBg() : bg(NULL), pal(), name() {
// Make sure the name is empty (Maybe this is not needed?)
memset(this->name, 0, sizeof(this->name));
}
/** @brief Clears the struct (Releases allocated memory etc). */
void clear() {
// In Operation Stealth the 9th background is sometimes aliased to
// the collision page so we should take care not to double delete it
// (The collision page is deleted elsewhere).
if (this->bg != collisionPage) {
delete[] this->bg;
}
this->bg = NULL;
this->pal.clear();
memset(this->name, 0, sizeof(this->name));
}
};
class FWRenderer;
class Menu {
public:
enum Type {
kSelectionMenu,
kTextInputMenu
};
Menu(Type t) : _type(t) {}
virtual ~Menu() {}
Type getType() const { return _type; }
virtual void drawMenu(FWRenderer &r, bool top) = 0;
private:
const Type _type;
};
class SelectionMenu : public Menu {
public:
SelectionMenu(Common::Point p, int width, Common::StringArray elements);
int getElementCount() const { return _elements.size(); }
void setSelection(int selection);
void drawMenu(FWRenderer &r, bool top);
private:
const Common::Point _pos;
const int _width;
const Common::StringArray _elements;
int _selection;
};
class TextInputMenu : public Menu {
public:
TextInputMenu(Common::Point p, int width, const char *info);
void setInput(const char *input, int cursor);
void drawMenu(FWRenderer &r, bool top);
private:
const Common::Point _pos;
const int _width;
const Common::String _info;
Common::String _input;
int _cursor;
};
/*! \brief Future Wars renderer
*
* Screen backbuffer is not cleared between frames.
*/
class FWRenderer : public Common::NonCopyable {
// TODO: Consider getting rid of this
friend class SelectionMenu;
friend class TextInputMenu;
private:
byte *_background; ///< Current background
char _bgName[13]; ///< Background filename
Common::String _cmd; ///< Player command string
protected:
static const int _screenSize = 320 * 200; ///< Screen size
static const int _screenWidth = 320; ///< Screen width
static const int _screenHeight = 200; ///< Screen height
byte *_backBuffer; ///< Screen backbuffer
Cine::Palette _backupPal; ///< The backup color palette
Cine::Palette _activePal; ///< The active color palette
Common::Stack