IAPing.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
(defproject advent "1.3.16-SNAPSHOT"
|
||||
(def version (str "2.0." (clojure.string/trim-newline (slurp "../desktop/last-release")) "-snapshot"))
|
||||
(defproject advent version
|
||||
:description "FIXME: write description"
|
||||
:manifest {"Implementation-Version" version}
|
||||
|
||||
:dependencies [[com.badlogicgames.gdx/gdx "1.9.3" :use-resources true]
|
||||
[com.badlogicgames.gdx/gdx-backend-lwjgl "1.9.3"]
|
||||
@@ -38,6 +40,7 @@
|
||||
;; key you want to sign APKs with.
|
||||
;; :keystore-path "ticks-talkes-release.jks"
|
||||
;; :key-alias "ticks-tales-release"
|
||||
:jvm-opts ["-Dplatform=android"]
|
||||
:build-type :release
|
||||
:aot :all-with-unused
|
||||
:aot-exclude-ns [cljs.core.async.macros cljs.core.impl-ioc-macros cljs.core.impl.ioc_macros]}}}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
(ns advent.android
|
||||
(:import [com.android.billingclient.api PurchasesUpdatedListener PurchaseHistoryResponseListener Purchase$PurchasesResult])
|
||||
(:require [clojure.core.async :as a]))
|
||||
|
||||
(def purchase-chan (a/chan))
|
||||
(:import [com.android.billingclient.api PurchasesUpdatedListener PurchaseHistoryResponseListener Purchase$PurchasesResult]
|
||||
[com.badlogic.gdx Gdx Application])
|
||||
(:require [clojure.core.async :as a]
|
||||
[advent.iap :as iap]))
|
||||
|
||||
(def listener
|
||||
(reify PurchasesUpdatedListener
|
||||
(onPurchasesUpdated [this response-code purchases]
|
||||
(println response-code purchases)
|
||||
(let [result (and purchases (> (.size purchases) 0))]
|
||||
(reset! @(resolve 'advent.core/has-purchased?) (if result true false))
|
||||
(a/go (a/>! purchase-chan (if result true false)))))) )
|
||||
(println "purchase response" result)
|
||||
(iap/set-purchase-pref (if result true false))))) )
|
||||
|
||||
(def history-listener
|
||||
(reify PurchaseHistoryResponseListener
|
||||
(onPurchaseHistoryResponse [this purchases-result]
|
||||
(println "got history")
|
||||
(reset! iap/can-purchase? true)
|
||||
(let [result (and purchases-result (.getPurchasesList purchases-result) (> (.size (.getPurchasesList purchases-result)) 0))]
|
||||
(reset! @(resolve 'advent.core/has-purchased?) (if result true false))
|
||||
(a/go (a/>! purchase-chan (if result true false)))))) )
|
||||
(println "purchase history" result)
|
||||
(iap/set-purchase-pref (if result true false))))) )
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.android.billingclient.api.BillingClient.SkuType;
|
||||
import com.android.billingclient.api.SkuDetails.SkuDetailsResult;
|
||||
import com.android.billingclient.api.BillingFlowParams;
|
||||
import com.android.billingclient.api.BillingFlowParams.Builder;
|
||||
import android.content.pm.*;
|
||||
|
||||
public class MainActivity extends AndroidApplication {
|
||||
public boolean triggerPurchase() {
|
||||
@@ -26,10 +27,19 @@ public class MainActivity extends AndroidApplication {
|
||||
|
||||
public void onCreate (android.os.Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
try {
|
||||
RT.var("clojure.core", "require").invoke(Symbol.intern("clojure.core.async"));
|
||||
RT.var("clojure.core", "require").invoke(Symbol.intern("advent.core"));
|
||||
RT.var("clojure.core", "require").invoke(Symbol.intern("advent.android"));
|
||||
|
||||
try {
|
||||
PackageInfo pInfo = this.getPackageManager().getPackageInfo(this.getPackageName(), 0);
|
||||
String version = pInfo.versionName;
|
||||
RT.var("advent.version", "version-override").bindRoot(version);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Importing failed");
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -1 +1 @@
|
||||
4
|
||||
6
|
||||
|
||||
@@ -37,12 +37,12 @@
|
||||
"script" ["run" "-m" "advent.analyze/dump-speech"]}
|
||||
:profiles {
|
||||
:uberjar {
|
||||
:jvm-opts ["-Duse-repl=false" "-Dui_scale=1.0" "-Dno-steam=true" "-Dclojure.compiler.direct-linking=true" "-Dis-desktop=true"]
|
||||
:jvm-opts ["-Duse-repl=false" "-Dui_scale=1.0" "-Dno-steam=true" "-Dclojure.compiler.direct-linking=true" "-Dis-desktop=true" "-Dplatform=desktop"]
|
||||
:aot :all
|
||||
}
|
||||
:dev {
|
||||
:source-paths ["src" "src-common" "src-dev"]
|
||||
:jvm-opts ["-Duse-repl=true" "-Dui_scale=1.0" "-Dno-steam=true" "-Dclojure.compiler.direct-linking=true" "-Dis-desktop=true"]
|
||||
:jvm-opts ["-Duse-repl=true" "-Dui_scale=1.0" "-Dno-steam=true" "-Dclojure.compiler.direct-linking=true" "-Dis-desktop=true" "-Dplatform=desktop"]
|
||||
:dependencies [[com.badlogicgames.gdx/gdx-tools "1.5.3"]
|
||||
[org.clojure/tools.nrepl "0.2.12"]
|
||||
[play-clj-nrepl "0.1.0" :exclusions [play-clj]]
|
||||
@@ -52,7 +52,7 @@
|
||||
:warn-on-reflection true}
|
||||
:mobile-dev {
|
||||
:source-paths ["src" "src-common" "src-dev"]
|
||||
:jvm-opts ["-Duse-repl=true" "-Dui_scale=1.5" "-Dno-steam=true" "-Dclojure.compiler.direct-linking=true" "-Dis-desktop=true"]
|
||||
:jvm-opts ["-Duse-repl=true" "-Dui_scale=1.5" "-Dno-steam=true" "-Dclojure.compiler.direct-linking=true" "-Dis-desktop=true" "-Dplatform=desktop"]
|
||||
:dependencies [[com.badlogicgames.gdx/gdx-tools "1.5.3"]
|
||||
[org.clojure/tools.nrepl "0.2.12"]
|
||||
[play-clj-nrepl "0.1.0" :exclusions [play-clj]]
|
||||
@@ -62,16 +62,16 @@
|
||||
#_#_:warn-on-reflection true}
|
||||
:app-store {
|
||||
:source-paths ["src" "src-common" "src-dev"]
|
||||
:jvm-opts ["-Dapp-store=true" "-Dui_scale=1.0" "-Dno-steam=true" "-Dis-desktop=true"]
|
||||
:jvm-opts ["-Dapp-store=true" "-Dui_scale=1.0" "-Dno-steam=true" "-Dis-desktop=true" "-Dplatform=desktop"]
|
||||
|
||||
:aot :all
|
||||
|
||||
:warn-on-reflection true}
|
||||
:steam {:dependencies [[com.code-disaster.steamworks4j/steamworks4j "1.2.2"]]
|
||||
:jvm-opts ["-Dis-desktop=true" "-Dui_scale=1.0" ]}
|
||||
:jvm-opts ["-Dis-desktop=true" "-Dui_scale=1.0" "-Dplatform=desktop"]}
|
||||
:steam-dev {
|
||||
:source-paths ["src" "src-common" "src-dev"]
|
||||
:jvm-opts ["-Duse-repl=true" "-Dui_scale=1.0" "-Dis-desktop=true"]
|
||||
:jvm-opts ["-Duse-repl=true" "-Dui_scale=1.0" "-Dis-desktop=true" "-Dplatform=desktop"]
|
||||
:dependencies [[com.badlogicgames.gdx/gdx-tools "1.5.3"]
|
||||
[org.clojure/tools.nrepl "0.2.7"]
|
||||
[play-clj-nrepl "0.1.0" :exclusions [play-clj]]
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
[advent.screens.safe :as safe]
|
||||
[advent.screens.fade :as fade]
|
||||
[advent.steam :as steam]
|
||||
[advent.iap :as iap]
|
||||
|
||||
[advent.pathfind])
|
||||
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
|
||||
@@ -21,12 +22,13 @@
|
||||
[com.badlogic.gdx Gdx Application]
|
||||
[java.io FileOutputStream File PrintStream]))
|
||||
|
||||
(def has-purchased? (atom false))
|
||||
|
||||
(defonce am (asset-manager))
|
||||
|
||||
|
||||
(set-asset-manager! am)
|
||||
(defn create-game [advent]
|
||||
(iap/use-pref)
|
||||
|
||||
(set-screen-wrapper! (fn [screen screen-fn]
|
||||
(try (screen-fn)
|
||||
(catch Exception e
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
[play-clj.math :refer :all]
|
||||
[play-clj.ui :refer :all]
|
||||
[play-clj.utils :refer :all]
|
||||
[play-clj.g2d :refer :all])
|
||||
[play-clj.g2d :refer :all]
|
||||
[advent.iap :as iap]
|
||||
[advent.ios :as ios])
|
||||
(:import [com.badlogic.gdx.graphics Color]
|
||||
[com.badlogic.gdx Application Gdx]))
|
||||
|
||||
@@ -378,15 +380,10 @@
|
||||
:label "Pit of destiny"
|
||||
:cursor :look
|
||||
:script (actions/get-script entities
|
||||
(println "billing purchased before" @@(resolve 'advent.core/has-purchased?))
|
||||
|
||||
(when-not @@(resolve 'advent.core/has-purchased?)
|
||||
(.triggerPurchase (Gdx/app))
|
||||
(a/<!! @(resolve 'advent.android/purchase-chan)))
|
||||
(println "billing purchased now:" @@(resolve 'advent.core/has-purchased?))
|
||||
(when @@(resolve 'advent.core/has-purchased?)
|
||||
(actions/walk-to entities :ego [154 41])
|
||||
(actions/talk entities :ego "Wow! That's a long way down.")))
|
||||
|
||||
(actions/walk-to entities :ego [154 41])
|
||||
(actions/talk entities :ego "Wow! That's a long way down."))
|
||||
:scripts {:shovel (actions/get-script entities
|
||||
(actions/walk-to entities :ego [154 41])
|
||||
(actions/talk entities :ego "I guess I'm doomed to be a gravedigger.")
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
[advent.tween :as tween]
|
||||
[advent.steam :as steam]
|
||||
[advent.utils :as utils]
|
||||
[advent.iap :as iap]
|
||||
[clojure.zip :as zip]
|
||||
[clojure.core.async :as a]
|
||||
[clojure.string :as str]
|
||||
[play-clj.core :refer :all]
|
||||
[play-clj.ui :refer :all]
|
||||
@@ -634,28 +636,35 @@
|
||||
(actions/walk-to entities :ego [257 90] :face :right :skip-type :end)
|
||||
(actions/talk entities :ego (str "Anyone home?"))
|
||||
(actions/play-animation entities :ego :reach)
|
||||
(cond
|
||||
(get-in @entities [:room :entities :wizard])
|
||||
(actions/do-dialogue entities :wizard "What are you doing, boy?"
|
||||
:wizard "I'm right here.")
|
||||
(when-not @iap/has-purchased?
|
||||
(when @iap/can-purchase?
|
||||
(actions/talk entities :ego "Uh-oh! It looks like it's guarded by a warding spell!")
|
||||
(actions/talk entities :ego "Looks like I need to buy an unwarding spell.")
|
||||
(iap/start-purchase)
|
||||
(a/<!! iap/purchase-chan)))
|
||||
(when @iap/has-purchased?
|
||||
(cond
|
||||
(get-in @entities [:room :entities :wizard])
|
||||
(actions/do-dialogue entities :wizard "What are you doing, boy?"
|
||||
:wizard "I'm right here.")
|
||||
|
||||
(= :night (get-in @entities [:state :time]))
|
||||
(actions/talk entities :ego "It's locked.")
|
||||
(= :night (get-in @entities [:state :time]))
|
||||
(actions/talk entities :ego "It's locked.")
|
||||
|
||||
:else
|
||||
(do (actions/play-animation entities :door :open)
|
||||
(actions/transition-background entities :inside-house [237 0] :between (fn [s e]
|
||||
(if (= 1 (rand-int 5))
|
||||
(assoc-in e [:room :entities :experiment] (get-in e [:room :experiment]))
|
||||
e)))
|
||||
(when (get-in @entities [:room :entities :experiment])
|
||||
(actions/play-animation entities :experiment :experiment)
|
||||
(actions/remove-entity entities :experiment))
|
||||
|
||||
(if (get-in @entities [:state :convinced-wizard?])
|
||||
(do (actions/talk entities :wizard "Oh, hello there, boy.")
|
||||
(utils/save @entities "autosave" "Autosave"))
|
||||
(wizard-dialogue entities)))))
|
||||
:else
|
||||
(do (actions/play-animation entities :door :open)
|
||||
(actions/transition-background entities :inside-house [237 0] :between (fn [s e]
|
||||
(if (= 1 (rand-int 5))
|
||||
(assoc-in e [:room :entities :experiment] (get-in e [:room :experiment]))
|
||||
e)))
|
||||
(when (get-in @entities [:room :entities :experiment])
|
||||
(actions/play-animation entities :experiment :experiment)
|
||||
(actions/remove-entity entities :experiment))
|
||||
|
||||
(if (get-in @entities [:state :convinced-wizard?])
|
||||
(do (actions/talk entities :wizard "Oh, hello there, boy.")
|
||||
(utils/save @entities "autosave" "Autosave"))
|
||||
(wizard-dialogue entities))))))
|
||||
:cursor :right}
|
||||
|
||||
:right-dir {:box [220 141 320 204]
|
||||
|
||||
@@ -228,6 +228,17 @@
|
||||
regular-version
|
||||
mobile-version))
|
||||
|
||||
(defmacro platformify [ios-version android-version regular-version]
|
||||
(println "Platforming: " (System/getProperty "platform"))
|
||||
(cond (= "desktop" (System/getProperty "platform"))
|
||||
regular-version
|
||||
|
||||
(= "android" (System/getProperty "platform"))
|
||||
android-version
|
||||
|
||||
:else
|
||||
ios-version))
|
||||
|
||||
(def screenshot-chan (chan))
|
||||
|
||||
(defn publish-screenshot-fn []
|
||||
|
||||
@@ -21,7 +21,9 @@
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>126</string>
|
||||
<string>135</string>
|
||||
<key>CFBundleIconName</key>
|
||||
<string>AppIcon</string>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
@@ -56,20 +58,6 @@
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>CFBundleIcons</key>
|
||||
<dict>
|
||||
<key>CFBundlePrimaryIcon</key>
|
||||
<dict>
|
||||
<key>CFBundleIconFiles</key>
|
||||
<array>
|
||||
<string>iTunesArtwork</string>
|
||||
<string>Icon</string>
|
||||
<string>Icon-60</string>
|
||||
<string>Icon-76</string>
|
||||
<string>Icon-83.5</string>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>ITSAppUsesNonExemptEncryption</key><false/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
(defproject advent "advent-2.0.4"
|
||||
(def version (str "2.0." (clojure.string/trim-newline (slurp "../desktop/last-release")) "-snapshot"))
|
||||
(defproject advent version
|
||||
:description "FIXME: write description"
|
||||
:dependencies [[com.badlogicgames.gdx/gdx "1.9.4"]
|
||||
[com.badlogicgames.gdx/gdx-backend-robovm "1.9.4"]
|
||||
@@ -10,12 +11,13 @@
|
||||
[com.mobidevelop.robovm/robovm-rt "2.3.0"]
|
||||
[play-clj "0.4.6-BRYCE" :exclusions [com.badlogicgames.gdx/gdx-box2d com.badlogicgames.gdx/gdx-bullet]]]
|
||||
:source-paths ["src/clojure" "../desktop/src-common"]
|
||||
|
||||
:java-source-paths ["src/java"]
|
||||
:plugins [[lein-fruit "0.2.4-SNAPSHOT"]
|
||||
[org.skummet/lein-skummet "0.2.2"]
|
||||
]
|
||||
:javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"]
|
||||
:jvm-opts ["-Dno-steam=true" "-Dclojure.compiler.direct-linking=true" "-Dclojure.compiler.elide-meta=[:doc :file :line :added]"]
|
||||
:jvm-opts ["-Dno-steam=true" "-Dclojure.compiler.direct-linking=true" "-Dclojure.compiler.elide-meta=[:doc :file :line :added]"
|
||||
"-Dplatform=ios"]
|
||||
:ios {:robovm-opts ["-config" "robovm.xml"]
|
||||
:robovm-path "/Users/brycecovert/.robovm-sdks/robovm-2.3.0"
|
||||
:version 2.1}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 26 KiB |
@@ -27,6 +27,8 @@
|
||||
</resource>
|
||||
</resources>
|
||||
<forceLinkClasses>
|
||||
|
||||
<pattern>org.robovm.apple.storekit.**</pattern>
|
||||
<pattern>advent.**</pattern>
|
||||
<pattern>clojure.genclass*</pattern>
|
||||
<pattern>clojure.gvec*</pattern>
|
||||
@@ -98,5 +100,6 @@
|
||||
<framework>OpenAL</framework>
|
||||
<framework>AudioToolbox</framework>
|
||||
<framework>AVFoundation</framework>
|
||||
<framework>StoreKit</framework>
|
||||
</frameworks>
|
||||
</config>
|
||||
|
||||
@@ -1,18 +1,35 @@
|
||||
package advent.core;
|
||||
|
||||
import java.util.*;
|
||||
import clojure.lang.RT;
|
||||
import clojure.lang.Symbol;
|
||||
// import advent.ios.*;
|
||||
|
||||
import com.badlogic.gdx.*;
|
||||
import com.badlogic.gdx.backends.iosrobovm.*;
|
||||
|
||||
import org.robovm.apple.foundation.*;
|
||||
import org.robovm.apple.uikit.UIApplication;
|
||||
import org.robovm.apple.uikit.*;
|
||||
import org.robovm.apple.glkit.GLKViewDrawableColorFormat;
|
||||
import org.robovm.apple.glkit.GLKViewDrawableDepthFormat;
|
||||
import org.robovm.apple.storekit.*;
|
||||
|
||||
public class IOSLauncher extends IOSApplication.Delegate {
|
||||
protected IOSApplication createApplication() {
|
||||
TransactionObserver transactionObserver;
|
||||
@Override
|
||||
public boolean didFinishLaunching (UIApplication application, UIApplicationLaunchOptions launchOptions) {
|
||||
transactionObserver = new TransactionObserver();
|
||||
SKPaymentQueue.getDefaultQueue().addTransactionObserver(transactionObserver);
|
||||
return super.didFinishLaunching(application, launchOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void willTerminate(UIApplication application) {
|
||||
SKPaymentQueue.getDefaultQueue().removeTransactionObserver(transactionObserver);
|
||||
super.willTerminate(application);
|
||||
}
|
||||
|
||||
protected IOSApplication createApplication() {
|
||||
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
|
||||
// config.colorFormat = GLKViewDrawableColorFormat.SRGBA8888;
|
||||
// config.depthFormat = GLKViewDrawableDepthFormat._24;
|
||||
@@ -22,8 +39,14 @@ public class IOSLauncher extends IOSApplication.Delegate {
|
||||
config.useAccelerometer=false;
|
||||
config.useCompass=false;
|
||||
System.out.println("application created.");
|
||||
HashSet<String> products = new HashSet();
|
||||
products.add("fullgame");
|
||||
SKProductsRequest request = new SKProductsRequest(products);
|
||||
request.setDelegate(new ProductDelegate());
|
||||
request.start();
|
||||
|
||||
RT.var("clojure.core", "require").invoke(Symbol.intern("advent.core"));
|
||||
RT.var("clojure.core", "require").invoke(Symbol.intern("advent.ios"));
|
||||
System.out.println("clojure loaded");
|
||||
try {
|
||||
NSDictionary infoDictionary = NSBundle.getMainBundle().getInfoDictionary();
|
||||
|
||||
Reference in New Issue
Block a user