World processor list in editor
This commit is contained in:
@@ -30,6 +30,7 @@ public class Fonts{
|
||||
private static final String mainFont = "fonts/font.woff";
|
||||
private static final ObjectSet<String> unscaled = ObjectSet.with("iconLarge");
|
||||
private static ObjectIntMap<String> unicodeIcons = new ObjectIntMap<>();
|
||||
private static IntMap<String> unicodeToName = new IntMap<>();
|
||||
private static ObjectMap<String, String> stringIcons = new ObjectMap<>();
|
||||
private static ObjectMap<String, TextureRegion> largeIcons = new ObjectMap<>();
|
||||
private static TextureRegion[] iconTable;
|
||||
@@ -95,12 +96,16 @@ public class Fonts{
|
||||
}})).loaded = f -> Fonts.logic = f;
|
||||
}
|
||||
|
||||
public static @Nullable String unicodeToName(int unicode){
|
||||
return unicodeToName.get(unicode, () -> Iconc.codeToName.get(unicode));
|
||||
}
|
||||
|
||||
public static TextureRegion getLargeIcon(String name){
|
||||
return largeIcons.get(name, () -> {
|
||||
var region = new TextureRegion();
|
||||
int code = Iconc.codes.get(name, '\uF8D4');
|
||||
var glyph = iconLarge.getData().getGlyph((char)code);
|
||||
if(glyph == null) return Core.atlas.find("error");
|
||||
if(glyph == null) return Core.atlas.find(name);
|
||||
region.set(iconLarge.getRegion().texture);
|
||||
region.set(glyph.u, glyph.v2, glyph.u2, glyph.v);
|
||||
return region;
|
||||
@@ -127,6 +132,7 @@ public class Fonts{
|
||||
|
||||
unicodeIcons.put(nametex[0], ch);
|
||||
stringIcons.put(nametex[0], ((char)ch) + "");
|
||||
unicodeToName.put(ch, texture);
|
||||
|
||||
Vec2 out = Scaling.fit.apply(region.width, region.height, size, size);
|
||||
|
||||
|
||||
@@ -73,6 +73,8 @@ public class Styles{
|
||||
geni,
|
||||
/** Gray, toggleable, no background. */
|
||||
grayi,
|
||||
/** Gray square background, standard behavior. Equivalent to grayt. */
|
||||
graySquarei,
|
||||
/** Flat, square, black background. */
|
||||
flati,
|
||||
/** Square border. */
|
||||
@@ -288,6 +290,14 @@ public class Styles{
|
||||
imageUpColor = Color.lightGray;
|
||||
imageDownColor = Color.white;
|
||||
}};
|
||||
graySquarei = new ImageButtonStyle(){{
|
||||
imageUpColor = Color.white;
|
||||
imageDownColor = Color.lightGray;
|
||||
|
||||
over = flatOver;
|
||||
down = flatOver;
|
||||
up = grayPanel;
|
||||
}};
|
||||
flati = new ImageButtonStyle(){{
|
||||
down = flatOver;
|
||||
up = black;
|
||||
|
||||
@@ -45,7 +45,7 @@ public class DatabaseDialog extends BaseDialog{
|
||||
|
||||
void rebuild(){
|
||||
all.clear();
|
||||
var text = search.getText();
|
||||
var text = search.getText().toLowerCase();
|
||||
|
||||
Seq<Content>[] allContent = Vars.content.getContentMap();
|
||||
|
||||
@@ -54,7 +54,7 @@ public class DatabaseDialog extends BaseDialog{
|
||||
|
||||
Seq<UnlockableContent> array = allContent[j]
|
||||
.select(c -> c instanceof UnlockableContent u && !u.isHidden() &&
|
||||
(text.isEmpty() || u.localizedName.toLowerCase().contains(text.toLowerCase()))).as();
|
||||
(text.isEmpty() || u.localizedName.toLowerCase().contains(text))).as();
|
||||
if(array.size == 0) continue;
|
||||
|
||||
all.add("@content." + type.name() + ".name").growX().left().color(Pal.accent);
|
||||
|
||||
74
core/src/mindustry/ui/dialogs/IconSelectDialog.java
Normal file
74
core/src/mindustry/ui/dialogs/IconSelectDialog.java
Normal file
@@ -0,0 +1,74 @@
|
||||
package mindustry.ui.dialogs;
|
||||
|
||||
import arc.*;
|
||||
import arc.func.*;
|
||||
import arc.scene.style.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class IconSelectDialog extends Dialog{
|
||||
private Intc consumer = i -> Log.info("you have mere seconds");
|
||||
|
||||
public IconSelectDialog(){
|
||||
closeOnBack();
|
||||
setFillParent(true);
|
||||
|
||||
cont.pane(t -> {
|
||||
resized(true, () -> {
|
||||
t.clearChildren();
|
||||
t.marginRight(19f);
|
||||
t.defaults().size(48f);
|
||||
|
||||
t.button(Icon.none, Styles.flati, () -> {
|
||||
hide();
|
||||
consumer.get(0);
|
||||
});
|
||||
|
||||
int cols = (int)Math.min(20, Core.graphics.getWidth() / Scl.scl(52f));
|
||||
|
||||
int i = 1;
|
||||
for(var key : accessibleIcons){
|
||||
var value = Icon.icons.get(key);
|
||||
|
||||
t.button(value, Styles.flati, () -> {
|
||||
hide();
|
||||
consumer.get(Iconc.codes.get(key));
|
||||
});
|
||||
|
||||
if(++i % cols == 0) t.row();
|
||||
}
|
||||
|
||||
for(ContentType ctype : defaultContentIcons){
|
||||
t.row();
|
||||
t.image().colspan(cols).growX().width(Float.NEGATIVE_INFINITY).height(3f).color(Pal.accent);
|
||||
t.row();
|
||||
|
||||
i = 0;
|
||||
for(UnlockableContent u : content.getBy(ctype).<UnlockableContent>as()){
|
||||
if(!u.isHidden() && u.unlocked()){
|
||||
t.button(new TextureRegionDrawable(u.uiIcon), Styles.flati, iconMed, () -> {
|
||||
hide();
|
||||
consumer.get(u.emojiChar());
|
||||
});
|
||||
|
||||
if(++i % cols == 0) t.row();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
buttons.button("@back", Icon.left, this::hide).size(210f, 64f);
|
||||
}
|
||||
|
||||
public void show(Intc listener){
|
||||
consumer = listener;
|
||||
super.show();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
package mindustry.ui.dialogs;
|
||||
|
||||
import arc.*;
|
||||
import mindustry.editor.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class PausedDialog extends BaseDialog{
|
||||
private MapProcessorsDialog processors = new MapProcessorsDialog();
|
||||
private SaveDialog save = new SaveDialog();
|
||||
private LoadDialog load = new LoadDialog();
|
||||
private boolean wasClient = false;
|
||||
@@ -49,13 +51,22 @@ public class PausedDialog extends BaseDialog{
|
||||
|
||||
cont.row();
|
||||
|
||||
cont.button("@hostserver", Icon.host, () -> {
|
||||
//the button runs out of space when the editor button is added, so use the mobile text
|
||||
cont.button(state.isEditor() ? "@hostserver.mobile" : "@hostserver", Icon.host, () -> {
|
||||
if(net.server() && steam){
|
||||
platform.inviteFriends();
|
||||
}else{
|
||||
ui.host.show();
|
||||
}
|
||||
}).disabled(b -> !((steam && net.server()) || !net.active())).colspan(2).width(dw * 2 + 10f).update(e -> e.setText(net.server() && steam ? "@invitefriends" : "@hostserver"));
|
||||
}).disabled(b -> !((steam && net.server()) || !net.active())).colspan(state.isEditor() ? 1 : 2).width(state.isEditor() ? dw : dw * 2 + 10f)
|
||||
.update(e -> e.setText(net.server() && steam ? "@invitefriends" : state.isEditor() ? "@hostserver.mobile" : "@hostserver"));
|
||||
|
||||
if(state.isEditor()){
|
||||
cont.button("@editor.worldprocessors", Icon.logic, () -> {
|
||||
hide();
|
||||
processors.show();
|
||||
});
|
||||
}
|
||||
|
||||
cont.row();
|
||||
|
||||
|
||||
@@ -43,13 +43,6 @@ import static mindustry.graphics.g3d.PlanetRenderer.*;
|
||||
import static mindustry.ui.dialogs.PlanetDialog.Mode.*;
|
||||
|
||||
public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
static final String[] defaultIcons = {
|
||||
"effect", "power", "logic", "units", "liquid", "production", "defense", "turret", "distribution", "crafting",
|
||||
"settings", "cancel", "zoom", "ok", "star", "home", "pencil", "up", "down", "left", "right",
|
||||
"hammer", "warning", "tree", "admin", "map", "modePvp", "terrain",
|
||||
"modeSurvival", "commandRally", "commandAttack",
|
||||
};
|
||||
|
||||
//if true, enables launching anywhere for testing
|
||||
public static boolean debugSelect = false;
|
||||
public static float sectorShowDuration = 60f * 2.4f;
|
||||
@@ -1054,6 +1047,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
Icon.icons.get(sector.info.icon + "Small");
|
||||
|
||||
title.button(icon == null ? Icon.noneSmall : icon, Styles.clearNonei, iconSmall, () -> {
|
||||
//TODO use IconSelectDialog
|
||||
new Dialog(""){{
|
||||
closeOnBack();
|
||||
setFillParent(true);
|
||||
@@ -1080,7 +1074,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
int cols = (int)Math.min(20, Core.graphics.getWidth() / Scl.scl(52f));
|
||||
|
||||
int i = 1;
|
||||
for(var key : defaultIcons){
|
||||
for(var key : accessibleIcons){
|
||||
var value = Icon.icons.get(key);
|
||||
|
||||
t.button(value, Styles.squareTogglei, () -> {
|
||||
|
||||
@@ -398,6 +398,7 @@ public class SchematicsDialog extends BaseDialog{
|
||||
closeOnBack();
|
||||
setFillParent(true);
|
||||
|
||||
//TODO: use IconSelectDialog
|
||||
cont.pane(t -> {
|
||||
resized(true, () -> {
|
||||
t.clearChildren();
|
||||
@@ -407,7 +408,7 @@ public class SchematicsDialog extends BaseDialog{
|
||||
int cols = (int)Math.min(20, Core.graphics.getWidth() / Scl.scl(52f));
|
||||
|
||||
int i = 0;
|
||||
for(String icon : PlanetDialog.defaultIcons){
|
||||
for(String icon : accessibleIcons){
|
||||
String out = (char)Iconc.codes.get(icon) + "";
|
||||
if(tags.contains(out)) continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user