Initial commit
This commit is contained in:
76
engines/crab/ui/AlphaImage.cpp
Normal file
76
engines/crab/ui/AlphaImage.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/crab.h"
|
||||
#include "crab/image/ImageManager.h"
|
||||
#include "crab/ui/AlphaImage.h"
|
||||
#include "crab/text/TextManager.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::image;
|
||||
|
||||
void AlphaImage::load(rapidxml::xml_node<char> *node, const bool &echo) {
|
||||
_pos.load(node, echo);
|
||||
loadImgKey(_img, "img", node, echo);
|
||||
|
||||
loadNum(alpha._min, "min", node);
|
||||
loadNum(alpha._max, "max", node);
|
||||
loadNum(alpha._change, "inc", node);
|
||||
|
||||
alpha._cur = alpha._min + g_engine->getRandomNumber(alpha._max - alpha._min - 1);
|
||||
}
|
||||
|
||||
void AlphaImage::internalEvents() {
|
||||
if (alpha._inc) {
|
||||
alpha._cur += alpha._change;
|
||||
if (alpha._cur >= alpha._max) {
|
||||
alpha._cur = alpha._max;
|
||||
alpha._inc = false;
|
||||
}
|
||||
} else {
|
||||
alpha._cur -= alpha._change;
|
||||
if (alpha._cur <= alpha._min) {
|
||||
alpha._cur = alpha._min;
|
||||
alpha._inc = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_engine->_imageManager->validTexture(_img))
|
||||
g_engine->_imageManager->getTexture(_img).alpha(alpha._cur);
|
||||
}
|
||||
|
||||
void AlphaImage::draw(const int &xOffset, const int &yOffset) {
|
||||
if (g_engine->_imageManager->validTexture(_img))
|
||||
g_engine->_imageManager->getTexture(_img).draw(_pos.x + xOffset, _pos.y + yOffset);
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
95
engines/crab/ui/AlphaImage.h
Normal file
95
engines/crab/ui/AlphaImage.h
Normal 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_ALPHAIMAGE_H
|
||||
#define CRAB_ALPHAIMAGE_H
|
||||
|
||||
#include "crab/image/ImageManager.h"
|
||||
#include "crab/ui/element.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class AlphaImage {
|
||||
// The image used - we don't use the image manager
|
||||
// because we don't change the alpha for those images
|
||||
ImageKey _img;
|
||||
|
||||
// The information for drawing the image
|
||||
Element _pos;
|
||||
|
||||
// The information related to alpha modulation of the image
|
||||
struct AlphaVal {
|
||||
int _cur, _min, _max;
|
||||
|
||||
// Are we increasing or decreasing the alpha
|
||||
bool _inc;
|
||||
|
||||
// By how much do we change the alpha every update
|
||||
int _change;
|
||||
|
||||
AlphaVal() {
|
||||
_cur = 255;
|
||||
_min = 255;
|
||||
_max = 255;
|
||||
_inc = true;
|
||||
_change = 0;
|
||||
}
|
||||
} alpha;
|
||||
|
||||
public:
|
||||
AlphaImage() {
|
||||
_img = 0;
|
||||
}
|
||||
|
||||
AlphaImage(rapidxml::xml_node<char> *node) : AlphaImage() {
|
||||
load(node);
|
||||
}
|
||||
|
||||
~AlphaImage() {}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node, const bool &echo = true);
|
||||
|
||||
void draw(const int &xOffset = 0, const int &yOffset = 0);
|
||||
|
||||
// This is used to vary the alpha
|
||||
void internalEvents();
|
||||
|
||||
void setUI() {
|
||||
_pos.setUI();
|
||||
}
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_ALPHAIMAGE_H
|
||||
62
engines/crab/ui/Caption.cpp
Normal file
62
engines/crab/ui/Caption.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "crab/ui/Caption.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::text;
|
||||
using namespace pyrodactyl::ui;
|
||||
|
||||
void Caption::init(const Caption &c, const int &xOffset, const int &yOffset) {
|
||||
*this = c;
|
||||
x += xOffset;
|
||||
y += yOffset;
|
||||
}
|
||||
|
||||
void Caption::load(rapidxml::xml_node<char> *node, Rect *parent) {
|
||||
if (TextData::load(node, parent, false)) {
|
||||
loadStr(_text, "text", node);
|
||||
loadNum(_colS, "color_s", node, false);
|
||||
_enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Caption::draw(bool selected, const int &xOffset, const int &yOffset) {
|
||||
if (_enabled) {
|
||||
if (selected)
|
||||
TextData::drawColor(_text, _colS, xOffset, yOffset);
|
||||
else
|
||||
TextData::draw(_text, xOffset, yOffset);
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
64
engines/crab/ui/Caption.h
Normal file
64
engines/crab/ui/Caption.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_CAPTION_H
|
||||
#define CRAB_CAPTION_H
|
||||
|
||||
#include "crab/ui/TextData.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
// Caption for buttons
|
||||
class Caption : public TextData {
|
||||
public:
|
||||
bool _enabled;
|
||||
int _colS;
|
||||
|
||||
Common::String _text;
|
||||
|
||||
Caption() {
|
||||
_colS = 0;
|
||||
_enabled = false;
|
||||
}
|
||||
~Caption() {}
|
||||
|
||||
void init(const Caption &c, const int &xOffset = 0, const int &yOffset = 0);
|
||||
|
||||
void load(rapidxml::xml_node<char> *node, Rect *parent = nullptr);
|
||||
void draw(bool selected, const int &xOffset = 0, const int &yOffset = 0);
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_CAPTION_H
|
||||
70
engines/crab/ui/ChapterIntro.cpp
Normal file
70
engines/crab/ui/ChapterIntro.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/animation/sprite.h"
|
||||
#include "crab/ui/ChapterIntro.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::image;
|
||||
|
||||
void ChapterIntro::load(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid("dialog", node))
|
||||
_dialog.load(node->first_node("dialog"));
|
||||
|
||||
if (nodeValid("image", node))
|
||||
_pos.load(node->first_node("image"));
|
||||
|
||||
if (nodeValid("trait", node))
|
||||
_traits.load(node->first_node("trait"));
|
||||
}
|
||||
|
||||
bool ChapterIntro::handleEvents(Common::Event &event) {
|
||||
if (_traits.handleEvents(event) != BUAC_IGNORE)
|
||||
_showTraits = true;
|
||||
|
||||
return _dialog.handleEvents(event);
|
||||
}
|
||||
|
||||
void ChapterIntro::draw(pyrodactyl::event::Info &info, Common::String &text,
|
||||
pyrodactyl::anim::Sprite *curSp, const pyrodactyl::people::PersonState &state) {
|
||||
_dialog.draw(false);
|
||||
_dialog.draw(info, text);
|
||||
|
||||
_traits.draw();
|
||||
|
||||
if (curSp != nullptr) {
|
||||
Rect clip = curSp->dialogClip(state);
|
||||
g_engine->_imageManager->draw(_pos.x, _pos.y, curSp->img(), &clip);
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
76
engines/crab/ui/ChapterIntro.h
Normal file
76
engines/crab/ui/ChapterIntro.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_CHAPTERINTRO_H
|
||||
#define CRAB_CHAPTERINTRO_H
|
||||
|
||||
#include "crab/ui/button.h"
|
||||
#include "crab/ui/dialogbox.h"
|
||||
#include "crab/TTSHandler.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace anim {
|
||||
class Sprite;
|
||||
} // End of namespace anim
|
||||
|
||||
namespace ui {
|
||||
class ChapterIntro : public TTSHandler {
|
||||
// This contains the background image info and start button
|
||||
GameDialogBox _dialog;
|
||||
|
||||
// This is where the sprite is drawn
|
||||
Element _pos;
|
||||
|
||||
// The traits button
|
||||
Button _traits;
|
||||
|
||||
public:
|
||||
// Should we show the traits screen
|
||||
bool _showTraits;
|
||||
|
||||
ChapterIntro() {
|
||||
_showTraits = false;
|
||||
}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
|
||||
bool handleEvents(Common::Event &event);
|
||||
|
||||
void draw(pyrodactyl::event::Info &info, Common::String &text,
|
||||
pyrodactyl::anim::Sprite *curSp, const pyrodactyl::people::PersonState &state);
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_CHAPTERINTRO_H
|
||||
56
engines/crab/ui/ClipButton.cpp
Normal file
56
engines/crab/ui/ClipButton.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/crab.h"
|
||||
#include "crab/ui/ClipButton.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::image;
|
||||
|
||||
void ClipButton::load(rapidxml::xml_node<char> *node, const bool &echo) {
|
||||
Button::load(node, echo);
|
||||
|
||||
if (nodeValid("clip", node, false))
|
||||
_clip.load(node->first_node("clip"));
|
||||
else {
|
||||
_clip.x = 0;
|
||||
_clip.y = 0;
|
||||
_clip.w = g_engine->_imageManager->getTexture(_img._normal).w();
|
||||
_clip.h = g_engine->_imageManager->getTexture(_img._normal).h();
|
||||
}
|
||||
}
|
||||
|
||||
void ClipButton::draw(const int &xOffset, const int &yOffset) {
|
||||
Button::draw(xOffset, yOffset, &_clip);
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
57
engines/crab/ui/ClipButton.h
Normal file
57
engines/crab/ui/ClipButton.h
Normal 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_CLIPBUTTON_H
|
||||
#define CRAB_CLIPBUTTON_H
|
||||
|
||||
#include "crab/ui/button.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
// Sometimes we need to display a clipped version of the button image
|
||||
class ClipButton : public Button {
|
||||
public:
|
||||
// The clip rectangle
|
||||
Rect _clip;
|
||||
|
||||
ClipButton() {}
|
||||
~ClipButton() {}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node, const bool &echo = true);
|
||||
void draw(const int &xOffset = 0, const int &yOffset = 0);
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_CLIPBUTTON_H
|
||||
180
engines/crab/ui/CreditScreen.cpp
Normal file
180
engines/crab/ui/CreditScreen.cpp
Normal file
@@ -0,0 +1,180 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/ScreenSettings.h"
|
||||
#include "crab/XMLDoc.h"
|
||||
#include "crab/ui/CreditScreen.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::text;
|
||||
|
||||
void CreditScreen::reset() {
|
||||
_start.x = g_engine->_screenSettings->_cur.w / 2 - 150;
|
||||
_start.y = g_engine->_screenSettings->_cur.h + 20;
|
||||
_cur.x = _start.x;
|
||||
_speed._cur = _speed._slow;
|
||||
}
|
||||
|
||||
void CreditScreen::load(const Common::Path &filename) {
|
||||
XMLDoc conf(filename);
|
||||
if (conf.ready()) {
|
||||
rapidxml::xml_node<char> *node = conf.doc()->first_node("credits");
|
||||
|
||||
if (nodeValid("bg", node))
|
||||
_bg.load(node->first_node("bg"));
|
||||
|
||||
if (nodeValid("h", node))
|
||||
_heading.load(node->first_node("h"));
|
||||
|
||||
if (nodeValid("p", node))
|
||||
_paragraph.load(node->first_node("p"));
|
||||
|
||||
if (nodeValid("logo", node))
|
||||
_logo.load(node->first_node("logo"));
|
||||
|
||||
if (nodeValid("website", node))
|
||||
_website.load(node->first_node("website"), false);
|
||||
|
||||
if (nodeValid("twitter", node))
|
||||
_twitter.load(node->first_node("twitter"), false);
|
||||
|
||||
if (nodeValid("twitter", node))
|
||||
_back.load(node->first_node("back"));
|
||||
|
||||
if (nodeValid("fast", node)) {
|
||||
rapidxml::xml_node<char> *fnode = node->first_node("fast");
|
||||
_fast.load(fnode);
|
||||
loadNum(_speed._fast, "val", fnode);
|
||||
}
|
||||
|
||||
if (nodeValid("slow", node)) {
|
||||
rapidxml::xml_node<char> *snode = node->first_node("slow");
|
||||
_slow.load(snode);
|
||||
loadNum(_speed._slow, "val", snode);
|
||||
}
|
||||
|
||||
if (nodeValid("reverse", node)) {
|
||||
rapidxml::xml_node<char> *rnode = node->first_node("reverse");
|
||||
_reverse.load(rnode);
|
||||
loadNum(_speed._reverse, "val", rnode);
|
||||
}
|
||||
|
||||
_speed._cur = _speed._slow;
|
||||
|
||||
if (nodeValid("pause", node))
|
||||
_pause.load(node->first_node("pause"));
|
||||
|
||||
if (nodeValid("text", node)) {
|
||||
rapidxml::xml_node<char> *tnode = node->first_node("text");
|
||||
for (rapidxml::xml_node<char> *n = tnode->first_node(); n != nullptr; n = n->next_sibling()) {
|
||||
CreditText t;
|
||||
t._text = n->value();
|
||||
t._heading = (n->name()[0] == 'h');
|
||||
_list.push_back(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CreditScreen::handleEvents(Common::Event &event) {
|
||||
if (_slow.handleEvents(event) == BUAC_LCLICK)
|
||||
_speed._cur = _speed._slow;
|
||||
else if (_fast.handleEvents(event) == BUAC_LCLICK)
|
||||
_speed._cur = _speed._fast;
|
||||
else if (_pause.handleEvents(event) == BUAC_LCLICK)
|
||||
_speed._cur = 0.0f;
|
||||
else if (_reverse.handleEvents(event) == BUAC_LCLICK)
|
||||
_speed._cur = _speed._reverse;
|
||||
|
||||
if (_website.handleEvents(event) != BUAC_IGNORE)
|
||||
g_system->openUrl("http://pyrodactyl.com");
|
||||
else if (_twitter.handleEvents(event) != BUAC_IGNORE)
|
||||
g_system->openUrl("https://www.twitter.com/pyrodactylgames");
|
||||
|
||||
return (_back.handleEvents(event) == BUAC_LCLICK);
|
||||
}
|
||||
|
||||
void CreditScreen::draw() {
|
||||
_bg.draw();
|
||||
|
||||
_slow.draw();
|
||||
_fast.draw();
|
||||
_pause.draw();
|
||||
_reverse.draw();
|
||||
|
||||
_logo.draw();
|
||||
_twitter.draw();
|
||||
_website.draw();
|
||||
|
||||
_back.draw();
|
||||
|
||||
_cur.y = _start.y;
|
||||
|
||||
for (const auto &i : _list) {
|
||||
_cur.y += _paragraph._inc;
|
||||
|
||||
if (i._heading) {
|
||||
_cur.y += _heading._inc;
|
||||
if (_cur.y > -30 && _cur.y < g_engine->_screenSettings->_cur.h + 40) // Only draw text if it is actually visible on screen
|
||||
g_engine->_textManager->draw(_cur.x, _cur.y, i._text, _heading._color, _heading._font, _heading._align);
|
||||
} else if (_cur.y > -30 && _cur.y < g_engine->_screenSettings->_cur.h + 40)
|
||||
g_engine->_textManager->draw(_cur.x, _cur.y, i._text, _paragraph._color, _paragraph._font, _paragraph._align);
|
||||
|
||||
// If our cur value has reached below the screen, simply exit the loop as we won't draw anything else
|
||||
if (_cur.y > g_engine->_screenSettings->_cur.h + 40)
|
||||
break;
|
||||
}
|
||||
|
||||
_start.y -= _speed._cur;
|
||||
|
||||
// Sanity check so that we don't scroll too high or low
|
||||
if (_start.y > g_engine->_screenSettings->_cur.h + 40)
|
||||
_start.y = g_engine->_screenSettings->_cur.h + 40;
|
||||
else if (_start.y < INT_MIN + 10)
|
||||
_start.y = INT_MIN + 10;
|
||||
}
|
||||
|
||||
void CreditScreen::setUI() {
|
||||
_bg.setUI();
|
||||
_back.setUI();
|
||||
|
||||
_slow.setUI();
|
||||
_fast.setUI();
|
||||
_pause.setUI();
|
||||
_reverse.setUI();
|
||||
|
||||
_logo.setUI();
|
||||
_twitter.setUI();
|
||||
_website.setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
128
engines/crab/ui/CreditScreen.h
Normal file
128
engines/crab/ui/CreditScreen.h
Normal file
@@ -0,0 +1,128 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_CREDITSCREEN_H
|
||||
#define CRAB_CREDITSCREEN_H
|
||||
|
||||
#include "crab/ui/button.h"
|
||||
#include "crab/ui/ImageData.h"
|
||||
#include "crab/ui/TextData.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class CreditScreen {
|
||||
// Text and formatting information
|
||||
struct CreditText {
|
||||
// Title of the section (stuff like programmer, designer etc)
|
||||
Common::String _text;
|
||||
|
||||
// The style it should be drawn in
|
||||
bool _heading;
|
||||
};
|
||||
|
||||
// The background image and company logo
|
||||
pyrodactyl::ui::ImageData _bg, _logo;
|
||||
|
||||
// The names displayed in the credits
|
||||
Common::Array<CreditText> _list;
|
||||
|
||||
// The starting position
|
||||
Vector2i _start;
|
||||
|
||||
// The current position
|
||||
Vector2D<long> _cur;
|
||||
|
||||
// Text parameters
|
||||
struct TextParam {
|
||||
int _inc, _color;
|
||||
FontKey _font;
|
||||
Align _align;
|
||||
|
||||
TextParam() {
|
||||
_inc = 30;
|
||||
_color = 0;
|
||||
_font = 1;
|
||||
_align = ALIGN_CENTER;
|
||||
}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node) {
|
||||
loadNum(_inc, "inc", node);
|
||||
loadNum(_color, "color", node);
|
||||
LoadFontKey(_font, "font", node);
|
||||
loadAlign(_align, node);
|
||||
}
|
||||
} _heading, _paragraph;
|
||||
|
||||
// All speed levels at which credits can scroll through
|
||||
struct ScrollSpeed {
|
||||
// The current speed
|
||||
float _cur;
|
||||
|
||||
// Various levels
|
||||
float _slow, _fast, _reverse;
|
||||
|
||||
ScrollSpeed() {
|
||||
_slow = 1.0f;
|
||||
_fast = 4.0f;
|
||||
_reverse = -2.0f;
|
||||
_cur = _slow;
|
||||
}
|
||||
} _speed;
|
||||
|
||||
// Speed controls for credits
|
||||
Button _fast, _slow, _reverse, _pause;
|
||||
|
||||
// The back button, website and twitter buttons
|
||||
Button _back, _website, _twitter;
|
||||
|
||||
public:
|
||||
CreditScreen() {
|
||||
reset();
|
||||
}
|
||||
|
||||
~CreditScreen() {}
|
||||
|
||||
void load(const Common::Path &filename);
|
||||
void reset();
|
||||
|
||||
bool handleEvents(Common::Event &event);
|
||||
|
||||
void draw();
|
||||
|
||||
void setUI();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_CREDITSCREEN_H
|
||||
127
engines/crab/ui/DevConsole.cpp
Normal file
127
engines/crab/ui/DevConsole.cpp
Normal file
@@ -0,0 +1,127 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/XMLDoc.h"
|
||||
#include "crab/ui/DevConsole.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
|
||||
void DebugConsole::load(const Common::Path &filename) {
|
||||
XMLDoc conf(filename);
|
||||
if (conf.ready()) {
|
||||
rapidxml::xml_node<char> *node = conf.doc()->first_node("debug");
|
||||
if (nodeValid(node)) {
|
||||
if (nodeValid("menu", node))
|
||||
_menu.load(node->first_node("menu"));
|
||||
|
||||
if (nodeValid("variable", node)) {
|
||||
rapidxml::xml_node<char> *varnode = node->first_node("variable");
|
||||
|
||||
if (nodeValid("bg", varnode))
|
||||
_bg.load(varnode->first_node("bg"));
|
||||
|
||||
if (nodeValid("check", varnode))
|
||||
_check.load(varnode->first_node("check"));
|
||||
|
||||
if (nodeValid("back", varnode))
|
||||
_back.load(varnode->first_node("back"));
|
||||
|
||||
if (nodeValid("value", varnode))
|
||||
_value.load(varnode->first_node("value"));
|
||||
|
||||
if (nodeValid("text", varnode))
|
||||
_textField.load(varnode->first_node("text"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DebugConsole::draw(pyrodactyl::event::Info &info) {
|
||||
switch (_state) {
|
||||
case STATE_NORMAL:
|
||||
_menu.draw();
|
||||
break;
|
||||
case STATE_VAR:
|
||||
_bg.draw();
|
||||
_check.draw();
|
||||
_back.draw();
|
||||
_textField.draw();
|
||||
|
||||
{
|
||||
int temp = 0;
|
||||
if (info.varGet(_varName, temp))
|
||||
_value.draw(numberToString(temp));
|
||||
else
|
||||
_value.draw("Does not exist.");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DebugConsole::handleEvents(const Common::Event &event) {
|
||||
switch (_state) {
|
||||
case STATE_NORMAL: {
|
||||
int choice = _menu.handleEvents(event);
|
||||
if (choice == 0)
|
||||
_state = STATE_VAR;
|
||||
} break;
|
||||
case STATE_VAR:
|
||||
_textField.handleEvents(event);
|
||||
|
||||
if (_check.handleEvents(event))
|
||||
_varName = _textField._text;
|
||||
|
||||
// Control+V pastes clipboard text into text field
|
||||
if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_v) {
|
||||
if (g_system->hasTextInClipboard()) {
|
||||
Common::U32String str = g_system->getTextFromClipboard();
|
||||
_textField._text = convertFromU32String(str).c_str();
|
||||
}
|
||||
}
|
||||
|
||||
if (_back.handleEvents(event) != BUAC_IGNORE) {
|
||||
_state = STATE_NORMAL;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DebugConsole::internalEvents() {
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
86
engines/crab/ui/DevConsole.h
Normal file
86
engines/crab/ui/DevConsole.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_DEVCONSOLE_H
|
||||
#define CRAB_DEVCONSOLE_H
|
||||
|
||||
#include "crab/event/GameEventInfo.h"
|
||||
#include "crab/ui/ImageData.h"
|
||||
#include "crab/ui/menu.h"
|
||||
#include "crab/ui/textarea.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class DebugConsole {
|
||||
// The state of the menu
|
||||
enum {
|
||||
STATE_NORMAL,
|
||||
STATE_VAR
|
||||
} _state;
|
||||
|
||||
// The overarching menu that is the starting point for all functions
|
||||
ButtonMenu _menu;
|
||||
|
||||
// The dialog box UI - used to check value of a variable
|
||||
ImageData _bg;
|
||||
Button _check, _back;
|
||||
TextData _value;
|
||||
TextArea _textField;
|
||||
|
||||
// The variable name we're tracking
|
||||
Common::String _varName;
|
||||
|
||||
public:
|
||||
DebugConsole() {
|
||||
_state = STATE_NORMAL;
|
||||
}
|
||||
|
||||
~DebugConsole() {}
|
||||
|
||||
// Only restrict input when we're in variable state
|
||||
bool restrictInput() {
|
||||
return (_state == STATE_VAR || _menu.hoverIndex() != -1);
|
||||
}
|
||||
|
||||
void handleEvents(const Common::Event &event);
|
||||
|
||||
void load(const Common::Path &filename);
|
||||
void draw(pyrodactyl::event::Info &info);
|
||||
|
||||
void internalEvents();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_DEVCONSOLE_H
|
||||
94
engines/crab/ui/FileData.cpp
Normal file
94
engines/crab/ui/FileData.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/savefile.h"
|
||||
#include "crab/crab.h"
|
||||
#include "crab/loaders.h"
|
||||
#include "crab/XMLDoc.h"
|
||||
#include "crab/ui/FileData.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
|
||||
SaveFileData::SaveFileData(const Common::String &file) {
|
||||
_path = file;
|
||||
_blank = true;
|
||||
|
||||
// Extract String between _ and . For eg., CRAB_Autosave 1.unr -> Autosave 1
|
||||
// 4 => .unr
|
||||
size_t pos = file.findFirstOf('_');
|
||||
_name = file.substr(pos + 1, file.size() - (pos + 1) - 4);
|
||||
|
||||
if (g_engine->getSaveFileManager()->exists(file)) {
|
||||
Common::InSaveFile *savefile = g_engine->getSaveFileManager()->openForLoading(file);
|
||||
|
||||
uint64 len = savefile->size();
|
||||
uint8 *data = new uint8[len + 1];
|
||||
data[len] = '\0';
|
||||
|
||||
savefile->read(data, len);
|
||||
|
||||
XMLDoc conf(data);
|
||||
if (conf.ready()) {
|
||||
rapidxml::xml_node<char> *node = conf.doc()->first_node("save");
|
||||
if (nodeValid(node)) {
|
||||
loadStr(_diff, "diff", node);
|
||||
loadStr(_locId, "loc_id", node);
|
||||
loadStr(_locName, "loc_name", node);
|
||||
loadStr(_charName, "char_name", node);
|
||||
loadStr(_time, "time", node);
|
||||
loadPath(_preview, "preview", node);
|
||||
_blank = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ModFileData::ModFileData(const Common::String &file) {
|
||||
|
||||
#if 0
|
||||
if (boost::filesystem::exists(filepath)) {
|
||||
XMLDoc conf(filepath.string());
|
||||
if (conf.ready()) {
|
||||
rapidxml::xml_node<char> *node = conf.doc()->first_node("config");
|
||||
if (nodeValid(node)) {
|
||||
loadStr(author, "author", node);
|
||||
loadStr(version, "version", node);
|
||||
loadStr(info, "info", node);
|
||||
loadStr(website, "website", node);
|
||||
loadStr(preview, "preview", node);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
92
engines/crab/ui/FileData.h
Normal file
92
engines/crab/ui/FileData.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_FILEDATA_H
|
||||
#define CRAB_FILEDATA_H
|
||||
|
||||
#include "common/str.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class FileData {
|
||||
public:
|
||||
Common::String _name, _path, _lastModified;
|
||||
};
|
||||
|
||||
class SaveFileData : public FileData {
|
||||
public:
|
||||
Common::String _locId, _locName, _charName, _diff, _time;
|
||||
Common::Path _preview;
|
||||
|
||||
// This is to account for the first save slot, called "New Save", which doesn't actually have a file
|
||||
bool _blank;
|
||||
|
||||
SaveFileData(const Common::String &filepath);
|
||||
SaveFileData(const bool empty);
|
||||
};
|
||||
|
||||
class ModFileData : public FileData {
|
||||
public:
|
||||
Common::String _author, _version, _info, _website;
|
||||
Common::Path _preview;
|
||||
ModFileData(const Common::String &filepath);
|
||||
};
|
||||
|
||||
// The types of data shown about the save file
|
||||
enum {
|
||||
DATA_SAVENAME,
|
||||
DATA_LASTMODIFIED,
|
||||
DATA_BUTTON_TOTAL
|
||||
};
|
||||
|
||||
// Both of these are capped at DATA_HOVER_TOTAL
|
||||
enum {
|
||||
DATA_LOCNAME,
|
||||
DATA_DIFFICULTY,
|
||||
DATA_TIMEPLAYED,
|
||||
DATA_PLAYERNAME
|
||||
};
|
||||
|
||||
enum {
|
||||
DATA_AUTHOR,
|
||||
DATA_VERSION,
|
||||
DATA_INFO,
|
||||
DATA_WEBSITE
|
||||
};
|
||||
|
||||
const int DATA_HOVER_TOTAL = 4;
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_FILEDATA_H
|
||||
256
engines/crab/ui/FileMenu.h
Normal file
256
engines/crab/ui/FileMenu.h
Normal file
@@ -0,0 +1,256 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_FILEMENU_H
|
||||
#define CRAB_FILEMENU_H
|
||||
|
||||
#include "common/savefile.h"
|
||||
#include "crab/crab.h"
|
||||
#include "crab/ui/FileData.h"
|
||||
#include "crab/ui/ImageData.h"
|
||||
#include "crab/ui/PageMenu.h"
|
||||
#include "crab/ui/TextData.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
// Used for menus that are responsible for reading multiple files from disk
|
||||
template<typename FileType>
|
||||
class FileMenu {
|
||||
protected:
|
||||
// The background of the menu
|
||||
ImageData _bg;
|
||||
|
||||
// The collection of buttons
|
||||
PageButtonMenu _menu;
|
||||
|
||||
// The final filename that is selected
|
||||
Common::String _selected;
|
||||
|
||||
// The extension and directory used by this menu
|
||||
Common::String _extension;
|
||||
Common::Path _directory;
|
||||
|
||||
// The save information for each slot
|
||||
Common::Array<FileType> _slotInfo;
|
||||
TextData tdB[DATA_BUTTON_TOTAL];
|
||||
|
||||
// The titles for loc_name, difficulty, time_played and player_name
|
||||
HoverInfo hov[DATA_HOVER_TOTAL];
|
||||
TextData tdH[DATA_HOVER_TOTAL];
|
||||
|
||||
// The preview picture details
|
||||
struct {
|
||||
// We load only the current preview image instead of all of them
|
||||
pyrodactyl::image::Image _preview;
|
||||
|
||||
// Fallback path if there is no preview image or if we fail to load it
|
||||
Common::Path _noPreviewPath;
|
||||
|
||||
// Position of image
|
||||
Element _pos;
|
||||
|
||||
// Is the image loaded
|
||||
bool _loaded;
|
||||
} _img;
|
||||
|
||||
// Are we hovering over a button right now?
|
||||
bool _hover;
|
||||
|
||||
// The previously hover button
|
||||
int _prevHover;
|
||||
|
||||
public:
|
||||
FileMenu() {
|
||||
_img._loaded = false;
|
||||
_hover = false;
|
||||
_prevHover = -1;
|
||||
}
|
||||
|
||||
~FileMenu() {
|
||||
if (_img._loaded)
|
||||
_img._preview.deleteImage();
|
||||
}
|
||||
void reset() {
|
||||
if (_img._loaded)
|
||||
_img._preview.deleteImage();
|
||||
_img._loaded = false;
|
||||
_hover = false;
|
||||
}
|
||||
|
||||
Common::String selectedPath() {
|
||||
return _selected;
|
||||
}
|
||||
|
||||
void selectedPath(const Common::String &val) {
|
||||
_selected = val;
|
||||
}
|
||||
|
||||
void scanDir() {
|
||||
Common::String res = "CRAB_*";
|
||||
res += g_engine->_filePath->_saveExt;
|
||||
Common::StringArray saves = g_engine->getSaveFileManager()->listSavefiles(res);
|
||||
|
||||
_slotInfo.clear();
|
||||
_menu.clear();
|
||||
|
||||
uint countSlot = 0, countMenu = 0;
|
||||
for (const Common::String& save : saves) {
|
||||
_slotInfo.push_back(FileType(save));
|
||||
_menu.add(countSlot, countMenu);
|
||||
}
|
||||
|
||||
_menu.assignPaths();
|
||||
}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid("bg", node))
|
||||
_bg.load(node->first_node("bg"));
|
||||
|
||||
if (nodeValid("menu", node))
|
||||
_menu.load(node->first_node("menu"));
|
||||
|
||||
if (nodeValid("preview", node)) {
|
||||
auto prnode = node->first_node("preview");
|
||||
_img._pos.load(prnode);
|
||||
loadPath(_img._noPreviewPath, "path", prnode);
|
||||
}
|
||||
|
||||
if (nodeValid("offset", node)) {
|
||||
rapidxml::xml_node<char> *offnode = node->first_node("offset");
|
||||
|
||||
// Stuff displayed on the slot button
|
||||
tdB[DATA_SAVENAME].load(offnode->first_node("save_name"));
|
||||
tdB[DATA_LASTMODIFIED].load(offnode->first_node("last_modified"));
|
||||
|
||||
// Stuff displayed when you hover over a slot button
|
||||
tdH[DATA_LOCNAME].load(offnode->first_node("loc_name"));
|
||||
tdH[DATA_DIFFICULTY].load(offnode->first_node("difficulty"));
|
||||
tdH[DATA_TIMEPLAYED].load(offnode->first_node("time_played"));
|
||||
tdH[DATA_PLAYERNAME].load(offnode->first_node("player_name"));
|
||||
|
||||
// Titles for the stuff displayed when you hover over a slot button
|
||||
hov[DATA_LOCNAME].load(offnode->first_node("loc_name_title"));
|
||||
hov[DATA_DIFFICULTY].load(offnode->first_node("difficulty_title"));
|
||||
hov[DATA_TIMEPLAYED].load(offnode->first_node("time_played_title"));
|
||||
hov[DATA_PLAYERNAME].load(offnode->first_node("player_name_title"));
|
||||
}
|
||||
|
||||
_extension = g_engine->_filePath->_saveExt;
|
||||
_directory = g_engine->_filePath->_appdata.join(g_engine->_filePath->_saveDir);
|
||||
scanDir();
|
||||
}
|
||||
|
||||
bool handleEvents(const Common::Event &event) {
|
||||
int choice = _menu.handleEvents(event);
|
||||
if (choice >= 0) {
|
||||
_menu.reset();
|
||||
_selected = _slotInfo[_menu.index() + choice]._path;
|
||||
reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void draw() {
|
||||
_bg.draw();
|
||||
_menu.draw();
|
||||
for (auto i = _menu.index(), count = 0u; i < _menu.indexPlusOne() && i < _slotInfo.size(); i++, count++) {
|
||||
auto base_x = _menu.baseX(count), base_y = _menu.baseY(count);
|
||||
tdB[DATA_SAVENAME].draw(_slotInfo[i]._name, base_x, base_y);
|
||||
tdB[DATA_LASTMODIFIED].draw(_slotInfo[i]._lastModified, base_x, base_y);
|
||||
}
|
||||
|
||||
drawHover();
|
||||
}
|
||||
|
||||
void drawHover() {
|
||||
if (_menu.hoverIndex() >= 0) {
|
||||
int i = _menu.hoverIndex();
|
||||
|
||||
if (!_img._loaded || _prevHover != i) {
|
||||
_img._loaded = true;
|
||||
_prevHover = i;
|
||||
if (!_img._preview.load(Common::Path(_slotInfo[i]._preview)))
|
||||
_img._preview.load(Common::Path(_img._noPreviewPath));
|
||||
}
|
||||
|
||||
_hover = true;
|
||||
_img._preview.draw(_img._pos.x, _img._pos.y);
|
||||
|
||||
tdH[DATA_LOCNAME].draw(_slotInfo[i]._locName);
|
||||
tdH[DATA_DIFFICULTY].draw(_slotInfo[i]._diff);
|
||||
tdH[DATA_TIMEPLAYED].draw(_slotInfo[i]._time);
|
||||
tdH[DATA_PLAYERNAME].draw(_slotInfo[i]._charName);
|
||||
|
||||
for (int num = 0; num < DATA_HOVER_TOTAL; ++num)
|
||||
hov[num].draw();
|
||||
} else if (_hover)
|
||||
reset();
|
||||
}
|
||||
|
||||
bool empty() {
|
||||
scanDir();
|
||||
return _slotInfo.empty();
|
||||
}
|
||||
|
||||
bool selectNewestFile() {
|
||||
if (_slotInfo.size() > 0) {
|
||||
_selected = _slotInfo[0]._path;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void setUI() {
|
||||
_bg.setUI();
|
||||
_menu.setUI();
|
||||
scanDir();
|
||||
_img._pos.setUI();
|
||||
|
||||
for (int i = 0; i < DATA_BUTTON_TOTAL; ++i)
|
||||
tdB[i].setUI();
|
||||
|
||||
for (int i = 0; i < DATA_HOVER_TOTAL; ++i) {
|
||||
tdH[i].setUI();
|
||||
hov[i].setUI();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_FILEMENU_H
|
||||
77
engines/crab/ui/GameOverMenu.cpp
Normal file
77
engines/crab/ui/GameOverMenu.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "crab/ui/GameOverMenu.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::image;
|
||||
|
||||
void GameOverMenu::load(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid(node)) {
|
||||
if (nodeValid("bg", node))
|
||||
_bg.load(node->first_node("bg"));
|
||||
|
||||
if (nodeValid("title", node)) {
|
||||
rapidxml::xml_node<char> *tinode = node->first_node("title");
|
||||
_title.load(tinode);
|
||||
|
||||
for (auto n = tinode->first_node("quote"); n != nullptr; n = n->next_sibling("quote")) {
|
||||
Common::String str;
|
||||
loadStr(str, "text", n);
|
||||
_quote.push_back(str);
|
||||
}
|
||||
}
|
||||
|
||||
_menu.load(node->first_node("menu"));
|
||||
}
|
||||
}
|
||||
|
||||
int GameOverMenu::handleEvents(const Common::Event &event) {
|
||||
return _menu.handleEvents(event);
|
||||
}
|
||||
|
||||
void GameOverMenu::draw() {
|
||||
_bg.draw();
|
||||
if (_cur < _quote.size())
|
||||
_title.draw(_quote[_cur]);
|
||||
|
||||
_menu.draw();
|
||||
}
|
||||
|
||||
void GameOverMenu::setUI() {
|
||||
_bg.setUI();
|
||||
_title.setUI();
|
||||
_menu.setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
81
engines/crab/ui/GameOverMenu.h
Normal file
81
engines/crab/ui/GameOverMenu.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_GAMEOVERMENU_H
|
||||
#define CRAB_GAMEOVERMENU_H
|
||||
|
||||
#include "crab/ui/ImageData.h"
|
||||
#include "crab/ui/TextData.h"
|
||||
#include "crab/ui/menu.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class GameOverMenu {
|
||||
// Background image
|
||||
ImageData _bg;
|
||||
|
||||
// The selection of quotes, we pick one out of these
|
||||
Common::Array<Common::String> _quote;
|
||||
|
||||
// The current picked quote
|
||||
uint _cur;
|
||||
|
||||
// How to draw the quote
|
||||
TextData _title;
|
||||
|
||||
// The menu for actions we can take
|
||||
ButtonMenu _menu;
|
||||
|
||||
public:
|
||||
GameOverMenu() {
|
||||
_cur = 0;
|
||||
}
|
||||
|
||||
~GameOverMenu() {}
|
||||
|
||||
void reset() {
|
||||
_cur = g_engine->getRandomNumber(_quote.size());
|
||||
}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
|
||||
int handleEvents(const Common::Event &event);
|
||||
void draw();
|
||||
|
||||
void setUI();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_GAMEOVERMENU_H
|
||||
161
engines/crab/ui/GeneralSettingMenu.cpp
Normal file
161
engines/crab/ui/GeneralSettingMenu.cpp
Normal file
@@ -0,0 +1,161 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/ScreenSettings.h"
|
||||
#include "crab/crab.h"
|
||||
#include "crab/ui/GeneralSettingMenu.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::music;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Load components from file
|
||||
//------------------------------------------------------------------------
|
||||
void GeneralSettingMenu::load(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid("volume", node)) {
|
||||
rapidxml::xml_node<char> *musnode = node->first_node("volume");
|
||||
|
||||
if (nodeValid("desc", musnode))
|
||||
_noticeVolume.load(musnode->first_node("desc"));
|
||||
|
||||
if (nodeValid("music", musnode)) {
|
||||
int val = g_engine->_musicManager->volMusic();
|
||||
if (ConfMan.hasKey("mute") && ConfMan.getBool("mute"))
|
||||
val = 0;
|
||||
_volMusic.load(musnode->first_node("music"), 0, 255, val);
|
||||
}
|
||||
|
||||
if (nodeValid("effects", musnode)) {
|
||||
int val = g_engine->_musicManager->volEffects();
|
||||
if (ConfMan.hasKey("mute") && ConfMan.getBool("mute"))
|
||||
val = 0;
|
||||
_volEffects.load(musnode->first_node("effects"), 0, 255, val);
|
||||
}
|
||||
}
|
||||
|
||||
if (nodeValid("mouse_trap", node))
|
||||
_mouseTrap.load(node->first_node("mouse_trap"));
|
||||
|
||||
if (nodeValid("save_on_exit", node))
|
||||
_saveOnExit.load(node->first_node("save_on_exit"));
|
||||
|
||||
if (nodeValid("text_speed", node))
|
||||
_textSpeed.load(node->first_node("text_speed"));
|
||||
|
||||
// Sync popup text value with actual value
|
||||
for (auto &i : _textSpeed._element)
|
||||
i._state = (i._val == g_engine->_screenSettings->_textSpeed);
|
||||
|
||||
setUI();
|
||||
createBackup();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Handle user input
|
||||
//------------------------------------------------------------------------
|
||||
void GeneralSettingMenu::handleEvents(const Common::Event &event) {
|
||||
if (_volMusic.handleEvents(event)) {
|
||||
bool unmute = _volMusic.Value() > 0 && ConfMan.hasKey("mute") && ConfMan.getBool("mute");
|
||||
g_engine->_musicManager->volMusic(_volMusic.Value(), unmute);
|
||||
}
|
||||
|
||||
if (_volEffects.handleEvents(event)) {
|
||||
bool unmute = _volEffects.Value() > 0 && ConfMan.hasKey("mute") && ConfMan.getBool("mute");
|
||||
g_engine->_musicManager->volEffects(_volEffects.Value(), unmute);
|
||||
}
|
||||
|
||||
// No need to change screen here
|
||||
if (_saveOnExit.handleEvents(event) != BUAC_IGNORE)
|
||||
g_engine->_screenSettings->_saveOnExit = !g_engine->_screenSettings->_saveOnExit;
|
||||
|
||||
if (_mouseTrap.handleEvents(event) != BUAC_IGNORE) {
|
||||
g_engine->_screenSettings->_mouseTrap = !g_engine->_screenSettings->_mouseTrap;
|
||||
|
||||
// Maybe move this to ScreenSettings itself
|
||||
g_system->lockMouse(g_engine->_screenSettings->_mouseTrap);
|
||||
}
|
||||
|
||||
int result = _textSpeed.handleEvents(event);
|
||||
if (result >= 0)
|
||||
g_engine->_screenSettings->_textSpeed = _textSpeed._element[result]._val;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Sync our buttons with screen settings
|
||||
//------------------------------------------------------------------------
|
||||
void GeneralSettingMenu::internalEvents() {
|
||||
_saveOnExit._state = g_engine->_screenSettings->_saveOnExit;
|
||||
_mouseTrap._state = g_engine->_screenSettings->_mouseTrap;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Draw stuff
|
||||
//------------------------------------------------------------------------
|
||||
void GeneralSettingMenu::draw() {
|
||||
// Draw volume sliders
|
||||
_noticeVolume.draw();
|
||||
_volMusic.draw();
|
||||
_volEffects.draw();
|
||||
|
||||
// Draw the auto-save on exit option
|
||||
_saveOnExit.draw();
|
||||
_mouseTrap.draw();
|
||||
|
||||
// Text speed radio button menu
|
||||
_textSpeed.draw();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Revert to previously backed up settings
|
||||
//------------------------------------------------------------------------
|
||||
void GeneralSettingMenu::restoreBackup() {
|
||||
_volMusic.restoreBackup();
|
||||
g_engine->_musicManager->volMusic(_volMusic.Value());
|
||||
|
||||
_volEffects.restoreBackup();
|
||||
g_engine->_musicManager->volEffects(_volEffects.Value());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Set UI positioned on screen size change
|
||||
//------------------------------------------------------------------------
|
||||
void GeneralSettingMenu::setUI() {
|
||||
_saveOnExit.setUI();
|
||||
_mouseTrap.setUI();
|
||||
|
||||
_volMusic.setUI();
|
||||
_volEffects.setUI();
|
||||
|
||||
_textSpeed.setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
78
engines/crab/ui/GeneralSettingMenu.h
Normal file
78
engines/crab/ui/GeneralSettingMenu.h
Normal 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_GENERALSETTINGMENU_H
|
||||
#define CRAB_GENERALSETTINGMENU_H
|
||||
|
||||
#include "crab/ui/RadioButtonMenu.h"
|
||||
#include "crab/ui/slider.h"
|
||||
#include "crab/ui/ToggleButton.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class GeneralSettingMenu {
|
||||
// The volume sliders and their caption
|
||||
Slider _volMusic, _volEffects;
|
||||
HoverInfo _noticeVolume;
|
||||
|
||||
// Other settings
|
||||
ToggleButton _saveOnExit, _mouseTrap;
|
||||
|
||||
// The menu for select pop-up text speed
|
||||
RadioButtonMenu _textSpeed;
|
||||
|
||||
public:
|
||||
GeneralSettingMenu() {}
|
||||
~GeneralSettingMenu() {}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
|
||||
void handleEvents(const Common::Event &event);
|
||||
|
||||
void internalEvents();
|
||||
|
||||
void draw();
|
||||
void setUI();
|
||||
|
||||
void createBackup() {
|
||||
_volMusic.createBackup();
|
||||
_volEffects.createBackup();
|
||||
}
|
||||
|
||||
void restoreBackup();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_GENERALSETTINGMENU_H
|
||||
148
engines/crab/ui/GfxSettingMenu.cpp
Normal file
148
engines/crab/ui/GfxSettingMenu.cpp
Normal file
@@ -0,0 +1,148 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/crab.h"
|
||||
#include "crab/ui/GfxSettingMenu.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Load components from file
|
||||
//------------------------------------------------------------------------
|
||||
void GfxSettingMenu::load(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid("resolution", node))
|
||||
_resolution.load(node->first_node("resolution"));
|
||||
|
||||
if (nodeValid("fullscreen", node))
|
||||
_fullscreen.load(node->first_node("fullscreen"));
|
||||
|
||||
if (nodeValid("vsync", node))
|
||||
_vsync.load(node->first_node("vsync"));
|
||||
|
||||
if (nodeValid("border", node))
|
||||
_border.load(node->first_node("border"));
|
||||
|
||||
if (nodeValid("quality", node)) {
|
||||
rapidxml::xml_node<char> *qnode = node->first_node("quality");
|
||||
_quality.load(qnode);
|
||||
|
||||
if (nodeValid("message", qnode))
|
||||
_noticeQuality.load(qnode->first_node("message"), &_quality);
|
||||
}
|
||||
|
||||
if (nodeValid("brightness", node))
|
||||
_brightness.load(node->first_node("brightness"), 0, 100, g_engine->_screenSettings->_gamma * 100);
|
||||
|
||||
// This functionality has been disabled in ScummVM.
|
||||
_brightness.setEnabled(false);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Draw stuff
|
||||
//------------------------------------------------------------------------
|
||||
void GfxSettingMenu::draw() {
|
||||
// Window border doesn't matter if you are in fullscreen
|
||||
if (!g_engine->_screenSettings->_fullscreen)
|
||||
_border.draw();
|
||||
|
||||
// Draw toggle buttons
|
||||
_brightness.draw();
|
||||
_fullscreen.draw();
|
||||
_vsync.draw();
|
||||
|
||||
// Quality and resolution can only be changed in the main menu
|
||||
if (!g_engine->_screenSettings->_inGame) {
|
||||
// Tree quality button
|
||||
_quality.draw();
|
||||
} else
|
||||
_noticeQuality.draw(); // Notice about quality settings
|
||||
|
||||
// Draw resolution menu
|
||||
_resolution.draw();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Handle input
|
||||
//------------------------------------------------------------------------
|
||||
int GfxSettingMenu::handleEvents(const Common::Event &event) {
|
||||
if (_fullscreen.handleEvents(event) != BUAC_IGNORE)
|
||||
g_engine->_screenSettings->toggleFullScreen();
|
||||
|
||||
if (_vsync.handleEvents(event) != BUAC_IGNORE)
|
||||
g_engine->_screenSettings->toggleVsync();
|
||||
|
||||
// Quality and resolution can only be changed in the main menu
|
||||
if (!g_engine->_screenSettings->_inGame) {
|
||||
if (_quality.handleEvents(event) != BUAC_IGNORE)
|
||||
g_engine->_screenSettings->_quality = !g_engine->_screenSettings->_quality;
|
||||
}
|
||||
|
||||
// Window border doesn't matter if you are in fullscreen
|
||||
if (_border.handleEvents(event) && !g_engine->_screenSettings->_fullscreen != BUAC_IGNORE) {
|
||||
g_engine->_screenSettings->_border = !g_engine->_screenSettings->_border;
|
||||
}
|
||||
|
||||
if (_brightness.handleEvents(event)) {
|
||||
g_engine->_screenSettings->_gamma = static_cast<float>(_brightness.Value()) / 100.0f;
|
||||
}
|
||||
|
||||
return _resolution.handleEvents(event);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Keep button settings synced with our screen settings
|
||||
//------------------------------------------------------------------------
|
||||
void GfxSettingMenu::internalEvents() {
|
||||
g_engine->_screenSettings->internalEvents();
|
||||
|
||||
_fullscreen._state = g_engine->_screenSettings->_fullscreen;
|
||||
_vsync._state = g_engine->_screenSettings->_vsync;
|
||||
_border._state = g_engine->_screenSettings->_border;
|
||||
_quality._state = g_engine->_screenSettings->_quality;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Rearrange UI when resolution changes
|
||||
//------------------------------------------------------------------------
|
||||
void GfxSettingMenu::setUI() {
|
||||
_resolution.setUI();
|
||||
|
||||
_fullscreen.setUI();
|
||||
_vsync.setUI();
|
||||
_border.setUI();
|
||||
_quality.setUI();
|
||||
|
||||
_noticeQuality.setUI();
|
||||
_brightness.setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
77
engines/crab/ui/GfxSettingMenu.h
Normal file
77
engines/crab/ui/GfxSettingMenu.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_GFXSETTINGMENU_H
|
||||
#define CRAB_GFXSETTINGMENU_H
|
||||
|
||||
#include "crab/ui/ImageData.h"
|
||||
#include "crab/ui/ResolutionMenu.h"
|
||||
#include "crab/ui/slider.h"
|
||||
#include "crab/ui/StateButton.h"
|
||||
#include "crab/ui/ToggleButton.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class GfxSettingMenu {
|
||||
// The brightness slider
|
||||
Slider _brightness;
|
||||
|
||||
// The button to toggle between full and windowed, and turn vsync on/off, window borders or not, game quality
|
||||
ToggleButton _fullscreen, _vsync, _border, _quality;
|
||||
|
||||
// The buttons and menus for changing resolution
|
||||
ResolutionMenu _resolution;
|
||||
|
||||
// Notice that quality setting can only be changed outside the game
|
||||
HoverInfo _noticeQuality;
|
||||
|
||||
public:
|
||||
GfxSettingMenu() {}
|
||||
~GfxSettingMenu() {}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
|
||||
int handleEvents(const Common::Event &event);
|
||||
|
||||
void internalEvents();
|
||||
|
||||
void draw();
|
||||
void setUI();
|
||||
|
||||
void SetInfo() { _resolution.setInfo(); }
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_GFXSETTINGMENU_H
|
||||
75
engines/crab/ui/HealthIndicator.cpp
Normal file
75
engines/crab/ui/HealthIndicator.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/crab.h"
|
||||
#include "crab/ui/HealthIndicator.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
|
||||
void HealthIndicator::load(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid(node)) {
|
||||
loadXY(_x, _y, node);
|
||||
|
||||
for (auto n = node->first_node("img"); n != nullptr; n = n->next_sibling("img")) {
|
||||
HealthImage hi;
|
||||
loadImgKey(hi._normal, "normal", n);
|
||||
loadImgKey(hi._glow, "glow", n);
|
||||
loadNum(hi._val, "val", n);
|
||||
|
||||
_img.push_back(hi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HealthIndicator::draw(int num) {
|
||||
for (const auto &i : _img)
|
||||
if (num == i._val) {
|
||||
using namespace pyrodactyl::image;
|
||||
g_engine->_imageManager->draw(_x, _y, i._normal);
|
||||
g_engine->_imageManager->getTexture(i._glow).alpha(_alpha);
|
||||
g_engine->_imageManager->draw(_x, _y, i._glow);
|
||||
|
||||
if (_inc) {
|
||||
_alpha += 2;
|
||||
if (_alpha >= 250)
|
||||
_inc = false;
|
||||
} else {
|
||||
_alpha -= 2;
|
||||
if (_alpha < 4)
|
||||
_inc = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
71
engines/crab/ui/HealthIndicator.h
Normal file
71
engines/crab/ui/HealthIndicator.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_HEALTHINDICATOR_H
|
||||
#define CRAB_HEALTHINDICATOR_H
|
||||
|
||||
#include "crab/image/ImageManager.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class HealthIndicator {
|
||||
struct HealthImage {
|
||||
ImageKey _normal, _glow;
|
||||
int _val;
|
||||
};
|
||||
|
||||
int _x, _y;
|
||||
Common::Array<HealthImage> _img;
|
||||
|
||||
// Related to the pulse effect
|
||||
uint8 _alpha;
|
||||
bool _inc;
|
||||
|
||||
public:
|
||||
HealthIndicator() {
|
||||
_x = 0;
|
||||
_y = 0;
|
||||
_alpha = 0;
|
||||
_inc = true;
|
||||
}
|
||||
|
||||
~HealthIndicator() {}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
void draw(int num);
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_HEALTHINDICATOR_H
|
||||
57
engines/crab/ui/HoverInfo.cpp
Normal file
57
engines/crab/ui/HoverInfo.cpp
Normal 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "crab/ui/HoverInfo.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::text;
|
||||
using namespace pyrodactyl::ui;
|
||||
|
||||
void HoverInfo::init(const HoverInfo &hInfo, const int &xOffset, const int &yOffset) {
|
||||
*this = hInfo;
|
||||
x += xOffset;
|
||||
y += yOffset;
|
||||
}
|
||||
|
||||
void HoverInfo::load(rapidxml::xml_node<char> *node, Rect *parent) {
|
||||
if (TextData::load(node, parent, false)) {
|
||||
loadStr(_text, "text", node);
|
||||
_enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
void HoverInfo::draw(const int &xOffset, const int &yOffset) {
|
||||
if (_enabled)
|
||||
TextData::draw(_text, xOffset, yOffset);
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
62
engines/crab/ui/HoverInfo.h
Normal file
62
engines/crab/ui/HoverInfo.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_HOVERINFO_H
|
||||
#define CRAB_HOVERINFO_H
|
||||
|
||||
#include "crab/ui/TextData.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
// Tooltip for buttons
|
||||
class HoverInfo : public TextData {
|
||||
public:
|
||||
bool _enabled;
|
||||
Common::String _text;
|
||||
|
||||
HoverInfo() {
|
||||
_enabled = false;
|
||||
}
|
||||
|
||||
~HoverInfo() {}
|
||||
|
||||
void init(const HoverInfo &h, const int &xOffset = 0, const int &yOffset = 0);
|
||||
|
||||
void load(rapidxml::xml_node<char> *node, Rect *parent = nullptr);
|
||||
void draw(const int &xOffset = 0, const int &yOffset = 0);
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_HOVERINFO_H
|
||||
57
engines/crab/ui/ImageData.cpp
Normal file
57
engines/crab/ui/ImageData.cpp
Normal 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/crab.h"
|
||||
#include "crab/image/ImageManager.h"
|
||||
#include "crab/ui/ImageData.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::image;
|
||||
|
||||
void ImageData::load(rapidxml::xml_node<char> *node, const bool &echo) {
|
||||
loadImgKey(_key, "img", node, echo);
|
||||
loadBool(_crop, "crop", node, false);
|
||||
|
||||
if (nodeValid("clip", node, false))
|
||||
_clip.load(node->first_node("clip"));
|
||||
|
||||
Element::load(node, _key, echo);
|
||||
}
|
||||
|
||||
void ImageData::draw(const int &xOffset, const int &yOffset) {
|
||||
if (_crop)
|
||||
g_engine->_imageManager->draw(x + xOffset, y + yOffset, _key, &_clip);
|
||||
else
|
||||
g_engine->_imageManager->draw(x + xOffset, y + yOffset, _key);
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
66
engines/crab/ui/ImageData.h
Normal file
66
engines/crab/ui/ImageData.h
Normal 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_IMAGEDATA_H
|
||||
#define CRAB_IMAGEDATA_H
|
||||
|
||||
#include "crab/ui/element.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class ImageData : public Element {
|
||||
// The image
|
||||
ImageKey _key;
|
||||
|
||||
// Should we clip the image? (usually used for large background images)
|
||||
bool _crop;
|
||||
|
||||
// The clip rectangle, used only when clip is true
|
||||
Rect _clip;
|
||||
|
||||
public:
|
||||
ImageData() {
|
||||
_key = 0;
|
||||
_crop = false;
|
||||
}
|
||||
|
||||
~ImageData() {}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node, const bool &echo = true);
|
||||
void draw(const int &xOffset = 0, const int &yOffset = 0);
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_IMAGEDATA_H
|
||||
134
engines/crab/ui/Inventory.cpp
Normal file
134
engines/crab/ui/Inventory.cpp
Normal file
@@ -0,0 +1,134 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/XMLDoc.h"
|
||||
#include "crab/ui/Inventory.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::image;
|
||||
using namespace pyrodactyl::item;
|
||||
using namespace pyrodactyl::people;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Load layout
|
||||
//------------------------------------------------------------------------
|
||||
void Inventory::load(const Common::Path &filename) {
|
||||
XMLDoc conf(filename);
|
||||
if (conf.ready()) {
|
||||
rapidxml::xml_node<char> *node = conf.doc()->first_node("inventory");
|
||||
if (nodeValid(node)) {
|
||||
if (nodeValid("bg", node))
|
||||
_bg.load(node->first_node("bg"));
|
||||
|
||||
_collection.load(node->first_node("items"));
|
||||
|
||||
/*if (nodeValid("stats", node))
|
||||
helper.load(node->first_node("stats"));*/
|
||||
|
||||
if (nodeValid("money", node))
|
||||
_money.load(node->first_node("money"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Inventory::loadItem(const Common::String &charId, const Common::String &id) {
|
||||
Item i;
|
||||
XMLDoc itemList(_itemfile);
|
||||
if (itemList.ready()) {
|
||||
rapidxml::xml_node<char> *node = itemList.doc()->first_node("items");
|
||||
for (auto n = node->first_node("item"); n != nullptr; n = n->next_sibling("item")) {
|
||||
Common::String str = n->first_attribute("id")->value();
|
||||
if (id == str) {
|
||||
i.load(n);
|
||||
addItem(charId, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Inventory::delItem(const Common::String &charId, const Common::String &itemId) {
|
||||
_collection.del(charId, itemId);
|
||||
}
|
||||
|
||||
void Inventory::addItem(const Common::String &charId, pyrodactyl::item::Item &item) {
|
||||
_collection.add(charId, item);
|
||||
}
|
||||
|
||||
bool Inventory::hasItem(const Common::String &charId, const Common::String &container, const Common::String &itemId) {
|
||||
return _collection.has(charId, container, itemId);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Draw
|
||||
//------------------------------------------------------------------------
|
||||
void Inventory::draw(Person &obj, const int &moneyVal) {
|
||||
_bg.draw();
|
||||
// helper.DrawInfo(obj);
|
||||
_collection.draw(obj._id /*, helper*/);
|
||||
|
||||
_money._caption._text = numberToString(moneyVal);
|
||||
_money.draw();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Handle events
|
||||
//------------------------------------------------------------------------
|
||||
void Inventory::handleEvents(const Common::String &string, const Common::Event &event) {
|
||||
_collection.handleEvents(string, event);
|
||||
(void)_money.handleEvents(event);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Load and save items
|
||||
//------------------------------------------------------------------------
|
||||
void Inventory::loadState(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid("items", node))
|
||||
_collection.loadState(node->first_node("items"));
|
||||
}
|
||||
|
||||
void Inventory::saveState(rapidxml::xml_document<> &doc, rapidxml::xml_node<char> *root) {
|
||||
rapidxml::xml_node<char> *child = doc.allocate_node(rapidxml::node_element, "items");
|
||||
_collection.saveState(doc, child);
|
||||
root->append_node(child);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Set UI positions after screen size change
|
||||
//------------------------------------------------------------------------
|
||||
void Inventory::setUI() {
|
||||
_bg.setUI();
|
||||
_collection.setUI();
|
||||
_money.setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
91
engines/crab/ui/Inventory.h
Normal file
91
engines/crab/ui/Inventory.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_INVENTORY_H
|
||||
#define CRAB_INVENTORY_H
|
||||
|
||||
#include "crab/item/ItemCollection.h"
|
||||
#include "crab/item/ItemSlot.h"
|
||||
#include "crab/ui/button.h"
|
||||
#include "crab/ui/ImageData.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class Inventory {
|
||||
// The background image and location
|
||||
ImageData _bg;
|
||||
|
||||
// The equipment and storage space, stored according to the player character id
|
||||
pyrodactyl::item::ItemCollection _collection;
|
||||
|
||||
// To draw the player stats
|
||||
// pyrodactyl::stat::StatDrawHelper helper;
|
||||
|
||||
// The file where all the item information is stored
|
||||
Common::Path _itemfile;
|
||||
|
||||
// Used to draw the money value
|
||||
Button _money;
|
||||
|
||||
public:
|
||||
Inventory() {}
|
||||
~Inventory() {}
|
||||
|
||||
void init(const Common::String &charId) {
|
||||
_collection.init(charId);
|
||||
}
|
||||
|
||||
void loadItem(const Common::String &charId, const Common::String &name);
|
||||
void addItem(const Common::String &charId, pyrodactyl::item::Item &item);
|
||||
void delItem(const Common::String &charId, const Common::String &itemId);
|
||||
bool hasItem(const Common::String &charId, const Common::String &container, const Common::String &itemId);
|
||||
|
||||
void load(const Common::Path &filename);
|
||||
void draw(pyrodactyl::people::Person &obj, const int &moneyVal);
|
||||
|
||||
void handleEvents(const Common::String &string, const Common::Event &Event);
|
||||
|
||||
void loadState(rapidxml::xml_node<char> *node);
|
||||
void saveState(rapidxml::xml_document<> &doc, rapidxml::xml_node<char> *root);
|
||||
|
||||
void itemFile(const Common::String &filename) {
|
||||
_itemfile = filename;
|
||||
}
|
||||
|
||||
void setUI();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_INVENTORY_H
|
||||
74
engines/crab/ui/ItemDesc.h
Normal file
74
engines/crab/ui/ItemDesc.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_ITEMDESC_H
|
||||
#define CRAB_ITEMDESC_H
|
||||
|
||||
#include "crab/ui/ParagraphData.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class ItemDesc {
|
||||
// The name of the item
|
||||
TextData _name;
|
||||
|
||||
// The description of the item
|
||||
ParagraphData _desc;
|
||||
|
||||
public:
|
||||
ItemDesc() {}
|
||||
~ItemDesc() {}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid("name", node))
|
||||
_name.load(node->first_node("name"));
|
||||
|
||||
if (nodeValid("desc", node))
|
||||
_desc.load(node->first_node("desc"));
|
||||
}
|
||||
|
||||
void draw(pyrodactyl::item::Item &item) {
|
||||
_name.draw(item._name);
|
||||
_desc.draw(item._desc);
|
||||
}
|
||||
|
||||
void setUI() {
|
||||
_name.setUI();
|
||||
_desc.setUI();
|
||||
}
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_ITEMDESC_H
|
||||
231
engines/crab/ui/KeyBindMenu.cpp
Normal file
231
engines/crab/ui/KeyBindMenu.cpp
Normal file
@@ -0,0 +1,231 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/crab.h"
|
||||
#include "crab/ui/KeyBindMenu.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::image;
|
||||
using namespace pyrodactyl::text;
|
||||
using namespace pyrodactyl::input;
|
||||
|
||||
void KeyBindMenu::load(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid(node)) {
|
||||
if (nodeValid("menu", node)) {
|
||||
rapidxml::xml_node<char> *menode = node->first_node("menu");
|
||||
|
||||
if (nodeValid("primary", menode))
|
||||
_prim.load(menode->first_node("primary"));
|
||||
|
||||
if (nodeValid("alt", menode))
|
||||
_alt.load(menode->first_node("alt"));
|
||||
|
||||
if (nodeValid("prompt", menode))
|
||||
_prompt.load(menode->first_node("prompt"));
|
||||
|
||||
if (nodeValid("inc", menode))
|
||||
_inc.load(menode->first_node("inc"));
|
||||
|
||||
if (nodeValid("dim", menode))
|
||||
_dim.load(menode->first_node("dim"));
|
||||
|
||||
if (nodeValid("divide", menode))
|
||||
_divide.load(menode->first_node("divide"));
|
||||
|
||||
if (nodeValid("desc", menode))
|
||||
_desc.load(menode->first_node("desc"));
|
||||
}
|
||||
|
||||
// Initialize the menus
|
||||
initMenu(CON_GAME);
|
||||
initMenu(CON_UI);
|
||||
|
||||
if (nodeValid("controls", node))
|
||||
_selControls.load(node->first_node("controls"));
|
||||
}
|
||||
}
|
||||
|
||||
void KeyBindMenu::startAndSize(const int &type, int &start, int &size) {
|
||||
switch (type) {
|
||||
case CON_GAME:
|
||||
start = IG_START;
|
||||
size = IG_SIZE;
|
||||
break;
|
||||
case CON_UI:
|
||||
start = IU_START;
|
||||
size = IU_SIZE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void KeyBindMenu::initMenu(const int &type) {
|
||||
int start = 0, size = 0;
|
||||
startAndSize(type, start, size);
|
||||
|
||||
// Initialize the menu
|
||||
_menu[type]._element.resize(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
int xoffset = _inc.x * i + _divide.x * (i / _dim.x);
|
||||
int yoffset = _inc.y * (i % _dim.x) + _divide.y * (i / _dim.x);
|
||||
|
||||
_menu[type]._element[i].init(_prim, xoffset, yoffset);
|
||||
_menu[type]._element[i]._caption._text = g_engine->_inputManager->getAssociatedKey((InputType)(start + i));
|
||||
|
||||
//_menu[type]._element[i + 1].init(_alt, xoffset, yoffset);
|
||||
//_menu[type]._element[i + 1]._caption._text = SDL_GetScancodeName(g_engine->_inputManager->iv[start + (i / 2)].alt);
|
||||
}
|
||||
}
|
||||
|
||||
void KeyBindMenu::drawDesc(const int &type) {
|
||||
int start = 0, size = 0;
|
||||
startAndSize(type, start, size);
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
int xoffset = _inc.x * i + _divide.x * (i / _dim.x);
|
||||
int yoffset = _inc.y * (i % _dim.x) + _divide.y * (i / _dim.x);
|
||||
|
||||
_desc.draw(g_engine->_inputManager->_iv[i + start], xoffset, yoffset);
|
||||
}
|
||||
}
|
||||
|
||||
void KeyBindMenu::draw() {
|
||||
_selControls.draw();
|
||||
|
||||
_menu[_selControls._cur].draw();
|
||||
drawDesc(_selControls._cur);
|
||||
}
|
||||
|
||||
void KeyBindMenu::setCaption() {
|
||||
int start = 0, size = 0;
|
||||
startAndSize(_selControls._cur, start, size);
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
_menu[_selControls._cur]._element[i]._caption._text = g_engine->_inputManager->getAssociatedKey((InputType)(start + i));
|
||||
}
|
||||
|
||||
void KeyBindMenu::handleEvents(const Common::Event &event) {
|
||||
if (_selControls.handleEvents(event))
|
||||
setCaption();
|
||||
|
||||
switch (_state) {
|
||||
case STATE_NORMAL:
|
||||
_choice = _menu[_selControls._cur].handleEvents(event);
|
||||
if (_choice >= 0) {
|
||||
_prompt.swap(_menu[_selControls._cur]._element[_choice]._caption);
|
||||
_state = STATE_KEY;
|
||||
g_system->getEventManager()->getKeymapper()->setEnabled(false);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case STATE_KEY:
|
||||
if (setKey(event)) { // if key remapped successfully
|
||||
g_engine->_inputManager->populateKeyTable(); // repopulate key table
|
||||
g_system->getEventManager()->getKeymapper()->setEnabled(true);
|
||||
|
||||
setCaption();
|
||||
_menu[_selControls._cur]._element[_choice]._caption._col = _prompt._colPrev;
|
||||
_state = STATE_NORMAL;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool KeyBindMenu::setKey(const Common::Event &event) {
|
||||
Common::HardwareInput hwInput = g_system->getEventManager()->getKeymapper()->findHardwareInput(event);
|
||||
if (hwInput.type != Common::kHardwareInputTypeInvalid) {
|
||||
int ch = _choice;
|
||||
if (_selControls._cur == CON_UI)
|
||||
ch += IG_SIZE;
|
||||
|
||||
Common::KeymapArray keymapArr = g_system->getEventManager()->getKeymapper()->getKeymaps();
|
||||
for (Common::Keymap *keymap : keymapArr) {
|
||||
if (keymap->getType() != Common::Keymap::kKeymapTypeGame)
|
||||
continue;
|
||||
|
||||
const Common::Keymap::ActionArray actions = keymap->getActions();
|
||||
for (Common::Action *action : actions) {
|
||||
if ((int)action->event.customType == ch) {
|
||||
keymap->unregisterMapping(action);
|
||||
keymap->registerMapping(action, hwInput);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void KeyBindMenu::SwapKey(const SDL_Scancode &find) {
|
||||
int start = 0, size = 0;
|
||||
StartAndSize(sel_controls.cur, start, size);
|
||||
int pos = start + (choice / 2);
|
||||
|
||||
for (int i = start; i < start + size; ++i) {
|
||||
if (g_engine->_inputManager->iv[i].key == find) {
|
||||
g_engine->_inputManager->iv[i].key = g_engine->_inputManager->iv[pos].key;
|
||||
break;
|
||||
} else if (g_engine->_inputManager->iv[i].alt == find) {
|
||||
g_engine->_inputManager->iv[i].alt = g_engine->_inputManager->iv[pos].key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (choice % 2 == 0)
|
||||
g_engine->_inputManager->iv[pos].key = find;
|
||||
else
|
||||
g_engine->_inputManager->iv[pos].alt = find;
|
||||
}
|
||||
#endif
|
||||
|
||||
void KeyBindMenu::setUI() {
|
||||
_menu[CON_GAME].clear();
|
||||
_menu[CON_UI].clear();
|
||||
|
||||
// Initialize the menus
|
||||
_prim.setUI();
|
||||
_alt.setUI();
|
||||
initMenu(CON_GAME);
|
||||
initMenu(CON_UI);
|
||||
|
||||
_desc.setUI();
|
||||
_selControls.setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
137
engines/crab/ui/KeyBindMenu.h
Normal file
137
engines/crab/ui/KeyBindMenu.h
Normal file
@@ -0,0 +1,137 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_KEYBINDMENU_H
|
||||
#define CRAB_KEYBINDMENU_H
|
||||
|
||||
#include "crab/ui/ImageData.h"
|
||||
#include "crab/ui/menu.h"
|
||||
#include "crab/ui/OptionSelect.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class KeyBindMenu {
|
||||
// The keyboard controls menu has 2 types of inputs
|
||||
enum Controls {
|
||||
CON_GAME = 0,
|
||||
CON_UI,
|
||||
CON_TOTAL
|
||||
};
|
||||
|
||||
// Each menu can be in these 2 states
|
||||
enum States {
|
||||
STATE_NORMAL,
|
||||
STATE_KEY
|
||||
} _state;
|
||||
|
||||
// This button swaps between sub-sections "Gameplay" and "Interface"
|
||||
OptionSelect _selControls;
|
||||
|
||||
// These two buttons are the template buttons for the menu
|
||||
Button _prim, _alt;
|
||||
|
||||
// This is the template text info
|
||||
TextData _desc;
|
||||
|
||||
// inc tells us what to add to the reference buttons to get multiple buttons
|
||||
// Divide is the space between two columns
|
||||
Vector2i _inc, _divide;
|
||||
|
||||
// The number of rows and columns
|
||||
Vector2i _dim;
|
||||
|
||||
// The menu for the keyboard options in both sub categories
|
||||
// all control types have equal entries so we just need to change the text displayed
|
||||
ButtonMenu _menu[CON_TOTAL];
|
||||
|
||||
// The selected button in the current menu
|
||||
int _choice;
|
||||
|
||||
struct PromptInfo {
|
||||
int _col, _colPrev;
|
||||
Common::String _text;
|
||||
|
||||
PromptInfo() {
|
||||
_col = 0;
|
||||
_colPrev = 0;
|
||||
}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid(node)) {
|
||||
loadStr(_text, "text", node);
|
||||
loadNum(_col, "color", node);
|
||||
}
|
||||
}
|
||||
|
||||
void swap(Caption &c) {
|
||||
_colPrev = c._col;
|
||||
c._text = _text;
|
||||
c._col = _col;
|
||||
}
|
||||
} _prompt;
|
||||
|
||||
void startAndSize(const int &type, int &start, int &size);
|
||||
void initMenu(const int &type);
|
||||
void drawDesc(const int &type);
|
||||
|
||||
public:
|
||||
KeyBindMenu() {
|
||||
reset();
|
||||
_choice = -1;
|
||||
}
|
||||
~KeyBindMenu() {}
|
||||
|
||||
void reset() {
|
||||
_state = STATE_NORMAL;
|
||||
}
|
||||
|
||||
bool disableHotkeys() {
|
||||
return _state != STATE_NORMAL;
|
||||
}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
|
||||
void handleEvents(const Common::Event &event);
|
||||
|
||||
void setCaption();
|
||||
|
||||
bool setKey(const Common::Event &event);
|
||||
|
||||
void draw();
|
||||
void setUI();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_KEYBINDMENU_H
|
||||
92
engines/crab/ui/MapData.cpp
Normal file
92
engines/crab/ui/MapData.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/crab.h"
|
||||
#include "crab/GameParam.h"
|
||||
#include "crab/ui/MapData.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
|
||||
void MapData::load(rapidxml::xml_node<char> *node) {
|
||||
loadPath(_pathBg, "bg", node);
|
||||
loadPath(_pathOverlay, "overlay", node);
|
||||
}
|
||||
|
||||
void MapData::destAdd(const Common::String &name, const int &x, const int &y) {
|
||||
MarkerData md;
|
||||
md._name = name;
|
||||
md._pos.x = x;
|
||||
md._pos.y = y;
|
||||
_dest.push_back(md);
|
||||
}
|
||||
|
||||
void MapData::saveState(rapidxml::xml_document<> &doc, rapidxml::xml_node<char> *root) {
|
||||
rapidxml::xml_node<char> *child_clip = doc.allocate_node(rapidxml::node_element, "clip");
|
||||
for (auto &c : _reveal)
|
||||
c.saveState(doc, child_clip, "rect");
|
||||
root->append_node(child_clip);
|
||||
|
||||
rapidxml::xml_node<char> *child_dest = doc.allocate_node(rapidxml::node_element, "dest");
|
||||
for (auto &d : _dest) {
|
||||
rapidxml::xml_node<char> *child = doc.allocate_node(rapidxml::node_element, "pos");
|
||||
child->append_attribute(doc.allocate_attribute("name", d._name.c_str()));
|
||||
child->append_attribute(doc.allocate_attribute("x", g_engine->_stringPool->get(d._pos.x)));
|
||||
child->append_attribute(doc.allocate_attribute("y", g_engine->_stringPool->get(d._pos.y)));
|
||||
child_dest->append_node(child);
|
||||
}
|
||||
root->append_node(child_dest);
|
||||
}
|
||||
|
||||
void MapData::loadState(rapidxml::xml_node<char> *node) {
|
||||
_reveal.clear();
|
||||
if (nodeValid("clip", node)) {
|
||||
rapidxml::xml_node<char> *clipnode = node->first_node("clip");
|
||||
for (rapidxml::xml_node<char> *n = clipnode->first_node("rect"); n != nullptr; n = n->next_sibling("rect")) {
|
||||
Rect r;
|
||||
r.load(n);
|
||||
_reveal.push_back(r);
|
||||
}
|
||||
}
|
||||
|
||||
_dest.clear();
|
||||
if (nodeValid("dest", node)) {
|
||||
rapidxml::xml_node<char> *destnode = node->first_node("dest");
|
||||
for (rapidxml::xml_node<char> *n = destnode->first_node("pos"); n != nullptr; n = n->next_sibling("pos")) {
|
||||
MarkerData md;
|
||||
loadStr(md._name, "name", n);
|
||||
md._pos.load(n);
|
||||
_dest.push_back(md);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
75
engines/crab/ui/MapData.h
Normal file
75
engines/crab/ui/MapData.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_MAPDATA_H
|
||||
#define CRAB_MAPDATA_H
|
||||
|
||||
#include "crab/Rectangle.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
struct MapData {
|
||||
// The paths of set of map images - background and the fully revealed map overlay
|
||||
Common::Path _pathBg, _pathOverlay;
|
||||
|
||||
// The places the player has revealed in this world map
|
||||
Common::Array<Rect> _reveal;
|
||||
|
||||
struct MarkerData {
|
||||
// The name of the marker, same name as the quest
|
||||
Common::String _name;
|
||||
|
||||
// Position of the marker
|
||||
Vector2i _pos;
|
||||
};
|
||||
|
||||
// The set of destinations currently active
|
||||
Common::Array<MarkerData> _dest;
|
||||
|
||||
MapData() {}
|
||||
MapData(rapidxml::xml_node<char> *node) {
|
||||
load(node);
|
||||
}
|
||||
~MapData() {}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
void destAdd(const Common::String &name, const int &x, const int &y);
|
||||
|
||||
void saveState(rapidxml::xml_document<> &doc, rapidxml::xml_node<char> *root);
|
||||
void loadState(rapidxml::xml_node<char> *node);
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_MAPDATA_H
|
||||
137
engines/crab/ui/MapMarkerMenu.cpp
Normal file
137
engines/crab/ui/MapMarkerMenu.cpp
Normal file
@@ -0,0 +1,137 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/ui/MapMarkerMenu.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Load
|
||||
//------------------------------------------------------------------------
|
||||
void MapMarkerMenu::load(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid("ref", node))
|
||||
_ref.load(node->first_node("ref"));
|
||||
|
||||
if (nodeValid("player", node))
|
||||
_player.load(node->first_node("player"));
|
||||
|
||||
if (nodeValid("offset", node)) {
|
||||
rapidxml::xml_node<char> *offnode = node->first_node("offset");
|
||||
|
||||
if (nodeValid("marker", offnode))
|
||||
_offset._marker.load(offnode->first_node("marker"));
|
||||
|
||||
if (nodeValid("player", offnode))
|
||||
_offset._player.load(offnode->first_node("player"));
|
||||
}
|
||||
|
||||
_menu.useKeyboard(true);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Draw
|
||||
//------------------------------------------------------------------------
|
||||
void MapMarkerMenu::draw(const Element &pos, const Vector2i &player_pos, const Rect &camera) {
|
||||
// Calculate all offsets
|
||||
Vector2i offsetP(pos.x + player_pos.x + _offset._player.x - camera.x, pos.y + player_pos.y + _offset._player.y - camera.y);
|
||||
Vector2i offsetM(pos.x - camera.x + _offset._marker.x, pos.y - camera.y + _offset._marker.y);
|
||||
|
||||
// Only draw the image - captions drawn later to prevent drawing another button over caption
|
||||
_player.imageCaptionOnlyDraw(offsetP.x, offsetP.y);
|
||||
|
||||
for (auto &i : _menu._element)
|
||||
i.imageCaptionOnlyDraw(offsetM.x, offsetM.y);
|
||||
|
||||
// Now draw the tool-tips for everything combined
|
||||
_player.hoverInfoOnlyDraw(offsetP.x, offsetP.y);
|
||||
|
||||
for (auto &i : _menu._element)
|
||||
i.hoverInfoOnlyDraw(offsetM.x, offsetM.y);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Handle Events
|
||||
//------------------------------------------------------------------------
|
||||
void MapMarkerMenu::handleEvents(const Element &pos, const Vector2i &playerPos, const Rect &camera, const Common::Event &event) {
|
||||
if (playerPos.x >= camera.x && playerPos.y >= camera.y)
|
||||
(void)_player.handleEvents(event, pos.x + playerPos.x - camera.x + _offset._player.x,
|
||||
pos.y + playerPos.y - camera.y + _offset._player.y);
|
||||
|
||||
int choice = _menu.handleEvents(event, pos.x - camera.x + _offset._marker.x, pos.y - camera.y + _offset._marker.y);
|
||||
if (choice != -1) {
|
||||
int c = 0;
|
||||
for (auto &i : _menu._element) {
|
||||
if (c == choice) // For an already selected marker, clicking it toggles the selection state
|
||||
i.state(!i.state());
|
||||
else
|
||||
i.state(false);
|
||||
|
||||
++c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Internal Events
|
||||
//------------------------------------------------------------------------
|
||||
void MapMarkerMenu::internalEvents(const Element &pos, const Vector2i &playerPos, const Rect &camera, Rect bounds) {
|
||||
// Find if the player marker is visible or not
|
||||
{
|
||||
Rect r(pos.x + playerPos.x - _offset._marker.x - camera.x,
|
||||
pos.y + playerPos.y - _offset._marker.y - camera.y,
|
||||
_player.w + _offset._marker.x,
|
||||
_player.h + _offset._marker.y);
|
||||
|
||||
_player._visible = bounds.contains(r);
|
||||
}
|
||||
|
||||
// Redefine p for marker buttons
|
||||
Vector2i p(pos.x - camera.x + _offset._marker.x, pos.y - camera.y + _offset._marker.y);
|
||||
|
||||
// Calculate visibility for each marker
|
||||
for (auto &i : _menu._element) {
|
||||
Rect r(i.x + p.x - _offset._marker.x, i.y + p.y - _offset._marker.y,
|
||||
i.w + _offset._marker.x, i.h + _offset._marker.y);
|
||||
|
||||
i._visible = bounds.contains(r);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Reposition UI
|
||||
//------------------------------------------------------------------------
|
||||
void MapMarkerMenu::setUI() {
|
||||
_player.setUI();
|
||||
_menu.setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
105
engines/crab/ui/MapMarkerMenu.h
Normal file
105
engines/crab/ui/MapMarkerMenu.h
Normal file
@@ -0,0 +1,105 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_MAPMARKERMENU_H
|
||||
#define CRAB_MAPMARKERMENU_H
|
||||
|
||||
#include "crab/ui/menu.h"
|
||||
#include "crab/ui/StateButton.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class MapMarkerMenu {
|
||||
// The reference map marker
|
||||
StateButton _ref;
|
||||
|
||||
// The menu containing all the map markers
|
||||
Menu<StateButton> _menu;
|
||||
|
||||
// The offset at which every map marker is drawn (used to compensate for icon design width)
|
||||
struct {
|
||||
Vector2i _marker, _player;
|
||||
} _offset;
|
||||
|
||||
// The button for the player's current position
|
||||
Button _player;
|
||||
|
||||
public:
|
||||
MapMarkerMenu() {}
|
||||
~MapMarkerMenu() {}
|
||||
|
||||
void addButton(const Common::String &name, const int &x, const int &y) {
|
||||
StateButton b;
|
||||
b.init(_ref, x, y);
|
||||
b._tooltip._text = name;
|
||||
_menu._element.push_back(b);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
_menu._element.clear();
|
||||
}
|
||||
|
||||
void assignPaths() {
|
||||
_menu.assignPaths();
|
||||
}
|
||||
|
||||
void selectDest(const Common::String &name) {
|
||||
for (auto &i : _menu._element)
|
||||
i.state(i._tooltip._text == name);
|
||||
}
|
||||
|
||||
void erase(const Common::String &name) {
|
||||
for (auto i = _menu._element.begin(); i != _menu._element.end(); ++i) {
|
||||
if (i->_tooltip._text == name) {
|
||||
_menu._element.erase(i);
|
||||
assignPaths();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
|
||||
void draw(const Element &pos, const Vector2i &player_pos, const Rect &camera);
|
||||
|
||||
void handleEvents(const Element &pos, const Vector2i &playerPos, const Rect &camera, const Common::Event &event);
|
||||
|
||||
void internalEvents(const Element &pos, const Vector2i &playerPos, const Rect &camera, Rect bounds);
|
||||
|
||||
void setUI();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_MAPMARKERMENU_H
|
||||
124
engines/crab/ui/ModMenu.cpp
Normal file
124
engines/crab/ui/ModMenu.cpp
Normal 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/XMLDoc.h"
|
||||
#include "crab/ui/ModMenu.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
|
||||
void ModMenu::load(const Common::Path &filename) {
|
||||
XMLDoc conf(filename);
|
||||
if (conf.ready()) {
|
||||
rapidxml::xml_node<char> *node = conf.doc()->first_node("mod_menu");
|
||||
|
||||
if (nodeValid("bg", node))
|
||||
_bg.load(node->first_node("bg"));
|
||||
|
||||
if (nodeValid("menu", node))
|
||||
_menu.load(node->first_node("menu"));
|
||||
|
||||
if (nodeValid("preview", node)) {
|
||||
auto prnode = node->first_node("preview");
|
||||
_img._pos.load(prnode);
|
||||
loadPath(_img._noPreviewPath, "path", prnode);
|
||||
}
|
||||
|
||||
if (nodeValid("offset", node)) {
|
||||
rapidxml::xml_node<char> *offnode = node->first_node("offset");
|
||||
|
||||
// Stuff displayed on the slot button
|
||||
tdB[DATA_SAVENAME].load(offnode->first_node("mod_name"));
|
||||
tdB[DATA_LASTMODIFIED].load(offnode->first_node("last_modified"));
|
||||
|
||||
// Stuff displayed when you hover over a slot button
|
||||
tdH[DATA_AUTHOR].load(offnode->first_node("author"));
|
||||
tdH[DATA_VERSION].load(offnode->first_node("version"));
|
||||
tdH[DATA_INFO].load(offnode->first_node("info"));
|
||||
tdH[DATA_WEBSITE].load(offnode->first_node("website"));
|
||||
|
||||
// Titles for the stuff displayed when you hover over a slot button
|
||||
hov[DATA_AUTHOR].load(offnode->first_node("author_title"));
|
||||
hov[DATA_VERSION].load(offnode->first_node("info_title"));
|
||||
hov[DATA_INFO].load(offnode->first_node("version_title"));
|
||||
hov[DATA_WEBSITE].load(offnode->first_node("website_title"));
|
||||
}
|
||||
|
||||
_extension = g_engine->_filePath->_modExt;
|
||||
_directory = g_engine->_filePath->_modPath;
|
||||
scanDir();
|
||||
}
|
||||
}
|
||||
|
||||
bool ModMenu::handleEvents(const Common::Event &event) {
|
||||
int choice = _menu.handleEvents(event);
|
||||
if (choice >= 0) {
|
||||
g_engine->_filePath->_modCur = _slotInfo[_menu.index() + choice]._path;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ModMenu::draw() {
|
||||
_bg.draw();
|
||||
_menu.draw();
|
||||
for (auto i = _menu.index(), count = 0u; i < _menu.indexPlusOne() && i < _slotInfo.size(); i++, count++) {
|
||||
auto base_x = _menu.baseX(count), base_y = _menu.baseY(count);
|
||||
tdB[DATA_SAVENAME].draw(_slotInfo[i]._name, base_x, base_y);
|
||||
tdB[DATA_LASTMODIFIED].draw(_slotInfo[i]._lastModified, base_x, base_y);
|
||||
}
|
||||
|
||||
if (_menu.hoverIndex() >= 0) {
|
||||
int i = _menu.hoverIndex();
|
||||
|
||||
if (!_img._loaded || _prevHover != i) {
|
||||
_img._loaded = true;
|
||||
_prevHover = i;
|
||||
if (!_img._preview.load(_slotInfo[i]._preview))
|
||||
_img._preview.load(_img._noPreviewPath);
|
||||
}
|
||||
|
||||
_hover = true;
|
||||
_img._preview.draw(_img._pos.x, _img._pos.y);
|
||||
|
||||
tdH[DATA_AUTHOR].draw(_slotInfo[i]._author);
|
||||
tdH[DATA_VERSION].draw(_slotInfo[i]._version);
|
||||
tdH[DATA_INFO].draw(_slotInfo[i]._info);
|
||||
tdH[DATA_WEBSITE].draw(_slotInfo[i]._website);
|
||||
|
||||
for (int num = 0; num < DATA_HOVER_TOTAL; ++num)
|
||||
hov[num].draw();
|
||||
} else if (_hover)
|
||||
reset();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
55
engines/crab/ui/ModMenu.h
Normal file
55
engines/crab/ui/ModMenu.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_MODMENU_H
|
||||
#define CRAB_MODMENU_H
|
||||
|
||||
#include "crab/ui/FileMenu.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class ModMenu : public FileMenu<ModFileData> {
|
||||
public:
|
||||
ModMenu() {}
|
||||
~ModMenu() {}
|
||||
|
||||
void load(const Common::Path &filename);
|
||||
|
||||
bool handleEvents(const Common::Event &event);
|
||||
void draw();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_MODMENU_H
|
||||
476
engines/crab/ui/OptionMenu.cpp
Normal file
476
engines/crab/ui/OptionMenu.cpp
Normal file
@@ -0,0 +1,476 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/crab.h"
|
||||
#include "crab/XMLDoc.h"
|
||||
#include "crab/ui/OptionMenu.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::image;
|
||||
using namespace pyrodactyl::music;
|
||||
|
||||
void OptionMenu::load(const Common::Path &filename) {
|
||||
XMLDoc conf(filename);
|
||||
if (conf.ready()) {
|
||||
rapidxml::xml_node<char> *node = conf.doc()->first_node("option");
|
||||
if (nodeValid(node)) {
|
||||
if (nodeValid("bg", node))
|
||||
_bg.load(node->first_node("bg"));
|
||||
|
||||
if (nodeValid("state", node)) {
|
||||
_menu.load(node->first_node("state"));
|
||||
|
||||
if (!_menu._element.empty())
|
||||
_menu._element[0].state(true);
|
||||
}
|
||||
|
||||
if (nodeValid("keybind", node))
|
||||
_keybind.load(node->first_node("keybind"));
|
||||
|
||||
if (nodeValid("controller", node))
|
||||
_conbind.load(node->first_node("controller"));
|
||||
|
||||
if (nodeValid("graphics", node))
|
||||
_gfx.load(node->first_node("graphics"));
|
||||
|
||||
if (nodeValid("general", node))
|
||||
_general.load(node->first_node("general"));
|
||||
|
||||
if (nodeValid("change", node)) {
|
||||
rapidxml::xml_node<char> *chanode = node->first_node("change");
|
||||
|
||||
if (nodeValid("accept", chanode))
|
||||
_accept.load(chanode->first_node("accept"));
|
||||
|
||||
if (nodeValid("cancel", chanode))
|
||||
_cancel.load(chanode->first_node("cancel"));
|
||||
|
||||
if (nodeValid("message", chanode))
|
||||
_noticeRes.load(chanode->first_node("message"));
|
||||
|
||||
if (nodeValid("width", chanode))
|
||||
_promptW.load(chanode->first_node("width"));
|
||||
|
||||
if (nodeValid("height", chanode))
|
||||
_promptH.load(chanode->first_node("height"));
|
||||
|
||||
if (nodeValid("countdown", chanode)) {
|
||||
rapidxml::xml_node<char> *counode = chanode->first_node("countdown");
|
||||
_countdown.load(counode);
|
||||
_timer.load(counode, "time");
|
||||
}
|
||||
|
||||
if (nodeValid("bg", chanode))
|
||||
_questionbox.load(chanode->first_node("bg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OptionMenu::reset() {
|
||||
_keybind.reset();
|
||||
_state = STATE_GENERAL;
|
||||
|
||||
for (uint i = 0; i < _menu._element.size(); ++i)
|
||||
_menu._element[i].state(i == STATE_GENERAL);
|
||||
}
|
||||
|
||||
void OptionMenu::draw(Button &back) {
|
||||
if (_state < STATE_ENTER_W) {
|
||||
_bg.draw();
|
||||
|
||||
switch (_state) {
|
||||
case STATE_GENERAL:
|
||||
_general.draw();
|
||||
break;
|
||||
case STATE_GRAPHICS:
|
||||
_gfx.draw();
|
||||
break;
|
||||
case STATE_KEYBOARD:
|
||||
_keybind.draw();
|
||||
break;
|
||||
case STATE_CONTROLLER:
|
||||
_conbind.draw();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
_menu.draw();
|
||||
back.draw();
|
||||
} else {
|
||||
_questionbox.draw();
|
||||
|
||||
switch (_state) {
|
||||
case STATE_ENTER_W:
|
||||
_promptW.draw();
|
||||
break;
|
||||
case STATE_ENTER_H:
|
||||
_promptH.draw();
|
||||
break;
|
||||
case STATE_CONFIRM:
|
||||
_noticeRes.draw();
|
||||
_countdown.draw(numberToString(_timer.remainingTicks() / 1000));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
_accept.draw();
|
||||
_cancel.draw();
|
||||
}
|
||||
}
|
||||
|
||||
bool OptionMenu::handleEvents(Button &back, const Common::Event &event) {
|
||||
if (_state < STATE_ENTER_W) {
|
||||
switch (_state) {
|
||||
case STATE_GENERAL:
|
||||
_general.handleEvents(event);
|
||||
break;
|
||||
case STATE_KEYBOARD:
|
||||
_keybind.handleEvents(event);
|
||||
break;
|
||||
case STATE_GRAPHICS: {
|
||||
int result = _gfx.handleEvents(event);
|
||||
if (result == 1) {
|
||||
_state = STATE_CONFIRM;
|
||||
_timer.start();
|
||||
_gfx.SetInfo();
|
||||
} else if (result == 2)
|
||||
_state = STATE_ENTER_W;
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return handleTabs(back, event);
|
||||
} else {
|
||||
_questionbox.draw();
|
||||
|
||||
switch (_state) {
|
||||
case STATE_ENTER_W:
|
||||
if (_promptW.handleEvents(event, true) || _accept.handleEvents(event) == BUAC_LCLICK) {
|
||||
g_engine->_screenSettings->_cur.w = stringToNumber<int>(_promptW._text);
|
||||
_state = STATE_ENTER_H;
|
||||
} else if (_cancel.handleEvents(event) == BUAC_LCLICK) {
|
||||
_gfx.SetInfo();
|
||||
_state = STATE_GRAPHICS;
|
||||
}
|
||||
break;
|
||||
case STATE_ENTER_H:
|
||||
if (_promptH.handleEvents(event, true) || _accept.handleEvents(event) == BUAC_LCLICK) {
|
||||
g_engine->_screenSettings->_cur.h = stringToNumber<int>(_promptH._text);
|
||||
_state = STATE_CONFIRM;
|
||||
_timer.start();
|
||||
_gfx.SetInfo();
|
||||
} else if (_cancel.handleEvents(event) == BUAC_LCLICK) {
|
||||
_gfx.SetInfo();
|
||||
_state = STATE_GRAPHICS;
|
||||
}
|
||||
|
||||
break;
|
||||
case STATE_CONFIRM:
|
||||
if (_accept.handleEvents(event) != BUAC_IGNORE) {
|
||||
_state = STATE_GRAPHICS;
|
||||
_timer.stop();
|
||||
} else if (_cancel.handleEvents(event) != BUAC_IGNORE) {
|
||||
_gfx.SetInfo();
|
||||
_state = STATE_GRAPHICS;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
_accept.draw();
|
||||
_cancel.draw();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool OptionMenu::handleTabs(Button &back, const Common::Event &event) {
|
||||
if (back.handleEvents(event) == BUAC_LCLICK) {
|
||||
reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
int choice = _menu.handleEvents(event);
|
||||
if (choice >= 0) {
|
||||
if (choice < 4)
|
||||
for (int i = 0; i < (int)_menu._element.size(); ++i)
|
||||
_menu._element[i].state(i == choice);
|
||||
|
||||
switch (choice) {
|
||||
case 0:
|
||||
_state = STATE_GENERAL;
|
||||
break;
|
||||
case 1:
|
||||
_state = STATE_GRAPHICS;
|
||||
break;
|
||||
case 2:
|
||||
_state = STATE_KEYBOARD;
|
||||
break;
|
||||
case 3:
|
||||
_state = STATE_CONTROLLER;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
// Save settings to file
|
||||
g_engine->_inputManager->save();
|
||||
g_engine->_screenSettings->saveState();
|
||||
g_engine->_musicManager->saveState();
|
||||
saveState();
|
||||
//general.CreateBackup();
|
||||
//g_engine->_screenSettings->CreateBackup();
|
||||
return true;
|
||||
|
||||
case 5:
|
||||
// Revert all changes made to settings and exit
|
||||
//g_engine->_inputManager->RestoreBackup();
|
||||
//keybind.SetCaption();
|
||||
//g_engine->_screenSettings->RestoreBackup();
|
||||
_general.restoreBackup();
|
||||
_general.setUI();
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#if 0
|
||||
bool OptionMenu::handleEvents(Button &back, const SDL_Event &Event) {
|
||||
if (state < STATE_ENTER_W) {
|
||||
bg.draw();
|
||||
|
||||
switch (state) {
|
||||
case STATE_GENERAL:
|
||||
general.handleEvents(Event);
|
||||
break;
|
||||
case STATE_KEYBOARD:
|
||||
keybind.handleEvents(Event);
|
||||
break;
|
||||
case STATE_GRAPHICS: {
|
||||
int result = gfx.handleEvents(Event);
|
||||
if (result == 1) {
|
||||
state = STATE_CONFIRM;
|
||||
timer.Start();
|
||||
g_engine->_screenSettings->SetResolution();
|
||||
gfx.SetInfo();
|
||||
} else if (result == 2)
|
||||
state = STATE_ENTER_W;
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return HandleTabs(back, Event);
|
||||
} else {
|
||||
questionbox.draw();
|
||||
|
||||
switch (state) {
|
||||
case STATE_ENTER_W:
|
||||
if (prompt_w.handleEvents(Event, true) || accept.handleEvents(Event) == BUAC_LCLICK) {
|
||||
g_engine->_screenSettings->cur.w = StringToNumber<int>(prompt_w.text);
|
||||
state = STATE_ENTER_H;
|
||||
} else if (cancel.handleEvents(Event) == BUAC_LCLICK) {
|
||||
g_engine->_screenSettings->RestoreBackup();
|
||||
gfx.SetInfo();
|
||||
state = STATE_GRAPHICS;
|
||||
}
|
||||
break;
|
||||
case STATE_ENTER_H:
|
||||
if (prompt_h.handleEvents(Event, true) || accept.handleEvents(Event) == BUAC_LCLICK) {
|
||||
g_engine->_screenSettings->cur.h = StringToNumber<int>(prompt_h.text);
|
||||
state = STATE_CONFIRM;
|
||||
timer.Start();
|
||||
g_engine->_screenSettings->SetResolution();
|
||||
gfx.SetInfo();
|
||||
} else if (cancel.handleEvents(Event) == BUAC_LCLICK) {
|
||||
g_engine->_screenSettings->RestoreBackup();
|
||||
gfx.SetInfo();
|
||||
state = STATE_GRAPHICS;
|
||||
}
|
||||
|
||||
break;
|
||||
case STATE_CONFIRM:
|
||||
if (accept.handleEvents(Event)) {
|
||||
state = STATE_GRAPHICS;
|
||||
timer.Stop();
|
||||
} else if (cancel.handleEvents(Event)) {
|
||||
g_engine->_screenSettings->RestoreBackup();
|
||||
g_engine->_screenSettings->SetResolution();
|
||||
gfx.SetInfo();
|
||||
state = STATE_GRAPHICS;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
accept.draw();
|
||||
cancel.draw();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool OptionMenu::HandleTabs(Button &back, const SDL_Event &Event) {
|
||||
if (back.handleEvents(Event) == BUAC_LCLICK) {
|
||||
reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
int choice = menu.handleEvents(Event);
|
||||
if (choice >= 0) {
|
||||
if (choice < 4)
|
||||
for (uint i = 0; i < menu.element.size(); ++i)
|
||||
menu.element[i].State(i == choice);
|
||||
|
||||
switch (choice) {
|
||||
case 0:
|
||||
state = STATE_GENERAL;
|
||||
break;
|
||||
case 1:
|
||||
state = STATE_GRAPHICS;
|
||||
break;
|
||||
case 2:
|
||||
state = STATE_KEYBOARD;
|
||||
break;
|
||||
case 3:
|
||||
state = STATE_CONTROLLER;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
// Save settings to file
|
||||
g_engine->_inputManager->Save();
|
||||
saveState();
|
||||
general.CreateBackup();
|
||||
g_engine->_screenSettings->CreateBackup();
|
||||
return true;
|
||||
|
||||
case 5:
|
||||
// Revert all changes made to settings and exit
|
||||
g_engine->_inputManager->RestoreBackup();
|
||||
keybind.SetCaption();
|
||||
g_engine->_screenSettings->RestoreBackup();
|
||||
general.RestoreBackup();
|
||||
|
||||
SDL_DisplayMode current;
|
||||
if (SDL_GetCurrentDisplayMode(0, ¤t) == 0) {
|
||||
if (g_engine->_screenSettings->cur.w != current.w || g_engine->_screenSettings->cur.h != current.h)
|
||||
gfx.SetInfo();
|
||||
}
|
||||
|
||||
g_engine->_screenSettings->SetResolution();
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
void OptionMenu::internalEvents() {
|
||||
// Since these states can be changed at any time, we just update it regularly
|
||||
_gfx.internalEvents();
|
||||
_general.internalEvents();
|
||||
|
||||
if (_state == STATE_CONFIRM && _timer.targetReached()) {
|
||||
_gfx.SetInfo();
|
||||
_state = STATE_GRAPHICS;
|
||||
}
|
||||
}
|
||||
|
||||
void OptionMenu::saveState() {
|
||||
ConfMan.flushToDisk();
|
||||
|
||||
#if 0
|
||||
rapidxml::xml_document<char> doc;
|
||||
|
||||
// xml declaration
|
||||
rapidxml::xml_node<char> *decl = doc.allocate_node(rapidxml::node_declaration);
|
||||
decl->append_attribute(doc.allocate_attribute("version", "1.0"));
|
||||
decl->append_attribute(doc.allocate_attribute("encoding", "utf-8"));
|
||||
doc.append_node(decl);
|
||||
|
||||
// root node
|
||||
rapidxml::xml_node<char> *root = doc.allocate_node(rapidxml::node_element, "settings");
|
||||
g_engine->_screenSettings->saveState(doc, root);
|
||||
g_engine->_musicManager->saveState(doc, root);
|
||||
|
||||
doc.append_node(root);
|
||||
Common::String xml_as_string;
|
||||
rapidxml::print(std::back_inserter(xml_as_string), doc);
|
||||
|
||||
Common::String settingpath = g_engine->_filePath->appdata;
|
||||
settingpath += "settings.xml";
|
||||
|
||||
std::ofstream save(settingpath, std::ios::out);
|
||||
if (save.is_open()) {
|
||||
save << xml_as_string;
|
||||
save.close();
|
||||
}
|
||||
|
||||
doc.clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
void OptionMenu::setUI() {
|
||||
_bg.setUI();
|
||||
_menu.setUI();
|
||||
|
||||
_keybind.setUI();
|
||||
_conbind.setUI();
|
||||
|
||||
_gfx.setUI();
|
||||
_general.setUI();
|
||||
|
||||
_noticeRes.setUI();
|
||||
|
||||
_countdown.setUI();
|
||||
_questionbox.setUI();
|
||||
|
||||
_promptW.setUI();
|
||||
_promptH.setUI();
|
||||
|
||||
_accept.setUI();
|
||||
_cancel.setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
122
engines/crab/ui/OptionMenu.h
Normal file
122
engines/crab/ui/OptionMenu.h
Normal file
@@ -0,0 +1,122 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_OPTIONMENU_H
|
||||
#define CRAB_OPTIONMENU_H
|
||||
|
||||
#include "crab/timer.h"
|
||||
#include "crab/ui/GeneralSettingMenu.h"
|
||||
#include "crab/ui/GfxSettingMenu.h"
|
||||
#include "crab/ui/ImageData.h"
|
||||
#include "crab/ui/KeyBindMenu.h"
|
||||
#include "crab/ui/StateButton.h"
|
||||
#include "crab/ui/ToggleButton.h"
|
||||
#include "crab/ui/slider.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class OptionMenu {
|
||||
// What overall state the menu is in
|
||||
enum {
|
||||
STATE_GENERAL,
|
||||
STATE_GRAPHICS,
|
||||
STATE_KEYBOARD,
|
||||
STATE_CONTROLLER,
|
||||
STATE_ENTER_W,
|
||||
STATE_ENTER_H,
|
||||
STATE_CONFIRM
|
||||
} _state;
|
||||
|
||||
// The overall menu for switching between states
|
||||
// The second last button is save, the last button is cancel
|
||||
Menu<StateButton> _menu;
|
||||
|
||||
// The background image
|
||||
ImageData _bg;
|
||||
|
||||
// The graphical settings menu
|
||||
GfxSettingMenu _gfx;
|
||||
|
||||
// The general settings menu
|
||||
GeneralSettingMenu _general;
|
||||
|
||||
// Keyboard controls menu
|
||||
KeyBindMenu _keybind;
|
||||
|
||||
// The controller controls are just drawn in a single image, no reassign options
|
||||
ImageData _conbind;
|
||||
|
||||
// The UI for accepting/rejecting change in resolution
|
||||
HoverInfo _noticeRes;
|
||||
ImageData _questionbox;
|
||||
Button _accept, _cancel;
|
||||
|
||||
// If the user wants to input a custom resolution, these are used along with the question box
|
||||
TextArea _promptW, _promptH;
|
||||
|
||||
// The countdown until the timer resets
|
||||
TextData _countdown;
|
||||
Timer _timer;
|
||||
|
||||
// Function to draw the main menu (controls, settings, save, cancel)
|
||||
bool handleTabs(Button &back, const Common::Event &event);
|
||||
|
||||
public:
|
||||
bool _loaded;
|
||||
|
||||
OptionMenu() {
|
||||
_loaded = false;
|
||||
_state = STATE_GENERAL;
|
||||
_menu.useKeyboard(true);
|
||||
}
|
||||
~OptionMenu() {}
|
||||
|
||||
void reset();
|
||||
bool disableHotkeys() {
|
||||
return _keybind.disableHotkeys();
|
||||
}
|
||||
|
||||
void load(const Common::Path &filename);
|
||||
void draw(Button &back);
|
||||
bool handleEvents(Button &back, const Common::Event &event);
|
||||
void internalEvents();
|
||||
|
||||
void setUI();
|
||||
void saveState();
|
||||
};
|
||||
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_OPTIONMENU_H
|
||||
117
engines/crab/ui/OptionSelect.cpp
Normal file
117
engines/crab/ui/OptionSelect.cpp
Normal file
@@ -0,0 +1,117 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/ui/OptionSelect.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::text;
|
||||
using namespace pyrodactyl::ui;
|
||||
|
||||
void OptionSelect::load(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid(node)) {
|
||||
option._data.load(node);
|
||||
_prev.load(node->first_node("prev"));
|
||||
_next.load(node->first_node("next"));
|
||||
_cur = 0;
|
||||
|
||||
option._text.clear();
|
||||
for (auto n = node->first_node("option"); n != nullptr; n = n->next_sibling("option")) {
|
||||
Common::String s;
|
||||
loadStr(s, "name", n);
|
||||
option._text.push_back(s);
|
||||
}
|
||||
|
||||
loadBool(_usekeyboard, "keyboard", node, false);
|
||||
}
|
||||
}
|
||||
|
||||
void OptionSelect::draw() {
|
||||
option.draw(_cur);
|
||||
|
||||
if (_cur > 0)
|
||||
_prev.draw();
|
||||
|
||||
if ((uint)_cur < option._text.size() - 1)
|
||||
_next.draw();
|
||||
}
|
||||
|
||||
bool OptionSelect::handleEvents(const Common::Event &event) {
|
||||
using namespace pyrodactyl::input;
|
||||
|
||||
if (_cur > 0) {
|
||||
// Don't check for keyboard inputs for now
|
||||
if (_prev.handleEvents(event) == BUAC_LCLICK) {
|
||||
_cur--;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((uint)_cur < option._text.size() - 1) {
|
||||
|
||||
// Don't check for keyboard inputs for now
|
||||
if (_next.handleEvents(event) == BUAC_LCLICK) {
|
||||
_cur++;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#if 0
|
||||
bool OptionSelect::handleEvents(const SDL_Event &Event) {
|
||||
using namespace pyrodactyl::input;
|
||||
|
||||
if (cur > 0) {
|
||||
if (prev.handleEvents(Event) == BUAC_LCLICK || (usekeyboard && g_engine->_inputManager->Equals(IU_LEFT, Event) == SDL_PRESSED)) {
|
||||
cur--;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (cur < option.text.size() - 1) {
|
||||
if (next.handleEvents(Event) == BUAC_LCLICK || (usekeyboard && g_engine->_inputManager->Equals(IU_RIGHT, Event) == SDL_PRESSED)) {
|
||||
cur++;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
void OptionSelect::setUI() {
|
||||
option._data.setUI();
|
||||
_prev.setUI();
|
||||
_next.setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
75
engines/crab/ui/OptionSelect.h
Normal file
75
engines/crab/ui/OptionSelect.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_OPTIONSELECT_H
|
||||
#define CRAB_OPTIONSELECT_H
|
||||
|
||||
#include "crab/ui/button.h"
|
||||
#include "crab/ui/TextData.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class OptionSelect {
|
||||
struct {
|
||||
Common::Array<Common::String> _text;
|
||||
TextData _data;
|
||||
|
||||
void draw(const int &index) {
|
||||
if (index >= 0 && (uint)index < _text.size())
|
||||
_data.draw(_text[index]);
|
||||
}
|
||||
} option;
|
||||
|
||||
Button _prev, _next;
|
||||
bool _usekeyboard;
|
||||
|
||||
public:
|
||||
int _cur;
|
||||
|
||||
OptionSelect() {
|
||||
_cur = 0;
|
||||
_usekeyboard = false;
|
||||
}
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
|
||||
void draw();
|
||||
|
||||
bool handleEvents(const Common::Event &event);
|
||||
|
||||
void setUI();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_OPTIONSELECT_H
|
||||
265
engines/crab/ui/PageMenu.h
Normal file
265
engines/crab/ui/PageMenu.h
Normal file
@@ -0,0 +1,265 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_PAGEMENU_H
|
||||
#define CRAB_PAGEMENU_H
|
||||
|
||||
#include "crab/ui/menu.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
// Sometimes we need multiple pages in a menu, this object does that
|
||||
// Used in save, load, mod and quest menu
|
||||
template<typename T>
|
||||
class PageMenu {
|
||||
// The buttons for cycling between pages of the menu
|
||||
Button _prev, _next;
|
||||
|
||||
// Each page is stored separately in a menu object
|
||||
Common::Array<Menu<T>> _menu;
|
||||
|
||||
// Keep track of which page we are at, and how many elements we keep in a page
|
||||
uint _currentPage, _elementsPerPage, _rows, _cols;
|
||||
|
||||
// The image used for the elements
|
||||
Button _ref;
|
||||
|
||||
// This vector stores the increments in x,y for each new button
|
||||
Vector2i _inc;
|
||||
|
||||
// Display "Page 1 of 3" style information for the menu
|
||||
TextData _status;
|
||||
Common::String _info;
|
||||
|
||||
public:
|
||||
PageMenu() {
|
||||
_currentPage = 0;
|
||||
_elementsPerPage = 1;
|
||||
_rows = 1;
|
||||
_cols = 1;
|
||||
clear();
|
||||
}
|
||||
~PageMenu() {}
|
||||
|
||||
void reset() {
|
||||
for (auto &m : _menu)
|
||||
m.reset();
|
||||
}
|
||||
|
||||
void clear() {
|
||||
_menu.resize(1);
|
||||
_menu[0].clear();
|
||||
_menu[0].useKeyboard(true);
|
||||
}
|
||||
|
||||
// Get the elements per page
|
||||
uint elementsPerPage() {
|
||||
return _elementsPerPage;
|
||||
}
|
||||
|
||||
// This is added to the result from handleEvents to calculate the exact position
|
||||
uint index() {
|
||||
return _currentPage * _elementsPerPage;
|
||||
}
|
||||
|
||||
// The end position of the elements
|
||||
uint indexPlusOne() {
|
||||
return (_currentPage + 1) * _elementsPerPage;
|
||||
}
|
||||
|
||||
// Get the current page of the menu
|
||||
uint currentPage() {
|
||||
return _currentPage;
|
||||
}
|
||||
|
||||
void currentPage(int &val) {
|
||||
_currentPage = val;
|
||||
}
|
||||
|
||||
// Get the index of the hovered element in the menu
|
||||
int hoverIndex() {
|
||||
if (_menu[_currentPage].hoverIndex() >= 0)
|
||||
return (_currentPage * _elementsPerPage) + _menu[_currentPage].hoverIndex();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get the base position of the elements
|
||||
int baseX(const int &count) {
|
||||
return _ref.x + _inc.x * (count % _cols);
|
||||
}
|
||||
|
||||
int baseY(const int &count) {
|
||||
return _ref.y + _inc.y * (count / _cols);
|
||||
}
|
||||
|
||||
// This is used to get the coordinates of a button
|
||||
const int &curX(const int &count) {
|
||||
return _menu[_currentPage]._element[count].x;
|
||||
}
|
||||
|
||||
const int &curY(const int &count) {
|
||||
return _menu[_currentPage]._element[count].y;
|
||||
}
|
||||
|
||||
void image(const int &slot, const int &page, ButtonImage &bi) {
|
||||
_menu[page]._element[slot].img(bi);
|
||||
}
|
||||
|
||||
void assignPaths() {
|
||||
for (auto &m : _menu)
|
||||
m.assignPaths();
|
||||
}
|
||||
|
||||
void useKeyboard(const bool &val) {
|
||||
for (auto &m : _menu)
|
||||
m.useKeyboard(val);
|
||||
}
|
||||
|
||||
void setUI() {
|
||||
_prev.setUI();
|
||||
_next.setUI();
|
||||
_ref.setUI();
|
||||
_status.setUI();
|
||||
|
||||
for (auto &m : _menu)
|
||||
m.setUI();
|
||||
}
|
||||
|
||||
void updateInfo() {
|
||||
_info = numberToString(_currentPage + 1);
|
||||
_info += " of ";
|
||||
_info += numberToString(_menu.size());
|
||||
}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node) {
|
||||
using namespace pyrodactyl::input;
|
||||
if (nodeValid(node)) {
|
||||
if (nodeValid("prev", node)) {
|
||||
_prev.load(node->first_node("prev"));
|
||||
_prev._hotkey.set(IU_PREV);
|
||||
}
|
||||
|
||||
if (nodeValid("next", node)) {
|
||||
_next.load(node->first_node("next"));
|
||||
_next._hotkey.set(IU_NEXT);
|
||||
}
|
||||
|
||||
if (nodeValid("reference", node))
|
||||
_ref.load(node->first_node("reference"));
|
||||
|
||||
if (nodeValid("inc", node))
|
||||
_inc.load(node->first_node("inc"));
|
||||
|
||||
if (nodeValid("status", node))
|
||||
_status.load(node->first_node("status"));
|
||||
|
||||
if (nodeValid("dim", node)) {
|
||||
rapidxml::xml_node<char> *dimnode = node->first_node("dim");
|
||||
loadNum(_rows, "rows", dimnode);
|
||||
loadNum(_cols, "cols", dimnode);
|
||||
_elementsPerPage = _rows * _cols;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void add(uint &slot, uint &page) {
|
||||
if (slot >= _elementsPerPage) {
|
||||
++page;
|
||||
slot = 0;
|
||||
_menu.resize(page + 1);
|
||||
_menu[page].useKeyboard(true);
|
||||
}
|
||||
|
||||
T b;
|
||||
b.init(_ref, _inc.x * (slot % _cols), _inc.y * (slot / _cols));
|
||||
_menu[page]._element.push_back(b);
|
||||
++slot;
|
||||
|
||||
assignPaths();
|
||||
updateInfo();
|
||||
}
|
||||
|
||||
void add() {
|
||||
uint page = _menu.size() - 1;
|
||||
uint slot = _menu[page]._element.size();
|
||||
add(slot, page);
|
||||
}
|
||||
|
||||
void erase() {
|
||||
uint page = _menu.size() - 1;
|
||||
_menu[page]._element.pop_back();
|
||||
assignPaths();
|
||||
updateInfo();
|
||||
}
|
||||
|
||||
int handleEvents(const Common::Event &event) {
|
||||
using namespace pyrodactyl::input;
|
||||
|
||||
if (_currentPage > 0 && _prev.handleEvents(event) == BUAC_LCLICK) {
|
||||
_currentPage--;
|
||||
updateInfo();
|
||||
|
||||
if ((int)_currentPage < 0)
|
||||
_currentPage = 0;
|
||||
}
|
||||
|
||||
if (_currentPage < _menu.size() - 1 && _next.handleEvents(event) == BUAC_LCLICK) {
|
||||
_currentPage++;
|
||||
updateInfo();
|
||||
|
||||
if (_currentPage >= _menu.size())
|
||||
_currentPage = _menu.size() - 1;
|
||||
}
|
||||
|
||||
return _menu[_currentPage].handleEvents(event);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
_status.draw(_info);
|
||||
_menu[_currentPage].draw();
|
||||
|
||||
if (_currentPage > 0)
|
||||
_prev.draw();
|
||||
|
||||
if (_currentPage < _menu.size() - 1)
|
||||
_next.draw();
|
||||
}
|
||||
};
|
||||
|
||||
typedef PageMenu<Button> PageButtonMenu;
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_PAGEMENU_H
|
||||
49
engines/crab/ui/ParagraphData.cpp
Normal file
49
engines/crab/ui/ParagraphData.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/crab.h"
|
||||
#include "crab/ui/ParagraphData.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
|
||||
bool ParagraphData::load(rapidxml::xml_node<char> *node, Rect *parent, const bool &echo) {
|
||||
if (nodeValid("line", node))
|
||||
_line.load(node->first_node("line"));
|
||||
|
||||
return TextData::load(node, parent, echo);
|
||||
}
|
||||
|
||||
void ParagraphData::draw(const Common::String &val, const int &xOffset, const int &yOffset) {
|
||||
g_engine->_textManager->draw(x + xOffset, y + yOffset, val, _col, _font, _align, _line.x, _line.y);
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
56
engines/crab/ui/ParagraphData.h
Normal file
56
engines/crab/ui/ParagraphData.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_PARAGRAPHDATA_H
|
||||
#define CRAB_PARAGRAPHDATA_H
|
||||
|
||||
#include "crab/ui/TextData.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class ParagraphData : public TextData {
|
||||
public:
|
||||
Vector2i _line;
|
||||
|
||||
ParagraphData() : _line(1, 1) {}
|
||||
~ParagraphData() {}
|
||||
|
||||
bool load(rapidxml::xml_node<char> *node, Rect *parent = nullptr, const bool &echo = true);
|
||||
|
||||
void draw(const Common::String &val, const int &xOffset = 0, const int &yOffset = 0);
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_PARAGRAPHDATA_H
|
||||
131
engines/crab/ui/PauseMenu.cpp
Normal file
131
engines/crab/ui/PauseMenu.cpp
Normal file
@@ -0,0 +1,131 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/ui/PauseMenu.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::image;
|
||||
|
||||
void PauseMenu::load(rapidxml::xml_node<char> *node) {
|
||||
_menu.load(node->first_node("menu"));
|
||||
_save.load(node->first_node("save"));
|
||||
|
||||
if (nodeValid("bg", node))
|
||||
_bg.load(node->first_node("bg"));
|
||||
}
|
||||
|
||||
bool PauseMenu::draw(Button &back) {
|
||||
switch (_state) {
|
||||
case STATE_NORMAL:
|
||||
_bg.draw();
|
||||
_menu.draw();
|
||||
break;
|
||||
case STATE_OPTION:
|
||||
g_engine->_optionMenu->draw(back);
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
PauseSignal PauseMenu::handleEvents(const Common::Event &event, Button &back) {
|
||||
switch (_state) {
|
||||
case STATE_NORMAL:
|
||||
_choice = _menu.handleEvents(event);
|
||||
if (_choice == -1) {
|
||||
if (back._hotkey.handleEvents(event))
|
||||
return PS_RESUME;
|
||||
} else {
|
||||
switch (_choice) {
|
||||
case 0:
|
||||
_state = STATE_NORMAL;
|
||||
return PS_RESUME;
|
||||
case 1:
|
||||
if (g_engine->saveGameDialog()) {
|
||||
_state = STATE_NORMAL;
|
||||
return PS_SAVE;
|
||||
} else
|
||||
_state = STATE_NORMAL;
|
||||
break;
|
||||
case 2:
|
||||
if (g_engine->loadGameDialog()) {
|
||||
_state = STATE_NORMAL;
|
||||
return PS_LOAD;
|
||||
} else
|
||||
_state = STATE_NORMAL;
|
||||
break;
|
||||
case 3:
|
||||
_state = STATE_OPTION;
|
||||
break;
|
||||
case 4:
|
||||
return PS_HELP;
|
||||
case 5:
|
||||
return PS_QUIT_MENU;
|
||||
case 6:
|
||||
return PS_QUIT_GAME;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case STATE_OPTION:
|
||||
if (g_engine->_optionMenu->handleEvents(back, event)) {
|
||||
g_engine->_optionMenu->reset();
|
||||
_state = STATE_NORMAL;
|
||||
}
|
||||
break;
|
||||
case STATE_LOAD:
|
||||
if (g_engine->loadGameDialog())
|
||||
return PS_LOAD;
|
||||
else
|
||||
_state = STATE_NORMAL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return PS_NONE;
|
||||
}
|
||||
|
||||
bool PauseMenu::disableHotkeys() {
|
||||
return (_state == STATE_SAVE && _save.disableHotkeys()) || (_state == STATE_OPTION && g_engine->_optionMenu->disableHotkeys());
|
||||
}
|
||||
|
||||
void PauseMenu::setUI() {
|
||||
_bg.setUI();
|
||||
_menu.setUI();
|
||||
_save.setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
124
engines/crab/ui/PauseMenu.h
Normal file
124
engines/crab/ui/PauseMenu.h
Normal 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_PAUSEMENU_H
|
||||
#define CRAB_PAUSEMENU_H
|
||||
|
||||
#include "crab/event/GameEventInfo.h"
|
||||
#include "crab/ui/FileMenu.h"
|
||||
#include "crab/ui/menu.h"
|
||||
#include "crab/ui/OptionMenu.h"
|
||||
#include "crab/ui/SaveGameMenu.h"
|
||||
#include "crab/ui/slider.h"
|
||||
#include "crab/ui/SlideShow.h"
|
||||
#include "crab/ui/textarea.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
enum PauseSignal {
|
||||
PS_NONE,
|
||||
PS_RESUME,
|
||||
PS_SAVE,
|
||||
PS_LOAD,
|
||||
PS_HELP,
|
||||
PS_QUIT_MENU,
|
||||
PS_QUIT_GAME
|
||||
};
|
||||
|
||||
class PauseMenu {
|
||||
enum PauseState {
|
||||
STATE_NORMAL,
|
||||
STATE_SAVE,
|
||||
STATE_OPTION,
|
||||
STATE_LOAD
|
||||
} _state;
|
||||
|
||||
// The pause menu background
|
||||
ImageData _bg;
|
||||
|
||||
// The buttons in the menu
|
||||
ButtonMenu _menu;
|
||||
|
||||
// Save game menu
|
||||
GameSaveMenu _save;
|
||||
|
||||
// The selected main menu button
|
||||
int _choice;
|
||||
|
||||
public:
|
||||
PauseMenu() {
|
||||
_state = STATE_NORMAL;
|
||||
_choice = -1;
|
||||
}
|
||||
|
||||
~PauseMenu() {}
|
||||
|
||||
void updateMode(const bool &ironman) {
|
||||
_menu._element[PS_SAVE - 1]._visible = !ironman;
|
||||
_menu._element[PS_LOAD - 1]._visible = !ironman;
|
||||
}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
|
||||
PauseSignal handleEvents(const Common::Event &event, Button &back);
|
||||
|
||||
// Returns true if inside options menu, false otherwise
|
||||
bool draw(Button &back);
|
||||
|
||||
void reset() {
|
||||
_state = STATE_NORMAL;
|
||||
}
|
||||
|
||||
void scanDir() {
|
||||
_save.scanDir();
|
||||
}
|
||||
|
||||
Common::String saveFile() {
|
||||
return _save.selectedPath();
|
||||
}
|
||||
|
||||
bool disableHotkeys();
|
||||
|
||||
// Should we allow the pause key(default escape) to quit to main menu?
|
||||
// This is done because esc is both the "go back on menu level" and the pause key
|
||||
bool showLevel() {
|
||||
return _state == STATE_NORMAL;
|
||||
}
|
||||
|
||||
void setUI();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_PAUSEMENU_H
|
||||
174
engines/crab/ui/PersonHandler.cpp
Normal file
174
engines/crab/ui/PersonHandler.cpp
Normal file
@@ -0,0 +1,174 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/animation/sprite.h"
|
||||
#include "crab/ui/PersonHandler.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::text;
|
||||
using namespace pyrodactyl::image;
|
||||
using namespace pyrodactyl::people;
|
||||
|
||||
void PersonHandler::load(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid("dialog", node))
|
||||
_dlbox.load(node->first_node("dialog"));
|
||||
|
||||
if (nodeValid("opinion", node)) {
|
||||
rapidxml::xml_node<char> *opnode = node->first_node("opinion");
|
||||
|
||||
if (nodeValid("friendship", opnode))
|
||||
_opinion[OPI_LIKE].load(opnode->first_node("friendship"));
|
||||
|
||||
if (nodeValid("respect", opnode))
|
||||
_opinion[OPI_RESPECT].load(opnode->first_node("respect"));
|
||||
|
||||
if (nodeValid("fear", opnode))
|
||||
_opinion[OPI_FEAR].load(opnode->first_node("fear"));
|
||||
}
|
||||
|
||||
if (nodeValid("image", node)) {
|
||||
rapidxml::xml_node<char> *imgnode = node->first_node("image");
|
||||
_img.load(imgnode);
|
||||
|
||||
if (nodeValid("sprite_align", imgnode))
|
||||
_spriteAlign.load(imgnode->first_node("sprite_align"));
|
||||
}
|
||||
|
||||
if (nodeValid("name", node))
|
||||
_name.load(node->first_node("name"));
|
||||
|
||||
if (nodeValid("journal", node))
|
||||
_jb.load(node->first_node("journal"));
|
||||
}
|
||||
|
||||
void PersonHandler::draw(pyrodactyl::event::Info &info, pyrodactyl::event::GameEvent *event, const Common::String &personId,
|
||||
const bool &player, pyrodactyl::anim::Sprite *s) {
|
||||
// Draw the dialog box background
|
||||
_dlbox.draw(player);
|
||||
|
||||
if (s != nullptr) {
|
||||
Rect r = s->dialogClip(event->_state);
|
||||
int x = _img.x, y = _img.y;
|
||||
|
||||
if (_spriteAlign._x == ALIGN_CENTER)
|
||||
x -= r.w / 2;
|
||||
else if (_spriteAlign._x == ALIGN_RIGHT)
|
||||
x -= r.w;
|
||||
|
||||
if (_spriteAlign._y == ALIGN_CENTER)
|
||||
y -= r.h / 2;
|
||||
else if (_spriteAlign._y == ALIGN_RIGHT)
|
||||
y -= r.h;
|
||||
|
||||
g_engine->_imageManager->draw(x, y, s->img(), &r);
|
||||
}
|
||||
|
||||
if (info.personValid(personId)) {
|
||||
_name.draw(info.personGet(personId)._name);
|
||||
|
||||
if (!player) {
|
||||
_opinion[OPI_LIKE].draw(info.personGet(personId)._opinion._val[OPI_LIKE], OPINION_MAX);
|
||||
_opinion[OPI_RESPECT].draw(info.personGet(personId)._opinion._val[OPI_RESPECT], OPINION_MAX);
|
||||
_opinion[OPI_FEAR].draw(info.personGet(personId)._opinion._val[OPI_FEAR], OPINION_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw the journal button
|
||||
_jb.draw();
|
||||
|
||||
// Draw the dialog box text
|
||||
_dlbox.draw(info, event->_dialog);
|
||||
}
|
||||
|
||||
bool PersonHandler::handleCommonEvents(const Common::Event &event) {
|
||||
(void)_opinion[OPI_LIKE].handleEvents(event);
|
||||
(void)_opinion[OPI_RESPECT].handleEvents(event);
|
||||
(void)_opinion[OPI_FEAR].handleEvents(event);
|
||||
|
||||
if (_jb.handleEvents(event) == BUAC_LCLICK) {
|
||||
// User wants to open their journal
|
||||
_showJournal = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PersonHandler::handleDlboxEvents(const Common::Event &event) {
|
||||
return _dlbox.handleEvents(event);
|
||||
}
|
||||
|
||||
void PersonHandler::internalEvents(const pyrodactyl::people::PersonState &state, pyrodactyl::anim::Sprite *s) {
|
||||
if (s != nullptr)
|
||||
s->dialogUpdateClip(state);
|
||||
}
|
||||
|
||||
void PersonHandler::opinionChange(pyrodactyl::event::Info &info, const Common::String &id, const pyrodactyl::people::OpinionType &type, const int &val) {
|
||||
if (info.personValid(id)) {
|
||||
// First, get the value of the object's opinion
|
||||
int old = 0;
|
||||
info.opinionGet(id, type, old);
|
||||
|
||||
// Update the opinion value to the new one
|
||||
info.opinionChange(id, type, val);
|
||||
|
||||
// Then get the current value of the object's opinion
|
||||
int value = 0;
|
||||
info.opinionGet(id, type, value);
|
||||
|
||||
// Now, send the new and old value of the object's opinion for drawing the change effect
|
||||
_opinion[type].effect(value, old);
|
||||
|
||||
_prev = id;
|
||||
}
|
||||
}
|
||||
|
||||
void PersonHandler::reset(const Common::String &id) {
|
||||
if (_prev != id) {
|
||||
using namespace pyrodactyl::people;
|
||||
_opinion[OPI_LIKE].reset();
|
||||
_opinion[OPI_RESPECT].reset();
|
||||
_opinion[OPI_FEAR].reset();
|
||||
}
|
||||
}
|
||||
|
||||
void PersonHandler::setUI() {
|
||||
_img.setUI();
|
||||
_name.setUI();
|
||||
_dlbox.setUI();
|
||||
_jb.setUI();
|
||||
|
||||
for (auto i = 0; i < pyrodactyl::people::OPI_TOTAL; ++i)
|
||||
_opinion[i].setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
118
engines/crab/ui/PersonHandler.h
Normal file
118
engines/crab/ui/PersonHandler.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_PERSONHANDLER_H
|
||||
#define CRAB_PERSONHANDLER_H
|
||||
|
||||
#include "crab/event/gameevent.h"
|
||||
#include "crab/event/GameEventInfo.h"
|
||||
#include "crab/ui/ProgressBar.h"
|
||||
#include "crab/ui/dialogbox.h"
|
||||
#include "crab/TTSHandler.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace anim {
|
||||
class Sprite;
|
||||
} // End of namespace Sprite
|
||||
|
||||
namespace ui {
|
||||
class PersonHandler : public TTSHandler {
|
||||
// The positions of various elements
|
||||
// img = player image position
|
||||
Element _img;
|
||||
|
||||
// How the individual sprite clips are drawn
|
||||
struct ImageAnchor {
|
||||
Align _x, _y;
|
||||
|
||||
ImageAnchor() {
|
||||
_x = ALIGN_CENTER;
|
||||
_y = ALIGN_RIGHT;
|
||||
}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node, const bool &echo = true) {
|
||||
loadAlign(_x, node, echo, "align_x");
|
||||
loadAlign(_y, node, echo, "align_y");
|
||||
}
|
||||
} _spriteAlign;
|
||||
|
||||
// For drawing the name
|
||||
TextData _name;
|
||||
|
||||
// The dialog box used to draw dialog
|
||||
pyrodactyl::ui::GameDialogBox _dlbox;
|
||||
|
||||
// The three opinion bars
|
||||
pyrodactyl::ui::ProgressBar _opinion[pyrodactyl::people::OPI_TOTAL];
|
||||
|
||||
// The button for selecting the journal
|
||||
Button _jb;
|
||||
|
||||
// The person id of the changed opinion, we use this to reset bar
|
||||
Common::String _prev;
|
||||
|
||||
public:
|
||||
// Used by other objects to see if journal needs to be displayed or not
|
||||
bool _showJournal;
|
||||
|
||||
PersonHandler() {
|
||||
_showJournal = false;
|
||||
}
|
||||
|
||||
~PersonHandler() {}
|
||||
|
||||
void reset(const Common::String &id);
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
|
||||
// Handle events for the three opinion bars and journal - used in both dialog box and reply events
|
||||
bool handleCommonEvents(const Common::Event &event);
|
||||
|
||||
// Handle events for the dialog box
|
||||
bool handleDlboxEvents(const Common::Event &event);
|
||||
|
||||
void internalEvents(const pyrodactyl::people::PersonState &state, pyrodactyl::anim::Sprite *s);
|
||||
|
||||
void draw(pyrodactyl::event::Info &info, pyrodactyl::event::GameEvent *event, const Common::String &personId,
|
||||
const bool &player, pyrodactyl::anim::Sprite *s = nullptr);
|
||||
|
||||
void opinionChange(pyrodactyl::event::Info &info, const Common::String &id,
|
||||
const pyrodactyl::people::OpinionType &type, const int &val);
|
||||
|
||||
void setUI();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_PERSONHANDLER_H
|
||||
103
engines/crab/ui/PersonScreen.cpp
Normal file
103
engines/crab/ui/PersonScreen.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/ui/PersonScreen.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::event;
|
||||
using namespace pyrodactyl::image;
|
||||
using namespace pyrodactyl::people;
|
||||
|
||||
void PersonScreen::load(const Common::Path &filename) {
|
||||
XMLDoc conf(filename);
|
||||
if (conf.ready()) {
|
||||
rapidxml::xml_node<char> *node = conf.doc()->first_node("character");
|
||||
if (nodeValid(node)) {
|
||||
if (nodeValid("bg", node))
|
||||
_bg.load(node->first_node("bg"));
|
||||
|
||||
if (nodeValid("name", node))
|
||||
_name.load(node->first_node("name"));
|
||||
|
||||
if (nodeValid("img", node))
|
||||
_img.load(node->first_node("img"));
|
||||
|
||||
if (nodeValid("menu", node))
|
||||
_menu.load(node->first_node("menu"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PersonScreen::handleEvents(pyrodactyl::event::Info &info, const Common::String &id, const Common::Event &event) {
|
||||
if (info.personValid(id))
|
||||
_menu.handleEvents(&info.personGet(id), event);
|
||||
else
|
||||
_menu.handleEvents(nullptr, event);
|
||||
}
|
||||
|
||||
void PersonScreen::internalEvents() {
|
||||
if (_curSp != nullptr)
|
||||
_curSp->dialogUpdateClip(PST_NORMAL);
|
||||
}
|
||||
|
||||
void PersonScreen::draw(pyrodactyl::event::Info &info, const Common::String &id) {
|
||||
_bg.draw();
|
||||
|
||||
if (info.personValid(id)) {
|
||||
_name.draw(info.personGet(id)._name);
|
||||
_menu.draw(&info.personGet(id));
|
||||
} else
|
||||
_menu.draw(nullptr);
|
||||
|
||||
if (_curSp != nullptr) {
|
||||
Rect clip = _curSp->dialogClip(PST_NORMAL);
|
||||
g_engine->_imageManager->draw(_img.x, _img.y, _curSp->img(), &clip);
|
||||
}
|
||||
}
|
||||
|
||||
void PersonScreen::Cache(Info &info, const Common::String &id, pyrodactyl::level::Level &level) {
|
||||
_curSp = level.getSprite(id);
|
||||
|
||||
if (info.personValid(id))
|
||||
_menu.cache(info.personGet(id));
|
||||
else
|
||||
_menu.clear();
|
||||
}
|
||||
|
||||
void PersonScreen::setUI() {
|
||||
_bg.setUI();
|
||||
_name.setUI();
|
||||
_img.setUI();
|
||||
_menu.setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
86
engines/crab/ui/PersonScreen.h
Normal file
86
engines/crab/ui/PersonScreen.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_PERSONSCREEN_H
|
||||
#define CRAB_PERSONSCREEN_H
|
||||
|
||||
#include "crab/event/gameevent.h"
|
||||
#include "crab/event/GameEventInfo.h"
|
||||
#include "crab/level/level.h"
|
||||
#include "crab/people/person.h"
|
||||
#include "crab/ui/TraitMenu.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace anim {
|
||||
class Sprite;
|
||||
} // End of namespace anim
|
||||
|
||||
namespace ui {
|
||||
class PersonScreen {
|
||||
// The background
|
||||
ImageData _bg;
|
||||
|
||||
// The name of the character
|
||||
TextData _name;
|
||||
|
||||
// The place where the sprite should be drawn
|
||||
Element _img;
|
||||
|
||||
// The buttons for drawing traits
|
||||
TraitMenu _menu;
|
||||
|
||||
// Store the current person sprite temporarily
|
||||
pyrodactyl::anim::Sprite *_curSp;
|
||||
|
||||
public:
|
||||
PersonScreen() {
|
||||
_curSp = nullptr;
|
||||
}
|
||||
|
||||
~PersonScreen() {}
|
||||
|
||||
void load(const Common::Path &filename);
|
||||
void Cache(pyrodactyl::event::Info &info, const Common::String &id, pyrodactyl::level::Level &level);
|
||||
|
||||
void handleEvents(pyrodactyl::event::Info &info, const Common::String &id, const Common::Event &event);
|
||||
|
||||
void internalEvents();
|
||||
void draw(pyrodactyl::event::Info &info, const Common::String &id);
|
||||
|
||||
void setUI();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_PERSONSCREEN_H
|
||||
118
engines/crab/ui/ProgressBar.cpp
Normal file
118
engines/crab/ui/ProgressBar.cpp
Normal file
@@ -0,0 +1,118 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/ui/ProgressBar.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::image;
|
||||
|
||||
void ProgressBar::load(rapidxml::xml_node<char> *node) {
|
||||
ClipButton::load(node);
|
||||
loadNum(_notifyRate, "notify", node);
|
||||
|
||||
if (nodeValid("effect", node)) {
|
||||
rapidxml::xml_node<char> *effnode = node->first_node("effect");
|
||||
loadImgKey(_inc, "inc", effnode);
|
||||
loadImgKey(_dec, "dec", effnode);
|
||||
_offset.load(effnode);
|
||||
}
|
||||
|
||||
if (nodeValid("desc", node)) {
|
||||
rapidxml::xml_node<char> *descnode = node->first_node("desc");
|
||||
for (rapidxml::xml_node<char> *n = descnode->first_node("above"); n != nullptr; n = n->next_sibling("above"))
|
||||
_ct.push_back(n);
|
||||
}
|
||||
}
|
||||
|
||||
void ProgressBar::draw(const int &value, const int &max) {
|
||||
// We don't want divide by zero errors
|
||||
if (max == 0)
|
||||
return;
|
||||
|
||||
// Figure out which text to draw as caption
|
||||
for (auto &i : _ct)
|
||||
if (value > i._val) {
|
||||
_caption._text = i._text;
|
||||
break;
|
||||
}
|
||||
|
||||
// If we don't have to draw animations for changing value, just draw the bar
|
||||
if (!_changed) {
|
||||
_clip.w = (g_engine->_imageManager->getTexture(_img._normal).w() * value) / max;
|
||||
ClipButton::draw();
|
||||
} else {
|
||||
_clip.w = (g_engine->_imageManager->getTexture(_img._normal).w() * _cur) / max;
|
||||
ClipButton::draw();
|
||||
|
||||
switch (_type) {
|
||||
case INCREASE:
|
||||
g_engine->_imageManager->draw(x + _clip.w + _offset.x, y + _offset.y, _inc);
|
||||
if (_timer.targetReached()) {
|
||||
_cur++;
|
||||
_timer.start();
|
||||
}
|
||||
break;
|
||||
case DECREASE:
|
||||
g_engine->_imageManager->draw(x + _clip.w + _offset.x, y + _offset.y, _dec);
|
||||
if (_timer.targetReached()) {
|
||||
_cur--;
|
||||
_timer.start();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (_cur == value)
|
||||
_changed = false;
|
||||
}
|
||||
}
|
||||
|
||||
void ProgressBar::effect(const int &value, const int &prev) {
|
||||
_old = prev;
|
||||
_cur = prev;
|
||||
|
||||
if (value > prev) {
|
||||
_changed = true;
|
||||
_type = INCREASE;
|
||||
_timer.target(_notifyRate * (value - prev));
|
||||
} else if (value < prev) {
|
||||
_changed = true;
|
||||
_type = DECREASE;
|
||||
_timer.target(_notifyRate * (prev - value));
|
||||
} else {
|
||||
_changed = false;
|
||||
_type = NONE;
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
120
engines/crab/ui/ProgressBar.h
Normal file
120
engines/crab/ui/ProgressBar.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_PROGRESSBAR_H
|
||||
#define CRAB_PROGRESSBAR_H
|
||||
|
||||
#include "crab/timer.h"
|
||||
#include "crab/ui/ClipButton.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class ProgressBar : public ClipButton {
|
||||
// Whenever the progress bar value is changed, we display a glowing effect
|
||||
Timer _timer;
|
||||
|
||||
// The total time for which the change effect must be shown
|
||||
uint32 _notifyRate;
|
||||
|
||||
// Are we currently displaying the effect?
|
||||
bool _changed;
|
||||
|
||||
// The effect also depends on if the change was positive or negative, so store the previous value
|
||||
int _old;
|
||||
|
||||
// If we are drawing an animation, we need to smoothly transition from old->value
|
||||
// This stores the current progress
|
||||
int _cur;
|
||||
|
||||
// The type of effect being drawn
|
||||
enum {
|
||||
NONE,
|
||||
INCREASE,
|
||||
DECREASE
|
||||
} _type;
|
||||
|
||||
// We reuse the button images for the 2 types of effect
|
||||
ImageKey _inc, _dec;
|
||||
|
||||
// Where to draw the effect
|
||||
Vector2i _offset;
|
||||
|
||||
// The caption text changes depending on the value of the progress bar - we store all possible text here
|
||||
struct CaptionText {
|
||||
// The text to be drawn
|
||||
Common::String _text;
|
||||
|
||||
// The above text is drawn only if the progress bar value is greater than this val
|
||||
int _val;
|
||||
|
||||
CaptionText() {
|
||||
_val = 0;
|
||||
}
|
||||
|
||||
CaptionText(rapidxml::xml_node<char> *node) {
|
||||
if (!loadNum(_val, "val", node))
|
||||
_val = 0;
|
||||
|
||||
if (!loadStr(_text, "text", node))
|
||||
_text = "";
|
||||
}
|
||||
};
|
||||
|
||||
Common::Array<CaptionText> _ct;
|
||||
|
||||
public:
|
||||
ProgressBar() {
|
||||
_old = 0;
|
||||
_cur = 0;
|
||||
_inc = 0;
|
||||
_dec = 0;
|
||||
_notifyRate = 5;
|
||||
reset();
|
||||
}
|
||||
~ProgressBar() {}
|
||||
|
||||
// Reset the effect
|
||||
void reset() {
|
||||
_changed = false;
|
||||
_type = NONE;
|
||||
}
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
|
||||
void draw(const int &value, const int &max);
|
||||
void effect(const int &value, const int &prev);
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_PROGRESSBAR_H
|
||||
159
engines/crab/ui/QuestText.cpp
Normal file
159
engines/crab/ui/QuestText.cpp
Normal file
@@ -0,0 +1,159 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/crab.h"
|
||||
#include "crab/ui/QuestText.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::text;
|
||||
using namespace pyrodactyl::input;
|
||||
|
||||
void QuestText::load(rapidxml::xml_node<char> *node) {
|
||||
ParagraphData::load(node);
|
||||
loadNum(_colS, "color_s", node);
|
||||
|
||||
if (nodeValid("line", node))
|
||||
loadNum(_linesPerPage, "page", node->first_node("line"));
|
||||
|
||||
if (nodeValid("inc", node))
|
||||
_inc.load(node->first_node("inc"));
|
||||
|
||||
if (nodeValid("img", node))
|
||||
_img.load(node->first_node("img"));
|
||||
|
||||
if (nodeValid("prev", node)) {
|
||||
_prev.load(node->first_node("prev"));
|
||||
_prev._hotkey.set(IU_PAGE_PREV);
|
||||
}
|
||||
|
||||
if (nodeValid("next", node)) {
|
||||
_next.load(node->first_node("next"));
|
||||
_next._hotkey.set(IU_PAGE_NEXT);
|
||||
}
|
||||
|
||||
if (nodeValid("status", node))
|
||||
_status.load(node->first_node("status"));
|
||||
}
|
||||
|
||||
void QuestText::draw(pyrodactyl::event::Quest &q) {
|
||||
// First, we must scan and find the part of the quest text we should draw
|
||||
|
||||
// Assign default values to start and stop
|
||||
_start = 0;
|
||||
_stop = q._text.size();
|
||||
|
||||
// Keep count of lines and pages - remember a single entry can take more than one line
|
||||
uint pageCount = 0, pageStart = 0;
|
||||
|
||||
// Start from line 0, page 0 and scan the list of entries
|
||||
for (uint i = 0, lineCount = 0; i < q._text.size(); ++i) {
|
||||
// Increment the number of lines by one text entry
|
||||
lineCount += (q._text[i].size() / _line.x) + 1;
|
||||
|
||||
// If we go over the quota for lines per page, go to next page and reset line counter to 0
|
||||
if (lineCount > _linesPerPage) {
|
||||
// We are about to go to next page, stop at this entry
|
||||
if (pageCount == _currentPage) {
|
||||
_start = pageStart;
|
||||
_stop = i;
|
||||
}
|
||||
|
||||
pageCount++;
|
||||
lineCount = 0;
|
||||
|
||||
// This is the start of the next page
|
||||
pageStart = i;
|
||||
}
|
||||
}
|
||||
|
||||
// Used for the final page, because the page count won't be incremented for the last one
|
||||
if (pageCount == _currentPage) {
|
||||
_start = pageStart;
|
||||
_stop = q._text.size();
|
||||
}
|
||||
|
||||
// Find out how many pages the lines need
|
||||
_totalPage = pageCount + 1;
|
||||
|
||||
// Update the text
|
||||
_status._text = (numberToString(_currentPage + 1) + " of " + numberToString(_totalPage));
|
||||
|
||||
// Now, start drawing the quest
|
||||
_status.draw();
|
||||
|
||||
if (_currentPage > 0)
|
||||
_prev.draw();
|
||||
|
||||
if (_currentPage < _totalPage - 1)
|
||||
_next.draw();
|
||||
|
||||
// Draw the current page of quest text
|
||||
if (!q._text.empty()) {
|
||||
// Count the number of lines, because a single entry can take more than one line
|
||||
int count = 0;
|
||||
|
||||
for (uint i = _start; i < (uint)_stop; ++i) {
|
||||
_img.draw(_inc.x * count, _inc.y * count);
|
||||
|
||||
// Draw first entry in selected color, and older quest entries in standard color
|
||||
if (i == 0)
|
||||
g_engine->_textManager->draw(x, y, q._text[i], _colS, _font, _align, _line.x, _line.y);
|
||||
else
|
||||
ParagraphData::draw(q._text[i], _inc.x * count, _inc.y * count);
|
||||
|
||||
// Count is reduced extra by the amount of lines it takes for the message to be drawn
|
||||
count += (q._text[i].size() / _line.x) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QuestText::handleEvents(pyrodactyl::event::Quest &q, const Common::Event &event) {
|
||||
if (_currentPage > 0 && _prev.handleEvents(event) == BUAC_LCLICK)
|
||||
_currentPage--;
|
||||
|
||||
if (_currentPage < _totalPage - 1 && _next.handleEvents(event) == BUAC_LCLICK) {
|
||||
_currentPage++;
|
||||
|
||||
if (_currentPage >= _totalPage)
|
||||
_currentPage = _totalPage - 1;
|
||||
}
|
||||
}
|
||||
|
||||
void QuestText::setUI() {
|
||||
ParagraphData::setUI();
|
||||
_img.setUI();
|
||||
_prev.setUI();
|
||||
_next.setUI();
|
||||
_status.setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
97
engines/crab/ui/QuestText.h
Normal file
97
engines/crab/ui/QuestText.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_QUESTTEXT_H
|
||||
#define CRAB_QUESTTEXT_H
|
||||
|
||||
#include "crab/event/quest.h"
|
||||
#include "crab/ui/button.h"
|
||||
#include "crab/ui/ImageData.h"
|
||||
#include "crab/ui/ParagraphData.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class QuestText : public ParagraphData {
|
||||
protected:
|
||||
// How much the text and bullet positions change per line
|
||||
Vector2i _inc;
|
||||
|
||||
// Color of the highlighted quest
|
||||
int _colS;
|
||||
|
||||
// The coordinates for drawing image, which is like bullet points in the form of <Bullet> <Text>
|
||||
ImageData _img;
|
||||
|
||||
// The lines per page, we split the quest text into multiple pages if we have to draw more than that
|
||||
uint _linesPerPage;
|
||||
|
||||
// Keep track of which page we are at, and total pages
|
||||
uint _currentPage, _totalPage;
|
||||
|
||||
// The quest entries we start and stop the drawing at
|
||||
int _start, _stop;
|
||||
|
||||
// The buttons for cycling between pages of the menu
|
||||
Button _prev, _next;
|
||||
|
||||
// Display "Page 1 of 3" style information for the menu
|
||||
HoverInfo _status;
|
||||
|
||||
public:
|
||||
QuestText() {
|
||||
_colS = 0;
|
||||
_currentPage = 0;
|
||||
_start = 0;
|
||||
_stop = 0;
|
||||
_totalPage = 1;
|
||||
_linesPerPage = 10;
|
||||
}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
|
||||
// Reset the value of current page
|
||||
void reset() {
|
||||
_currentPage = 0;
|
||||
}
|
||||
|
||||
void handleEvents(pyrodactyl::event::Quest &q, const Common::Event &event);
|
||||
|
||||
void draw(pyrodactyl::event::Quest &q);
|
||||
|
||||
void setUI();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_QUESTTEXT_H
|
||||
61
engines/crab/ui/RadioButton.h
Normal file
61
engines/crab/ui/RadioButton.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_RADIOBUTTON_H
|
||||
#define CRAB_RADIOBUTTON_H
|
||||
|
||||
#include "crab/ui/ToggleButton.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class RadioButton : public ToggleButton {
|
||||
public:
|
||||
// The value associated with the radio button
|
||||
float _val;
|
||||
|
||||
RadioButton() {
|
||||
_val = 0.0f;
|
||||
}
|
||||
|
||||
~RadioButton() {}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node) {
|
||||
ToggleButton::load(node);
|
||||
loadNum(_val, "val", node);
|
||||
}
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_RADIOBUTTON_H
|
||||
91
engines/crab/ui/RadioButtonMenu.h
Normal file
91
engines/crab/ui/RadioButtonMenu.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_RADIOBUTTONMENU_H
|
||||
#define CRAB_RADIOBUTTONMENU_H
|
||||
|
||||
#include "crab/ui/menu.h"
|
||||
#include "crab/ui/RadioButton.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class RadioButtonMenu : public Menu<RadioButton> {
|
||||
// The description of the menu
|
||||
HoverInfo _desc;
|
||||
|
||||
// The selected radio button
|
||||
int _select;
|
||||
|
||||
public:
|
||||
RadioButtonMenu() {
|
||||
_select = 0;
|
||||
}
|
||||
|
||||
~RadioButtonMenu() {}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid("desc", node))
|
||||
_desc.load(node->first_node("desc"));
|
||||
|
||||
if (nodeValid("menu", node))
|
||||
Menu::load(node->first_node("menu"));
|
||||
}
|
||||
|
||||
void draw(const int &xOffset = 0, const int &yOffset = 0) {
|
||||
_desc.draw(xOffset, yOffset);
|
||||
Menu::draw(xOffset, yOffset);
|
||||
}
|
||||
|
||||
int handleEvents(const Common::Event &event, const int &xOffset = 0, const int &yOffset = 0) {
|
||||
int result = Menu::handleEvents(event, xOffset, yOffset);
|
||||
|
||||
if (result >= 0) {
|
||||
_select = result;
|
||||
|
||||
for (int i = 0; i < (int)_element.size(); ++i)
|
||||
_element[i]._state = (i == result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void setUI() {
|
||||
Menu::setUI();
|
||||
_desc.setUI();
|
||||
}
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_RADIOBUTTONMENU_H
|
||||
91
engines/crab/ui/ReplyButton.cpp
Normal file
91
engines/crab/ui/ReplyButton.cpp
Normal file
@@ -0,0 +1,91 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "graphics/font.h"
|
||||
#include "crab/crab.h"
|
||||
#include "crab/ui/ReplyButton.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::text;
|
||||
using namespace pyrodactyl::image;
|
||||
|
||||
void ReplyButton::load(rapidxml::xml_node<char> *node) {
|
||||
Button::load(node);
|
||||
_orig = *this;
|
||||
|
||||
if (nodeValid("text", node)) {
|
||||
rapidxml::xml_node<char> *tenode = node->first_node("text");
|
||||
|
||||
loadColor(_colB, tenode->first_node("col_b"));
|
||||
loadColor(_colS, tenode->first_node("col_s"));
|
||||
loadColor(_colH, tenode->first_node("col_h"));
|
||||
loadNum(_font, "font", tenode);
|
||||
loadAlign(_replyAlign, tenode);
|
||||
|
||||
if (nodeValid("line_size", tenode))
|
||||
_lineSize.load(tenode->first_node("line_size"));
|
||||
}
|
||||
}
|
||||
|
||||
void ReplyButton::draw(const int &xOffset, const int &yOffset) {
|
||||
if (_visible) {
|
||||
if (_mousePressed)
|
||||
g_engine->_textManager->draw(x + xOffset, y + yOffset, _text, _colS, _font, _replyAlign, _lineSize.x, _lineSize.y);
|
||||
else if (_hoverMouse || _hoverKey)
|
||||
g_engine->_textManager->draw(x + xOffset, y + yOffset, _text, _colH, _font, _replyAlign, _lineSize.x, _lineSize.y);
|
||||
else
|
||||
g_engine->_textManager->draw(x + xOffset, y + yOffset, _text, _colB, _font, _replyAlign, _lineSize.x, _lineSize.y);
|
||||
}
|
||||
}
|
||||
|
||||
void ReplyButton::cache(const Common::String &val, const int &spacing, const int &bottomEdge, Rect *parent) {
|
||||
_text = val;
|
||||
|
||||
// Find out about the font
|
||||
int width = 0, height = 0;
|
||||
width = g_engine->_textManager->getFont(_font)->getStringWidth(val);
|
||||
height = g_engine->_textManager->getFont(_font)->getFontHeight();
|
||||
|
||||
// Find out how many line sizes will the text take
|
||||
int lines = ((_text.size() - 1) / _lineSize.x) + 1;
|
||||
|
||||
x = _orig.x;
|
||||
y = _orig.y;
|
||||
w = width;
|
||||
h = height * lines;
|
||||
setUI(parent);
|
||||
|
||||
if (_orig.y < bottomEdge)
|
||||
y = bottomEdge + spacing;
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
81
engines/crab/ui/ReplyButton.h
Normal file
81
engines/crab/ui/ReplyButton.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_REPLYBUTTON_H
|
||||
#define CRAB_REPLYBUTTON_H
|
||||
|
||||
#include "crab/ui/button.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
// This button is used to draw multiple lines of text instead of an image
|
||||
class ReplyButton : public Button {
|
||||
// Information about drawing reply options
|
||||
int _colB, _colS, _colH;
|
||||
FontKey _font;
|
||||
Align _replyAlign;
|
||||
Vector2D<uint> _lineSize;
|
||||
|
||||
// Reply options get moved around a lot, this remembers their actual position
|
||||
Rect _orig;
|
||||
|
||||
// The text for this button
|
||||
Common::String _text;
|
||||
|
||||
public:
|
||||
// The object it points to
|
||||
int _index;
|
||||
|
||||
ReplyButton() {
|
||||
_index = 0;
|
||||
_colB = 0;
|
||||
_colS = 0;
|
||||
_colH = 0;
|
||||
_font = 0;
|
||||
_replyAlign = ALIGN_LEFT;
|
||||
}
|
||||
~ReplyButton() {}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
void draw(const int &xOffset = 0, const int &yOffset = 0);
|
||||
|
||||
// Used to calculate size and set the string
|
||||
// Spacing is the minimum space between buttons added in case of overflow
|
||||
// Bottom edge is the y+h value of the previous choice
|
||||
void cache(const Common::String &val, const int &spacing, const int &bottomEdge, Rect *parent);
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_REPLYBUTTON_H
|
||||
148
engines/crab/ui/ReplyMenu.cpp
Normal file
148
engines/crab/ui/ReplyMenu.cpp
Normal file
@@ -0,0 +1,148 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/XMLDoc.h"
|
||||
#include "crab/ui/ReplyMenu.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::text;
|
||||
using namespace pyrodactyl::image;
|
||||
using namespace pyrodactyl::input;
|
||||
using namespace pyrodactyl::music;
|
||||
using namespace pyrodactyl::event;
|
||||
using namespace pyrodactyl::people;
|
||||
|
||||
void ReplyMenu::load(const Common::Path &filename) {
|
||||
XMLDoc conf(filename);
|
||||
if (conf.ready()) {
|
||||
rapidxml::xml_node<char> *node = conf.doc()->first_node("conversation");
|
||||
if (nodeValid(node)) {
|
||||
if (nodeValid("tone", node))
|
||||
_tone.load(node->first_node("tone"));
|
||||
|
||||
if (nodeValid("reply", node)) {
|
||||
rapidxml::xml_node<char> *replynode = node->first_node("reply");
|
||||
Menu<ReplyButton>::load(replynode->first_node("menu"));
|
||||
_tone._value.resize(_element.size());
|
||||
|
||||
_bg.load(replynode->first_node("bg"));
|
||||
loadNum(_spacing, "spacing", replynode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ReplyMenu::handleEvents(Info &info, ConversationData &dat, const Common::String &curId, PersonHandler &oh, const Common::Event &event) {
|
||||
// After that, check if the user has clicked on any reply option
|
||||
int choice = Menu<ReplyButton>::handleEvents(event);
|
||||
if (choice >= 0 && (uint)choice < dat._reply.size()) {
|
||||
bool playSound = false;
|
||||
|
||||
// Loop through any opinion changes required
|
||||
for (auto &i : dat._reply[_element[choice]._index]._change) {
|
||||
if (i._id == curId) {
|
||||
// This is a special case because we also need to update the opinion bars
|
||||
oh.opinionChange(info, i._id, OPI_LIKE, i._val[OPI_LIKE]);
|
||||
oh.opinionChange(info, i._id, OPI_RESPECT, i._val[OPI_RESPECT]);
|
||||
oh.opinionChange(info, i._id, OPI_FEAR, i._val[OPI_FEAR]);
|
||||
playSound = true;
|
||||
} else {
|
||||
info.opinionChange(i._id, OPI_LIKE, i._val[OPI_LIKE]);
|
||||
info.opinionChange(i._id, OPI_RESPECT, i._val[OPI_RESPECT]);
|
||||
info.opinionChange(i._id, OPI_FEAR, i._val[OPI_FEAR]);
|
||||
playSound = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Right now we play sound randomly
|
||||
if (playSound) {
|
||||
if (g_engine->getRandomNumber(1))
|
||||
info._sound._repDec = true;
|
||||
else
|
||||
info._sound._repInc = true;
|
||||
}
|
||||
|
||||
return dat._reply[_element[choice]._index]._nextid;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void ReplyMenu::draw() {
|
||||
_bg.draw();
|
||||
_tone.draw(_hoverIndex);
|
||||
|
||||
// Draw the reply options
|
||||
Menu<ReplyButton>::draw();
|
||||
}
|
||||
|
||||
void ReplyMenu::cache(pyrodactyl::event::Info &info, pyrodactyl::event::ConversationData &dat) {
|
||||
// Some replies are locked, which means the other replies move up and take their place -
|
||||
// which is why we need two count variables
|
||||
uint replyCount = 0, elementCount = 0;
|
||||
|
||||
for (auto i = dat._reply.begin(); i != dat._reply.end() && replyCount < dat._reply.size(); ++i, ++replyCount) {
|
||||
if (i->_unlock.evaluate(info)) {
|
||||
_element[elementCount]._visible = true;
|
||||
_element[elementCount]._index = replyCount;
|
||||
|
||||
_tone._value[elementCount] = dat._reply[replyCount]._tone;
|
||||
|
||||
const InputType type = static_cast<InputType>(IU_REPLY_0 + elementCount);
|
||||
Common::String text = g_engine->_inputManager->getAssociatedKey(type);
|
||||
text += ". " + i->_text;
|
||||
info.insertName(text);
|
||||
|
||||
if (elementCount == 0)
|
||||
_element[elementCount].cache(text, _spacing, 0, &_bg);
|
||||
else
|
||||
_element[elementCount].cache(text, _spacing, _element[elementCount - 1].y + _element[elementCount - 1].h, &_bg);
|
||||
|
||||
// Increment the element count only if the reply is unlocked
|
||||
// This means we will keep checking against element 0 until we find an unlocked reply
|
||||
// e.g. if replies 0,1,2 are locked, then element[0] will get reply[3]
|
||||
elementCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// Unused element buttons are hidden
|
||||
for (; elementCount < _element.size(); elementCount++)
|
||||
_element[elementCount]._visible = false;
|
||||
}
|
||||
|
||||
void ReplyMenu::setUI() {
|
||||
Menu<ReplyButton>::setUI();
|
||||
_bg.setUI();
|
||||
_tone.setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
79
engines/crab/ui/ReplyMenu.h
Normal file
79
engines/crab/ui/ReplyMenu.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_REPLYMENU_H
|
||||
#define CRAB_REPLYMENU_H
|
||||
|
||||
#include "crab/event/conversationdata.h"
|
||||
#include "crab/event/eventstore.h"
|
||||
#include "crab/event/GameEventInfo.h"
|
||||
#include "crab/ui/emotion.h"
|
||||
#include "crab/ui/ImageData.h"
|
||||
#include "crab/ui/PersonHandler.h"
|
||||
#include "crab/ui/ReplyButton.h"
|
||||
#include "crab/TTSHandler.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class ReplyMenu : public Menu<ReplyButton>, public TTSHandler {
|
||||
// Data about the background image
|
||||
ImageData _bg;
|
||||
|
||||
// The minimum spacing between two reply choices
|
||||
int _spacing;
|
||||
|
||||
// The emotion indicator used to indicate the type of reply selected
|
||||
EmotionIndicator _tone;
|
||||
|
||||
public:
|
||||
ReplyMenu() {
|
||||
_spacing = 20;
|
||||
}
|
||||
|
||||
~ReplyMenu() {}
|
||||
|
||||
void load(const Common::Path &filename);
|
||||
|
||||
int handleEvents(pyrodactyl::event::Info &info, pyrodactyl::event::ConversationData &dat,
|
||||
const Common::String &curId, PersonHandler &oh, const Common::Event &Event);
|
||||
|
||||
void draw();
|
||||
void cache(pyrodactyl::event::Info &info, pyrodactyl::event::ConversationData &dat);
|
||||
|
||||
void setUI();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_REPLYMENU_H
|
||||
145
engines/crab/ui/ResolutionMenu.cpp
Normal file
145
engines/crab/ui/ResolutionMenu.cpp
Normal file
@@ -0,0 +1,145 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/crab.h"
|
||||
#include "crab/ui/ResolutionMenu.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::image;
|
||||
using namespace pyrodactyl::text;
|
||||
using namespace pyrodactyl::ui;
|
||||
|
||||
void ResolutionMenu::load(rapidxml::xml_node<char> *node) {
|
||||
_cancel.load(node->first_node("cancel"));
|
||||
_change.load(node->first_node("change"));
|
||||
_custom.load(node->first_node("custom"));
|
||||
|
||||
_info.load(node->first_node("info"));
|
||||
_defInfo = _info._text;
|
||||
|
||||
if (nodeValid("reference", node))
|
||||
_ref.load(node->first_node("reference"));
|
||||
|
||||
if (nodeValid("inc", node)) {
|
||||
_inc.load(node->first_node("inc"));
|
||||
loadNum(_columns, "columns", node->first_node("inc"));
|
||||
}
|
||||
|
||||
if (nodeValid("options", node)) {
|
||||
int countSlot = 0;
|
||||
rapidxml::xml_node<char> *resnode = node->first_node("options");
|
||||
for (auto n = resnode->first_node("res"); n != nullptr; n = n->next_sibling("res"), countSlot++) {
|
||||
Dimension d;
|
||||
loadNum(d.w, "x", n);
|
||||
loadNum(d.h, "y", n);
|
||||
|
||||
if (g_engine->_screenSettings->validDimension(d)) {
|
||||
_dim.push_back(d);
|
||||
Button b;
|
||||
b.init(_ref, _inc.x * (countSlot % _columns), _inc.y * (countSlot / _columns));
|
||||
b._caption._text = numberToString(d.w);
|
||||
b._caption._text += " x ";
|
||||
b._caption._text += numberToString(d.h);
|
||||
_element.push_back(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setInfo();
|
||||
|
||||
loadBool(_useKeyboard, "keyboard", node, false);
|
||||
assignPaths();
|
||||
}
|
||||
|
||||
void ResolutionMenu::draw() {
|
||||
_info.draw();
|
||||
|
||||
switch (_state) {
|
||||
case STATE_NORMAL:
|
||||
_change.draw();
|
||||
break;
|
||||
case STATE_CHANGE:
|
||||
Menu::draw();
|
||||
_cancel.draw();
|
||||
_custom.draw();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int ResolutionMenu::handleEvents(const Common::Event &event) {
|
||||
switch (_state) {
|
||||
case STATE_NORMAL:
|
||||
if (_change.handleEvents(event) == BUAC_LCLICK)
|
||||
_state = STATE_CHANGE;
|
||||
break;
|
||||
case STATE_CHANGE: {
|
||||
int choice = Menu::handleEvents(event);
|
||||
if (choice >= 0) {
|
||||
g_engine->_screenSettings->_cur = _dim[choice];
|
||||
_state = STATE_NORMAL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (_custom.handleEvents(event) == BUAC_LCLICK) {
|
||||
_state = STATE_NORMAL;
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (_cancel.handleEvents(event) == BUAC_LCLICK)
|
||||
_state = STATE_NORMAL;
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ResolutionMenu::setInfo() {
|
||||
_info._text = _defInfo;
|
||||
_info._text += numberToString(g_engine->_screenSettings->_cur.w);
|
||||
_info._text += " x ";
|
||||
_info._text += numberToString(g_engine->_screenSettings->_cur.h);
|
||||
}
|
||||
|
||||
void ResolutionMenu::setUI() {
|
||||
_cancel.setUI();
|
||||
_change.setUI();
|
||||
_custom.setUI();
|
||||
|
||||
_info.setUI();
|
||||
_ref.setUI();
|
||||
ButtonMenu::setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
86
engines/crab/ui/ResolutionMenu.h
Normal file
86
engines/crab/ui/ResolutionMenu.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_RESOLUTIONMENU_H
|
||||
#define CRAB_RESOLUTIONMENU_H
|
||||
|
||||
#include "crab/ScreenSettings.h"
|
||||
#include "crab/ui/menu.h"
|
||||
#include "crab/ui/textarea.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class ResolutionMenu : public ButtonMenu {
|
||||
enum State {
|
||||
STATE_NORMAL,
|
||||
STATE_CHANGE
|
||||
} _state;
|
||||
|
||||
HoverInfo _info;
|
||||
Common::String _defInfo;
|
||||
Button _change, _cancel, _custom;
|
||||
|
||||
// Menu stores the button for each of the item in the dimension array
|
||||
Common::Array<Dimension> _dim;
|
||||
|
||||
// The reference button for resolution
|
||||
Button _ref;
|
||||
|
||||
// How much the button is incremented by
|
||||
Vector2i _inc;
|
||||
|
||||
// The number of rows and columns
|
||||
int _columns;
|
||||
|
||||
public:
|
||||
ResolutionMenu() {
|
||||
_state = STATE_NORMAL;
|
||||
_columns = 1;
|
||||
}
|
||||
~ResolutionMenu() {}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
void draw();
|
||||
|
||||
// Return 1 if one of resolution buttons is pressed, 2 if custom button is pressed, 0 otherwise
|
||||
int handleEvents(const Common::Event &event);
|
||||
|
||||
void setInfo();
|
||||
|
||||
void setUI();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_RESOLUTIONMENU_H
|
||||
136
engines/crab/ui/SaveGameMenu.cpp
Normal file
136
engines/crab/ui/SaveGameMenu.cpp
Normal file
@@ -0,0 +1,136 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/ui/SaveGameMenu.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::input;
|
||||
|
||||
void GameSaveMenu::load(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid("name", node))
|
||||
_taName.load(node->first_node("name"));
|
||||
|
||||
FileMenu<SaveFileData>::load(node);
|
||||
}
|
||||
|
||||
void GameSaveMenu::addButton(const Common::String &p, uint &slotIndex, uint &menuIndex) {
|
||||
_slotInfo.push_back(SaveFileData(p));
|
||||
_menu.add(slotIndex, menuIndex);
|
||||
}
|
||||
|
||||
void GameSaveMenu::scanDir() {
|
||||
Common::String res = "CRAB_*";
|
||||
res += g_engine->_filePath->_saveExt;
|
||||
Common::StringArray saves = g_engine->getSaveFileManager()->listSavefiles(res);
|
||||
|
||||
_slotInfo.clear();
|
||||
_menu.clear();
|
||||
|
||||
uint countSlot = 0, countMenu = 0;
|
||||
|
||||
// For the save menu, the first slot is a "blank" slot - to create a new save file
|
||||
addButton("CRAB_New Save" + g_engine->_filePath->_saveExt, countMenu, countSlot);
|
||||
|
||||
for (const Common::String& save : saves) {
|
||||
addButton(save, countMenu, countSlot);
|
||||
}
|
||||
|
||||
_menu.assignPaths();
|
||||
}
|
||||
|
||||
bool GameSaveMenu::handleEvents(const Common::Event &event) {
|
||||
int choice = -1;
|
||||
switch (_state) {
|
||||
case STATE_NORMAL:
|
||||
choice = _menu.handleEvents(event);
|
||||
if (choice >= 0) {
|
||||
_taName.x = _menu.curX(choice) + tdB[DATA_SAVENAME].x;
|
||||
_taName.y = _menu.curY(choice) + tdB[DATA_SAVENAME].y;
|
||||
|
||||
_index = _menu.index() + choice;
|
||||
|
||||
if (_index != 0)
|
||||
_taName._text = _slotInfo[_index]._name;
|
||||
else
|
||||
_taName._text = "";
|
||||
|
||||
_state = STATE_NAME;
|
||||
}
|
||||
break;
|
||||
case STATE_NAME:
|
||||
if (g_engine->_inputManager->getKeyBindingMode() != input::KBM_UI)
|
||||
g_engine->_inputManager->setKeyBindingMode(KBM_UI);
|
||||
|
||||
if (_taName.handleEvents(event)) {
|
||||
if (_index <= (int)_slotInfo.size() && _index != 0)
|
||||
g_engine->getSaveFileManager()->removeSavefile(_slotInfo[_index]._path);
|
||||
|
||||
_selected = _taName._text;
|
||||
_state = STATE_NORMAL;
|
||||
reset();
|
||||
g_engine->_inputManager->setKeyBindingMode(KBM_GAME);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (g_engine->_inputManager->state(IU_BACK)) {
|
||||
_taName._text = "New Save";
|
||||
_state = STATE_NORMAL;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void GameSaveMenu::draw() {
|
||||
_bg.draw();
|
||||
_menu.draw();
|
||||
for (auto i = _menu.index(), count = 0u; i < _menu.indexPlusOne() && i < _slotInfo.size(); i++, count++) {
|
||||
float base_x = _menu.baseX(count), base_y = _menu.baseY(count);
|
||||
tdB[DATA_LASTMODIFIED].draw(_slotInfo[i]._lastModified, base_x, base_y);
|
||||
|
||||
if (i == (uint)_index && _state == STATE_NAME)
|
||||
_taName.draw();
|
||||
else
|
||||
tdB[DATA_SAVENAME].draw(_slotInfo[i]._name, base_x, base_y);
|
||||
}
|
||||
|
||||
drawHover();
|
||||
}
|
||||
|
||||
void GameSaveMenu::setUI() {
|
||||
FileMenu<SaveFileData>::setUI();
|
||||
_taName.setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
81
engines/crab/ui/SaveGameMenu.h
Normal file
81
engines/crab/ui/SaveGameMenu.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_SAVEGAMEMENU_H
|
||||
#define CRAB_SAVEGAMEMENU_H
|
||||
|
||||
#include "crab/ui/FileMenu.h"
|
||||
#include "crab/ui/textarea.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class GameSaveMenu : public FileMenu<SaveFileData> {
|
||||
enum State {
|
||||
STATE_NORMAL,
|
||||
STATE_NAME
|
||||
} _state;
|
||||
|
||||
// This stores the name of the save slot
|
||||
TextArea _taName;
|
||||
|
||||
// The index of the selected button
|
||||
int _index;
|
||||
|
||||
void addButton(const Common::String &p, uint &slotIndex, uint &menuIndex);
|
||||
|
||||
public:
|
||||
GameSaveMenu() {
|
||||
_state = STATE_NORMAL;
|
||||
_index = 0;
|
||||
}
|
||||
|
||||
~GameSaveMenu() {}
|
||||
|
||||
void scanDir();
|
||||
bool disableHotkeys() {
|
||||
return _state == STATE_NAME;
|
||||
}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
|
||||
bool handleEvents(const Common::Event &event);
|
||||
|
||||
void draw();
|
||||
|
||||
void setUI();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_SAVEGAMEMENU_H
|
||||
94
engines/crab/ui/SectionHeader.cpp
Normal file
94
engines/crab/ui/SectionHeader.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "graphics/managed_surface.h"
|
||||
#include "crab/crab.h"
|
||||
#include "crab/ui/SectionHeader.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::text;
|
||||
using namespace pyrodactyl::image;
|
||||
|
||||
void SectionHeader::load(rapidxml::xml_node<char> *node) {
|
||||
|
||||
if (TextData::load(node, nullptr, false)) {
|
||||
loadStr(_text, "text", node);
|
||||
_text.insertChar(' ', 0);
|
||||
_text += " ";
|
||||
|
||||
loadImgKey(_img, "img", node);
|
||||
|
||||
loadBool(_drawL, "left", node);
|
||||
loadBool(_drawR, "right", node);
|
||||
|
||||
Graphics::ManagedSurface *surf = g_engine->_textManager->renderTextBlended(_font, _text, _col);
|
||||
|
||||
if (_align == ALIGN_CENTER) {
|
||||
_left.x = x - surf->w / 2 - g_engine->_imageManager->getTexture(_img).w();
|
||||
_left.y = y - surf->h / 2 + g_engine->_imageManager->getTexture(_img).h() / 2;
|
||||
|
||||
_right.x = x + surf->w / 2;
|
||||
_right.y = y - surf->h / 2 + g_engine->_imageManager->getTexture(_img).h() / 2;
|
||||
} else if (_align == ALIGN_LEFT) {
|
||||
_left.x = x - g_engine->_imageManager->getTexture(_img).w();
|
||||
_left.y = y + surf->h / 2 - g_engine->_imageManager->getTexture(_img).h() / 2;
|
||||
|
||||
_right.x = x + surf->w;
|
||||
_right.y = y + surf->h / 2 - g_engine->_imageManager->getTexture(_img).h() / 2;
|
||||
} else {
|
||||
_left.x = x - surf->w - g_engine->_imageManager->getTexture(_img).w();
|
||||
_left.y = y + surf->h / 2 - g_engine->_imageManager->getTexture(_img).h() / 2;
|
||||
|
||||
_right.x = x;
|
||||
_right.y = y + surf->h / 2 - g_engine->_imageManager->getTexture(_img).h() / 2;
|
||||
}
|
||||
|
||||
delete surf;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SectionHeader::draw(const int &xOffset, const int &yOffset) {
|
||||
draw(_text, xOffset, yOffset);
|
||||
}
|
||||
|
||||
void SectionHeader::draw(const Common::String &str, const int &xOffset, const int &yOffset) {
|
||||
if (_drawL)
|
||||
g_engine->_imageManager->draw(_left.x + xOffset, _left.y + yOffset, _img);
|
||||
|
||||
if (_drawR)
|
||||
g_engine->_imageManager->draw(_right.x + xOffset, _right.y + yOffset, _img, (Rect*)nullptr, FLIP_X);
|
||||
|
||||
TextData::draw(str, xOffset, yOffset);
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
73
engines/crab/ui/SectionHeader.h
Normal file
73
engines/crab/ui/SectionHeader.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_SECTIONHEADER_H
|
||||
#define CRAB_SECTIONHEADER_H
|
||||
|
||||
#include "crab/ui/TextData.h"
|
||||
#include "crab/text/TextManager.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class SectionHeader : public TextData {
|
||||
// The content of the header
|
||||
Common::String _text;
|
||||
|
||||
// This image surrounds the text like <img> text <img>, with the right image being flipped horizontally
|
||||
ImageKey _img;
|
||||
|
||||
// The coordinates for drawing image
|
||||
Vector2i _left, _right;
|
||||
|
||||
// Should we draw one or both or none of the images
|
||||
bool _drawL, _drawR;
|
||||
|
||||
public:
|
||||
SectionHeader() {
|
||||
_img = 0;
|
||||
_drawL = false;
|
||||
_drawR = false;
|
||||
}
|
||||
|
||||
~SectionHeader() {}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
|
||||
void draw(const int &xOffset = 0, const int &yOffset = 0);
|
||||
void draw(const Common::String &str, const int &xOffset = 0, const int &yOffset = 0);
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_SECTIONHEADER_H
|
||||
111
engines/crab/ui/SlideShow.cpp
Normal file
111
engines/crab/ui/SlideShow.cpp
Normal file
@@ -0,0 +1,111 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/ui/SlideShow.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::image;
|
||||
using namespace pyrodactyl::input;
|
||||
|
||||
void SlideShow::load(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid(node)) {
|
||||
if (nodeValid("pos", node))
|
||||
_pos.load(node->first_node("pos"));
|
||||
|
||||
if (nodeValid("bg", node))
|
||||
_bg.load(node->first_node("bg"));
|
||||
|
||||
if (nodeValid("prev", node)) {
|
||||
_prev.load(node->first_node("prev"));
|
||||
_prev._hotkey.set(IU_PREV);
|
||||
}
|
||||
|
||||
if (nodeValid("next", node)) {
|
||||
_next.load(node->first_node("next"));
|
||||
_next._hotkey.set(IU_NEXT);
|
||||
}
|
||||
|
||||
_path.clear();
|
||||
for (auto n = node->first_node("slide"); n != nullptr; n = n->next_sibling("slide")) {
|
||||
Common::Path p;
|
||||
loadPath(p, "path", n);
|
||||
_path.push_back(p);
|
||||
}
|
||||
|
||||
_index = 0;
|
||||
|
||||
loadBool(_usekeyboard, "keyboard", node, false);
|
||||
}
|
||||
}
|
||||
|
||||
void SlideShow::draw() {
|
||||
_bg.draw();
|
||||
_img.draw(_pos.x, _pos.y);
|
||||
|
||||
if (_index > 0)
|
||||
_prev.draw();
|
||||
|
||||
if (_index < _path.size() - 1)
|
||||
_next.draw();
|
||||
}
|
||||
|
||||
void SlideShow::handleEvents(const Common::Event &event) {
|
||||
using namespace pyrodactyl::input;
|
||||
|
||||
if (_index > 0)
|
||||
if (_prev.handleEvents(event) == BUAC_LCLICK || (_usekeyboard && g_engine->_inputManager->state(IU_LEFT))) {
|
||||
_index--;
|
||||
refresh();
|
||||
}
|
||||
|
||||
if (_index < _path.size() - 1)
|
||||
if (_next.handleEvents(event) == BUAC_LCLICK || (_usekeyboard && g_engine->_inputManager->state(IU_RIGHT))) {
|
||||
_index++;
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void SlideShow::refresh() {
|
||||
_img.deleteImage();
|
||||
|
||||
if (_index < _path.size())
|
||||
_img.load(_path[_index]);
|
||||
}
|
||||
|
||||
void SlideShow::setUI() {
|
||||
_pos.setUI();
|
||||
_bg.setUI();
|
||||
_prev.setUI();
|
||||
_next.setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
90
engines/crab/ui/SlideShow.h
Normal file
90
engines/crab/ui/SlideShow.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_SLIDESHOW_H
|
||||
#define CRAB_SLIDESHOW_H
|
||||
|
||||
#include "crab/image/Image.h"
|
||||
#include "crab/ui/button.h"
|
||||
#include "crab/ui/ImageData.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class SlideShow {
|
||||
// The list of images and where they are located, and the current image
|
||||
Common::Array<Common::Path> _path;
|
||||
|
||||
// We only load the current image in memory
|
||||
pyrodactyl::image::Image _img;
|
||||
|
||||
// The index of our current image
|
||||
uint _index;
|
||||
|
||||
// The position at which map image has to be drawn
|
||||
Element _pos;
|
||||
|
||||
// Background image of the slide show
|
||||
ImageData _bg;
|
||||
|
||||
Button _prev, _next;
|
||||
bool _usekeyboard;
|
||||
|
||||
public:
|
||||
SlideShow() {
|
||||
_index = 0;
|
||||
_usekeyboard = false;
|
||||
}
|
||||
|
||||
~SlideShow() {
|
||||
clear();
|
||||
}
|
||||
|
||||
void refresh();
|
||||
void clear() {
|
||||
_img.deleteImage();
|
||||
}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
|
||||
void handleEvents(const Common::Event &event);
|
||||
|
||||
void draw();
|
||||
|
||||
void setUI();
|
||||
};
|
||||
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_SLIDESHOW_H
|
||||
92
engines/crab/ui/StateButton.cpp
Normal file
92
engines/crab/ui/StateButton.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/crab.h"
|
||||
#include "crab/ui/StateButton.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::image;
|
||||
|
||||
void StateButton::init(const StateButton &ref, const int &XOffset, const int &YOffset) {
|
||||
Button::init(ref, XOffset, YOffset);
|
||||
_imgSet = ref._imgSet;
|
||||
_colNormal = ref._colNormal;
|
||||
_colSelect = ref._colSelect;
|
||||
}
|
||||
|
||||
void StateButton::load(rapidxml::xml_node<char> *node, const bool &echo) {
|
||||
Button::load(node, echo);
|
||||
|
||||
_imgSet._normal = _img;
|
||||
_colNormal._col = _caption._col;
|
||||
_colNormal._colS = _caption._colS;
|
||||
|
||||
if (nodeValid("select", node, false)) {
|
||||
rapidxml::xml_node<char> *selnode = node->first_node("select");
|
||||
|
||||
_imgSet._select.load(selnode, echo);
|
||||
loadNum(_colSelect._col, "color", selnode);
|
||||
loadNum(_colSelect._colS, "color_s", selnode);
|
||||
} else {
|
||||
_imgSet._select = _img;
|
||||
_colSelect._col = _caption._col;
|
||||
_colSelect._colS = _caption._colS;
|
||||
}
|
||||
}
|
||||
|
||||
void StateButton::state(const bool val) {
|
||||
if (val) {
|
||||
_img = _imgSet._select;
|
||||
_caption._col = _colSelect._col;
|
||||
_caption._colS = _colSelect._colS;
|
||||
} else {
|
||||
_img = _imgSet._normal;
|
||||
_caption._col = _colNormal._col;
|
||||
_caption._colS = _colNormal._colS;
|
||||
}
|
||||
|
||||
// Images might be different in size
|
||||
w = g_engine->_imageManager->getTexture(_img._normal).w();
|
||||
h = g_engine->_imageManager->getTexture(_img._normal).h();
|
||||
}
|
||||
|
||||
void StateButton::img(const StateButtonImage &sbi) {
|
||||
// Find which is the current image and set it
|
||||
if (_img == _imgSet._normal)
|
||||
_img = sbi._normal;
|
||||
else
|
||||
_img = sbi._select;
|
||||
|
||||
_imgSet = sbi;
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
94
engines/crab/ui/StateButton.h
Normal file
94
engines/crab/ui/StateButton.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_STATEBUTTON_H
|
||||
#define CRAB_STATEBUTTON_H
|
||||
|
||||
#include "crab/ui/button.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
struct StateButtonImage {
|
||||
ButtonImage _normal, _select;
|
||||
|
||||
StateButtonImage() {}
|
||||
StateButtonImage(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid("normal", node))
|
||||
_normal.load(node->first_node("normal"));
|
||||
|
||||
if (nodeValid("select", node, false))
|
||||
_select.load(node->first_node("select"));
|
||||
else
|
||||
_select = _normal;
|
||||
}
|
||||
};
|
||||
|
||||
struct StateButtonColor {
|
||||
int _col, _colS;
|
||||
|
||||
StateButtonColor() {
|
||||
_col = 0;
|
||||
_colS = 0;
|
||||
}
|
||||
};
|
||||
|
||||
// This button has two sets of images (b, h, s) and switching is done by clicking it
|
||||
// Similar to the checkbox UI element in windows/web
|
||||
class StateButton : public Button {
|
||||
// The two images
|
||||
StateButtonImage _imgSet;
|
||||
|
||||
// The color for the caption when the image is selected
|
||||
StateButtonColor _colNormal, _colSelect;
|
||||
|
||||
public:
|
||||
StateButton() {}
|
||||
~StateButton() {}
|
||||
|
||||
void init(const StateButton &ref, const int &xOffset = 0, const int &yOffset = 0);
|
||||
void load(rapidxml::xml_node<char> *node, const bool &echo = true);
|
||||
|
||||
// The state of the button - false is original image, true is second image
|
||||
void state(const bool val);
|
||||
bool state() {
|
||||
return (_img == _imgSet._select);
|
||||
}
|
||||
|
||||
// Set the image
|
||||
void img(const StateButtonImage &sbi);
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_STATEBUTTON_H
|
||||
69
engines/crab/ui/TextData.h
Normal file
69
engines/crab/ui/TextData.h
Normal 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_TEXTDATA_H
|
||||
#define CRAB_TEXTDATA_H
|
||||
|
||||
#include "crab/text/TextManager.h"
|
||||
#include "crab/ui/element.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class TextData : public Element {
|
||||
public:
|
||||
int _col;
|
||||
FontKey _font;
|
||||
Align _align;
|
||||
bool _background;
|
||||
|
||||
TextData() {
|
||||
_col = 0;
|
||||
_font = 0;
|
||||
_align = ALIGN_LEFT;
|
||||
_background = false;
|
||||
}
|
||||
~TextData() {}
|
||||
|
||||
bool load(rapidxml::xml_node<char> *node, Rect *parent = nullptr, const bool &echo = true);
|
||||
|
||||
// Plain drawing
|
||||
void draw(const Common::String &val, const int &xOffset = 0, const int &yOffset = 0);
|
||||
|
||||
// Draw with a different color
|
||||
void drawColor(const Common::String &val, const int &color, const int &xOffset = 0, const int &yOffset = 0);
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_TEXTDATA_H
|
||||
66
engines/crab/ui/ToggleButton.cpp
Normal file
66
engines/crab/ui/ToggleButton.cpp
Normal 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/crab.h"
|
||||
#include "crab/ui/ToggleButton.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::image;
|
||||
|
||||
void ToggleButton::load(rapidxml::xml_node<char> *node) {
|
||||
Button::load(node);
|
||||
loadImgKey(_on, "on", node);
|
||||
loadImgKey(_off, "off", node);
|
||||
|
||||
if (nodeValid("offset", node))
|
||||
_offset.load(node->first_node("offset"));
|
||||
}
|
||||
|
||||
void ToggleButton::draw(const int &xOffset, const int &yOffset, Rect *clip) {
|
||||
Button::draw(xOffset, yOffset, clip);
|
||||
|
||||
if (_state)
|
||||
g_engine->_imageManager->draw(x + _offset.x, y + _offset.y, _on);
|
||||
else
|
||||
g_engine->_imageManager->draw(x + _offset.x, y + _offset.y, _off);
|
||||
}
|
||||
|
||||
ButtonAction ToggleButton::handleEvents(const Common::Event &event, const int &xOffset, const int &yOffset) {
|
||||
ButtonAction action = Button::handleEvents(event, xOffset, yOffset);
|
||||
|
||||
if (action == BUAC_LCLICK)
|
||||
_state = !_state;
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
71
engines/crab/ui/ToggleButton.h
Normal file
71
engines/crab/ui/ToggleButton.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_TOGGLEBUTTON_H
|
||||
#define CRAB_TOGGLEBUTTON_H
|
||||
|
||||
#include "crab/ui/button.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
// This button has two states that can be switched between by clicking the button
|
||||
// Similar to the radio button / checkbox UI element in windows/web
|
||||
class ToggleButton : public Button {
|
||||
// The images corresponding to the state
|
||||
ImageKey _on, _off;
|
||||
|
||||
// The offset at which the on/off image is drawn
|
||||
Vector2i _offset;
|
||||
|
||||
public:
|
||||
// The state of the button - true is on, false is off
|
||||
bool _state;
|
||||
|
||||
ToggleButton() {
|
||||
_state = false;
|
||||
_on = 0;
|
||||
_off = 0;
|
||||
}
|
||||
|
||||
~ToggleButton() {}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
void draw(const int &xOffset = 0, const int &yOffset = 0, Rect *clip = nullptr);
|
||||
|
||||
ButtonAction handleEvents(const Common::Event &event, const int &xOffset = 0, const int &yOffset = 0);
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_TOGGLEBUTTON_H
|
||||
69
engines/crab/ui/TraitButton.cpp
Normal file
69
engines/crab/ui/TraitButton.cpp
Normal 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/crab.h"
|
||||
#include "crab/ui/TraitButton.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::image;
|
||||
using namespace pyrodactyl::people;
|
||||
|
||||
void TraitButton::init(const TraitButton &ref, const int &xOffset, const int &yOffset) {
|
||||
StateButton::init(ref, xOffset, yOffset);
|
||||
_offset = ref._offset;
|
||||
}
|
||||
|
||||
void TraitButton::load(rapidxml::xml_node<char> *node, const bool &echo) {
|
||||
StateButton::load(node, echo);
|
||||
|
||||
if (nodeValid("offset", node))
|
||||
_offset.load(node->first_node("offset"), echo);
|
||||
}
|
||||
|
||||
void TraitButton::draw(const int &xOffset, const int &yOffset, Rect *clip) {
|
||||
if (_traitImg != 0)
|
||||
g_engine->_imageManager->draw(x + _offset.x, y + _offset.y, _traitImg);
|
||||
|
||||
StateButton::draw(xOffset, yOffset, clip);
|
||||
}
|
||||
|
||||
void TraitButton::cache(const pyrodactyl::people::Trait &trait) {
|
||||
_traitImg = trait._img;
|
||||
_caption._text = trait._name;
|
||||
}
|
||||
|
||||
void TraitButton::empty() {
|
||||
_traitImg = 0;
|
||||
_caption._text = "";
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
68
engines/crab/ui/TraitButton.h
Normal file
68
engines/crab/ui/TraitButton.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_TRAITBUTTON_H
|
||||
#define CRAB_TRAITBUTTON_H
|
||||
|
||||
#include "crab/people/trait.h"
|
||||
#include "crab/ui/StateButton.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class TraitButton : public StateButton {
|
||||
// The offset for drawing the trait image
|
||||
Vector2i _offset;
|
||||
|
||||
// The trait image
|
||||
ImageKey _traitImg;
|
||||
|
||||
public:
|
||||
TraitButton() {
|
||||
_traitImg = 0;
|
||||
}
|
||||
|
||||
~TraitButton() {}
|
||||
|
||||
void init(const TraitButton &ref, const int &xOffset = 0, const int &yOffset = 0);
|
||||
void load(rapidxml::xml_node<char> *node, const bool &echo = true);
|
||||
|
||||
void draw(const int &xOffset = 0, const int &yOffset = 0, Rect *clip = nullptr);
|
||||
|
||||
void cache(const pyrodactyl::people::Trait &trait);
|
||||
void empty();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_TRAITBUTTON_H
|
||||
122
engines/crab/ui/TraitMenu.cpp
Normal file
122
engines/crab/ui/TraitMenu.cpp
Normal file
@@ -0,0 +1,122 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/crab.h"
|
||||
#include "crab/ui/TraitMenu.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
|
||||
void TraitMenu::load(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid("dim", node)) {
|
||||
rapidxml::xml_node<char> *dimnode = node->first_node("dim");
|
||||
loadNum(_rows, "rows", dimnode);
|
||||
loadNum(_cols, "cols", dimnode);
|
||||
_size = _rows * _cols;
|
||||
}
|
||||
|
||||
if (nodeValid("ref", node))
|
||||
_ref.load(node->first_node("ref"));
|
||||
|
||||
if (nodeValid("inc", node))
|
||||
_inc.load(node->first_node("inc"));
|
||||
|
||||
if (nodeValid("desc", node))
|
||||
_desc.load(node->first_node("desc"));
|
||||
|
||||
for (uint i = 0; i < _size; ++i) {
|
||||
TraitButton b;
|
||||
b.init(_ref, _inc.x * (i % _cols), _inc.y * (i / _cols));
|
||||
_menu._element.push_back(b);
|
||||
}
|
||||
|
||||
bool usekey = false;
|
||||
loadBool(usekey, "keyboard", node);
|
||||
_menu.useKeyboard(usekey);
|
||||
|
||||
_menu.assignPaths();
|
||||
}
|
||||
|
||||
void TraitMenu::draw(const pyrodactyl::people::Person *obj) {
|
||||
if (obj != nullptr) {
|
||||
auto i = _menu._element.begin();
|
||||
for (auto t = obj->_trait.begin(); t != obj->_trait.end() && i != _menu._element.end(); ++t, ++i) {
|
||||
i->draw();
|
||||
if (t->_unread)
|
||||
g_engine->_imageManager->notifyDraw(i->x + i->w, i->y);
|
||||
}
|
||||
|
||||
for (; i != _menu._element.end(); ++i)
|
||||
i->draw();
|
||||
|
||||
if (_select > -1 && (uint)_select < obj->_trait.size())
|
||||
_desc.draw(obj->_trait[_select]._desc);
|
||||
} else
|
||||
for (auto &i : _menu._element)
|
||||
i.draw();
|
||||
}
|
||||
|
||||
void TraitMenu::handleEvents(pyrodactyl::people::Person *obj, const Common::Event &event) {
|
||||
int choice = _menu.handleEvents(event);
|
||||
if (choice >= 0) {
|
||||
for (auto i = _menu._element.begin(); i != _menu._element.end(); ++i)
|
||||
i->state(false);
|
||||
|
||||
_menu._element[choice].state(true);
|
||||
_select = choice;
|
||||
|
||||
if (obj != nullptr && (uint)_select < obj->_trait.size())
|
||||
obj->_trait[_select]._unread = false;
|
||||
}
|
||||
}
|
||||
|
||||
void TraitMenu::cache(const pyrodactyl::people::Person &obj) {
|
||||
auto e = _menu._element.begin();
|
||||
|
||||
for (auto i = obj._trait.begin(); i != obj._trait.end() && e != _menu._element.end(); ++i, ++e)
|
||||
e->cache(*i);
|
||||
|
||||
for (; e != _menu._element.end(); ++e)
|
||||
e->empty();
|
||||
}
|
||||
|
||||
void TraitMenu::clear() {
|
||||
for (auto &e : _menu._element)
|
||||
e.empty();
|
||||
}
|
||||
|
||||
void TraitMenu::setUI() {
|
||||
_ref.setUI();
|
||||
_desc.setUI();
|
||||
_menu.setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
91
engines/crab/ui/TraitMenu.h
Normal file
91
engines/crab/ui/TraitMenu.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_TRAITMENU_H
|
||||
#define CRAB_TRAITMENU_H
|
||||
|
||||
#include "crab/people/person.h"
|
||||
#include "crab/ui/menu.h"
|
||||
#include "crab/ui/ParagraphData.h"
|
||||
#include "crab/ui/TraitButton.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class TraitMenu {
|
||||
// The menu for displaying all the traits
|
||||
Menu<TraitButton> _menu;
|
||||
|
||||
// The reference button (from which all buttons are initialized)
|
||||
TraitButton _ref;
|
||||
|
||||
// This vector stores the increments in x,y for each new button
|
||||
Vector2i _inc;
|
||||
|
||||
// How to draw the selected trait description
|
||||
ParagraphData _desc;
|
||||
|
||||
// The selected trait, and size of the menu
|
||||
int _select;
|
||||
|
||||
// The size and dimensions of the menu
|
||||
uint _size, _rows, _cols;
|
||||
|
||||
public:
|
||||
TraitMenu() {
|
||||
_select = -1;
|
||||
_size = 1;
|
||||
_rows = 1;
|
||||
_cols = 1;
|
||||
}
|
||||
|
||||
~TraitMenu() {}
|
||||
|
||||
void reset() {
|
||||
_select = -1;
|
||||
}
|
||||
|
||||
void clear();
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
void draw(const pyrodactyl::people::Person *obj);
|
||||
|
||||
void handleEvents(pyrodactyl::people::Person *obj, const Common::Event &event);
|
||||
|
||||
void cache(const pyrodactyl::people::Person &obj);
|
||||
void setUI();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_TRAITMENU_H
|
||||
203
engines/crab/ui/button.cpp
Normal file
203
engines/crab/ui/button.cpp
Normal file
@@ -0,0 +1,203 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
//=============================================================================
|
||||
// Author: Arvind
|
||||
// Purpose: Contains the button functions
|
||||
//=============================================================================
|
||||
#include "crab/crab.h"
|
||||
#include "crab/input/cursor.h"
|
||||
#include "crab/ui/button.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::image;
|
||||
using namespace pyrodactyl::input;
|
||||
using namespace pyrodactyl::music;
|
||||
using namespace pyrodactyl::text;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//------------------------------------------------------------------------
|
||||
Button::Button() {
|
||||
_visible = false;
|
||||
_canmove = false;
|
||||
_seClick = -1;
|
||||
_seHover = -1;
|
||||
_hoverPrev = false;
|
||||
reset();
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Load a new Button from a file
|
||||
//------------------------------------------------------------------------
|
||||
void Button::load(rapidxml::xml_node<char> *node, const bool &echo) {
|
||||
_img.load(node, echo);
|
||||
Element::load(node, _img._normal, echo);
|
||||
|
||||
loadNum(_seClick, "click", node, echo);
|
||||
loadNum(_seHover, "hover", node, echo);
|
||||
|
||||
if (nodeValid("hotkey", node, false))
|
||||
_hotkey.load(node->first_node("hotkey"));
|
||||
|
||||
_tooltip.load(node->first_node("tooltip"), this);
|
||||
_caption.load(node->first_node("caption"), this);
|
||||
|
||||
_visible = true;
|
||||
_canmove = false;
|
||||
reset();
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Load a new Button
|
||||
//------------------------------------------------------------------------
|
||||
void Button::init(const Button &ref, const int &xOffset, const int &yOffset) {
|
||||
_img = ref._img;
|
||||
Element::init(ref, _img._normal, xOffset, yOffset);
|
||||
_seClick = ref._seClick;
|
||||
_seHover = ref._seHover;
|
||||
|
||||
_caption.init(ref._caption, xOffset, yOffset);
|
||||
_tooltip.init(ref._tooltip, xOffset, yOffset);
|
||||
|
||||
_visible = true;
|
||||
_canmove = false;
|
||||
reset();
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Reset the button
|
||||
//------------------------------------------------------------------------
|
||||
void Button::reset() {
|
||||
_mousePressed = false;
|
||||
_hoverMouse = false;
|
||||
_hoverKey = false;
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Draw
|
||||
//------------------------------------------------------------------------
|
||||
void Button::draw(const int &xOffset, const int &yOffset, Rect *clip) {
|
||||
if (_visible) {
|
||||
if (_mousePressed) {
|
||||
g_engine->_imageManager->draw(x + xOffset, y + yOffset, _img._select, clip);
|
||||
|
||||
_tooltip.draw(xOffset, yOffset);
|
||||
_caption.draw(true, xOffset, yOffset);
|
||||
} else if (_hoverMouse || _hoverKey) {
|
||||
g_engine->_imageManager->draw(x + xOffset, y + yOffset, _img._hover, clip);
|
||||
|
||||
_tooltip.draw(xOffset, yOffset);
|
||||
_caption.draw(true, xOffset, yOffset);
|
||||
} else {
|
||||
g_engine->_imageManager->draw(x + xOffset, y + yOffset, _img._normal, clip);
|
||||
_caption.draw(false, xOffset, yOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Button::imageCaptionOnlyDraw(const int &xOffset, const int &yOffset, Rect *clip) {
|
||||
if (_visible) {
|
||||
if (_mousePressed) {
|
||||
g_engine->_imageManager->draw(x + xOffset, y + yOffset, _img._select, clip);
|
||||
_caption.draw(true, xOffset, yOffset);
|
||||
} else if (_hoverMouse || _hoverKey) {
|
||||
g_engine->_imageManager->draw(x + xOffset, y + yOffset, _img._hover, clip);
|
||||
_caption.draw(true, xOffset, yOffset);
|
||||
} else {
|
||||
g_engine->_imageManager->draw(x + xOffset, y + yOffset, _img._normal, clip);
|
||||
_caption.draw(false, xOffset, yOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Button::hoverInfoOnlyDraw(const int &xOffset, const int &yOffset, Rect *clip) {
|
||||
if (_visible) {
|
||||
if (_mousePressed || _hoverMouse || _hoverKey)
|
||||
_tooltip.draw(xOffset, yOffset);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Handle input and stuff
|
||||
//------------------------------------------------------------------------
|
||||
ButtonAction Button::handleEvents(const Common::Event &event, const int &xOffset, const int &yOffset) {
|
||||
Rect dim = *this;
|
||||
dim.x += xOffset;
|
||||
dim.y += yOffset;
|
||||
|
||||
if (_visible) {
|
||||
if (dim.contains(g_engine->_mouse->_motion.x, g_engine->_mouse->_motion.y)) {
|
||||
_hoverMouse = true;
|
||||
|
||||
if (!_hoverPrev) {
|
||||
_hoverPrev = true;
|
||||
g_engine->_musicManager->playEffect(_seHover, 0);
|
||||
}
|
||||
} else {
|
||||
_hoverPrev = false;
|
||||
_hoverMouse = false;
|
||||
}
|
||||
|
||||
if (event.type == Common::EVENT_MOUSEMOVE) {
|
||||
if (_canmove && _mousePressed) {
|
||||
x += g_engine->_mouse->_rel.x;
|
||||
y += g_engine->_mouse->_rel.y;
|
||||
return BUAC_GRABBED;
|
||||
}
|
||||
} else if (event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_RBUTTONDOWN) {
|
||||
// The g_engine->_mouse button pressed, then released, comprises of a click action
|
||||
if (dim.contains(g_engine->_mouse->_button.x, g_engine->_mouse->_button.y))
|
||||
_mousePressed = true;
|
||||
} else if ((event.type == Common::EVENT_LBUTTONUP || event.type == Common::EVENT_RBUTTONUP) && _mousePressed) {
|
||||
reset();
|
||||
if (dim.contains(g_engine->_mouse->_button.x, g_engine->_mouse->_button.y)) {
|
||||
_mousePressed = false;
|
||||
if (event.type == Common::EVENT_LBUTTONUP) {
|
||||
g_engine->_musicManager->playEffect(_seClick, 0);
|
||||
return BUAC_LCLICK;
|
||||
} else if (event.type == Common::EVENT_RBUTTONUP)
|
||||
return BUAC_RCLICK;
|
||||
}
|
||||
} else if (_hotkey.handleEvents(event)) {
|
||||
g_engine->_musicManager->playEffect(_seClick, 0);
|
||||
return BUAC_LCLICK;
|
||||
}
|
||||
}
|
||||
|
||||
return BUAC_IGNORE;
|
||||
}
|
||||
|
||||
void Button::setUI(Rect *parent) {
|
||||
Element::setUI(parent);
|
||||
|
||||
_tooltip.setUI(this);
|
||||
_caption.setUI(this);
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
145
engines/crab/ui/button.h
Normal file
145
engines/crab/ui/button.h
Normal file
@@ -0,0 +1,145 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
//=============================================================================
|
||||
// Author: Arvind
|
||||
// Purpose: Button class
|
||||
//=============================================================================
|
||||
#ifndef CRAB_BUTTON_H
|
||||
#define CRAB_BUTTON_H
|
||||
|
||||
#include "crab/GameParam.h"
|
||||
#include "crab/image/ImageManager.h"
|
||||
#include "crab/input/hotkey.h"
|
||||
#include "crab/music/MusicManager.h"
|
||||
#include "crab/text/TextManager.h"
|
||||
#include "crab/ui/Caption.h"
|
||||
#include "crab/ui/element.h"
|
||||
#include "crab/ui/HoverInfo.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
enum ButtonAction {
|
||||
BUAC_IGNORE,
|
||||
BUAC_LCLICK,
|
||||
BUAC_RCLICK,
|
||||
BUAC_GRABBED
|
||||
};
|
||||
|
||||
struct ButtonImage {
|
||||
ImageKey _normal, _select, _hover;
|
||||
|
||||
bool operator==(const ButtonImage &img) {
|
||||
return _normal == img._normal && _select == img._select && _hover == img._hover; }
|
||||
|
||||
|
||||
ButtonImage() {
|
||||
_normal = 0;
|
||||
_select = 0;
|
||||
_hover = 0;
|
||||
}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node, const bool &echo = true) {
|
||||
if (nodeValid(node)) {
|
||||
loadImgKey(_normal, "img_b", node, echo);
|
||||
loadImgKey(_select, "img_s", node, echo);
|
||||
loadImgKey(_hover, "img_h", node, echo);
|
||||
}
|
||||
}
|
||||
|
||||
void saveState(rapidxml::xml_document<> &doc, rapidxml::xml_node<char> *root) {
|
||||
root->append_attribute(doc.allocate_attribute("img_b", g_engine->_stringPool->get(_normal)));
|
||||
root->append_attribute(doc.allocate_attribute("img_s", g_engine->_stringPool->get(_select)));
|
||||
root->append_attribute(doc.allocate_attribute("img_h", g_engine->_stringPool->get(_hover)));
|
||||
}
|
||||
};
|
||||
|
||||
class Button : public Element {
|
||||
public:
|
||||
bool _visible, _mousePressed;
|
||||
|
||||
// We need to keep track of keyboard and mouse hovering separately
|
||||
bool _hoverMouse, _hoverKey, _hoverPrev;
|
||||
|
||||
// Can the player move this button?
|
||||
bool _canmove;
|
||||
|
||||
// The button images
|
||||
ButtonImage _img;
|
||||
|
||||
// The sound effect played when button is clicked
|
||||
pyrodactyl::music::ChunkKey _seClick, _seHover;
|
||||
|
||||
// Text shown when mouse is hovered over the button
|
||||
HoverInfo _tooltip;
|
||||
|
||||
// Text shown all times on the button
|
||||
Caption _caption;
|
||||
|
||||
// A hotkey is a keyboard key(s) that are equivalent to pressing a button
|
||||
pyrodactyl::input::HotKey _hotkey;
|
||||
|
||||
Button();
|
||||
~Button() {}
|
||||
void reset();
|
||||
|
||||
void setUI(Rect *parent = nullptr);
|
||||
|
||||
void load(rapidxml::xml_node<char> *node, const bool &echo = true);
|
||||
void init(const Button &ref, const int &xOffset = 0, const int &yOffset = 0);
|
||||
|
||||
void img(Button &b) {
|
||||
_img = b._img;
|
||||
}
|
||||
|
||||
void img(ButtonImage &image) {
|
||||
_img = image;
|
||||
}
|
||||
|
||||
ButtonImage img() {
|
||||
return _img;
|
||||
}
|
||||
|
||||
void draw(const int &xOffset = 0, const int &yOffset = 0, Rect *clip = nullptr);
|
||||
|
||||
ButtonAction handleEvents(const Common::Event &event, const int &xOffset = 0, const int &yOffset = 0);
|
||||
|
||||
// Special functions to only draw parts of a button (used in special situations like world map)
|
||||
void imageCaptionOnlyDraw(const int &xOffset = 0, const int &yOffset = 0, Rect *clip = nullptr);
|
||||
void hoverInfoOnlyDraw(const int &xOffset = 0, const int &yOffset = 0, Rect *clip = nullptr);
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_BUTTON_H
|
||||
106
engines/crab/ui/dialogbox.cpp
Normal file
106
engines/crab/ui/dialogbox.cpp
Normal file
@@ -0,0 +1,106 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
//=============================================================================
|
||||
// Author: Arvind
|
||||
// Purpose: Dialog box!
|
||||
//=============================================================================
|
||||
#include "crab/crab.h"
|
||||
#include "crab/ui/dialogbox.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::text;
|
||||
using namespace pyrodactyl::image;
|
||||
using namespace pyrodactyl::input;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Load stuff
|
||||
//------------------------------------------------------------------------
|
||||
void GameDialogBox::load(rapidxml::xml_node<char> *node) {
|
||||
loadImgKey(_bg, "bg", node);
|
||||
loadImgKey(_bgP, "bg_p", node);
|
||||
_pos.load(node, _bg);
|
||||
|
||||
if (nodeValid("text", node))
|
||||
_text.load(node->first_node("text"), &_pos);
|
||||
|
||||
if (nodeValid("button", node))
|
||||
_button.load(node->first_node("button"));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Draw the dialog box background
|
||||
//------------------------------------------------------------------------
|
||||
void GameDialogBox::draw(const bool &player) {
|
||||
if (player)
|
||||
g_engine->_imageManager->draw(_pos.x, _pos.y, _bgP);
|
||||
else
|
||||
g_engine->_imageManager->draw(_pos.x, _pos.y, _bg);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Draw the dialog box text
|
||||
//------------------------------------------------------------------------
|
||||
void GameDialogBox::draw(pyrodactyl::event::Info &info, Common::String &message) {
|
||||
// Create a copy of the string
|
||||
Common::String msg = message;
|
||||
info.insertName(msg);
|
||||
|
||||
_text.draw(message);
|
||||
_button.draw();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Handle input
|
||||
//------------------------------------------------------------------------
|
||||
bool GameDialogBox::handleEvents(const Common::Event &event) {
|
||||
// Switch to KBM_UI
|
||||
if (g_engine->_inputManager->getKeyBindingMode() != KBM_UI)
|
||||
g_engine->_inputManager->setKeyBindingMode(KBM_UI);
|
||||
|
||||
bool isLeftClick = (_button.handleEvents(event) == BUAC_LCLICK);
|
||||
|
||||
if (isLeftClick) {
|
||||
// Switch to KBM_GAME
|
||||
g_engine->_inputManager->setKeyBindingMode(KBM_GAME);
|
||||
}
|
||||
|
||||
return isLeftClick;
|
||||
}
|
||||
|
||||
void GameDialogBox::setUI() {
|
||||
_pos.setUI();
|
||||
_text.setUI(&_pos);
|
||||
_button.setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
84
engines/crab/ui/dialogbox.h
Normal file
84
engines/crab/ui/dialogbox.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
//=============================================================================
|
||||
// Author: Arvind
|
||||
// Purpose: Dialog box!
|
||||
//=============================================================================
|
||||
#ifndef CRAB_DIALOGBOX_H
|
||||
#define CRAB_DIALOGBOX_H
|
||||
|
||||
#include "crab/event/GameEventInfo.h"
|
||||
#include "crab/ui/button.h"
|
||||
#include "crab/ui/ParagraphData.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class GameDialogBox {
|
||||
// The position of the dialog box
|
||||
Element _pos;
|
||||
|
||||
// The area you click to skip to the next dialog
|
||||
Button _button;
|
||||
|
||||
// Information related to drawing the dialog box
|
||||
ParagraphData _text;
|
||||
|
||||
// The usual background
|
||||
ImageKey _bg;
|
||||
|
||||
// The background drawn when we don't want to show the opinion bars
|
||||
ImageKey _bgP;
|
||||
|
||||
public:
|
||||
GameDialogBox() {
|
||||
_bg = 0;
|
||||
_bgP = 0;
|
||||
}
|
||||
|
||||
~GameDialogBox() {}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
|
||||
void draw(pyrodactyl::event::Info &info, Common::String &message);
|
||||
void draw(const bool &player);
|
||||
|
||||
bool handleEvents(const Common::Event &event);
|
||||
|
||||
void setUI();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_DIALOGBOX_H
|
||||
138
engines/crab/ui/element.cpp
Normal file
138
engines/crab/ui/element.cpp
Normal file
@@ -0,0 +1,138 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/ScreenSettings.h"
|
||||
#include "crab/crab.h"
|
||||
#include "crab/ui/element.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::image;
|
||||
|
||||
void Element::init(const int &xCord, const int &yCord, const Align &alignX, const Align &alignY,
|
||||
const ImageKey img, const int &width, const int &height) {
|
||||
x = xCord;
|
||||
y = yCord;
|
||||
_align.x = alignX;
|
||||
_align.y = alignY;
|
||||
|
||||
if (img == 0) {
|
||||
w = width;
|
||||
h = height;
|
||||
} else {
|
||||
Image dat = g_engine->_imageManager->getTexture(img);
|
||||
w = dat.w();
|
||||
h = dat.h();
|
||||
}
|
||||
}
|
||||
|
||||
void Element::basicload(rapidxml::xml_node<char> *node, const bool &echo) {
|
||||
_raw.load(node, echo);
|
||||
loadAlign(_align.x, node, echo, "align_x");
|
||||
loadAlign(_align.y, node, echo, "align_y");
|
||||
}
|
||||
|
||||
void Element::load(rapidxml::xml_node<char> *node, ImageKey img, const bool &echo) {
|
||||
basicload(node, echo);
|
||||
|
||||
if (node->first_attribute("w") == nullptr)
|
||||
w = g_engine->_imageManager->getTexture(img).w();
|
||||
else
|
||||
loadNum(w, "w", node);
|
||||
|
||||
if (node->first_attribute("h") == nullptr)
|
||||
h = g_engine->_imageManager->getTexture(img).h();
|
||||
else
|
||||
loadNum(h, "h", node);
|
||||
|
||||
setUI();
|
||||
}
|
||||
|
||||
void Element::load(rapidxml::xml_node<char> *node, Rect *parent, const bool &echo) {
|
||||
basicload(node, echo);
|
||||
loadNum(w, "w", node, false);
|
||||
loadNum(h, "h", node, false);
|
||||
setUI(parent);
|
||||
}
|
||||
|
||||
void Element::setUI(Rect *parent) {
|
||||
if (parent == nullptr) {
|
||||
switch (_align.x) {
|
||||
case ALIGN_CENTER:
|
||||
x = g_engine->_screenSettings->_cur.w / 2 - w / 2 + _raw.x;
|
||||
break;
|
||||
case ALIGN_RIGHT:
|
||||
x = g_engine->_screenSettings->_cur.w - w + _raw.x;
|
||||
break;
|
||||
default:
|
||||
x = _raw.x;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (_align.y) {
|
||||
case ALIGN_CENTER:
|
||||
y = g_engine->_screenSettings->_cur.h / 2 - h / 2 + _raw.y;
|
||||
break;
|
||||
case ALIGN_RIGHT:
|
||||
y = g_engine->_screenSettings->_cur.h - h + _raw.y;
|
||||
break;
|
||||
default:
|
||||
y = _raw.y;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (_align.x) {
|
||||
case ALIGN_CENTER:
|
||||
x = parent->x + parent->w / 2 - w / 2 + _raw.x;
|
||||
break;
|
||||
case ALIGN_RIGHT:
|
||||
x = parent->x + parent->w - w + _raw.x;
|
||||
break;
|
||||
default:
|
||||
x = parent->x + _raw.x;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (_align.y) {
|
||||
case ALIGN_CENTER:
|
||||
y = parent->y + parent->h / 2 - h / 2 + _raw.y;
|
||||
break;
|
||||
case ALIGN_RIGHT:
|
||||
y = parent->y + parent->h - h + _raw.y;
|
||||
break;
|
||||
default:
|
||||
y = parent->y + _raw.y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
84
engines/crab/ui/element.h
Normal file
84
engines/crab/ui/element.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_ELEMENT_H
|
||||
#define CRAB_ELEMENT_H
|
||||
|
||||
#include "crab/image/ImageManager.h"
|
||||
#include "crab/Rectangle.h"
|
||||
#include "crab/vectors.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class Element : public Rect {
|
||||
// The position loaded directly from xml
|
||||
Vector2i _raw;
|
||||
|
||||
// Which side of the screen is this object aligned to?
|
||||
struct {
|
||||
Align x, y;
|
||||
} _align;
|
||||
|
||||
void basicload(rapidxml::xml_node<char> *node, const bool &echo = true);
|
||||
|
||||
public:
|
||||
Element() {
|
||||
_align.x = ALIGN_LEFT;
|
||||
_align.y = ALIGN_LEFT;
|
||||
}
|
||||
~Element() {}
|
||||
|
||||
// Initialize an element without loading it from file
|
||||
void init(const int &x, const int &y, const Align &alignX, const Align &alignY,
|
||||
const ImageKey image = 0, const int &w = 0, const int &h = 0);
|
||||
|
||||
// Initialize an element from another
|
||||
void init(const Element &e, ImageKey img = 0, const int &xOffset = 0, const int &yOffset = 0) {
|
||||
_raw.x = e._raw.x + xOffset;
|
||||
_raw.y = e._raw.y + yOffset;
|
||||
init(e.x + xOffset, e.y + yOffset, e._align.x, e._align.y, img, e.w, e.h);
|
||||
}
|
||||
|
||||
// The parent is the object inside which the element exists
|
||||
void load(rapidxml::xml_node<char> *node, ImageKey img, const bool &echo = true);
|
||||
|
||||
// The parent is the object inside which the element exists
|
||||
void load(rapidxml::xml_node<char> *node, Rect *parent = nullptr, const bool &echo = true);
|
||||
|
||||
void setUI(Rect *parent = nullptr);
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_ELEMENT_H
|
||||
54
engines/crab/ui/emotion.cpp
Normal file
54
engines/crab/ui/emotion.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/ui/emotion.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::event;
|
||||
|
||||
void EmotionIndicator::load(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid("text", node))
|
||||
_text.load(node->first_node("text"));
|
||||
}
|
||||
|
||||
void EmotionIndicator::draw(const int &select) {
|
||||
if (select >= 0 && (uint)select < _value.size())
|
||||
if (_value[select] < g_engine->_eventStore->_tone.size()) {
|
||||
_text.draw(g_engine->_eventStore->_tone[_value[select]]._text);
|
||||
}
|
||||
}
|
||||
|
||||
void EmotionIndicator::setUI() {
|
||||
_text.setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
59
engines/crab/ui/emotion.h
Normal file
59
engines/crab/ui/emotion.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_EMOTION_H
|
||||
#define CRAB_EMOTION_H
|
||||
|
||||
#include "crab/event/eventstore.h"
|
||||
#include "crab/ui/textarea.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
struct EmotionIndicator {
|
||||
// The info for drawing the description
|
||||
TextData _text;
|
||||
|
||||
// This array is used to store the corresponding tone values to a reply
|
||||
Common::Array<uint> _value;
|
||||
|
||||
EmotionIndicator() {}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
void draw(const int &select);
|
||||
void setUI();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_EMOTION_H
|
||||
165
engines/crab/ui/hud.cpp
Normal file
165
engines/crab/ui/hud.cpp
Normal file
@@ -0,0 +1,165 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
//=============================================================================
|
||||
// Author: Arvind
|
||||
// Purpose: The tray where you have inventory, map and GameObjectives icons
|
||||
//=============================================================================
|
||||
#include "crab/XMLDoc.h"
|
||||
#include "crab/input/cursor.h"
|
||||
#include "crab/ui/hud.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::image;
|
||||
using namespace pyrodactyl::input;
|
||||
|
||||
void HUD::load(const Common::Path &filename, pyrodactyl::level::TalkNotify &tn, pyrodactyl::level::PlayerDestMarker &pdm) {
|
||||
XMLDoc conf(filename);
|
||||
if (conf.ready()) {
|
||||
rapidxml::xml_node<char> *node = conf.doc()->first_node("hud");
|
||||
if (nodeValid(node)) {
|
||||
if (nodeValid("bg", node))
|
||||
_bg.load(node->first_node("bg"));
|
||||
|
||||
if (nodeValid("tray", node))
|
||||
_menu.load(node->first_node("tray"));
|
||||
|
||||
_pause.load(node->first_node("pause"));
|
||||
_gom.load(node->first_node("game_over"));
|
||||
_back.load(node->first_node("back"));
|
||||
// health.load(node->first_node("health"));
|
||||
|
||||
if (nodeValid("notify", node)) {
|
||||
rapidxml::xml_node<char> *notifynode = node->first_node("notify");
|
||||
|
||||
loadImgKey(g_engine->_imageManager->_notify, "img", notifynode);
|
||||
tn.load(notifynode);
|
||||
pdm.load(notifynode);
|
||||
|
||||
if (nodeValid("anim", notifynode)) {
|
||||
rapidxml::xml_node<char> *animnode = notifynode->first_node("anim");
|
||||
loadImgKey(_notifyAnim, "img", animnode);
|
||||
_clip.load(animnode);
|
||||
|
||||
_timer.load(animnode, "delay");
|
||||
_timer.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create a copy of all the tooltips
|
||||
for (const auto &i : _menu._element)
|
||||
_tooltip.push_back(i._tooltip._text);
|
||||
|
||||
setTooltip();
|
||||
}
|
||||
}
|
||||
|
||||
void HUD::draw(pyrodactyl::event::Info &info, const Common::String &id) {
|
||||
_bg.draw();
|
||||
_menu.draw();
|
||||
|
||||
if (info._unread._journal) {
|
||||
g_engine->_imageManager->draw(_menu._element[HS_JOURNAL].x + _menu._element[HS_JOURNAL].w - _clip.w / 2,
|
||||
_menu._element[HS_JOURNAL].y - _clip.h / 2, _notifyAnim, &_clip);
|
||||
}
|
||||
|
||||
if (info._unread._inventory) {
|
||||
g_engine->_imageManager->draw(_menu._element[HS_INV].x + _menu._element[HS_INV].w - _clip.w / 2,
|
||||
_menu._element[HS_INV].y - _clip.h / 2, _notifyAnim, &_clip);
|
||||
}
|
||||
|
||||
if (info._unread._trait) {
|
||||
g_engine->_imageManager->draw(_menu._element[HS_CHAR].x + _menu._element[HS_CHAR].w - _clip.w / 2,
|
||||
_menu._element[HS_CHAR].y - _clip.h / 2, _notifyAnim, &_clip);
|
||||
}
|
||||
|
||||
if (info._unread._map) {
|
||||
g_engine->_imageManager->draw(_menu._element[HS_MAP].x + _menu._element[HS_MAP].w - _clip.w / 2,
|
||||
_menu._element[HS_MAP].y - _clip.h / 2, _notifyAnim, &_clip);
|
||||
}
|
||||
}
|
||||
|
||||
void HUD::internalEvents(bool showMap) {
|
||||
_menu._element[HS_MAP]._visible = showMap;
|
||||
|
||||
if (_timer.targetReached()) {
|
||||
_clip.x += _clip.w;
|
||||
|
||||
if (_clip.x >= g_engine->_imageManager->getTexture(_notifyAnim).w())
|
||||
_clip.x = 0;
|
||||
|
||||
_timer.start();
|
||||
}
|
||||
}
|
||||
|
||||
HUDSignal HUD::handleEvents(pyrodactyl::event::Info &info, const Common::Event &event) {
|
||||
g_engine->_mouse->_insideHud = _bg.contains(g_engine->_mouse->_motion.x, g_engine->_mouse->_motion.y);
|
||||
|
||||
int choice = _menu.handleEvents(event);
|
||||
|
||||
if (choice == HS_JOURNAL)
|
||||
info._unread._journal = false;
|
||||
else if (choice == HS_INV)
|
||||
info._unread._inventory = false;
|
||||
else if (choice == HS_CHAR)
|
||||
info._unread._trait = false;
|
||||
else if (choice == HS_MAP)
|
||||
info._unread._map = false;
|
||||
|
||||
return static_cast<HUDSignal>(choice);
|
||||
}
|
||||
|
||||
void HUD::State(const int &val) {
|
||||
int count = 0;
|
||||
for (auto i = _menu._element.begin(); i != _menu._element.end(); ++i, ++count)
|
||||
i->state(val == count);
|
||||
}
|
||||
|
||||
void HUD::setTooltip() {
|
||||
uint count = 0;
|
||||
for (auto i = _menu._element.begin(); i != _menu._element.end() && count < _tooltip.size(); ++i, ++count)
|
||||
i->_tooltip._text = _tooltip[count] + " (" + i->_hotkey.name() + ")";
|
||||
|
||||
_menu._element[HS_PAUSE]._tooltip._text = _tooltip[HS_PAUSE] + " (" + g_engine->_inputManager->getAssociatedKey(IG_PAUSE) + ")";
|
||||
}
|
||||
|
||||
void HUD::setUI() {
|
||||
_bg.setUI();
|
||||
_menu.setUI();
|
||||
|
||||
_gom.setUI();
|
||||
_pause.setUI();
|
||||
_back.setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
117
engines/crab/ui/hud.h
Normal file
117
engines/crab/ui/hud.h
Normal file
@@ -0,0 +1,117 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
//=============================================================================
|
||||
// Author: Arvind
|
||||
// Purpose: The tray where you have inventory, map and journal icons
|
||||
//=============================================================================
|
||||
#ifndef CRAB_HUD_H
|
||||
#define CRAB_HUD_H
|
||||
|
||||
#include "crab/event/GameEventInfo.h"
|
||||
#include "crab/level/level_objects.h"
|
||||
#include "crab/level/talknotify.h"
|
||||
#include "crab/ui/FileMenu.h"
|
||||
#include "crab/ui/GameOverMenu.h"
|
||||
#include "crab/ui/PauseMenu.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
enum HUDSignal {
|
||||
HS_NONE = -1,
|
||||
HS_MAP,
|
||||
HS_PAUSE,
|
||||
HS_CHAR,
|
||||
HS_JOURNAL,
|
||||
HS_INV
|
||||
};
|
||||
|
||||
// The world map, inventory and objective buttons are in the button menu
|
||||
class HUD {
|
||||
// The background image
|
||||
ImageData _bg;
|
||||
|
||||
// The launcher menu for stuff like inventory, character, pause etc
|
||||
Menu<StateButton> _menu;
|
||||
|
||||
// The health gem thingy
|
||||
// HealthIndicator health;
|
||||
|
||||
// Sprite sheet for animated notify icon
|
||||
ImageKey _notifyAnim;
|
||||
|
||||
// Animated notification icon needs a clip sign
|
||||
Rect _clip;
|
||||
|
||||
// The amount of time to wait before incrementing clip
|
||||
Timer _timer;
|
||||
|
||||
// The original tooltips as provided in the xml
|
||||
Common::Array<Common::String> _tooltip;
|
||||
|
||||
public:
|
||||
GameOverMenu _gom;
|
||||
PauseMenu _pause;
|
||||
pyrodactyl::input::HotKey _pausekey;
|
||||
Button _back;
|
||||
|
||||
HUD() {
|
||||
_pausekey.set(pyrodactyl::input::IG_PAUSE);
|
||||
_notifyAnim = 0;
|
||||
}
|
||||
~HUD() {}
|
||||
|
||||
void internalEvents(bool showMap);
|
||||
void playerImg(const StateButtonImage &img) {
|
||||
_menu._element[HS_CHAR].img(img);
|
||||
}
|
||||
|
||||
void State(const int &val);
|
||||
|
||||
void load(const Common::Path &filename, pyrodactyl::level::TalkNotify &tn, pyrodactyl::level::PlayerDestMarker &pdm);
|
||||
|
||||
HUDSignal handleEvents(pyrodactyl::event::Info &info, const Common::Event &event);
|
||||
|
||||
void draw(pyrodactyl::event::Info &info, const Common::String &id);
|
||||
|
||||
// Set the tooltips for the buttons in the menu
|
||||
// The tooltips are of the style <Name> (<Hotkey>), with Name being provided by the xml
|
||||
void setTooltip();
|
||||
|
||||
void setUI();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_HUD_H
|
||||
291
engines/crab/ui/journal.cpp
Normal file
291
engines/crab/ui/journal.cpp
Normal file
@@ -0,0 +1,291 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/crab.h"
|
||||
#include "crab/XMLDoc.h"
|
||||
#include "crab/ui/journal.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::image;
|
||||
using namespace pyrodactyl::ui;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Load game
|
||||
//------------------------------------------------------------------------
|
||||
void Journal::load(const Common::Path &filename) {
|
||||
XMLDoc conf(filename);
|
||||
if (conf.ready()) {
|
||||
rapidxml::xml_node<char> *node = conf.doc()->first_node("objectives");
|
||||
if (nodeValid(node)) {
|
||||
if (nodeValid("bg", node))
|
||||
_bg.load(node->first_node("bg"));
|
||||
|
||||
if (nodeValid("map", node))
|
||||
_bu_map.load(node->first_node("map"));
|
||||
|
||||
if (nodeValid("category", node))
|
||||
_category.load(node->first_node("category"));
|
||||
|
||||
if (nodeValid("quest_list", node))
|
||||
_ref.load(node->first_node("quest_list"));
|
||||
|
||||
_category.useKeyboard(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Prepare a new character's journal
|
||||
//------------------------------------------------------------------------
|
||||
void Journal::init(const Common::String &id) {
|
||||
int found = false;
|
||||
|
||||
for (auto &i : _journal)
|
||||
if (i._id == id) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
Group g;
|
||||
g._id = id;
|
||||
for (int i = 0; i < JE_TOTAL; ++i) {
|
||||
g._menu[i] = _ref;
|
||||
g._menu[i].useKeyboard(true);
|
||||
g._menu[i].assignPaths();
|
||||
}
|
||||
_journal.push_back(g);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Select a category
|
||||
//------------------------------------------------------------------------
|
||||
void Journal::select(const Common::String &id, const int &choice) {
|
||||
for (uint i = 0; i < _category._element.size(); ++i)
|
||||
_category._element[i].state(false);
|
||||
|
||||
_category._element[choice].state(true);
|
||||
_select = choice;
|
||||
|
||||
// Always find valid journal group first
|
||||
for (auto &jo : _journal)
|
||||
if (jo._id == id) {
|
||||
jo._menu[choice]._unread = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Draw stuff
|
||||
//------------------------------------------------------------------------
|
||||
void Journal::draw(const Common::String &id) {
|
||||
_bg.draw();
|
||||
_category.draw();
|
||||
|
||||
// Always find valid journal group first
|
||||
for (auto &jo : _journal)
|
||||
if (jo._id == id) {
|
||||
int count = 0;
|
||||
for (auto i = _category._element.begin(); i != _category._element.end() && count < JE_TOTAL; ++i, ++count)
|
||||
if (jo._menu[count]._unread)
|
||||
g_engine->_imageManager->notifyDraw(i->x + i->w, i->y);
|
||||
|
||||
if (_select >= 0 && _select < JE_TOTAL)
|
||||
jo._menu[_select].draw(_bu_map);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Handle user input
|
||||
//------------------------------------------------------------------------
|
||||
bool Journal::handleEvents(const Common::String &id, const Common::Event &event) {
|
||||
int choice = _category.handleEvents(event);
|
||||
if (choice >= 0 && (uint)choice < _category._element.size())
|
||||
select(id, choice);
|
||||
|
||||
// Check if select is valid
|
||||
if (_select >= 0 && _select < JE_TOTAL) {
|
||||
// Always find valid journal group first
|
||||
for (auto &jo : _journal)
|
||||
if (jo._id == id)
|
||||
return jo._menu[_select].handleEvents(_bu_map, _markerTitle, event);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Add an entry to journal
|
||||
//------------------------------------------------------------------------
|
||||
void Journal::add(const Common::String &id, const Common::String &category, const Common::String &title, const Common::String &text) {
|
||||
// Always find valid journal group first
|
||||
for (auto &jo : _journal)
|
||||
if (jo._id == id) {
|
||||
if (category == JE_CUR_NAME) {
|
||||
jo._menu[JE_CUR].add(title, text);
|
||||
} else if (category == JE_DONE_NAME) {
|
||||
jo._menu[JE_DONE].add(title, text);
|
||||
} else if (category == JE_PEOPLE_NAME) {
|
||||
jo._menu[JE_PEOPLE].add(title, text);
|
||||
} else if (category == JE_LOCATION_NAME) {
|
||||
jo._menu[JE_LOCATION].add(title, text);
|
||||
} else if (category == JE_HISTORY_NAME) {
|
||||
jo._menu[JE_HISTORY].add(title, text);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Set the marker of a quest
|
||||
//------------------------------------------------------------------------
|
||||
void Journal::marker(const Common::String &id, const Common::String &title, const bool &val) {
|
||||
// Always find valid journal group first
|
||||
for (auto &jo : _journal)
|
||||
if (jo._id == id) {
|
||||
jo._menu[JE_CUR].marker(title, val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Move an entry from one category to another
|
||||
//------------------------------------------------------------------------
|
||||
void Journal::move(const Common::String &id, const Common::String &title, const bool &completed) {
|
||||
JournalCategory source, destination;
|
||||
if (completed) {
|
||||
source = JE_CUR;
|
||||
destination = JE_DONE;
|
||||
} else {
|
||||
source = JE_DONE;
|
||||
destination = JE_CUR;
|
||||
}
|
||||
|
||||
// Always find valid journal group first
|
||||
for (auto &jo : _journal)
|
||||
if (jo._id == id) {
|
||||
// Find the quest chain in the source menu
|
||||
uint index = 0;
|
||||
for (auto i = jo._menu[source]._quest.begin(); i != jo._menu[source]._quest.end(); ++i, ++index)
|
||||
if (i->_title == title)
|
||||
break;
|
||||
|
||||
if (index < jo._menu[source]._quest.size()) {
|
||||
jo._menu[destination].add(jo._menu[source]._quest[index]);
|
||||
jo._menu[source].erase(index);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Open a specific entry in the journal
|
||||
//------------------------------------------------------------------------
|
||||
void Journal::open(const Common::String &id, const JournalCategory &category, const Common::String &title) {
|
||||
// Always find valid journal group first
|
||||
for (auto &jo : _journal)
|
||||
if (jo._id == id) {
|
||||
if (category >= 0 && category < (int)_category._element.size()) {
|
||||
// If category passes the valid check, select it
|
||||
select(id, category);
|
||||
|
||||
// Perform validity check on select, just in case
|
||||
if (_select > 0 && _select < JE_TOTAL) {
|
||||
// Search for the title with same name
|
||||
for (uint num = 0; num < jo._menu[_select]._quest.size(); ++num)
|
||||
if (jo._menu[_select]._quest[num]._title == title) {
|
||||
// Found it, switch to this
|
||||
jo._menu[_select].select(num);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Load save game stuff
|
||||
//------------------------------------------------------------------------
|
||||
void Journal::saveState(rapidxml::xml_document<> &doc, rapidxml::xml_node<char> *root) {
|
||||
for (auto &m : _journal) {
|
||||
rapidxml::xml_node<char> *child = doc.allocate_node(rapidxml::node_element, "journal");
|
||||
child->append_attribute(doc.allocate_attribute("id", m._id.c_str()));
|
||||
|
||||
m._menu[JE_CUR].saveState(doc, child, JE_CUR_NAME);
|
||||
m._menu[JE_DONE].saveState(doc, child, JE_DONE_NAME);
|
||||
m._menu[JE_PEOPLE].saveState(doc, child, JE_PEOPLE_NAME);
|
||||
m._menu[JE_LOCATION].saveState(doc, child, JE_LOCATION_NAME);
|
||||
m._menu[JE_HISTORY].saveState(doc, child, JE_HISTORY_NAME);
|
||||
root->append_node(child);
|
||||
}
|
||||
}
|
||||
|
||||
void Journal::loadState(rapidxml::xml_node<char> *node) {
|
||||
_journal.clear();
|
||||
|
||||
for (rapidxml::xml_node<char> *n = node->first_node("journal"); n != nullptr; n = n->next_sibling("journal")) {
|
||||
Common::String id;
|
||||
loadStr(id, "id", n);
|
||||
|
||||
init(id);
|
||||
|
||||
for (auto &i : _journal)
|
||||
if (i._id == id) {
|
||||
i._menu[JE_CUR].loadState(n->first_node(JE_CUR_NAME));
|
||||
i._menu[JE_DONE].loadState(n->first_node(JE_DONE_NAME));
|
||||
i._menu[JE_PEOPLE].loadState(n->first_node(JE_PEOPLE_NAME));
|
||||
i._menu[JE_LOCATION].loadState(n->first_node(JE_LOCATION_NAME));
|
||||
i._menu[JE_HISTORY].loadState(n->first_node(JE_HISTORY_NAME));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Adjust UI elements
|
||||
//------------------------------------------------------------------------
|
||||
void Journal::setUI() {
|
||||
_bg.setUI();
|
||||
_category.setUI();
|
||||
_ref.setUI();
|
||||
|
||||
for (auto &m : _journal)
|
||||
for (auto i = 0; i < JE_TOTAL; ++i)
|
||||
m._menu[i].setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
124
engines/crab/ui/journal.h
Normal file
124
engines/crab/ui/journal.h
Normal 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_JOURNAL_H
|
||||
#define CRAB_JOURNAL_H
|
||||
|
||||
#include "crab/ui/ImageData.h"
|
||||
#include "crab/ui/questmenu.h"
|
||||
#include "crab/ui/StateButton.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
#define JE_CUR_NAME "cur"
|
||||
#define JE_DONE_NAME "done"
|
||||
#define JE_PEOPLE_NAME "people"
|
||||
#define JE_LOCATION_NAME "location"
|
||||
#define JE_HISTORY_NAME "history"
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
// The categories of journal entries
|
||||
enum JournalCategory {
|
||||
JE_CUR, // Quests in progress
|
||||
JE_DONE, // Completed quests
|
||||
JE_PEOPLE, // Info about characters
|
||||
JE_LOCATION, // Info about locations
|
||||
JE_HISTORY, // All the other info
|
||||
JE_TOTAL // The total number of categories
|
||||
};
|
||||
|
||||
class Journal {
|
||||
// The background image data
|
||||
ImageData _bg;
|
||||
|
||||
// The menu to select the category to display
|
||||
Menu<StateButton> _category;
|
||||
|
||||
// The selected category
|
||||
int _select;
|
||||
|
||||
// A group contains the entire journal for a single character
|
||||
struct Group {
|
||||
// Id of the character who this journal belongs to
|
||||
Common::String _id;
|
||||
|
||||
// The set of menus containing all categories of journals
|
||||
QuestMenu _menu[JE_TOTAL];
|
||||
};
|
||||
|
||||
// This contains journal entries for all characters
|
||||
Common::Array<Group> _journal;
|
||||
|
||||
// The reference quest menu, used to copy layouts
|
||||
QuestMenu _ref;
|
||||
|
||||
// This button is the "go to map" button, shown if the quest has a corresponding map marker
|
||||
Button _bu_map;
|
||||
|
||||
void select(const Common::String &id, const int &choice);
|
||||
|
||||
public:
|
||||
// The title of the quest selected by the "show in map" button
|
||||
Common::String _markerTitle;
|
||||
|
||||
Journal() {
|
||||
_select = 0;
|
||||
}
|
||||
|
||||
~Journal() {}
|
||||
|
||||
void load(const Common::Path &filename);
|
||||
void draw(const Common::String &id);
|
||||
|
||||
// Return true if "go to map" is selected
|
||||
bool handleEvents(const Common::String &id, const Common::Event &event);
|
||||
|
||||
void add(const Common::String &id, const Common::String &category, const Common::String &title, const Common::String &text);
|
||||
void move(const Common::String &id, const Common::String &title, const bool &completed);
|
||||
void marker(const Common::String &id, const Common::String &title, const bool &val);
|
||||
|
||||
// Open a specific entry in the journal
|
||||
void open(const Common::String &id, const JournalCategory &category, const Common::String &title);
|
||||
|
||||
// Prepare a new character's journal
|
||||
void init(const Common::String &id);
|
||||
|
||||
void saveState(rapidxml::xml_document<char> &doc, rapidxml::xml_node<char> *root);
|
||||
void loadState(rapidxml::xml_node<char> *node);
|
||||
|
||||
void setUI();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_JOURNAL_H
|
||||
425
engines/crab/ui/map.cpp
Normal file
425
engines/crab/ui/map.cpp
Normal file
@@ -0,0 +1,425 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/crab.h"
|
||||
#include "crab/XMLDoc.h"
|
||||
#include "crab/input/cursor.h"
|
||||
#include "crab/ui/map.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::image;
|
||||
using namespace pyrodactyl::input;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Load stuff that can't be modified by the user
|
||||
//------------------------------------------------------------------------
|
||||
void Map::load(const Common::Path &filename, pyrodactyl::event::Info &info) {
|
||||
XMLDoc conf(filename);
|
||||
if (conf.ready()) {
|
||||
rapidxml::xml_node<char> *node = conf.doc()->first_node("map");
|
||||
if (nodeValid(node)) {
|
||||
if (nodeValid("img", node)) {
|
||||
rapidxml::xml_node<char> *imgnode = node->first_node("img");
|
||||
loadNum(_speed, "speed", imgnode);
|
||||
|
||||
for (auto n = imgnode->first_node("map"); n != nullptr; n = n->next_sibling("map"))
|
||||
_map.push_back(n);
|
||||
}
|
||||
|
||||
if (nodeValid("fg", node))
|
||||
_fg.load(node->first_node("fg"));
|
||||
|
||||
if (nodeValid("dim", node)) {
|
||||
loadNum(_camera.w, "x", node->first_node("dim"));
|
||||
loadNum(_camera.h, "y", node->first_node("dim"));
|
||||
}
|
||||
|
||||
if (nodeValid("pos", node))
|
||||
_pos.load(node->first_node("pos"));
|
||||
|
||||
if (nodeValid("scroll", node))
|
||||
_scroll.load(node->first_node("scroll"));
|
||||
|
||||
if (nodeValid("marker", node))
|
||||
_marker.load(node->first_node("marker"));
|
||||
|
||||
if (nodeValid("title", node))
|
||||
_title.load(node->first_node("title"));
|
||||
|
||||
if (nodeValid("locations", node))
|
||||
_travel.load(node->first_node("locations"));
|
||||
|
||||
if (nodeValid("overlay", node))
|
||||
_buOverlay.load(node->first_node("overlay"));
|
||||
}
|
||||
}
|
||||
|
||||
setImage(_cur, true);
|
||||
update(info);
|
||||
calcBounds();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Draw
|
||||
//------------------------------------------------------------------------
|
||||
void Map::draw(pyrodactyl::event::Info &info) {
|
||||
|
||||
// The map graphic is clipped to fit inside the UI
|
||||
_imgBg.draw(_pos.x, _pos.y, &_camera);
|
||||
|
||||
if (_overlay) {
|
||||
// The overlay needs to be clipped as well, so we must find the intersection of the camera and the clip itself
|
||||
for (auto &i : _map[_cur]._reveal) {
|
||||
Rect r = i;
|
||||
int X = _pos.x + i.x - _camera.x, Y = _pos.y + i.y - _camera.y;
|
||||
|
||||
// Do not draw any area of the clip that is outside the camera bounds
|
||||
|
||||
// If we're outside the left edges, we need to cull the left point
|
||||
if (X < _pos.x) {
|
||||
X += _camera.x - i.x;
|
||||
r.x += _camera.x - i.x;
|
||||
r.w -= _camera.x - i.x;
|
||||
|
||||
if (r.w < 0)
|
||||
r.w = 0;
|
||||
}
|
||||
|
||||
if (Y < _pos.y) {
|
||||
Y += _camera.y - i.y;
|
||||
r.y += _camera.y - i.y;
|
||||
r.h -= _camera.y - i.y;
|
||||
|
||||
if (r.h < 0)
|
||||
r.h = 0;
|
||||
}
|
||||
|
||||
// If we're outside the right edge, we need to cull the width and height
|
||||
if (X + r.w > _pos.x + _camera.w)
|
||||
r.w = ABS(_pos.x + _camera.w - X); // abs to fix crash incase _pos.x + _camera.w < X
|
||||
if (Y + r.h > _pos.y + _camera.h)
|
||||
r.h = ABS(_pos.y + _camera.h - Y); // abs to fix crash incase _pos.y + _camera.h < Y
|
||||
|
||||
_imgOverlay.draw(X, Y, &r);
|
||||
}
|
||||
}
|
||||
|
||||
_travel.draw(_camera.x - _pos.x, _camera.y - _pos.y);
|
||||
|
||||
_fg.draw();
|
||||
_buOverlay.draw();
|
||||
|
||||
_title._text = info.curLocName();
|
||||
_title.draw();
|
||||
|
||||
_marker.draw(_pos, _playerPos, _camera);
|
||||
|
||||
_scroll.draw();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Center the world map on a spot
|
||||
//------------------------------------------------------------------------
|
||||
void Map::center(const Vector2i &vec) {
|
||||
_camera.x = vec.x - _camera.w / 2;
|
||||
_camera.y = vec.y - _camera.h / 2;
|
||||
validate();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Keep the camera in bounds and decide marker visibility
|
||||
//------------------------------------------------------------------------
|
||||
void Map::validate() {
|
||||
// Make all scroll buttons visible first
|
||||
for (auto &i : _scroll._element)
|
||||
i._visible = true;
|
||||
|
||||
// Keep camera in bounds
|
||||
if (_camera.x + _camera.w > _size.x)
|
||||
_camera.x = _size.x - _camera.w;
|
||||
if (_camera.y + _camera.h > _size.y)
|
||||
_camera.y = _size.y - _camera.h;
|
||||
if (_camera.x < 0)
|
||||
_camera.x = 0;
|
||||
if (_camera.y < 0)
|
||||
_camera.y = 0;
|
||||
|
||||
// decide visibility of scroll buttons
|
||||
_scroll._element[DIRECTION_RIGHT]._visible = !(_camera.x == _size.x - _camera.w);
|
||||
_scroll._element[DIRECTION_DOWN]._visible = !(_camera.y == _size.y - _camera.h);
|
||||
_scroll._element[DIRECTION_LEFT]._visible = !(_camera.x == 0);
|
||||
_scroll._element[DIRECTION_UP]._visible = !(_camera.y == 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Move
|
||||
//------------------------------------------------------------------------
|
||||
void Map::move(const Common::Event &event) {
|
||||
// Reset the velocity to avoid weirdness
|
||||
_vel.x = 0;
|
||||
_vel.y = 0;
|
||||
|
||||
// We don't use the result, but this keeps the button states up to date
|
||||
_scroll.handleEvents(event);
|
||||
|
||||
switch (event.type) {
|
||||
case Common::EVENT_LBUTTONDOWN:
|
||||
case Common::EVENT_RBUTTONDOWN: {
|
||||
bool click = false;
|
||||
int count = 0;
|
||||
for (auto &i : _scroll._element) {
|
||||
if (i.contains(g_engine->_mouse->_button)) {
|
||||
if (count == DIRECTION_UP)
|
||||
_vel.y = -1 * _speed;
|
||||
else if (count == DIRECTION_DOWN)
|
||||
_vel.y = _speed;
|
||||
else if (count == DIRECTION_RIGHT)
|
||||
_vel.x = _speed;
|
||||
else if (count == DIRECTION_LEFT)
|
||||
_vel.x = -1 * _speed;
|
||||
|
||||
click = true;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
if (!click) {
|
||||
_pan = true;
|
||||
_vel.x = 0;
|
||||
_vel.y = 0;
|
||||
} else
|
||||
_pan = false;
|
||||
} break;
|
||||
|
||||
case Common::EVENT_LBUTTONUP:
|
||||
case Common::EVENT_RBUTTONUP:
|
||||
_pan = false;
|
||||
break;
|
||||
|
||||
case Common::EVENT_MOUSEMOVE:
|
||||
if (_pan) {
|
||||
_camera.x -= g_engine->_mouse->_rel.x;
|
||||
_camera.y -= g_engine->_mouse->_rel.y;
|
||||
validate();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Move the map camera if player presses the direction keys
|
||||
if (g_engine->_inputManager->state(IU_UP))
|
||||
_vel.y = -1 * _speed;
|
||||
else if (g_engine->_inputManager->state(IU_DOWN))
|
||||
_vel.y = _speed;
|
||||
else if (g_engine->_inputManager->state(IU_RIGHT))
|
||||
_vel.x = _speed;
|
||||
else if (g_engine->_inputManager->state(IU_LEFT))
|
||||
_vel.x = -1 * _speed;
|
||||
// Stop moving when we release a key (but only in that direction)
|
||||
else if (!g_engine->_inputManager->state(IU_UP) && !g_engine->_inputManager->state(IU_DOWN))
|
||||
_vel.y = 0;
|
||||
else if (!g_engine->_inputManager->state(IU_LEFT) && !g_engine->_inputManager->state(IU_RIGHT))
|
||||
_vel.x = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Internal Events
|
||||
//------------------------------------------------------------------------
|
||||
void Map::internalEvents(pyrodactyl::event::Info &info) {
|
||||
// The map overlay and button state should be in sync
|
||||
_buOverlay._state = _overlay;
|
||||
|
||||
_camera.x += _vel.x;
|
||||
_camera.y += _vel.y;
|
||||
validate();
|
||||
|
||||
for (auto &i : _travel._element)
|
||||
i._visible = i.x >= _camera.x && i.y >= _camera.y;
|
||||
|
||||
_marker.internalEvents(_pos, _playerPos, _camera, _bounds);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Handle Events
|
||||
//------------------------------------------------------------------------
|
||||
bool Map::handleEvents(pyrodactyl::event::Info &info, const Common::Event &event) {
|
||||
int choice = _travel.handleEvents(event, -1 * _camera.x, -1 * _camera.y);
|
||||
if (choice >= 0) {
|
||||
_curLoc = _travel._element[choice]._loc;
|
||||
_pan = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
_marker.handleEvents(_pos, _playerPos, _camera, event);
|
||||
|
||||
move(event);
|
||||
if (_buOverlay.handleEvents(event) == BUAC_LCLICK)
|
||||
_overlay = _buOverlay._state;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Map::setImage(const uint &val, const bool &force) {
|
||||
if (force || (_cur != val && val < _map.size())) {
|
||||
_cur = val;
|
||||
|
||||
_imgBg.deleteImage();
|
||||
_imgOverlay.deleteImage();
|
||||
|
||||
_imgBg.load(_map[_cur]._pathBg);
|
||||
_imgOverlay.load(_map[_cur]._pathOverlay);
|
||||
|
||||
_size.x = _imgBg.w();
|
||||
_size.y = _imgBg.h();
|
||||
|
||||
_marker.clear();
|
||||
for (auto &i : _map[_cur]._dest)
|
||||
_marker.addButton(i._name, i._pos.x, i._pos.y);
|
||||
|
||||
_marker.assignPaths();
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Select the marker corresponding to a quest title
|
||||
//------------------------------------------------------------------------
|
||||
void Map::selectDest(const Common::String &name) {
|
||||
_marker.selectDest(name);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Update the status of the fast travel buttons
|
||||
//------------------------------------------------------------------------
|
||||
void Map::update(pyrodactyl::event::Info &info) {
|
||||
for (auto &i : _travel._element) {
|
||||
i._unlock.evaluate(info);
|
||||
i._visible = i._unlock.result();
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Add a rectangle to the revealed world map data
|
||||
//------------------------------------------------------------------------
|
||||
void Map::revealAdd(const int &id, const Rect &area) {
|
||||
if ((uint)id < _map.size()) {
|
||||
for (auto &i : _map[id]._reveal)
|
||||
if (i == area)
|
||||
return;
|
||||
|
||||
_map[id]._reveal.push_back(area);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Add or remove a destination marker from the world map
|
||||
//------------------------------------------------------------------------
|
||||
void Map::destAdd(const Common::String &name, const int &x, const int &y) {
|
||||
if (_cur < _map.size()) {
|
||||
for (auto &i : _map[_cur]._dest) {
|
||||
if (i._name == name) {
|
||||
i._pos.x = x;
|
||||
i._pos.y = y;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_map[_cur].destAdd(name, x, y);
|
||||
_marker.addButton(name, x, y);
|
||||
_marker.assignPaths();
|
||||
}
|
||||
}
|
||||
|
||||
void Map::destDel(const Common::String &name) {
|
||||
if (_cur < _map.size()) {
|
||||
for (auto i = _map[_cur]._dest.begin(); i != _map[_cur]._dest.end(); ++i) {
|
||||
if (i->_name == name) {
|
||||
_map[_cur]._dest.erase(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_marker.erase(name);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Save and load object state
|
||||
//------------------------------------------------------------------------
|
||||
void Map::saveState(rapidxml::xml_document<> &doc, rapidxml::xml_node<char> *root) {
|
||||
rapidxml::xml_node<char> *child = doc.allocate_node(rapidxml::node_element, "map");
|
||||
|
||||
child->append_attribute(doc.allocate_attribute("cur", g_engine->_stringPool->get(_cur)));
|
||||
saveBool(_overlay, "overlay", doc, child);
|
||||
|
||||
for (auto &r : _map) {
|
||||
rapidxml::xml_node<char> *child_data = doc.allocate_node(rapidxml::node_element, "data");
|
||||
r.saveState(doc, child_data);
|
||||
child->append_node(child_data);
|
||||
}
|
||||
|
||||
root->append_node(child);
|
||||
}
|
||||
|
||||
void Map::loadState(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid("map", node)) {
|
||||
rapidxml::xml_node<char> *mapnode = node->first_node("map");
|
||||
loadBool(_overlay, "overlay", mapnode);
|
||||
|
||||
int val = _cur;
|
||||
loadNum(val, "cur", mapnode);
|
||||
|
||||
auto r = _map.begin();
|
||||
for (rapidxml::xml_node<char> *n = mapnode->first_node("data"); n != nullptr && r != _map.end(); n = n->next_sibling("data"), ++r)
|
||||
r->loadState(n);
|
||||
|
||||
setImage(val, true);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Reset the UI positions in response to change in resolution
|
||||
//------------------------------------------------------------------------
|
||||
void Map::setUI() {
|
||||
_pos.setUI();
|
||||
_fg.setUI();
|
||||
|
||||
_travel.setUI();
|
||||
_marker.setUI();
|
||||
|
||||
_buOverlay.setUI();
|
||||
_scroll.setUI();
|
||||
_title.setUI();
|
||||
|
||||
calcBounds();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
147
engines/crab/ui/map.h
Normal file
147
engines/crab/ui/map.h
Normal file
@@ -0,0 +1,147 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_MAP_H
|
||||
#define CRAB_MAP_H
|
||||
|
||||
#include "crab/event/GameEventInfo.h"
|
||||
#include "crab/ui/ImageData.h"
|
||||
#include "crab/ui/mapbutton.h"
|
||||
#include "crab/ui/MapData.h"
|
||||
#include "crab/ui/MapMarkerMenu.h"
|
||||
#include "crab/ui/StateButton.h"
|
||||
#include "crab/ui/ToggleButton.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class Map {
|
||||
// We have multiple world maps, each with their own data
|
||||
Common::Array<MapData> _map;
|
||||
|
||||
// Index of the currently visible map
|
||||
uint _cur;
|
||||
|
||||
// The currently loaded map background image
|
||||
pyrodactyl::image::Image _imgBg, _imgOverlay;
|
||||
|
||||
// The position at which map image has to be drawn
|
||||
Element _pos;
|
||||
|
||||
// Foreground image of the map
|
||||
ImageData _fg;
|
||||
|
||||
// size = Dimensions of the map image
|
||||
// mouse = The current coordinates of the mouse
|
||||
// vel = The speed at which the map is moving
|
||||
Vector2i _size, _mouse, _vel;
|
||||
|
||||
// The reference speed of the camera movement
|
||||
int _speed;
|
||||
|
||||
// The pan toggle is used when the mouse is down and moving simultaneously
|
||||
// overlay = true if we are showing a more detailed world map
|
||||
bool _pan, _overlay;
|
||||
|
||||
// The camera size and position for the map
|
||||
// Bounds is the area we draw the map elements for
|
||||
Rect _camera, _bounds;
|
||||
|
||||
// The button to toggle between showing the overlay or not
|
||||
ToggleButton _buOverlay;
|
||||
|
||||
// All data for drawing map markers
|
||||
MapMarkerMenu _marker;
|
||||
|
||||
// The map name is drawn here
|
||||
HoverInfo _title;
|
||||
|
||||
// The buttons for scrolling the map (only visible if there is area to scroll)
|
||||
ButtonMenu _scroll;
|
||||
|
||||
// The menu for fast travel locations
|
||||
MapButtonMenu _travel;
|
||||
|
||||
void calcBounds() {
|
||||
_bounds.x = _pos.x;
|
||||
_bounds.y = _pos.y;
|
||||
_bounds.w = _camera.w;
|
||||
_bounds.h = _camera.h;
|
||||
}
|
||||
|
||||
public:
|
||||
// The currently selected location
|
||||
Common::String _curLoc;
|
||||
|
||||
// The coordinates of the player's current location
|
||||
Vector2i _playerPos;
|
||||
|
||||
Map() {
|
||||
_speed = 1;
|
||||
_pan = false;
|
||||
_cur = 0;
|
||||
_overlay = true;
|
||||
}
|
||||
|
||||
~Map() {
|
||||
_imgBg.deleteImage();
|
||||
_imgOverlay.deleteImage();
|
||||
}
|
||||
|
||||
void load(const Common::Path &filename, pyrodactyl::event::Info &info);
|
||||
|
||||
void draw(pyrodactyl::event::Info &info);
|
||||
bool handleEvents(pyrodactyl::event::Info &info, const Common::Event &event);
|
||||
void internalEvents(pyrodactyl::event::Info &info);
|
||||
|
||||
void center(const Vector2i &pos);
|
||||
void move(const Common::Event &event);
|
||||
void validate();
|
||||
|
||||
void revealAdd(const int &id, const Rect &area);
|
||||
void destAdd(const Common::String &name, const int &x, const int &y);
|
||||
void destDel(const Common::String &name);
|
||||
void selectDest(const Common::String &name);
|
||||
|
||||
void update(pyrodactyl::event::Info &info);
|
||||
void setImage(const uint &val, const bool &force = false);
|
||||
|
||||
void saveState(rapidxml::xml_document<> &doc, rapidxml::xml_node<char> *root);
|
||||
void loadState(rapidxml::xml_node<char> *node);
|
||||
|
||||
void setUI();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_MAP_H
|
||||
67
engines/crab/ui/mapbutton.h
Normal file
67
engines/crab/ui/mapbutton.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_MAPBUTTON_H
|
||||
#define CRAB_MAPBUTTON_H
|
||||
|
||||
#include "crab/event/triggerset.h"
|
||||
#include "crab/ui/menu.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class MapButton : public Button {
|
||||
public:
|
||||
// The id of the location
|
||||
Common::String _loc;
|
||||
|
||||
// Conditions needed for the location to be unlocked in world map
|
||||
pyrodactyl::event::TriggerSet _unlock;
|
||||
|
||||
MapButton() {}
|
||||
~MapButton() {}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node) {
|
||||
Button::load(node);
|
||||
|
||||
loadStr(_loc, "id", node);
|
||||
if (nodeValid("unlock", node, false))
|
||||
_unlock.load(node->first_node("unlock"));
|
||||
}
|
||||
};
|
||||
|
||||
typedef Menu<MapButton> MapButtonMenu;
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_MAPBUTTON_H
|
||||
340
engines/crab/ui/menu.h
Normal file
340
engines/crab/ui/menu.h
Normal file
@@ -0,0 +1,340 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
//=============================================================================
|
||||
// Author: Arvind
|
||||
// Purpose: Menu class
|
||||
//=============================================================================
|
||||
#ifndef CRAB_MENU_H
|
||||
#define CRAB_MENU_H
|
||||
|
||||
#include "crab/crab.h"
|
||||
#include "crab/metaengine.h"
|
||||
#include "crab/ui/button.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
template<typename T>
|
||||
class Menu {
|
||||
protected:
|
||||
// The index of current selected option and highlighted option
|
||||
int _hoverIndex;
|
||||
|
||||
// The order in which a keyboard or gamepad traverses the menu
|
||||
Common::Array<uint> _path;
|
||||
|
||||
// Are keyboard buttons enabled?
|
||||
bool _useKeyboard;
|
||||
|
||||
// Has a key been pressed?
|
||||
enum InputDevice {
|
||||
KEYBOARD,
|
||||
MOUSE
|
||||
} _latestInput;
|
||||
|
||||
// Do the paths use horizontal, vertical or both types of input for keyboard traversal
|
||||
enum PathType {
|
||||
PATH_DEFAULT,
|
||||
PATH_HORIZONTAL,
|
||||
PATH_VERTICAL
|
||||
} _pathType;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Find the next element in our path
|
||||
//------------------------------------------------------------------------
|
||||
void next() {
|
||||
if (_hoverIndex == -1) {
|
||||
for (uint pos = 0; pos < _path.size(); pos++)
|
||||
if (_element[_path[pos]]._visible == true) {
|
||||
_hoverIndex = _path[pos];
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
uint curpos = 0;
|
||||
for (; curpos < _path.size(); curpos++)
|
||||
if ((int)_path[curpos] == _hoverIndex)
|
||||
break;
|
||||
|
||||
for (uint nextloc = (curpos + 1) % _element.size(); nextloc != curpos; nextloc = (nextloc + 1) % _element.size())
|
||||
if (_element[nextloc]._visible == true) {
|
||||
_hoverIndex = _path[nextloc];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Find the previous element in our path
|
||||
//------------------------------------------------------------------------
|
||||
void prev() {
|
||||
if (_hoverIndex == -1) {
|
||||
for (uint pos = 0; pos < _path.size(); pos++)
|
||||
if (_element[_path[pos]]._visible == true) {
|
||||
_hoverIndex = _path[pos];
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
uint curpos = 0;
|
||||
for (; curpos < _path.size(); curpos++)
|
||||
if ((int)_path[curpos] == _hoverIndex)
|
||||
break;
|
||||
|
||||
if (curpos == 0)
|
||||
return; // There is no previous element
|
||||
|
||||
int nextloc = curpos - 1;
|
||||
while (nextloc != (int)curpos) {
|
||||
if (nextloc < 0)
|
||||
nextloc = _element.size() - 1;
|
||||
|
||||
if (_element[nextloc]._visible == true) {
|
||||
_hoverIndex = _path[nextloc];
|
||||
break;
|
||||
}
|
||||
|
||||
nextloc--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Handle keyboard input
|
||||
//------------------------------------------------------------------------
|
||||
int handleKeyboard(const Common::Event &event) {
|
||||
using namespace pyrodactyl::input;
|
||||
|
||||
if (g_engine->_inputManager->getKeyBindingMode() != KBM_UI) {
|
||||
g_engine->_inputManager->setKeyBindingMode(KBM_UI);
|
||||
}
|
||||
|
||||
if (!_element.empty()) {
|
||||
if (_pathType != PATH_HORIZONTAL) {
|
||||
if (g_engine->_inputManager->state(IU_DOWN)) {
|
||||
next();
|
||||
_latestInput = KEYBOARD;
|
||||
} else if (g_engine->_inputManager->state(IU_UP)) {
|
||||
prev();
|
||||
_latestInput = KEYBOARD;
|
||||
}
|
||||
}
|
||||
|
||||
if (_pathType != PATH_VERTICAL) {
|
||||
if (g_engine->_inputManager->state(IU_RIGHT)) {
|
||||
next();
|
||||
_latestInput = KEYBOARD;
|
||||
} else if (g_engine->_inputManager->state(IU_LEFT)) {
|
||||
prev();
|
||||
_latestInput = KEYBOARD;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_engine->_inputManager->state(IU_ACCEPT) && _hoverIndex != -1)
|
||||
return _hoverIndex;
|
||||
|
||||
// We pressed a key, which means we have to update the hovering status
|
||||
if (_latestInput == KEYBOARD) {
|
||||
// Update hover status of keys according to the current index
|
||||
int i = 0;
|
||||
for (auto it = _element.begin(); it != _element.end(); ++it, ++i)
|
||||
it->_hoverKey = (i == _hoverIndex);
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public:
|
||||
// The collection of buttons in the menu
|
||||
Common::Array<T> _element;
|
||||
|
||||
Menu() {
|
||||
_hoverIndex = -1;
|
||||
_useKeyboard = false;
|
||||
_latestInput = MOUSE;
|
||||
_pathType = PATH_DEFAULT;
|
||||
}
|
||||
~Menu() {}
|
||||
|
||||
void reset() {
|
||||
_latestInput = MOUSE;
|
||||
_hoverIndex = -1;
|
||||
for (auto &b : _element)
|
||||
b.reset();
|
||||
}
|
||||
|
||||
void setUI() {
|
||||
for (auto &i : _element)
|
||||
i.setUI();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Load the menu from a file
|
||||
//------------------------------------------------------------------------
|
||||
void load(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid(node)) {
|
||||
for (auto n = node->first_node(); n != nullptr; n = n->next_sibling()) {
|
||||
T b;
|
||||
b.load(n);
|
||||
_element.push_back(b);
|
||||
}
|
||||
|
||||
loadBool(_useKeyboard, "keyboard", node, false);
|
||||
assignPaths();
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Event Handling
|
||||
// The reason this function doesn't declare its own Event object is because
|
||||
// a menu might not be the only object in a game state
|
||||
//------------------------------------------------------------------------
|
||||
int handleEvents(const Common::Event &event, const int &xOffset = 0, const int &yOffset = 0) {
|
||||
// The keyboard/joystick event handling bit
|
||||
if (_useKeyboard) {
|
||||
int result = handleKeyboard(event);
|
||||
|
||||
// We have accepted a menu option using the keyboard
|
||||
if (result != -1) {
|
||||
// Reset the menu state
|
||||
reset();
|
||||
g_engine->_inputManager->setKeyBindingMode(pyrodactyl::input::KBM_GAME);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we have moved or clicked the mouse
|
||||
if (Common::isMouseEvent(event)) {
|
||||
// Since the player is moving the mouse, we have to recalculate hover index at every opportunity
|
||||
_hoverIndex = -1;
|
||||
_latestInput = MOUSE;
|
||||
}
|
||||
|
||||
// The mouse and hotkey event handling bit
|
||||
int i = 0;
|
||||
for (auto it = _element.begin(); it != _element.end(); ++it, ++i) {
|
||||
// We clicked on a button using the mouse
|
||||
if (it->handleEvents(event, xOffset, yOffset) == BUAC_LCLICK) {
|
||||
// Reset the menu state
|
||||
reset();
|
||||
g_engine->_inputManager->setKeyBindingMode(pyrodactyl::input::KBM_GAME);
|
||||
return i;
|
||||
}
|
||||
|
||||
// We did not click a button, however we did hover over the button
|
||||
// However if we are use keyboard to browse through the menu, hovering is forgotten until we move the mouse again
|
||||
if (it->_hoverMouse && _latestInput == MOUSE) {
|
||||
_hoverIndex = i;
|
||||
|
||||
// The latest input is the mouse, which means we have to forget the keyboard hover states
|
||||
for (auto &e : _element)
|
||||
e._hoverKey = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (_latestInput == KEYBOARD) {
|
||||
// The latest input is the keyboard, which means we have to forget the mouse hover states
|
||||
for (auto &it : _element)
|
||||
it._hoverMouse = false;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Draw the menu
|
||||
//------------------------------------------------------------------------
|
||||
void draw(const int &XOffset = 0, const int &YOffset = 0) {
|
||||
for (auto &it : _element)
|
||||
it.draw(XOffset, YOffset);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Get info about the menu
|
||||
//------------------------------------------------------------------------
|
||||
void useKeyboard(const bool &val) {
|
||||
_useKeyboard = val;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
_element.clear();
|
||||
}
|
||||
|
||||
int hoverIndex() {
|
||||
return _hoverIndex;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Assign traversal paths
|
||||
//------------------------------------------------------------------------
|
||||
void assignPaths() {
|
||||
_path.clear();
|
||||
|
||||
// These variables are used to see if the X and Y values of buttons are the same or not
|
||||
// Used to determine the path type of the menu
|
||||
bool sameX = true, sameY = true;
|
||||
|
||||
if (!_element.empty()) {
|
||||
_path.push_back(0);
|
||||
|
||||
for (uint i = 1; i < _element.size(); i++) {
|
||||
_path.push_back(i);
|
||||
|
||||
int prevX = _element[i - 1].x;
|
||||
int prevY = _element[i - 1].y;
|
||||
|
||||
if (sameX && _element[i].x != prevX)
|
||||
sameX = false;
|
||||
|
||||
if (sameY && _element[i].y != prevY)
|
||||
sameY = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (sameX) {
|
||||
if (sameY)
|
||||
_pathType = PATH_DEFAULT;
|
||||
else
|
||||
_pathType = PATH_VERTICAL;
|
||||
} else if (sameY)
|
||||
_pathType = PATH_HORIZONTAL;
|
||||
else
|
||||
_pathType = PATH_DEFAULT;
|
||||
}
|
||||
};
|
||||
|
||||
// A menu with simple buttons
|
||||
typedef Menu<Button> ButtonMenu;
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_MENU_H
|
||||
244
engines/crab/ui/questmenu.cpp
Normal file
244
engines/crab/ui/questmenu.cpp
Normal file
@@ -0,0 +1,244 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "crab/crab.h"
|
||||
#include "crab/ui/questmenu.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::event;
|
||||
|
||||
QuestMenu::QuestMenu() {
|
||||
_selQuest = -1;
|
||||
_selPage = -1;
|
||||
_selBu = -1;
|
||||
_align = ALIGN_LEFT;
|
||||
_colN = 0;
|
||||
_colS = 0;
|
||||
_unread = false;
|
||||
_font = 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Load layout from file
|
||||
//------------------------------------------------------------------------
|
||||
void QuestMenu::load(rapidxml::xml_node<char> *node) {
|
||||
if (nodeValid(node)) {
|
||||
if (nodeValid("menu", node))
|
||||
_menu.load(node->first_node("menu"));
|
||||
|
||||
if (nodeValid("tab", node)) {
|
||||
rapidxml::xml_node<char> *tabnode = node->first_node("tab");
|
||||
loadNum(_font, "font", tabnode);
|
||||
loadAlign(_align, tabnode);
|
||||
_offTitle.load(tabnode);
|
||||
_offUnread.load(tabnode->first_node("unread"));
|
||||
|
||||
if (nodeValid("normal", tabnode)) {
|
||||
rapidxml::xml_node<char> *nornode = tabnode->first_node("normal");
|
||||
_imgN.load(nornode);
|
||||
//loadColor(col_n, nornode);
|
||||
}
|
||||
|
||||
if (nodeValid("select", tabnode)) {
|
||||
rapidxml::xml_node<char> *selnode = tabnode->first_node("select");
|
||||
_imgS.load(selnode);
|
||||
//loadColor(col_s, selnode);
|
||||
}
|
||||
}
|
||||
|
||||
if (nodeValid("text", node))
|
||||
_text.load(node->first_node("text"));
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Add an entry to the menu
|
||||
//------------------------------------------------------------------------
|
||||
void QuestMenu::add(const Common::String &title, const Common::String &txt) {
|
||||
for (auto &i : _quest)
|
||||
if (i._title == title) { // We already have the quest entry
|
||||
i._text.insert_at(0, txt); // Just add the new string to the start of the quest messages and return
|
||||
i._unread = true;
|
||||
return;
|
||||
}
|
||||
|
||||
Quest q(title, txt, true, false);
|
||||
_quest.insert_at(0, q);
|
||||
_menu.add();
|
||||
_unread = true;
|
||||
}
|
||||
|
||||
void QuestMenu::add(const pyrodactyl::event::Quest &q) {
|
||||
_quest.insert_at(0, q);
|
||||
_menu.add();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Remove an entry from the menu
|
||||
//------------------------------------------------------------------------
|
||||
void QuestMenu::erase(const int &index) {
|
||||
_quest.erase(_quest.begin() + index);
|
||||
_menu.erase();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Indicate that this quest has an associated map marker in world map
|
||||
//------------------------------------------------------------------------
|
||||
void QuestMenu::marker(const Common::String &title, const bool &val) {
|
||||
for (auto &i : _quest)
|
||||
if (i._title == title)
|
||||
i._marker = val;
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Draw
|
||||
//------------------------------------------------------------------------
|
||||
void QuestMenu::draw(Button &buMap) {
|
||||
_menu.draw();
|
||||
|
||||
using namespace pyrodactyl::text;
|
||||
for (auto i = _menu.index(), count = 0u; i < _menu.indexPlusOne() && i < _quest.size(); i++, count++) {
|
||||
auto base_x = _menu.baseX(count), base_y = _menu.baseY(count);
|
||||
|
||||
// Only draw in _s color if we are on the same button and page
|
||||
if ((uint)_selBu == count && (uint)_selPage == _menu.currentPage())
|
||||
g_engine->_textManager->draw(base_x + _offTitle.x, base_y + _offTitle.y, _quest[i]._title, _colS, _font, _align);
|
||||
else
|
||||
g_engine->_textManager->draw(base_x + _offTitle.x, base_y + _offTitle.y, _quest[i]._title, _colN, _font, _align);
|
||||
|
||||
if (_quest[i]._unread) {
|
||||
using namespace pyrodactyl::image;
|
||||
g_engine->_imageManager->draw(base_x + _offUnread.x, base_y + _offUnread.y, g_engine->_imageManager->_notify);
|
||||
}
|
||||
}
|
||||
|
||||
if (_selQuest >= 0 && (uint)_selQuest < _quest.size()) {
|
||||
_text.draw(_quest[_selQuest]);
|
||||
|
||||
if (_quest[_selQuest]._marker)
|
||||
buMap.draw();
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Handle user input
|
||||
//------------------------------------------------------------------------
|
||||
bool QuestMenu::handleEvents(Button &buMap, Common::String &mapTitle, const Common::Event &event) {
|
||||
int res = _menu.handleEvents(event);
|
||||
if (res != -1) {
|
||||
if (_selBu >= 0 && _selPage >= 0)
|
||||
_menu.image(_selBu, _selPage, _imgN);
|
||||
|
||||
_selBu = res;
|
||||
_selPage = _menu.currentPage();
|
||||
_selQuest = _menu.index() + _selBu;
|
||||
|
||||
_quest[_selQuest]._unread = false;
|
||||
_text.reset();
|
||||
|
||||
_menu.image(_selBu, _selPage, _imgS);
|
||||
}
|
||||
|
||||
if (_selQuest >= 0 && (uint)_selQuest < _quest.size()) {
|
||||
if (_quest[_selQuest]._marker)
|
||||
if (buMap.handleEvents(event) == BUAC_LCLICK) {
|
||||
// The title of the quest selected by the "show in map" button
|
||||
mapTitle = _quest[_selQuest]._title;
|
||||
return true;
|
||||
}
|
||||
|
||||
_text.handleEvents(_quest[_selQuest], event);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Select an entry
|
||||
//------------------------------------------------------------------------
|
||||
void QuestMenu::select(const int &questIndex) {
|
||||
if (questIndex >= 0 && (uint)questIndex < _quest.size()) {
|
||||
if (_selBu >= 0 && _selPage >= 0)
|
||||
_menu.image(_selBu, _selPage, _imgN);
|
||||
|
||||
_selQuest = questIndex;
|
||||
|
||||
_selPage = questIndex / _menu.elementsPerPage();
|
||||
_menu.currentPage(_selPage);
|
||||
_menu.updateInfo();
|
||||
|
||||
_selBu = questIndex % _menu.elementsPerPage();
|
||||
|
||||
_quest[questIndex]._unread = false;
|
||||
_text.reset();
|
||||
|
||||
_menu.image(_selBu, _selPage, _imgS);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Save state to file
|
||||
//------------------------------------------------------------------------
|
||||
void QuestMenu::saveState(rapidxml::xml_document<> &doc, rapidxml::xml_node<char> *root, const char *name) {
|
||||
rapidxml::xml_node<char> *child = doc.allocate_node(rapidxml::node_element, name);
|
||||
|
||||
saveBool(_unread, "unread", doc, child);
|
||||
|
||||
for (auto &q: _quest)
|
||||
q.saveState(doc, child);
|
||||
|
||||
root->append_node(child);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Load state from file
|
||||
//------------------------------------------------------------------------
|
||||
void QuestMenu::loadState(rapidxml::xml_node<char> *node) {
|
||||
loadBool(_unread, "unread", node);
|
||||
|
||||
_quest.clear();
|
||||
for (auto n = node->first_node("quest"); n != nullptr; n = n->next_sibling("quest")) {
|
||||
Quest q;
|
||||
q.loadState(n);
|
||||
_quest.push_back(q);
|
||||
_menu.add();
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Reposition UI elements
|
||||
//------------------------------------------------------------------------
|
||||
void QuestMenu::setUI() {
|
||||
_menu.setUI();
|
||||
_text.setUI();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
106
engines/crab/ui/questmenu.h
Normal file
106
engines/crab/ui/questmenu.h
Normal file
@@ -0,0 +1,106 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_QUESTMENU_H
|
||||
#define CRAB_QUESTMENU_H
|
||||
|
||||
#include "crab/event/quest.h"
|
||||
#include "crab/ui/PageMenu.h"
|
||||
#include "crab/ui/QuestText.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class QuestMenu {
|
||||
// The collection of quest pages
|
||||
PageButtonMenu _menu;
|
||||
|
||||
// The currently selected quest for reading
|
||||
int _selQuest;
|
||||
|
||||
// The currently selected page
|
||||
int _selPage;
|
||||
|
||||
// The currently selected button in the page menu
|
||||
int _selBu;
|
||||
|
||||
// For drawing quest text
|
||||
QuestText _text;
|
||||
|
||||
// For drawing quest tabs
|
||||
FontKey _font;
|
||||
Align _align;
|
||||
int _colN, _colS;
|
||||
ButtonImage _imgN, _imgS;
|
||||
Vector2i _offTitle, _offUnread;
|
||||
|
||||
public:
|
||||
// All the quests currently in this menu
|
||||
Common::Array<pyrodactyl::event::Quest> _quest;
|
||||
|
||||
// Keep track of unread notifications for each category button
|
||||
bool _unread;
|
||||
|
||||
QuestMenu();
|
||||
~QuestMenu() {}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
void draw(Button &buMap);
|
||||
|
||||
bool handleEvents(Button &buMap, Common::String &mapTitle, const Common::Event &event);
|
||||
|
||||
void useKeyboard(const bool &val) {
|
||||
_menu.useKeyboard(val);
|
||||
}
|
||||
|
||||
void assignPaths() {
|
||||
_menu.assignPaths();
|
||||
}
|
||||
|
||||
void marker(const Common::String &title, const bool &val);
|
||||
|
||||
void add(const Common::String &title, const Common::String &txt);
|
||||
void add(const pyrodactyl::event::Quest &q);
|
||||
void erase(const int &index);
|
||||
|
||||
void select(const int &questIndex);
|
||||
|
||||
void saveState(rapidxml::xml_document<char> &doc, rapidxml::xml_node<char> *root, const char *name);
|
||||
void loadState(rapidxml::xml_node<char> *node);
|
||||
|
||||
void setUI();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_QUESTMENU_H
|
||||
152
engines/crab/ui/slider.cpp
Normal file
152
engines/crab/ui/slider.cpp
Normal file
@@ -0,0 +1,152 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "graphics/screen.h"
|
||||
#include "crab/crab.h"
|
||||
#include "crab/input/cursor.h"
|
||||
#include "crab/ui/slider.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::image;
|
||||
using namespace pyrodactyl::input;
|
||||
|
||||
void Slider::load(rapidxml::xml_node<char> *node, const int &min, const int &max, const int &val) {
|
||||
if (nodeValid(node)) {
|
||||
_knob.load(node->first_node("knob"), false);
|
||||
_bar.load(node->first_node("bar"));
|
||||
|
||||
_knob.x = _bar.x + ((_bar.w - _knob.w) * _value / (_max - _min));
|
||||
_knob.y = _bar.y;
|
||||
_knob.w = g_engine->_imageManager->getTexture(_knob._img._normal).w();
|
||||
_knob.h = g_engine->_imageManager->getTexture(_knob._img._normal).h();
|
||||
_knob._canmove = true;
|
||||
|
||||
_min = min;
|
||||
_max = max;
|
||||
_value = val;
|
||||
|
||||
_caption.load(node->first_node("caption"), &_bar);
|
||||
}
|
||||
}
|
||||
|
||||
bool Slider::handleEvents(const Common::Event &Event) {
|
||||
if (_isGreyed) // do not entertain events when greyed is set
|
||||
return false;
|
||||
|
||||
// A person is moving the knob
|
||||
if (_knob.handleEvents(Event) == BUAC_GRABBED) {
|
||||
int dx = g_engine->_mouse->_motion.x - _bar.x;
|
||||
|
||||
if (dx < 0)
|
||||
dx = 0;
|
||||
else if (dx > (_bar.w - _knob.w))
|
||||
dx = (_bar.w - _knob.w);
|
||||
|
||||
_knob.x = _bar.x + dx;
|
||||
_knob.y = _bar.y;
|
||||
|
||||
_value = _min + (((_max - _min) * (_knob.x - _bar.x)) / (_bar.w - _knob.w));
|
||||
return true;
|
||||
}
|
||||
|
||||
// If a person clicks on the slider bar, the knob needs to travel there
|
||||
if ((Event.type == Common::EVENT_LBUTTONDOWN || Event.type == Common::EVENT_RBUTTONDOWN) && _bar.contains(g_engine->_mouse->_button.x, g_engine->_mouse->_button.y)) {
|
||||
_knob.x = g_engine->_mouse->_button.x;
|
||||
_knob.y = _bar.y;
|
||||
|
||||
_value = _min + (((_max - _min) * (_knob.x - _bar.x)) / (_bar.w - _knob.w));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Slider::draw() {
|
||||
_bar.draw();
|
||||
_caption.draw(false);
|
||||
_knob.draw();
|
||||
greyOut();
|
||||
}
|
||||
|
||||
// This function only works when slider is drawn over the textured background in Unrest
|
||||
// Constants have been found by hit and trial
|
||||
void Slider::greyOut() {
|
||||
if (!_isGreyed)
|
||||
return;
|
||||
|
||||
int w = _bar.w + _bar.x - _caption.x;
|
||||
int h = _knob.h > _caption.h ? _knob.h : _caption.h;
|
||||
|
||||
byte a, r, g, b;
|
||||
for (int y = _caption.y; y < _caption.y + h; y++) {
|
||||
uint32 *ptr = (uint32 *)g_engine->_screen->getBasePtr(_caption.x, y);
|
||||
for (int x = 0; x < w; x++, ptr++) {
|
||||
g_engine->_format.colorToARGB(*ptr, a, r, g, b);
|
||||
if (x >= _knob.x - _caption.x && x <= _knob.w + _knob.x - _caption.x) {
|
||||
r /= 3;
|
||||
g /= 3;
|
||||
b /= 2;
|
||||
*ptr = g_engine->_format.ARGBToColor(a, r, g, b);
|
||||
} else if (g > 0x37) {
|
||||
r >>= 1;
|
||||
g >>= 1;
|
||||
b >>= 1;
|
||||
*ptr = g_engine->_format.ARGBToColor(a, r, g, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Slider::value(const int val) {
|
||||
_value = val;
|
||||
|
||||
if (_value < _min)
|
||||
_value = _min;
|
||||
else if (_value > _max)
|
||||
_value = _max;
|
||||
|
||||
_knob.x = _bar.x + ((_bar.w - _knob.w) * (_value - _min)) / (_max - _min);
|
||||
}
|
||||
|
||||
void Slider::setUI() {
|
||||
_bar.setUI();
|
||||
_knob.setUI();
|
||||
_caption.setUI(&_bar);
|
||||
|
||||
_knob.x = _bar.x + ((_bar.w - _knob.w) * _value / (_max - _min));
|
||||
_knob.y = _bar.y;
|
||||
_knob.w = g_engine->_imageManager->getTexture(_knob._img._normal).w();
|
||||
_knob.h = g_engine->_imageManager->getTexture(_knob._img._normal).h();
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
103
engines/crab/ui/slider.h
Normal file
103
engines/crab/ui/slider.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRAB_SLIDER_H
|
||||
#define CRAB_SLIDER_H
|
||||
|
||||
#include "crab/ui/Caption.h"
|
||||
#include "crab/ui/ImageData.h"
|
||||
#include "crab/ui/button.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class Slider {
|
||||
// The value of the slider and the backup
|
||||
int _value, _backup;
|
||||
|
||||
// The slider bar position and dimensions
|
||||
ImageData _bar;
|
||||
|
||||
// The slider knob
|
||||
Button _knob;
|
||||
|
||||
// Caption for the slider
|
||||
Caption _caption;
|
||||
|
||||
// The maximum and minimum values for the slider
|
||||
int _max, _min;
|
||||
|
||||
// Grey out?
|
||||
bool _isGreyed;
|
||||
|
||||
public:
|
||||
Slider() {
|
||||
_max = 100;
|
||||
_min = 0;
|
||||
_value = ((_max - _min) / 2);
|
||||
_backup = _value;
|
||||
_isGreyed = false;
|
||||
}
|
||||
|
||||
~Slider() {}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node, const int &min, const int &max, const int &val);
|
||||
|
||||
bool handleEvents(const Common::Event &event);
|
||||
|
||||
void draw();
|
||||
|
||||
int Value() { return _value; }
|
||||
void value(const int val);
|
||||
|
||||
void createBackup() {
|
||||
_backup = _value;
|
||||
}
|
||||
|
||||
void restoreBackup() {
|
||||
_value = _backup;
|
||||
setUI();
|
||||
}
|
||||
|
||||
void setEnabled(bool enabled) {
|
||||
_isGreyed = !enabled;
|
||||
}
|
||||
|
||||
void greyOut();
|
||||
|
||||
void setUI();
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_SLIDER_H
|
||||
101
engines/crab/ui/textarea.cpp
Normal file
101
engines/crab/ui/textarea.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
//=============================================================================
|
||||
// Author: Arvind
|
||||
// Purpose: TextArea functions
|
||||
//=============================================================================
|
||||
#include "crab/crab.h"
|
||||
#include "crab/input/input.h"
|
||||
#include "crab/ui/textarea.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
using namespace pyrodactyl::ui;
|
||||
using namespace pyrodactyl::text;
|
||||
using namespace pyrodactyl::input;
|
||||
|
||||
void TextArea::load(rapidxml::xml_node<char> *node) {
|
||||
if (TextData::load(node)) {
|
||||
loadStr(_text, "text", node);
|
||||
loadNum(_size, "size", node);
|
||||
|
||||
loadNum(_seEntry, "entry", node);
|
||||
loadNum(_seErase, "erase", node);
|
||||
loadNum(_seAccept, "accept", node);
|
||||
|
||||
if (nodeValid("caption", node))
|
||||
_title.load(node->first_node("caption"), this);
|
||||
}
|
||||
}
|
||||
|
||||
bool TextArea::handleEvents(const Common::Event &event, bool numbersOnly) {
|
||||
if (event.type == Common::EVENT_KEYDOWN && event.kbd.ascii == Common::ASCII_BACKSPACE && _text.size() != 0) {
|
||||
// Now play the text erase sound
|
||||
g_engine->_musicManager->playEffect(_seErase, 0);
|
||||
|
||||
// If backspace was pressed and the string isn't blank, remove a character from the end
|
||||
_text.erase(_text.size() - 1);
|
||||
} else if (event.type == Common::EVENT_KEYDOWN) {
|
||||
// If the string less than maximum size and does not contain invalid characters \ / : * ? " < > |
|
||||
if (_text.size() < _size && event.kbd.ascii != '\\' \
|
||||
&& event.kbd.ascii != '/' && event.kbd.ascii != ':' \
|
||||
&& event.kbd.ascii != '*' && event.kbd.ascii != '?' \
|
||||
&& event.kbd.ascii != '\"' && event.kbd.ascii != '<' \
|
||||
&& event.kbd.ascii != '>' && event.kbd.ascii != '|') {
|
||||
// Should we only accept numbers?
|
||||
if (numbersOnly && (event.kbd.ascii < '0' || event.kbd.ascii > '9'))
|
||||
return false;
|
||||
|
||||
// Now play the text input sound
|
||||
g_engine->_musicManager->playEffect(_seEntry, 0);
|
||||
|
||||
// Append the character to string
|
||||
_text += event.kbd.ascii;
|
||||
}
|
||||
} else if (g_engine->_inputManager->state(IU_ACCEPT) && _text.size() != 0) {
|
||||
// Now play the accept sound
|
||||
g_engine->_musicManager->playEffect(_seAccept, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Purpose: Draw
|
||||
//------------------------------------------------------------------------
|
||||
void TextArea::draw() {
|
||||
_title.draw();
|
||||
TextData::draw(_text + "_");
|
||||
}
|
||||
|
||||
} // End of namespace Crab
|
||||
82
engines/crab/ui/textarea.h
Normal file
82
engines/crab/ui/textarea.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is based on the CRAB engine
|
||||
*
|
||||
* Copyright (c) Arvind Raja Yadav
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
*/
|
||||
|
||||
//=============================================================================
|
||||
// Author: Arvind
|
||||
// Purpose: A box for entering text
|
||||
//=============================================================================
|
||||
#ifndef CRAB_TEXTAREA_H
|
||||
#define CRAB_TEXTAREA_H
|
||||
|
||||
#include "crab/music/MusicManager.h"
|
||||
#include "crab/ui/HoverInfo.h"
|
||||
|
||||
namespace Crab {
|
||||
|
||||
namespace pyrodactyl {
|
||||
namespace ui {
|
||||
class TextArea : public TextData {
|
||||
// The maximum number of characters allowed
|
||||
uint _size;
|
||||
|
||||
// The name of the text area is stored here
|
||||
HoverInfo _title;
|
||||
|
||||
// Sound effects
|
||||
pyrodactyl::music::ChunkKey _seEntry, _seErase, _seAccept;
|
||||
|
||||
public:
|
||||
Common::String _text;
|
||||
|
||||
TextArea() {
|
||||
_size = 20;
|
||||
_seEntry = -1;
|
||||
_seErase = -1;
|
||||
_seAccept = -1;
|
||||
}
|
||||
~TextArea() {}
|
||||
|
||||
void load(rapidxml::xml_node<char> *node);
|
||||
|
||||
bool handleEvents(const Common::Event &event, bool numbersOnly = false);
|
||||
|
||||
void draw();
|
||||
|
||||
void setUI() {
|
||||
_title.setUI();
|
||||
TextData::setUI();
|
||||
}
|
||||
};
|
||||
} // End of namespace ui
|
||||
} // End of namespace pyrodactyl
|
||||
|
||||
} // End of namespace Crab
|
||||
|
||||
#endif // CRAB_TEXTAREA_H
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user