Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Fixed Carrier station type detection
Browse files Browse the repository at this point in the history
Added company Name to pom
Updated version number
  • Loading branch information
Felix Pechtl committed Jun 8, 2021
1 parent 5526d8d commit bf83b80
Show file tree
Hide file tree
Showing 9 changed files with 916 additions and 105 deletions.
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>com.fi0x.edct</groupId>
<artifactId>EliteDangerousCarrierTrader</artifactId>
<!-- //TODO: update version -->
<version>1.0.1.1</version>
<version>1.0.1.2</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Expand Down Expand Up @@ -118,6 +118,7 @@
<productVersion>${project.version}</productVersion>
<txtProductVersion>${project.version}</txtProductVersion>
<productName>EliteDangerousCarrierTrader</productName>
<companyName>Fi0x</companyName>
<internalName>EDCT</internalName>
<originalFilename>EDCT.exe</originalFilename>
</versionInfo>
Expand Down
2 changes: 1 addition & 1 deletion setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

; TODO: Update Version info
#define MyAppName "Elite Dangerous Carrier Trader"
#define MyAppVersion "1.0.1.1"
#define MyAppVersion "1.0.1.2"
#define MyAppPublisher "Fi0x"
#define MyAppURL "https://github.com/Fi0x/EDCT"
#define MyAppExeName "EDCT.exe"
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/fi0x/edct/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Main
public static File errors;
public static File settings;
//TODO: Update version information
public static final String version = "1.0.1.1";//All.GUI.Logic.Hotfix
public static final String version = "1.0.1.2";//All.GUI.Logic.Hotfix

public static void main(String[] args)
{
Expand Down
22 changes: 17 additions & 5 deletions src/main/java/com/fi0x/edct/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
public class MainWindow extends Application
{
private static MainWindow instance;
private Stage primeStage;

public ProgramInfo infoController;
public Interaction interactionController;
Expand All @@ -26,6 +27,7 @@ public class MainWindow extends Application
public void start(Stage primaryStage)
{
instance = this;
primeStage = primaryStage;
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/main.fxml"));
Parent root;
try
Expand All @@ -42,11 +44,11 @@ public void start(Stage primaryStage)
loadInteraction(loader);
loadResults(loader);

primaryStage.setTitle("Elite: Dangerous Carrier Trader");
primaryStage.getIcons().add(new Image("images/icon.png"));
primaryStage.setScene(new Scene(root));
primaryStage.setResizable(false);
primaryStage.show();
primeStage.setTitle("Elite: Dangerous Carrier Trader");
primeStage.getIcons().add(new Image("images/icon.png"));
primeStage.setScene(new Scene(root));
primeStage.setResizable(false);
primeStage.show();

Logger.INFO("GUI loaded");

Expand All @@ -70,6 +72,16 @@ public static MainWindow getInstance()
return instance;
}

public void setUpdateStatus(String status, boolean displayAsTitle)
{
interactionController.storageController.setUpdateStatus(status);
if(displayAsTitle)
{
if(status == null) primeStage.setTitle("Elite: Dangerous Carrier Trader");
else primeStage.setTitle("Elite: Dangerous Carrier Trader - " + status);
}
}

private void loadInfo(FXMLLoader parentLoader)
{
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/programinfo.fxml"));
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/com/fi0x/edct/data/Updater.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ public void run()
if(loadMissingIDs()) return;

Logger.INFO("All Commodities loaded");
Platform.runLater(() -> MainWindow.getInstance().interactionController.storageController.setUpdateStatus("Updated"));
Platform.runLater(() ->
{
MainWindow.getInstance().setUpdateStatus(null, true);
MainWindow.getInstance().setUpdateStatus("Updated", false);
});

Thread threadReq = new Thread(new TradeReloader(MainWindow.getInstance().interactionController));
threadReq.start();
Expand All @@ -46,7 +50,7 @@ public void run()
while(!Thread.interrupted())
{
if(sleepInterrupted((long) (Math.random() * 5000) + 10000)) return;
Platform.runLater(() -> MainWindow.getInstance().interactionController.storageController.setUpdateStatus("Updating..."));
Platform.runLater(() -> MainWindow.getInstance().setUpdateStatus("Updating...", false));

int oldestID = DBHandler.getInstance().getOldestCommodityID();
if(oldestID == 0) continue;
Expand All @@ -63,7 +67,7 @@ public void run()
Platform.runLater(() ->
{
MainWindow.getInstance().interactionController.storageController.setDataAge(age, true);
MainWindow.getInstance().interactionController.storageController.setUpdateStatus("Updated");
MainWindow.getInstance().setUpdateStatus("Updated", false);
});
}
Logger.INFO("Updater Thread stopped");
Expand All @@ -78,7 +82,7 @@ private boolean loadMissingIDs()
{
counter++;
int finalCounter = counter;
Platform.runLater(() -> MainWindow.getInstance().interactionController.storageController.setUpdateStatus("Initializing " + finalCounter + "/" + missingIDs.size() + " ..."));
Platform.runLater(() -> MainWindow.getInstance().setUpdateStatus("Initializing " + finalCounter + "/" + missingIDs.size(), true));
if(sleepInterrupted(250)) return true;
try
{
Expand Down
39 changes: 27 additions & 12 deletions src/main/java/com/fi0x/edct/data/cleanup/HTMLCleanup.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fi0x.edct.data.structures.PADSIZE;
import com.fi0x.edct.data.structures.STATION;
import com.fi0x.edct.data.structures.STATIONTYPE;
import com.fi0x.edct.util.Logger;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
Expand All @@ -11,6 +12,7 @@
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

public class HTMLCleanup
Expand Down Expand Up @@ -126,40 +128,46 @@ public static String getStationID(String inputHTML, String stationName, String s
return stationID;
}

@Nullable
public static PADSIZE getStationPad(String inputHTML)
{
PADSIZE padsize = PADSIZE.M;
PADSIZE padsize = PADSIZE.S;

Element details = getStationDetails(inputHTML);
if(details == null) return padsize;
if(details == null) return null;

for(Element pair : details.getElementsByClass("itempaircontainer"))
{
String pairText = pair.toString();
if(pairText.contains("Landing pad") && !pairText.contains("Large"))
String pairText = pair.toString().toLowerCase();
if(pairText.contains("landing pad"))
{
padsize = PADSIZE.L;
if(pairText.contains("none")) return null;
else if(pairText.contains("large")) padsize = PADSIZE.L;
else if(pairText.contains("medium")) padsize = PADSIZE.M;
break;
}
}

return padsize;
}

@Nullable
public static STATIONTYPE getStationType(String inputHTML)
{
STATIONTYPE type = STATIONTYPE.ORBIT;
STATIONTYPE type = null;

Element details = getStationDetails(inputHTML);
if(details == null) return type;
if(details == null) return null;

for(Element pair : details.getElementsByClass("itempaircontainer"))
{
if(pair.toString().toLowerCase().contains("station type"))
{
String typeName = pair.getElementsByClass("itempairvalue").first().ownText();
if(typeName.toLowerCase().contains("odyssey")) type = STATIONTYPE.ODYSSEY;
else if(typeName.toLowerCase().contains("fleet carrier")) type = STATIONTYPE.CARRIER;
else if(typeName.toLowerCase().contains("surface")) type = STATIONTYPE.SURFACE;
String typeName = pair.getElementsByClass("itempairvalue").first().ownText().toLowerCase();
if(typeName.contains("odyssey")) type = STATIONTYPE.ODYSSEY;
else if(typeName.contains("fleet") || typeName.contains("carrier")) type = STATIONTYPE.CARRIER;
else if(typeName.contains("surface")) type = STATIONTYPE.SURFACE;
else if(typeName.contains("starport") || typeName.contains("outpost")) type = STATIONTYPE.ORBIT;
}
}

Expand All @@ -186,6 +194,13 @@ private static Element getStationDetails(String inputHTML)
Elements mainblocks = mainconten1s.first().getElementsByClass("mainblock");
if(mainblocks.size() == 0) return null;

return mainblocks.get(1);
for(Element block : mainblocks)
{
String blockText = block.toString().toLowerCase();
if(blockText.contains("class=\"mainblock\"") && (blockText.contains("landing pad") || blockText.contains("station type") || blockText.contains("href=\"/station/")))
return block;

}
return null;
}
}
6 changes: 6 additions & 0 deletions src/main/java/com/fi0x/edct/data/webconnection/EDDN.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ public void run()

PADSIZE padsize = HTMLCleanup.getStationPad(html);
STATIONTYPE stationtype = HTMLCleanup.getStationType(html);
if(stationtype == null || padsize == null)
{
Platform.runLater(() -> MainWindow.getInstance().interactionController.storageController.setEDDNStatus(""));
Logger.WARNING("Aborted station update for " + stationName + " type=" + stationtype + " pad=" + padsize + " - html: " + html);
continue;
}

for(String trade : JSONCleanup.getTrades(outputString))
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/fi0x/edct/util/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private static void log(int code, LOGLEVEL lvl, String text, @Nullable Exception
String color = WHITE;
if(lvl == LOGLEVEL.WRN) color = YELLOW;
else if(lvl == LOGLEVEL.ERR) color = RED;
System.out.println(time + color + prefix + errorCode + text + RESET);
System.out.println(color + time + prefix + errorCode + text + RESET);
if(e != null) e.printStackTrace();
}

Expand Down
Loading

0 comments on commit bf83b80

Please sign in to comment.