-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP #12: actually check in energy slider
- Loading branch information
1 parent
e9e08e2
commit 3d1aab9
Showing
3 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
74
src/com/brindyblitz/artemis/engconsole/ui/EnergySlider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |