Skip to content

Commit

Permalink
0.96a, better key names in HUD, fixed issue with one of the examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
scardwell15 committed May 5, 2023
1 parent 5098374 commit 5fc0f4f
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 15 deletions.
2 changes: 1 addition & 1 deletion combatactivators.version
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
{
"major":1,
"minor":0,
"patch":2
"patch":3
}
}
Binary file added image.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 modified jars/CombatActivators.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions mod_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"name": "Combat Activators",
"author": "President Matt Damon",
"utility": "true",
"version": { "major":"1", "minor": "0", "patch": "2" },
"version": { "major":"1", "minor": "0", "patch": "3" },
"description": "Abilities that can be activated during combat.",
"gameVersion": "0.95.1a-RC6",
"gameVersion": "0.96a",
"jars":["jars/CombatActivators.jar"],
"modPlugin":"activators.CombatActivatorsModPlugin",
"dependencies": [
Expand Down
6 changes: 3 additions & 3 deletions src/activators/ActivatorManager.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package activators

import activators.examples.AmmoFeedersActivator
import com.fs.starfarer.api.Global
import com.fs.starfarer.api.combat.ShipAPI
import com.fs.starfarer.api.combat.ViewportAPI
Expand All @@ -12,7 +13,7 @@ object ActivatorManager {

fun initialize() {
reloadKeys()
Global.getSector().listenerManager.addListener(LunaKeybindSettingsListener(), true)
LunaSettings.addListener(LunaKeybindSettingsListener())
}

@JvmStatic
Expand Down Expand Up @@ -53,8 +54,7 @@ object ActivatorManager {

@JvmStatic
fun drawActivatorsUI(viewport: ViewportAPI) {
if (Global.getCombatEngine().combatUI != null
&& (Global.getCombatEngine().combatUI.isShowingCommandUI || Global.getCombatEngine().combatUI.isShowingDeploymentDialog)) {
if (Global.getCombatEngine().combatUI == null || Global.getCombatEngine().combatUI.isShowingCommandUI || Global.getCombatEngine().combatUI.isShowingDeploymentDialog) {
return
}

Expand Down
39 changes: 33 additions & 6 deletions src/activators/CombatActivator.java
Original file line number Diff line number Diff line change
Expand Up @@ -571,15 +571,42 @@ public Color getHUDColor() {
return MagicLibRendering.GREENCOLOR;
}

public String getKeyText() {
int keycode = -1;
if (getKeyIndex() >= 0 && ActivatorManager.INSTANCE.getKeyList().size() > getKeyIndex()) {
keycode = ActivatorManager.INSTANCE.getKeyList().get(getKeyIndex());
}

switch (keycode) {
case -1:
return "N/A";
case Keyboard.KEY_LMENU:
return "L-ALT";
case Keyboard.KEY_RMENU:
return "R-ALT";
case Keyboard.KEY_LCONTROL:
return "L-CTRL";
case Keyboard.KEY_RCONTROL:
return "R-CTRL";
case Keyboard.KEY_LSHIFT:
return "L-SHIFT";
case Keyboard.KEY_RSHIFT:
return "R-SHIFT";
case Keyboard.KEY_CAPITAL:
return "CAPS";
case Keyboard.KEY_RETURN:
return "ENTER";
case Keyboard.KEY_BACK:
return "BKSPC";
default:
return Keyboard.getKeyName(keycode).toUpperCase();
}
}

public void drawHUDBar(ViewportAPI viewport, Vector2f barLoc) {
MagicLibRendering.setTextAligned(LazyFont.TextAlignment.LEFT);

String keyText = getKey();
if (getKeyIndex() >= 0) {
if (ActivatorManager.INSTANCE.getKeyList().size() > getKeyIndex()) {
keyText = Keyboard.getKeyName(ActivatorManager.INSTANCE.getKeyList().get(getKeyIndex()));
}
}
String keyText = getKeyText();

String nameText = String.format("%s (%s)", getDisplayText(), keyText);
float nameWidth = MagicLibRendering.getTextWidth(nameText);
Expand Down
6 changes: 4 additions & 2 deletions src/activators/CombatActivatorsModPlugin.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package activators

import com.fs.starfarer.api.BaseModPlugin
import com.fs.starfarer.api.Global

class CombatActivatorsModPlugin: BaseModPlugin() {
override fun onGameLoad(newGame: Boolean) {
override fun onApplicationLoad() {
ActivatorManager.initialize()
}

override fun onGameLoad(newGame: Boolean) {
}
}
8 changes: 7 additions & 1 deletion src/activators/examples/AmmoFeedersActivator.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ public boolean shouldActivateAI(float amount) {
@Override
public void onActivate() {
stats.getBallisticWeaponFluxCostMod().modifyMult(this.getDisplayText(), 0.5f);
stats.getBallisticRoFMult().modifyMult(this.getDisplayText(), 0.5f);
stats.getBallisticRoFMult().modifyMult(this.getDisplayText(), 2f);
}

@Override
public void onFinished() {
stats.getBallisticWeaponFluxCostMod().unmodify(this.getDisplayText());
stats.getBallisticRoFMult().unmodify(this.getDisplayText());
}

@Override
Expand Down

0 comments on commit 5fc0f4f

Please sign in to comment.