Exemple #1
0
bool ScScript::create(const char *filename, byte *buffer, uint32 size, BaseScriptHolder *owner) {
	cleanup();

	_thread = false;
	_methodThread = false;

	delete[] _threadEvent;
	_threadEvent = nullptr;

	_filename = new char[strlen(filename) + 1];
	if (_filename) {
		strcpy(_filename, filename);
	}

	_buffer = new byte [size];
	if (!_buffer) {
		return STATUS_FAILED;
	}

	memcpy(_buffer, buffer, size);

	_bufferSize = size;

	bool res = initScript();
	if (DID_FAIL(res)) {
		return res;
	}

	// establish global variables table
	_globals = new ScValue(_gameRef);

	_owner = owner;

	return STATUS_OK;
}
void FLFormRecordDB::previousRecord() {
    if ( cursor_ && cursor_->isValid() ) {
        if ( cursor_->at() == 0 ) {
            lastRecord();
            return ;
        }
        if ( !validateForm() )
            return ;
        if ( cursor_->checkIntegrity() ) {
            acceptedForm();
            cursor_->setActivatedCheckIntegrity( false );
            if ( cursor_->commitBuffer() ) {
                cursor_->setActivatedCheckIntegrity( true );
                cursor_->commit();
                cursor_->setModeAccess( initialModeAccess );
                accepted = false;
                QString caption = cursor_->metadata() ->alias() + " [ " + static_cast<FLApplication *>( qApp ) ->lastTextCaption() + " ]";
                cursor_->transaction();
                cursor_->prev();
                initScript();
            }
        }
#ifdef FL_TEST
        static_cast<FLApplication *>( qApp ) ->continueTesting( FLTester::FORM_RECORD_READY, this->name() );
#endif
    }
}
Exemple #3
0
int QTController::run(int argc, char **argv)
{
    if( m_job == NULL ) {
        throw std::runtime_error( "No job set" );
    }
    m_model = m_job->getExposedModel();



    m_app.reset(  new QApplication( argc, argv ) );
    m_main_window.reset( new QMainWindow() );
    m_invoker = new impl::Invoker( m_main_window.get() );

    setupServerController();

    // Now we may init the script.
    tiniaInitResources();
    initScript();

    if( dynamic_cast<jobcontroller::OpenGLJob*>( m_job ) ) {
        for( int i=1; i<argc; i++) {
            if( strcmp(argv[i], "--perf" ) == 0 ) {
                m_perf_mode = true;
            }
            else if( strcmp( argv[i], "--renderlist" ) == 0 ) {
                m_renderlist_mode = true;
            }
        }

        // Create an off-screen context that is subsequently shared with all
        // GL widgets that will be subsequently created. This avoids requiring
        // that the view is defined before doing GL init as well as allowing
        // GL resources to be shared between widgets.
        m_root_context = new QGLWidget(QGL::DepthBuffer| QGL::DoubleBuffer | QGL::AlphaChannel);
        m_root_context->makeCurrent();
    }
    if( !m_job->init() ) {
       throw new std::runtime_error("Job did not start up properly");
    }

    m_builder.reset( new GUIBuilder( m_model, m_job, this, m_perf_mode, m_root_context ) );

    m_main_window->setCentralWidget( m_builder->buildGUI( m_model->getGUILayout(model::gui::DESKTOP),
                                                          NULL ) );

	if( dynamic_cast<jobcontroller::OpenGLJob*>( m_job ) ) {
	if( !(dynamic_cast<jobcontroller::OpenGLJob*>(m_job))->initGL()) {
		throw new std::runtime_error("Job did not initialize GL correctly");
	}
	}
    m_main_window->show();

    return m_app->exec();
}
Exemple #4
0
bool ScScript::createMethodThread(ScScript *original, const Common::String &methodName) {
	uint32 ip = original->getMethodPos(methodName);
	if (ip == 0) {
		return STATUS_FAILED;
	}

	cleanup();

	_thread = true;
	_methodThread = true;
	_threadEvent = new char[methodName.size() + 1];
	if (_threadEvent) {
		strcpy(_threadEvent, methodName.c_str());
	}

	// copy filename
	_filename = new char[strlen(original->_filename) + 1];
	if (_filename) {
		strcpy(_filename, original->_filename);
	}

	// copy buffer
	_buffer = new byte [original->_bufferSize];
	if (!_buffer) {
		return STATUS_FAILED;
	}

	memcpy(_buffer, original->_buffer, original->_bufferSize);
	_bufferSize = original->_bufferSize;

	// initialize
	bool res = initScript();
	if (DID_FAIL(res)) {
		return res;
	}

	// copy globals
	_globals = original->_globals;

	// skip to the beginning of the event
	_iP = ip;

	_timeSlice = original->_timeSlice;
	_freezable = original->_freezable;
	_owner = original->_owner;

	_engine = original->_engine;
	_parentScript = original;

	return STATUS_OK;
}
Exemple #5
0
void exportFlistEntry(LPContext lpContext, LPFlistEntry lpFlistEntry)
{
    HSCRIPT hScript=initScript("Moderate", FALSE);

    addToScript(hScript, "put `join %s/%s`¬"
			 "if waitfor(`R:`, `M:`) == 0¬"
			     "put `fexport %s`¬"
			     "waitfor `R:`¬"
			     "put `quit`¬"
			     "waitfor `M:`¬"
			 "endif¬",
		lpContext->lpcConfName, lpContext->lpcTopicName, lpFlistEntry->flistName);

    actionScript(hScript, OT_PREINCLUDE, "export %s to filepool from %s/%s",
		 lpFlistEntry->flistName, lpContext->lpcConfName, lpContext->lpcTopicName);

}
void FLFormRecordDB::acceptContinue() {
    if ( accepting )
        return ;
    else
        accepting = true;

    if ( !cursor_ ) {
        close();
        return ;
    }

    if ( !validateForm() ) {
        accepting = false;
        return ;
    }

    if ( cursor_->checkIntegrity() ) {
        acceptedForm();
        cursor_->setActivatedCheckIntegrity( false );
        if ( cursor_->commitBuffer() ) {
            cursor_->setActivatedCheckIntegrity( true );
            cursor_->commit();
            cursor_->setModeAccess( FLSqlCursor::INSERT );
            accepted = false;
            QString caption = cursor_->metadata() ->alias() + " [ " + static_cast<FLApplication *>( qApp ) ->lastTextCaption() + " ]";
            cursor_->transaction();
            setCaption( tr( "Insertar " ) + caption );
            if ( initFocusWidget_ )
                initFocusWidget_->setFocus();
            cursor_->refreshBuffer();
            initScript();
        }
    }
    accepting = false;
#ifdef FL_TEST
    static_cast<FLApplication *>( qApp ) ->continueTesting( FLTester::FORM_RECORD_READY, this->name() );
#endif
}
Exemple #7
0
void BladeRunnerEngine::newGame(int difficulty) {
	_settings->reset();
	_combat->reset();

	for (uint i = 0; i < _gameInfo->getActorCount(); ++i) {
		_actors[i]->setup(i);
	}
	_actors[kActorVoiceOver]->setup(99);

	for (uint i = 0; i < _gameInfo->getSuspectCount(); ++i) {
		_suspectsDatabase->get(i)->reset();
	}

	_gameFlags->clear();

	_gameInfo->getGlobalVarCount();

	for (uint i = 0; i < _gameInfo->getGlobalVarCount(); ++i) {
		_gameVars[i] = 0;
	}

	_items->reset();
	_scores->reset();
	_kia->reset();
	_dialogueMenu->clear();
	_scene->_exits->enable();

	if (difficulty >= 0 && difficulty < 3) {
		_settings->setDifficulty(difficulty);
	}

	InitScript initScript(this);
	initScript.SCRIPT_Initialize_Game();
	initChapterAndScene();

	_settings->setStartingGame();
}
Exemple #8
0
Common::Error BladeRunnerEngine::run() {
	Graphics::PixelFormat format = createRGB555();
	initGraphics(640, 480, &format);

	_system->showMouse(true);

	bool hasSavegames = !SaveFileManager::list(_targetName).empty();

	if (!startup(hasSavegames)) {
		shutdown();
		return Common::Error(Common::kUnknownError, "Failed to initialize resources");
	}



#if BLADERUNNER_DEBUG_GAME
	{
#else
	if (warnUserAboutUnsupportedGame()) {
#endif
		if (hasSavegames) {
			_kia->_forceOpen = true;
			_kia->open(kKIASectionLoad);
		}
		// TODO: why is game starting new game here when everything is done in startup?
		//  else {
		// 	newGame(1);
		// }

		gameLoop();

		_mouse->disable();

		if (_gameOver) {
			// autoSaveGame(4, 1); // TODO
			_endCredits->show();
		}
	}

	shutdown();

	return Common::kNoError;
}

bool BladeRunnerEngine::startup(bool hasSavegames) {
	// These are static objects in original game

	_screenEffects = new ScreenEffects(this, 0x8000);

	_endCredits = new EndCredits(this);

	_actorDialogueQueue = new ActorDialogueQueue(this);

	_settings = new Settings(this);

	_itemPickup = new ItemPickup(this);

	_lights = new Lights(this);

	// TODO: outtake player - but this is done bit differently

	_policeMaze = new PoliceMaze(this);

	_obstacles = new Obstacles(this);

	_sceneScript = new SceneScript(this);

	_debugger = new Debugger(this);

	// This is the original startup in the game

	bool r;

	_surfaceFront.create(640, 480, createRGB555());
	_surfaceBack.create(640, 480, createRGB555());
	_surface4.create(640, 480, createRGB555());

	_gameTime = new Time(this);

	r = openArchive("STARTUP.MIX");
	if (!r)
		return false;

	_gameInfo = new GameInfo(this);
	if (!_gameInfo)
		return false;

	r = _gameInfo->open("GAMEINFO.DAT");
	if (!r) {
		return false;
	}


	// TODO: Create datetime - not used

	// TODO: Create graphics surfaces 1-4

	// TODO: Allocate audio cache

	if (hasSavegames) {
		if (!loadSplash()) {
			return false;
		}
	}

	_waypoints = new Waypoints(this, _gameInfo->getWaypointCount());

	_combat = new Combat(this);

	_gameVars = new int[_gameInfo->getGlobalVarCount()]();

	// TODO: Init Actor AI Update counter

	// Seed rand

	// TODO: Sine and cosine lookup tables for intervals of 1.0, 4.0, and 12.0
	_cosTable1024 = new Common::CosineTable(1024); // 10-bits = 1024 points for 2*PI;
	_sinTable1024 = new Common::SineTable(1024);

	_view = new View();

	_sceneObjects = new SceneObjects(this, _view);

	_gameFlags = new GameFlags();
	_gameFlags->setFlagCount(_gameInfo->getFlagCount());

	_items = new Items(this);

	_audioMixer = new AudioMixer(this);

	_audioPlayer = new AudioPlayer(this);

	_music = new Music(this);

	_audioSpeech = new AudioSpeech(this);

	_ambientSounds = new AmbientSounds(this);

	// TODO: Read BLADE.INI

	_chapters = new Chapters(this);
	if (!_chapters)
		return false;

	if (!openArchive("MUSIC.MIX"))
		return false;

	if (!openArchive("SFX.MIX"))
		return false;

	if (!openArchive("SPCHSFX.TLK"))
		return false;

	_overlays = new Overlays(this);
	_overlays->init();

	_zbuffer = new ZBuffer();
	_zbuffer->init(640, 480);

	int actorCount = (int)_gameInfo->getActorCount();
	assert(actorCount < kActorCount);
	for (int i = 0; i != actorCount; ++i) {
		_actors[i] = new Actor(this, i);
		_actors[i]->setup(i);
	}
	_actors[kActorVoiceOver] = new Actor(this, kActorVoiceOver);
	_playerActor = _actors[_gameInfo->getPlayerId()];

	_playerActor->setFPS(15);
	_playerActor->timerStart(6, 200);

	// TODO: Set actor ids (redundant?)

	_policeMaze = new PoliceMaze(this);

	_textActorNames = new TextResource(this);
	if (!_textActorNames->open("ACTORS"))
		return false;

	_textCrimes = new TextResource(this);
	if (!_textCrimes->open("CRIMES"))
		return false;

	_textClueTypes = new TextResource(this);
	if (!_textClueTypes->open("CLUETYPE"))
		return false;

	_textKIA = new TextResource(this);
	if (!_textKIA->open("KIA"))
		return false;

	_textSpinnerDestinations = new TextResource(this);
	if (!_textSpinnerDestinations->open("SPINDEST"))
		return false;

	_textVK = new TextResource(this);
	if (!_textVK->open("VK"))
		return false;

	_textOptions = new TextResource(this);
	if (!_textOptions->open("OPTIONS"))
		return false;

	_dialogueMenu = new DialogueMenu(this);
	if (!_dialogueMenu->loadText("DLGMENU"))
		return false;

	_suspectsDatabase = new SuspectsDatabase(this, _gameInfo->getSuspectCount());

	_kia = new KIA(this);

	_spinner = new Spinner(this);

	_elevator = new Elevator(this);

	_scores = new Scores(this);

	_mainFont = new Font(this);
	_mainFont->open("KIA6PT.FON", 640, 480, -1, 0, 0x252D);
	_mainFont->setSpacing(1, 0);

	for (int i = 0; i != 43; ++i) {
		Shape *shape = new Shape(this);
		shape->open("SHAPES.SHP", i);
		_shapes.push_back(shape);
	}

	_esper = new ESPER(this);

	_vk = new VK(this);

	_mouse = new Mouse(this);
	// _mouse->setCursorPosition(320, 240);
	_mouse->setCursor(0);

	_sliceAnimations = new SliceAnimations(this);
	r = _sliceAnimations->open("INDEX.DAT");
	if (!r)
		return false;

	r = _sliceAnimations->openCoreAnim();
	if (!r) {
		return false;
	}

	_sliceRenderer = new SliceRenderer(this);
	_sliceRenderer->setScreenEffects(_screenEffects);

	_crimesDatabase = new CrimesDatabase(this, "CLUES", _gameInfo->getClueCount());

	// TODO: Scene
	_scene = new Scene(this);

	// Load INIT.DLL
	InitScript initScript(this);
	initScript.SCRIPT_Initialize_Game();

	// TODO: Load AI-ACT1.DLL
	_aiScripts = new AIScripts(this, actorCount);

	initChapterAndScene();

	return true;
}
void SubScriptable::loadScript(VFS::File* filename) {
	freeScript();
	scriptSource = filename->copy();
	initScript();
}