2013-12-08 22:44:43 +01:00
|
|
|
/*
|
|
|
|
* Author: Harry van Haaren 2013
|
|
|
|
* harryhaaren@gmail.com
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2013-09-06 01:28:11 +02:00
|
|
|
|
|
|
|
#include "stately.hxx"
|
|
|
|
|
|
|
|
#include "../jack.hxx"
|
2013-11-14 17:36:18 +01:00
|
|
|
#include "../eventhandler.hxx"
|
2013-09-06 01:28:11 +02:00
|
|
|
#include "state.hxx"
|
|
|
|
|
|
|
|
extern Jack* jack;
|
|
|
|
|
2013-11-14 14:29:22 +01:00
|
|
|
int Stately::saveSuccess = 0;
|
|
|
|
int Stately::saveErrors = 0;
|
2013-09-06 01:28:11 +02:00
|
|
|
|
|
|
|
Stately::Stately()
|
|
|
|
{
|
|
|
|
jack->getState()->registerStately( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Stately::reset()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Stately::save()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-11-14 14:29:22 +01:00
|
|
|
void Stately::checkCompletedSave()
|
2013-09-06 01:28:11 +02:00
|
|
|
{
|
2013-11-14 14:29:22 +01:00
|
|
|
if ( (saveSuccess + saveErrors) >= jack->getState()->getNumStatelys() )
|
2013-09-06 01:28:11 +02:00
|
|
|
{
|
|
|
|
jack->getState()->finish();
|
2013-11-14 14:29:22 +01:00
|
|
|
|
2013-11-14 17:36:18 +01:00
|
|
|
if ( saveErrors )
|
|
|
|
{
|
|
|
|
// send message to UI to be printed, noting # of clips unsaved due to errors
|
|
|
|
char buf[50];
|
|
|
|
sprintf( buf, "Saved with %i clips !saved due to errors", saveErrors);
|
|
|
|
EventGuiPrint e( buf );
|
|
|
|
writeToGuiRingbuffer( &e );
|
|
|
|
}
|
|
|
|
|
2013-11-14 14:29:22 +01:00
|
|
|
// reset in case of another save before quit
|
|
|
|
saveErrors = 0;
|
|
|
|
saveSuccess = 0;
|
2013-09-06 01:28:11 +02:00
|
|
|
}
|
|
|
|
}
|
2013-11-13 13:03:24 +01:00
|
|
|
|
2013-11-14 14:29:22 +01:00
|
|
|
void Stately::success()
|
|
|
|
{
|
|
|
|
saveSuccess++;
|
|
|
|
checkCompletedSave();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Stately::error(const char* errorString)
|
2013-11-13 13:03:24 +01:00
|
|
|
{
|
|
|
|
// CRITICAL FIXME: add error handling code, noting an error occured, perhaps prompt user?
|
2013-11-14 14:29:22 +01:00
|
|
|
saveErrors++;
|
|
|
|
checkCompletedSave();
|
2013-11-13 13:03:24 +01:00
|
|
|
}
|