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
This commit is contained in:
parent
7d984d1a67
commit
7731af9833
4 changed files with 62 additions and 60 deletions
|
@ -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;
|
||||
|
||||
_gfx->drawLabel(*label);
|
||||
if (_deletingLabel)
|
||||
return;
|
||||
|
||||
debugC(9, kDebugExec, "jobDisplayLabel (%p)", _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;
|
||||
_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;
|
||||
if (_deletingLabel) {
|
||||
count++;
|
||||
if (count == 2) {
|
||||
count = 0;
|
||||
_engineFlags &= ~kEngineBlockInput;
|
||||
_deletingLabel = false;
|
||||
_label = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Parallaction
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue