Initial commit

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

View File

@@ -0,0 +1,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/>.
*
*/
#ifndef ZVISION_FOCUS_LIST_H
#define ZVISION_FOCUS_LIST_H
#include "common/array.h"
namespace ZVision {
/**
* FILO array of unique members
*
* Tracks redraw order of layered graphical elements.
* When an element has current focus, it is reshuffled to the top of the pile.
* When redrawing, start with last (bottom) element of list and finish with first (top)
* Used to:
* - ensure scrolling menus are drawn in the order in which they last had mouse focus.
* - ensure most recently updated subtitle is drawn atop all others.
*/
template<class T>
class FocusList : public Common::Array<T> {
private:
typedef uint size_type;
public:
/**
* Move unique entry to front of list; add to list if not already present.
* Sequence of all remaining members remains unchanged.
*/
void set(const T currentFocus) {
if (!this->size())
this->push_back(currentFocus);
else {
if (this->front() != currentFocus) {
Common::Array<T> buffer;
while (this->size() > 0) {
if (this->back() != currentFocus)
buffer.push_back(this->back());
this->pop_back();
}
this->push_back(currentFocus);
while (buffer.size() > 0) {
this->push_back(buffer.back());
buffer.pop_back();
}
}
}
}
/**
* Remove unique entry, if present.
* Sequence of all remaining members remains unchanged.
*/
void remove(const T value) {
if (this->size()) {
Common::Array<T> buffer;
while (this->size() > 0) {
if (this->back() != value)
buffer.push_back(this->back());
this->pop_back();
}
while (buffer.size() > 0) {
this->push_back(buffer.back());
buffer.pop_back();
}
}
}
};
} // End of namespace ZVision
#endif

View 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/>.
*
*/
#include "zvision/common/scroller.h"
namespace ZVision {
LinearScroller::LinearScroller(const int16 activePos, const int16 idlePos, const int16 period) :
_pos(idlePos),
_prevPos(idlePos),
_activePos(activePos),
_idlePos(idlePos),
_deltaPos((int16)(activePos - idlePos)),
_period(period) {
}
LinearScroller::~LinearScroller() {
}
bool LinearScroller::update(uint32 deltatime) {
_prevPos = _pos;
if (_period != 0) {
int16 targetPos;
float dPos = 0;
if (_active)
targetPos = _activePos;
else
targetPos = _idlePos;
if (_pos != targetPos) {
dPos = (float)((int32)deltatime * (int32)_deltaPos) / _period;
if ((int16)dPos == 0) {
if (_deltaPos > 0)
dPos = 1;
else
dPos = -1;
}
}
if (!_active)
dPos = -dPos;
_pos += (int16)dPos;
if ((dPos == 0) || ((dPos > 0) && (_pos > targetPos)) || ((dPos < 0) && (_pos < targetPos)))
_pos = targetPos;
_moving = (_pos != targetPos);
} else {
if (_active)
_pos = _activePos;
else
_pos = _idlePos;
_moving = false;
}
return (_pos != _prevPos); // True if redraw necessary
}
void LinearScroller::reset() {
setActive(false);
_pos = _idlePos;
}
void LinearScroller::setActive(bool active) {
_active = active;
}
bool LinearScroller::isMoving() {
return _moving;
}
Scroller::Scroller(const Common::Point &activePos, const Common::Point &idlePos, int16 period) :
_xScroller(activePos.x, idlePos.x, period),
_yScroller(activePos.y, idlePos.y, period) {
_pos.x = _xScroller._pos;
_pos.y = _yScroller._pos;
}
Scroller::~Scroller() {
}
void Scroller::reset() {
_xScroller.reset();
_yScroller.reset();
}
void Scroller::setActive(bool active) {
_xScroller.setActive(active);
_yScroller.setActive(active);
}
bool Scroller::isMoving() {
return _xScroller.isMoving() || _yScroller.isMoving();
}
bool Scroller::update(uint32 deltatime) {
bool redraw = false;
if (_xScroller.update(deltatime))
redraw = true;
if (_yScroller.update(deltatime))
redraw = true;
_pos.x = _xScroller._pos;
_pos.y = _yScroller._pos;
return (redraw);
}
} // End of namespace ZVision

View 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/>.
*
*/
#ifndef ZVISION_SCROLLER_H
#define ZVISION_SCROLLER_H
#include "common/rect.h"
#include "zvision/zvision.h"
namespace ZVision {
/**
* Automatically scroll a GUI menu or similar graphical element between an active and an idle position
* Movement in one dimension; idle & active positions specified as int16.
* Movement is at constant speed determined by period, specified in ms.
* If active/idle status is changed mid-transition, will scroll from current position to the appropriate position.
* LinearScroller also be used to reversibly scroll animation frames.
*/
class LinearScroller {
public:
LinearScroller(const int16 activePos, const int16 idlePos, const int16 period = 500);
~LinearScroller();
void reset(); ///< Set idle and immediately jump to idle position
bool update(uint32 deltatime); ///< Calculate updated position of scrolled graphics; return true if redraw is necessary.
void setActive(bool active); ///< Set active or idle & scroll at set speed from current position to that position.
bool isMoving();
int16 getPos();
int16 _pos;
int16 _prevPos;
private:
bool _active = false;
bool _moving = false;
const int16 _activePos;
const int16 _idlePos;
const int16 _deltaPos;
const int16 _period;
};
/**
* Automatically scroll a GUI menu or similar graphical element between an active and an idle position
* Movement in two dimensions; idle & active positions specified as Common::Point
* Movement is at constant speed determined by period, specified in ms.
* If active/idle status is changed mid-transition, will scroll from current position to the appropriate position.
*/
class Scroller {
public:
Scroller(const Common::Point &activePos, const Common::Point &idlePos, const int16 period = 500);
~Scroller();
void reset(); ///< Set idle and immediately jump to idle position
bool update(uint32 deltatime); ///< Calculate updated position of scrolled graphics; return true if redraw is necessary.
void setActive(bool active); ///< Set active or idle & scroll at set speed from current position to that position.
bool isMoving();
Common::Point _pos;
private:
LinearScroller _xScroller, _yScroller;
};
} // End of namespace ZVision
#endif