one.empty3.library.Config Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of empty3-library-3d Show documentation
Show all versions of empty3-library-3d Show documentation
3D rendering engine. Plus modelling. Expected glsl textures 3d and 2d rendering3D primitives, and a lot of scenes' samples to test.+ Game Jogl reworked, Calculator (numbers and vectors). Java code parser implementation starts (<=1.2)
The newest version!
/*
*
* * Copyright (c) 2024. Manuel Daniel Dahmen
* *
* *
* * Copyright 2024 Manuel Daniel Dahmen
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*
*/
package one.empty3.library;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
public class Config {
public static final int DIR_TMP = 0;
public static final int DIR_TEST_OUTPUT = 1;
public static final int DIR_MODELS = 2;
public static final int DIR_TEXTURES = 3;
private File fileDirectoryDefault;
private File file1;
protected Map map = new HashMap();
public Config() {
initIfEmpty();
}
public boolean initIfEmpty() {
Properties p = new Properties();
Reader reader = null;
file1 = new File(System.getProperty("user.home") + File.separator + "empty3.config");
if (!file1.exists()) {
if (!file1.exists()) {
createConfig();
}
}
try {
reader = new FileReader(file1);
p.load(reader);
for (Object key : p.keySet()) {
String value = p.get(key).toString();
map.put((String) key, value);
// if is file reference..
if (key.equals("path")) {
fileDirectoryDefault = new File(value);
File path = fileDirectoryDefault.getParentFile();
//if (path.exists() || path.mkdir()) {
//} else {
// System.err.println("Failed to make/find directory for " + path);
// return false;
//}
}
}
} catch (IOException exp) {
return false;
}
return false;
}
public boolean createConfig() {
if (!file1.exists()) {
try {
file1.createNewFile();
PrintWriter pw = new PrintWriter(file1);
pw.println("folderoutput=c\\" + System.getProperty("user.home") + "\\EmptyCanvasTest");
pw.println("path=" + System.getProperty("user.home") + "\\EmptyCanvasTest");
pw.close();
return true;
} catch (IOException ex) {
return false;
}
} else return true;
}
public String allDefaultStrings() {
StringBuilder sb = new StringBuilder();
sb.append("folder.samples=");
return sb.toString();
}
public File[] dirs(int type) {
return new File[0];
}
public File getFileDirectoryDefault() {
return fileDirectoryDefault;
}
public void setFileDirectoryDefault(File fileDirectoryDefault) {
this.fileDirectoryDefault = fileDirectoryDefault;
}
public String getDefaultCodeVecMesh() {
String s = getFileDirectoryDefault() + File.separator + "defaultCode.calcmath";
System.out.println(s);
return s;
}
public Map getMap() {
return map;
}
}