This commit is contained in:
Anuken
2025-07-01 19:38:44 -04:00
parent ecb3984110
commit c035cf00dd
4 changed files with 20 additions and 8 deletions

View File

@@ -95,6 +95,10 @@ public abstract class UnlockableContent extends MappableContent{
uiIcon = Core.atlas.find(getContentType().name() + "-" + name + "-ui", fullIcon);
}
public boolean isBanned(){
return false;
}
public boolean isOnPlanet(@Nullable Planet planet){
return planet == null || planet == Planets.sun || shownPlanets.isEmpty() || shownPlanets.contains(planet);
}

View File

@@ -700,6 +700,7 @@ public class UnitType extends UnlockableContent implements Senseable{
return (envEnabled & env) != 0 && (envDisabled & env) == 0 && (envRequired == 0 || (envRequired & env) == envRequired);
}
@Override
public boolean isBanned(){
return state.rules.isBanned(this);
}

View File

@@ -17,7 +17,6 @@ import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.*;
import static arc.Core.*;
import static mindustry.Vars.*;
@@ -95,7 +94,7 @@ public class DatabaseDialog extends BaseDialog{
if(++i % 10 == 0) t.row();
}
}).row();;
}).row();
for(int j = 0; j < allContent.length; j++){
ContentType type = ContentType.all[j];
@@ -106,6 +105,11 @@ public class DatabaseDialog extends BaseDialog{
if(array.size == 0) continue;
//sorting only makes sense when in-game; otherwise, banned blocks can't exist
if(state.isGame()){
array.sort(Structs.comps(Structs.comparingBool(UnlockableContent::isBanned), Structs.comparingInt(u -> u.id)));
}
all.add("@content." + type.name() + ".name").growX().left().color(Pal.accent);
all.row();
all.image().growX().pad(5).padLeft(0).padRight(0).height(3).color(Pal.accent);
@@ -116,13 +120,11 @@ public class DatabaseDialog extends BaseDialog{
int cols = (int)Mathf.clamp((Core.graphics.getWidth() - Scl.scl(30)) / Scl.scl(32 + 12), 1, 22);
int count = 0;
for(int i = 0; i < array.size; i++){
UnlockableContent unlock = array.get(i);
for(var unlock : array){
Image image = unlocked(unlock) ? new Image(new TextureRegionDrawable(unlock.uiIcon), mobile ? Color.white : Color.lightGray).setScaling(Scaling.fit) : new Image(Icon.lock, Pal.gray);
//banned cross
if(state.isGame() && (unlock instanceof UnitType u && u.isBanned() || unlock instanceof Block b && state.rules.isBanned(b))){
if(state.isGame() && unlock.isBanned()){
list.stack(image, new Image(Icon.cancel){{
setColor(Color.scarlet);
touchable = Touchable.disabled;

View File

@@ -923,11 +923,16 @@ public class Block extends UnlockableContent implements Senseable{
}
public boolean isVisible(){
return !isHidden() && (state.rules.editor || (!state.rules.hideBannedBlocks || !state.rules.isBanned(this)));
return !isHidden() && (state.rules.editor || (!state.rules.hideBannedBlocks || !isBanned()));
}
public boolean isPlaceable(){
return isVisible() && (!state.rules.isBanned(this) || state.rules.editor) && supportsEnv(state.rules.env);
return isVisible() && (!isBanned() || state.rules.editor) && supportsEnv(state.rules.env);
}
@Override
public boolean isBanned(){
return state.rules.isBanned(this);
}
/** @return whether this block supports a specific environment. */