Skip to content

Commit

Permalink
WIP #12: actually check in energy slider
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobmaxfrank committed Feb 2, 2016
1 parent e9e08e2 commit 3d1aab9
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
Binary file added art/energy_icon_white.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 added art/energy_icon_with_color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions src/com/brindyblitz/artemis/engconsole/ui/EnergySlider.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.brindyblitz.artemis.engconsole.ui;

import com.brindyblitz.artemis.engconsole.EngineeringConsoleManager;
import net.dhleong.acl.enums.ShipSystem;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class EnergySlider extends SystemStatusSlider {

private static final long serialVersionUID = 1L;

private static BufferedImage statusImageWithColor = null, statusImageWhite = null;

protected static final int
WIDGET_HEIGHT = 20,
WIDGET_WIDTH = 400,
SLIDER_WIDTH = WIDGET_WIDTH / 2,
SLIDER_HEIGHT = WIDGET_HEIGHT;

private static final Color ENERGY_COLOR = Color.BLUE;

public EnergySlider(ShipSystem system, EngineeringConsoleManager engineeringConsoleManager) {
super(system, engineeringConsoleManager, WIDGET_WIDTH, WIDGET_HEIGHT, SLIDER_WIDTH, SLIDER_HEIGHT);
}

@Override
protected int getStatusPctInt() {
// TODO: >>> TESTME
return 100 * (int)(this.engineeringConsoleManager.getTotalEnergyRemaining() / 1000f);
}

@Override
protected void loadIcons() {
try {
if (statusImageWithColor == null) {
statusImageWithColor = ImageIO.read(new File(System.getProperty("user.dir"), "/art/energy_icon_with_color.png"));
statusImageWhite = ImageIO.read(new File(System.getProperty("user.dir"), "/art/energy_icon_white.png"));
}
} catch (IOException e) {
System.err.println("Unable to locate system status icon(s)");
e.printStackTrace(System.err);
throw new RuntimeException();
}
}

@Override
protected BufferedImage getStatusImageWithColor() {
return statusImageWithColor;
}

@Override
protected BufferedImage getStatusImageWhite() {
return statusImageWhite;
}

@Override
protected Color getStatusColor() {
return ENERGY_COLOR;
}

@Override
protected float getFullHue() {
throw new UnsupportedOperationException();
}

@Override
protected float getEmptyHue() {
throw new UnsupportedOperationException();
}
}

0 comments on commit 3d1aab9

Please sign in to comment.