Skip to content

Commit

Permalink
Updated Cybernize
Browse files Browse the repository at this point in the history
Add support for ArchiveItem
  • Loading branch information
zpiddock committed Sep 13, 2020
1 parent ca23275 commit 94c10db
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Cybernize
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ repositories {

dependencies {

implementation 'uk.co.innoxium.cybernize:cybernize:1.1.3'
implementation 'uk.co.innoxium.cybernize:cybernize:1.1.4'
implementation 'com.electronwill.night-config:toml:3.6.3'
implementation 'com.miglayout:miglayout:3.7.4'
implementation 'com.google.code.gson:gson:2.8.6'
Expand Down Expand Up @@ -178,7 +178,7 @@ publishing {
artifact javadocJar
groupId 'uk.co.innoxium.candor'
artifactId 'candor-api'
version '0.2.0'
version '0.2.1'
}
}
}
Expand All @@ -204,7 +204,7 @@ bintray {
licenses = ['MIT']
version {

name = '0.2.0'
name = '0.2.1'
desc = 'This release marks a huge step forward in terms of UX and presentation.'
released = new Date()
}
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/uk/co/innoxium/candor/mod/Mod.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import uk.co.innoxium.candor.util.Utils;
import uk.co.innoxium.cybernize.archive.Archive;
import uk.co.innoxium.cybernize.archive.ArchiveBuilder;
import uk.co.innoxium.cybernize.archive.ArchiveItem;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -75,13 +76,13 @@ public static Mod fromFile(File file) {
Archive archive = new ArchiveBuilder(file).build();
try {

for(String filePath : archive.getAllArchiveItems()) {
for(ArchiveItem archiveItem : archive.getAllArchiveItems()) {

// TODO: Add exclude critical folders
if(!ModuleSelector.currentModule.isCritical(filePath)) {
if(!ModuleSelector.currentModule.isCritical(archiveItem)) {

System.out.println(filePath);
array.add(filePath);
System.out.println(archiveItem);
array.add(archiveItem.getFilePath());
}
}
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package uk.co.innoxium.candor.module;

import uk.co.innoxium.cybernize.archive.ArchiveItem;

import java.io.File;

public abstract class AbstractModule {
Expand Down Expand Up @@ -44,7 +46,7 @@ public boolean getEnableExtractOption() {

public abstract RunConfig getDefaultRunConfig();

public boolean isCritical(String filePath) {
public boolean isCritical(ArchiveItem archiveItem) {

return false;
}
Expand Down
46 changes: 22 additions & 24 deletions src/main/java/uk/co/innoxium/candor/module/ModuleSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private static void instanceGenericModule() {
}
}

public static AbstractModule getModuleForGame(String gameExe) {
public static AbstractModule getModuleForGame(String gameExe, boolean showWarning) {

File file = new File(gameExe);
String gameString = file.getName().substring(0, file.getName().indexOf("."));
Expand All @@ -85,8 +85,8 @@ public static AbstractModule getModuleForGame(String gameExe) {

for(String s : module.acceptedExe()) {

System.out.println(s);
System.out.println(gameString);
// System.out.println(s);
// System.out.println(gameString);
if(s.equalsIgnoreCase(gameString)) {

System.out.println("Module is " + module.getModuleName());
Expand All @@ -95,38 +95,36 @@ public static AbstractModule getModuleForGame(String gameExe) {
}
}
}
if(showWarning) {

Dialogs.showInfoDialog(
"Candor Mod Manager",
"Warning, No module was found for this game.\n" +
"Defaulting to Generic Module, this may have unforseen consequences.\n" +
"For more information, please visit https://innoxium.co.uk/candor/modules",
"ok",
"warning",
true
);
}
System.out.println("Module is " + GENERIC_MODULE.getModuleName());
currentModule = GENERIC_MODULE;
return GENERIC_MODULE;
}

public static AbstractModule getModuleForGame(Game game) {
public static AbstractModule getModuleForGame(Game game, boolean showWarning) {

return getModuleForGame(game.getGameExe());
return getModuleForGame(game.getGameExe(), showWarning);
}

// Please use getModuleForGame(Game game)
@Deprecated(forRemoval = true)
public static AbstractModule getModuleForGame(File gameExe) {

for (AbstractModule module : MODULES) {
public static AbstractModule getModuleForGame(Game game) {

for(String s : module.acceptedExe()) {
return getModuleForGame(game.getGameExe(), false);
}

String gameString = gameExe.getName().substring(0, gameExe.getName().indexOf("."));
System.out.println(s);
System.out.println(gameString);
if(s.equalsIgnoreCase(gameString)) {
public static AbstractModule getModuleForGame(String gameExe) {

System.out.println("Module is " + module.getModuleName());
currentModule = module;
return module;
}
}
}
System.out.println("Module is " + GENERIC_MODULE.getModuleName());
currentModule = GENERIC_MODULE;
return GENERIC_MODULE;
return getModuleForGame(gameExe, false);
}

public static void checkGenericModule() throws IOException {
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/uk/co/innoxium/candor/window/EntryScene.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import uk.co.innoxium.candor.Settings;
import uk.co.innoxium.candor.game.Game;
import uk.co.innoxium.candor.game.GamesList;
import uk.co.innoxium.candor.module.AbstractModule;
import uk.co.innoxium.candor.module.ModuleSelector;
import uk.co.innoxium.candor.util.Utils;
import uk.co.innoxium.candor.util.WindowUtils;
import uk.co.innoxium.cybernize.util.ClassLoadUtil;
Expand Down Expand Up @@ -47,7 +45,7 @@ private void loadGameClicked(ActionEvent e) {
Settings.showIntro = false;
}
Settings.lastGameUuid = game.getUUID().toString();
AbstractModule module = ModuleSelector.getModuleForGame(game.getGameExe());
// AbstractModule module = ModuleSelector.getModuleForGame(game.getGameExe(), true);
WindowUtils.setupModScene(game);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private void gameExeClicked(ActionEvent e) {
try {

gameField.setText(gameExe.getCanonicalPath());
AbstractModule module = ModuleSelector.getModuleForGame(gameExe.getCanonicalPath());
AbstractModule module = ModuleSelector.getModuleForGame(gameExe.getCanonicalPath(), true);
if(module.requiresModFolderSelection()) {

modFolderField.setEnabled(true);
Expand Down

0 comments on commit 94c10db

Please sign in to comment.