Skip to content

Commit

Permalink
Merge pull request chukong#310 from yinjimmy/develop
Browse files Browse the repository at this point in the history
move
  • Loading branch information
dualface committed May 14, 2014
2 parents f16a6e4 + 770e84b commit cc56eee
Show file tree
Hide file tree
Showing 11 changed files with 208 additions and 18 deletions.
12 changes: 6 additions & 6 deletions lib/proj.qt/quick-x-common.pri
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ CC_ROOT=$${ROOT}/lib/cocos2d-x/
DEFINES += COCOS2D_DEBUG=1
DEFINES += DEBUG=1

CONFIG += no_batch
greaterThan(QT_MAJOR_VERSION, 4) {
CONFIG += object_parallel_to_source
} else:equals(PWD, $$OUT_PWD) {
CONFIG += object_with_source
}
#CONFIG += no_batch
#greaterThan(QT_MAJOR_VERSION, 4) {
# CONFIG += object_parallel_to_source
#} else:equals(PWD, $$OUT_PWD) {
# CONFIG += object_with_source
#}

CONFIG(debug, debug|release) {
BUILD_TYPE = debug
Expand Down
File renamed without changes.
Binary file modified player/mac/quick-x-player.app/Contents/MacOS/quick-x-player
Binary file not shown.
82 changes: 82 additions & 0 deletions player/proj.qt/bridge.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@

local simpleList = {
{id="demo1_id", text="<b>One Demo</b> <br/> <img src=:/QuickIcon.png</img>", args=""},
{id="demo2_id", text="<b>Two Demo</b> <br/> <img src=:/QuickIcon.png</img>", args=""},
}

-- string.split()

function lua_string_split(s, p)
local rt= {}
string.gsub(s, '[^'..p..']+', function(w) table.insert(rt, w) end )
return rt
end

-- helper

-- @return -p @packageName -f -r portrait -o @projectPath
function GET_CREATE_PROJECT_COMMAND_ARGS( projectPath, packageName, isPortrait )
local screen = (isPortrait and " -r portrait") or " -r landscape"

local cmd = "-f -p "..packageName..screen.." -o "..projectPath
return cmd, " "
end

function GET_QUICK_SIMPLES()
return json.encode(simpleList)
end

-- core

local core = {}
function core.openDemo( demoId )
QT_INTERFACE("core.openProject")
end

function core.login( data )
user = json.decode(data)
print(user.user..user.pwd)
end

function core.positionNofity(name)
local notificationCenter = CCNotificationCenter:sharedNotificationCenter()
notificationCenter:postNotification(name)
end


-- player : register submodule

local PLAYER = {core=core}

-- interface for player

function LUA_Interface(messageId, messageData)
local messageList = lua_string_split(messageId, ".")
local messageSize = #messageList;

if messageSize == 1 then
PLAYER[messageId](messageData)
else
local object = PLAYER[messageList[1]]
for i=2, messageSize-1 do
object = object[messageList[i]]
i=i+1
end
local functionName = messageList[messageSize]

object[functionName](messageData)
end

end

-- init
function __QT_INIT()
local notificationCenter = CCNotificationCenter:sharedNotificationCenter()
notificationCenter:registerScriptObserver(nil, function() QT_INTERFACE("core.newProject") end, "WELCOME_NEW_PROJECT")
notificationCenter:registerScriptObserver(nil, function() QT_INTERFACE("core.openProject") end, "WELCOME_OPEN_PROJECT")
notificationCenter:registerScriptObserver(nil, function() QT_INTERFACE("core.openDemo") end, "WELCOME_LIST_SAMPLES")
notificationCenter:registerScriptObserver(nil, function() QT_INTERFACE("core.openURL", "http://quick.cocoachina.com/wiki/doku.php?id=zh_cn") end,"WELCOME_OPEN_COMMUNITY")
notificationCenter:registerScriptObserver(nil, function() QT_INTERFACE("core.openURL", "http://quick.cocoachina.com/wiki/doku.php?id=zh_cn") end,"WELCOME_OPEN_DOCUMENTS")
end

__QT_INIT()
1 change: 0 additions & 1 deletion player/proj.qt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,3 @@ int main(int argc, char *argv[])
}
return ret;
}

10 changes: 4 additions & 6 deletions player/proj.qt/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ void Player::initMainMenu()
//
// Preferences
//
QAction *m_preference = moreMenu->addAction(tr("&Preferences"));
playerMenu->addSeparator();
QAction *m_preference = playerMenu->addAction(tr("&Preferences"));
m_preference->setMenuRole(QAction::PreferencesRole);
connect(m_preference, SIGNAL(triggered()), this, SLOT(onShowPreferences()));
}
Expand Down Expand Up @@ -567,11 +568,8 @@ QStringList Player::getCreateProjectCommandArgs(QString projectPath, QString pac

void Player::loadLuaBridgeModule()
{
ProjectConfig welcomeProjectConfig;
welcomeProjectConfig.resetToWelcome();
std::string projectPath = welcomeProjectConfig.getProjectDir();
projectPath = projectPath.append("/scripts/bridge.lua");
cocos2d::CCLuaEngine::defaultEngine()->executeScriptFile(projectPath.data());
QString bridgeFilePath = qApp->applicationDirPath() + "/bridge.lua";
cocos2d::CCLuaEngine::defaultEngine()->executeScriptFile(bridgeFilePath.toUtf8().constData());
}

void Player::initScreenMenu()
Expand Down
2 changes: 1 addition & 1 deletion player/proj.qt/preferenceui.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Choose Quick Root Path</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
Expand Down
Binary file added player/proj.qt/quick-x-icon.ico
Binary file not shown.
37 changes: 33 additions & 4 deletions player/proj.qt/quick-x-player.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ TEMPLATE = app
include(../../lib/proj.qt/quick-x-common.pri)

#CONFIG += warn_off
macx {
ICON = QuickIcon.icns
}
macx:ICON = QuickIcon.icns
win32:RC_ICONS = quick-x-icon.ico

INCLUDEPATH += ../sources .

Expand Down Expand Up @@ -59,10 +58,40 @@ FORMS += \
logindialog.ui \
preferenceui.ui

OTHER_FILES +=


DESTDIR = $${LIB_OUTPUT_DIR}

RESOURCES += \
res.qrc

#
# copy files
#
win32{
COPY = copy /y
}else{
COPY = cp -a
}

IN__PROPERTY_FILE = $$PWD/bridge.lua

win32 {
OUT_PATH = $$DESTDIR
OUT_PATH = $$replace(OUT_PATH, /, \\)
OUT_PROPERTY_FILE = $$OUT_PATH/bridge.lua
!exists($$OUT_PATH):system(md $$OUT_PATH)
}

macx {
OUT_PATH = $${DESTDIR}/quick-x-player.app/Contents/MacOS
OUT_PROPERTY_FILE = $$OUT_PATH/bridge.lua
!exists($$OUT_PATH):system(mkdir -p $$OUT_PATH)
}

win32{
IN__PROPERTY_FILE = $$replace(IN__PROPERTY_FILE, /, \\)
OUT_PROPERTY_FILE = $$replace(OUT_PROPERTY_FILE, /, \\)
}

system($$COPY $$IN__PROPERTY_FILE $$OUT_PROPERTY_FILE)
82 changes: 82 additions & 0 deletions player/win/bridge.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@

local simpleList = {
{id="demo1_id", text="<b>One Demo</b> <br/> <img src=:/QuickIcon.png</img>", args=""},
{id="demo2_id", text="<b>Two Demo</b> <br/> <img src=:/QuickIcon.png</img>", args=""},
}

-- string.split()

function lua_string_split(s, p)
local rt= {}
string.gsub(s, '[^'..p..']+', function(w) table.insert(rt, w) end )
return rt
end

-- helper

-- @return -p @packageName -f -r portrait -o @projectPath
function GET_CREATE_PROJECT_COMMAND_ARGS( projectPath, packageName, isPortrait )
local screen = (isPortrait and " -r portrait") or " -r landscape"

local cmd = "-f -p "..packageName..screen.." -o "..projectPath
return cmd, " "
end

function GET_QUICK_SIMPLES()
return json.encode(simpleList)
end

-- core

local core = {}
function core.openDemo( demoId )
QT_INTERFACE("core.openProject")
end

function core.login( data )
user = json.decode(data)
print(user.user..user.pwd)
end

function core.positionNofity(name)
local notificationCenter = CCNotificationCenter:sharedNotificationCenter()
notificationCenter:postNotification(name)
end


-- player : register submodule

local PLAYER = {core=core}

-- interface for player

function LUA_Interface(messageId, messageData)
local messageList = lua_string_split(messageId, ".")
local messageSize = #messageList;

if messageSize == 1 then
PLAYER[messageId](messageData)
else
local object = PLAYER[messageList[1]]
for i=2, messageSize-1 do
object = object[messageList[i]]
i=i+1
end
local functionName = messageList[messageSize]

object[functionName](messageData)
end

end

-- init
function __QT_INIT()
local notificationCenter = CCNotificationCenter:sharedNotificationCenter()
notificationCenter:registerScriptObserver(nil, function() QT_INTERFACE("core.newProject") end, "WELCOME_NEW_PROJECT")
notificationCenter:registerScriptObserver(nil, function() QT_INTERFACE("core.openProject") end, "WELCOME_OPEN_PROJECT")
notificationCenter:registerScriptObserver(nil, function() QT_INTERFACE("core.openDemo") end, "WELCOME_LIST_SAMPLES")
notificationCenter:registerScriptObserver(nil, function() QT_INTERFACE("core.openURL", "http://quick.cocoachina.com/wiki/doku.php?id=zh_cn") end,"WELCOME_OPEN_COMMUNITY")
notificationCenter:registerScriptObserver(nil, function() QT_INTERFACE("core.openURL", "http://quick.cocoachina.com/wiki/doku.php?id=zh_cn") end,"WELCOME_OPEN_DOCUMENTS")
end

__QT_INIT()
Binary file modified player/win/quick-x-player.exe
Binary file not shown.

0 comments on commit cc56eee

Please sign in to comment.