2012-04-16 18:58:43 +08:00
|
|
|
/*
|
2013-06-20 14:17:10 +08:00
|
|
|
* ControlSceneManager.m
|
2012-04-16 18:58:43 +08:00
|
|
|
*
|
|
|
|
* Copyright (c) 2011 Yannick Loriot
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "CCControlSceneManager.h"
|
|
|
|
#include "CCControlScene.h"
|
2012-04-16 23:16:03 +08:00
|
|
|
#include "CCControlButtonTest/CCControlButtonTest.h"
|
2012-04-17 11:12:05 +08:00
|
|
|
#include "CCControlColourPicker/CCControlColourPickerTest.h"
|
2012-04-17 16:00:18 +08:00
|
|
|
#include "CCControlSliderTest/CCControlSliderTest.h"
|
|
|
|
#include "CCControlSwitchTest/CCControlSwitchTest.h"
|
2012-09-25 16:57:51 +08:00
|
|
|
#include "CCControlPotentiometerTest/CCControlPotentiometerTest.h"
|
|
|
|
#include "CCControlStepperTest/CCControlStepperTest.h"
|
2012-04-16 18:58:43 +08:00
|
|
|
|
|
|
|
USING_NS_CC;
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
kControlSliderTest = 0,
|
|
|
|
kControlColourPickerTest,
|
|
|
|
kControlSwitchTest,
|
|
|
|
kControlButtonTest_HelloVariableSize,
|
|
|
|
kControlButtonTest_Event,
|
|
|
|
kControlButtonTest_Styling,
|
|
|
|
kControlPotentiometerTest,
|
|
|
|
kControlStepperTest,
|
|
|
|
kControlTestMax
|
2012-04-16 18:58:43 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static const char* s_testArray[] = {
|
|
|
|
"CCControlSliderTest",
|
|
|
|
"ControlColourPickerTest",
|
|
|
|
"ControlSwitchTest",
|
|
|
|
"ControlButtonTest_HelloVariableSize",
|
|
|
|
"ControlButtonTest_Event",
|
2012-09-25 16:57:51 +08:00
|
|
|
"ControlButtonTest_Styling",
|
|
|
|
"ControlPotentiometerTest",
|
|
|
|
"CCControlStepperTest"
|
2012-04-16 18:58:43 +08:00
|
|
|
};
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
static ControlSceneManager *sharedInstance = NULL;
|
2012-04-16 18:58:43 +08:00
|
|
|
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ControlSceneManager::ControlSceneManager()
|
2012-04-16 18:58:43 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
_currentControlSceneId = kControlSliderTest;
|
2012-04-16 18:58:43 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ControlSceneManager::~ControlSceneManager()
|
2012-04-16 18:58:43 +08:00
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE(sharedInstance);
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ControlSceneManager * ControlSceneManager::sharedControlSceneManager()
|
2012-04-16 18:58:43 +08:00
|
|
|
{
|
|
|
|
if (sharedInstance == NULL)
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
sharedInstance = new ControlSceneManager();
|
2012-04-16 18:58:43 +08:00
|
|
|
}
|
|
|
|
return sharedInstance;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene *ControlSceneManager::nextControlScene()
|
2012-04-16 18:58:43 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
_currentControlSceneId = (_currentControlSceneId + 1) % kControlTestMax;
|
2012-04-16 18:58:43 +08:00
|
|
|
|
|
|
|
return currentControlScene();
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene *ControlSceneManager::previousControlScene()
|
2012-04-16 18:58:43 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_currentControlSceneId = _currentControlSceneId - 1;
|
|
|
|
if (_currentControlSceneId < 0)
|
2012-04-16 18:58:43 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
_currentControlSceneId = kControlTestMax - 1;
|
2012-04-16 18:58:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return currentControlScene();
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene *ControlSceneManager::currentControlScene()
|
2012-04-16 18:58:43 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
switch (_currentControlSceneId)
|
2012-04-16 18:58:43 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
case kControlSliderTest: return ControlSliderTest::sceneWithTitle(s_testArray[_currentControlSceneId]);
|
|
|
|
case kControlColourPickerTest:return ControlColourPickerTest::sceneWithTitle(s_testArray[_currentControlSceneId]);
|
|
|
|
case kControlSwitchTest:return ControlSwitchTest::sceneWithTitle(s_testArray[_currentControlSceneId]);
|
|
|
|
case kControlButtonTest_HelloVariableSize:return ControlButtonTest_HelloVariableSize::sceneWithTitle(s_testArray[_currentControlSceneId]);
|
|
|
|
case kControlButtonTest_Event:return ControlButtonTest_Event::sceneWithTitle(s_testArray[_currentControlSceneId]);
|
|
|
|
case kControlButtonTest_Styling:return ControlButtonTest_Styling::sceneWithTitle(s_testArray[_currentControlSceneId]);
|
|
|
|
case kControlPotentiometerTest:return ControlPotentiometerTest::sceneWithTitle(s_testArray[_currentControlSceneId]);
|
|
|
|
case kControlStepperTest:return ControlStepperTest::sceneWithTitle(s_testArray[_currentControlSceneId]);
|
2012-04-16 18:58:43 +08:00
|
|
|
}
|
2012-04-17 16:00:18 +08:00
|
|
|
return NULL;
|
2012-04-16 18:58:43 +08:00
|
|
|
}
|