Made content icon system more sane

This commit is contained in:
Anuken
2019-10-01 23:46:40 -04:00
parent d9b8335e0e
commit 2db3060a03
50 changed files with 10457 additions and 7591 deletions
@@ -0,0 +1,23 @@
package io.anuke.mindustry.game;
import java.util.*;
/** Defines sizes of a content's preview icon. */
public enum Cicon{
/** Full size. */
full(0),
tiny(8 * 2),
small(8 * 3),
medium(8 * 4),
large(8 * 5),
xlarge(8 * 6);
public static final Cicon[] all = values();
public static final Cicon[] scaled = Arrays.copyOfRange(all, 1, all.length);
public final int size;
Cicon(int size){
this.size = size;
}
}
@@ -1,9 +1,9 @@
package io.anuke.mindustry.game;
import io.anuke.arc.Core;
import io.anuke.arc.graphics.g2d.TextureRegion;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.mindustry.Vars;
import io.anuke.arc.*;
import io.anuke.arc.graphics.g2d.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.mindustry.*;
/** Base interface for an unlockable content type. */
public abstract class UnlockableContent extends MappableContent{
@@ -11,6 +11,8 @@ public abstract class UnlockableContent extends MappableContent{
public String localizedName;
/** Localized description. May be null. */
public String description;
/** Icons by Cicon ID.*/
protected TextureRegion[] cicons = new TextureRegion[Cicon.all.length];
public UnlockableContent(String name){
super(name);
@@ -19,10 +21,22 @@ public abstract class UnlockableContent extends MappableContent{
this.description = Core.bundle.getOrNull(getContentType() + "." + name + ".description");
}
public void createIcons(){
//TODO implement.
}
/** Returns a specific content icon, or the region {contentType}-{name} if not found.*/
public TextureRegion icon(Cicon icon){
if(cicons[icon.ordinal()] == null){
cicons[icon.ordinal()] = Core.atlas.find(getContentType().name() + "-" + name + "-" + icon.name(), Core.atlas.find(getContentType().name() + "-" + name + "-full", Core.atlas.find(getContentType().name() + "-" + name, Core.atlas.find(name))));
}
return cicons[icon.ordinal()];
}
/** Returns the localized name of this content. */
public abstract String localizedName();
public abstract TextureRegion getContentIcon();
//public abstract TextureRegion getContentIcon();
/** This should show all necessary info about this content in the specified table. */
public abstract void displayInfo(Table table);