Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor editor/world processor fixes and tweaks #10505

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/mindustry/editor/BannedContentDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void build(){
t.table(s -> {
s.label(() -> "@search").padRight(10);
var field = s.field(contentSearch, value -> {
contentSearch = value;
contentSearch = value.trim().replaceAll(" +", " ").toLowerCase();
rebuildTables();
}).get();
s.button(Icon.cancel, Styles.emptyi, () -> {
Expand Down
2 changes: 1 addition & 1 deletion core/src/mindustry/editor/MapEditorDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ private void rebuildBlockSelection(String searchText){

if(!Core.atlas.isFound(region) || !block.inEditor
|| block.buildVisibility == BuildVisibility.debugOnly
|| (!searchText.isEmpty() && !block.localizedName.toLowerCase().contains(searchText.toLowerCase()))
|| (!searchText.isEmpty() && !block.localizedName.toLowerCase().contains(searchText.trim().replaceAll(" +", " ").toLowerCase()))
) continue;

ImageButton button = new ImageButton(Tex.whiteui, Styles.clearNoneTogglei);
Expand Down
2 changes: 1 addition & 1 deletion core/src/mindustry/logic/LExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1431,7 +1431,7 @@ public void run(LExecutor exec){

Team t = team.team();

if(type.obj() instanceof UnitType type && !type.internal && !type.hidden && t != null && Units.canCreate(t, type)){
if(type.obj() instanceof UnitType type && t != null && Units.canCreate(t, type)){
Copy link
Owner

@Anuken Anuken Feb 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is very important that internal units should not be spawned, as they could cause a crash.

Copy link
Contributor Author

@ApsZoldat ApsZoldat Feb 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know about this, as i stated in PR description, internal units still cannot be spawned because such global variables just don't exist.

But now i think this change still isn't worth it, because it won't go well in case someone decides to add some global vars, so i'll revert it.

upd: it still will be possible to spawn internal units by using setprop @payloadType (if they somehow appear in global vars), so i might change this as well

//random offset to prevent stacking
var unit = type.spawn(t, World.unconv(x.numf()) + Mathf.range(0.01f), World.unconv(y.numf()) + Mathf.range(0.01f));
spawner.spawnEffect(unit, rotation.numf());
Expand Down
25 changes: 16 additions & 9 deletions core/src/mindustry/ui/dialogs/CustomRulesDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import mindustry.ui.*;
import mindustry.world.*;

import static arc.Core.*;
import static arc.util.Time.*;
import static mindustry.Vars.*;

Expand Down Expand Up @@ -117,24 +118,30 @@ public void show(Rules rules, Prov<Rules> resetter){
}

void setup(){
categories.clear();
cont.clear();
cont.table(t -> {
t.add("@search").padRight(10);
var field = t.field(ruleSearch, text -> {
ruleSearch = text.trim().replaceAll(" +", " ").toLowerCase();
setup();
setupMain();
}).grow().pad(8).get();
field.setCursorPosition(ruleSearch.length());
Core.scene.setKeyboardFocus(field);
t.button(Icon.cancel, Styles.emptyi, () -> {
ruleSearch = "";
setup();
setupMain();
}).padLeft(10f).size(35f);
t.button(Icon.zoom, Styles.emptyi, this::setup).size(54f);
}).row();
cont.pane(m -> main = m).scrollX(false);
main.margin(10f);
Cell<ScrollPane> paneCell = cont.pane(m -> main = m);

setupMain();

paneCell.scrollX(main.getPrefWidth() + 40f > graphics.getWidth());
}

void setupMain(){
categories.clear();
main.clear();
main.left().defaults().fillX().left();
main.row();

Expand Down Expand Up @@ -333,7 +340,7 @@ void setup(){

public void category(String name){
current = new Table();
current.left().defaults().fillX().left().pad(5);
current.left().defaults().fillX().expandX().left().pad(5);
currentName = name;
categories.add(current);
categoryNames.add(currentName);
Expand Down Expand Up @@ -403,7 +410,7 @@ public void number(String text, boolean integer, Floatc cons, Floatp prov, Boolp
t.add(text).left().padRight(5)
.update(a -> a.setColor(condition.get() ? Color.white : Color.gray));
t.field((integer ? (int)prov.get() : prov.get()) + "", s -> cons.get(Strings.parseFloat(s)))
.padRight(100f)
.padRight(50f)
.update(a -> a.setDisabled(!condition.get()))
.valid(f -> Strings.canParsePositiveFloat(f) && Strings.parseFloat(f) >= min && Strings.parseFloat(f) <= max).width(120f).left();
}).padTop(0);
Expand All @@ -429,7 +436,7 @@ public void ruleInfo(Cell<?> cell, String text){
Table table = new Table();
table.add(cell.get()).left().expandX().fillX();
cell.clearElement();
table.button(Icon.infoSmall, () -> ui.showInfo(text + ".info")).size(32f).padRight(24f).right();
table.button(Icon.infoSmall, () -> ui.showInfo(text + ".info")).size(32f).right();
cell.setElement(table).left().expandX().fillX();
}else{
cell.tooltip(text + ".info");
Expand Down
2 changes: 1 addition & 1 deletion core/src/mindustry/ui/fragments/HudFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private void rebuildBlockSelection(Table blockSelection, String searchText){
|| (!block.inEditor && !(block instanceof RemoveWall) && !(block instanceof RemoveOre))
|| !block.isOnPlanet(state.rules.planet)
|| block.buildVisibility == BuildVisibility.debugOnly
|| (!searchText.isEmpty() && !block.localizedName.toLowerCase().contains(searchText.toLowerCase()))
|| (!searchText.isEmpty() && !block.localizedName.toLowerCase().contains(searchText.trim().replaceAll(" +", " ").toLowerCase()))
) continue;

ImageButton button = new ImageButton(Tex.whiteui, Styles.clearNoneTogglei);
Expand Down