Add template

This commit is contained in:
oakes
2014-01-18 20:15:29 -05:00
parent 6bfbdce2c7
commit f5860b976b
17 changed files with 337 additions and 0 deletions

8
template/project.clj Normal file
View File

@@ -0,0 +1,8 @@
(defproject play-clj/lein-template "0.1.0-SNAPSHOT"
:description "A template for making play-clj projects"
:url "https://github.com/oakes/play-clj"
:license {:name "Public Domain"
:url "http://unlicense.org/UNLICENSE"}
:dependencies [[lein-droid "0.2.0"]]
:resource-paths ["resources"]
:eval-in-leiningen true)

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
template/resources/libgdx.a Normal file

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,96 @@
(ns leiningen.new.play-clj
(:require [clojure.java.io :as io]
[leiningen.droid.new :as droid-new]
[leiningen.new.templates :as t]))
(defn play-clj
[name & [package-name]]
(let [render (t/renderer "play-clj")
lein-droid-render (droid-new/renderer "templates")
desktop-class-name "desktop-launcher"
android-class-name "AndroidLauncher"
ios-class-name "IOSLauncher"
package-name (t/sanitize (t/multi-segment (or package-name name)))
package-prefix (->> (.lastIndexOf package-name ".")
(subs package-name 0))
main-ns (t/sanitize-ns package-name)
desktop-ns (str main-ns "." desktop-class-name)
android-ns (str package-name "." android-class-name)
ios-ns (str package-name "." ios-class-name)
data {:app-name name
:name (t/project-name name)
:package package-name
:package-sanitized package-name
:package-prefix package-prefix
:desktop-class-name desktop-class-name
:android-class-name android-class-name
:ios-class-name ios-class-name
:activity android-class-name
:namespace main-ns
:desktop-namespace desktop-ns
:android-namespace android-ns
:ios-namespace ios-ns
:path (t/name-to-path main-ns)
:desktop-path (t/name-to-path desktop-ns)
:android-path (t/name-to-path android-ns)
:ios-path (t/name-to-path ios-ns)
:year (t/year)
:target-sdk "15"}]
(t/->files data
; main
["README.md" (render "README.md" data)]
[".gitignore" (render "gitignore" data)]
; desktop
["desktop/project.clj" (render "desktop-project.clj" data)]
["desktop/src-common/{{path}}.clj" (render "core.clj" data)]
["desktop/src/{{desktop-path}}.clj"
(render "desktop-launcher.clj" data)]
"desktop/src-common"
"desktop/src"
"desktop/resources"
; android
["android/project.clj"
(render "android-project.clj" data)]
["android/src/java/{{android-path}}.java"
(render "AndroidLauncher.java" data)]
"android/src/clojure"
["android/AndroidManifest.xml"
(lein-droid-render "AndroidManifest.xml" data)]
["android/res/drawable-hdpi/ic_launcher.png"
(lein-droid-render "ic_launcher_hdpi.png")]
["android/res/drawable-mdpi/ic_launcher.png"
(lein-droid-render "ic_launcher_mdpi.png")]
["android/res/drawable-ldpi/ic_launcher.png"
(lein-droid-render "ic_launcher_ldpi.png")]
["android/res/values/strings.xml"
(lein-droid-render "strings.xml" data)]
["android/res/drawable-hdpi/splash_circle.png"
(lein-droid-render "splash_circle.png")]
["android/res/drawable-hdpi/splash_droid.png"
(lein-droid-render "splash_droid.png")]
["android/res/drawable-hdpi/splash_hands.png"
(lein-droid-render "splash_hands.png")]
["android/res/drawable/splash_background.xml"
(lein-droid-render "splash_background.xml")]
["android/res/anim/splash_rotation.xml"
(lein-droid-render "splash_rotation.xml")]
["android/res/layout/splashscreen.xml"
(lein-droid-render "splashscreen.xml")]
["android/src/java/{{path}}/SplashActivity.java"
(lein-droid-render "SplashActivity.java" data)]
["android/libs/armeabi/libgdx.so"
(-> (io/resource "armeabi-libgdx.so") io/input-stream)]
["android/libs/armeabi-v7a/libgdx.so"
(-> (io/resource "armeabi-v7a-libgdx.so") io/input-stream)]
["android/libs/x86/libgdx.so"
(-> (io/resource "x86-libgdx.so") io/input-stream)]
; ios
["ios/project.clj" (render "ios-project.clj" data)]
["ios/Info.plist.xml" (render "Info.plist.xml" data)]
"ios/src/clojure"
["ios/src/java/{{ios-path}}.java"
(render "IOSLauncher.java" data)]
["ios/libs/libObjectAL.a"
(-> (io/resource "libObjectAL.a") io/input-stream)]
["ios/libs/libgdx.a"
(-> (io/resource "libgdx.a") io/input-stream)])))

View File

@@ -0,0 +1,20 @@
package {{package}};
import clojure.lang.RT;
import clojure.lang.Symbol;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.Game;
public class {{android-class-name}} extends AndroidApplication {
public void onCreate (android.os.Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RT.var("clojure.core", "require").invoke(Symbol.intern("{{namespace}}"));
try {
Game game = (Game) RT.var("{{namespace}}", "{{app-name}}").deref();
initialize(game, true);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,31 @@
package {{package}};
import clojure.lang.RT;
import clojure.lang.Symbol;
import com.badlogic.gdx.backends.iosrobovm.IOSApplication;
import com.badlogic.gdx.backends.iosrobovm.IOSApplicationConfiguration;
import com.badlogic.gdx.Game;
import org.robovm.cocoatouch.foundation.NSAutoreleasePool;
import org.robovm.cocoatouch.uikit.UIApplication;
public class {{ios-class-name}} extends IOSApplication.Delegate {
protected IOSApplication createApplication() {
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
RT.var("clojure.core", "require").invoke(Symbol.intern("{{namespace}}"));
try {
Game game = (Game) RT.var("{{namespace}}", "{{app-name}}").deref();
return new IOSApplication(game, config);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static void main(String[] argv) {
NSAutoreleasePool pool = new NSAutoreleasePool();
UIApplication.main(argv, null, {{ios-class-name}}.class);
pool.drain();
}
}

View File

@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>{{app-name}}</string>
<key>CFBundleExecutable</key>
<string>{{app-name}}</string>
<key>CFBundleIdentifier</key>
<string>{{package}}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>{{app-name}}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${app.version}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>Icon</string>
<string>Icon-72</string>
</array>
</dict>
</dict>
</dict>
</plist>

View File

@@ -0,0 +1,11 @@
# {{name}}
A LibGDX game in which ... well, that part is up to you.
## Contents
* `android/src` Android-specific code
* `desktop/resources` Images, audio, and other files
* `desktop/src` Desktop-specific code
* `desktop/src-common` Cross-platform game code
* `ios/src` iOS-specific code

View File

@@ -0,0 +1,37 @@
(defproject {{app-name}} "0.0.1-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[com.badlogicgames.gdx/gdx "0.9.9" :use-resources true]
[com.badlogicgames.gdx/gdx-backend-android "0.9.9"]
[neko/neko "3.0.0"]
[org.clojure-android/clojure "1.5.1-jb" :use-resources true]
[play-clj "0.1.0-SNAPSHOT"]]
:repositories [["sonatype"
"https://oss.sonatype.org/content/repositories/snapshots/"]]
:profiles {:dev {:dependencies [[android/tools.nrepl "0.2.0-bigstack"]
[compliment "0.0.3"]]
:android {:aot :all-with-unused}}
:release {:android
{;; Specify the path to your private
;; keystore and the the alias of the
;; key you want to sign APKs with.
;; :keystore-path "/home/user/.android/private.keystore"
;; :key-alias "mykeyalias"
:aot :all}}}
:android {;; Specify the path to the Android SDK directory either
;; here or in your ~/.lein/profiles.clj file.
;; :sdk-path "/home/user/path/to/android-sdk/"
;; Uncomment this if dexer fails with OutOfMemoryException
;; :force-dex-optimize true
:assets-path "../desktop/resources"
:native-libraries-paths ["libs"]
:target-version "{{target-sdk}}"
:aot-exclude-ns ["clojure.parallel" "clojure.core.reducers"]
:dex-opts ["-JXmx2048M"]}
:source-paths ["src/clojure" "../desktop/src-common"]
:java-source-paths ["src/java" "gen"]
:javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"])

View File

@@ -0,0 +1,18 @@
(ns {{namespace}}
(:require [play-clj.core :refer :all]
[play-clj.ui :refer :all]))
(defscreen main-screen
:on-show
(fn [screen entities]
(update! screen :renderer (stage))
(conj entities (label "Hello world!" (color :white))))
:on-render
(fn [screen entities]
(clear!)
(render! screen entities)))
(defgame {{app-name}}
:on-create
(fn [this]
(set-screen! this main-screen)))

View File

@@ -0,0 +1,10 @@
(ns {{desktop-namespace}}
(:require [{{namespace}} :refer :all])
(:import [com.badlogic.gdx.backends.lwjgl LwjglApplication]
[org.lwjgl.input Keyboard])
(:gen-class))
(defn -main
[]
(LwjglApplication. {{app-name}} "{{app-name}}" 800 600 true)
(Keyboard/enableRepeatEvents true))

View File

@@ -0,0 +1,16 @@
(defproject {{app-name}} "0.0.1-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[com.badlogicgames.gdx/gdx "0.9.9"]
[com.badlogicgames.gdx/gdx-backend-lwjgl "0.9.9"]
[com.badlogicgames.gdx/gdx-platform "0.9.9"
:classifier "natives-desktop"]
[org.clojure/clojure "1.5.1"]
[play-clj "0.1.0-SNAPSHOT"]]
:repositories [["sonatype"
"https://oss.sonatype.org/content/repositories/snapshots/"]]
:source-paths ["src" "src-common"]
:javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options"]
:aot [{{desktop-namespace}}]
:main {{desktop-namespace}})

View File

@@ -0,0 +1,12 @@
/target
/lib
/classes
/checkouts
pom.xml
pom.xml.asc
*.jar
*.class
.lein-deps-sum
.lein-failures
.lein-plugins
.lein-repl-history

View File

@@ -0,0 +1,17 @@
(defproject {{app-name}} "0.0.1-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[com.badlogicgames.gdx/gdx "0.9.9"]
[com.badlogicgames.gdx/gdx-backend-robovm "0.9.9"]
[org.clojure/clojure "1.5.1"]
[play-clj "0.1.0-SNAPSHOT"]]
:repositories [["sonatype"
"https://oss.sonatype.org/content/repositories/snapshots/"]]
:source-paths ["src/clojure" "../desktop/src-common"]
:java-source-paths ["src/java"]
:javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"]
:ios {:robovm-opts ["-forcelinkclasses" "{{package-prefix}}.**:clojure.**:com.badlogic.**:play_clj.**"
"-libs" "libs/libObjectAL.a:libs/libgdx.a"
"-frameworks" "UIKit:OpenGLES:QuartzCore:CoreGraphics:OpenAL:AudioToolbox:AVFoundation"
"-resources" "../desktop/resources/**"]}
:aot :all
:main {{ios-namespace}})