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

Commit

Permalink
Gui upgrade (#118)
Browse files Browse the repository at this point in the history
* Added icons to station type

* Station name can now be clicked to open inara

* Adjusted drop-down menu design

* Added feedback button
Made fancy alerts

* Added loading gifs to gui

* Updated version info
  • Loading branch information
Fi0x authored Dec 2, 2022
1 parent 63a19c9 commit 7313d71
Show file tree
Hide file tree
Showing 24 changed files with 418 additions and 29 deletions.
2 changes: 1 addition & 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>2.0.0.1</version>
<version>2.1.0.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
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 "2.0.0.1"
#define MyAppVersion "2.1.0.0"
#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 @@ -39,7 +39,7 @@ public class Main
public static File reddit;
public static File discord;
//TODO: Update version information
public static final String version = "2.0.0.1";//All.GUI.Logic.Hotfix
public static final String version = "2.1.0.0";//All.GUI.Logic.Hotfix
public static final VersionType versionType = VersionType.INSTALLER;

public static void main(String[] args)
Expand Down
24 changes: 22 additions & 2 deletions src/main/java/com/fi0x/edct/gui/controller/Datastorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Tooltip;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

import java.util.HashMap;
import java.util.Objects;

public class Datastorage
{
private Interaction interactionController;

private final Image loadingGif = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/images/loading.gif")), 15, 15, false, false);

@FXML
public Button btnStart;
@FXML
Expand All @@ -34,6 +39,7 @@ private void calculate()
{
btnStart.setVisible(false);
lblReloadStatus.setVisible(true);
lblReloadStatus.setGraphic(new ImageView(loadingGif));
lblDataAge.setText("Loading data from storage");

MixpanelHandler.addMessage(MixpanelEvents.BUTTON_CLICKED.name(), new HashMap<>(){{put("buttonName", "trade-reloader");}});
Expand All @@ -49,9 +55,14 @@ public void setDataAge(long age)
lblDataAge.setText(ConvertToString.ageText(age));
}

public void setUpdateStatus(String status, BACKGROUND_STATUS phase)
public void setUpdateStatus(String status, BACKGROUND_STATUS phase, boolean updateGif)
{
lblUpdateStatus.setText(status);
if(updateGif)
lblUpdateStatus.setGraphic(new ImageView(loadingGif));
else
lblUpdateStatus.setGraphic(null);

switch(phase)
{
case INITIALIZING:
Expand All @@ -64,7 +75,16 @@ public void setUpdateStatus(String status, BACKGROUND_STATUS phase)
}
public void setEDDNStatus(boolean updating)
{
lblEDDNStatus.setText(updating ? "Storing EDDN information..." : "EDDN information stored");
if(updating)
{
lblEDDNStatus.setText("Storing EDDN information");
lblEDDNStatus.setGraphic(new ImageView(loadingGif));
}
else
{
lblEDDNStatus.setText("EDDN information stored");
lblEDDNStatus.setGraphic(null);
}
}

public void setInteractionController(Interaction controller)
Expand Down
52 changes: 51 additions & 1 deletion src/main/java/com/fi0x/edct/gui/controller/Settings.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.fi0x.edct.gui.controller;

import com.fi0x.edct.Main;
import com.fi0x.edct.gui.visual.CustomAlert;
import com.fi0x.edct.gui.visual.MainWindow;
import com.fi0x.edct.logging.LogName;
import com.fi0x.edct.logging.exceptions.MixpanelEvents;
Expand All @@ -18,6 +19,7 @@
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;

public class Settings implements Initializable
Expand Down Expand Up @@ -152,6 +154,53 @@ public void initialize(URL url, ResourceBundle resourceBundle)
ttDiscord.setText("This opens the config file for discord-texts in the Windows-editor.\nYou can find out how to configure the file correctly in the wiki");
}

@FXML
private void provideFeedback()
{
MixpanelHandler.addMessage(MixpanelEvents.BUTTON_CLICKED.name(), new HashMap<>(){{put("buttonName", "feedback");}});

Map<String, String> results = new HashMap<>();
boolean noFlag = false;

Alert alertUseful = new CustomAlert(Alert.AlertType.NONE, "Do you think this tool is useful?", ButtonType.YES, ButtonType.NO);
alertUseful.showAndWait();
results.put("usefulTool", alertUseful.getResult() == ButtonType.YES ? "Yes" : "No");
if(alertUseful.getResult() == ButtonType.NO)
noFlag = true;

Alert alertEasyUse = new CustomAlert(Alert.AlertType.NONE, "Is the tool easy to use and understand?", ButtonType.YES, ButtonType.NO);
alertEasyUse.showAndWait();
results.put("easyUse", alertEasyUse.getResult() == ButtonType.YES ? "Yes" : "No");
if(alertEasyUse.getResult() == ButtonType.NO)
noFlag = true;

Alert alertCorrectInfo = new CustomAlert(Alert.AlertType.NONE, "Is the provided information always correct?", ButtonType.YES, ButtonType.NO);
alertCorrectInfo.showAndWait();
results.put("correctInformation", alertCorrectInfo.getResult() == ButtonType.YES ? "Yes" : "No");
if(alertCorrectInfo.getResult() == ButtonType.NO)
noFlag = true;

Alert alertMissingFilter = new CustomAlert(Alert.AlertType.NONE, "Is there a filter-option missing you would like to use?", ButtonType.YES, ButtonType.NO);
alertMissingFilter.showAndWait();
results.put("missingFilter", alertMissingFilter.getResult() == ButtonType.YES ? "Yes" : "No");
if(alertMissingFilter.getResult() == ButtonType.YES)
noFlag = true;

if(noFlag)
{
Alert alertGithub = new CustomAlert(Alert.AlertType.NONE, "Would you like to provide more information and create a GitHub issue?", ButtonType.YES, ButtonType.NO);
alertGithub.showAndWait();
results.put("githubIssue", alertGithub.getResult() == ButtonType.YES ? "Yes" : "No");
if(alertGithub.getResult() == ButtonType.YES)
ExternalProgram.openWebsite("https://github.com/Fi0x/EDCT/issues/new/choose");
}

MixpanelHandler.addMessage(MixpanelEvents.FEEDBACK.name(), results);

Alert alertThanks = new CustomAlert(Alert.AlertType.INFORMATION, "Your feedback was sent to the developer", ButtonType.CLOSE);
alertThanks.setHeaderText("Thank you!");
alertThanks.showAndWait();
}
@FXML
private void changeDetailMode()
{
Expand All @@ -171,6 +220,7 @@ private void clearLogs()
try
{
Main.clearLogs();
new CustomAlert(Alert.AlertType.NONE, "Log files cleared", ButtonType.CLOSE).showAndWait();
} catch(IOException e)
{
Logger.log("Could not clear the log files", LogName.WARNING, e);
Expand All @@ -189,7 +239,7 @@ private void clearDB()
else if(tradeEntries > 0) alertText += " It contains " + tradeEntries + " trades";
if(stationEntries > 0 && tradeEntries > 0) alertText += " and " + tradeEntries + " trades";

Alert alert = new Alert(Alert.AlertType.WARNING, alertText, ButtonType.YES, ButtonType.CANCEL);
Alert alert = new CustomAlert(Alert.AlertType.WARNING, alertText, ButtonType.YES, ButtonType.CANCEL);
alert.showAndWait();

if(alert.getResult() == ButtonType.CANCEL)
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/com/fi0x/edct/gui/controller/Station.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.fi0x.edct.gui.controller;

import com.fi0x.edct.logging.LogName;
import com.fi0x.edct.logging.exceptions.HtmlConnectionException;
import com.fi0x.edct.logging.exceptions.MixpanelEvents;
import com.fi0x.edct.logic.database.DBHandler;
import com.fi0x.edct.logic.filesystem.BlacklistHandler;
import com.fi0x.edct.logic.helper.ConvertToString;
import com.fi0x.edct.logic.helper.ExternalProgram;
import com.fi0x.edct.logic.structures.ENDPOINTS;
import com.fi0x.edct.logic.structures.TRADE;
import com.fi0x.edct.logic.websites.InaraStation;
import io.fi0x.javalogger.logging.Logger;
Expand All @@ -32,6 +34,7 @@ public class Station implements Initializable

private boolean isImportStation;
public int stationID;
private String inaraID;
private String stationSystem;
private String stationName;

Expand All @@ -48,6 +51,8 @@ public class Station implements Initializable
@FXML
private Label lblType;
@FXML
private Label lblTypeIcon;
@FXML
private Label lblPad;
@FXML
private Label lblPrice;
Expand Down Expand Up @@ -77,6 +82,8 @@ public void initialize(URL url, ResourceBundle resourceBundle)
btnBlacklist.setGraphic(new ImageView(img));
img = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/images/reload.png")), 20, 20, false, false);
btnReloadStation.setGraphic(new ImageView(img));
img = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/images/station_orbit.png")), 20, 20, false, false);
lblTypeIcon.setGraphic(new ImageView(img));

btnReddit.addEventHandler(MouseEvent.MOUSE_CLICKED, e ->
{
Expand Down Expand Up @@ -186,18 +193,44 @@ private void copySystemToClipboard()
{
ExternalProgram.copyToClipboard(stationSystem);
}
@FXML
private void openStationOnInara()
{
ExternalProgram.openWebsite(ENDPOINTS.StationInfo.url + inaraID);
}

public void setStation(TRADE trade, boolean hasPrev, boolean hasNext)
{
stationSystem = trade.STATION.SYSTEM;
stationName = trade.STATION.NAME;
try
{
inaraID = InaraStation.getInaraStationID(stationName, stationSystem);
} catch(InterruptedException | HtmlConnectionException e)
{
Logger.log("Could not get the correct inaraID for a station: " + stationName + " | " + stationSystem, LogName.WARNING);
}

DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(1);

lblSystem.setText("System:\t " + stationSystem);
lblStationName.setText("Station:\t " + stationName);
lblType.setText("Type:\t " + trade.STATION.TYPE);
String typeIcon = "/images/station_orbit.png";
switch(trade.STATION.TYPE)
{
case CARRIER:
typeIcon = "/images/station_carrier.png";
break;
case SURFACE:
case ODYSSEY:typeIcon = "/images/station_surface.png";
break;
default:
break;
}
Image img = new Image(Objects.requireNonNull(getClass().getResourceAsStream(typeIcon)), 20, 20, false, false);
lblTypeIcon.setGraphic(new ImageView(img));
lblPad.setText("Pad:\t\t " + trade.STATION.PAD);
lblPrice.setText("Price:\t " + df.format((isImportStation ? trade.IMPORT_PRICE : trade.EXPORT_PRICE)) + " credits");
lblAmount.setText((isImportStation ? "Demand:\t " : "Supply:\t ") + df.format((isImportStation ? trade.DEMAND : trade.SUPPLY)) + " tons");
Expand Down
55 changes: 55 additions & 0 deletions src/main/java/com/fi0x/edct/gui/visual/CustomAlert.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.fi0x.edct.gui.visual;

import com.fi0x.edct.logging.LogName;
import io.fi0x.javalogger.logging.Logger;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.stage.StageStyle;

import java.net.URL;

public class CustomAlert extends Alert
{
public CustomAlert(AlertType alertType)
{
super(alertType);
setCSS(alertType);
initStyle(StageStyle.UNDECORATED);
}
public CustomAlert(AlertType alertType, String message, ButtonType... buttonTypes)
{
super(alertType, message, buttonTypes);
setCSS(alertType);
initStyle(StageStyle.UNDECORATED);
}

private void setCSS(AlertType type)
{
URL resource = null;

switch(type)
{
case NONE:
resource = getClass().getResource("/css/alert_none.css");
break;
case INFORMATION:
setGraphic(null);
resource = getClass().getResource("/css/alert_info.css");
break;
case WARNING:
resource = getClass().getResource("/css/alert_warning.css");
break;
case CONFIRMATION:
resource = getClass().getResource("/css/alert_confirm.css");
break;
case ERROR:
resource = getClass().getResource("/css/alert_error.css");
break;
}

if(resource == null)
Logger.log("Could not find css-file for alert", LogName.WARNING);
else
getDialogPane().getStylesheets().add(resource.toExternalForm());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ public enum MixpanelEvents
FILTERS_CHANGE,
BUTTON_CLICKED,
TRADES_LOADED,
HEARTBEAT
FEEDBACK
}
8 changes: 4 additions & 4 deletions src/main/java/com/fi0x/edct/logic/threads/Updater.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void run()
Platform.runLater(() ->
{
MainWindow.getInstance().setUpdateStatus(-1);
MainWindow.getInstance().interactionController.storageController.setUpdateStatus("Updated", Datastorage.BACKGROUND_STATUS.INITIALIZED);
MainWindow.getInstance().interactionController.storageController.setUpdateStatus("Updated", Datastorage.BACKGROUND_STATUS.INITIALIZED, false);
});

if(Main.reloader != null) Main.reloader.interrupt();
Expand All @@ -68,7 +68,7 @@ public void run()
while(!Thread.interrupted())
{
if(sleepInterrupted((long) (Math.random() * 5000) + Settings.inaraDelay - 5000)) return;
Platform.runLater(() -> MainWindow.getInstance().interactionController.storageController.setUpdateStatus("Updating...", Datastorage.BACKGROUND_STATUS.INITIALIZED));
Platform.runLater(() -> MainWindow.getInstance().interactionController.storageController.setUpdateStatus("Updating", Datastorage.BACKGROUND_STATUS.INITIALIZED, true));

int oldestID = DBHandler.getOldestCommodityID();
if(oldestID == 0) continue;
Expand All @@ -93,7 +93,7 @@ public void run()
Platform.runLater(() ->
{
MainWindow.getInstance().interactionController.storageController.setDataAge(age);
MainWindow.getInstance().interactionController.storageController.setUpdateStatus("Updated", Datastorage.BACKGROUND_STATUS.INITIALIZED);
MainWindow.getInstance().interactionController.storageController.setUpdateStatus("Updated", Datastorage.BACKGROUND_STATUS.INITIALIZED, false);
});
}
Logger.log("Updater Thread stopped", LogName.INFO);
Expand All @@ -113,7 +113,7 @@ private boolean loadMissingIDs()
Platform.runLater(() ->
{
MainWindow.getInstance().setUpdateStatus((float)finalCounter / (float)missingIDs.size());
MainWindow.getInstance().interactionController.storageController.setUpdateStatus("Initializing " + finalCounter + "/" + missingIDs.size(), Datastorage.BACKGROUND_STATUS.INITIALIZING);
MainWindow.getInstance().interactionController.storageController.setUpdateStatus("Initializing " + finalCounter + "/" + missingIDs.size(), Datastorage.BACKGROUND_STATUS.INITIALIZING, true);
});
if(sleepInterrupted(250)) return true;

Expand Down
Loading

0 comments on commit 7313d71

Please sign in to comment.