Skip to content

Commit

Permalink
10.1 patch, see latest_changelog.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
qcwxezda committed Jun 10, 2023
1 parent f73d6c4 commit a6d4454
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 7 deletions.
4 changes: 4 additions & 0 deletions latest_changelog.txt
@@ -0,0 +1,4 @@
- Made recent built-in list size a setting, default size 10 -> 20
- Recent built-in list is now sorted alphabetically
- Fix NPE on hull mods with null unapplicableReason
- Fix no_build_in being disregarded regardless of setting
2 changes: 1 addition & 1 deletion mod_info.json
Expand Up @@ -2,7 +2,7 @@
"id": "progressiveSMods",
"name": "Progressive S-Mods",
"author": "qcwxezda",
"version": {"major":0, "minor":10, "patch":0},
"version": {"major":0, "minor":10, "patch":1},
"dependencies": [],
"description": "Ships gain XP during combat that can be spent to build in hull mods. Disables building in hull mods using story points.",
"gameVersion": "0.96a-RC8",
Expand Down
2 changes: 1 addition & 1 deletion progsmod.version
Expand Up @@ -6,6 +6,6 @@
{
"major":0,
"minor":10,
"patch":0,
"patch":1,
},
}
3 changes: 3 additions & 0 deletions progsmod_settings.json
@@ -1,4 +1,7 @@
{
# Maximum size of recently-built-in list
"recentlyBuiltInListSize": 20,

# Deployment cost increase per additional s-mod,
# as fraction of base DP cost
"deploymentCostPenalty": 0.08,
Expand Down
14 changes: 13 additions & 1 deletion src/progsmod/data/campaign/rulecmd/PSM_BuildInHullMod.java
Expand Up @@ -171,7 +171,19 @@ public boolean hasCancelButton() {
@Override
public void showRecentPressed(CustomPanelAPI panel, TooltipMakerAPI tooltipMaker) {
List<HullModButtonData> newButtonData = new ArrayList<>();
for (String id : RecentBuildInTracker.getRecentlyBuiltIn()) {
List<String> recentlyBuiltIn = new ArrayList<>(RecentBuildInTracker.getRecentlyBuiltIn());
Collections.sort(recentlyBuiltIn, new Comparator<String>() {
@Override
public int compare(String s1, String s2) {
HullModSpecAPI spec1 = Global.getSettings().getHullModSpec(s1);
String name1 = spec1 == null ? "zzzunknown" : spec1.getDisplayName();
HullModSpecAPI spec2 = Global.getSettings().getHullModSpec(s2);
String name2 = spec2 == null ? "zzzunknown" : spec2.getDisplayName();
return name1.compareTo(name2);
}
});

for (String id : recentlyBuiltIn) {
if (selectedVariant.hasHullMod(id)) {
continue;
}
Expand Down
Expand Up @@ -133,7 +133,7 @@ private BitSet disableUnapplicable() {
// Can build in any number of logistics hull mods
// Don't use s-mods in the check ship as we want to be able to tell when incompatibilities arise
// via forcible removing of non s-mods
if (!reason.startsWith("Maximum of 2 non-built-in \"Logistics\"")) {
if (reason != null && !reason.startsWith("Maximum of 2 non-built-in \"Logistics\"")) {
disableText = SModUtils.shortenText(reason, button.description);
shouldDisable = true;
}
Expand All @@ -149,7 +149,7 @@ else if (interactionTarget != null && interactionTarget.getMarket() != null) {
button.description);
}
}
if (hullMod.hasTag("progsmod_no_build_in") && !SModUtils.Constants.IGNORE_NO_BUILD_IN) {
if (hullMod.hasTag("no_build_in") && !SModUtils.Constants.IGNORE_NO_BUILD_IN) {
shouldDisable = true;
disableText = hullMod.getDisplayName() + " can't be built in";
}
Expand Down
3 changes: 1 addition & 2 deletions src/util/RecentBuildInTracker.java
Expand Up @@ -7,7 +7,6 @@
import java.util.Map;

public class RecentBuildInTracker {
public static final int recentlyBuiltInMaxSize = 10;
public static final String DATA_KEY = "progsmod_RecentlyBuiltIn";

public static void addToRecentlyBuiltIn(String id) {
Expand All @@ -22,7 +21,7 @@ public static void addToRecentlyBuiltIn(String id) {
recentlyBuiltIn.remove(id);
recentlyBuiltIn.addFirst(id);

if (recentlyBuiltIn.size() > recentlyBuiltInMaxSize) {
while (recentlyBuiltIn.size() > SModUtils.Constants.MAX_RECENTLY_BUILT_IN_SIZE) {
recentlyBuiltIn.removeLast();
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/util/SModUtils.java
Expand Up @@ -49,6 +49,7 @@ public enum GrowthType {LINEAR, EXPONENTIAL};
public static ReserveXPTable RESERVE_XP_TABLE = new ReserveXPTable();

public static class Constants {
public static int MAX_RECENTLY_BUILT_IN_SIZE;
/** How many story points it costs to unlock the first extra SMod slot. */
public static int BASE_EXTRA_SMOD_SP_COST_FRIGATE;
public static int BASE_EXTRA_SMOD_SP_COST_DESTROYER;
Expand Down Expand Up @@ -123,6 +124,7 @@ public static class Constants {
/** Load constants from a json file */
private static void load(String filePath) throws IOException, JSONException {
JSONObject json = Global.getSettings().loadJSON(filePath);
MAX_RECENTLY_BUILT_IN_SIZE = json.getInt("recentlyBuiltInListSize");
JSONObject augmentSP = json.getJSONObject("baseExtraSModSPCost");
BASE_EXTRA_SMOD_SP_COST_FRIGATE = augmentSP.getInt("frigate");
BASE_EXTRA_SMOD_SP_COST_DESTROYER = augmentSP.getInt("destroyer");
Expand Down

0 comments on commit a6d4454

Please sign in to comment.