Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Commit

Permalink
Readd Profit tab and improve existing Commodities intel (#85)
Browse files Browse the repository at this point in the history
- Rework Commodity intel look and feel.
- Readd cleaner implementation of Profit tab (again, thanks to @isthiscodefluffy).
- Show message dialog when uninstalling the mod.
  • Loading branch information
jaghaimo authored Mar 19, 2022
1 parent 37ede9f commit 59e5df1
Show file tree
Hide file tree
Showing 129 changed files with 1,485 additions and 1,139 deletions.
5 changes: 1 addition & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ jobs:
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
docker:
# specify the version you desire here
- image: circleci/openjdk:8-jdk

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/postgres:9.4
- image: cimg/openjdk:8.0

working_directory: ~/repo

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
lfs: true

- name: Install Prettier
run: npm install
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package-lock.json
!.vscode/extensions.json
# Local copies of mod structure (dev env)
/data
/exclude
/graphics
/stelnet*
/translate
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,21 @@ All items and ships acquired during the call will be deposited to the Storage of
### Commodity

Commodity board (formerly [Galactic Markets](https://fractalsoftworks.com/forum/index.php?topic=19383)) is used to display buying and selling prices among all known markets.
It also hosts a Profit tab that can be used to find viable trade routes.

![Commodity](images/commodity.png?raw=1)

#### Profit

Commodity board also hosts a Profit tab which can be used to find viable trade routes.
Filters by most profitable routes in descending order and displays routes where:

- profit margin is at least 10000 credits, and
- trade volume is at least 1000.

Highlights rows when buy and sell markets are in the same system and caps results to first 50.

![Profit](images/profit.png?raw=1)

### Market

Queries board (formerly [Hyperspace Networks](https://fractalsoftworks.com/forum/index.php?topic=19252)) manages market searches.
Expand Down Expand Up @@ -50,3 +61,7 @@ This mod can be added to an existing save - just enable it in the mod list and l

This mod can be removed from an existing save - edit `stelnet.json` and set `uninstallMod` to `true`.
Then load the save, save the game, quit the game, and finally disable this mod in the mod list.

## Integration with Other Mods

See various CSV files in [data/stelnet](assets/data/stelnet/) directory.
1 change: 1 addition & 0 deletions assets/data/config/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"commodity": "graphics/icons/intel/tutorial_mission.png",
"query": "graphics/icons/intel/investigation.png",
"storage": "graphics/icons/intel/all.png",
"trade": "graphics/icons/intel/price_update.png",
"viewer": "graphics/icons/markets/headquarters.png",

"result_0": "graphics/icons/markets/population00.png",
Expand Down
4 changes: 4 additions & 0 deletions assets/data/stelnet/include/abandoned_stations.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
id
corvus_abandoned_station
yma_abandoned_station
mairaath_abandoned_station1
2 changes: 1 addition & 1 deletion assets/mod_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Stellar Networks",
"author": "Jaghaimo",
"utility": true,
"version": "2.4.3",
"version": "2.5.0",
"description": "A collection of intel boards for Starsector",
"gameVersion": "0.95.1a-RC6",
"modPlugin": "stelnet.StelnetMod",
Expand Down
6 changes: 3 additions & 3 deletions assets/stelnet.version
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"modThreadId": 20836,
"modVersion": {
"major": 2,
"minor": 4,
"patch": 3
"minor": 5,
"patch": 0
},
"directDownloadURL": "https://github.com/jaghaimo/stelnet/releases/download/2.4.3/stelnet-2.4.3.zip"
"directDownloadURL": "https://github.com/jaghaimo/stelnet/releases/download/2.5.0/stelnet-2.5.0.zip"
}
21 changes: 16 additions & 5 deletions assets/translate/commodity.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"DELETE_THIS": "Delete this",
"DELETE_THIS_CONFIRMATION": "Are you sure you want to delete all intel for this commodity?",
"HEADER_AVAILABLE": "Available",
"HEADER_BUY_AVAILABLE": "Buy / Available",
"HEADER_BUY_EXPENSE": "Expense",
"HEADER_BUY_LOCATION": "Buy location",
"HEADER_DEFICIT": "Deficit",
"HEADER_DEMAND": "Demand",
Expand All @@ -17,10 +17,21 @@
"HEADER_LOCATION": "Location",
"HEADER_PRICE": "Price",
"HEADER_PROFIT": "Profit",
"HEADER_SELL_DEMAND": "Sell / Demand",
"HEADER_SELL_LOCATION": "Sell location",
"HEADER_SELL_REVENUE": "Revenue",
"HEADER_SYSTEM": "Star system",
"HEADER_TRIP": "Trip (ly)",
"INTEL_TITLE": "{0} {1} for {2}",
"PRICE_CHANGED": "The original price of {0} has changed to {1}."
}
"INTEL_BUY_AT": "Buy at",
"INTEL_AT_A_GLANCE": "{0} at a glance",
"INTEL_DEFICIT_QUANTITY": "Deficit quantity",
"INTEL_EXCESS_QUANTITY": "Excess quantity",
"INTEL_INFO_BUY_AT": "Buy at: {0}",
"INTEL_INFO_FACTION": "Faction: {0}",
"INTEL_INFO_SELL_FOR": "Sell for: {0}",
"INTEL_QUANTITY": "Quantity",
"INTEL_SELL_FOR": "Sell for",
"INTEL_TITLE": "{0} on {1}",
"INTEL_WITH_DEFICIT": "All commodities with deficit",
"INTEL_WITH_EXCESS": "All commodities with excess",
"PRICE_CHANGED": "{0} (was {1})"
}
3 changes: 2 additions & 1 deletion assets/translate/commodityaction.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"BUY": "Buy",
"SELL": "Sell"
"SELL": "Sell",
"PROFIT": "Profit"
}
4 changes: 4 additions & 0 deletions assets/translate/trade.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"BOARD_DESCRIPTION": "Find best trade opportunities within and across systems.",
"BOARD_TITLE": "Trade Opportunities"
}
Binary file modified images/commodity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/profit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/stelnet/BaseBoard.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package stelnet;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.comm.IntelInfoPlugin;
import com.fs.starfarer.api.ui.SectorMapAPI;
import java.util.List;
import java.util.Set;
import lombok.Getter;
import lombok.extern.log4j.Log4j;
import stelnet.util.IntelUtils;
import uilib.Renderable;
import uilib.RenderableIntel;
import uilib.RenderableState;
Expand All @@ -23,12 +23,12 @@ public abstract class BaseBoard extends RenderableIntel {
* Requires no-args constructor. Used by all "Boards".
*/
public static <T extends IntelInfoPlugin> T getInstance(Class<T> className) {
IntelInfoPlugin intel = IntelUtils.getFirst(className);
IntelInfoPlugin intel = Global.getSector().getIntelManager().getFirstIntel(className);
if (intel == null) {
try {
@SuppressWarnings("deprecation")
IntelInfoPlugin board = className.newInstance();
IntelUtils.add(board, true);
Global.getSector().getIntelManager().addIntel(board, true);
intel = board;
} catch (Exception exception) {
log.error("Couldn't create board for " + className.getName(), exception);
Expand Down
4 changes: 2 additions & 2 deletions src/stelnet/BaseIntel.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import lombok.Setter;
import stelnet.util.DistanceCalculator;
import stelnet.util.L10n;
import stelnet.util.StringUtils;
import stelnet.util.StelnetHelper;
import uilib.RenderableIntel;

@Getter
Expand Down Expand Up @@ -63,7 +63,7 @@ protected String getLocationName() {
}

protected String getLocationNameWithSystem() {
return StringUtils.getStarSystem(sectorEntityToken) + " - " + getLocationName();
return StelnetHelper.getStarSystemName(sectorEntityToken.getStarSystem(), true) + " - " + getLocationName();
}

protected abstract String getTag();
Expand Down
33 changes: 26 additions & 7 deletions src/stelnet/StelnetMod.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,51 @@
package stelnet;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CampaignUIAPI;
import com.fs.starfarer.api.impl.campaign.tutorial.TutorialMissionIntel;
import stelnet.util.ConfigConstants;
import stelnet.util.ConfigUtils;
import stelnet.util.ReportUtils;
import stelnet.util.Configurator;
import stelnet.util.Reporter;

public class StelnetMod extends BaseModPlugin {

@Override
public void afterGameSave() {
if (ConfigConstants.UNINSTALL_MOD) {
showUninstalledDialog();
}
}

@Override
public void beforeGameSave() {
if (ConfigConstants.UNINSTALL_MOD) {
ConfigUtils.deactivate();
Configurator.deactivate();
}
}

@Override
public void onApplicationLoad() throws Exception {
ReportUtils.generate();
ConfigUtils.configure();
Reporter.generate();
Configurator.configure();
}

@Override
public void onGameLoad(boolean newGame) {
if (TutorialMissionIntel.isTutorialInProgress()) {
ConfigUtils.deactivate();
Configurator.deactivate();
return;
}
Configurator.activate();
}

private void showUninstalledDialog() {
CampaignUIAPI campaignUi = Global.getSector().getCampaignUI();
if (campaignUi == null) {
return;
}
ConfigUtils.activate();
campaignUi.showMessageDialog(
"Stellar Networks has been removed from this save. You can now update (or disable) this mod."
);
}
}
28 changes: 14 additions & 14 deletions src/stelnet/board/commodity/CommodityAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public enum CommodityAction {
BUY {
@Override
public List<MarketAPI> getMarkets(String commodityId) {
return new BuyMarketFactory(commodityId).createMarkets();
return getBuyMarkets(commodityId);
}

@Override
Expand All @@ -24,30 +24,30 @@ public Price getPrice(String commodityId) {
SELL {
@Override
public List<MarketAPI> getMarkets(String commodityId) {
return new SellMarketFactory(commodityId).createMarkets();
return getSellMarkets(commodityId);
}

@Override
public Price getPrice(String commodityId) {
return new DemandPrice(commodityId);
}
};
},

PROFIT {};

public List<MarketAPI> getMarkets(String commodityId) {
return Collections.emptyList();
}

public List<MarketAPI> getSellMarkets(String commodityId) {
return new SellMarketFactory(commodityId).createMarkets();
}

public List<MarketAPI> getBuyMarkets(String commodityId) {
return new BuyMarketFactory(commodityId).createMarkets();
}

public Price getPrice(String commodityId) {
return new Price() {
@Override
public float getPriceAmount(MarketAPI market) {
return 0;
}

@Override
public float getPriceAmount(MarketAPI market, int quantity) {
return 0;
}
};
return null;
}
}
11 changes: 7 additions & 4 deletions src/stelnet/board/commodity/CommodityBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@
import stelnet.BoardInfo;
import stelnet.util.L10n;
import stelnet.util.ModConstants;
import stelnet.util.SettingsUtils;
import uilib.RenderableIntelInfo;
import stelnet.util.StelnetHelper;

@Getter
public class CommodityBoard extends BaseBoard {

private final String icon = SettingsUtils.getSpriteName("commodity");
private final RenderableIntelInfo intelInfo = new BoardInfo(
private final String icon = StelnetHelper.getSpriteName("commodity");
private final BoardInfo intelInfo = new BoardInfo(
L10n.get(CommodityL10n.BOARD_TITLE),
L10n.get(CommodityL10n.BOARD_DESCRIPTION)
);
private final CommodityState renderableState = new CommodityState();
private final String tag = ModConstants.TAG_COMMODITY;

public void restore() {
renderableState.getIntelTracker().restore();
}
}
Loading

0 comments on commit 59e5df1

Please sign in to comment.