Skip to content

Commit

Permalink
Merge pull request #183 from Koud-Wind/Configurable-bullet-counter
Browse files Browse the repository at this point in the history
Configurable bullet counter
  • Loading branch information
Koud-Wind committed Jun 29, 2023
2 parents 14157df + a61b370 commit 937e82d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 14 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ and this project follows to [Ragnarök Versioning Convention](https://gist.githu
- penetrableBlocks
- knockbackOnHi
- hipFireSpread
- ammoCounterX \ ammoCounterY
- ammoCounterSize \ ammoCounterBackgroundReverse
- Durability to all vests as a temporary measure to resolve vest-related issues
- Smelting of sulfur into gunpowder
- .50 AE in the Ammo Press
Expand Down
30 changes: 20 additions & 10 deletions src/main/java/com/paneedah/weaponlib/CustomGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public void handleModificationHUD(RenderGameOverlayEvent.Pre event, PlayerWeapon
// Ammo counter spec
public static final int AMMO_COUNTER_WIDTH = 256;
public static final int AMMO_COUNTER_HEIGHT = 53;
public static final double AMMO_COUNTER_SCALE = 0.50;
//public static final double AMMO_COUNTER_SCALE = 0.50;

// Weapon name
public static final int AMMO_COUNTER_WEAPON_NAME_DOWNSCALE_THRESHOLD = 13;
Expand Down Expand Up @@ -277,17 +277,20 @@ public void handleModificationHUD(RenderGameOverlayEvent.Pre event, PlayerWeapon
public static final double CURRENT_AMMO_WIDTH_MULTIPLIER = 2.0;
public static final double TOTAL_AMMO_STRING_SCALE = 6.625;

public void handleAmmoCounter(RenderGameOverlayEvent.Pre event, PlayerWeaponInstance weaponInstance, double scaledWidth, double scaledHeight) { final int AMMO_COUNTER_Y_POS = 128;

public void handleAmmoCounter(RenderGameOverlayEvent.Pre event, PlayerWeaponInstance weaponInstance, double scaledWidth, double scaledHeight) {
//If moved up, the game needs to be restarted every time there is a change

This comment has been minimized.

Copy link
@Desoroxxx

Desoroxxx Jun 30, 2023

Collaborator

Why??? why not make it not mutable and allow hot reloading???
This is terrible, imagine moving the UI and not liking it restarting the modpack for 10 minutes oh wait I want it to the right, 10 minutes later oh shit a little bit down

This comment has been minimized.

Copy link
@Koud-Wind

Koud-Wind Jun 30, 2023

Author Collaborator

This can hot reload

This comment has been minimized.

Copy link
@Desoroxxx

Desoroxxx Jun 30, 2023

Collaborator

This can hot reload

Then why does the comment says that it needs to be restarted?

final int AMMO_COUNTER_X_POS = 256 + ModernConfigManager.ammoCounterX;
final int AMMO_COUNTER_Y_POS = 128 + ModernConfigManager.ammoCounterY;
final double AMMO_COUNTER_SIZE = ModernConfigManager.ammoCounterSize;


GlStateManager.enableBlend();
GlStateManager.pushMatrix();

GlStateManager.translate((scaledWidth - AMMO_COUNTER_WIDTH * AMMO_COUNTER_SCALE), (scaledHeight - AMMO_COUNTER_Y_POS * AMMO_COUNTER_SCALE), 0);
GlStateManager.scale(AMMO_COUNTER_SCALE, AMMO_COUNTER_SCALE, AMMO_COUNTER_SCALE);
GlStateManager.translate((scaledWidth - AMMO_COUNTER_X_POS * AMMO_COUNTER_SIZE), (scaledHeight - AMMO_COUNTER_Y_POS * AMMO_COUNTER_SIZE), 0);
GlStateManager.scale(AMMO_COUNTER_SIZE, AMMO_COUNTER_SIZE, AMMO_COUNTER_SIZE);
mc.getTextureManager().bindTexture(AMMO_COUNTER_TEXTURES);


// Figure out the firemode, and assign it an ID
int firemode = 0;
switch(weaponInstance.getMaxShots()) {
Expand Down Expand Up @@ -327,17 +330,24 @@ public void handleModificationHUD(RenderGameOverlayEvent.Pre event, PlayerWeapon
double keyNameOffset = getFontRenderer().getStringWidth(keyNameString);

// Render main ammo counter body
if(ModernConfigManager.enableAmmoCounterBackground) drawTexturedModalRect(0, 0, 0, 0, AMMO_COUNTER_WIDTH, AMMO_COUNTER_HEIGHT);


if(ModernConfigManager.enableAmmoCounterBackground) {
if(ModernConfigManager.ammoCounterBackgroundReverse) {
GlStateManager.enableBlend();
GlStateManager.pushMatrix();
GlStateManager.scale(-1, 1, 1);
drawTexturedModalRect(-90, 0, 0, 0, -AMMO_COUNTER_WIDTH, AMMO_COUNTER_HEIGHT);
GlStateManager.popMatrix();
} else
drawTexturedModalRect(0, 0, 0, 0, AMMO_COUNTER_WIDTH, AMMO_COUNTER_HEIGHT);
}

// Draw the firemode indicator

GlStateManager.pushMatrix();
GlStateManager.translate(AMMO_COUNTER_WIDTH - FIREMODE_INDICATOR_X_OFFSET - (keyNameOffset * KEY_NAME_OFFSET_FIREMODE_INDICATOR_MULTIPLIER), FIREMODE_INDICATOR_Y_OFFSET, 0);
GlStateManager.scale(FIREMODE_INDICATOR_SCALE, FIREMODE_INDICATOR_SCALE, FIREMODE_INDICATOR_SCALE);
GlStateManager.enableBlend();
drawTexturedModalRect(0, 0,
drawTexturedModalRect(0, 0,
FIREMODE_INDICATOR_U_OFFSET + FIREMODE_INDICATOR_U_WIDTH * (Weapon.FIREMODE_AUTO - firemode),
FIREMODE_INDICATOR_V_HEIGHT, FIREMODE_INDICATOR_U_WIDTH, FIREMODE_INDICATOR_U_WIDTH);
GlStateManager.popMatrix();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,28 @@ public class ModernConfigManager {
// Fixing Method
@ConfigSync(category = CATEGORY_GAMEPLAY, comment = "Enables the ammo counter")
public static boolean enableAmmoCounter = true;


@ConfigSync(category = CATEGORY_GAMEPLAY, comment = "")
public static int ammoCounterX = 0;

@ConfigSync(category = CATEGORY_GAMEPLAY, comment = "")
public static int ammoCounterY = 0;

@RangeDouble(min=0.1, max=3.0)
@ConfigSync(category = CATEGORY_GAMEPLAY, comment = "")
public static double ammoCounterSize = 0.50;

@ConfigSync(category = CATEGORY_GAMEPLAY, comment = "Enables the black background on the ammo counter.")
public static boolean enableAmmoCounterBackground = true;

@ConfigSync(category = CATEGORY_GAMEPLAY, comment = "")
public static boolean ammoCounterBackgroundReverse = false;

@ConfigSync(category = CATEGORY_GAMEPLAY, comment = "Enable open door key display when hovering doors")
public static boolean enableOpenDoorDisplay = true;

@ConfigSync(category = CATEGORY_GAMEPLAY, comment = "If true, hold to aim. If false, toggle to aim.")
public static boolean holdToAim = true;

@ConfigSync(category = CATEGORY_GAMEPLAY, comment = "Enables the black background on the ammo counter.")
public static boolean enableAmmoCounterBackground = true;

@RangeDouble(min=0.0, max=1.0)
@ConfigSync(category = CATEGORY_GAMEPLAY, comment = "Should players bleed when hit?")
Expand Down

0 comments on commit 937e82d

Please sign in to comment.