scummvm/engines/mediastation/asset.h
Nathanael Gentry 361996787d MEDIASTATION: Refactor file/stream handling classes
They are moved inside a single source unit, and the
rather messy implementation of Chunk is somewhat
cleaned up. Some hacks for chunk handling are left in
for now, but they should be addressed in the future.
2025-02-22 20:09:19 -05:00

90 lines
No EOL
2.7 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* 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 MEDIASTATION_ASSET_H
#define MEDIASTATION_ASSET_H
#include "common/keyboard.h"
#include "mediastation/mediastation.h"
#include "mediastation/datafile.h"
#include "mediastation/mediascript/scriptconstants.h"
#include "mediastation/mediascript/operand.h"
#include "mediastation/assetheader.h"
namespace MediaStation {
class AssetHeader;
class Asset {
public:
Asset(AssetHeader *header) : _header(header) {};
virtual ~Asset();
// Does any needed frame drawing, audio playing, event handlers, etc.
virtual void process() {
return;
}
// For spatial assets, actually redraws the dirty area.
virtual void redraw(Common::Rect &rect) {
return;
}
// Runs built-in bytecode methods.
virtual Operand callMethod(BuiltInMethod methodId, Common::Array<Operand> &args) = 0;
// Called to have the asset do any processing, like drawing new frames,
// handling time-based event handlers, and such. Some assets don't have any
// processing to do.
virtual bool isActive() const {
return _isActive;
}
// These are not pure virtual so if an asset doesnʻt read any chunks or
// subfiles it doesnʻt need to just implement these with an error message.
virtual void readChunk(Chunk &chunk);
virtual void readSubfile(Subfile &subfile, Chunk &chunk);
void setInactive();
void setActive();
void processTimeEventHandlers();
void runEventHandlerIfExists(EventType eventType);
void runKeyDownEventHandlerIfExists(Common::KeyState keyState);
AssetType type() const;
int zIndex() const;
AssetHeader *getHeader() const {
return _header;
}
Common::Rect *getBbox();
protected:
AssetHeader *_header = nullptr;
bool _isActive = false;
uint _startTime = 0;
uint _lastProcessedTime = 0;
// TODO: Rename this to indicate the time is in milliseconds.
uint _duration = 0;
};
} // End of namespace MediaStation
#endif