Hello, I got a little annoyed that ships look blurry when zoomed in so I wrote a batch script that upscaled all images 2x with ffmpeg nearest neighbor filter.
That works great for ships because they are automatically scaled down to a fixed size ingame.
Weapons don't work out of the box so I tried writing a mod that scales them down.
I've used the following code to scale the weapons down:
public class UpscaleCombatPlugin extends BaseEveryFrameCombatPlugin {
private CombatEngineAPI engine;
private List<WeaponAPI> adjustedWeapons;
@Override
public void init(CombatEngineAPI engine){
this.engine = engine;
for(ShipAPI ship: engine.getShips()){
System.out.println(ship.getName());
}
adjustedWeapons = new ArrayList<WeaponAPI>();
}
@Override
public void advance(float amount, List<InputEventAPI> events) {
if (engine == null || engine.getCombatUI() == null) return;
if (engine.getCombatUI().isShowingCommandUI()) return;
for(ShipAPI ship: engine.getShips()){
adjustShip(ship);
}
}
private void adjustShip(ShipAPI ship){
List<WeaponAPI> weapons = ship.getAllWeapons();
for (WeaponAPI weapon: weapons) {
if (adjustedWeapons.contains(weapon)) continue;
adjustSprite(weapon.getSprite(), 2.0f);
adjustSprite(weapon.getUnderSpriteAPI(), 2.0f);
adjustSprite(weapon.getBarrelSpriteAPI(), 2.0f);
adjustSprite(weapon.getGlowSpriteAPI(), 2.0f);
adjustedWeapons.add(weapon);
}
}
private void adjustSprite(SpriteAPI sprite, float factor) {
if (sprite == null) return;
float width = sprite.getWidth() / factor;
float height = sprite.getHeight() / factor;
sprite.setSize(width, height);
sprite.setCenter(sprite.getCenterX()/ factor, sprite.getCenterY() / factor);
}
}
It works kinda.
The weapon bases work without issue.
The barrels work for hardpoints as far as I can tell.
Turret barrels don't seem to use the CenterY value after the sprite size was changed(no matter to what value I change CenterY for a turret barrel it won't move vertically).
Is there a way to work around that that I'm not aware?
Also animated weapons(chaingun for example) don't work(I could run the resize every frame by saving the sprites to a list or something along those lines).
Is there a way to get all sprites of an animation beforehand?
Also this doesn't work in the refit screen and I can't seem to find a way to do it via the api.
Is there a way to access a ship in the refit screen somehow?