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) {
|
void Parallaction_ns::jobDisplayLabel(void *parm, Job *j) {
|
||||||
|
|
||||||
Label *label = (Label*)parm;
|
if (!_label)
|
||||||
debugC(9, kDebugExec, "jobDisplayLabel (%p)", (const void*) label);
|
return;
|
||||||
|
|
||||||
_gfx->drawLabel(*label);
|
if (_deletingLabel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
debugC(9, kDebugExec, "jobDisplayLabel (%p)", _label);
|
||||||
|
|
||||||
|
_gfx->drawLabel(*_label);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parallaction_ns::jobEraseLabel(void *parm, Job *j) {
|
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;
|
int16 _si, _di;
|
||||||
|
|
||||||
if (_activeItem._id != 0) {
|
if (_activeItem._id != 0) {
|
||||||
_si = _mousePos.x + 16 - label->_cnv.w/2;
|
_si = _mousePos.x + 16 - _label->_cnv.w/2;
|
||||||
_di = _mousePos.y + 34;
|
_di = _mousePos.y + 34;
|
||||||
} else {
|
} else {
|
||||||
_si = _mousePos.x + 8 - label->_cnv.w/2;
|
_si = _mousePos.x + 8 - _label->_cnv.w/2;
|
||||||
_di = _mousePos.y + 21;
|
_di = _mousePos.y + 21;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_si < 0) _si = 0;
|
if (_si < 0) _si = 0;
|
||||||
if (_di > 190) _di = 190;
|
if (_di > 190) _di = 190;
|
||||||
|
|
||||||
if (label->_cnv.w + _si > _screenWidth)
|
if (_label->_cnv.w + _si > _screenWidth)
|
||||||
_si = _screenWidth - label->_cnv.w;
|
_si = _screenWidth - _label->_cnv.w;
|
||||||
|
|
||||||
Common::Rect r;
|
Common::Rect r;
|
||||||
label->getRect(r, true);
|
_label->getRect(r, true);
|
||||||
_gfx->restoreBackground(r);
|
_gfx->restoreBackground(r);
|
||||||
|
|
||||||
label->_old = label->_pos;
|
_label->_old = _label->_pos;
|
||||||
label->_pos.x = _si;
|
_label->_pos.x = _si;
|
||||||
label->_pos.y = _di;
|
_label->_pos.y = _di;
|
||||||
|
|
||||||
return;
|
if (_deletingLabel) {
|
||||||
}
|
count++;
|
||||||
|
if (count == 2) {
|
||||||
|
count = 0;
|
||||||
|
_engineFlags &= ~kEngineBlockInput;
|
||||||
// this Job uses a static counter to delay removal
|
_deletingLabel = false;
|
||||||
// and is in fact only used to remove jEraseLabel jobs
|
_label = 0;
|
||||||
//
|
}
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace Parallaction
|
} // namespace Parallaction
|
||||||
|
|
|
@ -159,6 +159,8 @@ int Parallaction::init() {
|
||||||
_location._startFrame = 0;
|
_location._startFrame = 0;
|
||||||
_location._comment = NULL;
|
_location._comment = NULL;
|
||||||
_location._endComment = NULL;
|
_location._endComment = NULL;
|
||||||
|
_label = 0;
|
||||||
|
_deletingLabel = false;
|
||||||
|
|
||||||
_backgroundInfo = 0;
|
_backgroundInfo = 0;
|
||||||
_pathBuffer = 0;
|
_pathBuffer = 0;
|
||||||
|
@ -285,8 +287,18 @@ void Parallaction::runGame() {
|
||||||
changeLocation(_location._name);
|
changeLocation(_location._name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jobEraseLabel(0, 0);
|
||||||
|
jobEraseAnimations((void*)1, 0);
|
||||||
|
|
||||||
runJobs();
|
runJobs();
|
||||||
|
|
||||||
|
jobDisplayAnimations(0, 0);
|
||||||
|
jobDisplayLabel(0, 0);
|
||||||
|
|
||||||
|
if (_engineFlags & kEngineInventory) {
|
||||||
|
jobShowInventory(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
updateView();
|
updateView();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -306,25 +318,20 @@ void Parallaction::updateView() {
|
||||||
|
|
||||||
void Parallaction::showLabel(Label &label) {
|
void Parallaction::showLabel(Label &label) {
|
||||||
label.resetPosition();
|
label.resetPosition();
|
||||||
_jDrawLabel = addJob(kJobDisplayLabel, (void*)&label, kPriority0);
|
_label = &label;
|
||||||
_jEraseLabel = addJob(kJobEraseLabel, (void*)&label, kPriority20);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parallaction::hideLabel(uint priority) {
|
void Parallaction::hideLabel(uint priority) {
|
||||||
|
|
||||||
if (!_jDrawLabel)
|
if (!_label)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
removeJob(_jDrawLabel);
|
|
||||||
_jDrawLabel = 0;
|
|
||||||
|
|
||||||
if (priority == kPriority99) {
|
if (priority == kPriority99) {
|
||||||
// remove job immediately
|
_label = 0;
|
||||||
removeJob(_jEraseLabel);
|
|
||||||
_jEraseLabel = 0;
|
|
||||||
} else {
|
} else {
|
||||||
// schedule job for deletion
|
// schedule job for deletion
|
||||||
addJob(kJobWaitRemoveJob, _jEraseLabel, priority);
|
_deletingLabel = true;
|
||||||
|
_engineFlags |= kEngineBlockInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -360,7 +367,7 @@ void Parallaction::processInput(InputData *data) {
|
||||||
setArrowCursor();
|
setArrowCursor();
|
||||||
}
|
}
|
||||||
removeJob(_jRunScripts);
|
removeJob(_jRunScripts);
|
||||||
_jDrawInventory = addJob(kJobShowInventory, 0, kPriority2);
|
// _jDrawInventory = addJob(kJobShowInventory, 0, kPriority2);
|
||||||
openInventory();
|
openInventory();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -369,7 +376,6 @@ void Parallaction::processInput(InputData *data) {
|
||||||
setInventoryCursor(data->_inventoryIndex);
|
setInventoryCursor(data->_inventoryIndex);
|
||||||
_jRunScripts = addJob(kJobRunScripts, 0, kPriority15);
|
_jRunScripts = addJob(kJobRunScripts, 0, kPriority15);
|
||||||
addJob(kJobHideInventory, 0, kPriority20);
|
addJob(kJobHideInventory, 0, kPriority20);
|
||||||
removeJob(_jDrawInventory);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kEvHoverInventory:
|
case kEvHoverInventory:
|
||||||
|
|
|
@ -438,7 +438,8 @@ public:
|
||||||
Table *_callableNames;
|
Table *_callableNames;
|
||||||
Table *_localFlagNames;
|
Table *_localFlagNames;
|
||||||
|
|
||||||
|
bool _deletingLabel;
|
||||||
|
Label *_label;
|
||||||
void showLabel(Label &label);
|
void showLabel(Label &label);
|
||||||
void hideLabel(uint priority);
|
void hideLabel(uint priority);
|
||||||
|
|
||||||
|
@ -487,6 +488,10 @@ public:
|
||||||
|
|
||||||
Common::RandomSource _rnd;
|
Common::RandomSource _rnd;
|
||||||
|
|
||||||
|
virtual void jobShowInventory(void*, Job*) = 0;
|
||||||
|
virtual void jobHideInventory(void*, Job*) = 0;
|
||||||
|
|
||||||
|
|
||||||
protected: // data
|
protected: // data
|
||||||
|
|
||||||
Debugger *_debugger;
|
Debugger *_debugger;
|
||||||
|
@ -587,7 +592,6 @@ public:
|
||||||
virtual void jobWalk(void*, Job *j) = 0;
|
virtual void jobWalk(void*, Job *j) = 0;
|
||||||
virtual void jobDisplayLabel(void *parm, Job *j) = 0;
|
virtual void jobDisplayLabel(void *parm, Job *j) = 0;
|
||||||
virtual void jobEraseLabel(void *parm, Job *j) = 0;
|
virtual void jobEraseLabel(void *parm, Job *j) = 0;
|
||||||
virtual void jobWaitRemoveJob(void *parm, Job *j) = 0;
|
|
||||||
|
|
||||||
void beep();
|
void beep();
|
||||||
|
|
||||||
|
@ -742,7 +746,6 @@ protected:
|
||||||
void jobWalk(void*, Job *j);
|
void jobWalk(void*, Job *j);
|
||||||
void jobDisplayLabel(void *parm, Job *j);
|
void jobDisplayLabel(void *parm, Job *j);
|
||||||
void jobEraseLabel(void *parm, Job *j);
|
void jobEraseLabel(void *parm, Job *j);
|
||||||
void jobWaitRemoveJob(void *parm, Job *j);
|
|
||||||
void jobShowInventory(void *parm, Job *j);
|
void jobShowInventory(void *parm, Job *j);
|
||||||
void jobHideInventory(void *parm, Job *j);
|
void jobHideInventory(void *parm, Job *j);
|
||||||
|
|
||||||
|
|
|
@ -256,9 +256,9 @@ int Parallaction_ns::go() {
|
||||||
|
|
||||||
changeLocation(_location._name);
|
changeLocation(_location._name);
|
||||||
|
|
||||||
addJob(kJobEraseAnimations, (void*)1, kPriority20);
|
// addJob(kJobEraseAnimations, (void*)1, kPriority20);
|
||||||
_jRunScripts = addJob(kJobRunScripts, 0, kPriority15);
|
_jRunScripts = addJob(kJobRunScripts, 0, kPriority15);
|
||||||
addJob(kJobDisplayAnimations, 0, kPriority3);
|
// addJob(kJobDisplayAnimations, 0, kPriority3);
|
||||||
|
|
||||||
runGame();
|
runGame();
|
||||||
|
|
||||||
|
@ -444,17 +444,17 @@ void Parallaction_ns::changeCharacter(const char *name) {
|
||||||
void Parallaction_ns::initJobs() {
|
void Parallaction_ns::initJobs() {
|
||||||
|
|
||||||
static const JobFn jobs[] = {
|
static const JobFn jobs[] = {
|
||||||
&Parallaction_ns::jobDisplayAnimations,
|
0,
|
||||||
&Parallaction_ns::jobEraseAnimations,
|
0,
|
||||||
&Parallaction_ns::jobDisplayDroppedItem,
|
&Parallaction_ns::jobDisplayDroppedItem,
|
||||||
&Parallaction_ns::jobRemovePickedItem,
|
&Parallaction_ns::jobRemovePickedItem,
|
||||||
&Parallaction_ns::jobRunScripts,
|
&Parallaction_ns::jobRunScripts,
|
||||||
&Parallaction_ns::jobWalk,
|
&Parallaction_ns::jobWalk,
|
||||||
&Parallaction_ns::jobDisplayLabel,
|
0,
|
||||||
&Parallaction_ns::jobEraseLabel,
|
0,
|
||||||
&Parallaction_ns::jobWaitRemoveJob,
|
0,
|
||||||
&Parallaction_ns::jobToggleDoor,
|
&Parallaction_ns::jobToggleDoor,
|
||||||
&Parallaction_ns::jobShowInventory,
|
0,
|
||||||
&Parallaction_ns::jobHideInventory
|
&Parallaction_ns::jobHideInventory
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue