Skip to content
This repository was archived by the owner on Feb 4, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: "2"
checks:
return-statements:
enabled: false
similar-code:
enabled: false
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,32 @@
A collection of QoL improvements to campaign layer of Starsector.
Named after first QoL addition - Transponder Off, or just `transpoffder`.
Safe to install and uninstall mid-game.
Also changes some vanilla settings.

## Transponder Off in Hyperspace

Automatically turn off fleet transponder whenever transitioning to Hyperspace.
Comes in two flavours: basic mod (`transpoffder-x.y.z.zip`) and mod that changes some settings (see below, `transpoffder-x.y.z-with-settings.zip`).

## Better Active Sensor Burst

Do not disable Sustained Burn or Neutrino Detector when using Active Sensor Burst.
Fleet will move slowly for the cool-down duration (instead of doing full stop).
Fleet will move slowly for the cool-down duration (instead of doing full stop) and resume full burn afterwards.

## Partial Survey as You Fly

Automatically provide partial survey for planets within your sensor range.
No need to land on the planet any more.

## Scavenge as You Fly

Use Scavenge ability as soon as it is usable.
Toggled via new ability (blue Scavenge icon).

## Partial Survey as You Fly
## Transponder Off in Hyperspace

No need to "touch" the planet any more.
Automatically provide partial survey for planets within your sensor range.
Automatically turn off fleet transponder when transitioning to Hyperspace.

## Vanilla Settings Changed

List of settings changes in `transpoffder-x.y.z-with-settings.zip` version:

- `altMouseMoveToMassTransfer` (true instead of false),
- `campaignSpeedupMult` (3 instead of 2),
- `enableShipExplosionWhiteout` (false instead of true),
Expand Down
6 changes: 6 additions & 0 deletions assets/data/config/LunaSettings.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fieldID,fieldName,fieldType,defaultValue,secondaryValue,fieldDescription,minValue,maxValue,tab
,,,,,,,,
BetterActiveBurst,Better Active Burst,Boolean,true,,"Slow down fleet movement (instead of full-stop) and resume Sustained Burn (if it was active) after the cooldown.",,,
PartialSurveyAsYouFly,Partial Survey As You Fly,Boolean,true,,"Automatically provide partial survey for planets within your sensor range. No need to land on the planet anymore.",,,
ScavengeAsYouFly,Scavenge As You Fly,Boolean,true,,"Use Scavenge ability as soon as it is usable. Toggled via new ability (blue Scavenge icon).",,,
TransponderOff,Transponder Off in Hyperspace,Boolean,true,,"Automatically turn off fleet transponder when transitioning to Hyperspace.",,,
5 changes: 5 additions & 0 deletions assets/data/config/LunaSettingsConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"transpoffder": {
"iconPath": "graphics/icons/transpoffder.png"
}
}
Binary file added assets/graphics/icons/transpoffder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions assets/mod_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"name": "Transponder Off",
"author": "Jaghaimo",
"utility": true,
"version": "1.2.2",
"version": "2.0.0-rc2",
"description": "QoL improvements to the campaign layer of Starsector",
"gameVersion": "0.95.1a-RC6",
"gameVersion": "0.96a-RC10",
"modPlugin": "transpoffder.TranspoffderMod",
"jars": ["transpoffder.jar"]
}
6 changes: 0 additions & 6 deletions assets/transpoffder.json

This file was deleted.

9 changes: 5 additions & 4 deletions assets/transpoffder.version
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"modName": "Transponder Off",
"modThreadId": 23545,
"modVersion": {
"major": 1,
"minor": 2,
"patch": 2
"major": 2,
"minor": 0,
"patch": 0
},
"directDownloadURL": "https://github.com/jaghaimo/transpoffder/releases/download/1.2.2/transpoffder-1.2.2.zip"
"directDownloadURL": "https://github.com/jaghaimo/transpoffder/releases/download/2.0.0/transpoffder-2.0.0.zip",
"changelogURL": "https://raw.githubusercontent.com/jaghaimo/transpoffder/2.0.0/changelog.txt"
}
28 changes: 27 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,36 @@ repositories {
url 'https://github.com/'
patternLayout {
artifact '/[organization]/[module]/releases/download/[revision]/[ext]'
artifact '/[organization]/[module]/raw/[revision]/jars/[ext]'
}
metadataSources {
artifact()
}
}
}

// add zipped configuration
configurations {
zipped
}

// install dependencies from zipped releases
task installDependencies(type: Sync) {
def extractDir = "${buildDir}/libs"

ext.extractedJars = fileTree(extractDir) {
include "**/*.jar"
exclude "transpoffder.jar"
builtBy "installDependencies"
}

dependsOn configurations.zipped
from {
configurations.zipped.collect { zipTree(it) }
}
into extractDir
}

// project level config
java {
sourceCompatibility = JavaVersion.VERSION_1_7
Expand All @@ -38,7 +62,9 @@ build {

// compile time dependencies
dependencies {
implementation "jaghaimo:starsector-api:0.95.1a-RC6@starfarer.api.jar"
implementation "jaghaimo:starsector-api:0.96a-RC10@starfarer.api.jar"
zipped "Lukas22041:LunaLib:1.7.7@LunaLib.zip"
implementation files({ tasks.installDependencies.extractedJars })

// game dependencies
implementation group: 'com.thoughtworks.xstream', name: 'xstream', version: '1.4.10'
Expand Down
4 changes: 4 additions & 0 deletions src/transpoffder/AutoScavengeAbility.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

public class AutoScavengeAbility extends BaseToggleAbility {

public static boolean has() {
return getInstance() != null;
}

public static boolean isOn() {
return getInstance().isActive();
}
Expand Down
78 changes: 6 additions & 72 deletions src/transpoffder/TranspoffderMod.java
Original file line number Diff line number Diff line change
@@ -1,94 +1,28 @@
package transpoffder;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.EveryFrameScript;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.util.Misc;
import lombok.extern.log4j.Log4j;
import org.json.JSONObject;
import transpoffder.settings.Settings;
import transpoffder.settings.SettingsListener;

@Log4j
public class TranspoffderMod extends BaseModPlugin {

private JSONObject settings;

@Override
public void afterGameSave() {
if (hasQol("ScavengeAsYouFly")) {
restoreAutoScavenge();
}
Settings.SCAVENGE_AS_YOU_FLY.configure();
}

@Override
public void beforeGameSave() {
if (hasQol("ScavengeAsYouFly")) {
removeAutoScavenge();
}
Settings.SCAVENGE_AS_YOU_FLY.disable();
}

@Override
public void onApplicationLoad() throws Exception {
settings = Global.getSettings().loadJSON("transpoffder.json");
if (hasQol("BetterSensorBurst")) {
Global.getSettings().getAbilitySpec("sensor_burst").getTags().remove("burn-");
Global.getSettings().getAbilitySpec("sensor_burst").getTags().remove("sensors+");
log.info("Enabled better sensor burst");
}
SettingsListener.register();
}

@Override
public void onGameLoad(boolean newGame) {
if (hasQol("PartialSurveyAsYouFly")) {
addTransientScript(new PartialSurveyScript());
log.info("Enabled partial survey as you fly");
}
if (hasQol("ScavengeAsYouFly")) {
restoreAutoScavenge();
notifyAboutState();
log.info("Enabled scavenge as you fly");
}
if (hasQol("Transpoffder")) {
addTransientListener(new TranspoffderListener());
log.info("Enabled transpoffder");
}
}

private void addTransientListener(Object listener) {
Global.getSector().getListenerManager().addListener(listener, true);
}

private void addTransientScript(EveryFrameScript script) {
Global.getSector().addTransientScript(script);
}

private boolean hasQol(String key) {
return settings.optBoolean(key, true);
}

private void notifyAboutState() {
String state = AutoScavengeAbility.isOn() ? "enabled" : "disabled";
Global
.getSector()
.getCampaignUI()
.addMessage(
"Automatic scavenging is %s.",
Misc.getTextColor(),
state,
state,
Misc.getHighlightColor(),
Misc.getHighlightColor()
);
}

private void removeAutoScavenge() {
boolean isOn = AutoScavengeAbility.isOn();
Global.getSector().getMemoryWithoutUpdate().set("$transpoffderAutoScavenge", isOn);
Global.getSector().getCharacterData().removeAbility("auto_scavenge");
}

private void restoreAutoScavenge() {
Global.getSector().getCharacterData().addAbility("auto_scavenge");
boolean isOn = Global.getSector().getMemoryWithoutUpdate().getBoolean("$transpoffderAutoScavenge");
AutoScavengeAbility.setOn(isOn);
SettingsListener.configure();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.fs.starfarer.api.campaign.listeners.CurrentLocationChangedListener;
import com.fs.starfarer.api.impl.campaign.ids.Abilities;

public class TranspoffderListener implements CurrentLocationChangedListener {
public class TransponderOffListener implements CurrentLocationChangedListener {

@Override
public void reportCurrentLocationChanged(LocationAPI prev, LocationAPI curr) {
Expand Down
47 changes: 47 additions & 0 deletions src/transpoffder/Utils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package transpoffder;

import com.fs.starfarer.api.EveryFrameScript;
import com.fs.starfarer.api.GameState;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.util.Misc;

public class Utils {

public static void addTransientListener(Object listener) {
Global.getSector().getListenerManager().addListener(listener, true);
}

public static void addTransientScript(EveryFrameScript script) {
Global.getSector().addTransientScript(script);
}

public static boolean isInCampaign() {
return Global.getSettings().getCurrentState() == GameState.CAMPAIGN;
}

public static void quickNotify(String text, String highlight1, String highlight2) {
Global
.getSector()
.getCampaignUI()
.addMessage(
text,
Misc.getTextColor(),
highlight1,
highlight2,
Misc.getHighlightColor(),
Misc.getHighlightColor()
);
}

public static void removeTransientListeners(Class<?> clazz) {
Global.getSector().getListenerManager().removeListenerOfClass(clazz);
}

public static void removeTransientScripts(Class<?> clazz) {
for (EveryFrameScript script : Global.getSector().getTransientScripts()) {
if (clazz.isInstance(script)) {
Global.getSector().removeTransientScript(null);
}
}
}
}
22 changes: 22 additions & 0 deletions src/transpoffder/settings/BetterSensorBurst.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package transpoffder.settings;

import com.fs.starfarer.api.Global;
import lombok.extern.log4j.Log4j;

@Log4j
public class BetterSensorBurst implements Toggler {

@Override
public void enable() {
Global.getSettings().getAbilitySpec("sensor_burst").getTags().remove("burn-");
Global.getSettings().getAbilitySpec("sensor_burst").getTags().remove("sensors+");
log.info("Enabled better sensor burst");
}

@Override
public void disable() {
Global.getSettings().getAbilitySpec("sensor_burst").getTags().add("burn-");
Global.getSettings().getAbilitySpec("sensor_burst").getTags().add("sensors+");
log.info("Disabled better sensor burst");
}
}
21 changes: 21 additions & 0 deletions src/transpoffder/settings/PartialSurveyToggler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package transpoffder.settings;

import lombok.extern.log4j.Log4j;
import transpoffder.PartialSurveyScript;
import transpoffder.Utils;

@Log4j
public class PartialSurveyToggler implements Toggler {

@Override
public void enable() {
Utils.addTransientScript(new PartialSurveyScript());
log.info("Enabled partial survey as you fly");
}

@Override
public void disable() {
Utils.removeTransientScripts(PartialSurveyScript.class);
log.info("Disabled partial survey as you fly");
}
}
30 changes: 30 additions & 0 deletions src/transpoffder/settings/ScavengeAsYouFlyToggler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package transpoffder.settings;

import com.fs.starfarer.api.Global;
import lombok.extern.log4j.Log4j;
import transpoffder.AutoScavengeAbility;
import transpoffder.Utils;

@Log4j
public class ScavengeAsYouFlyToggler implements Toggler {

@Override
public void enable() {
boolean isOn = Global.getSector().getMemoryWithoutUpdate().getBoolean("$transpoffderAutoScavenge");
Global.getSector().getCharacterData().addAbility("auto_scavenge");
AutoScavengeAbility.setOn(isOn);
String state = isOn ? "enabled" : "disabled";
Utils.quickNotify("Automatic scavenging is %s.", state, state);
log.info("Enabled scavenge as you fly");
}

@Override
public void disable() {
if (AutoScavengeAbility.has()) {
boolean isOn = AutoScavengeAbility.isOn();
Global.getSector().getMemoryWithoutUpdate().set("$transpoffderAutoScavenge", isOn);
Global.getSector().getCharacterData().removeAbility("auto_scavenge");
}
log.info("Disabled scavenge as you fly");
}
}
Loading