Merge pull request #6825 from cocoscodeide/v3

[ci skip] update template project lua
This commit is contained in:
minggo 2014-05-20 15:45:03 +08:00
commit 47482f8a3a
3 changed files with 37 additions and 8 deletions

View File

@ -48,14 +48,21 @@ using namespace cocos2d;
std::string g_resourcePath;
static rapidjson::Document g_filecfgjson;
class ConnectWaitLayer;
static ConnectWaitLayer* s_pConnectLayer;
extern string getIPAddress();
const char* getRuntimeVersion()
{
return "1.1";
}
void hideRcvFile() {
s_pConnectLayer = nullptr;
}
void startScript(string strDebugArg)
{
hideRcvFile();
// register lua engine
auto engine = LuaEngine::getInstance();
if (!strDebugArg.empty())
@ -91,6 +98,8 @@ bool reloadScript(const string& modulefile)
class ConnectWaitLayer: public Layer
{
private:
LabelTTF* pLabelUploadFile;
public:
ConnectWaitLayer()
@ -113,8 +122,11 @@ public:
auto labelwait = LabelTTF::create(strShowMsg.c_str(), "Arial", 22);
addChild(labelwait, 10000);
labelwait->setPosition( Point(VisibleRect::center().x, VisibleRect::center().y) );
pLabelUploadFile = LabelTTF::create("", "Arial", 22);
addChild(pLabelUploadFile, 10000);
pLabelUploadFile->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 60) );
auto labelPlay = LabelTTF::create("play", "Arial", 36);
auto menuItem = MenuItemLabel::create(labelPlay, CC_CALLBACK_1(ConnectWaitLayer::playerCallback, this));
auto menu = Menu::create(menuItem, NULL);
@ -129,8 +141,15 @@ public:
startScript("");
}
void showCurRcvFile(string fileName) {
pLabelUploadFile->setString(fileName);
}
};
void showCurRcvFile(string fileName) {
if (NULL == s_pConnectLayer) return;
s_pConnectLayer->showCurRcvFile(fileName);
}
#if defined(_MSC_VER) || defined(__MINGW32__)
#include <io.h>
@ -362,6 +381,7 @@ bool FileServer::receiveFile(int fd)
string file(fullfilename);
file=replaceAll(file,"\\","/");
sprintf(fullfilename, "%s", file.c_str());
showCurRcvFile(filename.c_str());
cocos2d::log("recv fullfilename = %s",fullfilename);
CreateDir(file.substr(0,file.find_last_of("/")).c_str());
FILE *fp =fopen(fullfilename, "wb");
@ -808,11 +828,10 @@ bool startRuntime()
readResFileFinfo();
auto scene = Scene::create();
auto layer = new ConnectWaitLayer();
layer->autorelease();
s_pConnectLayer = new ConnectWaitLayer();
s_pConnectLayer->autorelease();
auto director = Director::getInstance();
scene->addChild(layer);
scene->addChild(s_pConnectLayer);
director->runWithScene(scene);
return true;
}

View File

@ -25,5 +25,14 @@ extern "C"
}
return ConfigParser::getInstance()->isLanscape();
}
bool Java_org_cocos2dx_lua_AppActivity_nativeIsDebug(JNIEnv *env, jobject thisz)
{
#ifdef NDEBUG
return false;
#else
return true;
#endif
}
}

View File

@ -69,8 +69,8 @@ public class AppActivity extends Cocos2dxActivity{
//2.Set the format of window
// Check the wifi is opened when the android:debuggable is "true".
if(0!=((this.getApplicationInfo().flags) & ApplicationInfo.FLAG_DEBUGGABLE))
// Check the wifi is opened when the native is debug.
if(nativeIsDebug())
{
if(!isWifiConnected())
{
@ -123,5 +123,6 @@ public class AppActivity extends Cocos2dxActivity{
}
private static native boolean nativeIsLandScape();
private static native boolean nativeIsDebug();
}