Hot fix:Remove the MenuLayerPriorityTest test case of menu

This commit is contained in:
samuele3 2013-11-19 14:32:17 +08:00
parent 594450e3f7
commit eefaf9b81d
3 changed files with 24 additions and 174 deletions

View File

@ -67,22 +67,20 @@ MenuLayerMainMenu::MenuLayerMainMenu()
// Events
MenuItemFont::setFontName("Marker Felt");
auto item6 = MenuItemFont::create("Priority Test", CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackPriorityTest, this));
// Bugs Item
auto item7 = MenuItemFont::create("Bugs", CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackBugsTest, this));
auto item6 = MenuItemFont::create("Bugs", CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackBugsTest, this));
// Font Item
auto item8 = MenuItemFont::create("Quit", CC_CALLBACK_1(MenuLayerMainMenu::onQuit, this));
auto item7= MenuItemFont::create("Quit", CC_CALLBACK_1(MenuLayerMainMenu::onQuit, this));
auto item9 = MenuItemFont::create("Remove menu item when moving", CC_CALLBACK_1(MenuLayerMainMenu::menuMovingCallback, this));
auto item8 = MenuItemFont::create("Remove menu item when moving", CC_CALLBACK_1(MenuLayerMainMenu::menuMovingCallback, this));
auto color_action = TintBy::create(0.5f, 0, -255, -255);
auto color_back = color_action->reverse();
auto seq = Sequence::create(color_action, color_back, NULL);
item8->runAction(RepeatForever::create(seq));
item7->runAction(RepeatForever::create(seq));
auto menu = Menu::create( item1, item2, item3, item4, item5, item6, item7, item8, item9, NULL);
auto menu = Menu::create( item1, item2, item3, item4, item5, item6, item7, item8, NULL);
menu->alignItemsVertically();
@ -172,14 +170,9 @@ void MenuLayerMainMenu::menuCallback2(Object* sender)
static_cast<LayerMultiplex*>(_parent)->switchTo(2);
}
void MenuLayerMainMenu::menuCallbackPriorityTest(Object* sender)
{
static_cast<LayerMultiplex*>(_parent)->switchTo(4);
}
void MenuLayerMainMenu::menuCallbackBugsTest(Object *pSender)
{
static_cast<LayerMultiplex*>(_parent)->switchTo(5);
static_cast<LayerMultiplex*>(_parent)->switchTo(4);
}
void MenuLayerMainMenu::onQuit(Object* sender)
@ -190,7 +183,7 @@ void MenuLayerMainMenu::onQuit(Object* sender)
void MenuLayerMainMenu::menuMovingCallback(Object *pSender)
{
static_cast<LayerMultiplex*>(_parent)->switchTo(6);
static_cast<LayerMultiplex*>(_parent)->switchTo(5);
}
//------------------------------------------------------------------
@ -461,64 +454,6 @@ void MenuLayer4::backCallback(Object* sender)
static_cast<LayerMultiplex*>(_parent)->switchTo(0);
}
MenuLayerPriorityTest::MenuLayerPriorityTest()
{
// Testing empty menu
_menu1 = Menu::create();
_menu2 = Menu::create();
// Menu 1
MenuItemFont::setFontName("Marker Felt");
MenuItemFont::setFontSize(18);
auto item1 = MenuItemFont::create("Return to Main Menu", CC_CALLBACK_1(MenuLayerPriorityTest::menuCallback, this));
auto item2 = MenuItemFont::create("Disable menu for 5 seconds", [&](Object *sender) {
_menu1->setEnabled(false);
auto wait = DelayTime::create(5);
auto enable = CallFunc::create( [&]() {
_menu1->setEnabled(true);
});
auto seq = Sequence::create(wait, enable, NULL);
_menu1->runAction(seq);
});
_menu1->addChild(item1);
_menu1->addChild(item2);
_menu1->alignItemsVerticallyWithPadding(2);
addChild(_menu1);
// Menu 2
_priority = true;
MenuItemFont::setFontSize(48);
item1 = MenuItemFont::create("Toggle priority", [&](Object *sender) {
if( _priority) {
// _menu2->setHandlerPriority(Menu::HANDLER_PRIORITY + 20);
_priority = false;
} else {
// _menu2->setHandlerPriority(Menu::HANDLER_PRIORITY - 20);
_priority = true;
}
});
item1->setColor(Color3B(0,0,255));
_menu2->addChild(item1);
addChild(_menu2);
}
MenuLayerPriorityTest::~MenuLayerPriorityTest()
{
}
void MenuLayerPriorityTest::menuCallback(Object* sender)
{
static_cast<LayerMultiplex*>(_parent)->switchTo(0);
// [[Director sharedDirector] poscene];
}
// BugsTest
BugsTest::BugsTest()
{
@ -621,11 +556,10 @@ void MenuTestScene::runThisTest()
auto layer2 = new MenuLayer2();
auto layer3 = new MenuLayer3();
auto layer4 = new MenuLayer4();
auto layer5 = new MenuLayerPriorityTest();
auto layer6 = new BugsTest();
auto layer7 = new RemoveMenuItemWhenMove();
auto layer5 = new BugsTest();
auto layer6 = new RemoveMenuItemWhenMove();
auto layer = LayerMultiplex::create(layer1, layer2, layer3, layer4, layer5, layer6, layer7, NULL);
auto layer = LayerMultiplex::create(layer1, layer2, layer3, layer4, layer5, layer6, NULL);
addChild(layer, 0);
layer1->release();
@ -634,7 +568,6 @@ void MenuTestScene::runThisTest()
layer4->release();
layer5->release();
layer6->release();
layer7->release();
Director::getInstance()->replaceScene(this);
}

View File

@ -79,19 +79,6 @@ public:
//CREATE_NODE(MenuLayer4);
};
class MenuLayerPriorityTest : public Layer
{
public:
MenuLayerPriorityTest();
~MenuLayerPriorityTest();
void menuCallback(Object* sender);
private:
Menu* _menu1;
Menu* _menu2;
bool _priority;
};
class BugsTest : public Layer
{
public:

View File

@ -98,42 +98,35 @@ local function MenuLayerMainMenu()
-- Testing issue #500
item5:setScale( 0.8 )
local function menuCallbackPriorityTest(pSender)
-- Events
cc.MenuItemFont:setFontName("Marker Felt")
local function menuCallbackBugsTest(pSender)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(4)
end
-- Events
cc.MenuItemFont:setFontName("Marker Felt")
local item6 = cc.MenuItemFont:create("Priority Test")
item6:registerScriptTapHandler(menuCallbackPriorityTest)
local function menuCallbackBugsTest(pSender)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(5)
end
-- Bugs Item
local item7 = cc.MenuItemFont:create("Bugs")
item7:registerScriptTapHandler(menuCallbackBugsTest)
local item6 = cc.MenuItemFont:create("Bugs")
item6:registerScriptTapHandler(menuCallbackBugsTest)
local function onQuit(sender)
cclog("onQuit item is clicked.")
end
-- Font Item
local item8 = cc.MenuItemFont:create("Quit")
item8:registerScriptTapHandler(onQuit)
local item7 = cc.MenuItemFont:create("Quit")
item7:registerScriptTapHandler(onQuit)
local function menuMovingCallback(pSender)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(6)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(5)
end
local item9 = cc.MenuItemFont:create("Remove menu item when moving")
item9:registerScriptTapHandler(menuMovingCallback)
local item8 = cc.MenuItemFont:create("Remove menu item when moving")
item8:registerScriptTapHandler(menuMovingCallback)
local color_action = cc.TintBy:create(0.5, 0, -255, -255)
local color_back = color_action:reverse()
local seq = cc.Sequence:create(color_action, color_back)
item8:runAction(cc.RepeatForever:create(seq))
item7:runAction(cc.RepeatForever:create(seq))
local menu = cc.Menu:create()
@ -145,7 +138,6 @@ local function MenuLayerMainMenu()
menu:addChild(item6)
menu:addChild(item7)
menu:addChild(item8)
menu:addChild(item9)
menu:alignItemsVertically()
@ -481,66 +473,6 @@ local function MenuLayer4()
return ret
end
local function MenuLayerPriorityTest()
local ret = cc.Layer:create()
local m_bPriority = false
-- Testing empty menu
local m_pMenu1 = cc.Menu:create()
local m_pMenu2 = cc.Menu:create()
local function menuCallback(tag, pSender)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0)
end
local function enableMenuCallback()
m_pMenu1:setEnabled(true)
end
local function disableMenuCallback(tag, pSender)
m_pMenu1:setEnabled(false)
local wait = cc.DelayTime:create(5)
local enable = cc.CallFunc:create(enableMenuCallback)
local seq = cc.Sequence:create(wait, enable)
m_pMenu1:runAction(seq)
end
local function togglePriorityCallback(tag, pSender)
if m_bPriority then
m_pMenu2:setHandlerPriority(cc.MENU_HANDLER_PRIORITY + 20)
m_bPriority = false
else
m_pMenu2:setHandlerPriority(cc.MENU_HANDLER_PRIORITY - 20)
m_bPriority = true
end
end
-- Menu 1
cc.MenuItemFont:setFontName("Marker Felt")
cc.MenuItemFont:setFontSize(18)
local item1 = cc.MenuItemFont:create("Return to Main Menu")
item1:registerScriptTapHandler(menuCallback)
local item2 = cc.MenuItemFont:create("Disable menu for 5 seconds")
item2:registerScriptTapHandler(disableMenuCallback)
m_pMenu1:addChild(item1)
m_pMenu1:addChild(item2)
m_pMenu1:alignItemsVerticallyWithPadding(20)
ret:addChild(m_pMenu1)
-- Menu 2
m_bPriority = true
cc.MenuItemFont:setFontSize(48)
item1 = cc.MenuItemFont:create("Toggle priority")
item2:registerScriptTapHandler(togglePriorityCallback)
item1:setColor(cc.c3b(0,0,255))
m_pMenu2:addChild(item1)
ret:addChild(m_pMenu2)
return ret
end
-- BugsTest
local function BugsTest()
local ret = cc.Layer:create()
@ -648,17 +580,15 @@ function MenuTestMain()
local pLayer3 = MenuLayer3()
local pLayer4 = MenuLayer4()
local pLayer5 = MenuLayerPriorityTest()
local pLayer6 = BugsTest()
local pLayer7 = RemoveMenuItemWhenMove()
local pLayer5 = BugsTest()
local pLayer6 = RemoveMenuItemWhenMove()
local layer = cc.LayerMultiplex:create(pLayer1,
pLayer2,
pLayer3,
pLayer4,
pLayer5,
pLayer6,
pLayer7)
pLayer6 )
scene:addChild(layer, 0)
scene:addChild(CreateBackMenuItem())