add fields to profile
This commit is contained in:
@@ -28,7 +28,7 @@ public class Main extends Application {
|
|||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) throws Exception {
|
public void start(Stage primaryStage) throws Exception {
|
||||||
SETTINGS = new Settings(new File("profile.properties"));
|
SETTINGS = new Settings(new File("profile.properties"));
|
||||||
SETTINGS.load();
|
SETTINGS.load(World.getMarket());
|
||||||
Locale locale = SETTINGS.getLocale();
|
Locale locale = SETTINGS.getLocale();
|
||||||
if (locale != null){
|
if (locale != null){
|
||||||
Localization.setLocale(locale);
|
Localization.setLocale(locale);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class Settings {
|
|||||||
profile = new Profile(new Ship());
|
profile = new Profile(new Ship());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load() {
|
public void load(Market market) {
|
||||||
try (InputStream is = new FileInputStream(file)) {
|
try (InputStream is = new FileInputStream(file)) {
|
||||||
values.load(is);
|
values.load(is);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
@@ -34,7 +34,7 @@ public class Settings {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.error("Error on load settings", e);
|
LOG.error("Error on load settings", e);
|
||||||
}
|
}
|
||||||
profile = Profile.readFrom(values);
|
profile = Profile.readFrom(values, market);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(){
|
public void save(){
|
||||||
|
|||||||
@@ -5,10 +5,14 @@ import java.util.Properties;
|
|||||||
public class Profile {
|
public class Profile {
|
||||||
public static enum PATH_PRIORITY {FAST, ECO}
|
public static enum PATH_PRIORITY {FAST, ECO}
|
||||||
|
|
||||||
|
private String name;
|
||||||
private double balance;
|
private double balance;
|
||||||
|
private Place system;
|
||||||
|
private Vendor station;
|
||||||
|
private Ship ship;
|
||||||
|
private boolean docked;
|
||||||
private int jumps;
|
private int jumps;
|
||||||
private int lands;
|
private int lands;
|
||||||
private Ship ship;
|
|
||||||
private boolean refill;
|
private boolean refill;
|
||||||
private int routesCount;
|
private int routesCount;
|
||||||
//Scorer multipliers
|
//Scorer multipliers
|
||||||
@@ -35,6 +39,14 @@ public class Profile {
|
|||||||
pathPriority = PATH_PRIORITY.FAST;
|
pathPriority = PATH_PRIORITY.FAST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
public double getBalance() {
|
public double getBalance() {
|
||||||
return balance;
|
return balance;
|
||||||
}
|
}
|
||||||
@@ -43,6 +55,38 @@ public class Profile {
|
|||||||
this.balance = balance;
|
this.balance = balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Place getSystem() {
|
||||||
|
return system;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSystem(Place system) {
|
||||||
|
this.system = system;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vendor getStation() {
|
||||||
|
return station;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStation(Vendor station) {
|
||||||
|
this.station = station;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ship getShip() {
|
||||||
|
return ship;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShip(Ship ship) {
|
||||||
|
this.ship = ship;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDocked() {
|
||||||
|
return docked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDocked(boolean docked) {
|
||||||
|
this.docked = docked;
|
||||||
|
}
|
||||||
|
|
||||||
public int getJumps() {
|
public int getJumps() {
|
||||||
return jumps;
|
return jumps;
|
||||||
}
|
}
|
||||||
@@ -59,14 +103,6 @@ public class Profile {
|
|||||||
this.lands = lands;
|
this.lands = lands;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ship getShip() {
|
|
||||||
return ship;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setShip(Ship ship) {
|
|
||||||
this.ship = ship;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean withRefill() {
|
public boolean withRefill() {
|
||||||
return refill;
|
return refill;
|
||||||
}
|
}
|
||||||
@@ -139,10 +175,26 @@ public class Profile {
|
|||||||
this.pathPriority = pathPriority;
|
this.pathPriority = pathPriority;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Profile readFrom(Properties values){
|
public static Profile readFrom(Properties values, Market market){
|
||||||
Ship ship = Ship.readFrom(values);
|
Ship ship = Ship.readFrom(values);
|
||||||
Profile profile = new Profile(ship);
|
Profile profile = new Profile(ship);
|
||||||
|
profile.setName(values.getProperty("profile.name","Cmdr NoName"));
|
||||||
profile.setBalance(Double.valueOf(values.getProperty("profile.balance","1000")));
|
profile.setBalance(Double.valueOf(values.getProperty("profile.balance","1000")));
|
||||||
|
String v = values.getProperty("profile.system", null);
|
||||||
|
if (v != null){
|
||||||
|
Place system = market.get(v);
|
||||||
|
profile.setSystem(system);
|
||||||
|
v = values.getProperty("profile.station", null);
|
||||||
|
if (v != null && system != null){
|
||||||
|
profile.setStation(system.get(v));
|
||||||
|
} else {
|
||||||
|
profile.setStation(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
profile.setSystem(null);
|
||||||
|
profile.setStation(null);
|
||||||
|
}
|
||||||
|
profile.setDocked(Boolean.valueOf(values.getProperty("profile.docked","false")));
|
||||||
profile.setJumps(Integer.valueOf(values.getProperty("profile.jumps", "6")));
|
profile.setJumps(Integer.valueOf(values.getProperty("profile.jumps", "6")));
|
||||||
profile.setLands(Integer.valueOf(values.getProperty("profile.lands", "4")));
|
profile.setLands(Integer.valueOf(values.getProperty("profile.lands", "4")));
|
||||||
profile.setPathPriority(PATH_PRIORITY.valueOf(values.getProperty("profile.search.priority", "FAST")));
|
profile.setPathPriority(PATH_PRIORITY.valueOf(values.getProperty("profile.search.priority", "FAST")));
|
||||||
@@ -157,7 +209,11 @@ public class Profile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void writeTo(Properties values){
|
public void writeTo(Properties values){
|
||||||
|
values.setProperty("profile.name", String.valueOf(name));
|
||||||
values.setProperty("profile.balance", String.valueOf(balance));
|
values.setProperty("profile.balance", String.valueOf(balance));
|
||||||
|
values.setProperty("profile.system", String.valueOf(system != null ? system.getName():""));
|
||||||
|
values.setProperty("profile.station", String.valueOf(station != null ? station.getName():""));
|
||||||
|
values.setProperty("profile.docked", String.valueOf(docked));
|
||||||
values.setProperty("profile.jumps", String.valueOf(jumps));
|
values.setProperty("profile.jumps", String.valueOf(jumps));
|
||||||
values.setProperty("profile.lands", String.valueOf(lands));
|
values.setProperty("profile.lands", String.valueOf(lands));
|
||||||
values.setProperty("profile.search.priority", String.valueOf(pathPriority));
|
values.setProperty("profile.search.priority", String.valueOf(pathPriority));
|
||||||
|
|||||||
Reference in New Issue
Block a user