diff options
| author | Nicola Mettifogo | 2007-11-18 21:16:27 +0000 | 
|---|---|---|
| committer | Nicola Mettifogo | 2007-11-18 21:16:27 +0000 | 
| commit | 7731af9833dbc01e5ae66bbce4b3e364e414b99a (patch) | |
| tree | 072ea99cf3af17602d49eb9f3e3f4c750a9d0e19 | |
| parent | 7d984d1a67a43e14e3fc32e9c1bbe91b3157b792 (diff) | |
| download | scummvm-rg350-7731af9833dbc01e5ae66bbce4b3e364e414b99a.tar.gz scummvm-rg350-7731af9833dbc01e5ae66bbce4b3e364e414b99a.tar.bz2 scummvm-rg350-7731af9833dbc01e5ae66bbce4b3e364e414b99a.zip | |
Partly decoupled rendering from game data update. Graphics routines to draw/erase animations and labels are now invoked explicitly instead of being handled in the job list.
svn-id: r29561
| -rw-r--r-- | engines/parallaction/exec_ns.cpp | 69 | ||||
| -rw-r--r-- | engines/parallaction/parallaction.cpp | 30 | ||||
| -rw-r--r-- | engines/parallaction/parallaction.h | 9 | ||||
| -rw-r--r-- | engines/parallaction/parallaction_ns.cpp | 16 | 
4 files changed, 63 insertions, 61 deletions
| diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp index 253025a461..345b5b6668 100644 --- a/engines/parallaction/exec_ns.cpp +++ b/engines/parallaction/exec_ns.cpp @@ -847,71 +847,64 @@ void Parallaction_ns::initOpcodes() {  void Parallaction_ns::jobDisplayLabel(void *parm, Job *j) { -	Label *label = (Label*)parm; -	debugC(9, kDebugExec, "jobDisplayLabel (%p)", (const void*) label); +	if (!_label) +		return; + +	if (_deletingLabel) +		return; + +	debugC(9, kDebugExec, "jobDisplayLabel (%p)", _label); -	_gfx->drawLabel(*label); +	_gfx->drawLabel(*_label);  	return;  }  void Parallaction_ns::jobEraseLabel(void *parm, Job *j) { -	Label *label = (Label*)parm; -	debugC(9, kDebugExec, "jobEraseLabel (%p)", (const void*) label); +	static uint16 count = 0; + +	if (!_label) +		return; + +	debugC(9, kDebugExec, "jobEraseLabel (%p)", _label);  	int16 _si, _di;  	if (_activeItem._id != 0) { -		_si = _mousePos.x + 16 - label->_cnv.w/2; +		_si = _mousePos.x + 16 - _label->_cnv.w/2;  		_di = _mousePos.y + 34;  	} else { -		_si = _mousePos.x + 8 - label->_cnv.w/2; +		_si = _mousePos.x + 8 - _label->_cnv.w/2;  		_di = _mousePos.y + 21;  	}  	if (_si < 0) _si = 0;  	if (_di > 190) _di = 190; -	if (label->_cnv.w + _si > _screenWidth) -		_si = _screenWidth - label->_cnv.w; +	if (_label->_cnv.w + _si > _screenWidth) +		_si = _screenWidth - _label->_cnv.w;  	Common::Rect r; -	label->getRect(r, true); +	_label->getRect(r, true);  	_gfx->restoreBackground(r); -	label->_old = label->_pos; -	label->_pos.x = _si; -	label->_pos.y = _di; - -	return; -} - - - -// this Job uses a static counter to delay removal -// and is in fact only used to remove jEraseLabel jobs -// -void Parallaction_ns::jobWaitRemoveJob(void *parm, Job *j) { -	Job *arg = (Job*)parm; - -	static uint16 count = 0; - -	debugC(9, kDebugExec, "jobWaitRemoveJob: count = %i", count); - -	_engineFlags |= kEngineBlockInput; - -	count++; -	if (count == 2) { -		count = 0; -		removeJob(arg); -		_engineFlags &= ~kEngineBlockInput; -		j->_finished = 1; +	_label->_old = _label->_pos; +	_label->_pos.x = _si; +	_label->_pos.y = _di; + +	if (_deletingLabel) { +		count++; +		if (count == 2) { +			count = 0; +			_engineFlags &= ~kEngineBlockInput; +			_deletingLabel = false; +			_label = 0; +		}  	}  	return;  } -  }	// namespace Parallaction diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index 169d8198ca..e37d31ad6f 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -159,6 +159,8 @@ int Parallaction::init() {  	_location._startFrame = 0;  	_location._comment = NULL;  	_location._endComment = NULL; +	_label = 0; +	_deletingLabel = false;  	_backgroundInfo = 0;  	_pathBuffer = 0; @@ -285,8 +287,18 @@ void Parallaction::runGame() {  			changeLocation(_location._name);  		} +		jobEraseLabel(0, 0); +		jobEraseAnimations((void*)1, 0); +  		runJobs(); +		jobDisplayAnimations(0, 0); +		jobDisplayLabel(0, 0); + +		if (_engineFlags & kEngineInventory) { +			jobShowInventory(0, 0); +		} +  		updateView();  	} @@ -306,25 +318,20 @@ void Parallaction::updateView() {  void Parallaction::showLabel(Label &label) {  	label.resetPosition(); -	_jDrawLabel = addJob(kJobDisplayLabel, (void*)&label, kPriority0); -	_jEraseLabel = addJob(kJobEraseLabel, (void*)&label, kPriority20); +	_label = &label;  }  void Parallaction::hideLabel(uint priority) { -	if (!_jDrawLabel) +	if (!_label)  		return; -	removeJob(_jDrawLabel); -	_jDrawLabel = 0; -  	if (priority == kPriority99) { -		// remove job immediately -		removeJob(_jEraseLabel); -		_jEraseLabel = 0; +		_label = 0;  	} else {  		// schedule job for deletion -		addJob(kJobWaitRemoveJob, _jEraseLabel, priority); +		_deletingLabel = true; +		_engineFlags |= kEngineBlockInput;  	}  } @@ -360,7 +367,7 @@ void Parallaction::processInput(InputData *data) {  			setArrowCursor();  		}  		removeJob(_jRunScripts); -		_jDrawInventory = addJob(kJobShowInventory, 0, kPriority2); +//		_jDrawInventory = addJob(kJobShowInventory, 0, kPriority2);  		openInventory();  		break; @@ -369,7 +376,6 @@ void Parallaction::processInput(InputData *data) {  		setInventoryCursor(data->_inventoryIndex);  		_jRunScripts = addJob(kJobRunScripts, 0, kPriority15);  		addJob(kJobHideInventory, 0, kPriority20); -		removeJob(_jDrawInventory);  		break;  	case kEvHoverInventory: diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index a6eb625128..60889422b6 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -438,7 +438,8 @@ public:  	Table		*_callableNames;  	Table		*_localFlagNames; - +	bool		_deletingLabel; +	Label		*_label;  	void showLabel(Label &label);  	void hideLabel(uint priority); @@ -487,6 +488,10 @@ public:  	Common::RandomSource _rnd; +	virtual void jobShowInventory(void*, Job*) = 0; +	virtual void jobHideInventory(void*, Job*) = 0; + +  protected:		// data  	Debugger	*_debugger; @@ -587,7 +592,6 @@ public:  	virtual void jobWalk(void*, Job *j) = 0;  	virtual void jobDisplayLabel(void *parm, Job *j) = 0;  	virtual void jobEraseLabel(void *parm, Job *j) = 0; -	virtual void jobWaitRemoveJob(void *parm, Job *j) = 0;  	void		beep(); @@ -742,7 +746,6 @@ protected:  	void jobWalk(void*, Job *j);  	void jobDisplayLabel(void *parm, Job *j);  	void jobEraseLabel(void *parm, Job *j); -	void jobWaitRemoveJob(void *parm, Job *j);  	void jobShowInventory(void *parm, Job *j);  	void jobHideInventory(void *parm, Job *j); diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp index 162e9c46c7..e56db61691 100644 --- a/engines/parallaction/parallaction_ns.cpp +++ b/engines/parallaction/parallaction_ns.cpp @@ -256,9 +256,9 @@ int Parallaction_ns::go() {  	changeLocation(_location._name); -	addJob(kJobEraseAnimations, (void*)1, kPriority20); +//	addJob(kJobEraseAnimations, (void*)1, kPriority20);  	_jRunScripts = addJob(kJobRunScripts, 0, kPriority15); -	addJob(kJobDisplayAnimations, 0, kPriority3); +//	addJob(kJobDisplayAnimations, 0, kPriority3);  	runGame(); @@ -444,17 +444,17 @@ void Parallaction_ns::changeCharacter(const char *name) {  void Parallaction_ns::initJobs() {  	static const JobFn jobs[] = { -		&Parallaction_ns::jobDisplayAnimations, -		&Parallaction_ns::jobEraseAnimations, +		0, +		0,  		&Parallaction_ns::jobDisplayDroppedItem,  		&Parallaction_ns::jobRemovePickedItem,  		&Parallaction_ns::jobRunScripts,  		&Parallaction_ns::jobWalk, -		&Parallaction_ns::jobDisplayLabel, -		&Parallaction_ns::jobEraseLabel, -		&Parallaction_ns::jobWaitRemoveJob, +		0, +		0, +		0,  		&Parallaction_ns::jobToggleDoor, -		&Parallaction_ns::jobShowInventory, +		0,  		&Parallaction_ns::jobHideInventory  	}; | 
