Core database tabs
This commit is contained in:
@@ -5755,43 +5755,51 @@ public class Blocks{
|
||||
requirements(Category.power, BuildVisibility.sandboxOnly, with());
|
||||
powerProduction = 1000000f / 60f;
|
||||
alwaysUnlocked = true;
|
||||
allDatabaseTabs = true;
|
||||
}};
|
||||
|
||||
powerVoid = new PowerVoid("power-void"){{
|
||||
requirements(Category.power, BuildVisibility.sandboxOnly, with());
|
||||
alwaysUnlocked = true;
|
||||
allDatabaseTabs = true;
|
||||
}};
|
||||
|
||||
itemSource = new ItemSource("item-source"){{
|
||||
requirements(Category.distribution, BuildVisibility.sandboxOnly, with());
|
||||
alwaysUnlocked = true;
|
||||
allDatabaseTabs = true;
|
||||
}};
|
||||
|
||||
itemVoid = new ItemVoid("item-void"){{
|
||||
requirements(Category.distribution, BuildVisibility.sandboxOnly, with());
|
||||
alwaysUnlocked = true;
|
||||
allDatabaseTabs = true;
|
||||
}};
|
||||
|
||||
liquidSource = new LiquidSource("liquid-source"){{
|
||||
requirements(Category.liquid, BuildVisibility.sandboxOnly, with());
|
||||
alwaysUnlocked = true;
|
||||
allDatabaseTabs = true;
|
||||
}};
|
||||
|
||||
liquidVoid = new LiquidVoid("liquid-void"){{
|
||||
requirements(Category.liquid, BuildVisibility.sandboxOnly, with());
|
||||
alwaysUnlocked = true;
|
||||
allDatabaseTabs = true;
|
||||
}};
|
||||
|
||||
payloadSource = new PayloadSource("payload-source"){{
|
||||
requirements(Category.units, BuildVisibility.sandboxOnly, with());
|
||||
size = 5;
|
||||
alwaysUnlocked = true;
|
||||
allDatabaseTabs = true;
|
||||
}};
|
||||
|
||||
payloadVoid = new PayloadVoid("payload-void"){{
|
||||
requirements(Category.units, BuildVisibility.sandboxOnly, with());
|
||||
size = 5;
|
||||
alwaysUnlocked = true;
|
||||
allDatabaseTabs = true;
|
||||
}};
|
||||
|
||||
heatSource = new HeatProducer("heat-source"){{
|
||||
@@ -5945,6 +5953,7 @@ public class Blocks{
|
||||
size = 1;
|
||||
maxInstructionsPerTick = 1000;
|
||||
range = Float.MAX_VALUE;
|
||||
allDatabaseTabs = true;
|
||||
}};
|
||||
|
||||
worldCell = new MemoryBlock("world-cell"){{
|
||||
@@ -5954,6 +5963,7 @@ public class Blocks{
|
||||
privileged = true;
|
||||
memoryCapacity = 128;
|
||||
forceDark = true;
|
||||
allDatabaseTabs = true;
|
||||
}};
|
||||
|
||||
worldMessage = new MessageBlock("world-message"){{
|
||||
@@ -5961,6 +5971,7 @@ public class Blocks{
|
||||
|
||||
targetable = false;
|
||||
privileged = true;
|
||||
allDatabaseTabs = true;
|
||||
}};
|
||||
|
||||
worldSwitch = new SwitchBlock("world-switch"){{
|
||||
@@ -5968,6 +5979,7 @@ public class Blocks{
|
||||
|
||||
targetable = false;
|
||||
privileged = true;
|
||||
allDatabaseTabs = true;
|
||||
}};
|
||||
|
||||
//endregion
|
||||
|
||||
@@ -139,6 +139,11 @@ public class TechTree{
|
||||
}
|
||||
}
|
||||
|
||||
/** Adds the specified tab to all the content in this tree. */
|
||||
public void addDatabaseTab(UnlockableContent tab){
|
||||
each(node -> node.content.databaseTabs.add(tab));
|
||||
}
|
||||
|
||||
public Drawable icon(){
|
||||
return icon == null ? new TextureRegionDrawable(content.uiIcon) : icon;
|
||||
}
|
||||
|
||||
@@ -35,8 +35,6 @@ public abstract class UnlockableContent extends MappableContent{
|
||||
public boolean hideDetails = true;
|
||||
/** If false, all icon generation is disabled for this content; createIcons is not called. */
|
||||
public boolean generateIcons = true;
|
||||
/** Special logic icon ID. */
|
||||
public int iconId = 0;
|
||||
/** How big the content appears in certain selection menus */
|
||||
public float selectionSize = 24f;
|
||||
/** Icon of the content to use in UI. */
|
||||
@@ -45,6 +43,10 @@ public abstract class UnlockableContent extends MappableContent{
|
||||
public TextureRegion fullIcon;
|
||||
/** Override for the full icon. Useful for mod content with duplicate icons. Overrides any other full icon.*/
|
||||
public String fullOverride = "";
|
||||
/** If true, this content will appear in all database tabs. */
|
||||
public boolean allDatabaseTabs = false;
|
||||
/** Content - usually a planet - that dictates which database tab(s) this content will appear in. If nothing is defined, Serpulo is considered to be the "default" tab. */
|
||||
public ObjectSet<UnlockableContent> databaseTabs = new ObjectSet<>();
|
||||
/** The tech tree node for this content, if applicable. Null if not part of a tech tree. */
|
||||
public @Nullable TechNode techNode;
|
||||
/** Tech nodes for all trees that this content is part of. */
|
||||
|
||||
@@ -338,6 +338,10 @@ public class Planet extends UnlockableContent{
|
||||
techTree = TechTree.roots.find(n -> n.planet == this);
|
||||
}
|
||||
|
||||
if(techTree != null){
|
||||
techTree.addDatabaseTab(this);
|
||||
}
|
||||
|
||||
for(Sector sector : sectors){
|
||||
sector.loadInfo();
|
||||
}
|
||||
|
||||
@@ -68,10 +68,12 @@ public class StatusEffect extends UnlockableContent{
|
||||
|
||||
public StatusEffect(String name){
|
||||
super(name);
|
||||
allDatabaseTabs = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
super.init();
|
||||
if(initblock != null){
|
||||
initblock.run();
|
||||
}
|
||||
|
||||
@@ -675,6 +675,8 @@ public class UnitType extends UnlockableContent implements Senseable{
|
||||
@CallSuper
|
||||
@Override
|
||||
public void init(){
|
||||
super.init();
|
||||
|
||||
if(constructor == null) throw new IllegalArgumentException("no constructor set up for unit '" + name + "'");
|
||||
|
||||
Unit example = constructor.get();
|
||||
|
||||
@@ -5,11 +5,13 @@ import arc.graphics.*;
|
||||
import arc.input.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.event.*;
|
||||
import arc.scene.style.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
@@ -24,16 +26,30 @@ public class DatabaseDialog extends BaseDialog{
|
||||
private TextField search;
|
||||
private Table all = new Table();
|
||||
|
||||
private @Nullable Seq<UnlockableContent> allTabs;
|
||||
//sun means "all content"
|
||||
private UnlockableContent tab = Planets.sun;
|
||||
|
||||
public DatabaseDialog(){
|
||||
super("@database");
|
||||
|
||||
shouldPause = true;
|
||||
addCloseButton();
|
||||
shown(this::rebuild);
|
||||
shown(() -> {
|
||||
checkTabList();
|
||||
if(state.isCampaign() && allTabs.contains(state.getPlanet())){
|
||||
tab = state.getPlanet();
|
||||
}else if(state.isGame() && state.rules.planet != null && allTabs.contains(state.rules.planet)){
|
||||
tab = state.rules.planet;
|
||||
}
|
||||
|
||||
rebuild();
|
||||
});
|
||||
onResize(this::rebuild);
|
||||
|
||||
all.margin(20).marginTop(0f);
|
||||
|
||||
cont.top();
|
||||
cont.table(s -> {
|
||||
s.image(Icon.zoom).padRight(8);
|
||||
search = s.field(null, text -> rebuild()).growX().get();
|
||||
@@ -43,18 +59,51 @@ public class DatabaseDialog extends BaseDialog{
|
||||
cont.pane(all).scrollX(false);
|
||||
}
|
||||
|
||||
void checkTabList(){
|
||||
if(allTabs == null){
|
||||
Seq<Content>[] allContent = Vars.content.getContentMap();
|
||||
ObjectSet<UnlockableContent> all = new ObjectSet<>();
|
||||
for(var contents : allContent){
|
||||
for(var content : contents){
|
||||
if(content instanceof UnlockableContent u){
|
||||
all.addAll(u.databaseTabs);
|
||||
}
|
||||
}
|
||||
}
|
||||
allTabs = all.toSeq().sort();
|
||||
allTabs.insert(0, Planets.sun);
|
||||
}
|
||||
}
|
||||
|
||||
void rebuild(){
|
||||
checkTabList();
|
||||
|
||||
all.clear();
|
||||
var text = search.getText().toLowerCase();
|
||||
|
||||
Seq<Content>[] allContent = Vars.content.getContentMap();
|
||||
|
||||
all.table(t -> {
|
||||
int i = 0;
|
||||
for(var content : allTabs){
|
||||
t.button(content == Planets.sun ? Icon.eyeSmall : content instanceof Planet ? Icon.planet : new TextureRegionDrawable(content.uiIcon), Styles.clearNoneTogglei, iconMed, () -> {
|
||||
tab = content;
|
||||
rebuild();
|
||||
}).size(50f).checked(b -> tab == content).tooltip(content == Planets.sun ? "@all" : content.localizedName).with(but -> {
|
||||
but.getStyle().imageUpColor = content instanceof Planet p ? p.iconColor : Color.white.cpy();
|
||||
});
|
||||
|
||||
if(++i % 10 == 0) t.row();
|
||||
}
|
||||
}).row();;
|
||||
|
||||
for(int j = 0; j < allContent.length; j++){
|
||||
ContentType type = ContentType.all[j];
|
||||
|
||||
Seq<UnlockableContent> array = allContent[j]
|
||||
.select(c -> c instanceof UnlockableContent u && !u.isHidden() &&
|
||||
.select(c -> c instanceof UnlockableContent u && !u.isHidden() && (tab == Planets.sun || u.allDatabaseTabs || (u.databaseTabs.isEmpty() && tab == Planets.serpulo) || u.databaseTabs.contains(tab)) &&
|
||||
(text.isEmpty() || u.localizedName.toLowerCase().contains(text))).as();
|
||||
|
||||
if(array.size == 0) continue;
|
||||
|
||||
all.add("@content." + type.name() + ".name").growX().left().color(Pal.accent);
|
||||
|
||||
@@ -1168,6 +1168,8 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
@Override
|
||||
@CallSuper
|
||||
public void init(){
|
||||
super.init();
|
||||
|
||||
//disable standard shadow
|
||||
if(customShadow){
|
||||
hasShadow = false;
|
||||
|
||||
Reference in New Issue
Block a user