Skip to content

Commit

Permalink
Rewrite somethings methods
Browse files Browse the repository at this point in the history
I'm change couple of items and rewrite all pathes for fixed PAPI.
  • Loading branch information
Mega4oSS committed Nov 3, 2024
1 parent 0438da3 commit e6476b3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Binary file modified libs/PlusicAPIAoh3-1.0-SNAPSHOT-all.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,27 @@
import aoc.kingdoms.lukasz.jakowski.setting.SettingsDesktop;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import ru.artem.alaverdyan.PlusicAPI;

import java.io.File;

public class PTCFG {
public static int screenMode = 2;
public static boolean fullscreenBorderless = false;
public static String pathToConfig = "";

static {
for (int i = 0; i < PlusicAPI.mods.size(); i++) {
if(PlusicAPI.mods.get(i).getName().equals("FullscreenBorderless")) {
pathToConfig = PlusicAPI.mods.get(i).getRoot() + File.separator + "settings" + File.separator + "Config.txt";
}
}
}

public static void readConfig() {
try {
if (Gdx.files.local("mods/FullscreenBorderless/settings/Config.txt").exists()) {
final FileHandle file = Gdx.files.local("mods/FullscreenBorderless/settings/Config.txt");
if (Gdx.files.absolute(pathToConfig).exists()) {
final FileHandle file = Gdx.files.absolute(pathToConfig);
final String tempTags = file.readString();
final String[] tSplited = tempTags.replace("\n", "").split(";");
for (int i = 0; i < tSplited.length; ++i) {
Expand Down Expand Up @@ -59,7 +71,7 @@ public static void saveConfig() {
int sMode = 0;
if(SettingsDesktop.fullscreen == true) sMode = 1;
if(fullscreenBorderless == true) sMode = 2;
final FileHandle fileSave = FileManager.getSaveType("mods/FullscreenBorderless/settings/Config.txt");
final FileHandle fileSave = Gdx.files.absolute(pathToConfig);
fileSave.writeString("SCREENMODE=" + sMode + ";\n", false);
fileSave.writeString("WIDTH=" + SettingsDesktop.iWidth + ";\n", true);
fileSave.writeString("HEIGHT=" + SettingsDesktop.iHeight + ";\n", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ public class PlusicTest2 {
@DirectInject
public static void directInject(CtClass cc) {
String code2 = "if(tempR[0].equals(\"SCREENMODE\")) {ru.artem.alaverdyan.fullscreenborderless.elements.PTCFG.screenMode = Integer.parseInt(tempR[1]);System.out.println(\"SCREENMODE: \" + ru.artem.alaverdyan.fullscreenborderless.elements.PTCFG.screenMode);}";
String code4 = "fr = new java.io.FileReader(\"mods/FullscreenBorderless/settings/Config.txt\");";
String code4 = "fr = new java.io.FileReader(ru.artem.alaverdyan.fullscreenborderless.elements.PTCFG.pathToConfig);";
String code5 = "System.out.println(ru.artem.alaverdyan.fullscreenborderless.elements.PTCFG.pathToConfig);";
try {
CtMethod method = cc.getDeclaredMethod("main");
method.insertAt(54, code4);
method.insertAt(54, code5);
method.insertAt(60, code2);
} catch (NotFoundException | CannotCompileException e) {
throw new RuntimeException(e);
Expand Down

0 comments on commit e6476b3

Please sign in to comment.