Initial commit
This commit is contained in:
120
engines/director/lingo/xlibs/a/aiff.cpp
Normal file
120
engines/director/lingo/xlibs/a/aiff.cpp
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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************
|
||||
*
|
||||
* USED IN:
|
||||
* Gahan Wilson's Ultimate Haunted House
|
||||
*
|
||||
*************************************/
|
||||
|
||||
/*
|
||||
* -- copyright 1994 by Byron Priess Multimedia, authored by MayoSmith and Lee
|
||||
* aiff
|
||||
* I mNew --Read Docs to avoid Hard Drive failure
|
||||
* X mDispose --Disposes of XObject instance
|
||||
* S mName --Returns the XObject name (Widget)
|
||||
* I mStatus --Returns an integer status code
|
||||
* SI mError, code --Returns an error string
|
||||
* S mLastError --Returns last error string
|
||||
* III mAdd, arg1, arg2 --Returns arg1+arg2
|
||||
* SSI mFirst, str, nchars --Return the first nchars of string str
|
||||
* V mMul, f1, f2 --Returns f1*f2 as floating point
|
||||
* X mGlobals --Sample code to Read & Modify globals
|
||||
* X mSymbols --Sample code to work with Symbols
|
||||
* X mSendPerform --Sample code to show SendPerform call
|
||||
* X mFactory --Sample code to find Factory objects
|
||||
* IS mDuration, str --Read Docs to avoid Hard Drive failure
|
||||
*/
|
||||
|
||||
#include "common/macresman.h"
|
||||
#include "audio/decoders/aiff.h"
|
||||
#include "director/director.h"
|
||||
#include "director/lingo/lingo.h"
|
||||
#include "director/lingo/lingo-object.h"
|
||||
#include "director/lingo/xlibs/a/aiff.h"
|
||||
|
||||
|
||||
namespace Director {
|
||||
|
||||
const char *const AiffXObj::xlibName = "aiff";
|
||||
const XlibFileDesc AiffXObj::fileNames[] = {
|
||||
{ "AIFF", nullptr },
|
||||
{ nullptr, nullptr },
|
||||
};
|
||||
|
||||
static const MethodProto xlibMethods[] = {
|
||||
{ "new", AiffXObj::m_new, 0, 0, 400 }, // D4
|
||||
{ "Duration", AiffXObj::m_duration, 1, 1, 400 }, // D4
|
||||
{ nullptr, nullptr, 0, 0, 0 }
|
||||
};
|
||||
|
||||
void AiffXObj::open(ObjectType type, const Common::Path &path) {
|
||||
if (type == kXObj) {
|
||||
AiffXObject::initMethods(xlibMethods);
|
||||
AiffXObject *xobj = new AiffXObject(kXObj);
|
||||
g_lingo->exposeXObject(xlibName, xobj);
|
||||
}
|
||||
}
|
||||
|
||||
void AiffXObj::close(ObjectType type) {
|
||||
if (type == kXObj) {
|
||||
AiffXObject::cleanupMethods();
|
||||
g_lingo->_globalvars[xlibName] = Datum();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AiffXObject::AiffXObject(ObjectType ObjectType) :Object<AiffXObject>("Aiff") {
|
||||
_objType = ObjectType;
|
||||
}
|
||||
|
||||
void AiffXObj::m_new(int nargs) {
|
||||
g_lingo->printSTUBWithArglist("AiffXObj::new", nargs);
|
||||
g_lingo->push(g_lingo->_state->me);
|
||||
}
|
||||
|
||||
void AiffXObj::m_duration(int nargs) {
|
||||
Common::String filePath = g_lingo->pop().asString();
|
||||
|
||||
Common::SeekableReadStream *aiffStream = Common::MacResManager::openFileOrDataFork(findPath(filePath));
|
||||
if (!aiffStream) {
|
||||
warning("AiffXObj::m_duration: Failed to open %s", filePath.c_str());
|
||||
g_lingo->push(0);
|
||||
return;
|
||||
}
|
||||
|
||||
Audio::AIFFHeader *aiffHeader = Audio::AIFFHeader::readAIFFHeader(aiffStream, DisposeAfterUse::NO);
|
||||
if (!aiffHeader) {
|
||||
warning("AiffXObj::m_duration: No AIFF header found for %s", filePath.c_str());
|
||||
g_lingo->push(0);
|
||||
delete aiffStream;
|
||||
return;
|
||||
}
|
||||
|
||||
int duration = (aiffHeader->getFrameCount() / (float)aiffHeader->getFrameRate()) * 60;
|
||||
|
||||
delete aiffHeader;
|
||||
delete aiffStream;
|
||||
g_lingo->push(Datum(duration));
|
||||
}
|
||||
|
||||
} // End of namespace Director
|
||||
49
engines/director/lingo/xlibs/a/aiff.h
Normal file
49
engines/director/lingo/xlibs/a/aiff.h
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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DIRECTOR_LINGO_XLIBS_AIFF_H
|
||||
#define DIRECTOR_LINGO_XLIBS_AIFF_H
|
||||
|
||||
namespace Director {
|
||||
|
||||
class AiffXObject : public Object<AiffXObject> {
|
||||
public:
|
||||
AiffXObject(ObjectType objType);
|
||||
};
|
||||
|
||||
namespace AiffXObj {
|
||||
|
||||
extern const char *const xlibName;
|
||||
extern const XlibFileDesc fileNames[];
|
||||
|
||||
void open(ObjectType type, const Common::Path &path);
|
||||
void close(ObjectType type);
|
||||
|
||||
void m_new(int nargs);
|
||||
|
||||
void m_duration(int nargs);
|
||||
|
||||
} // End of namespace AiffXObj
|
||||
|
||||
} // End of namespace Director
|
||||
|
||||
#endif
|
||||
321
engines/director/lingo/xlibs/a/applecdxobj.cpp
Normal file
321
engines/director/lingo/xlibs/a/applecdxobj.cpp
Normal file
@@ -0,0 +1,321 @@
|
||||
/* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************
|
||||
*
|
||||
* USED IN:
|
||||
* Classical Cats
|
||||
* The Daedalus Encounter
|
||||
* Refixion II
|
||||
*
|
||||
*************************************/
|
||||
|
||||
/*
|
||||
-! Category compactDisc
|
||||
* -! Title AppleCD SC
|
||||
* -! Protocol Ortho-Play 1.6.1
|
||||
* --© 1990,1991 MacroMind, Inc. Alan McNeil
|
||||
* ------------------------------------------------------
|
||||
* --AppleCD SC, version 2.5.6
|
||||
* --Mar 7 1994
|
||||
* --including AppleCD SC Plus volume control
|
||||
* ------------------------------------------------------
|
||||
* X mNew
|
||||
* X mDispose
|
||||
* --
|
||||
* I mGetMaxNodes
|
||||
* SI mGetNodeTitle NodeNum
|
||||
* II mSelectNode NodeNum
|
||||
* --
|
||||
* I mService
|
||||
* I mGetValue
|
||||
* I mCancel
|
||||
* S mExplain
|
||||
* I mIdle
|
||||
* --
|
||||
* X mReadStatus
|
||||
* X mReadPos
|
||||
* XI mSearchTo position
|
||||
* X mPlay
|
||||
* X mStill
|
||||
* X mStop
|
||||
* X mScanForward
|
||||
* X mScanReverse
|
||||
* X mEject
|
||||
* --
|
||||
* I mGetFirstTrack
|
||||
* I mGetLastTrack
|
||||
* II mGetFirstFrame tracknum
|
||||
* II mGetLastFrame tracknum
|
||||
* I mGetTrack
|
||||
* XII mAudioEnable number number
|
||||
* I mGetFrameResolution
|
||||
* --
|
||||
* II mSetInPoint frame
|
||||
* II mSetOutPoint frame
|
||||
* II mSetDuration frames
|
||||
* --
|
||||
* X mPlayCue
|
||||
* X mPlaySegment
|
||||
* --
|
||||
* S mTitle
|
||||
* SI mTrackName tracknum
|
||||
* IS mSetTitle string
|
||||
* IIS mSetTrackName tracknum string
|
||||
* II mGetTrackType tracknum
|
||||
* III mSetVolume leftVolume rightVolume
|
||||
* II mGetVolume leftFlag
|
||||
* --
|
||||
*/
|
||||
|
||||
#include "backends/audiocd/audiocd.h"
|
||||
#include "common/file.h"
|
||||
#include "common/formats/cue.h"
|
||||
#include "director/director.h"
|
||||
#include "director/lingo/lingo.h"
|
||||
#include "director/lingo/lingo-object.h"
|
||||
#include "director/lingo/xlibs/a/applecdxobj.h"
|
||||
|
||||
|
||||
namespace Director {
|
||||
|
||||
const char *const AppleCDXObj::xlibName = "AppleCD";
|
||||
const XlibFileDesc AppleCDXObj::fileNames[] = {
|
||||
{ "AppleCD", nullptr },
|
||||
{ "AppleCD XObj", nullptr },
|
||||
{ nullptr, nullptr },
|
||||
};
|
||||
|
||||
static const MethodProto xlibMethods[] = {
|
||||
{ "new", AppleCDXObj::m_new, 0, 0, 300 }, // D3
|
||||
{ "dispose", AppleCDXObj::m_dispose, 0, 0, 300 }, // D3
|
||||
{ "Service", AppleCDXObj::m_service, 0, 0, 300 }, // D4
|
||||
{ "Still", AppleCDXObj::m_still, 0, 0, 300 }, // D3
|
||||
{ "ReadStatus", AppleCDXObj::m_readStatus, 0, 0, 300 }, // D3
|
||||
{ "GetValue", AppleCDXObj::m_getValue, 0, 0, 300 }, // D3
|
||||
{ "Eject", AppleCDXObj::m_eject, 0, 0, 300 }, // D3
|
||||
{ "GetFirstTrack", AppleCDXObj::m_getFirstTrack, 0, 0, 300 }, // D3
|
||||
{ "GetLastTrack", AppleCDXObj::m_getLastTrack, 0, 0, 300 }, // D3
|
||||
{ "GetFirstFrame", AppleCDXObj::m_getFirstFrame, 1, 1, 300 }, // D3
|
||||
{ "GetLastFrame", AppleCDXObj::m_getLastFrame, 1, 1, 300 }, // D3
|
||||
{ "SetInPoint", AppleCDXObj::m_setInPoint, 1, 1, 300 }, // D3
|
||||
{ "SetOutPoint", AppleCDXObj::m_setOutPoint, 1, 1, 300 }, // D3
|
||||
{ "PlayCue", AppleCDXObj::m_playCue, 0, 0, 300 }, // D3
|
||||
{ "PlaySegment", AppleCDXObj::m_playSegment, 0, 0, 300 }, // D3
|
||||
{ "ReadPos", AppleCDXObj::m_readPos, 0, 0, 300 }, // D3
|
||||
{ nullptr, nullptr, 0, 0, 0 }
|
||||
};
|
||||
|
||||
void AppleCDXObj::open(ObjectType type, const Common::Path &path) {
|
||||
if (type == kXObj) {
|
||||
AppleCDXObject::initMethods(xlibMethods);
|
||||
AppleCDXObject *xobj = new AppleCDXObject(kXObj);
|
||||
g_lingo->exposeXObject(xlibName, xobj);
|
||||
}
|
||||
}
|
||||
|
||||
void AppleCDXObj::close(ObjectType type) {
|
||||
if (type == kXObj) {
|
||||
AppleCDXObject::cleanupMethods();
|
||||
g_lingo->_globalvars[xlibName] = Datum();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AppleCDXObject::AppleCDXObject(ObjectType ObjectType) :Object<AppleCDXObject>("AppleCD") {
|
||||
_objType = ObjectType;
|
||||
_inpoint = 0;
|
||||
_outpoint = 0;
|
||||
|
||||
Common::File cuefile;
|
||||
if (cuefile.open("disc.cue")) {
|
||||
Common::String cuestring = cuefile.readString(0, cuefile.size());
|
||||
|
||||
_cue = Common::SharedPtr<Common::CueSheet>(new Common::CueSheet(cuestring.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
void AppleCDXObj::m_new(int nargs) {
|
||||
g_lingo->push(g_lingo->_state->me);
|
||||
}
|
||||
|
||||
void AppleCDXObj::m_dispose(int nargs) {
|
||||
g_director->_system->getAudioCDManager()->stop();
|
||||
}
|
||||
|
||||
void AppleCDXObj::m_still(int nargs) {
|
||||
g_director->_system->getAudioCDManager()->stop();
|
||||
}
|
||||
|
||||
// Not implemented yet; needs to be able to return appropriate values
|
||||
// for playing/paused.
|
||||
void AppleCDXObj::m_service(int nargs) {
|
||||
g_lingo->push(Datum(0));
|
||||
}
|
||||
|
||||
void AppleCDXObj::m_readStatus(int nargs) {
|
||||
}
|
||||
|
||||
void AppleCDXObj::m_getValue(int nargs) {
|
||||
AppleCDXObject *me = static_cast<AppleCDXObject *>(g_lingo->_state->me.u.obj);
|
||||
|
||||
g_lingo->push(Datum(me->_returnValue));
|
||||
}
|
||||
|
||||
void AppleCDXObj::m_setInPoint(int nargs) {
|
||||
AppleCDXObject *me = static_cast<AppleCDXObject *>(g_lingo->_state->me.u.obj);
|
||||
|
||||
int inpoint = g_lingo->pop().asInt();
|
||||
debug(5, "AppleCDXObj::setInPoint: %i", inpoint);
|
||||
me->_inpoint = inpoint;
|
||||
}
|
||||
|
||||
void AppleCDXObj::m_setOutPoint(int nargs) {
|
||||
AppleCDXObject *me = static_cast<AppleCDXObject *>(g_lingo->_state->me.u.obj);
|
||||
|
||||
int outpoint = g_lingo->pop().asInt();
|
||||
debug(5, "AppleCDXObj::setOutPoint: %i", outpoint);
|
||||
me->_outpoint = outpoint;
|
||||
}
|
||||
|
||||
void AppleCDXObj::m_playCue(int nargs) {
|
||||
// Essentially a noop for us; this asks the drive to seek to that point,
|
||||
// then poll until it does. We don't have seek times, so we'll
|
||||
// simply noop.
|
||||
}
|
||||
|
||||
void AppleCDXObj::m_playSegment(int nargs) {
|
||||
// Performs playback at the pre-specified absolute point on the disc,
|
||||
// using the values from setInPoint and setOutPoint
|
||||
AppleCDXObject *me = static_cast<AppleCDXObject *>(g_lingo->_state->me.u.obj);
|
||||
|
||||
g_director->_system->getAudioCDManager()->playAbsolute(me->_inpoint, -1, 0, 0);
|
||||
}
|
||||
|
||||
void AppleCDXObj::m_readPos(int nargs) {
|
||||
AppleCDXObject *me = static_cast<AppleCDXObject *>(g_lingo->_state->me.u.obj);
|
||||
|
||||
AudioCDManager::Status status = g_director->_system->getAudioCDManager()->getStatus();
|
||||
if (me->_cue) {
|
||||
// ScummVM currently doesn't support specifying the exact frame, so we pretend we're at the first frame of the song
|
||||
Common::CueSheet::CueTrack *track = me->_cue->getTrack(status.track);
|
||||
if (track != nullptr) {
|
||||
me->_returnValue = track->indices[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AppleCDXObj::m_getFirstTrack(int nargs) {
|
||||
AppleCDXObject *me = static_cast<AppleCDXObject *>(g_lingo->_state->me.u.obj);
|
||||
|
||||
if (me->_cue) {
|
||||
Common::Array<Common::CueSheet::CueTrack> tracks = me->_cue->tracks();
|
||||
// If we have a set of tracks parsed, return the first track's number
|
||||
int index;
|
||||
if (tracks.size() >= 1) {
|
||||
index = tracks[0].number;
|
||||
} else {
|
||||
index = 1;
|
||||
}
|
||||
debug(5, "AppleCDXObj::m_getFirstTrack: returning %i", index);
|
||||
g_lingo->push(Datum(index));
|
||||
} else {
|
||||
// If we don't have a TOC, just assume the first track is 1
|
||||
debug(5, "AppleCDXObj::m_getFirstTrack: returning default");
|
||||
g_lingo->push(Datum(1));
|
||||
}
|
||||
}
|
||||
|
||||
void AppleCDXObj::m_getLastTrack(int nargs) {
|
||||
AppleCDXObject *me = static_cast<AppleCDXObject *>(g_lingo->_state->me.u.obj);
|
||||
|
||||
if (me->_cue) {
|
||||
Common::Array<Common::CueSheet::CueTrack> tracks = me->_cue->tracks();
|
||||
// If we have a set of tracks parsed, return the final track's number
|
||||
int index;
|
||||
if (tracks.size() >= 1) {
|
||||
index = tracks.back().number;
|
||||
} else {
|
||||
index = 1;
|
||||
}
|
||||
debug(5, "AppleCDXObj::m_getLastTrack: returning %i", index);
|
||||
} else {
|
||||
// If we don't have a TOC, just assume the last track is 1
|
||||
debug(5, "AppleCDXObj::m_getLastTrack: returning default");
|
||||
g_lingo->push(Datum(1));
|
||||
}
|
||||
}
|
||||
|
||||
void AppleCDXObj::m_getFirstFrame(int nargs) {
|
||||
AppleCDXObject *me = static_cast<AppleCDXObject *>(g_lingo->_state->me.u.obj);
|
||||
int trackNum = g_lingo->pop().asInt();
|
||||
|
||||
if (me->_cue) {
|
||||
Common::CueSheet::CueTrack *track = me->_cue->getTrack(trackNum);
|
||||
|
||||
// We use index 1 here because index 0 is typically the
|
||||
// pregap, and we don't want to describe the first sector of the
|
||||
// pregap as being the first sector of the track. Most discs
|
||||
// will have only two indices, and the second index is where the
|
||||
// actual track begins.
|
||||
int index = track->indices.size() > 1 ? track->indices[1] : track->indices[0];
|
||||
debug(5, "AppleCDXObj::m_getFirstFrame(%i): returning %i", trackNum, index);
|
||||
g_lingo->push(Datum(index));
|
||||
} else {
|
||||
// If we don't have a TOC, just provide a stub value
|
||||
debug(5, "AppleCDXObj::m_getFirstFrame(%i): returning default", trackNum);
|
||||
g_lingo->push(Datum(0));
|
||||
}
|
||||
}
|
||||
|
||||
// Currently calculated based on the start of the next track, since
|
||||
// cuesheets don't contain the duration of a song.
|
||||
void AppleCDXObj::m_getLastFrame(int nargs) {
|
||||
AppleCDXObject *me = static_cast<AppleCDXObject *>(g_lingo->_state->me.u.obj);
|
||||
int trackNum = g_lingo->pop().asInt();
|
||||
|
||||
if (me->_cue) {
|
||||
// We look for the pregap of the next track, if there is one.
|
||||
// TODO opening the actual audio track and getting its length
|
||||
// in sectors would produce a more accurate result for the final track
|
||||
Common::CueSheet::CueTrack *track = me->_cue->getTrack(trackNum + 1);
|
||||
int index;
|
||||
if (track) {
|
||||
// Don't use the pregap if there is no pregap
|
||||
index = track->indices[0] == -1 ? track->indices[1] : track->indices[0];
|
||||
} else {
|
||||
debug(5, "AppleCDXObj::m_getLastFrame(%i): no track at trackNum %i, setting index to 0", trackNum, trackNum + 1);
|
||||
index = 0;
|
||||
}
|
||||
debug(5, "AppleCDXObj::m_getLastFrame(%i): returning %i", trackNum, index);
|
||||
g_lingo->push(Datum(index));
|
||||
} else {
|
||||
// If we don't have a TOC, just provide a stub value
|
||||
debug(5, "AppleCDXObj::m_getLastFrame(%i): returning default", trackNum);
|
||||
g_lingo->push(Datum(0));
|
||||
}
|
||||
}
|
||||
|
||||
void AppleCDXObj::m_eject(int nargs) {
|
||||
debug(5, "AppleCDXObj::eject: Ejecting CD");
|
||||
}
|
||||
|
||||
} // End of namespace Director
|
||||
74
engines/director/lingo/xlibs/a/applecdxobj.h
Normal file
74
engines/director/lingo/xlibs/a/applecdxobj.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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DIRECTOR_LINGO_XLIBS_APPLECDXOBJ_H
|
||||
#define DIRECTOR_LINGO_XLIBS_APPLECDXOBJ_H
|
||||
|
||||
#include "common/ptr.h"
|
||||
|
||||
namespace Common {
|
||||
class CueSheet;
|
||||
}
|
||||
|
||||
namespace Director {
|
||||
|
||||
class AppleCDXObject : public Object<AppleCDXObject> {
|
||||
public:
|
||||
AppleCDXObject(ObjectType objType);
|
||||
int _inpoint;
|
||||
int _outpoint;
|
||||
// Instead of immediately returning values, methods which return
|
||||
// a value store it internally and return it via a subsequent
|
||||
// call to mGetValue.
|
||||
int _returnValue;
|
||||
Common::SharedPtr<Common::CueSheet> _cue;
|
||||
};
|
||||
|
||||
namespace AppleCDXObj {
|
||||
|
||||
extern const char *const xlibName;
|
||||
extern const XlibFileDesc fileNames[];
|
||||
|
||||
void open(ObjectType type, const Common::Path &path);
|
||||
void close(ObjectType type);
|
||||
|
||||
void m_new(int nargs);
|
||||
void m_dispose(int nargs);
|
||||
void m_still(int nargs);
|
||||
void m_service(int nargs);
|
||||
void m_readStatus(int nargs);
|
||||
void m_getValue(int nargs);
|
||||
void m_setInPoint(int nargs);
|
||||
void m_setOutPoint(int nargs);
|
||||
void m_playCue(int nargs);
|
||||
void m_playSegment(int nargs);
|
||||
void m_readPos(int nargs);
|
||||
void m_getFirstTrack(int nargs);
|
||||
void m_getLastTrack(int nargs);
|
||||
void m_getFirstFrame(int nargs);
|
||||
void m_getLastFrame(int nargs);
|
||||
void m_eject(int nargs);
|
||||
|
||||
} // End of namespace AppleCDXObj
|
||||
|
||||
} // End of namespace Director
|
||||
|
||||
#endif
|
||||
140
engines/director/lingo/xlibs/a/askuser.cpp
Normal file
140
engines/director/lingo/xlibs/a/askuser.cpp
Normal file
@@ -0,0 +1,140 @@
|
||||
/* 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 "common/system.h"
|
||||
#include "director/types.h"
|
||||
#include "gui/message.h"
|
||||
|
||||
#include "director/director.h"
|
||||
#include "director/lingo/lingo.h"
|
||||
#include "director/lingo/lingo-object.h"
|
||||
#include "director/lingo/xlibs/a/askuser.h"
|
||||
|
||||
namespace Director {
|
||||
|
||||
/**************************************************
|
||||
*
|
||||
* USED IN:
|
||||
* DEVO Presents: Adventures of the Smart Patrol
|
||||
*
|
||||
**************************************************/
|
||||
|
||||
/*
|
||||
* -- AskUser XObject. Copyright 1996 Inscape v1.0 24May96 BDL
|
||||
* AskUser
|
||||
* I mNew --Creates a new instance
|
||||
* X mDispose --Disposes XObject instance
|
||||
* SSSS mAsk --Data to display in the message box.
|
||||
*/
|
||||
|
||||
const char *const AskUser::xlibName = "AskUser";
|
||||
const XlibFileDesc AskUser::fileNames[] = {
|
||||
{ "AskUser", nullptr },
|
||||
{ nullptr, nullptr },
|
||||
};
|
||||
|
||||
static const MethodProto xlibMethods[] = {
|
||||
{ "new", AskUser::m_new, 0, 0, 400 }, // D4
|
||||
{ "ask", AskUser::m_ask, 3, 3, 400 }, // D4
|
||||
{ nullptr, nullptr, 0, 0, 0 }
|
||||
};
|
||||
|
||||
AskUserXObject::AskUserXObject(ObjectType ObjectType) :Object<AskUserXObject>("AskUser") {
|
||||
_objType = ObjectType;
|
||||
}
|
||||
|
||||
void AskUser::open(ObjectType type, const Common::Path &path) {
|
||||
if (type == kXObj) {
|
||||
AskUserXObject::initMethods(xlibMethods);
|
||||
AskUserXObject *xobj = new AskUserXObject(kXObj);
|
||||
g_lingo->exposeXObject(xlibName, xobj);
|
||||
}
|
||||
}
|
||||
|
||||
void AskUser::close(ObjectType type) {
|
||||
if (type == kXObj) {
|
||||
AskUserXObject::cleanupMethods();
|
||||
g_lingo->_globalvars[xlibName] = Datum();
|
||||
}
|
||||
}
|
||||
|
||||
void AskUser::m_new(int nargs) {
|
||||
g_lingo->printSTUBWithArglist("AskUser::m_new", nargs);
|
||||
g_lingo->dropStack(nargs);
|
||||
g_lingo->push(g_lingo->_state->me);
|
||||
}
|
||||
|
||||
void AskUser::m_ask(int nargs) {
|
||||
if (nargs != 3) {
|
||||
warning("AskUser::m_ask: expected 3 arguments");
|
||||
g_lingo->dropStack(nargs);
|
||||
g_lingo->push(Datum("Ok"));
|
||||
return;
|
||||
}
|
||||
Datum text = g_lingo->pop();
|
||||
Datum caption = g_lingo->pop(); // ScummVM doesn't have a title for message boxes, not used
|
||||
Datum mbType = g_lingo->pop();
|
||||
if (text.type != STRING) {
|
||||
warning("AskUser::m_ask: expected text to be a string, not %s", text.type2str());
|
||||
g_lingo->push(Datum("Ok"));
|
||||
return;
|
||||
}
|
||||
if (mbType.type != STRING) {
|
||||
warning("AskUser::m_ask: expected mbType to be a string, not %s", mbType.type2str());
|
||||
g_lingo->push(Datum("Ok"));
|
||||
return;
|
||||
}
|
||||
|
||||
Common::U32String defaultButton;
|
||||
Common::U32StringArray altButtons;
|
||||
|
||||
if (mbType.u.s->equals("YesNoCancel")) {
|
||||
defaultButton = Common::U32String("Yes");
|
||||
altButtons.push_back(Common::U32String("No"));
|
||||
altButtons.push_back(Common::U32String("Cancel"));
|
||||
} else if (mbType.u.s->equals("YesNo")) {
|
||||
defaultButton = Common::U32String("Yes");
|
||||
altButtons.push_back(Common::U32String("No"));
|
||||
} else if (mbType.u.s->equals("OkCancel")) {
|
||||
defaultButton = Common::U32String("OK");
|
||||
altButtons.push_back(Common::U32String("Cancel"));
|
||||
} else if (mbType.u.s->equals("Ok")) {
|
||||
defaultButton = Common::U32String("OK");
|
||||
} else {
|
||||
warning("AskUser::m_ask: unhandled mbType %s, falling back to Ok", mbType.u.s->c_str());
|
||||
defaultButton = Common::U32String("OK");
|
||||
}
|
||||
|
||||
g_director->_wm->clearHandlingWidgets();
|
||||
GUI::MessageDialog dialog(Common::U32String(text.u.s->c_str()), defaultButton, altButtons);
|
||||
int result = dialog.runModal();
|
||||
|
||||
if (result == GUI::kMessageOK) {
|
||||
g_lingo->push(Datum(Common::String(defaultButton)));
|
||||
} else if ((result >= GUI::kMessageAlt) && (result < GUI::kMessageAlt + (int)altButtons.size())) {
|
||||
g_lingo->push(Datum(Common::String(altButtons[result - GUI::kMessageAlt])));
|
||||
} else {
|
||||
warning("AskUser::m_ask: got unexpected dialog result of %d", result);
|
||||
g_lingo->push(Datum("Ok"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
48
engines/director/lingo/xlibs/a/askuser.h
Normal file
48
engines/director/lingo/xlibs/a/askuser.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* 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 DIRECTOR_LINGO_XLIBS_ASKUSER_H
|
||||
#define DIRECTOR_LINGO_XLIBS_ASKUSER_H
|
||||
|
||||
namespace Director {
|
||||
|
||||
class AskUserXObject : public Object<AskUserXObject> {
|
||||
public:
|
||||
AskUserXObject(ObjectType objType);
|
||||
};
|
||||
|
||||
namespace AskUser {
|
||||
|
||||
extern const char *const xlibName;
|
||||
extern const XlibFileDesc fileNames[];
|
||||
|
||||
void open(ObjectType type, const Common::Path &path);
|
||||
void close(ObjectType type);
|
||||
|
||||
void m_new(int nargs);
|
||||
void m_dispose(int nargs);
|
||||
void m_ask(int nargs);
|
||||
|
||||
} // End of namespace AskUser
|
||||
|
||||
} // End of namespace Director
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user