You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Making Godot Easier to Use..
-=-=-=-=-=-=-=-=-=-=-=-=-=-= -Auto indenter in code editor, this makes it much easier to paste external code. -Zoom in 2D viewport now uses the mouse pointer as reference. -Obscure hack to see where code/line of GDScript in C++ backtrace. -Fixed a bug where keys would get stuck on X11 if pressed simultaneously -Added Api on IP singleton to request local IPs. -Premultiplied alpha support when importing texture, editing PNGs and as a blend mode.
This commit is contained in:
@@ -65,6 +65,9 @@ import java.io.InputStream;
|
||||
|
||||
public class Godot extends Activity implements SensorEventListener
|
||||
{
|
||||
|
||||
static final int MAX_SINGLETONS = 64;
|
||||
|
||||
static public class SingletonBase {
|
||||
|
||||
protected void registerClass(String p_name, String[] p_methods) {
|
||||
@@ -104,8 +107,21 @@ public class Godot extends Activity implements SensorEventListener
|
||||
|
||||
|
||||
}
|
||||
|
||||
Godot.singletons[Godot.singleton_count++]=this;
|
||||
}
|
||||
|
||||
protected void onMainActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void onMainResume() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void registerMethods() {}
|
||||
}
|
||||
|
||||
@@ -133,6 +149,12 @@ public class Godot extends Activity implements SensorEventListener
|
||||
//setTitle(title);
|
||||
}
|
||||
|
||||
|
||||
static SingletonBase singletons[] = new SingletonBase[MAX_SINGLETONS];
|
||||
static int singleton_count=0;
|
||||
|
||||
|
||||
|
||||
public interface ResultCallback {
|
||||
public void callback(int requestCode, int resultCode, Intent data);
|
||||
};
|
||||
@@ -147,6 +169,11 @@ public class Godot extends Activity implements SensorEventListener
|
||||
result_callback.callback(requestCode, resultCode, data);
|
||||
result_callback = null;
|
||||
};
|
||||
|
||||
for(int i=0;i<singleton_count;i++) {
|
||||
|
||||
singletons[i].onMainActivityResult(requestCode,resultCode,data);
|
||||
}
|
||||
};
|
||||
|
||||
public void onVideoInit(boolean use_gl2) {
|
||||
@@ -271,6 +298,12 @@ public class Godot extends Activity implements SensorEventListener
|
||||
mView.onResume();
|
||||
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
|
||||
GodotLib.focusin();
|
||||
|
||||
for(int i=0;i<singleton_count;i++) {
|
||||
|
||||
singletons[i].onMainResume();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override public void onSensorChanged(SensorEvent event) {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.android.godot;
|
||||
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
public class GodotPaymentV3 extends Godot.SingletonBase {
|
||||
@@ -13,14 +16,17 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
|
||||
private String accessToken;
|
||||
|
||||
private String purchaseValidationUrlPrefix;
|
||||
|
||||
private String transactionId;
|
||||
|
||||
public void purchase( String _sku) {
|
||||
public void purchase( String _sku, String _transactionId) {
|
||||
final String sku = _sku;
|
||||
final String transactionId = _transactionId;
|
||||
activity.getPaymentsManager().setBaseSingleton(this);
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
activity.getPaymentsManager().requestPurchase(sku);
|
||||
activity.getPaymentsManager().requestPurchase(sku, transactionId);
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -38,22 +44,31 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
|
||||
|
||||
public GodotPaymentV3(Activity p_activity) {
|
||||
|
||||
registerClass("GodotPayments", new String[] {"purchase", "setPurchaseCallbackId", "setPurchaseValidationUrlPrefix"});
|
||||
registerClass("GodotPayments", new String[] {"purchase", "setPurchaseCallbackId", "setPurchaseValidationUrlPrefix", "setTransactionId", "getSignature"});
|
||||
activity=(Godot) p_activity;
|
||||
}
|
||||
|
||||
|
||||
private String signature;
|
||||
public String getSignature(){
|
||||
return this.signature;
|
||||
}
|
||||
|
||||
public void callbackSuccess(String ticket){
|
||||
GodotLib.callobject(purchaseCallbackId, "purchase_success", new Object[]{ticket});
|
||||
|
||||
public void callbackSuccess(String ticket, String signature){
|
||||
Log.d(this.getClass().getName(), "PRE-Send callback to purchase success");
|
||||
GodotLib.calldeferred(purchaseCallbackId, "purchase_success", new Object[]{ticket, signature});
|
||||
Log.d(this.getClass().getName(), "POST-Send callback to purchase success");
|
||||
}
|
||||
|
||||
public void callbackFail(){
|
||||
GodotLib.callobject(purchaseCallbackId, "purchase_fail", new Object[]{});
|
||||
GodotLib.calldeferred(purchaseCallbackId, "purchase_fail", new Object[]{});
|
||||
// GodotLib.callobject(purchaseCallbackId, "purchase_fail", new Object[]{});
|
||||
}
|
||||
|
||||
public void callbackCancel(){
|
||||
GodotLib.callobject(purchaseCallbackId, "purchase_cancel", new Object[]{});
|
||||
GodotLib.calldeferred(purchaseCallbackId, "purchase_cancel", new Object[]{});
|
||||
// GodotLib.callobject(purchaseCallbackId, "purchase_cancel", new Object[]{});
|
||||
}
|
||||
|
||||
public int getPurchaseCallbackId() {
|
||||
@@ -84,4 +99,12 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
public void setTransactionId(String transactionId){
|
||||
this.transactionId = transactionId;
|
||||
}
|
||||
|
||||
public String getTransactionId(){
|
||||
return this.transactionId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,8 +56,7 @@ abstract public class ConsumeTask {
|
||||
|
||||
protected void onPostExecute(String param){
|
||||
if(param == null){
|
||||
|
||||
success(new PaymentsCache(context).getConsumableValue("ticket", sku));
|
||||
success( new PaymentsCache(context).getConsumableValue("ticket", sku) );
|
||||
}else{
|
||||
error(param);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,8 @@ abstract public class HandlePurchaseTask {
|
||||
|
||||
String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
|
||||
Log.d("XXX", "Purchase data:" + purchaseData);
|
||||
// String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");
|
||||
String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");
|
||||
Log.d("XXX", "Purchase signature:" + dataSignature);
|
||||
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
|
||||
@@ -57,12 +58,13 @@ abstract public class HandlePurchaseTask {
|
||||
error("Untrusted callback");
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d("XXX", "Este es el product ID:" + productId);
|
||||
pc.setConsumableValue("ticket_signautre", productId, dataSignature);
|
||||
pc.setConsumableValue("ticket", productId, purchaseData);
|
||||
pc.setConsumableFlag("block", productId, true);
|
||||
pc.setConsumableValue("token", productId, purchaseToken);
|
||||
|
||||
success(productId);
|
||||
success(productId, dataSignature);
|
||||
return;
|
||||
} catch (JSONException e) {
|
||||
error(e.getMessage());
|
||||
@@ -72,7 +74,7 @@ abstract public class HandlePurchaseTask {
|
||||
}
|
||||
}
|
||||
|
||||
abstract protected void success(String ticket);
|
||||
abstract protected void success(String ticket, String signature);
|
||||
abstract protected void error(String message);
|
||||
abstract protected void canceled();
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.android.godot.payments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
|
||||
public class PaymentsCache {
|
||||
|
||||
@@ -30,12 +31,14 @@ public class PaymentsCache {
|
||||
SharedPreferences sharedPref = context.getSharedPreferences("consumables_" + set, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedPref.edit();
|
||||
editor.putString(sku, value);
|
||||
Log.d("XXX", "Setting asset: consumables_" + set + ":" + sku);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public String getConsumableValue(String set, String sku){
|
||||
SharedPreferences sharedPref = context.getSharedPreferences(
|
||||
"consumables_" + set, Context.MODE_PRIVATE);
|
||||
Log.d("XXX", "Getting asset: consumables_" + set + ":" + sku);
|
||||
return sharedPref.getString(sku, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.godot.Godot;
|
||||
import com.android.godot.GodotPaymentV3;
|
||||
@@ -63,7 +64,7 @@ public class PaymentsManager {
|
||||
}
|
||||
};
|
||||
|
||||
public void requestPurchase(String sku){
|
||||
public void requestPurchase(String sku, String transactionId){
|
||||
new PurchaseTask(mService, Godot.getInstance()) {
|
||||
|
||||
@Override
|
||||
@@ -76,7 +77,7 @@ public class PaymentsManager {
|
||||
protected void canceled() {
|
||||
godotPaymentV3.callbackCancel();
|
||||
}
|
||||
}.purchase(sku);
|
||||
}.purchase(sku, transactionId);
|
||||
|
||||
}
|
||||
|
||||
@@ -84,13 +85,14 @@ public class PaymentsManager {
|
||||
new HandlePurchaseTask(activity){
|
||||
|
||||
@Override
|
||||
protected void success(final String sku) {
|
||||
protected void success(final String sku, final String signature) {
|
||||
new ConsumeTask(mService, activity) {
|
||||
|
||||
@Override
|
||||
protected void success(String ticket) {
|
||||
// godotPaymentV3.callbackSuccess("");
|
||||
godotPaymentV3.callbackSuccess(ticket);
|
||||
Log.d("XXX", "calling success:" + signature);
|
||||
godotPaymentV3.callbackSuccess(ticket, signature);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,7 +133,7 @@ public class PaymentsManager {
|
||||
|
||||
@Override
|
||||
protected void success(String ticket) {
|
||||
godotPaymentV3.callbackSuccess(ticket);
|
||||
godotPaymentV3.callbackSuccess(ticket, null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ abstract public class PurchaseTask {
|
||||
|
||||
private boolean isLooping = false;
|
||||
|
||||
public void purchase(final String sku){
|
||||
public void purchase(final String sku, final String transactionId){
|
||||
Log.d("XXX", "Starting purchase for: " + sku);
|
||||
PaymentsCache pc = new PaymentsCache(context);
|
||||
Boolean isBlocked = pc.getConsumableFlag("block", sku);
|
||||
@@ -40,7 +40,7 @@ abstract public class PurchaseTask {
|
||||
// error("Awaiting payment confirmation");
|
||||
// return;
|
||||
// }
|
||||
final String hash = Crypt.createRandomHash() + Crypt.createRandomHash();
|
||||
final String hash = transactionId;
|
||||
|
||||
Bundle buyIntentBundle;
|
||||
try {
|
||||
@@ -76,7 +76,7 @@ abstract public class PurchaseTask {
|
||||
return;
|
||||
}
|
||||
isLooping=true;
|
||||
PurchaseTask.this.purchase(sku);
|
||||
PurchaseTask.this.purchase(sku, transactionId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user