Skip to content

Commit

Permalink
Merge pull request #4 from DiamondPRO02/selfCSVread
Browse files Browse the repository at this point in the history
removed csv library
  • Loading branch information
DiamondCoder02 authored Nov 16, 2023
2 parents 50043b0 + 733d81d commit df3017b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 34 deletions.
Binary file modified builds/HentaiGameManager.exe
Binary file not shown.
Binary file modified builds/HentaiGameManager.jar
Binary file not shown.
Binary file removed libs/commons-lang3-3.13.0.jar
Binary file not shown.
Binary file removed libs/opencsv-5.8.jar
Binary file not shown.
60 changes: 26 additions & 34 deletions src/main/langLoad.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package main;

import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.FileReader;

import javax.swing.JOptionPane;

import com.opencsv.CSVParserBuilder;
import com.opencsv.CSVReader;
import com.opencsv.CSVReaderBuilder;

import folderHandle.loadSaveGamesSettings.loadSettingsFromXml;

public class langLoad {
Expand All @@ -17,42 +13,37 @@ public class langLoad {
tempjLaPa = new String[30], tempjRaBu = new String[30], tempbuton = new String[30], tempFold = new String[30],
tempSear = new String[30], tempRand = new String[30];
public static String[] base, basic, tabl, jlapa, jrabu, buton, folder, serc, rand;
private static CSVReader reader = null;
public static String[] langChoices, lanMeans;

public static void loadLanguages() {
for (int i = 0; i < 30; i++) {
tempBase[i] = null; tempBasic[i] = null; tempTabl[i] = null; tempjLaPa[i] = null;
tempjRaBu[i] = null; tempbuton[i] = null; tempFold[i] = null; tempSear[i] = null;
tempRand[i] = null;
}
String language = loadSettingsFromXml.loadStringSettings("language")[0];
Integer temp = 0;
String lastLang = "", split = ";", langFromConfig = "english";
String[] tempAr = new String[30];
int langindex = 0;
BufferedReader br = null;

try {
// parsing a CSV file into CSVReader class constructor
reader = new CSVReaderBuilder(
new InputStreamReader( new FileInputStream(path+"language.csv"), "utf-8")
).withCSVParser( new CSVParserBuilder().withSeparator(';').build()).build();
// parsing a CSV file into BufferedReader class constructor
br = new BufferedReader(new FileReader(path+"language.csv"));
} catch (Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Error loading language csv (loadLanguages)", "Error", JOptionPane.ERROR_MESSAGE);
return;
JOptionPane.showMessageDialog(null, "Error language file (loadLanguages)", "Error", JOptionPane.ERROR_MESSAGE);
}
if (language == null || reader == null) { return; }
try {
String[] nextLine = reader.readNext();
langChoices = new String[nextLine.length-1];
lanMeans = new String[nextLine.length-1];
// first line is the language names
int langindex = 0;
for (int i = 0; i < nextLine.length; i++) { if (nextLine[i].equals(language)) { langindex = i; break; } }
if (br == null) { return; }
try{
langFromConfig = loadSettingsFromXml.loadStringSettings("language")[0];
String[] languages = br.readLine().split(split);// first line is the language names
lanMeans = new String[languages.length-1];
langChoices = new String[languages.length-1];
for (int i = 0; i < languages.length; i++) { if (languages[i].equals(langFromConfig)) { langindex = i; break; } }
if (langindex == 0) { langindex = 1; }
for (int i = 0; i < (nextLine.length-1); i++) { langChoices[i] = nextLine[i+1]; }
nextLine = reader.readNext();
for (int i = 0; i < (nextLine.length-1); i++) { lanMeans[i] = nextLine[i+1]; }
// System.out.println("Currently has " +(nextLine.length-1)+ " languages, choosen: "+nextLine[langindex]);
Integer temp = 0; String lastLang = "";
String[] tempAr = new String[30];
while ((nextLine = reader.readNext()) != null) {
for (int i = 0; i < (languages.length-1); i++) { langChoices[i] = languages[i+1]; }
languages = br.readLine().split(split); // Second line is language in own language
for (int i = 0; i < (languages.length-1); i++) { lanMeans[i] = languages[i+1]; }

String line = "";
while ((line = br.readLine()) != null) { // returns a Boolean value
String[] nextLine = line.split(split); // use comma as separator
if (!lastLang.equals(nextLine[0])) {
lastLang = nextLine[0];
temp = 0;
Expand All @@ -77,6 +68,7 @@ public static void loadLanguages() {
base = tempBase; basic = tempBasic; tabl = tempTabl; jlapa = tempjLaPa;
jrabu = tempjRaBu; buton = tempbuton; folder = tempFold; serc = tempSear;
rand = tempRand;
br.close();
return;
} catch (Exception e) {
e.printStackTrace();
Expand Down

0 comments on commit df3017b

Please sign in to comment.