Closes #10884
This commit is contained in:
@@ -95,6 +95,10 @@ public abstract class UnlockableContent extends MappableContent{
|
|||||||
uiIcon = Core.atlas.find(getContentType().name() + "-" + name + "-ui", fullIcon);
|
uiIcon = Core.atlas.find(getContentType().name() + "-" + name + "-ui", fullIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isBanned(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isOnPlanet(@Nullable Planet planet){
|
public boolean isOnPlanet(@Nullable Planet planet){
|
||||||
return planet == null || planet == Planets.sun || shownPlanets.isEmpty() || shownPlanets.contains(planet);
|
return planet == null || planet == Planets.sun || shownPlanets.isEmpty() || shownPlanets.contains(planet);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -700,6 +700,7 @@ public class UnitType extends UnlockableContent implements Senseable{
|
|||||||
return (envEnabled & env) != 0 && (envDisabled & env) == 0 && (envRequired == 0 || (envRequired & env) == envRequired);
|
return (envEnabled & env) != 0 && (envDisabled & env) == 0 && (envRequired == 0 || (envRequired & env) == envRequired);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isBanned(){
|
public boolean isBanned(){
|
||||||
return state.rules.isBanned(this);
|
return state.rules.isBanned(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import mindustry.gen.*;
|
|||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.*;
|
|
||||||
|
|
||||||
import static arc.Core.*;
|
import static arc.Core.*;
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
@@ -95,7 +94,7 @@ public class DatabaseDialog extends BaseDialog{
|
|||||||
|
|
||||||
if(++i % 10 == 0) t.row();
|
if(++i % 10 == 0) t.row();
|
||||||
}
|
}
|
||||||
}).row();;
|
}).row();
|
||||||
|
|
||||||
for(int j = 0; j < allContent.length; j++){
|
for(int j = 0; j < allContent.length; j++){
|
||||||
ContentType type = ContentType.all[j];
|
ContentType type = ContentType.all[j];
|
||||||
@@ -106,6 +105,11 @@ public class DatabaseDialog extends BaseDialog{
|
|||||||
|
|
||||||
if(array.size == 0) continue;
|
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.add("@content." + type.name() + ".name").growX().left().color(Pal.accent);
|
||||||
all.row();
|
all.row();
|
||||||
all.image().growX().pad(5).padLeft(0).padRight(0).height(3).color(Pal.accent);
|
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 cols = (int)Mathf.clamp((Core.graphics.getWidth() - Scl.scl(30)) / Scl.scl(32 + 12), 1, 22);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for(int i = 0; i < array.size; i++){
|
for(var unlock : array){
|
||||||
UnlockableContent unlock = array.get(i);
|
|
||||||
|
|
||||||
Image image = unlocked(unlock) ? new Image(new TextureRegionDrawable(unlock.uiIcon), mobile ? Color.white : Color.lightGray).setScaling(Scaling.fit) : new Image(Icon.lock, Pal.gray);
|
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
|
//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){{
|
list.stack(image, new Image(Icon.cancel){{
|
||||||
setColor(Color.scarlet);
|
setColor(Color.scarlet);
|
||||||
touchable = Touchable.disabled;
|
touchable = Touchable.disabled;
|
||||||
|
|||||||
@@ -923,11 +923,16 @@ public class Block extends UnlockableContent implements Senseable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVisible(){
|
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(){
|
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. */
|
/** @return whether this block supports a specific environment. */
|
||||||
|
|||||||
Reference in New Issue
Block a user