Browse code

move playn projects to correct folder

bob authored on 26/07/2014 at 17:22:19
Showing 109 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,19 @@
0
+<?xml version="1.0" encoding="utf-8"?>
1
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+      package="org.geekygoblin.nedetlesmaki.playn.android"
3
+      android:screenOrientation="landscape"
4
+      android:versionCode="1"
5
+      android:versionName="1.0">
6
+    <uses-sdk android:minSdkVersion="6" android:targetSdkVersion="11" />
7
+    <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
8
+        <activity android:name="NedEtLesMakiPlaynGameActivity"
9
+                  android:label="@string/app_name"
10
+                  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
11
+                  android:configChanges="keyboardHidden|orientation">
12
+            <intent-filter>
13
+                <action android:name="android.intent.action.MAIN" />
14
+                <category android:name="android.intent.category.LAUNCHER" />
15
+            </intent-filter>
16
+        </activity>
17
+    </application>
18
+</manifest>
0 19
new file mode 100644
... ...
@@ -0,0 +1,11 @@
0
+# This file is automatically generated by Android Tools.
1
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
2
+#
3
+# This file must be checked in Version Control Systems.
4
+#
5
+# To customize properties used by the Ant build system use,
6
+# "build.properties", and override values to adapt the script to your
7
+# project structure.
8
+
9
+# Project target.
10
+target=android-11
0 11
new file mode 100644
... ...
@@ -0,0 +1,167 @@
0
+<?xml version="1.0" encoding="UTF-8"?>
1
+<project xmlns="http://maven.apache.org/POM/4.0.0"
2
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
+  <modelVersion>4.0.0</modelVersion>
5
+  <parent>
6
+    <groupId>org.geekygoblin</groupId>
7
+    <artifactId>nedetlesmaki-playn</artifactId>
8
+    <version>0.4-SNAPSHOT</version>
9
+  </parent>
10
+
11
+  <artifactId>nedetlesmaki-playn-android</artifactId>
12
+  <packaging>apk</packaging>
13
+  <name>nedetlesmaki-playn-android</name>
14
+
15
+  <properties>
16
+    <sign.keystore>game.keystore</sign.keystore>
17
+    <keystore.alias>game</keystore.alias>
18
+    <!-- you can pass these on the command line as -Dkeystore.password=foo etc. -->
19
+    <keystore.password></keystore.password>
20
+    <key.password></key.password>
21
+  </properties>
22
+
23
+  <dependencies>
24
+    <dependency>
25
+      <groupId>org.geekygoblin</groupId>
26
+      <artifactId>nedetlesmaki-playn-core</artifactId>
27
+      <version>${project.version}</version>
28
+    </dependency>
29
+
30
+    <dependency>
31
+      <groupId>com.googlecode.playn</groupId>
32
+      <artifactId>playn-android</artifactId>
33
+      <version>${playn.version}</version>
34
+    </dependency>
35
+
36
+    <dependency>
37
+      <groupId>com.googlecode.playn</groupId>
38
+      <artifactId>playn-android-nativelib</artifactId>
39
+      <version>1.0</version>
40
+      <scope>runtime</scope>
41
+      <type>so</type>
42
+    </dependency>
43
+
44
+    <dependency>
45
+      <groupId>com.google.android</groupId>
46
+      <artifactId>android</artifactId>
47
+      <version>${android.version}</version>
48
+      <scope>provided</scope>
49
+    </dependency>
50
+  </dependencies>
51
+
52
+  <build>
53
+    <plugins>
54
+      <plugin>
55
+        <groupId>org.apache.maven.plugins</groupId>
56
+          <artifactId>maven-dependency-plugin</artifactId>
57
+             <executions>
58
+               <execution>
59
+                 <id>unpack</id>
60
+                   <phase>generate-sources</phase>
61
+                     <goals>
62
+                       <goal>unpack</goal>
63
+                     </goals>
64
+                     <configuration>
65
+                       <artifactItems>
66
+                         <artifactItem>
67
+                           <groupId>org.geekygoblin</groupId>
68
+                           <artifactId>nedetlesmaki-playn-assets</artifactId>
69
+                           <version>${project.version}</version>
70
+                           <outputDirectory>${basedir}</outputDirectory>
71
+                           <includes>**/assets/**/*</includes>
72
+                         </artifactItem>
73
+                       </artifactItems>
74
+                     </configuration>
75
+                   </execution>
76
+                </executions>
77
+        </plugin>
78
+      <plugin>
79
+        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
80
+        <artifactId>android-maven-plugin</artifactId>
81
+	<version>3.9.0-rc.1</version>
82
+	<configuration>
83
+          <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
84
+          <assetsDirectory>${project.basedir}/assets</assetsDirectory>
85
+          <resourceDirectory>${project.basedir}/res</resourceDirectory>
86
+          <sdk>
87
+            <platform>11</platform>
88
+          </sdk>
89
+          <deleteConflictingFiles>true</deleteConflictingFiles>
90
+          <undeployBeforeDeploy>true</undeployBeforeDeploy>
91
+          <jvmArguments>
92
+            <jvmArgument>-Xmx1024m</jvmArgument>
93
+          </jvmArguments>
94
+          <dex>
95
+            <jvmArguments>
96
+              <jvmArgument>-Xmx1024m</jvmArgument>
97
+            </jvmArguments>
98
+          </dex>
99
+        </configuration>
100
+        <extensions>true</extensions>
101
+        <executions>
102
+          <execution>
103
+            <id>deploy-on-install</id>
104
+            <phase>install</phase>
105
+            <goals>
106
+              <goal>deploy</goal>
107
+            </goals>
108
+          </execution>
109
+        </executions>
110
+      </plugin>
111
+    </plugins>
112
+  </build>
113
+  <!-- run 'mvn package -Pandroid -Psign -Dkeystore.password=foo' to sign and align -->
114
+  <profiles>
115
+    <profile>
116
+      <id>sign</id>
117
+      <build>
118
+        <plugins>
119
+          <plugin>
120
+            <groupId>org.apache.maven.plugins</groupId>
121
+            <artifactId>maven-jarsigner-plugin</artifactId>
122
+            <version>1.2</version>
123
+            <executions>
124
+              <execution>
125
+                <id>signing</id>
126
+                <goals><goal>sign</goal></goals>
127
+                <phase>package</phase>
128
+                <inherited>true</inherited>
129
+                <configuration>
130
+                  <archiveDirectory></archiveDirectory>
131
+                  <includes>
132
+                    <include>target/*.apk</include>
133
+                  </includes>
134
+                  <keystore>${keystore.path}</keystore>
135
+                  <storepass>${keystore.password}</storepass>
136
+                  <keypass>${key.password}</keypass>
137
+                  <alias>${keystore.alias}</alias>
138
+                  <arguments>
139
+                    <argument>-sigalg</argument><argument>MD5withRSA</argument>
140
+                    <argument>-digestalg</argument><argument>SHA1</argument>
141
+                  </arguments>
142
+                </configuration>
143
+              </execution>
144
+            </executions>
145
+          </plugin>
146
+          <plugin>
147
+            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
148
+            <artifactId>android-maven-plugin</artifactId>
149
+            <inherited>true</inherited>
150
+            <configuration>
151
+              <zipalign><skip>false</skip></zipalign>
152
+              <sign><debug>false</debug></sign>
153
+            </configuration>
154
+            <executions>
155
+              <execution>
156
+                <id>alignApk</id>
157
+                <phase>package</phase>
158
+                <goals><goal>zipalign</goal></goals>
159
+              </execution>
160
+            </executions>
161
+          </plugin>
162
+        </plugins>
163
+      </build>
164
+    </profile>
165
+  </profiles>
166
+</project>
0 167
new file mode 100644
... ...
@@ -0,0 +1,34 @@
0
+-optimizationpasses 5
1
+-dontusemixedcaseclassnames
2
+-dontskipnonpubliclibraryclasses
3
+-dontpreverify
4
+-verbose
5
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
6
+
7
+-keep public class * extends android.app.Activity
8
+-keep public class * extends android.app.Application
9
+-keep public class * extends android.app.Service
10
+-keep public class * extends android.content.BroadcastReceiver
11
+-keep public class * extends android.content.ContentProvider
12
+-keep public class com.android.vending.licensing.ILicensingService
13
+
14
+-keepclasseswithmembernames class * {
15
+    native <methods>;
16
+}
17
+
18
+-keepclasseswithmembernames class * {
19
+    public <init>(android.content.Context, android.util.AttributeSet);
20
+}
21
+
22
+-keepclasseswithmembernames class * {
23
+    public <init>(android.content.Context, android.util.AttributeSet, int);
24
+}
25
+
26
+-keepclassmembers enum * {
27
+    public static **[] values();
28
+    public static ** valueOf(java.lang.String);
29
+}
30
+
31
+-keep class * implements android.os.Parcelable {
32
+  public static final android.os.Parcelable$Creator *;
33
+}
0 34
new file mode 100644
1 35
Binary files /dev/null and b/playn/android/res/drawable-hdpi/icon.png differ
2 36
new file mode 100644
3 37
Binary files /dev/null and b/playn/android/res/drawable-ldpi/icon.png differ
4 38
new file mode 100644
5 39
Binary files /dev/null and b/playn/android/res/drawable-mdpi/icon.png differ
6 40
new file mode 100644
... ...
@@ -0,0 +1,4 @@
0
+<?xml version="1.0" encoding="utf-8"?>
1
+<resources>
2
+    <string name="app_name">Ned Et Les Maki</string>
3
+</resources>
0 4
new file mode 100644
... ...
@@ -0,0 +1,14 @@
0
+package org.geekygoblin.nedetlesmaki.playn.android;
1
+
2
+import playn.android.GameActivity;
3
+import playn.core.PlayN;
4
+
5
+import org.geekygoblin.nedetlesmaki.playn.core.NedEtLesMakiPlaynGame;
6
+
7
+public class NedEtLesMakiPlaynGameActivity extends GameActivity {
8
+
9
+  @Override
10
+  public void main(){
11
+    PlayN.run(new NedEtLesMakiPlaynGame());
12
+  }
13
+}
0 14
new file mode 100644
... ...
@@ -0,0 +1,37 @@
0
+<?xml version="1.0" encoding="UTF-8"?>
1
+<project xmlns="http://maven.apache.org/POM/4.0.0"
2
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
+    <modelVersion>4.0.0</modelVersion>
5
+    <parent>
6
+        <groupId>org.geekygoblin</groupId>
7
+        <artifactId>nedetlesmaki-playn</artifactId>
8
+        <version>0.4-SNAPSHOT</version>
9
+    </parent>
10
+    <artifactId>nedetlesmaki-playn-assets</artifactId>
11
+    <packaging>jar</packaging>
12
+    <name>nedetlesmaki-playn-assets</name>
13
+    <build>
14
+        <resources>
15
+            <resource>
16
+                <directory>src/main/resources</directory>
17
+                <filtering>false</filtering>
18
+            </resource>
19
+            <resource>
20
+                <directory>../../game/data</directory>
21
+                <targetPath>assets</targetPath>
22
+                <filtering>false</filtering>
23
+                <excludes>
24
+                    <exclude>**/*.nanim</exclude>
25
+                    <exclude>**/*.ogg</exclude>
26
+                    <exclude>**/*.wav</exclude>
27
+                </excludes>
28
+            </resource>
29
+        </resources>
30
+        <plugins>
31
+            <plugin>
32
+                <artifactId>maven-compiler-plugin</artifactId>
33
+            </plugin>
34
+        </plugins>
35
+    </build>
36
+</project>
0 37
new file mode 100644
... ...
@@ -0,0 +1,3 @@
0
+<module>
1
+  <public path="assets" />
2
+</module>
0 3
new file mode 100644
1 4
Binary files /dev/null and b/playn/assets/src/main/resources/assets/images/bg.png differ
2 5
new file mode 100644
... ...
@@ -0,0 +1,39 @@
0
+<?xml version="1.0" encoding="UTF-8"?>
1
+<project xmlns="http://maven.apache.org/POM/4.0.0"
2
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
+    <modelVersion>4.0.0</modelVersion>
5
+    <parent>
6
+        <groupId>org.geekygoblin</groupId>
7
+        <artifactId>nedetlesmaki-playn</artifactId>
8
+        <version>0.4-SNAPSHOT</version>
9
+    </parent>
10
+
11
+    <artifactId>nedetlesmaki-playn-core</artifactId>
12
+    <packaging>jar</packaging>
13
+    <name>nedetlesmaki-playn-core</name>
14
+
15
+    <dependencies>
16
+        <dependency>
17
+            <groupId>com.googlecode.playn</groupId>
18
+            <artifactId>playn-core</artifactId>
19
+        </dependency>
20
+        <dependency>
21
+            <groupId>org.geekygoblin</groupId>
22
+            <artifactId>nedetlesmaki-core</artifactId>
23
+        </dependency>
24
+        <dependency>
25
+            <groupId>im.bci</groupId>
26
+            <artifactId>jnuit-playn-utils</artifactId>
27
+        </dependency>
28
+    </dependencies>
29
+
30
+    <build>
31
+        <plugins>
32
+            <plugin>
33
+                <groupId>org.apache.maven.plugins</groupId>
34
+                <artifactId>maven-source-plugin</artifactId>
35
+            </plugin>
36
+        </plugins>
37
+    </build>
38
+</project>
0 39
new file mode 100644
... ...
@@ -0,0 +1,57 @@
0
+/*
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 devnewton <devnewton@bci.im>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+ */
23
+package org.geekygoblin.nedetlesmaki.playn.core;
24
+
25
+import org.geekygoblin.nedetlesmaki.core.IMainLoop;
26
+
27
+import playn.core.Game;
28
+
29
+public class NedEtLesMakiPlaynGame extends Game.Default {
30
+
31
+    private IMainLoop mainLoop;
32
+
33
+    public NedEtLesMakiPlaynGame() {
34
+        super(1000 / 60);
35
+    }
36
+
37
+    @Override
38
+    public void init() {
39
+
40
+        /*PlaynNedModule module = new PlaynNedModule();
41
+         Injector injector = Guice.createInjector(module);
42
+         mainLoop = injector.getInstance(IMainLoop.class);
43
+         */
44
+        mainLoop = new NedFactory().getMainLoop();
45
+    }
46
+
47
+    @Override
48
+    public void update(int delta) {
49
+        mainLoop.tick();
50
+    }
51
+
52
+    @Override
53
+    public void paint(float alpha) {
54
+        // the background automatically paints itself, so no need to do anything here!
55
+    }
56
+}
0 57
new file mode 100644
... ...
@@ -0,0 +1,157 @@
0
+/*
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 devnewton <devnewton@bci.im>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+ */
23
+package org.geekygoblin.nedetlesmaki.playn.core;
24
+
25
+import com.artemis.Entity;
26
+import im.bci.jnuit.NuitAudio;
27
+import im.bci.jnuit.NuitFont;
28
+import im.bci.jnuit.NuitPreferences;
29
+import im.bci.jnuit.NuitToolkit;
30
+import im.bci.jnuit.NuitTranslator;
31
+import im.bci.jnuit.playn.PlaynNuitAudio;
32
+import im.bci.jnuit.playn.PlaynNuitDisplay;
33
+import im.bci.jnuit.playn.PlaynNuitFont;
34
+import im.bci.jnuit.playn.PlaynNuitPreferences;
35
+import im.bci.jnuit.playn.PlaynNuitRenderer;
36
+import im.bci.jnuit.playn.controls.PlaynNuitControls;
37
+import java.util.Random;
38
+import javax.inject.Provider;
39
+import org.geekygoblin.nedetlesmaki.core.IDefaultControls;
40
+import org.geekygoblin.nedetlesmaki.core.NedGame;
41
+import org.geekygoblin.nedetlesmaki.core.NedNuitToolkit;
42
+import org.geekygoblin.nedetlesmaki.core.NedNuitTranslator;
43
+import org.geekygoblin.nedetlesmaki.core.components.IngameControls;
44
+import org.geekygoblin.nedetlesmaki.core.components.ui.CutScenes;
45
+import org.geekygoblin.nedetlesmaki.core.components.ui.InGameUI;
46
+import org.geekygoblin.nedetlesmaki.core.components.ui.LevelSelector;
47
+import org.geekygoblin.nedetlesmaki.core.components.ui.MainMenu;
48
+import org.geekygoblin.nedetlesmaki.core.events.HideMenuTrigger;
49
+import org.geekygoblin.nedetlesmaki.core.events.IStartGameTrigger;
50
+import org.geekygoblin.nedetlesmaki.core.events.ShowLevelMenuTrigger;
51
+import org.geekygoblin.nedetlesmaki.core.events.ShowMenuTrigger;
52
+import org.geekygoblin.nedetlesmaki.core.manager.EntityIndexManager;
53
+import org.geekygoblin.nedetlesmaki.core.systems.GameSystem;
54
+import org.geekygoblin.nedetlesmaki.core.systems.IngameInputSystem;
55
+import org.geekygoblin.nedetlesmaki.core.systems.UpdateLevelVisualSystem;
56
+import org.geekygoblin.nedetlesmaki.core.utils.MoveStory;
57
+import org.geekygoblin.nedetlesmaki.playn.core.events.PlaynStartGameTrigger;
58
+import org.geekygoblin.nedetlesmaki.playn.core.systems.PlaynInGameUISystem;
59
+import org.geekygoblin.nedetlesmaki.playn.core.systems.PlaynMainMenuSystem;
60
+import org.geekygoblin.nedetlesmaki.playn.core.systems.PlaynSpriteSystem;
61
+import playn.core.Font;
62
+
63
+/**
64
+ *
65
+ * @author devnewton <devnewton@bci.im>
66
+ */
67
+public class NedFactory {
68
+
69
+    private final PlaynMainLoop mainLoop;
70
+    private Entity mainMenu;
71
+    private final Entity ingameControls;
72
+    private final PlaynAssets assets;
73
+    private final EntityIndexManager indexedManager;
74
+    private final MoveStory moveStory;
75
+    private final Random random;
76
+    private final Entity inGameUI;
77
+
78
+    public NedFactory() {
79
+        this.random = new Random(42);
80
+        PlaynNuitControls controls = new PlaynNuitControls();
81
+        PlaynTouchControls touch = new PlaynTouchControls();
82
+        PlaynNuitDisplay display = new PlaynNuitDisplay();
83
+        NuitFont font = new PlaynNuitFont("Arial", Font.Style.BOLD, 32, true);
84
+        NuitTranslator translator = new NedNuitTranslator();
85
+        PlaynNuitRenderer renderer = new NedPlaynNuitRenderer(translator, font);
86
+        NuitAudio audio = new PlaynNuitAudio();
87
+        NuitToolkit toolkit = new NedNuitToolkit(display, translator, font, renderer, controls, audio);
88
+        Provider<ShowLevelMenuTrigger> showLevelMenuTrigger = new Provider<ShowLevelMenuTrigger>() {
89
+
90
+            @Override
91
+            public ShowLevelMenuTrigger get() {
92
+                return new ShowLevelMenuTrigger(mainMenu, ingameControls);
93
+            }
94
+        };
95
+        Provider<ShowMenuTrigger> showMenuTrigger = new Provider<ShowMenuTrigger>() {
96
+
97
+            @Override
98
+            public ShowMenuTrigger get() {
99
+                return new ShowMenuTrigger(mainMenu, inGameUI, ingameControls);
100
+            }
101
+        };
102
+        Provider<IStartGameTrigger> startGameTrigger = new Provider<IStartGameTrigger>() {
103
+
104
+            @Override
105
+            public IStartGameTrigger get() {
106
+                return new PlaynStartGameTrigger(assets, mainMenu, inGameUI, ingameControls, indexedManager, moveStory, random);
107
+            }
108
+        };
109
+        
110
+        assets = new PlaynAssets();
111
+        indexedManager = new EntityIndexManager();
112
+        moveStory = new MoveStory();
113
+        GameSystem gameSystem = new GameSystem(indexedManager, moveStory);
114
+        IDefaultControls defaultControls = new PlaynDefaultControls(controls, touch);
115
+        InGameUI inGameUIComponent = new InGameUI(toolkit, assets);
116
+        IngameInputSystem ingameInputSystem = new IngameInputSystem(showMenuTrigger, showLevelMenuTrigger, startGameTrigger, indexedManager, moveStory, gameSystem, defaultControls, inGameUIComponent);
117
+        UpdateLevelVisualSystem updateLevelVisualSystem = new UpdateLevelVisualSystem(assets, indexedManager, moveStory, gameSystem, showLevelMenuTrigger);
118
+        PlaynSpriteSystem drawSystem = new PlaynSpriteSystem(controls);
119
+        PlaynMainMenuSystem mainMenuSystem = new PlaynMainMenuSystem(renderer);
120
+        PlaynInGameUISystem inGameUISystem = new PlaynInGameUISystem(renderer);
121
+        NedGame game = new PlaynGame(toolkit, ingameInputSystem, updateLevelVisualSystem, indexedManager, assets, drawSystem, mainMenuSystem,inGameUISystem);
122
+
123
+        mainLoop = new PlaynMainLoop(game);
124
+        LevelSelector levelSelector = new LevelSelector(game, toolkit, assets, startGameTrigger, showMenuTrigger);
125
+        Provider<HideMenuTrigger> hideMenuTrigger = new Provider<HideMenuTrigger>() {
126
+
127
+            @Override
128
+            public HideMenuTrigger get() {
129
+                return new HideMenuTrigger(mainMenu, inGameUI, ingameControls);
130
+            }
131
+        };
132
+        CutScenes cutscenes = new CutScenes(assets);
133
+        NuitPreferences preferences = new PlaynNuitPreferences(controls, "nedetlesmaki");
134
+
135
+        ingameControls = game.createEntity();
136
+        IngameControls ingameControlsComponent = new IngameControls(defaultControls);
137
+        ingameControls.addComponent(ingameControlsComponent);
138
+        ingameControls.disable();
139
+        game.addEntity(ingameControls);
140
+
141
+        MainMenu mainMenuComponent = new MainMenu(mainLoop, game, toolkit, assets, levelSelector, hideMenuTrigger, ingameControlsComponent, cutscenes, preferences);
142
+        mainMenu = game.createEntity();
143
+        mainMenu.addComponent(mainMenuComponent);
144
+        game.addEntity(mainMenu);
145
+
146
+        inGameUI = game.createEntity();
147
+        inGameUI.addComponent(inGameUIComponent);
148
+        game.addEntity(inGameUI);
149
+        inGameUI.disable();
150
+    }
151
+
152
+    public PlaynMainLoop getMainLoop() {
153
+        return mainLoop;
154
+    }
155
+
156
+}
0 157
new file mode 100644
... ...
@@ -0,0 +1,42 @@
0
+/*
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 devnewton <devnewton@bci.im>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+ */
23
+package org.geekygoblin.nedetlesmaki.playn.core;
24
+
25
+import im.bci.jnuit.NuitFont;
26
+import im.bci.jnuit.NuitTranslator;
27
+import im.bci.jnuit.playn.PlaynNuitFont;
28
+import im.bci.jnuit.playn.PlaynNuitRenderer;
29
+import org.geekygoblin.nedetlesmaki.core.NamedEntities;
30
+
31
+/**
32
+ *
33
+ * @author devnewton <devnewton@bci.im>
34
+ */
35
+class NedPlaynNuitRenderer extends PlaynNuitRenderer {
36
+
37
+    public NedPlaynNuitRenderer(NuitTranslator translator, @NamedEntities.DefaultFont NuitFont font) {
38
+        super(translator, (PlaynNuitFont) font);
39
+    }
40
+
41
+}
0 42
new file mode 100644
... ...
@@ -0,0 +1,44 @@
0
+/*
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 devnewton <devnewton@bci.im>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+ */
23
+package org.geekygoblin.nedetlesmaki.playn.core;
24
+
25
+import im.bci.jnuit.playn.TimeBasedCachedAssets;
26
+import org.geekygoblin.nedetlesmaki.core.IAssets;
27
+
28
+/**
29
+ *
30
+ * @author devnewton <devnewton@bci.im>
31
+ */
32
+public class PlaynAssets extends TimeBasedCachedAssets implements IAssets {
33
+
34
+    public PlaynAssets() {
35
+        super(1000f);
36
+    }
37
+ 
38
+    
39
+    @Override
40
+    public void setIcon(String icon) {
41
+    }
42
+
43
+}
0 44
new file mode 100644
... ...
@@ -0,0 +1,81 @@
0
+/*
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 devnewton <devnewton@bci.im>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+ */
23
+package org.geekygoblin.nedetlesmaki.playn.core;
24
+
25
+import org.geekygoblin.nedetlesmaki.core.IDefaultControls;
26
+import im.bci.jnuit.controls.Control;
27
+import im.bci.jnuit.playn.controls.KeyControl;
28
+import im.bci.jnuit.playn.controls.PlaynNuitControls;
29
+import playn.core.Key;
30
+
31
+/**
32
+ *
33
+ * @author devnewton <devnewton@bci.im>
34
+ */
35
+public class PlaynDefaultControls implements IDefaultControls {
36
+
37
+    private final PlaynNuitControls controls;
38
+    private final PlaynTouchControls touch;
39
+
40
+    public PlaynDefaultControls(PlaynNuitControls controls, PlaynTouchControls touch) {
41
+        this.controls = controls;
42
+        this.touch = touch;
43
+    }
44
+
45
+    @Override
46
+    public Control[] getMouseClickControls() {
47
+        return new Control[]{controls.getClickControl()};
48
+    }
49
+
50
+    @Override
51
+    public Control[] getUp() {
52
+        return new Control[]{new KeyControl(controls, Key.UP), new TouchControls(touch, Key.UP)};
53
+    }
54
+
55
+    @Override
56
+    public Control[] getDown() {
57
+        return new Control[]{new KeyControl(controls, Key.DOWN), new TouchControls(touch, Key.DOWN)};
58
+    }
59
+
60
+    @Override
61
+    public Control[] getLeft() {
62
+        return new Control[]{new KeyControl(controls, Key.LEFT), new TouchControls(touch, Key.LEFT)};
63
+    }
64
+
65
+    @Override
66
+    public Control[] getRight() {
67
+        return new Control[]{new KeyControl(controls, Key.RIGHT), new TouchControls(touch, Key.RIGHT)};
68
+    }
69
+
70
+    @Override
71
+    public Control[] getRewind() {
72
+        return new Control[]{new KeyControl(controls, Key.BACK), new TouchControls(touch, Key.BACK)};
73
+    }
74
+
75
+    @Override
76
+    public Control[] getMenu() {
77
+        return new Control[]{new KeyControl(controls, Key.ESCAPE), new TouchControls(touch, Key.BACK)};
78
+    }
79
+
80
+}
0 81
new file mode 100644
... ...
@@ -0,0 +1,81 @@
0
+/*
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 devnewton <devnewton@bci.im>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+ */
23
+package org.geekygoblin.nedetlesmaki.playn.core;
24
+
25
+import com.artemis.Entity;
26
+import com.artemis.managers.GroupManager;
27
+import im.bci.jnuit.NuitToolkit;
28
+import im.bci.jnuit.artemis.sprite.SpriteAnimateSystem;
29
+import org.geekygoblin.nedetlesmaki.core.IAssets;
30
+import org.geekygoblin.nedetlesmaki.core.NedGame;
31
+import org.geekygoblin.nedetlesmaki.core.manager.EntityIndexManager;
32
+import org.geekygoblin.nedetlesmaki.core.systems.DebugSpriteSystem;
33
+import org.geekygoblin.nedetlesmaki.core.systems.DialogSystem;
34
+import org.geekygoblin.nedetlesmaki.core.systems.IngameInputSystem;
35
+import org.geekygoblin.nedetlesmaki.core.systems.MouseArrowSystem;
36
+import org.geekygoblin.nedetlesmaki.core.systems.SpritePuppetControlSystem;
37
+import org.geekygoblin.nedetlesmaki.core.systems.TriggerSystem;
38
+import org.geekygoblin.nedetlesmaki.core.systems.UpdateLevelVisualSystem;
39
+import org.geekygoblin.nedetlesmaki.playn.core.systems.PlaynInGameUISystem;
40
+import org.geekygoblin.nedetlesmaki.playn.core.systems.PlaynLevelBackgroundSystem;
41
+import org.geekygoblin.nedetlesmaki.playn.core.systems.PlaynMainMenuSystem;
42
+import org.geekygoblin.nedetlesmaki.playn.core.systems.PlaynSpriteSystem;
43
+
44
+/**
45
+ *
46
+ * @author devnewton
47
+ */
48
+public class PlaynGame extends NedGame {
49
+
50
+    private Entity ned;
51
+
52
+    public PlaynGame(NuitToolkit toolkit, IngameInputSystem ingameInputSystem, UpdateLevelVisualSystem updateLevelVisualSystem, EntityIndexManager indexedManager, IAssets assets, PlaynSpriteSystem drawSystem, PlaynMainMenuSystem mainMenuSystem, PlaynInGameUISystem inGameUISystem) {
53
+        setManager(indexedManager);
54
+        setSystem(ingameInputSystem);
55
+        setSystem(updateLevelVisualSystem);
56
+        setSystem(new SpriteAnimateSystem());
57
+        setSystem(new SpritePuppetControlSystem());
58
+        setSystem(new MouseArrowSystem(this, assets, drawSystem));
59
+        setSystem(new PlaynLevelBackgroundSystem());
60
+        setSystem(drawSystem);
61
+        setSystem(new TriggerSystem());
62
+        setSystem(mainMenuSystem);
63
+        setSystem(inGameUISystem);
64
+        setSystem(new DialogSystem());
65
+        setSystem(new DebugSpriteSystem());
66
+        setManager(new GroupManager());
67
+
68
+        initialize();
69
+    }
70
+
71
+    @Override
72
+    public void setNed(Entity ned) {
73
+        this.ned = ned;
74
+    }
75
+
76
+    @Override
77
+    public Entity getNed() {
78
+        return ned;
79
+    }
80
+}
0 81
new file mode 100644
... ...
@@ -0,0 +1,60 @@
0
+/*
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 devnewton <devnewton@bci.im>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+ */
23
+package org.geekygoblin.nedetlesmaki.playn.core;
24
+
25
+import com.artemis.Entity;
26
+import org.geekygoblin.nedetlesmaki.core.IMainLoop;
27
+import org.geekygoblin.nedetlesmaki.core.NamedEntities;
28
+import org.geekygoblin.nedetlesmaki.core.NedGame;
29
+
30
+/**
31
+ *
32
+ * @author devnewton
33
+ */
34
+public class PlaynMainLoop implements IMainLoop {
35
+
36
+    private boolean closeRequested;
37
+    private final NedGame game;
38
+
39
+    public PlaynMainLoop(NedGame game) {
40
+        this.game = game;
41
+    }
42
+
43
+    @Override
44
+    public boolean isCloseRequested() {
45
+        return closeRequested;
46
+    }
47
+
48
+    @Override
49
+    public void setCloseRequested(boolean closeRequested) {
50
+        this.closeRequested = closeRequested;
51
+    }
52
+
53
+    @Override
54
+    public void tick() {
55
+        game.setDelta(1.0f / 60.0f);
56
+        game.process();
57
+    }
58
+
59
+}
0 60
new file mode 100644
... ...
@@ -0,0 +1,82 @@
0
+/*
1
+ * To change this license header, choose License Headers in Project Properties.
2
+ * To change this template file, choose Tools | Templates
3
+ * and open the template in the editor.
4
+ */
5
+package org.geekygoblin.nedetlesmaki.playn.core;
6
+
7
+import playn.core.Key;
8
+import playn.core.PlayN;
9
+import playn.core.Touch;
10
+import playn.core.Touch.Listener;
11
+
12
+/*
13
+ *
14
+ * @author pierre
15
+ */
16
+public class PlaynTouchControls implements Listener {
17
+
18
+    public boolean move[] = new boolean[Key.values().length];
19
+    private Touch.Event begin;
20
+    private Key last;
21
+
22
+    public PlaynTouchControls() {
23
+        PlayN.touch().setListener(this);
24
+
25
+        this.last = Key.UNKNOWN;
26
+    }
27
+
28
+    @Override
29
+    public void onTouchStart(Touch.Event[] events) {
30
+        if (events.length == 1) {
31
+            this.begin = events[0];
32
+        }
33
+    }
34
+
35
+    @Override
36
+    public void onTouchMove(Touch.Event[] events) {
37
+        if (events.length == 1) {
38
+
39
+            Touch.Event end = events[0];
40
+            float diffX = this.begin.x() - end.x();
41
+            float diffY = this.begin.y() - end.y();
42
+
43
+            if (diffX > 0) {
44
+                if (diffY > 0) {
45
+                    this.setupMove(Key.LEFT);
46
+                } else {
47
+                    this.setupMove(Key.DOWN);
48
+                }
49
+            } else {
50
+                if (diffY > 0) {
51
+                    this.setupMove(Key.UP);
52
+                } else {
53
+                    this.setupMove(Key.RIGHT);
54
+                }
55
+            }
56
+        }
57
+    }
58
+
59
+    @Override
60
+    public void onTouchEnd(Touch.Event[] events) {
61
+        this.move[this.last.ordinal()] = false;
62
+    }
63
+
64
+    @Override
65
+    public void onTouchCancel(Touch.Event[] events) {
66
+
67
+    }
68
+
69
+    public String getName() {
70
+        return this.last.toString();
71
+    }
72
+
73
+    private void setupMove(Key next) {
74
+        if (this.last != next) {
75
+            this.move[this.last.ordinal()] = false;
76
+        }
77
+
78
+        this.move[next.ordinal()] = true;
79
+        this.last = next;
80
+    }
81
+}
0 82
new file mode 100644
... ...
@@ -0,0 +1,45 @@
0
+/*
1
+ * To change this license header, choose License Headers in Project Properties.
2
+ * To change this template file, choose Tools | Templates
3
+ * and open the template in the editor.
4
+ */
5
+package org.geekygoblin.nedetlesmaki.playn.core;
6
+
7
+import playn.core.Key;
8
+
9
+import im.bci.jnuit.controls.Control;
10
+
11
+/**
12
+ *
13
+ * @author pierre
14
+ */
15
+public class TouchControls implements Control {
16
+
17
+    private Key move;
18
+    private PlaynTouchControls controls; 
19
+    
20
+    public TouchControls(PlaynTouchControls controls, Key move) {
21
+        this.move = move;
22
+        this.controls = controls;
23
+    }
24
+
25
+    @Override
26
+    public String getControllerName() {
27
+        return "Touch";
28
+    }
29
+
30
+    @Override
31
+    public String getName() {
32
+       return move.toString();
33
+    }
34
+
35
+    @Override
36
+    public float getDeadZone() {
37
+        return 0.0f;
38
+    }
39
+
40
+    @Override
41
+    public float getValue() {
42
+        return this.controls.move[move.ordinal()] ? 1.0f : 0.0f;
43
+    }
44
+}
0 45
new file mode 100644
... ...
@@ -0,0 +1,45 @@
0
+/*
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 devnewton <devnewton@bci.im>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+ */
23
+package org.geekygoblin.nedetlesmaki.playn.core.components.ui;
24
+
25
+import com.artemis.Component;
26
+import playn.core.Layer;
27
+
28
+/**
29
+ *
30
+ * @author devnewton <devnewton@bci.im>
31
+ */
32
+public class PlaynLayerOwner extends Component {
33
+
34
+    private final Layer layer;
35
+
36
+    public PlaynLayerOwner(Layer layer) {
37
+        this.layer = layer;
38
+    }
39
+
40
+    public Layer getLayer() {
41
+        return layer;
42
+    }
43
+
44
+}
0 45
new file mode 100644
... ...
@@ -0,0 +1,158 @@
0
+/*
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 devnewton <devnewton@bci.im>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+ */
23
+package org.geekygoblin.nedetlesmaki.playn.core.events;
24
+
25
+import com.artemis.Entity;
26
+import im.bci.jnuit.animation.IAnimationCollection;
27
+import im.bci.jnuit.artemis.sprite.IsometricSpriteProjector;
28
+import im.bci.jnuit.artemis.sprite.SpriteProjector;
29
+import im.bci.jnuit.playn.animation.PlaynAnimation;
30
+import im.bci.jnuit.playn.animation.PlaynAnimationCollection;
31
+import im.bci.jnuit.playn.animation.PlaynAnimationImage;
32
+import im.bci.tmxloader.TmxFrame;
33
+import im.bci.tmxloader.TmxImage;
34
+import im.bci.tmxloader.TmxLoader;
35
+import im.bci.tmxloader.TmxMap;
36
+import im.bci.tmxloader.TmxTile;
37
+import im.bci.tmxloader.TmxTileInstance;
38
+import im.bci.tmxloader.TmxTileset;
39
+import java.util.HashMap;
40
+import java.util.HashSet;
41
+import java.util.Random;
42
+import java.util.logging.Level;
43
+import java.util.logging.Logger;
44
+import org.geekygoblin.nedetlesmaki.core.AbstractStartGameTrigger;
45
+import org.geekygoblin.nedetlesmaki.core.IAssets;
46
+import org.geekygoblin.nedetlesmaki.core.NamedEntities;
47
+import org.geekygoblin.nedetlesmaki.core.NedGame;
48
+import org.geekygoblin.nedetlesmaki.core.manager.EntityIndexManager;
49
+import org.geekygoblin.nedetlesmaki.core.utils.MoveStory;
50
+import org.geekygoblin.nedetlesmaki.playn.core.systems.PlaynSpriteSystem;
51
+import playn.core.Image;
52
+import playn.core.PlayN;
53
+import playn.core.util.Callback;
54
+
55
+/**
56
+ *
57
+ * @author devnewton natir
58
+ */
59
+public class PlaynStartGameTrigger extends AbstractStartGameTrigger {
60
+
61
+    private static final Logger LOGGER = Logger.getLogger(PlaynStartGameTrigger.class.getName());
62
+    private final HashMap<TmxTileInstance, IAnimationCollection> tileAnimations = new HashMap<TmxTileInstance, IAnimationCollection>();
63
+
64
+   public PlaynStartGameTrigger(IAssets assets, @NamedEntities.MainMenu Entity mainMenu, @NamedEntities.InGameUI Entity inGameUI, @NamedEntities.IngameControls Entity ingameControls, EntityIndexManager indexSystem, MoveStory moveStory, Random random) {
65
+        super(assets, mainMenu, inGameUI, ingameControls, indexSystem, random, moveStory);
66
+    }
67
+
68
+    @Override
69
+    protected State load(NedGame game) {
70
+        if (null == map) {
71
+            map = new TmxMap();
72
+            final TmxLoader loader = new TmxLoader();
73
+            final String tmxFile = levelName;
74
+            final String tmxDir = tmxFile.substring(0, tmxFile.lastIndexOf("/"));
75
+            final String tsxDir = tmxDir.substring(0, tmxDir.lastIndexOf("/"));
76
+            PlayN.assets().getText(tmxFile, new Callback<String>() {
77
+                @Override
78
+                public void onSuccess(String result) {
79
+                    loader.parseTmx(map, result);
80
+                    loadNextTileset();
81
+                }
82
+
83
+                @Override
84
+                public void onFailure(Throwable cause) {
85
+                    LOGGER.log(Level.SEVERE, "Cannot load " + tmxFile, cause);
86
+                }
87
+
88
+                private void loadNextTileset() {
89
+                    for (final TmxTileset tileset : map.getTilesets()) {
90
+                        if (!tileset.isReady() && null != tileset.getSource()) {
91
+                            //TODO real path resolve...
92
+                            final String tsxFile = tsxDir + "/" + tileset.getSource().replaceAll("../", "");
93
+                            PlayN.assets().getText(tsxFile, new Callback<String>() {
94
+
95
+                                @Override
96
+                                public void onSuccess(String result) {
97
+                                    loader.parseTsx(map, tileset, result);
98
+                                    HashSet<TmxImage> imagesWithSourceAdjusted = new HashSet<TmxImage>();
99
+                                    for (TmxTile tile : tileset.getTiles()) {
100
+                                        final TmxImage image = tile.getFrame().getImage();
101
+                                        if(!imagesWithSourceAdjusted.contains(image)) {
102
+                                            image.setSource(tsxDir + "/" + tile.getFrame().getImage().getSource());
103
+                                            imagesWithSourceAdjusted.add(image);
104
+                                        }
105
+                                    }
106
+                                    loadNextTileset();
107
+                                }
108
+
109
+                                @Override
110
+                                public void onFailure(Throwable cause) {
111
+                                    LOGGER.log(Level.SEVERE, "Cannot load " + tsxFile, cause);
112
+                                }
113
+                            });
114
+                            return;
115
+                        }
116
+                    }
117
+                    loader.decode(map);
118
+                }
119
+            });
120
+        }
121
+        if (map.isReady()) {
122
+            return State.BUILD;
123
+        } else {
124
+            return State.LOAD;
125
+        }
126
+    }
127
+
128
+    @Override
129
+    protected IAnimationCollection getTileAnimationCollection(TmxTileInstance tile) {
130
+        IAnimationCollection animationCollection = tileAnimations.get(tile);
131
+        if (null == animationCollection) {
132
+            animationCollection = createAnimationFromTile(tile);
133
+            tileAnimations.put(tile, animationCollection);
134
+        }
135
+        return animationCollection;
136
+    }
137
+
138
+    @Override
139
+    protected void createProjector(NedGame game) {
140
+        final float tileWidth = map.getTilewidth();
141
+        final float tileHeight = map.getTileheight();
142
+        final SpriteProjector spriteProjector = new IsometricSpriteProjector(tileWidth, tileHeight);
143
+        //final SpriteProjector spriteProjector = new OrthogonalSpriteProjector(tileWidth, tileHeight);
144
+        game.getSystem(PlaynSpriteSystem.class).setSpriteProjector(spriteProjector);
145
+    }
146
+
147
+    private IAnimationCollection createAnimationFromTile(TmxTileInstance tile) {
148
+        TmxFrame frame = tile.getFrame();
149
+        Image.Region image = PlayN.assets().getImage(frame.getImage().getSource()).subImage(frame.getX1(), frame.getY1(), frame.getX2() - frame.getX1(), frame.getY2() - frame.getY1());
150
+        PlaynAnimationCollection collection = new PlaynAnimationCollection();
151
+        PlaynAnimation animation = new PlaynAnimation("default");
152
+        animation.addFrame(new PlaynAnimationImage(image), 1000000);
153
+        collection.addAnimation(animation);
154
+        collection.setReady(true);
155
+        return collection;
156
+    }
157
+}
0 158
new file mode 100644
... ...
@@ -0,0 +1,74 @@
0
+/*
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 devnewton <devnewton@bci.im>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+ */
23
+package org.geekygoblin.nedetlesmaki.playn.core.systems;
24
+
25
+import com.artemis.ComponentMapper;
26
+import com.artemis.Entity;
27
+import im.bci.jnuit.playn.PlaynNuitRenderer;
28
+
29
+import org.geekygoblin.nedetlesmaki.core.systems.DialogSystem;
30
+import org.geekygoblin.nedetlesmaki.playn.core.components.ui.PlaynLayerOwner;
31
+import playn.core.ImmediateLayer;
32
+import playn.core.PlayN;
33
+import playn.core.Surface;
34
+
35
+/**
36
+ *
37
+ * @author devnewton
38
+ */
39
+public class PlaynDialogSystem extends DialogSystem {
40
+
41
+    private final PlaynNuitRenderer nuitRenderer;
42
+    private ComponentMapper<PlaynLayerOwner> layerOwnerMapper;
43
+
44
+    public PlaynDialogSystem(PlaynNuitRenderer nuitRenderer) {
45
+        this.nuitRenderer = nuitRenderer;
46
+    }
47
+
48
+    
49
+    @Override
50
+    protected void initialize() {
51
+        super.initialize();
52
+    layerOwnerMapper = world.getMapper(PlaynLayerOwner.class);
53
+    }
54
+
55
+    @Override
56
+    protected void inserted(final Entity e) {
57
+        ImmediateLayer layer = PlayN.graphics().createImmediateLayer(PlayN.graphics().width(), PlayN.graphics().height(), new ImmediateLayer.Renderer() {
58
+
59
+            @Override
60
+            public void render(Surface surface) {
61
+                nuitRenderer.setSurface(surface);
62
+                nuitRenderer.render(dialogMapper.get(e).getRoot());
63
+            }
64
+        });
65
+        e.addComponent(new PlaynLayerOwner(layer));
66
+        PlayN.graphics().rootLayer().add(layer);
67
+    }
68
+
69
+    @Override
70
+    protected void removed(Entity e) {
71
+        PlayN.graphics().rootLayer().remove(layerOwnerMapper.get(e).getLayer());
72
+    }
73
+}
0 74
new file mode 100644
... ...
@@ -0,0 +1,86 @@
0
+/*
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 devnewton <devnewton@bci.im>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+ */
23
+package org.geekygoblin.nedetlesmaki.playn.core.systems;
24
+
25
+import com.artemis.Aspect;
26
+import com.artemis.ComponentMapper;
27
+import com.artemis.Entity;
28
+
29
+import com.artemis.systems.EntityProcessingSystem;
30
+import im.bci.jnuit.playn.PlaynNuitRenderer;
31
+import org.geekygoblin.nedetlesmaki.core.components.ui.InGameUI;
32
+import org.geekygoblin.nedetlesmaki.playn.core.components.ui.PlaynLayerOwner;
33
+import playn.core.ImmediateLayer;
34
+import playn.core.PlayN;
35
+import playn.core.Surface;
36
+
37
+/**
38
+ *
39
+ * @author devnewton <devnewton@bci.im>
40
+ */
41
+public class PlaynInGameUISystem extends EntityProcessingSystem {
42
+
43
+    private final PlaynNuitRenderer nuitRenderer;
44
+
45
+    private ComponentMapper<PlaynLayerOwner> layerOwnerMapper;