mirror of https://github.com/axmolengine/axmol.git
issue #2868:Config cocoStudio GUI lua binding files and add a few script files
This commit is contained in:
parent
5061c7cae4
commit
6a1a774303
|
@ -0,0 +1,266 @@
|
|||
local cocoStudioGuiArray =
|
||||
{
|
||||
{
|
||||
title = "UIButtonTest",
|
||||
func = function ()
|
||||
--return new UIButtonTest()
|
||||
print("come in UIButtonTest")
|
||||
return cc.Scene:create()
|
||||
end
|
||||
},
|
||||
{
|
||||
title = "UIButtonTest_Scale9",
|
||||
func = function ()
|
||||
--return new UIButtonTest_Scale9();
|
||||
end
|
||||
},
|
||||
-- {
|
||||
-- title: "UIButtonTest_PressedAction",
|
||||
-- -- func: function () {
|
||||
-- -- return new UIButtonTest_PressedAction();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UITextButtonTest",
|
||||
-- -- func: function () {
|
||||
-- -- return new UITextButtonTest();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UITextButtonTest_Scale9",
|
||||
-- -- func: function () {
|
||||
-- -- return new UITextButtonTest_Scale9();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UICheckBoxTest",
|
||||
-- -- func: function () {
|
||||
-- -- return new UICheckBoxTest();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UISliderTest",
|
||||
-- -- func: function () {
|
||||
-- -- return new UISliderTest();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UIButtonTest",
|
||||
-- -- func: function () {
|
||||
-- -- return new UISliderTest_Scale9();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UIImageViewTest",
|
||||
-- -- func: function () {
|
||||
-- -- return new UIImageViewTest();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UIImageViewTest_Scale9",
|
||||
-- -- func: function () {
|
||||
-- -- return new UIImageViewTest_Scale9();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UILoadingBarTest_Left",
|
||||
-- -- func: function () {
|
||||
-- -- return new UILoadingBarTest_Left();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UILoadingBarTest_Right",
|
||||
-- -- func: function () {
|
||||
-- -- return new UILoadingBarTest_Right();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UILoadingBarTest_Left_Scale9",
|
||||
-- -- func: function () {
|
||||
-- -- return new UILoadingBarTest_Left_Scale9();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UILoadingBarTest_Right_Scale9",
|
||||
-- -- func: function () {
|
||||
-- -- return new UILoadingBarTest_Right_Scale9();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UILabelAtlasTest",
|
||||
-- -- func: function () {
|
||||
-- -- return new UILabelAtlasTest();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UILabelTest",
|
||||
-- -- func: function () {
|
||||
-- -- return new UILabelTest();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UITextAreaTest",
|
||||
-- -- func: function () {
|
||||
-- -- return new UITextAreaTest();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UILabelBMFontTest",
|
||||
-- -- func: function () {
|
||||
-- -- return new UILabelBMFontTest();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UITextFieldTest",
|
||||
-- -- func: function () {
|
||||
-- -- return new UITextFieldTest();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UITextFieldTest_MaxLength",
|
||||
-- -- func: function () {
|
||||
-- -- return new UITextFieldTest_MaxLength();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UITextFieldTest_Password",
|
||||
-- -- func: function () {
|
||||
-- -- return new UITextFieldTest_Password();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UIPanelTest",
|
||||
-- -- func: function () {
|
||||
-- -- return new UIPanelTest();
|
||||
-- -- }
|
||||
-- },
|
||||
-- { title: "UIPanelTest_Color",
|
||||
-- -- func: function () {
|
||||
-- -- return new UIPanelTest_Color();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UIPanelTest_Gradient",
|
||||
-- -- func: function () {
|
||||
-- -- return new UIPanelTest_Gradient();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UIPanelTest_BackGroundImage",
|
||||
-- -- func: function () {
|
||||
-- -- return new UIPanelTest_BackGroundImage();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UIPanelTest_BackGroundImage_Scale9",
|
||||
-- -- func: function () {
|
||||
-- -- return new UIPanelTest_BackGroundImage_Scale9();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UIPanelTest_Layout_Linear_Vertical",
|
||||
-- -- func: function () {
|
||||
-- -- return new UIPanelTest_Layout_Linear_Vertical();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UIPanelTest_Layout_Linear_Horizontal",
|
||||
-- -- func: function () {
|
||||
-- -- return new UIPanelTest_Layout_Linear_Horizontal();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UIScrollViewTest_Vertical",
|
||||
-- -- func: function () {
|
||||
-- -- return new UIScrollViewTest_Vertical();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UIScrollViewTest_Horizontal",
|
||||
-- -- func: function () {
|
||||
-- -- return new UIScrollViewTest_Horizontal();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UIPageViewTest",
|
||||
-- -- func: function () {
|
||||
-- -- return new UIPageViewTest();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UIListViewTest_Vertical",
|
||||
-- -- func: function () {
|
||||
-- -- return new UIListViewTest_Vertical();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UIListViewTest_Horizontal",
|
||||
-- -- func: function () {
|
||||
-- -- return new UIListViewTest_Horizontal();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UIDragPanelTest",
|
||||
-- -- func: function () {
|
||||
-- -- return new UIDragPanelTest();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UIDragPanelTest_Bounce",
|
||||
-- -- func: function () {
|
||||
-- -- return new UIDragPanelTest_Bounce();
|
||||
-- -- }
|
||||
-- },
|
||||
-- {
|
||||
-- title: "UINodeContainerTest",
|
||||
-- -- func: function () {
|
||||
-- -- return new UINodeContainerTest();
|
||||
-- -- }
|
||||
-- }
|
||||
}
|
||||
|
||||
guiSceneManager = guiSceneManager or {}
|
||||
guiSceneManager.currentUISceneIdx = 1
|
||||
|
||||
function guiSceneManager.nextUIScene()
|
||||
guiSceneManager.currentUISceneIdx = (guiSceneManager.currentUISceneIdx + 1) % table.getn(cocoStudioGuiArray)
|
||||
if 1 == guiSceneManager.currentUISceneIdx then
|
||||
guiSceneManager.currentUISceneIdx = table.getn(cocoStudioGuiArray)
|
||||
end
|
||||
|
||||
return cocoStudioGuiArray[guiSceneManager.currentUISceneIdx].func()
|
||||
end
|
||||
|
||||
function guiSceneManager.previousUIScene()
|
||||
|
||||
guiSceneManager.currentUISceneIdx = guiSceneManager.currentUISceneIdx - 1
|
||||
if guiSceneManager.currentUISceneIdx <= 0 then
|
||||
guiSceneManager.currentUISceneIdx = guiSceneManager.currentUISceneIdx + table.getn(cocoStudioGuiArray)
|
||||
end
|
||||
|
||||
return cocoStudioGuiArray[guiSceneManager.currentUISceneIdx].func()
|
||||
end
|
||||
|
||||
function guiSceneManager.currentUIScene()
|
||||
return cocoStudioGuiArray[guiSceneManager.currentUISceneIdx].func()
|
||||
end
|
||||
|
||||
function guiSceneManager:getInstance()
|
||||
local gsMgr = _G.guiSceneManager
|
||||
if gsMgr then return gsMgr end
|
||||
|
||||
gsMgr = {}
|
||||
_G.guiSceneManager = gsMgr
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
return gsMgr
|
||||
end
|
||||
|
||||
function guiSceneManager:purge()
|
||||
_G.guiSceneManager = nil
|
||||
end
|
||||
|
||||
function runCocosGUITestScene()
|
||||
local scene = guiSceneManager:getInstance().currentUIScene()
|
||||
cc.Director:getInstance():replaceScene(scene)
|
||||
end
|
|
@ -0,0 +1,71 @@
|
|||
UIScene = class("UIScene")
|
||||
UIScene.__index = UIScene
|
||||
UIScene._uiLayer= nil
|
||||
UIScene._widget=nil
|
||||
UIScene._sceneTitle=nil
|
||||
UIScene._topDisplayLabel=nil
|
||||
UIScene._bottomDisplayLabel=nil
|
||||
|
||||
function UIScene.extend(target)
|
||||
local t = tolua.getpeer(target)
|
||||
if not t then
|
||||
t = {}
|
||||
tolua.setpeer(target, t)
|
||||
end
|
||||
setmetatable(t, UIScene)
|
||||
return target
|
||||
end
|
||||
|
||||
function UIScene:init()
|
||||
self._uiLayer = ccs.UILayer:create()
|
||||
self._uiLayer:scheduleUpdate()
|
||||
self:addChild(this._uiLayer)
|
||||
|
||||
self._widget = ccs.UIHelper:getInstance():createWidgetFromJsonFile("res/cocosgui/UITest/UITest.json")
|
||||
self._uiLayer:addWidget(self._widget)
|
||||
|
||||
self._sceneTitle = self._uiLayer:getWidgetByName("UItest")
|
||||
|
||||
local back_label = self._uiLayer:getWidgetByName("back")
|
||||
--back_label:addTouchEventListener(this.toExtensionsMainLayer, this)
|
||||
|
||||
local left_button = self._uiLayer:getWidgetByName("left_Button")
|
||||
--left_button:addTouchEventListener(this.previousCallback ,this)
|
||||
|
||||
local middle_button = self._uiLayer:getWidgetByName("middle_Button")
|
||||
--middle_button.addTouchEventListener(this.restartCallback ,this)
|
||||
|
||||
local right_button = self._uiLayer:getWidgetByName("right_Button")
|
||||
--right_button.addTouchEventListener(this.nextCallback ,this)
|
||||
|
||||
local winSize = cc.Director:getInstance():getWinSize()
|
||||
local scale = winSize.height / 320
|
||||
self._uiLayer:setAnchorPoint(cc.p(0,0))
|
||||
self._uiLayer:setScale(scale)
|
||||
self._uiLayer:setPosition(cc.p((winSize.width - 480 * scale) / 2, (winSize.height - 320 * scale) / 2))
|
||||
|
||||
local widgetSize = self._widget.getRect().size
|
||||
local eventLabel = ccs.UILabel:create()
|
||||
eventLabel:setText("")
|
||||
eventLabel:setFontName("Marker Felt")
|
||||
eventLabel:setFontSize(32)
|
||||
eventLabel:setAnchorPoint(cc.p(0.5, -1))
|
||||
eventLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0))
|
||||
self._uiLayer:addWidget(eventLabel)
|
||||
self._topDisplayLabel = eventLabel
|
||||
|
||||
local uiLabel = ccs.UILabel:create()
|
||||
uiLabel:setText("")
|
||||
uiLabel:setFontName("Marker Felt")
|
||||
uiLabel:setFontSize(30)
|
||||
uiLabel:setColor(cc.c3b(159, 168, 176))
|
||||
uiLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - uiLabel.getRect().size.height * 1.75))
|
||||
self._uiLayer.addWidget(uiLabel)
|
||||
self._bottomDisplayLabel = uiLabel
|
||||
end
|
||||
|
||||
function UIScene.create()
|
||||
local scene = UIScene.extend(cc.Scene:create())
|
||||
scene:init()
|
||||
return scene
|
||||
end
|
|
@ -0,0 +1,113 @@
|
|||
require "luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest"
|
||||
|
||||
local LINE_SPACE = 40
|
||||
local ITEM_TAG_BASIC = 1000
|
||||
|
||||
local cocoStudioTestItemNames =
|
||||
{
|
||||
{
|
||||
itemTitle = "CocoStudioArmatureTest",
|
||||
testScene = function ()
|
||||
--runArmatureTestScene()
|
||||
end
|
||||
},
|
||||
{
|
||||
itemTitle = "CocoStudioGUITest",
|
||||
testScene = function ()
|
||||
runCocosGUITestScene()
|
||||
end
|
||||
},
|
||||
{
|
||||
itemTitle = "CocoStudioComponentsTest",
|
||||
testScene = function ()
|
||||
--runComponentsTestLayer()
|
||||
end
|
||||
},
|
||||
{
|
||||
itemTitle = "CocoStudioSceneTest",
|
||||
testScene = function ()
|
||||
--runSceneEditorTestLayer()
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
local CocoStudioTestScene = class("CocoStudioTestScene")
|
||||
CocoStudioTestScene.__index = CocoStudioTestScene
|
||||
|
||||
function CocoStudioTestScene.extend(target)
|
||||
local t = tolua.getpeer(target)
|
||||
if not t then
|
||||
t = {}
|
||||
tolua.setpeer(target, t)
|
||||
end
|
||||
setmetatable(t, CocoStudioTestScene)
|
||||
return target
|
||||
end
|
||||
|
||||
function CocoStudioTestScene:runThisTest()
|
||||
|
||||
--armatureSceneIdx = ArmatureTestIndex.TEST_COCOSTUDIO_WITH_SKELETON
|
||||
--self:addChild(restartArmatureTest())
|
||||
end
|
||||
|
||||
function CocoStudioTestScene.create()
|
||||
local scene = CocoStudioTestScene.extend(cc.Scene:create())
|
||||
return scene
|
||||
end
|
||||
|
||||
local CocoStudioTestLayer = class("CocoStudioTestLayer")
|
||||
CocoStudioTestLayer.__index = CocoStudioTestLayer
|
||||
|
||||
function CocoStudioTestLayer.extend(target)
|
||||
local t = tolua.getpeer(target)
|
||||
if not t then
|
||||
t = {}
|
||||
tolua.setpeer(target, t)
|
||||
end
|
||||
setmetatable(t, CocoStudioTestLayer)
|
||||
return target
|
||||
end
|
||||
|
||||
function CocoStudioTestLayer.onMenuCallback(tag,sender)
|
||||
local index = sender:getZOrder() - ITEM_TAG_BASIC
|
||||
cocoStudioTestItemNames[index].testScene()
|
||||
end
|
||||
|
||||
function CocoStudioTestLayer:createMenu()
|
||||
|
||||
local winSize = cc.Director:getInstance():getWinSize()
|
||||
|
||||
local menu = cc.Menu:create()
|
||||
menu:setPosition(cc.p(0,0))
|
||||
cc.MenuItemFont:setFontName("Arial")
|
||||
cc.MenuItemFont:setFontSize(24)
|
||||
|
||||
for i = 1, table.getn(cocoStudioTestItemNames) do
|
||||
local menuItem = cc.MenuItemFont:create(cocoStudioTestItemNames[i].itemTitle)
|
||||
menuItem:setPosition(cc.p(winSize.width / 2, winSize.height - (i + 1) * LINE_SPACE))
|
||||
menuItem:registerScriptTapHandler(CocoStudioTestLayer.onMenuCallback)
|
||||
menu:addChild(menuItem, ITEM_TAG_BASIC + i)
|
||||
end
|
||||
|
||||
self:addChild(menu)
|
||||
end
|
||||
|
||||
function CocoStudioTestLayer.create()
|
||||
local layer = CocoStudioTestLayer.extend(cc.Layer:create())
|
||||
|
||||
if nil ~= layer then
|
||||
layer:createMenu()
|
||||
end
|
||||
return layer
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
--CocoStudio Test
|
||||
-------------------------------------
|
||||
function CocoStudioTestMain()
|
||||
local newScene = CocoStudioTestScene.create()
|
||||
newScene:addChild(CreateBackMenuItem())
|
||||
newScene:addChild(CocoStudioTestLayer.create())
|
||||
newScene:runThisTest()
|
||||
return newScene
|
||||
end
|
|
@ -17,6 +17,7 @@ require "luaScript/AssetsManagerTest/AssetsManagerTest"
|
|||
require "luaScript/BugsTest/BugsTest"
|
||||
require "luaScript/ClickAndMoveTest/ClickAndMoveTest"
|
||||
require "luaScript/CocosDenshionTest/CocosDenshionTest"
|
||||
require "luaScript/CocoStudioTest/CocoStudioTest"
|
||||
require "luaScript/CurrentLanguageTest/CurrentLanguageTest"
|
||||
require "luaScript/DrawPrimitivesTest/DrawPrimitivesTest"
|
||||
require "luaScript/EffectsTest/EffectsTest"
|
||||
|
@ -67,6 +68,7 @@ local _allTests = {
|
|||
{ isSupported = false, name = "ChipmunkAccelTouchTest" , create_func= ChipmunkAccelTouchTestMain },
|
||||
{ isSupported = true, name = "ClickAndMoveTest" , create_func = ClickAndMoveTest },
|
||||
{ isSupported = true, name = "CocosDenshionTest" , create_func = CocosDenshionTestMain },
|
||||
{ isSupported = true, name = "CocoStudioTest" , create_func = CocoStudioTestMain },
|
||||
{ isSupported = false, name = "CurlTest" , create_func= CurlTestMain },
|
||||
{ isSupported = true, name = "CurrentLanguageTest" , create_func= CurrentLanguageTestMain },
|
||||
{ isSupported = true, name = "DrawPrimitivesTest" , create_func= DrawPrimitivesTest },
|
||||
|
|
|
@ -23,11 +23,11 @@ cxxgenerator_headers =
|
|||
extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s
|
||||
|
||||
# what headers to parse
|
||||
headers = %(cocosdir)s/cocos/editor-support/cocostudio/CocoStudio.h
|
||||
headers = %(cocosdir)s/cocos/editor-support/cocostudio/CocoStudio.h %(cocosdir)s/cocos/gui/CocosGUI.h
|
||||
|
||||
# what classes to produce code for. You can use regular expressions here. When testing the regular
|
||||
# expression, it will be enclosed in "^$", like this: "^Menu*$".
|
||||
classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$
|
||||
classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$ UIWidget Layout UIRootWidget UIButton UICheckBox UIImageView UILabel UICCLabelAtlas UILabelAtlas UILoadingBar UIScrollView UISlider UICCTextField UITextField UIListView UILabelBMFont UIPageView UIHelper UILayer
|
||||
|
||||
# what should we skip? in the format ClassName::[function function]
|
||||
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
|
||||
|
@ -36,16 +36,18 @@ classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$
|
|||
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
|
||||
# functions from all classes.
|
||||
|
||||
skip = .*Delegate::[*],
|
||||
.*Loader.*::[*],
|
||||
*::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener],
|
||||
skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* (s|g)etBlendFunc add\w*EventListener],
|
||||
ArmatureDataManager::[CCArmatureDataManager ~CCArmatureDataManager],
|
||||
Armature::[createBone updateBlendType getCPBody setCPBody (s|g)etBlendFunc getShapeList ^getBody$],
|
||||
Armature::[createBone updateBlendType getCPBody setCPBody getShapeList ^getBody$],
|
||||
Skin::[(s|g)etSkinData],
|
||||
ArmatureAnimation::[updateHandler updateFrameData frameEvent],
|
||||
Bone::[(s|g)etIgnoreMovementBoneData]
|
||||
Bone::[(s|g)etIgnoreMovementBoneData],
|
||||
UILayer::[getInputManager],
|
||||
UILayoutParameter::[(s|g)etMargin],
|
||||
UIHelper::[init]
|
||||
|
||||
rename_functions = ArmatureDataManager::[sharedArmatureDataManager=getInstance]
|
||||
rename_functions = UIHelper::[instance=getInstance],
|
||||
ArmatureDataManager::[sharedArmatureDataManager=getInstance]
|
||||
|
||||
rename_classes =
|
||||
|
||||
|
|
Loading…
Reference in New Issue