Fixed time machine dialog glitches when the state list is empty.

This commit is contained in:
Stephen Anthony 2018-01-30 19:50:29 -03:30
parent f53e4d01f7
commit 86941ad6af
3 changed files with 7 additions and 6 deletions

View File

@ -78,6 +78,9 @@ class LinkedObjectPool
SLOW, but only required for messages SLOW, but only required for messages
*/ */
uInt32 currentIdx() const { uInt32 currentIdx() const {
if(empty())
return 0;
iter it = myCurrent; iter it = myCurrent;
uInt32 idx = 1; uInt32 idx = 1;

View File

@ -284,7 +284,6 @@ string RewindManager::getUnitString(Int64 cycles)
const Int32 PAL_FREQ = 1182298; // ~76*312*50 const Int32 PAL_FREQ = 1182298; // ~76*312*50
const Int32 freq = isNTSC ? NTSC_FREQ : PAL_FREQ; // = cycles/second const Int32 freq = isNTSC ? NTSC_FREQ : PAL_FREQ; // = cycles/second
// TODO: do we need hours here? don't think so
const Int32 NUM_UNITS = 5; const Int32 NUM_UNITS = 5;
const string UNIT_NAMES[NUM_UNITS] = { "cycle", "scanline", "frame", "second", "minute" }; const string UNIT_NAMES[NUM_UNITS] = { "cycle", "scanline", "frame", "second", "minute" };
const Int64 UNIT_CYCLES[NUM_UNITS + 1] = { 1, 76, 76 * scanlines, freq, freq * 60, Int64(1) << 62 }; const Int64 UNIT_CYCLES[NUM_UNITS + 1] = { 1, 76, 76 * scanlines, freq, freq * 60, Int64(1) << 62 };
@ -298,7 +297,7 @@ string RewindManager::getUnitString(Int64 cycles)
{ {
// use the lower unit up to twice the nextCycles unit, except for an exact match of the nextCycles unit // use the lower unit up to twice the nextCycles unit, except for an exact match of the nextCycles unit
// TODO: does the latter make sense, e.g. for ROMs with changing scanlines? // TODO: does the latter make sense, e.g. for ROMs with changing scanlines?
if(cycles == 0 || cycles < UNIT_CYCLES[i + 1] * 2 && cycles % UNIT_CYCLES[i + 1] != 0) if(cycles == 0 || (cycles < UNIT_CYCLES[i + 1] * 2 && cycles % UNIT_CYCLES[i + 1] != 0))
break; break;
} }
result << cycles / UNIT_CYCLES[i] << " " << UNIT_NAMES[i]; result << cycles / UNIT_CYCLES[i] << " " << UNIT_NAMES[i];
@ -311,8 +310,7 @@ string RewindManager::getUnitString(Int64 cycles)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 RewindManager::getFirstCycles() const uInt32 RewindManager::getFirstCycles() const
{ {
// TODO: check if valid return !myStateList.empty() ? myStateList.first()->cycles : 0;
return Common::LinkedObjectPool<RewindState>::const_iter(myStateList.first())->cycles;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -327,8 +325,7 @@ uInt32 RewindManager::getCurrentCycles() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 RewindManager::getLastCycles() const uInt32 RewindManager::getLastCycles() const
{ {
// TODO: check if valid return !myStateList.empty() ? myStateList.last()->cycles : 0;
return Common::LinkedObjectPool<RewindState>::const_iter(myStateList.last())->cycles;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -395,6 +395,7 @@ void TimeMachineDialog::handleWinds(Int32 numWinds)
myMessageWidget->setLabel((numWinds < 0 ? "(-" : "(+") + message + ")"); myMessageWidget->setLabel((numWinds < 0 ? "(-" : "(+") + message + ")");
} }
} }
// Update time // Update time
myCurrentTimeWidget->setLabel(getTimeString(r.getCurrentCycles() - r.getFirstCycles())); myCurrentTimeWidget->setLabel(getTimeString(r.getCurrentCycles() - r.getFirstCycles()));
myLastTimeWidget->setLabel(getTimeString(r.getLastCycles() - r.getFirstCycles())); myLastTimeWidget->setLabel(getTimeString(r.getLastCycles() - r.getFirstCycles()));