Misc Fixes

==========

-NOTIFICATION_WM_QUIT fixed on android (seems tha way this is reported changed in newer sdk)
-WIP implementation of APK Expansion APIs for publishing games larger than 50mb in Play Store
-Feaures in the new tutorials are all present in the sourcecode
-This (hopefully) should get rid of the animation list order getting corrupted
-Improved 3D Scene Importer (Skeletons, Animations and other stuff were not being merged). Anything missing?
-In code editor, the automatic syntax checker will only use file_exists() to check preload() else it might freeze the editor too much while typing if the preload is a big resource
-Fixed bugs in PolygonPathFinder, stil pending to do a node and a demo
This commit is contained in:
Juan Linietsky 2014-06-27 23:21:45 -03:00
parent 1cc96a4d74
commit 2af2a84a03
74 changed files with 1416 additions and 662 deletions

View file

@ -258,7 +258,11 @@ bool EditorExportPlatformAndroid::_set(const StringName& p_name, const Variant&
String n=p_name;
if (n=="version/code")
if (n=="custom_package/debug")
custom_debug_package=p_value;
else if (n=="custom_package/release")
custom_release_package=p_value;
else if (n=="version/code")
version_code=p_value;
else if (n=="version/name")
version_name=p_value;
@ -317,8 +321,11 @@ bool EditorExportPlatformAndroid::_set(const StringName& p_name, const Variant&
bool EditorExportPlatformAndroid::_get(const StringName& p_name,Variant &r_ret) const{
String n=p_name;
if (n=="version/code")
if (n=="custom_package/debug")
r_ret=custom_debug_package;
else if (n=="custom_package/release")
r_ret=custom_release_package;
else if (n=="version/code")
r_ret=version_code;
else if (n=="version/name")
r_ret=version_name;
@ -389,7 +396,7 @@ void EditorExportPlatformAndroid::_get_property_list( List<PropertyInfo> *p_list
p_list->push_back( PropertyInfo( Variant::STRING, "keystore/release_user" ) );
p_list->push_back( PropertyInfo( Variant::BOOL, "apk_expansion/enable" ) );
p_list->push_back( PropertyInfo( Variant::STRING, "apk_expansion/SALT" ) );
p_list->push_back( PropertyInfo( Variant::STRING, "apk_expansion/pubic_key" ) );
p_list->push_back( PropertyInfo( Variant::STRING, "apk_expansion/public_key",PROPERTY_HINT_MULTILINE_TEXT ) );
const char **perms = android_perms;
while(*perms) {
@ -1095,6 +1102,12 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
ep.step("Adding Files..",1);
Error err=OK;
Vector<String> cl = cmdline.strip_edges().split(" ");
for(int i=0;i<cl.size();i++) {
if (cl[i].strip_edges().length()==0) {
cl.remove(i);
i--;
}
}
if (p_dumb) {
@ -1123,12 +1136,12 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
}
err = save_pack(pf);
memdelete(pf);
cl.push_back("-main_pack");
cl.push_back(apkfname);
cl.push_back("-main_pack_md5");
cl.push_back("-use_apk_expansion");
cl.push_back("-apk_expansion_md5");
cl.push_back(FileAccess::get_md5(fullpath));
cl.push_back("-main_pack_cfg");
cl.push_back(apk_expansion_salt+","+apk_expansion_pkey);
cl.push_back("-apk_expansion_key");
cl.push_back(apk_expansion_pkey.strip_edges());
} else {
@ -1562,10 +1575,10 @@ bool EditorExportPlatformAndroid::can_export(String *r_error) const {
if (apk_expansion) {
if (apk_expansion_salt=="") {
valid=false;
err+="Invalid SALT for apk expansion.\n";
}
//if (apk_expansion_salt=="") {
// valid=false;
// err+="Invalid SALT for apk expansion.\n";
//}
if (apk_expansion_pkey=="") {
valid=false;
err+="Invalid public key for apk expansion.\n";

View file

@ -63,6 +63,10 @@ import com.android.godot.input.*;
import java.io.InputStream;
import javax.microedition.khronos.opengles.GL10;
import java.security.MessageDigest;
import java.io.File;
import java.io.FileInputStream;
import java.util.LinkedList;
public class Godot extends Activity implements SensorEventListener
{
@ -138,7 +142,11 @@ public class Godot extends Activity implements SensorEventListener
*/
private String[] command_line;
public GodotView mView;
private boolean godot_initialized=false;
private SensorManager mSensorManager;
private Sensor mAccelerometer;
@ -190,9 +198,9 @@ public class Godot extends Activity implements SensorEventListener
// GodotEditText layout
GodotEditText edittext = new GodotEditText(this);
edittext.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
edittext.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
// ...add to FrameLayout
layout.addView(edittext);
layout.addView(edittext);
mView = new GodotView(getApplication(),io,use_gl2, this);
layout.addView(mView,new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
@ -216,46 +224,89 @@ public class Godot extends Activity implements SensorEventListener
private String[] getCommandLine() {
InputStream is;
try {
is = getAssets().open("_cl_");
byte[] len = new byte[4];
int r = is.read(len);
if (r<4) {
System.out.printf("**ERROR** Wrong cmdline length.\n");
Log.d("GODOT", "**ERROR** Wrong cmdline length.\n");
return new String[0];
}
int argc=((int)(len[3]&0xFF)<<24) | ((int)(len[2]&0xFF)<<16) | ((int)(len[1]&0xFF)<<8) | ((int)(len[0]&0xFF));
String[] cmdline = new String[argc];
InputStream is;
try {
is = getAssets().open("/_cl_");
byte[] len = new byte[4];
int r = is.read(len);
if (r<4) {
System.out.printf("**ERROR** Wrong cmdline length.\n");
return new String[0];
for(int i=0;i<argc;i++) {
r = is.read(len);
if (r<4) {
Log.d("GODOT", "**ERROR** Wrong cmdline param lenght.\n");
return new String[0];
}
int strlen=((int)(len[3]&0xFF)<<24) | ((int)(len[2]&0xFF)<<16) | ((int)(len[1]&0xFF)<<8) | ((int)(len[0]&0xFF));
if (strlen>65535) {
Log.d("GODOT", "**ERROR** Wrong command len\n");
return new String[0];
}
byte[] arg = new byte[strlen];
r = is.read(arg);
if (r==strlen) {
cmdline[i]=new String(arg,"UTF-8");
}
}
int argc=((int)(len[3])<<24) | ((int)(len[2])<<16) | ((int)(len[1])<<8) | ((int)(len[0]));
String[] cmdline = new String[argc];
for(int i=0;i<argc;i++) {
r = is.read(len);
if (r<4) {
System.out.printf("**ERROR** Wrong cmdline param lenght.\n");
return new String[0];
}
int strlen=((int)(len[3])<<24) | ((int)(len[2])<<16) | ((int)(len[1])<<8) | ((int)(len[0]));
if (strlen>65535) {
System.out.printf("**ERROR** Wrong command len\n");
return new String[0];
}
byte[] arg = new byte[strlen];
r = is.read(arg);
if (r!=strlen) {
cmdline[i]=new String(arg,"UTF-8");
}
}
return cmdline;
} catch (Exception e) {
e.printStackTrace();
System.out.printf("**ERROR** No commandline.\n");
Log.d("GODOT", "**ERROR** Exception " + e.getClass().getName() + ":" + e.getMessage());
return new String[0];
}
}
String expansion_pack_path;
private void initializeGodot() {
if (expansion_pack_path!=null) {
String[] new_cmdline;
int cll=0;
if (command_line!=null) {
new_cmdline = new String[ command_line.length + 2 ];
cll=command_line.length;
for(int i=0;i<command_line.length;i++) {
new_cmdline[i]=command_line[i];
}
} else {
new_cmdline = new String[ 2 ];
}
new_cmdline[cll]="-main_pack";
new_cmdline[cll+1]=expansion_pack_path;
command_line=new_cmdline;
}
io = new GodotIO(this);
io.unique_id = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
GodotLib.io=io;
GodotLib.initialize(this,io.needsReloadHooks(),command_line);
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
result_callback = null;
mPaymentsManager = PaymentsManager.createManager(this).initService();
godot_initialized=true;
}
@Override protected void onCreate(Bundle icicle) {
System.out.printf("** GODOT ACTIVITY CREATED HERE ***\n");
@ -267,20 +318,112 @@ public class Godot extends Activity implements SensorEventListener
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//check for apk expansion API
if (true) {
command_line = getCommandLine();
boolean use_apk_expansion=false;
String main_pack_md5=null;
String main_pack_key=null;
List<String> new_args = new LinkedList<String>();
io = new GodotIO(this);
io.unique_id = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
GodotLib.io=io;
GodotLib.initialize(this,io.needsReloadHooks(),getCommandLine());
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
for(int i=0;i<command_line.length;i++) {
result_callback = null;
mPaymentsManager = PaymentsManager.createManager(this).initService();
boolean has_extra = i< command_line.length -1;
if (command_line[i].equals("-use_apk_expansion")) {
use_apk_expansion=true;
} else if (has_extra && command_line[i].equals("-apk_expansion_md5")) {
main_pack_md5=command_line[i+1];
i++;
} else if (has_extra && command_line[i].equals("-apk_expansion_key")) {
main_pack_key=command_line[i+1];
i++;
} else if (command_line[i].trim().length()!=0){
new_args.add(command_line[i]);
}
}
if (new_args.isEmpty())
command_line=null;
else
command_line = new_args.toArray(new String[new_args.size()]);
if (use_apk_expansion && main_pack_md5!=null && main_pack_key!=null) {
//check that environment is ok!
if (!Environment.getExternalStorageState().equals( Environment.MEDIA_MOUNTED )) {
Log.d("GODOT", "**ERROR! No media mounted!");
//show popup and die
}
// Build the full path to the app's expansion files
try {
expansion_pack_path = Environment.getExternalStorageDirectory().toString() + "/Android/obb/"+this.getPackageName();
expansion_pack_path+="/"+"main."+getPackageManager().getPackageInfo(getPackageName(), 0).versionCode+"."+this.getPackageName()+".obb";
} catch (Exception e) {
e.printStackTrace();
}
File f = new File(expansion_pack_path);
boolean pack_valid = true;
Log.d("GODOT","**PACK** - Path "+expansion_pack_path);
if (!f.exists()) {
pack_valid=false;
Log.d("GODOT","**PACK** - File does not exist");
} else {
try {
InputStream fis = new FileInputStream(expansion_pack_path);
// Create MD5 Hash
byte[] buffer = new byte[16384];
MessageDigest complete = MessageDigest.getInstance("MD5");
int numRead;
do {
numRead = fis.read(buffer);
if (numRead > 0) {
complete.update(buffer, 0, numRead);
}
} while (numRead != -1);
fis.close();
byte[] messageDigest = complete.digest();
// Create Hex String
StringBuffer hexString = new StringBuffer();
for (int i=0; i<messageDigest.length; i++)
hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
String md5str = hexString.toString();
Log.d("GODOT","**PACK** - My MD5: "+hexString+" - APK md5: "+main_pack_md5);
if (!hexString.equals(main_pack_md5)) {
pack_valid=false;
}
} catch (Exception e) {
e.printStackTrace();
Log.d("GODOT","**PACK FAIL**");
pack_valid=false;
}
}
if (!pack_valid) {
}
}
}
initializeGodot();
// instanceSingleton( new GodotFacebook(this) );
@ -299,6 +442,8 @@ public class Godot extends Activity implements SensorEventListener
@Override protected void onPause() {
super.onPause();
if (!godot_initialized)
return;
mView.onPause();
mSensorManager.unregisterListener(this);
GodotLib.focusout();
@ -310,6 +455,9 @@ public class Godot extends Activity implements SensorEventListener
@Override protected void onResume() {
super.onResume();
if (!godot_initialized)
return;
mView.onResume();
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
GodotLib.focusin();

View file

@ -0,0 +1,27 @@
package com.android.godot;
import com.google.android.vending.expansion.downloader.DownloaderClientMarshaller;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
/**
* You should start your derived downloader class when this receiver gets the message
* from the alarm service using the provided service helper function within the
* DownloaderClientMarshaller. This class must be then registered in your AndroidManifest.xml
* file with a section like this:
* <receiver android:name=".GodotDownloaderAlarmReceiver"/>
*/
public class GodotDownloaderAlarmReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
try {
DownloaderClientMarshaller.startDownloadServiceIfRequired(context, intent, GodotDownloaderService.class);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
}
}

View file

@ -0,0 +1,47 @@
package com.android.godot;
import com.google.android.vending.expansion.downloader.impl.DownloaderService;
/**
* This class demonstrates the minimal client implementation of the
* DownloaderService from the Downloader library.
*/
public class GodotDownloaderService extends DownloaderService {
// stuff for LVL -- MODIFY FOR YOUR APPLICATION!
private static final String BASE64_PUBLIC_KEY = "REPLACE THIS WITH YOUR PUBLIC KEY";
// used by the preference obfuscater
private static final byte[] SALT = new byte[] {
1, 43, -12, -1, 54, 98,
-100, -12, 43, 2, -8, -4, 9, 5, -106, -108, -33, 45, -1, 84
};
/**
* This public key comes from your Android Market publisher account, and it
* used by the LVL to validate responses from Market on your behalf.
*/
@Override
public String getPublicKey() {
return BASE64_PUBLIC_KEY;
}
/**
* This is used by the preference obfuscater to make sure that your
* obfuscated preferences are different than the ones used by other
* applications.
*/
@Override
public byte[] getSALT() {
return SALT;
}
/**
* Fill this in with the class name for your alarm receiver. We do this
* because receivers must be unique across all of Android (it's a good idea
* to make sure that your receiver is in your unique package)
*/
@Override
public String getAlarmReceiverClassName() {
return GodotDownloaderAlarmReceiver.class.getName();
}
}

View file

@ -747,8 +747,34 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env,
}
const char ** cmdline=NULL;
int cmdlen=0;
bool use_apk_expansion=false;
if (p_cmdline) {
int cmdlen = env->GetArrayLength(p_cmdline);
if (cmdlen) {
cmdline = (const char**)malloc((env->GetArrayLength(p_cmdline)+1)*sizeof(const char*));
cmdline[cmdlen]=NULL;
os_android = new OS_Android(_gfx_init_func,env,_open_uri,_get_data_dir,_get_locale, _get_model,_show_vk, _hide_vk,_set_screen_orient,_get_unique_id, _play_video, _is_video_playing, _pause_video, _stop_video);
for (int i=0; i<cmdlen; i++) {
jstring string = (jstring) env->GetObjectArrayElement(p_cmdline, i);
const char *rawString = env->GetStringUTFChars(string, 0);
if (!rawString) {
__android_log_print(ANDROID_LOG_INFO,"godot","cmdline arg %i is null\n",i);
} else {
// __android_log_print(ANDROID_LOG_INFO,"godot","cmdline arg %i is: %s\n",i,rawString);
if (strcmp(rawString,"-main_pack")==0)
use_apk_expansion=true;
}
cmdline[i]=rawString;
}
}
}
os_android = new OS_Android(_gfx_init_func,env,_open_uri,_get_data_dir,_get_locale, _get_model,_show_vk, _hide_vk,_set_screen_orient,_get_unique_id, _play_video, _is_video_playing, _pause_video, _stop_video,use_apk_expansion);
os_android->set_need_reload_hooks(p_need_reload_hook);
char wd[500];
@ -759,16 +785,6 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env,
__android_log_print(ANDROID_LOG_INFO,"godot","**SETUP");
const char ** cmdline=NULL;
int cmdlen = env->GetArrayLength(p_cmdline);
cmdline = (const char**)malloc((env->GetArrayLength(p_cmdline)+1)*sizeof(const char*));
cmdline[cmdlen]=NULL;
for (int i=0; i<cmdlen; i++) {
jstring string = (jstring) env->GetObjectArrayElement(p_cmdline, i);
const char *rawString = env->GetStringUTFChars(string, 0);
cmdline[i]=rawString;
}
#if 0
char *args[]={"-test","render",NULL};
@ -833,6 +849,7 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_quit(JNIEnv * env, jobjec
input_mutex->lock();
quit_request=true;
print_line("BACK PRESSED");
input_mutex->unlock();
}
@ -1289,7 +1306,10 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_key(JNIEnv * env, jobject
} else if (val == 61453) {
ievent.key.scancode = KEY_ENTER;
ievent.key.unicode = KEY_ENTER;
}
} else if (p_scancode==4) {
quit_request=true;
}
input_mutex->lock();
key_events.push_back(ievent);
@ -1390,7 +1410,7 @@ static Variant::Type get_jni_type(const String& p_type) {
static const char* get_jni_sig(const String& p_type) {
print_line("getting sig for " + p_type);
static struct {
const char *name;
const char *sig;

View file

@ -87,11 +87,17 @@ void OS_Android::initialize_core() {
#else
FileAccess::make_default<FileAccessBufferedFA<FileAccessJAndroid> >(FileAccess::ACCESS_RESOURCES);
if (use_apk_expansion)
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_RESOURCES);
else
FileAccess::make_default<FileAccessBufferedFA<FileAccessJAndroid> >(FileAccess::ACCESS_RESOURCES);
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_USERDATA);
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_FILESYSTEM);
//FileAccessBufferedFA<FileAccessUnix>::make_default();
DirAccess::make_default<DirAccessJAndroid>(DirAccess::ACCESS_RESOURCES);
if (use_apk_expansion)
DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_RESOURCES);
else
DirAccess::make_default<DirAccessJAndroid>(DirAccess::ACCESS_RESOURCES);
DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_USERDATA);
DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_FILESYSTEM);
@ -698,9 +704,10 @@ void OS_Android::native_video_stop() {
video_stop_func();
}
OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func) {
OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func,bool p_use_apk_expansion) {
use_apk_expansion=p_use_apk_expansion;
default_videomode.width=800;
default_videomode.height=600;
default_videomode.fullscreen=true;
@ -720,10 +727,10 @@ OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFu
get_model_func=p_get_model_func;
get_unique_id_func=p_get_unique_id;
video_play_func = p_video_play_func;
video_is_playing_func = p_video_is_playing_func;
video_pause_func = p_video_pause_func;
video_stop_func = p_video_stop_func;
video_play_func = p_video_play_func;
video_is_playing_func = p_video_is_playing_func;
video_pause_func = p_video_pause_func;
video_stop_func = p_video_stop_func;
show_virtual_keyboard_func = p_show_vk;
hide_virtual_keyboard_func = p_hide_vk;

View file

@ -88,6 +88,7 @@ private:
bool use_gl2;
bool use_reload_hooks;
bool use_apk_expansion;
Rasterizer *rasterizer;
VisualServer *visual_server;
@ -213,7 +214,7 @@ public:
virtual void native_video_pause();
virtual void native_video_stop();
OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func);
OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func,bool p_use_apk_expansion);
~OS_Android();
};