Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "mutationofjb/widgets/buttonwidget.h"
#include "common/events.h"
#include "graphics/managed_surface.h"
namespace MutationOfJB {
ButtonWidget::ButtonWidget(GuiScreen &gui, const Common::Rect &area, const Graphics::Surface &normalSurface, const Graphics::Surface &pressedSurface) :
Widget(gui, area),
_normalSurface(normalSurface),
_pressedSurface(pressedSurface),
_callback(nullptr),
_pressed(false) {}
void ButtonWidget::setCallback(ButtonWidgetCallback *callback) {
_callback = callback;
}
void ButtonWidget::handleEvent(const Common::Event &event) {
switch (event.type) {
case Common::EVENT_LBUTTONDOWN: {
const int16 x = event.mouse.x;
const int16 y = event.mouse.y;
if (_area.contains(x, y)) {
_pressed = true;
markDirty();
}
break;
}
case Common::EVENT_LBUTTONUP: {
if (_pressed) {
_pressed = false;
markDirty();
if (_callback) {
_callback->onButtonClicked(this);
}
}
break;
}
default:
break;
}
}
void ButtonWidget::draw(Graphics::ManagedSurface &surface) {
surface.blitFrom(_pressed ? _pressedSurface : _normalSurface, Common::Point(_area.left, _area.top));
}
}

View File

@@ -0,0 +1,57 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef MUTATIONOFJB_BUTTONWIDGET_H
#define MUTATIONOFJB_BUTTONWIDGET_H
#include "mutationofjb/widgets/widget.h"
#include "graphics/surface.h"
namespace MutationOfJB {
class ButtonWidget;
class ButtonWidgetCallback {
public:
virtual ~ButtonWidgetCallback() {}
virtual void onButtonClicked(ButtonWidget *) = 0;
};
class ButtonWidget : public Widget {
public:
ButtonWidget(GuiScreen &gui, const Common::Rect &area, const Graphics::Surface &normalSurface, const Graphics::Surface &pressedSurface);
void setCallback(ButtonWidgetCallback *callback);
void handleEvent(const Common::Event &event) override;
protected:
void draw(Graphics::ManagedSurface &) override;
private:
Graphics::Surface _normalSurface;
Graphics::Surface _pressedSurface;
ButtonWidgetCallback *_callback;
bool _pressed;
};
}
#endif

View File

@@ -0,0 +1,95 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "mutationofjb/widgets/conversationwidget.h"
#include "mutationofjb/game.h"
#include "mutationofjb/gamedata.h"
#include "mutationofjb/guiscreen.h"
#include "mutationofjb/font.h"
#include "common/events.h"
namespace MutationOfJB {
enum {
CONVERSATION_LINES_X = 5,
CONVERSATION_LINES_Y = 151,
CONVERSATION_LINE_HEIGHT = 12
};
ConversationWidget::ConversationWidget(GuiScreen &gui, const Common::Rect &area, const Graphics::Surface &surface) :
Widget(gui, area),
_surface(surface),
_callback(nullptr) {}
void ConversationWidget::setChoice(int choiceNo, const Common::String &str, uint32 data) {
if (choiceNo >= CONVERSATION_MAX_CHOICES) {
return;
}
_choices[choiceNo]._str = str;
_choices[choiceNo]._data = data;
markDirty();
}
void ConversationWidget::clearChoices() {
for (int i = 0; i < CONVERSATION_MAX_CHOICES; ++i) {
_choices[i]._str.clear();
_choices[i]._data = 0;
}
markDirty();
}
void ConversationWidget::draw(Graphics::ManagedSurface &surface) {
surface.blitFrom(_surface, Common::Point(_area.left, _area.top));
for (int i = 0; i < CONVERSATION_MAX_CHOICES; ++i) {
Common::String &str = _choices[i]._str;
if (str.empty()) {
continue;
}
// TODO: Active line should be WHITE.
_gui.getGame().getAssets().getSystemFont().drawString(&surface, str, CONVERSATION_LINES_X, CONVERSATION_LINES_Y + i * CONVERSATION_LINE_HEIGHT, _area.width(), LIGHTGRAY);
}
}
void ConversationWidget::handleEvent(const Common::Event &event) {
switch (event.type) {
case Common::EVENT_LBUTTONDOWN: {
const int16 x = event.mouse.x;
const int16 y = event.mouse.y;
if (_area.contains(x, y)) {
if (_callback) {
int choiceNo = (y - CONVERSATION_LINES_Y) / CONVERSATION_LINE_HEIGHT;
if (!_choices[choiceNo]._str.empty()) {
_callback->onChoiceClicked(this, choiceNo, _choices[choiceNo]._data);
}
}
}
break;
}
default:
break;
}
}
}

View File

@@ -0,0 +1,66 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef MUTATIONOFJB_CONVERSATIONWIDGET_H
#define MUTATIONOFJB_CONVERSATIONWIDGET_H
#include "mutationofjb/widgets/widget.h"
#include "graphics/surface.h"
namespace MutationOfJB {
class ConversationWidget;
class ConversationWidgetCallback {
public:
virtual ~ConversationWidgetCallback() {}
virtual void onChoiceClicked(ConversationWidget *, int choiceNo, uint32 data) = 0;
};
class ConversationWidget : public Widget {
public:
enum { CONVERSATION_MAX_CHOICES = 4 };
ConversationWidget(GuiScreen &gui, const Common::Rect &area, const Graphics::Surface &surface);
void setCallback(ConversationWidgetCallback *callback) {
_callback = callback;
}
void setChoice(int choiceNo, const Common::String &str, uint32 data = 0);
void clearChoices();
void handleEvent(const Common::Event &event) override;
protected:
void draw(Graphics::ManagedSurface &surface) override;
private:
Graphics::Surface _surface;
struct ChoiceInfo {
Common::String _str;
uint32 _data;
} _choices[CONVERSATION_MAX_CHOICES];
ConversationWidgetCallback *_callback;
};
}
#endif

View File

@@ -0,0 +1,182 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "mutationofjb/widgets/gamewidget.h"
#include "mutationofjb/game.h"
#include "mutationofjb/gamedata.h"
#include "mutationofjb/guiscreen.h"
#include "mutationofjb/mutationofjb.h"
#include "mutationofjb/room.h"
#include "common/events.h"
#include "graphics/screen.h"
namespace MutationOfJB {
GameWidget::GameWidget(GuiScreen &gui) :
Widget(gui, Common::Rect(GAME_NORMAL_AREA_WIDTH, GAME_NORMAL_AREA_HEIGHT)),
_currentMapObjectId(0),
_nextMapObjectId(0),
_callback(nullptr) {}
void GameWidget::handleEvent(const Common::Event &event) {
if (!_enabled)
return;
if (!_gui.getGame().isCurrentSceneMap()) {
handleNormalScene(event);
} else {
handleMapScene(event);
}
}
void GameWidget::clearState() {
_currentMapObjectId = _nextMapObjectId = 0;
}
void GameWidget::draw(Graphics::ManagedSurface &) {
Room &room = _gui.getGame().getRoom();
// Full redraw using background buffer.
if (_dirtyBits == DIRTY_ALL) {
room.redraw();
return;
}
// Full redraw without background buffer.
if (_dirtyBits & DIRTY_AFTER_SCENE_CHANGE) {
room.redraw(false); // Don't use background buffer.
return;
}
// Only selection changed.
if (_dirtyBits & DIRTY_MAP_SELECTION) {
if (_currentMapObjectId != _nextMapObjectId) {
if (_currentMapObjectId) {
room.drawObjectAnimation(_currentMapObjectId, 1);
}
if (_nextMapObjectId) {
room.drawObjectAnimation(_nextMapObjectId, 0);
}
_currentMapObjectId = _nextMapObjectId;
}
}
}
void GameWidget::handleNormalScene(const Common::Event &event) {
Game &game = _gui.getGame();
Scene *const scene = game.getGameData().getCurrentScene();
switch (event.type) {
case Common::EVENT_LBUTTONDOWN: {
const int16 x = event.mouse.x;
const int16 y = event.mouse.y;
if (!_area.contains(x, y))
break;
if (Door *const door = scene->findDoor(x, y)) {
if (_callback)
_callback->onGameDoorClicked(this, door);
} else if (Static *const stat = scene->findStatic(x, y)) {
if (_callback)
_callback->onGameStaticClicked(this, stat);
}
break;
}
case Common::EVENT_MOUSEMOVE: {
const int16 x = event.mouse.x;
const int16 y = event.mouse.y;
if (!_area.contains(x, y))
break;
bool entityHit = false;
if (Door *const door = scene->findDoor(x, y)) {
if (_callback)
_callback->onGameEntityHovered(this, door->_name);
entityHit = true;
} else if (Static *const stat = scene->findStatic(x, y)) {
if (_callback)
_callback->onGameEntityHovered(this, stat->_name);
entityHit = true;
}
if (_callback && !entityHit)
_callback->onGameEntityHovered(this, Common::String());
_gui.getGame().getEngine().setCursorState(entityHit ? MutationOfJBEngine::CURSOR_ACTIVE : MutationOfJBEngine::CURSOR_IDLE);
break;
}
default:
break;
}
}
void GameWidget::handleMapScene(const Common::Event &event) {
Game &game = _gui.getGame();
Scene *const scene = game.getGameData().getCurrentScene();
switch (event.type) {
case Common::EVENT_LBUTTONDOWN: {
const int16 x = event.mouse.x;
const int16 y = event.mouse.y;
int index = 0;
if (scene->findBitmap(x, y, &index)) {
Static *const stat = scene->getStatic(index);
if (stat && stat->_active == 1) {
game.startActionSection(ActionInfo::Walk, stat->_name);
}
}
break;
}
case Common::EVENT_MOUSEMOVE: {
const int16 x = event.mouse.x;
const int16 y = event.mouse.y;
_nextMapObjectId = 0;
int index = 0;
//bool found = false;
if (scene->findBitmap(x, y, &index)) {
Static *const stat = scene->getStatic(index);
if (stat && stat->_active == 1) {
Object *const object = scene->getObject(index);
if (object) {
_nextMapObjectId = index;
}
}
}
if (_currentMapObjectId != _nextMapObjectId)
markDirty(DIRTY_MAP_SELECTION);
_gui.getGame().getEngine().setCursorState(_nextMapObjectId ? MutationOfJBEngine::CURSOR_ACTIVE : MutationOfJBEngine::CURSOR_IDLE);
break;
}
default:
break;
}
}
}

View File

@@ -0,0 +1,96 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef MUTATIONOFJB_GAMEWIDGET_H
#define MUTATIONOFJB_GAMEWIDGET_H
#include "mutationofjb/widgets/widget.h"
namespace MutationOfJB {
class GameWidget;
struct Door;
struct Static;
class GameWidgetCallback {
public:
virtual ~GameWidgetCallback() {}
virtual void onGameDoorClicked(GameWidget *, Door *door) = 0;
virtual void onGameStaticClicked(GameWidget *, Static *stat) = 0;
virtual void onGameEntityHovered(GameWidget *, const Common::String &entity) = 0;
};
class GameWidget : public Widget {
public:
enum {
GAME_NORMAL_AREA_WIDTH = 320,
GAME_NORMAL_AREA_HEIGHT = 139,
GAME_FULL_AREA_WIDTH = 320,
GAME_FULL_AREA_HEIGHT = 200
};
enum DirtyFlags {
DIRTY_AFTER_SCENE_CHANGE = 1 << 1,
DIRTY_MAP_SELECTION = 1 << 2
};
GameWidget(GuiScreen &gui);
void setCallback(GameWidgetCallback *callback) {
_callback = callback;
}
void handleEvent(const Common::Event &) override;
void clearState();
protected:
void draw(Graphics::ManagedSurface &) override;
private:
/**
* Handling for normal (non-map) scenes.
*
* Statics and doors define mouse clickable areas.
* Statics are used to start actions.
* Doors are used to transition between scenes.
*
* @param event ScummVM event.
*/
void handleNormalScene(const Common::Event &event);
/**
* Special handling for map scenes.
*
* Bitmaps define mouse clickable areas.
* Statics are used to start actions.
* Objects are used for showing labels.
*
* @param event ScummVM event.
*/
void handleMapScene(const Common::Event &event);
uint8 _currentMapObjectId;
uint8 _nextMapObjectId;
GameWidgetCallback *_callback;
};
}
#endif

View File

@@ -0,0 +1,36 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "mutationofjb/widgets/imagewidget.h"
#include "graphics/managed_surface.h"
namespace MutationOfJB {
ImageWidget::ImageWidget(GuiScreen &gui, const Common::Rect &area, const Graphics::Surface &image) :
Widget(gui, area),
_image(image) {}
void ImageWidget::draw(Graphics::ManagedSurface &surface) {
surface.blitFrom(_image, Common::Point(_area.left, _area.top));
}
}

View File

@@ -0,0 +1,43 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef MUTATIONOFJB_IMAGEWIDGET_H
#define MUTATIONOFJB_IMAGEWIDGET_H
#include "mutationofjb/widgets/widget.h"
#include "graphics/surface.h"
namespace MutationOfJB {
class ImageWidget : public Widget {
public:
ImageWidget(GuiScreen &gui, const Common::Rect &area, const Graphics::Surface &image);
protected:
void draw(Graphics::ManagedSurface &surface) override;
private:
Graphics::Surface _image;
};
}
#endif

View File

@@ -0,0 +1,124 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "mutationofjb/widgets/inventorywidget.h"
#include "mutationofjb/game.h"
#include "mutationofjb/gamedata.h"
#include "mutationofjb/gamescreen.h"
#include "mutationofjb/inventory.h"
#include "common/str.h"
#include "common/rect.h"
#include "common/util.h"
#include "common/events.h"
#include "graphics/managed_surface.h"
namespace MutationOfJB {
enum {
INVENTORY_START_X = 88,
INVENTORY_START_Y = 149,
INVENTORY_ITEM_WIDTH = 34,
INVENTORY_ITEM_HEIGHT = 33,
INVENTORY_ITEMS_PER_LINE = 8,
INVENTORY_ITEMS_LINES = 5
};
InventoryWidget::InventoryWidget(GuiScreen &gui, const Common::Array<Graphics::Surface> &inventorySurfaces) :
Widget(gui, Common::Rect(INVENTORY_START_X, INVENTORY_START_Y, INVENTORY_START_X + Inventory::VISIBLE_ITEMS * INVENTORY_ITEM_WIDTH, INVENTORY_START_Y + INVENTORY_ITEM_HEIGHT)),
_surfaces(inventorySurfaces),
_callback(nullptr),
_hoveredItemPos(-1) {}
void InventoryWidget::drawInventoryItem(Graphics::ManagedSurface &surface, const Common::String &item, int pos) {
const int index = _gui.getGame().getAssets().getInventoryItemDefList().findItemIndex(item);
if (index == -1) {
return;
}
const int surfaceNo = index / (INVENTORY_ITEMS_LINES * INVENTORY_ITEMS_PER_LINE);
const int indexInSurface = index % (INVENTORY_ITEMS_LINES * INVENTORY_ITEMS_PER_LINE);
const int itemX = indexInSurface % INVENTORY_ITEMS_PER_LINE;
const int itemY = indexInSurface / INVENTORY_ITEMS_PER_LINE;
Common::Point destStartPos(INVENTORY_START_X + pos * INVENTORY_ITEM_WIDTH, INVENTORY_START_Y);
Common::Rect sourceRect(itemX * INVENTORY_ITEM_WIDTH, itemY * INVENTORY_ITEM_HEIGHT, (itemX + 1) * INVENTORY_ITEM_WIDTH, (itemY + 1) * INVENTORY_ITEM_HEIGHT);
surface.blitFrom(_surfaces[surfaceNo], sourceRect, destStartPos);
}
void InventoryWidget::draw(Graphics::ManagedSurface &surface) {
Inventory &inventory = _gui.getGame().getGameData().getInventory();
const Inventory::Items &items = inventory.getItems();
surface.fillRect(_area, 0x00);
for (Inventory::Items::size_type i = 0; i < MIN<Inventory::Items::size_type>(items.size(), Inventory::VISIBLE_ITEMS); ++i) {
drawInventoryItem(surface, items[i], i);
}
}
void InventoryWidget::handleEvent(const Common::Event &event) {
if (!_callback)
return;
Inventory &inventory = _gui.getGame().getGameData().getInventory();
const int numItems = inventory.getItems().size();
switch (event.type) {
case Common::EVENT_LBUTTONDOWN: {
const int16 x = event.mouse.x;
const int16 y = event.mouse.y;
if (_area.contains(x, y)) {
int itemPos = (x - INVENTORY_START_X) / INVENTORY_ITEM_WIDTH;
if (itemPos < numItems) {
_callback->onInventoryItemClicked(this, itemPos);
}
}
break;
}
case Common::EVENT_MOUSEMOVE: {
const int16 x = event.mouse.x;
const int16 y = event.mouse.y;
int newHoveredItemPos = -1;
if (_area.contains(x, y)) {
int itemPos = (x - INVENTORY_START_X) / INVENTORY_ITEM_WIDTH;
if (itemPos < numItems) {
newHoveredItemPos = itemPos;
if (_hoveredItemPos != newHoveredItemPos) {
_callback->onInventoryItemHovered(this, itemPos);
}
}
}
if (newHoveredItemPos == -1 && _hoveredItemPos != -1) {
_callback->onInventoryItemHovered(this, -1);
}
_hoveredItemPos = newHoveredItemPos;
break;
}
default:
break;
}
}
}

View File

@@ -0,0 +1,80 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef MUTATIONOFJB_INVENTORYWIDGET_H
#define MUTATIONOFJB_INVENTORYWIDGET_H
#include "mutationofjb/widgets/widget.h"
#include "common/array.h"
#include "graphics/surface.h"
namespace Common {
class String;
}
namespace MutationOfJB {
class InventoryWidget;
class InventoryWidgetCallback {
public:
virtual ~InventoryWidgetCallback() {}
/**
* Called when the user hovers an inventory item with the mouse or when stops hovering an item.
*
* @param widget Inventory widget.
* @param posInWidget Item position in the widget or -1 if none.
*/
virtual void onInventoryItemHovered(InventoryWidget *widget, int posInWidget) = 0;
/**
* Called when the user clicks on an inventory item.
*
* @param widget Inventory widget.
* @param posInWidget Item position in the widget.
*/
virtual void onInventoryItemClicked(InventoryWidget *widget, int posInWidget) = 0;
};
class InventoryWidget : public Widget {
public:
InventoryWidget(GuiScreen &gui, const Common::Array<Graphics::Surface> &inventorySurfaces);
void setCallback(InventoryWidgetCallback *callback) {
_callback = callback;
}
void handleEvent(const Common::Event &event) override;
protected:
void draw(Graphics::ManagedSurface &surface) override;
private:
void drawInventoryItem(Graphics::ManagedSurface &surface, const Common::String &item, int pos);
const Common::Array<Graphics::Surface> &_surfaces;
InventoryWidgetCallback *_callback;
int _hoveredItemPos;
};
}
#endif

View File

@@ -0,0 +1,63 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "mutationofjb/widgets/labelwidget.h"
#include "mutationofjb/assets.h"
#include "mutationofjb/game.h"
#include "mutationofjb/gamedata.h"
namespace MutationOfJB {
LabelWidget::LabelWidget(GuiScreen &gui, const Common::Rect &area) :
Widget(gui, area),
_backgroundColor(0x00) {}
uint8 LabelWidget::getBackgroundColor() const {
return _backgroundColor;
}
void LabelWidget::setBackgroundColor(uint8 color) {
if (_backgroundColor == color)
return;
_backgroundColor = color;
markDirty();
}
const Common::String &LabelWidget::getText() const {
return _text;
}
void LabelWidget::setText(const Common::String &text) {
if (_text == text)
return;
_text = text;
markDirty();
}
void LabelWidget::draw(Graphics::ManagedSurface &surface) {
surface.fillRect(_area, _backgroundColor);
_gui.getGame().getAssets().getSystemFont().drawString(&surface, _text, _area.left, _area.top, _area.width(), LIGHTGRAY, Graphics::kTextAlignCenter);
}
}

View File

@@ -0,0 +1,51 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef MUTATIONOJFB_LABELWIDGET_H
#define MUTATIONOJFB_LABELWIDGET_H
#include "mutationofjb/widgets/widget.h"
#include "common/str.h"
namespace MutationOfJB {
class LabelWidget : public Widget {
public:
LabelWidget(GuiScreen &gui, const Common::Rect &area);
uint8 getBackgroundColor() const;
void setBackgroundColor(uint8 color);
const Common::String &getText() const;
void setText(const Common::String &text);
protected:
void draw(Graphics::ManagedSurface &) override;
private:
uint8 _backgroundColor;
Common::String _text;
};
}
#endif

View File

@@ -0,0 +1,78 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "mutationofjb/widgets/widget.h"
namespace MutationOfJB {
int Widget::getId() const {
return _id;
}
void Widget::setId(int id) {
_id = id;
}
bool Widget::isVisible() const {
return _visible;
}
void Widget::setVisible(bool visible) {
if (!_visible && visible) {
markDirty();
}
_visible = visible;
}
bool Widget::isEnabled() const {
return _enabled;
}
void Widget::setEnabled(bool enabled) {
_enabled = enabled;
}
Common::Rect Widget::getArea() const {
return _area;
}
void Widget::setArea(const Common::Rect &area) {
_area = area;
}
void Widget::markDirty(uint32 dirtyBits) {
_dirtyBits = dirtyBits;
}
bool Widget::isDirty() const {
return _dirtyBits != DIRTY_NONE;
}
void Widget::update(Graphics::ManagedSurface &surface) {
if (isDirty()) {
if (_visible) {
draw(surface);
}
_dirtyBits = DIRTY_NONE;
}
}
}

View File

@@ -0,0 +1,80 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef MUTATIONOFJB_WIDGET_H
#define MUTATIONOFJB_WIDGET_H
#include "common/scummsys.h"
#include "common/rect.h"
namespace Common {
struct Event;
}
namespace Graphics {
class ManagedSurface;
}
namespace MutationOfJB {
class GuiScreen;
class Widget {
public:
enum : uint {
DIRTY_NONE = 0,
DIRTY_ALL = 0xFFFFFFFF
};
Widget(GuiScreen &gui, const Common::Rect &area) : _gui(gui), _area(area), _id(0), _visible(true), _enabled(true), _dirtyBits(DIRTY_NONE) {}
virtual ~Widget() {}
int getId() const;
void setId(int id);
bool isVisible() const;
void setVisible(bool visible);
bool isEnabled() const;
void setEnabled(bool enabled);
Common::Rect getArea() const;
void setArea(const Common::Rect &area);
bool isDirty() const;
void markDirty(uint32 dirtyBits = DIRTY_ALL);
void update(Graphics::ManagedSurface &);
virtual void handleEvent(const Common::Event &) {}
protected:
virtual void draw(Graphics::ManagedSurface &) = 0;
GuiScreen &_gui;
Common::Rect _area;
int _id;
bool _visible;
bool _enabled;
uint32 _dirtyBits;
};
}
#endif