Skip to content

Commit

Permalink
save game implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
msx80 committed Aug 27, 2024
1 parent 103a9b4 commit 88dd15a
Show file tree
Hide file tree
Showing 9 changed files with 269 additions and 429 deletions.
2 changes: 1 addition & 1 deletion android-mvn/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<dependency>
<groupId>com.github.msx80.omicron</groupId>
<artifactId>omicron-engine</artifactId>
<version>0.0.4</version>
<version>0.0.5</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.github.msx80.omicron.AndroidPlugin;
import com.github.msx80.omicron.HardwareInterface;
import com.github.msx80.omicron.api.Game;
import com.github.msx80.omicron.api.Sys;
import com.github.msx80.omicron.api.adv.*;
import com.github.msx80.omicron.fantasyconsole.cartridges.*;
import java.util.Properties;
Expand All @@ -27,7 +28,10 @@ public class AndroidLauncher extends AndroidApplication implements HardwareInter
private byte[] bytesToSave = null;
private Consumer<String> fileResult = null;

//AndroidPlugin plugin = new NfcAndroidPlugin();

private Sys sys;

PluginManager plugins = new PluginManager(this);

@Override
protected void onCreate (Bundle savedInstanceState) {
Expand Down Expand Up @@ -59,30 +63,54 @@ protected void onCreate (Bundle savedInstanceState) {
}

AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
initialize(new GdxOmicron(c, this), config);
GdxOmicron go = new GdxOmicron(c, this);
sys = go;
initialize(go, config);
}


/*
@Override
protected void onResume() {
super.onResume();
//plugin.onResume(this);
for(HardwarePlugin p : plugins.getPlugins())
{
if(p instanceof AndroidPlugin)
{
((AndroidPlugin)p).onResume(this);
}
}
}
@Override
protected void onPause() {
super.onPause();
//plugin.onPause(this);
for(HardwarePlugin p : plugins.getPlugins())
{
if(p instanceof AndroidPlugin)
{
((AndroidPlugin)p).onPause(this);
}
}
}*/


@Override
public void onNewIntent(Intent intent) {

//plugin.onNewIntent(this, intent);
super.onNewIntent(intent);
setIntent(intent);
for(HardwarePlugin p : plugins.getPlugins())
{
if(p instanceof AndroidPlugin)
{

boolean ok = ((AndroidPlugin)p).resolveIntent(intent);
if(ok) return;
}
}
}


/*
@Override
public void openUrl(String url) throws Exception {
Uri uri = Uri.parse( url );
Expand All @@ -92,16 +120,16 @@ public void openUrl(String url) throws Exception {
@Override
public void saveFile(String mimeType, String filename, byte[] content, Consumer<String> result) {
/*this.bytesToSave = content;
this.bytesToSave = content;
this.fileResult = result;
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType(mimeType); //not needed, but maybe usefull
intent.putExtra(Intent.EXTRA_TITLE, filename); //not needed, but maybe usefull
startActivityForResult(intent, SAVE_FILE);
*/
}

*/
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == SAVE_FILE ) {
Expand Down Expand Up @@ -140,12 +168,45 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {

public Object hardware(String module, String command, Object param)
{
return null;
return plugins.getPlugin(module).exec(command, param);
}


@Override public String[] startupArgs()
{
return new String[0];
}


@Override
public Sys getSys() {

return sys;
}

@Override
public void setSys(Sys sys) {
// not needed

}

@Override
public void gamePaused() {
for(HardwarePlugin p : plugins.getPlugins())
{
p.onPause();
}

}

@Override
public void gameRestored() {
for(HardwarePlugin p : plugins.getPlugins())
{
p.onResume();
}

}


}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
package com.github.msx80.omicron;

import android.os.Bundle;
import android.content.Context;
import android.app.Activity;
import android.content.Intent;

public interface AndroidPlugin
{

void onCreate (android.app.Activity ctx, Bundle savedInstanceState);

void onResume(android.app.Activity ctx);

void onPause(android.app.Activity ctx);

void onNewIntent(android.app.Activity ctx, Intent intent);

public interface AndroidPlugin extends HardwarePlugin{

boolean resolveIntent(Intent intent);

}

This file was deleted.

Loading

0 comments on commit 88dd15a

Please sign in to comment.