Power armor GUI now indicates installed modules with checkmarks. Config-disallowed modules are hidden from view unless they are installed, then they're displayed with an X, allowing them to be salvaged.

This commit is contained in:
Lyneira 2013-04-07 22:45:46 +02:00
parent a38d0aee23
commit 2f80830224
4 changed files with 63 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

View file

@ -606,4 +606,32 @@ public abstract class MuseRenderer {
matrix.put(10, scalez);
GL11.glLoadMatrix(matrix);
}
public static void drawCheckmark(double x, double y, Colour colour) {
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_DEPTH_TEST);
texturelessOff();
blendingOn();
if (colour != null) {
colour.doGL();
}
getRenderEngine().bindTexture("/mods/mmmPowersuits/textures/gui/checkmark.png");
Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
tess.addVertexWithUV(x, y, 0.0F, 0.0F, 0.0F);
tess.addVertexWithUV(x, y + 16, 0.0F, 0.0F, 1.0F);
tess.addVertexWithUV(x + 16, y + 16, 0.0F, 1.0F, 1.0F);
tess.addVertexWithUV(x + 16, y, 0.0F, 1.0F, 0.0F);
tess.draw();
MuseRenderer.blendingOff();
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glPopMatrix();
}
}

View file

@ -17,6 +17,8 @@ import net.machinemuse.general.geometry.MusePoint2D;
*/
public class ClickableModule extends Clickable {
protected IPowerModule module;
protected boolean allowed = true;
protected boolean installed = false;
/**
* @param vaug
@ -38,13 +40,17 @@ public class ClickableModule extends Clickable {
@Override
public void draw() {
Colour c1 = new Colour(1.0F, 0.2F, 0.6F, 1.0F);
Colour c2 = new Colour(0.6F, 0.2F, 1.0F, 1.0F);
Colour.getGreyscale(1.0f, 1.0f).doGL();
MuseRenderer.TEXTURE_MAP = getModule().getStitchedTexture(null);
MuseRenderer.drawIconAt(getPosition().x() - 8, getPosition().y() - 8, getModule().getIcon(null), null);
// Draw the status indicators slightly lower and to the right so they stand out a little more.
if (! allowed) {
String string = MuseStringUtils.wrapFormatTags("x", MuseStringUtils.FormatCodes.DarkRed);
MuseRenderer.drawString(string, getPosition().x() + 3, getPosition().y() + 1);
} else if (installed) {
MuseRenderer.drawCheckmark(getPosition().x() - 8 + 1, getPosition().y() - 8 + 1, new Colour(0.0F, 0.667F, 0.0F, 1.0F));
}
}
@Override
@ -67,4 +73,12 @@ public class ClickableModule extends Clickable {
return this.module.equals(other.module);
}
public void setAllowed(boolean allowed) {
this.allowed = allowed;
}
public void setInstalled(boolean installed) {
this.installed = installed;
}
}

View file

@ -86,6 +86,16 @@ public class ModuleSelectionFrame extends ScrollableFrame {
categories = new HashMap();
List<IPowerModule> workingModules = MuseItemUtils.getValidModulesForItem(null, selectedItem.getItem());
// Prune the list of disallowed modules, if not installed on this item.
for (Iterator<IPowerModule> it = workingModules.iterator(); it.hasNext();) {
IPowerModule module = it.next();
if (module.isAllowed() == false &&
MuseItemUtils.itemHasModule(selectedItem.getItem(), module.getName()) == false) {
it.remove();
}
}
if (workingModules.size() > 0) {
List<MusePoint2D> points = MuseRenderer.pointsInLine(
workingModules.size(),
@ -96,6 +106,13 @@ public class ModuleSelectionFrame extends ScrollableFrame {
for (IPowerModule module : workingModules) {
ModuleSelectionSubFrame frame = getOrCreateCategory(module.getCategory());
ClickableModule moduleClickable = frame.addModule(module);
// Indicate installed modules
if (module.isAllowed() == false) {
// If a disallowed module made it to the list, indicate it as disallowed
moduleClickable.setAllowed(false);
} else if (MuseItemUtils.itemHasModule(selectedItem.getItem(), module.getName())) {
moduleClickable.setInstalled(true);
}
if (moduleClickable.getModule().equals(this.prevSelection)) {
this.selectedModule = moduleButtons.size();
}