2b086345663a — Quintillus 2 months ago
The save file now gets the game year automatically.  It also looks at the text input for both year and cumulative years when you press enter for either.
M src/main/java/com/ajtjp/gearcityuserinterface/Main.java +2 -2
@@ 14,6 14,7 @@ import javafx.scene.Scene;
 import javafx.stage.Stage;
 import static javafx.application.Application.launch;
 import javafx.stage.FileChooser;
+import static javafx.application.Application.launch;
 
 /**
  *

          
@@ 50,10 51,9 @@ public class Main extends Application {
                 
                 saveFile = new SaveFile(file.getAbsolutePath());
 //                saveFile = new SaveFile("C:\\Software\\Games\\Steam\\steamapps\\common\\GearCity\\GearCity\\SaveGames\\Philadelphia Motors.db");
-                List<AnnualFinancialResult> results = saveFile.testQuery_Profitability(1950);
                 
                 ReportsController controller = fxml.getController();
-                controller.setupData(results, saveFile);
+                controller.setupData(saveFile);
                 
 		stage.show();
                 

          
M src/main/java/com/ajtjp/gearcityuserinterface/controller/IndustryProfitabilityController.java +6 -3
@@ 164,6 164,7 @@ public class IndustryProfitabilityContro
     private void setYear(KeyEvent e) {
         if (e.getCode() == KeyCode.ENTER) {
             year = Integer.parseInt(txtYear.textProperty().get());
+            yearsIncluded = Integer.parseInt(txtYearsIncluded.textProperty().get());
             updateData();
         }
     }

          
@@ 171,17 172,18 @@ public class IndustryProfitabilityContro
     @FXML
     private void setYearsIncluded(KeyEvent e) {
         if (e.getCode() == KeyCode.ENTER) {
+            year = Integer.parseInt(txtYear.textProperty().get());
             yearsIncluded = Integer.parseInt(txtYearsIncluded.textProperty().get());
             updateData();
         }
     }
 
     private void updateData() {
-        List<AnnualFinancialResult> results = saveFile.testQuery_Profitability(year);
+        List<AnnualFinancialResult> results = saveFile.getAnnualProfitabilityForAllCompanies(year);
         
         if (yearsIncluded > 1) {
             for (int i = 1; i < yearsIncluded; i++) {
-                List<AnnualFinancialResult> previousYearResults = saveFile.testQuery_Profitability(year - i);
+                List<AnnualFinancialResult> previousYearResults = saveFile.getAnnualProfitabilityForAllCompanies(year - i);
                 for (AnnualFinancialResult companyOldResult : previousYearResults) {
                     boolean foundOldResults = false;
                     for (AnnualFinancialResult existing : results) {

          
@@ 210,8 212,9 @@ public class IndustryProfitabilityContro
         tblYearlyProfitsAndLosses.getSortOrder().setAll(profitColumn);
     }
     
-    public void setupData(List<AnnualFinancialResult> results, SaveFile saveFile) {
+    public void setupData(SaveFile saveFile) {
         this.saveFile = saveFile;
+        this.year = saveFile.getGameYear();
         updateData();
     }
 }

          
M src/main/java/com/ajtjp/gearcityuserinterface/controller/ReportsController.java +2 -2
@@ 19,7 19,7 @@ public class ReportsController {
     }
     
     
-    public void setupData(List<AnnualFinancialResult> results, SaveFile saveFile) {
-        industryProfitabilityController.setupData(results, saveFile);
+    public void setupData(SaveFile saveFile) {
+        industryProfitabilityController.setupData(saveFile);
     }
 }