Skip to content

Commit

Permalink
Fixed bug, simplified installation, updated Readme, enabled AoT again
Browse files Browse the repository at this point in the history
  • Loading branch information
deathkiller committed Mar 9, 2019
1 parent c01f914 commit e5a273d
Show file tree
Hide file tree
Showing 40 changed files with 61 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
},

"Animations": {
"SpikeBall": {
"Platform": {
"Path": "Object/3d_spike.png"
},
"Chain": {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions Jazz2.Android/CrashHandlerActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,6 @@ private async void SendReportAsync()
string deviceId;
try {
deviceId = Settings.Secure.GetString(ContentResolver, Settings.Secure.AndroidId);
if (string.IsNullOrWhiteSpace(deviceId) && Build.Serial != null) {
deviceId = Build.Serial;
}
if (string.IsNullOrWhiteSpace(deviceId)) {
deviceId = "";
}
Expand Down
5 changes: 5 additions & 0 deletions Jazz2.Android/InnerView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Platform.Android;
using ContentResolver = Jazz2.Game.ContentResolver;
using INativeWindow = Duality.Backend.INativeWindow;
using Vector2 = Duality.Vector2;

Expand Down Expand Up @@ -35,9 +36,13 @@ protected override void OnLoad(EventArgs e)
// ToDo: Create Android-specific AssemblyLoader
DualityApp.Init(DualityApp.ExecutionContext.Game, /*new DefaultAssemblyLoader()*/null, null);

ContentResolver.Current.Init();

DualityApp.WindowSize = new Point2(viewportWidth, viewportHeight);
INativeWindow window = DualityApp.OpenWindow(new WindowOptions());

ContentResolver.Current.InitPostWindow();

FocusableInTouchMode = true;
RequestFocus();

Expand Down
2 changes: 1 addition & 1 deletion Jazz2.Android/Jazz2.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<AndroidLinkMode>Full</AndroidLinkMode>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AotAssemblies>false</AotAssemblies>
<AotAssemblies>true</AotAssemblies>
<EnableLLVM>true</EnableLLVM>
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
<EnableProguard>true</EnableProguard>
Expand Down
2 changes: 1 addition & 1 deletion Jazz2.Android/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private void TryInit()
}

if (!File.Exists(Path.Combine(rootPath, "Content", "Main.dz"))) {
ShowInfoScreen("Content files not found", "Content should be placed in&nbsp;" + rootPath.Substring(0, storagePathLength) + "<b><u>" + rootPath.Substring(storagePathLength) + "Content/</u></b>…<br>It includes <b>Main.dz</b> file and <b>Episodes</b>, <b>Internal</b>, <b>Music</b>, <b>Shaders</b>, <b>Tilesets</b> directories.");
ShowInfoScreen("Content files not found", "Content should be placed in&nbsp;" + rootPath.Substring(0, storagePathLength) + "<b><u>" + rootPath.Substring(storagePathLength) + "Content/</u></b>…<br>It includes <b>Main.dz</b> file and <b>Episodes</b>, <b>Music</b>, <b>Tilesets</b> directories.");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion Jazz2.Android/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="jazz2.android" android:versionName="0.5.4" android:installLocation="auto" android:versionCode="540">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="jazz2.android" android:versionName="0.5.5" android:installLocation="auto" android:versionCode="550">
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Expand Down
6 changes: 3 additions & 3 deletions Jazz2.Core/Actors/Solid/SpikeBall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public override void OnAttach(ActorInstantiationDetails details)
collisionFlags = CollisionFlags.CollideWithOtherActors;
canBeFrozen = false;

RequestMetadata("Object/SpikeBall");
SetAnimation("SpikeBall");
RequestMetadata("MovingPlatform/SpikeBall");
SetAnimation("Platform");

pieces = new ChainPiece[length];
for (int i = 0; i < length; i++) {
Expand Down Expand Up @@ -135,7 +135,7 @@ public ChainPiece(ActorApi api, Vector3 pos, int distance)

collisionFlags = CollisionFlags.None;

RequestMetadata("Object/SpikeBall");
RequestMetadata("MovingPlatform/SpikeBall");
SetAnimation("Chain");
}

Expand Down
11 changes: 10 additions & 1 deletion Jazz2.Core/Game/ContentResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ public static ContentResolver Current
public ContentRef<Texture> DefaultNormalMap => defaultNormalMap;

private ContentResolver()
{
}

public void Init()
{
jsonParser = new JsonParser();
imageCodec = ImageCodec.GetRead(ImageCodec.FormatPng);
Expand All @@ -104,7 +108,10 @@ private ContentResolver()
string dz = PathOp.Combine(DualityApp.DataDirectory, "Main.dz");
PathOp.Mount(dz, new CompressedContent(dz));
#endif
}

public void InitPostWindow()
{
defaultNormalMap = new Texture(new Pixmap(new PixelData(2, 2, new ColorRgba(0.5f, 0.5f, 1f))), TextureSizeMode.Default, TextureMagFilter.Nearest, TextureMinFilter.Nearest);
defaultNormalMap.Res.DetachPixmap();

Expand Down Expand Up @@ -505,8 +512,10 @@ public ContentRef<DrawTechnique> RequestShader(string path)
if (!cachedShaders.TryGetValue(path, out shader)) {
// Shaders for Android are always uncompressed for now, so the compressed
// content package can be used in Android version as well.
#if UNCOMPRESSED_CONTENT || __ANDROID__
#if UNCOMPRESSED_CONTENT
string pathAbsolute = PathOp.Combine(DualityApp.DataDirectory, "Shaders", path + ".res");
#elif __ANDROID__
string pathAbsolute = PathOp.Combine(DualityApp.DataDirectory, "Main.dz", "Shaders.ES30", path + ".res");
#else
string pathAbsolute = PathOp.Combine(DualityApp.DataDirectory, "Main.dz", "Shaders", path + ".res");
#endif
Expand Down
20 changes: 9 additions & 11 deletions Jazz2.Core/Misc/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,30 @@ public static void CheckUpdates(CheckUpdatesCallback callback)
#if __ANDROID__
try {
deviceId = global::Android.Provider.Settings.Secure.GetString(Android.MainActivity.Current.ContentResolver, global::Android.Provider.Settings.Secure.AndroidId);
if (string.IsNullOrWhiteSpace(deviceId) && global::Android.OS.Build.Serial != null) {
deviceId = global::Android.OS.Build.Serial;
}
if (!string.IsNullOrWhiteSpace(deviceId)) {
deviceId = System.Convert.ToBase64String(Encoding.UTF8.GetBytes(deviceId))
.Replace('+', '-').Replace('/', '_').TrimEnd('=');
} else {
if (deviceId == null) {
deviceId = "";
}
} catch {
deviceId = "";
}

deviceId += "|Android " + global::Android.OS.Build.VERSION.Release;
#else
try {
deviceId = System.Environment.MachineName;
if (!string.IsNullOrWhiteSpace(deviceId)) {
deviceId = System.Convert.ToBase64String(Encoding.UTF8.GetBytes(deviceId))
.Replace('+', '-').Replace('/', '_').TrimEnd('=');
} else {
if (deviceId == null) {
deviceId = "";
}
} catch {
deviceId = "";
}

deviceId += "|" + System.Environment.OSVersion.ToString();
#endif

deviceId = System.Convert.ToBase64String(Encoding.UTF8.GetBytes(deviceId))
.Replace('+', '-').Replace('/', '_').TrimEnd('=');

try {
string currentVersion = App.AssemblyVersion;

Expand Down
4 changes: 4 additions & 0 deletions Jazz2/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,16 @@ private static void Main(string[] args)
case 1: newScreenMode = ScreenMode.FullWindow; break;
}

ContentResolver.Current.Init();

using (INativeWindow window = DualityApp.OpenWindow(new WindowOptions {
Title = AssemblyTitle,
RefreshMode = (args.Contains("/nv") ? RefreshMode.NoSync : (args.Contains("/mv") ? RefreshMode.ManualSync : RefreshMode.VSync)),
Size = LevelRenderSetup.TargetSize,
ScreenMode = newScreenMode
})) {
ContentResolver.Current.InitPostWindow();

current = new App(window);
current.ShowMainMenu();
window.Run();
Expand Down
4 changes: 2 additions & 2 deletions Jazz2/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.4.0")]
[assembly: AssemblyFileVersion("0.5.4.0")]
[assembly: AssemblyVersion("0.5.5.0")]
[assembly: AssemblyFileVersion("0.5.5.0")]

[assembly: InternalsVisibleTo("Editor")]
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ Requires [Microsoft Visual Studio 2017](https://www.visualstudio.com/) or newer
* Build the solution (or download release from GitHub)
* Run `‹Game›/Import.exe "Path to JJ2"` (or drag and drop JJ2 directory on `Import.exe`)
* Copy `‹Game›/Content` directory to `‹SDCard›/jazz2.android/Content`
* Copy files from `Jazz2.Android/Shaders` directory to `‹SDCard›/jazz2.android/Content/Shaders`
* Copy files from `Jazz2.Android/Shaders/Internal` directory to `‹SDCard›/jazz2.android/Content/Internal`
* *Create empty file `.nomedia` in `‹SDCard›/jazz2.android` to hide game files in Android Gallery (optimal)*
* <small>*Create empty file `.nomedia` in `‹SDCard›/jazz2.android` to hide game files in Android Gallery (optimal)*</small>
* Install APK file on Android
* Run the application

Expand Down Expand Up @@ -115,7 +113,7 @@ Requires [Microsoft Visual Studio 2017](https://www.visualstudio.com/) or newer
### OpenGL ES 2.0
Alternative OpenGL ES 2.0 backend can be built separately. It does not contain all features
that are available in default OpenGL 2.1 backend, but it should run faster on low-end configurations.
<span style="color:#a22;">Don't use it if you have no reason to do so!</span>
<span color="#aa2222">Don't use it if you have no reason to do so!</span>

To use it, build `Extensions/Es20Backend` project. The library will be copied to
`/Jazz2/Bin/Debug/Extensions/Es20Backend.core.dll` automatically.
Expand Down
9 changes: 8 additions & 1 deletion Shared/Duality/DefaultContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ public static void Dispose()
public static void InitType<T>(string nameExt, Func<Stream, T> resourceCreator) where T : Resource
{
InitType<T>(name => {
using (Stream stream = FileOp.Open(PathOp.Combine(DualityApp.DataDirectory, "Internal", name + nameExt), FileAccessMode.Read)) {
#if UNCOMPRESSED_CONTENT
string path = PathOp.Combine(DualityApp.DataDirectory, "Shaders", name + nameExt);
#elif __ANDROID__
string path = PathOp.Combine(DualityApp.DataDirectory, "Main.dz", "Shaders.ES30", name + nameExt);
#else
string path = PathOp.Combine(DualityApp.DataDirectory, "Main.dz", "Shaders", name + nameExt);
#endif
using (Stream stream = FileOp.Open(path, FileAccessMode.Read)) {
return resourceCreator(stream);
}
});
Expand Down
12 changes: 12 additions & 0 deletions Tools/Import/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,10 @@ private static void CreateMinimalCompressedContent(string targetPath)
tree.GetContentFromDirectory(Path.Combine(targetPath, "Content", "Shaders"));
}

if (Directory.Exists(Path.Combine(targetPath, "Content", "Shaders.ES30"))) {
tree.GetContentFromDirectory(Path.Combine(targetPath, "Content", "Shaders.ES30"));
}

Log.PopIndent();
Log.Write(LogType.Info, "Saving changes...");

Expand Down Expand Up @@ -1107,6 +1111,10 @@ private static void MergeToCompressedContent(string targetPath, bool keep)
tree.GetContentFromDirectory(Path.Combine(targetPath, "Content", "Shaders"));
}

if (Directory.Exists(Path.Combine(targetPath, "Content", "Shaders.ES30"))) {
tree.GetContentFromDirectory(Path.Combine(targetPath, "Content", "Shaders.ES30"));
}

Log.Write(LogType.Info, "Saving changes...");

tree.RemoveEmptyNodes();
Expand Down Expand Up @@ -1142,6 +1150,10 @@ private static void MergeToCompressedContent(string targetPath, bool keep)
if (Directory.Exists(Path.Combine(targetPath, "Content", "Shaders"))) {
Directory.Delete(Path.Combine(targetPath, "Content", "Shaders"), true);
}

if (Directory.Exists(Path.Combine(targetPath, "Content", "Shaders.ES30"))) {
Directory.Delete(Path.Combine(targetPath, "Content", "Shaders.ES30"), true);
}
}

Log.PopIndent();
Expand Down
4 changes: 2 additions & 2 deletions Tools/Import/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Můžete zadat všechny hodnoty nebo nastavit výchozí číslo buildu a revize pomocí *, jak je vidět níže:
// pomocí zástupného znaku * takto:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.4.0")]
[assembly: AssemblyFileVersion("0.5.4.0")]
[assembly: AssemblyVersion("0.5.5.0")]
[assembly: AssemblyFileVersion("0.5.5.0")]

0 comments on commit e5a273d

Please sign in to comment.