Skip to content

Commit

Permalink
Rename some references and remove references to deleted classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Novampr committed Oct 17, 2024
1 parent 4bd163c commit 753674c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/main/java/org/lwjgl/glfw/CallbackBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.ArrayList;

import dalvik.annotation.optimization.CriticalNative;
import pojlib.UnityPlayerActivity;
import pojlib.Launcher;
import pojlib.input.GrabListener;
import pojlib.input.LwjglGlfwKeycode;

Expand Down Expand Up @@ -107,12 +107,12 @@ public static boolean isGrabbing() {
public static @Nullable String accessAndroidClipboard(int type, String copy) {
switch (type) {
case CLIPBOARD_COPY:
UnityPlayerActivity.GLOBAL_CLIPBOARD.setPrimaryClip(ClipData.newPlainText("Copy", copy));
Launcher.GLOBAL_CLIPBOARD.setPrimaryClip(ClipData.newPlainText("Copy", copy));
return null;

case CLIPBOARD_PASTE:
if (UnityPlayerActivity.GLOBAL_CLIPBOARD.hasPrimaryClip() && UnityPlayerActivity.GLOBAL_CLIPBOARD.getPrimaryClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
return UnityPlayerActivity.GLOBAL_CLIPBOARD.getPrimaryClip().getItemAt(0).getText().toString();
if (Launcher.GLOBAL_CLIPBOARD.hasPrimaryClip() && Launcher.GLOBAL_CLIPBOARD.getPrimaryClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
return Launcher.GLOBAL_CLIPBOARD.getPrimaryClip().getItemAt(0).getText().toString();
} else {
return "";
}
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/pojlib/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ public class API {
// Values to store for use in any external java files
public static String gameDir;

public static Activity getActivity() {
return activity;
}

private static Activity activity;

/**
* Launch the game
*
Expand Down Expand Up @@ -52,6 +58,7 @@ public static void startGame(
String[] mcAdditionalArgs,
String jvmHome
) {
API.activity = activity;
VLoader.setActivity(activity);

String[] mcArgs = {"--username", username, "--version", versionName, "--gameDir", gameDir,
Expand Down
17 changes: 5 additions & 12 deletions src/main/java/pojlib/input/gamepad/GamepadMapStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

import android.util.Log;

import com.google.gson.Gson;
import com.google.gson.JsonParseException;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;

import pojlib.API;
import pojlib.util.Constants;
import pojlib.util.FileUtil;
import pojlib.util.GsonUtils;

public class GamepadMapStore {
private static final File STORE_FILE = new File(Constants.USER_HOME, "gamepad_map.json");
private static final File STORE_FILE = new File(Constants.getFilesDir(API.getActivity()), "gamepad_map.json");
private static GamepadMapStore sMapStore;
private GamepadMap mInMenuMap;
private GamepadMap mInGameMap;
Expand All @@ -32,8 +33,7 @@ public static void load() {
GamepadMapStore mapStore = null;
if(STORE_FILE.exists() && STORE_FILE.canRead()) {
try {
String storeFileContent = FileUtil.read(STORE_FILE.getPath());
mapStore = GsonUtils.GLOBAL_GSON.fromJson(storeFileContent, GamepadMapStore.class);
mapStore = new Gson().fromJson(new FileReader(STORE_FILE), GamepadMapStore.class);
} catch (JsonParseException | IOException e) {
Log.w("GamepadMapStore", "Map store failed to load!", e);
}
Expand All @@ -42,13 +42,6 @@ public static void load() {
sMapStore = mapStore;
}

public static void save() throws IOException {
if(sMapStore == null) throw new RuntimeException("Must load map store first!");
FileUtil.ensureParentDirectory(STORE_FILE);
String jsonData = GsonUtils.GLOBAL_GSON.toJson(sMapStore);
FileUtil.write(STORE_FILE.getAbsolutePath(), jsonData.getBytes());
}

public static GamepadMap getGameMap() {
loadIfNecessary();
return sMapStore.mInGameMap;
Expand Down

0 comments on commit 753674c

Please sign in to comment.