DIRECTOR: Implement FindSys Xlib.

Used in teamxtreme2-win. Now the title goes in-game
This commit is contained in:
Eugene Sandulenko 2023-02-03 22:54:43 +01:00
parent 320492d442
commit c89cc0bc4c
No known key found for this signature in database
GPG Key ID: 014D387312D34F08
4 changed files with 135 additions and 0 deletions

View File

@ -47,6 +47,7 @@
#include "director/lingo/xlibs/fileexists.h"
#include "director/lingo/xlibs/fileio.h"
#include "director/lingo/xlibs/findfolder.h"
#include "director/lingo/xlibs/findsys.h"
#include "director/lingo/xlibs/flushxobj.h"
#include "director/lingo/xlibs/fplayxobj.h"
#include "director/lingo/xlibs/gpid.h"
@ -156,6 +157,7 @@ static struct XLibProto {
{ FileExists::fileNames, FileExists::open, FileExists::close, kXObj, 300 }, // D3
{ FileIO::fileNames, FileIO::open, FileIO::close, kXObj | kXtraObj, 200 }, // D2
{ FindFolder::fileNames, FindFolder::open, FindFolder::close, kXObj, 300 }, // D3
{ FindSys::fileNames, FindSys::open, FindSys::close, kXObj, 400 }, // D4
{ FlushXObj::fileNames, FlushXObj::open, FlushXObj::close, kXObj, 300 }, // D3
{ FPlayXObj::fileNames, FPlayXObj::open, FPlayXObj::close, kXObj, 200 }, // D2
{ GpidXObj::fileNames, GpidXObj::open, GpidXObj::close, kXObj, 400 }, // D4

View File

@ -0,0 +1,85 @@
/* 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/>.
*
*/
/**
* Findsys
* I mNew --Creates a new instance of the XObject
* X mDispose --Disposes of XObject instance
* S mDo --Return the System directory path as a string
* -- Returns pathname OR:
* -- <empty string> couldn't allocate memory
* -- string beginning with the word 'Error:<description>'
* -- The Windows directory is where you should write Preferences files etc.
* -- Mark_Carolan@aapda.com.au Compuserve 100242,1154
*
* USED IN: teamxtreme2-win
*/
#include "director/director.h"
#include "director/lingo/lingo.h"
#include "director/lingo/lingo-object.h"
#include "director/lingo/xlibs/findsys.h"
namespace Director {
// The name is different from the obj filename.
const char *FindSys::xlibName = "FindSys";
const char *FindSys::fileNames[] = {
"FindSys",
nullptr
};
static MethodProto xlibMethods[] = {
{ "new", FindSys::m_new, 0, 0, 400 }, // D4
{ "do", FindSys::m_do, 0, 0, 400 }, // D4
{ nullptr, nullptr, 0, 0, 0 }
};
void FindSys::open(int type) {
if (type == kXObj) {
FindSysXObject::initMethods(xlibMethods);
FindSysXObject *xobj = new FindSysXObject(kXObj);
g_lingo->exposeXObject(xlibName, xobj);
}
}
void FindSys::close(int type) {
if (type == kXObj) {
FindSysXObject::cleanupMethods();
g_lingo->_globalvars[xlibName] = Datum();
}
}
FindSysXObject::FindSysXObject(ObjectType ObjectType) : Object<FindSysXObject>("FindSys") {
_objType = ObjectType;
}
void FindSys::m_new(int nargs) {
g_lingo->push(g_lingo->_state->me);
}
void FindSys::m_do(int nargs) {
g_lingo->push(Common::String("C:\\WINDOWS"));
}
} // End of namespace Director

View File

@ -0,0 +1,47 @@
/* 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_FINDSYS_H
#define DIRECTOR_LINGO_XLIBS_FINDSYS_H
namespace Director {
class FindSysXObject : public Object<FindSysXObject> {
public:
FindSysXObject(ObjectType objType);
};
namespace FindSys {
extern const char *xlibName;
extern const char *fileNames[];
void open(int type);
void close(int type);
void m_new(int nargs);
void m_do(int nargs);
} // End of namespace FindSys
} // End of namespace Director
#endif

View File

@ -50,6 +50,7 @@ MODULE_OBJS = \
lingo/xlibs/fileexists.o \
lingo/xlibs/fileio.o \
lingo/xlibs/findfolder.o \
lingo/xlibs/findsys.o \
lingo/xlibs/flushxobj.o \
lingo/xlibs/fplayxobj.o \
lingo/xlibs/gpid.o \