From 54d376db01bc59b1c2770263755c0d5b83024405 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 31 Dec 2014 16:28:14 +0800 Subject: [PATCH] Resolve the bug that requiring lua scrip did not consider the module dependent --- .../script/cocosbuilder/CCBReaderLoad.lua | 4 ++ .../DeprecatedCocosBuilderClass.lua | 3 + .../script/cocosdenshion/AudioEngine.lua | 4 +- .../DeprecatedCocosDenshionClass.lua | 3 + .../DeprecatedCocosDenshionFunc.lua | 3 + .../script/cocostudio/CocoStudio.lua | 5 +- .../cocostudio/DeprecatedCocoStudioClass.lua | 3 + .../cocostudio/DeprecatedCocoStudioFunc.lua | 4 ++ .../script/cocostudio/StudioConstants.lua | 5 +- .../extension/DeprecatedExtensionClass.lua | 56 +++++++++++-------- .../extension/DeprecatedExtensionEnum.lua | 3 + .../extension/DeprecatedExtensionFunc.lua | 4 ++ .../script/extension/ExtensionConstants.lua | 5 +- cocos/scripting/lua-bindings/script/init.lua | 28 +++++++--- .../script/network/DeprecatedNetworkClass.lua | 3 + .../script/network/DeprecatedNetworkEnum.lua | 4 ++ .../script/network/DeprecatedNetworkFunc.lua | 4 ++ .../script/network/NetworkConstants.lua | 5 +- .../script/spine/SpineConstants.lua | 5 +- .../script/ui/DeprecatedUIEnum.lua | 3 + .../script/ui/DeprecatedUIFunc.lua | 4 ++ .../lua-bindings/script/ui/GuiConstants.lua | 5 +- .../script/ui/experimentalUIConstants.lua | 5 +- 23 files changed, 121 insertions(+), 47 deletions(-) diff --git a/cocos/scripting/lua-bindings/script/cocosbuilder/CCBReaderLoad.lua b/cocos/scripting/lua-bindings/script/cocosbuilder/CCBReaderLoad.lua index 141a4e5df5..30ee404a85 100644 --- a/cocos/scripting/lua-bindings/script/cocosbuilder/CCBReaderLoad.lua +++ b/cocos/scripting/lua-bindings/script/cocosbuilder/CCBReaderLoad.lua @@ -1,3 +1,7 @@ +if nil == cc.CCBReader then + return +end + ccb = ccb or {} function CCBReaderLoad(strFilePath,proxy,owner) diff --git a/cocos/scripting/lua-bindings/script/cocosbuilder/DeprecatedCocosBuilderClass.lua b/cocos/scripting/lua-bindings/script/cocosbuilder/DeprecatedCocosBuilderClass.lua index 66f1f5affd..aaa66543b7 100644 --- a/cocos/scripting/lua-bindings/script/cocosbuilder/DeprecatedCocosBuilderClass.lua +++ b/cocos/scripting/lua-bindings/script/cocosbuilder/DeprecatedCocosBuilderClass.lua @@ -1,3 +1,6 @@ +if nil == cc.CCBProxy then + return +end -- This is the DeprecatedCocosBuilderClass DeprecatedCocosBuilderClass = {} or DeprecatedCocosBuilderClass diff --git a/cocos/scripting/lua-bindings/script/cocosdenshion/AudioEngine.lua b/cocos/scripting/lua-bindings/script/cocosdenshion/AudioEngine.lua index 7a6f78967e..deea904a44 100644 --- a/cocos/scripting/lua-bindings/script/cocosdenshion/AudioEngine.lua +++ b/cocos/scripting/lua-bindings/script/cocosdenshion/AudioEngine.lua @@ -1,4 +1,6 @@ - +if nil == cc.SimpleAudioEngine then + return +end --Encapsulate SimpleAudioEngine to AudioEngine,Play music and sound effects. local M = {} diff --git a/cocos/scripting/lua-bindings/script/cocosdenshion/DeprecatedCocosDenshionClass.lua b/cocos/scripting/lua-bindings/script/cocosdenshion/DeprecatedCocosDenshionClass.lua index 49e3cc3c3d..64f23f6f57 100644 --- a/cocos/scripting/lua-bindings/script/cocosdenshion/DeprecatedCocosDenshionClass.lua +++ b/cocos/scripting/lua-bindings/script/cocosdenshion/DeprecatedCocosDenshionClass.lua @@ -1,3 +1,6 @@ +if nil == cc.SimpleAudioEngine then + return +end -- This is the DeprecatedCocosDenshionClass DeprecatedCocosDenshionClass = {} or DeprecatedCocosDenshionClass diff --git a/cocos/scripting/lua-bindings/script/cocosdenshion/DeprecatedCocosDenshionFunc.lua b/cocos/scripting/lua-bindings/script/cocosdenshion/DeprecatedCocosDenshionFunc.lua index 932962e505..9588a1f362 100644 --- a/cocos/scripting/lua-bindings/script/cocosdenshion/DeprecatedCocosDenshionFunc.lua +++ b/cocos/scripting/lua-bindings/script/cocosdenshion/DeprecatedCocosDenshionFunc.lua @@ -1,3 +1,6 @@ +if nil == cc.SimpleAudioEngine then + return +end --tip local function deprecatedTip(old_name,new_name) print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********") diff --git a/cocos/scripting/lua-bindings/script/cocostudio/CocoStudio.lua b/cocos/scripting/lua-bindings/script/cocostudio/CocoStudio.lua index e24251a7cf..a9d6a44d58 100644 --- a/cocos/scripting/lua-bindings/script/cocostudio/CocoStudio.lua +++ b/cocos/scripting/lua-bindings/script/cocostudio/CocoStudio.lua @@ -1,10 +1,11 @@ +if nil == ccs then + return +end if not json then require "cocos.cocos2d.json" end -ccs = ccs or {} - require "cocos.cocostudio.StudioConstants" function ccs.sendTriggerEvent(event) diff --git a/cocos/scripting/lua-bindings/script/cocostudio/DeprecatedCocoStudioClass.lua b/cocos/scripting/lua-bindings/script/cocostudio/DeprecatedCocoStudioClass.lua index 6dba789064..712886b6e0 100644 --- a/cocos/scripting/lua-bindings/script/cocostudio/DeprecatedCocoStudioClass.lua +++ b/cocos/scripting/lua-bindings/script/cocostudio/DeprecatedCocoStudioClass.lua @@ -1,3 +1,6 @@ +if nil == ccs then + return +end -- This is the DeprecatedExtensionClass DeprecatedExtensionClass = {} or DeprecatedExtensionClass diff --git a/cocos/scripting/lua-bindings/script/cocostudio/DeprecatedCocoStudioFunc.lua b/cocos/scripting/lua-bindings/script/cocostudio/DeprecatedCocoStudioFunc.lua index 0c8952690f..f8e867deac 100644 --- a/cocos/scripting/lua-bindings/script/cocostudio/DeprecatedCocoStudioFunc.lua +++ b/cocos/scripting/lua-bindings/script/cocostudio/DeprecatedCocoStudioFunc.lua @@ -1,3 +1,7 @@ +if nil == ccs then + return +end + --tip local function deprecatedTip(old_name,new_name) print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********") diff --git a/cocos/scripting/lua-bindings/script/cocostudio/StudioConstants.lua b/cocos/scripting/lua-bindings/script/cocostudio/StudioConstants.lua index 0fc8fc7711..8c78ca2f71 100644 --- a/cocos/scripting/lua-bindings/script/cocostudio/StudioConstants.lua +++ b/cocos/scripting/lua-bindings/script/cocostudio/StudioConstants.lua @@ -1,5 +1,6 @@ - -ccs = ccs or {} +if nil == ccs then + return +end ccs.MovementEventType = { start = 0, diff --git a/cocos/scripting/lua-bindings/script/extension/DeprecatedExtensionClass.lua b/cocos/scripting/lua-bindings/script/extension/DeprecatedExtensionClass.lua index 62093cafbc..a5a593063a 100644 --- a/cocos/scripting/lua-bindings/script/extension/DeprecatedExtensionClass.lua +++ b/cocos/scripting/lua-bindings/script/extension/DeprecatedExtensionClass.lua @@ -1,5 +1,8 @@ --- This is the DeprecatedExtensionClass +if nil == cc.Control then + return +end +-- This is the DeprecatedExtensionClass DeprecatedExtensionClass = {} or DeprecatedExtensionClass --tip @@ -15,21 +18,6 @@ end _G["CCControl"] = DeprecatedExtensionClass.CCControl() --CCControl class will be Deprecated,end ---CCEditBox class will be Deprecated,begin -function DeprecatedExtensionClass.CCEditBox() - deprecatedTip("CCEditBox","ccui.EditBox") - return ccui.EditBox -end -_G["CCEditBox"] = DeprecatedExtensionClass.CCEditBox() - -function DeprecatedExtensionClass.CCUIEditBox() - deprecatedTip("cc.EditBox","ccui.EditBox") - return ccui.EditBox -end -_G["cc"]["EditBox"] = DeprecatedExtensionClass.CCUIEditBox() - ---CCEditBox class will be Deprecated,end - --CCScrollView class will be Deprecated,begin function DeprecatedExtensionClass.CCScrollView() deprecatedTip("CCScrollView","cc.ScrollView") @@ -102,6 +90,34 @@ end _G["CCControlButton"] = DeprecatedExtensionClass.CCControlButton() --CCControlButton class will be Deprecated,end +--CCControlColourPicker class will be Deprecated,begin +function DeprecatedExtensionClass.CCControlColourPicker() + deprecatedTip("CCControlColourPicker","cc.ControlColourPicker") + return cc.ControlColourPicker +end +_G["CCControlColourPicker"] = DeprecatedExtensionClass.CCControlColourPicker() +--CCControlColourPicker class will be Deprecated,end + + +if nil == ccui then + return +end + +--CCEditBox class will be Deprecated,begin +function DeprecatedExtensionClass.CCEditBox() + deprecatedTip("CCEditBox","ccui.EditBox") + return ccui.EditBox +end +_G["CCEditBox"] = DeprecatedExtensionClass.CCEditBox() + +function DeprecatedExtensionClass.CCUIEditBox() + deprecatedTip("cc.EditBox","ccui.EditBox") + return ccui.EditBox +end +_G["cc"]["EditBox"] = DeprecatedExtensionClass.CCUIEditBox() + +--CCEditBox class will be Deprecated,end + --CCScale9Sprite class will be Deprecated,begin function DeprecatedExtensionClass.CCScale9Sprite() deprecatedTip("CCScale9Sprite","ccui.Scale9Sprite") @@ -116,11 +132,3 @@ end _G["cc"]["Scale9Sprite"] = DeprecatedExtensionClass.UIScale9Sprite() --CCScale9Sprite class will be Deprecated,end ---CCControlColourPicker class will be Deprecated,begin -function DeprecatedExtensionClass.CCControlColourPicker() - deprecatedTip("CCControlColourPicker","cc.ControlColourPicker") - return cc.ControlColourPicker -end -_G["CCControlColourPicker"] = DeprecatedExtensionClass.CCControlColourPicker() ---CCControlColourPicker class will be Deprecated,end - diff --git a/cocos/scripting/lua-bindings/script/extension/DeprecatedExtensionEnum.lua b/cocos/scripting/lua-bindings/script/extension/DeprecatedExtensionEnum.lua index aad58e5753..9483df0973 100644 --- a/cocos/scripting/lua-bindings/script/extension/DeprecatedExtensionEnum.lua +++ b/cocos/scripting/lua-bindings/script/extension/DeprecatedExtensionEnum.lua @@ -1,3 +1,6 @@ +if nil == cc.Control then + return +end _G.kCCControlStepperPartMinus = cc.CONTROL_STEPPER_PART_MINUS _G.kCCControlStepperPartPlus = cc.CONTROL_STEPPER_PART_PLUS diff --git a/cocos/scripting/lua-bindings/script/extension/DeprecatedExtensionFunc.lua b/cocos/scripting/lua-bindings/script/extension/DeprecatedExtensionFunc.lua index 282c0118b5..2b617fc435 100644 --- a/cocos/scripting/lua-bindings/script/extension/DeprecatedExtensionFunc.lua +++ b/cocos/scripting/lua-bindings/script/extension/DeprecatedExtensionFunc.lua @@ -1,3 +1,7 @@ +if nil == cc.Control then + return +end + --tip local function deprecatedTip(old_name,new_name) print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********") diff --git a/cocos/scripting/lua-bindings/script/extension/ExtensionConstants.lua b/cocos/scripting/lua-bindings/script/extension/ExtensionConstants.lua index 4bd74ba274..0bfc8f80f0 100644 --- a/cocos/scripting/lua-bindings/script/extension/ExtensionConstants.lua +++ b/cocos/scripting/lua-bindings/script/extension/ExtensionConstants.lua @@ -1,5 +1,6 @@ - -cc = cc or {} +if nil == cc.Control then + return +end cc.CONTROL_STATE_NORMAL = 1 cc.CONTROL_STATE_HIGH_LIGHTED = 2 diff --git a/cocos/scripting/lua-bindings/script/init.lua b/cocos/scripting/lua-bindings/script/init.lua index c07240c5ca..b03a3350eb 100644 --- a/cocos/scripting/lua-bindings/script/init.lua +++ b/cocos/scripting/lua-bindings/script/init.lua @@ -35,16 +35,23 @@ else -- audio require "cocos.cocosdenshion.AudioEngine" -- cocosstudio - require "cocos.cocostudio.CocoStudio" + if nil ~= ccs then + require "cocos.cocostudio.CocoStudio" + end -- ui - require "cocos.ui.GuiConstants" - require "cocos.ui.experimentalUIConstants" + if nil ~= ccui then + require "cocos.ui.GuiConstants" + require "cocos.ui.experimentalUIConstants" + end + -- extensions require "cocos.extension.ExtensionConstants" -- network require "cocos.network.NetworkConstants" -- Spine - require "cocos.spine.SpineConstants" + if nil ~= sp then + require "cocos.spine.SpineConstants" + end require "cocos.cocos2d.deprecated" require "cocos.cocos2d.DrawPrimitives" @@ -59,8 +66,11 @@ else require "cocos.cocos2d.DeprecatedOpenglEnum" -- register_cocostudio_module - require "cocos.cocostudio.DeprecatedCocoStudioClass" - require "cocos.cocostudio.DeprecatedCocoStudioFunc" + if nil ~= ccs then + require "cocos.cocostudio.DeprecatedCocoStudioClass" + require "cocos.cocostudio.DeprecatedCocoStudioFunc" + end + -- register_cocosbuilder_module require "cocos.cocosbuilder.DeprecatedCocosBuilderClass" @@ -80,8 +90,10 @@ else require "cocos.network.DeprecatedNetworkFunc" -- register_ui_moudle - require "cocos.ui.DeprecatedUIEnum" - require "cocos.ui.DeprecatedUIFunc" + if nil ~= ccui then + require "cocos.ui.DeprecatedUIEnum" + require "cocos.ui.DeprecatedUIFunc" + end -- cocosbuilder require "cocos.cocosbuilder.CCBReaderLoad" diff --git a/cocos/scripting/lua-bindings/script/network/DeprecatedNetworkClass.lua b/cocos/scripting/lua-bindings/script/network/DeprecatedNetworkClass.lua index f465dc7bbd..06e280bd21 100644 --- a/cocos/scripting/lua-bindings/script/network/DeprecatedNetworkClass.lua +++ b/cocos/scripting/lua-bindings/script/network/DeprecatedNetworkClass.lua @@ -1,3 +1,6 @@ +if nil == cc.XMLHttpRequest then + return +end -- This is the DeprecatedNetworkClass DeprecatedNetworkClass = {} or DeprecatedNetworkClass diff --git a/cocos/scripting/lua-bindings/script/network/DeprecatedNetworkEnum.lua b/cocos/scripting/lua-bindings/script/network/DeprecatedNetworkEnum.lua index da9051cd3e..da08d356f8 100644 --- a/cocos/scripting/lua-bindings/script/network/DeprecatedNetworkEnum.lua +++ b/cocos/scripting/lua-bindings/script/network/DeprecatedNetworkEnum.lua @@ -1,3 +1,7 @@ +if nil == cc.XMLHttpRequest then + return +end + _G.kWebSocketScriptHandlerOpen = cc.WEBSOCKET_OPEN _G.kWebSocketScriptHandlerMessage = cc.WEBSOCKET_MESSAGE _G.kWebSocketScriptHandlerClose = cc.WEBSOCKET_CLOSE diff --git a/cocos/scripting/lua-bindings/script/network/DeprecatedNetworkFunc.lua b/cocos/scripting/lua-bindings/script/network/DeprecatedNetworkFunc.lua index 6ea3cfac9b..f1143926fc 100644 --- a/cocos/scripting/lua-bindings/script/network/DeprecatedNetworkFunc.lua +++ b/cocos/scripting/lua-bindings/script/network/DeprecatedNetworkFunc.lua @@ -1,3 +1,7 @@ +if nil == cc.XMLHttpRequest then + return +end + --tip local function deprecatedTip(old_name,new_name) print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********") diff --git a/cocos/scripting/lua-bindings/script/network/NetworkConstants.lua b/cocos/scripting/lua-bindings/script/network/NetworkConstants.lua index 2311657a1a..ee18d55dda 100644 --- a/cocos/scripting/lua-bindings/script/network/NetworkConstants.lua +++ b/cocos/scripting/lua-bindings/script/network/NetworkConstants.lua @@ -1,5 +1,6 @@ - -cc = cc or {} +if nil == cc.XMLHttpRequest then + return +end cc.WEBSOCKET_OPEN = 0 cc.WEBSOCKET_MESSAGE = 1 diff --git a/cocos/scripting/lua-bindings/script/spine/SpineConstants.lua b/cocos/scripting/lua-bindings/script/spine/SpineConstants.lua index 470bf6a712..a7d7dfa085 100644 --- a/cocos/scripting/lua-bindings/script/spine/SpineConstants.lua +++ b/cocos/scripting/lua-bindings/script/spine/SpineConstants.lua @@ -1,5 +1,6 @@ - -sp = sp or {} +if nil == sp then + return +end sp.EventType = { diff --git a/cocos/scripting/lua-bindings/script/ui/DeprecatedUIEnum.lua b/cocos/scripting/lua-bindings/script/ui/DeprecatedUIEnum.lua index 1fd5b4fe5c..ae7d63f964 100644 --- a/cocos/scripting/lua-bindings/script/ui/DeprecatedUIEnum.lua +++ b/cocos/scripting/lua-bindings/script/ui/DeprecatedUIEnum.lua @@ -1,3 +1,6 @@ +if nil == ccui then + return +end LAYOUT_COLOR_NONE = ccui.LayoutBackGroundColorType.none LAYOUT_COLOR_SOLID = ccui.LayoutBackGroundColorType.solid diff --git a/cocos/scripting/lua-bindings/script/ui/DeprecatedUIFunc.lua b/cocos/scripting/lua-bindings/script/ui/DeprecatedUIFunc.lua index 8427740119..52c5e2e851 100644 --- a/cocos/scripting/lua-bindings/script/ui/DeprecatedUIFunc.lua +++ b/cocos/scripting/lua-bindings/script/ui/DeprecatedUIFunc.lua @@ -1,3 +1,7 @@ +if nil == ccui then + return +end + --tip local function deprecatedTip(old_name,new_name) print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********") diff --git a/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua b/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua index 1ebcaac88d..0c700c5494 100644 --- a/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua +++ b/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua @@ -1,5 +1,6 @@ - -ccui = ccui or {} +if nil == ccui then + return +end ccui.BrightStyle = { diff --git a/cocos/scripting/lua-bindings/script/ui/experimentalUIConstants.lua b/cocos/scripting/lua-bindings/script/ui/experimentalUIConstants.lua index 63a65648ea..b2bcc05bf1 100644 --- a/cocos/scripting/lua-bindings/script/ui/experimentalUIConstants.lua +++ b/cocos/scripting/lua-bindings/script/ui/experimentalUIConstants.lua @@ -1,5 +1,6 @@ -ccexp = ccexp or {} - +if nil == ccexp then + return +end ccexp.VideoPlayerEvent = { PLAYING = 0,