Skip to content

Commit b698911

Browse files
authored
chore: update .gitignore, docs, compile script, and mod source/config (#3)
- .gitignore: ignore FactionRelationships-*/ and FactionRelationships-*.zip at repo root - COMPILATION.md, compile.bat, README: doc and build updates - Mod: LunaSettings.csv, mod_info.json, Java plugin/UI/input/change listener updates - Remove obsolete FactionRelationshipsPackage config and mod_info Made-with: Cursor
1 parent 1044ef3 commit b698911

12 files changed

Lines changed: 155 additions & 46 deletions

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
# Developer config (copy compile.local.example.bat to compile.local.bat and set your paths)
55
FactionRelationships/compile.local.bat
66

7-
# Build output (from compile.bat; folder and zip include version from mod_info.json)
7+
# Build output (compile.bat writes to dist/; folder and zip include version from mod_info.json)
8+
dist/
9+
# Legacy or alternate build output at repo root (versioned folder and zip)
810
FactionRelationships-*/
911
FactionRelationships-*.zip
1012

FactionRelationships/COMPILATION.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ FactionRelationships/
4848
└── COMPILATION.md
4949
```
5050

51-
Output: `FactionRelationships-<version>/` (folder and zip), where `<version>` comes from `mod_info.json`. Contains `classes/`, `jars/FactionRelationships.jar`, `config/`, and `data/`. In-game settings and keybind are configured via **Mod Settings** (F2 in campaign) under this mod's section.
51+
Output: written to **`dist/`** at the repo root (gitignored). The build produces `dist/FactionRelationships-<version>/` (folder) and `dist/FactionRelationships-<version>.zip`, where `<version>` comes from `mod_info.json`. Each package contains `classes/`, `jars/FactionRelationships.jar`, `config/`, and `data/`. In-game settings and keybind are configured via **Mod Settings** (F2 in campaign) under this mod's section.
5252

5353
## Compile
5454

@@ -74,13 +74,13 @@ Set `GAME_DIR` (and optionally `LUNALIB`, `LAZYLIB`) before running (e.g. via `c
7474

7575
## Package and Install
7676

77-
1. The build script copies `mod_info.json` and config into the versioned package folder (e.g. `FactionRelationships-1.0.0/`).
77+
1. The build script copies `mod_info.json` and config into the versioned package folder under `dist/` (e.g. `dist/FactionRelationships-1.0.0/`).
7878
2. Copy that folder into your game `mods` folder, then rename to `FactionRelationships` for the game to load it, or use the zip:
7979

8080
```
81-
xcopy /E /I FactionRelationships-1.0.0 "YOUR_STARSECTOR_PATH\mods\FactionRelationships\"
81+
xcopy /E /I dist\FactionRelationships-1.0.0 "YOUR_STARSECTOR_PATH\mods\FactionRelationships\"
8282
```
83-
Or extract `FactionRelationships-1.0.0.zip` into `mods` and rename the extracted folder to `FactionRelationships`.
83+
Or extract `dist/FactionRelationships-1.0.0.zip` into `mods` and rename the extracted folder to `FactionRelationships`.
8484

8585
3. Final layout in your game `mods` folder:
8686

@@ -96,10 +96,10 @@ Set `GAME_DIR` (and optionally `LUNALIB`, `LAZYLIB`) before running (e.g. via `c
9696
└── FactionRelationships.jar
9797
```
9898

99-
Configure max factions, text size, overlay keybind (toggle or hold), hostile-only filter, relationship-change display, and auto-show overlay on change in **Mod Settings** (F2 in campaign).
99+
Configure max factions, text size, overlay keybind (toggle or hold), hostile-only filter, show-only-factions-in-current-system (and hyperspace fallback), relationship-change display, auto-show overlay on change, and optional auto-hide overlay after N seconds in **Mod Settings** (F2 in campaign).
100100

101101
## Quick Reference
102102

103103
- **Game directory**: Set `GAME_DIR` in `compile.local.bat` (recommended) or in `compile.bat` / manual commands. Optionally set `LUNALIB` and `LAZYLIB` in `compile.local.bat` if you use versioned LunaLib/LazyLib folders.
104104
- **Source**: `FactionRelationships/src/com/factionrelationships/`
105-
- **Output**: `FactionRelationships-<version>/` and `FactionRelationships-<version>.zip` (version from `mod_info.json`); JAR at `jars/FactionRelationships.jar` inside the package.
105+
- **Output**: `dist/FactionRelationships-<version>/` and `dist/FactionRelationships-<version>.zip` (version from `mod_info.json`); JAR at `jars/FactionRelationships.jar` inside the package. The `dist/` folder is gitignored.

FactionRelationships/compile.bat

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ if not exist "%LAZYLIB%" (
2525
REM Read version from mod_info.json for package and zip names
2626
for /f "delims=" %%v in ('powershell -NoProfile -Command "(Get-Content '%~dp0mod_info.json' -Raw | ConvertFrom-Json).version"') do set VERSION=%%v
2727
set PKG=FactionRelationships-%VERSION%
28+
set DIST=..\dist
2829

2930
set SRC=src\com\factionrelationships
30-
set OUT=..\%PKG%\classes
31-
set JAR=..\%PKG%\jars\FactionRelationships.jar
31+
set OUT=%DIST%\%PKG%\classes
32+
set JAR=%DIST%\%PKG%\jars\FactionRelationships.jar
3233

34+
if not exist "%DIST%" mkdir "%DIST%"
3335
if not exist "%OUT%" mkdir "%OUT%"
34-
if not exist "..\%PKG%\jars" mkdir "..\%PKG%\jars"
36+
if not exist "%DIST%\%PKG%\jars" mkdir "%DIST%\%PKG%\jars"
3537

3638
echo Compiling...
3739
javac -encoding UTF-8 -cp "%CORE%\starfarer.api.jar;%CORE%\starfarer_obf.jar;%CORE%\json.jar;%CORE%\log4j-1.2.9.jar;%CORE%\lwjgl.jar;%CORE%\lwjgl_util.jar;%LAZYLIB%;%LUNALIB%" -d "%OUT%" "%SRC%\FactionRelationshipsPlugin.java" "%SRC%\FactionRelationshipsUIRenderer.java" "%SRC%\FactionRelationshipsCampaignInputListener.java" "%SRC%\FactionRelationshipsKeybindScript.java" "%SRC%\FactionRelationshipChangeListener.java" "%SRC%\RelationshipChangeStore.java" "%SRC%\SystemFactionRelationshipsIntel.java"
@@ -48,11 +50,11 @@ if errorlevel 1 (
4850
)
4951

5052
echo Copying mod_info.json, config, and data to package...
51-
copy /Y "mod_info.json" "..\%PKG%\mod_info.json" >nul
52-
if exist "config" xcopy /E /I /Y "config" "..\%PKG%\config" >nul
53-
if exist "data" xcopy /E /I /Y "data" "..\%PKG%\data" >nul
53+
copy /Y "mod_info.json" "%DIST%\%PKG%\mod_info.json" >nul
54+
if exist "config" xcopy /E /I /Y "config" "%DIST%\%PKG%\config" >nul
55+
if exist "data" xcopy /E /I /Y "data" "%DIST%\%PKG%\data" >nul
5456

5557
echo Creating %PKG%.zip...
56-
powershell -NoProfile -Command "Compress-Archive -Path '..\%PKG%' -DestinationPath '..\%PKG%.zip' -Force"
58+
powershell -NoProfile -Command "Compress-Archive -Path '%DIST%\%PKG%' -DestinationPath '%DIST%\%PKG%.zip' -Force"
5759

58-
echo Done. Install by copying %PKG% to Starsector\mods\FactionRelationships\ (or extract %PKG%.zip into mods)
60+
echo Done. Output in dist\%PKG%\ and dist\%PKG%.zip. Install by copying to Starsector\mods\FactionRelationships\ (or extract the zip into mods)
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
fieldID,fieldName,fieldType,defaultValue,secondaryValue,fieldDescription,minValue,maxValue,tab
2-
factionRelationshipsHeader,Faction Relationships,Header,Faction Relationships,,,,,General
32
maxFactions,Max Factions Shown,Int,15,,Maximum number of factions to display in the overlay (sorted by relationship).,1,50,General
43
showOnlyHostile,Show Only Hostile Factions,Boolean,false,,Only display factions with reputation -50 or worse (Hostile/Inhospitable). Helps focus on immediate threats.,,,General
4+
showOnlyFactionsInSystem,Show Only Factions in Current System,Boolean,false,,Only show factions that have a market in the current star system. In hyperspace, behavior is controlled by the option below.,,,General
5+
showFullListInHyperspace,In Hyperspace: Show Full List,Boolean,true,,When "Show only factions in current system" is on, in hyperspace show the full faction list instead of none. Reduces clutter in-system while avoiding an empty overlay while traveling.,,,General
56
textSize,Text Size,Radio,Medium,"Small,Medium,Large",Text size for the overlay. Use [Large] for 4K or high-DPI displays.,,,General
67
overlayKeybindMode,Overlay Keybind Mode,Radio,Toggle,"Toggle,Hold",[Toggle]: Press key to show or hide overlay. [Hold]: Overlay only visible while key is held.,,,General
7-
toggleOverlayKeybind,Toggle Overlay Keybind,Keycode,0,,Key to show or hide the faction relationship overlay on the campaign map. Set in Mod Settings (F2). Keycode 0 = unbound.,,,General
8+
toggleOverlayKeybind,Toggle Overlay Keybind,Keycode,66,,Key to show or hide the faction relationship overlay on the campaign map. Set in Mod Settings (F2). Keycode 0 = unbound. Default: B.,,,General
89
showRelationshipChangeInOverlay,Show Relationship Change in Overlay,Boolean,true,,"When a faction relationship changes, show the change (e.g. +5 or -10) next to that faction for the duration set below.",,,General
9-
relationshipChangeDisplaySeconds,Relationship Change Display (seconds),Int,30,,"How long to show the change next to a faction in the overlay, in seconds.",5,120,General
10-
autoShowOverlayOnRelationshipChange,Auto-Show Overlay When Relationship Changes,Boolean,false,,"When a faction relationship changes, automatically show the overlay (for the duration set above).",,,General
10+
relationshipChangeDisplaySeconds,Relationship Change Display (seconds),Int,10,,"How long to show the change next to a faction in the overlay, in seconds.",5,120,General
11+
autoShowOverlayOnRelationshipChange,Auto-Show Overlay When Relationship Changes,Boolean,true,,"When a faction relationship changes, automatically show the overlay (for the duration set above).",,,General
12+
autoHideOverlayAfterSeconds,Auto-Hide Overlay After (seconds),Int,10,,"0 = overlay stays until you hide it (relationship-change auto-show still uses the duration above). When > 0, overlay auto-hides after this many seconds whenever it is shown (hotkey, location change, or relationship change).",0,300,General

FactionRelationships/mod_info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "factionrelationships",
33
"name": "Faction Relationships",
44
"author": "boop",
5-
"version": "1.4.8",
5+
"version": "1.5.9",
66
"description": "Shows a list of factions and their relationship with the player on the main navigation screen.",
77
"gameVersion": "0.98a-RC8",
88
"jars": ["jars/FactionRelationships.jar"],

FactionRelationships/src/com/factionrelationships/FactionRelationshipChangeListener.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ public void reportPlayerReputationChange(String factionId, float delta) {
4343
Boolean autoShow = LunaSettings.getBoolean(FactionRelationshipsPlugin.MOD_ID, AUTO_SHOW_SETTING);
4444
if (Boolean.TRUE.equals(autoShow)) {
4545
FactionRelationshipsPlugin.setOverlayVisible(true);
46-
RelationshipChangeStore.setAutoShowExpiry(System.currentTimeMillis() + durationMs);
46+
int autoHideSec = FactionRelationshipsPlugin.getAutoHideOverlayAfterSeconds();
47+
long hideAfterMs = (autoHideSec > 0) ? (autoHideSec * 1000L) : durationMs;
48+
RelationshipChangeStore.setAutoShowExpiry(System.currentTimeMillis() + hideAfterMs);
4749
}
4850
}
4951
}

FactionRelationships/src/com/factionrelationships/FactionRelationshipsCampaignInputListener.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,18 @@ public void processCampaignInputPreCore(List<InputEventAPI> events) {
4242
continue;
4343
}
4444
if (event.isKeyDownEvent() && event.getEventValue() == keycode) {
45-
RelationshipChangeStore.clearAutoShowExpiry();
4645
if ("Hold".equals(mode)) {
46+
RelationshipChangeStore.clearAutoShowExpiry();
4747
FactionRelationshipsPlugin.setOverlayKeyHeld(true);
4848
} else {
49-
FactionRelationshipsPlugin.setOverlayVisible(!FactionRelationshipsPlugin.isOverlayVisible());
49+
boolean willBeVisible = !FactionRelationshipsPlugin.isOverlayVisible();
50+
FactionRelationshipsPlugin.setOverlayVisible(willBeVisible);
51+
int autoHideSec = FactionRelationshipsPlugin.getAutoHideOverlayAfterSeconds();
52+
if (willBeVisible && autoHideSec > 0) {
53+
RelationshipChangeStore.setAutoShowExpiry(System.currentTimeMillis() + autoHideSec * 1000L);
54+
} else if (!willBeVisible) {
55+
RelationshipChangeStore.clearAutoShowExpiry();
56+
}
5057
}
5158
event.consume();
5259
break;

FactionRelationships/src/com/factionrelationships/FactionRelationshipsPlugin.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,19 @@ public static boolean isLunaLibEnabled() {
5959
return Global.getSettings().getModManager().isModEnabled("lunalib");
6060
}
6161

62+
/** Seconds after which to auto-hide the overlay when shown (0 = only relationship-change uses its duration). */
63+
public static int getAutoHideOverlayAfterSeconds() {
64+
if (!isLunaLibEnabled()) {
65+
return 0;
66+
}
67+
Integer v = LunaSettings.getInt(MOD_ID, "autoHideOverlayAfterSeconds");
68+
if (v == null || v.intValue() <= 0) {
69+
return 0;
70+
}
71+
int sec = Math.min(300, v.intValue());
72+
return sec;
73+
}
74+
6275
/** Called when LunaSettings change so mode and other caches are re-read. */
6376
public static void invalidateSettingsCache() {
6477
cachedOverlayKeybindMode = null;

FactionRelationships/src/com/factionrelationships/FactionRelationshipsUIRenderer.java

Lines changed: 103 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.fs.starfarer.api.Global;
44
import com.fs.starfarer.api.campaign.FactionAPI;
5+
import com.fs.starfarer.api.campaign.LocationAPI;
56
import com.fs.starfarer.api.campaign.econ.EconomyAPI;
67
import com.fs.starfarer.api.campaign.econ.MarketAPI;
78
import com.fs.starfarer.api.campaign.listeners.CampaignUIRenderingListener;
@@ -37,15 +38,29 @@ public class FactionRelationshipsUIRenderer implements CampaignUIRenderingListen
3738
private static Integer cachedMaxFactions = null;
3839
private static Boolean cachedShowOnlyHostile = null;
3940
private static Boolean cachedShowRelationshipChangeInOverlay = null;
41+
private static Boolean cachedShowOnlyFactionsInSystem = null;
42+
private static Boolean cachedShowFullListInHyperspace = null;
4043
private static String cachedFont = null;
4144
private static Float cachedLineHeight = null;
4245

46+
/** Cache for "show only in system": only rebuild when location or settings change. */
47+
private static LocationAPI cachedFactionIdsLocation = null;
48+
private static Set<String> cachedFactionIdsForLocation = null;
49+
50+
/** When "show only in system" is on (Toggle mode), we auto-show the overlay when location changes. */
51+
private static LocationAPI lastSeenLocationForAutoShow = null;
52+
4353
public static void invalidateSettingsCache() {
4454
cachedMaxFactions = null;
4555
cachedShowOnlyHostile = null;
4656
cachedShowRelationshipChangeInOverlay = null;
57+
cachedShowOnlyFactionsInSystem = null;
58+
cachedShowFullListInHyperspace = null;
4759
cachedFont = null;
4860
cachedLineHeight = null;
61+
cachedFactionIdsLocation = null;
62+
cachedFactionIdsForLocation = null;
63+
lastSeenLocationForAutoShow = null;
4964
}
5065

5166
private static boolean getShowRelationshipChangeInOverlay() {
@@ -78,6 +93,36 @@ private static boolean getShowOnlyHostile() {
7893
return value;
7994
}
8095

96+
private static boolean getShowOnlyFactionsInSystem() {
97+
if (cachedShowOnlyFactionsInSystem != null) {
98+
return cachedShowOnlyFactionsInSystem.booleanValue();
99+
}
100+
boolean value = false;
101+
if (FactionRelationshipsPlugin.isLunaLibEnabled()) {
102+
Boolean v = LunaSettings.getBoolean(FactionRelationshipsPlugin.MOD_ID, "showOnlyFactionsInSystem");
103+
if (v != null) {
104+
value = v.booleanValue();
105+
}
106+
}
107+
cachedShowOnlyFactionsInSystem = Boolean.valueOf(value);
108+
return value;
109+
}
110+
111+
private static boolean getShowFullListInHyperspace() {
112+
if (cachedShowFullListInHyperspace != null) {
113+
return cachedShowFullListInHyperspace.booleanValue();
114+
}
115+
boolean value = true;
116+
if (FactionRelationshipsPlugin.isLunaLibEnabled()) {
117+
Boolean v = LunaSettings.getBoolean(FactionRelationshipsPlugin.MOD_ID, "showFullListInHyperspace");
118+
if (v != null) {
119+
value = v.booleanValue();
120+
}
121+
}
122+
cachedShowFullListInHyperspace = Boolean.valueOf(value);
123+
return value;
124+
}
125+
81126
private static int getMaxFactions() {
82127
if (cachedMaxFactions != null) {
83128
return cachedMaxFactions.intValue();
@@ -131,6 +176,52 @@ private static FontAndLineHeight getFontAndLineHeight() {
131176
return new FontAndLineHeight(font, lineHeight);
132177
}
133178

179+
private static Set<String> buildSetFromAllMarkets() {
180+
Set<String> out = new HashSet<String>();
181+
EconomyAPI economy = Global.getSector().getEconomy();
182+
if (economy != null) {
183+
for (MarketAPI market : economy.getMarketsCopy()) {
184+
if (market.getFaction() != null) {
185+
out.add(market.getFactionId());
186+
}
187+
}
188+
}
189+
return out;
190+
}
191+
192+
private static Set<String> getFactionIdsToShow() {
193+
if (!getShowOnlyFactionsInSystem()) {
194+
return buildSetFromAllMarkets();
195+
}
196+
197+
LocationAPI loc = Global.getSector().getPlayerFleet().getContainingLocation();
198+
if (loc == null || loc.isHyperspace()) {
199+
if (getShowFullListInHyperspace()) {
200+
return buildSetFromAllMarkets();
201+
}
202+
return new HashSet<String>();
203+
}
204+
205+
if (loc == cachedFactionIdsLocation && cachedFactionIdsForLocation != null) {
206+
return cachedFactionIdsForLocation;
207+
}
208+
Set<String> factionIds = new HashSet<String>();
209+
EconomyAPI economy = Global.getSector().getEconomy();
210+
if (economy != null) {
211+
List<MarketAPI> marketsInLoc = economy.getMarkets(loc);
212+
if (marketsInLoc != null) {
213+
for (MarketAPI market : marketsInLoc) {
214+
if (market != null && market.getFaction() != null) {
215+
factionIds.add(market.getFactionId());
216+
}
217+
}
218+
}
219+
}
220+
cachedFactionIdsLocation = loc;
221+
cachedFactionIdsForLocation = factionIds;
222+
return factionIds;
223+
}
224+
134225
@Override
135226
public void renderInUICoordsBelowUI(ViewportAPI viewport) {
136227
// no-op; draw above UI
@@ -158,22 +249,25 @@ private void renderPanel(ViewportAPI viewport) {
158249
RelationshipChangeStore.clearAutoShowExpiry();
159250
}
160251
String mode = FactionRelationshipsPlugin.getOverlayKeybindMode();
252+
if (getShowOnlyFactionsInSystem() && "Toggle".equals(mode)) {
253+
LocationAPI loc = Global.getSector().getPlayerFleet().getContainingLocation();
254+
if (loc != lastSeenLocationForAutoShow) {
255+
FactionRelationshipsPlugin.setOverlayVisible(true);
256+
int autoHideSec = FactionRelationshipsPlugin.getAutoHideOverlayAfterSeconds();
257+
if (autoHideSec > 0) {
258+
RelationshipChangeStore.setAutoShowExpiry(System.currentTimeMillis() + autoHideSec * 1000L);
259+
}
260+
}
261+
lastSeenLocationForAutoShow = loc;
262+
}
161263
boolean showOverlay = "Hold".equals(mode)
162264
? FactionRelationshipsPlugin.isOverlayKeyHeld()
163265
: FactionRelationshipsPlugin.isOverlayVisible();
164266
if (!showOverlay) {
165267
return;
166268
}
167269

168-
Set<String> factionIdsWithMarkets = new HashSet<String>();
169-
EconomyAPI economy = Global.getSector().getEconomy();
170-
if (economy != null) {
171-
for (MarketAPI market : economy.getMarketsCopy()) {
172-
if (market.getFaction() != null) {
173-
factionIdsWithMarkets.add(market.getFactionId());
174-
}
175-
}
176-
}
270+
Set<String> factionIdsWithMarkets = getFactionIdsToShow();
177271

178272
List<FactionAPI> factions = new ArrayList<FactionAPI>();
179273
for (FactionAPI faction : Global.getSector().getAllFactions()) {

FactionRelationshipsPackage/config/faction_relationships_config.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)