Merge remote-tracking branch 'origin/master'

This commit is contained in:
Anuken
2022-02-02 11:54:44 -05:00
18 changed files with 158 additions and 58 deletions

View File

@@ -2040,6 +2040,7 @@ public class UnitTypes implements ContentList{
weaveMag = 4;
weaveScale = 4;
lifetime = 60f;
keepVelocity = false;
shootEffect = Fx.shootHeal;
smokeEffect = Fx.hitLaser;
splashDamage = 13f;

View File

@@ -48,7 +48,7 @@ public class ContentLoader{
clear();
}
/** Clears all initialized content.*/
/** Clears all initialized content. */
public void clear(){
contentNameMap = new ObjectMap[ContentType.all.length];
contentMap = new Seq[ContentType.all.length];
@@ -75,7 +75,7 @@ public class ContentLoader{
}
}
/** Logs content statistics.*/
/** Logs content statistics. */
public void logContent(){
//check up ID mapping, make sure it's linear (debug only)
for(Seq<Content> arr : contentMap){
@@ -95,14 +95,14 @@ public class ContentLoader{
Log.debug("-------------------");
}
/** Calls Content#init() on everything. Use only after all modules have been created.*/
/** Calls Content#init() on everything. Use only after all modules have been created. */
public void init(){
initialize(Content::init);
if(constants != null) constants.init();
Events.fire(new ContentInitEvent());
}
/** Calls Content#load() on everything. Use only after all modules have been created on the client.*/
/** Calls Content#loadIcon() and Content#load() on everything. Use only after all modules have been created on the client. */
public void load(){
initialize(Content::loadIcon);
initialize(Content::load);
@@ -323,4 +323,4 @@ public class ContentLoader{
public Planet planet(String name){
return getByName(ContentType.planet, name);
}
}
}

View File

@@ -31,7 +31,7 @@ public abstract class Content implements Comparable<Content>{
*/
public void load(){}
/** Called right after load(). */
/** Called right before load(). */
public void loadIcon(){}
/** @return whether an error occurred during mod loading. */

View File

@@ -1249,6 +1249,11 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
return self() != other;
}
/**
* Called when this block's config menu is closed
*/
public void onConfigureClosed(){}
/** Returns whether this config menu should show when the specified player taps it. */
public boolean shouldShowConfigure(Player player){
return true;

View File

@@ -1269,19 +1269,24 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
}
int endRotation = -1;
var start = world.build(startX, startY);
var end = world.build(endX, endY);
if(diagonal){
var start = world.build(startX, startY);
var end = world.build(endX, endY);
if(block != null && start instanceof ChainedBuilding && end instanceof ChainedBuilding
&& block.canReplace(end.block) && block.canReplace(start.block)){
points = Placement.upgradeLine(startX, startY, endX, endY);
endRotation = end.rotation;
}else{
points = Placement.pathfindLine(block != null && block.conveyorPlacement, startX, startY, endX, endY);
}
}else{
points = Placement.normalizeLine(startX, startY, endX, endY);
}
if(points.size > 1 && end instanceof ChainedBuilding){
Point2 secondToLast = points.get(points.size - 2);
if (!(world.build(secondToLast.x, secondToLast.y) instanceof ChainedBuilding)){
endRotation = end.rotation;
}
}
if(block != null){
block.changePlacementPath(points, rotation);

View File

@@ -589,6 +589,30 @@ public class SettingsMenuDialog extends BaseDialog{
rebuild();
}
public void textPref(String name, String def){
list.add(new TextSetting(name, def, null));
settings.defaults(name, def);
rebuild();
}
public void textPref(String name, String def, Cons<String> changed){
list.add(new TextSetting(name, def, changed));
settings.defaults(name, def);
rebuild();
}
public void areaTextPref(String name, String def){
list.add(new AreaTextSetting(name, def, null));
settings.defaults(name, def);
rebuild();
}
public void areaTextPref(String name, String def, Cons<String> changed){
list.add(new AreaTextSetting(name, def, changed));
settings.defaults(name, def);
rebuild();
}
public void rebuild(){
clearChildren();
@@ -704,6 +728,67 @@ public class SettingsMenuDialog extends BaseDialog{
table.row();
}
}
public static class TextSetting extends Setting{
String def;
Cons<String> changed;
public TextSetting(String name, String def, Cons<String> changed){
super(name);
this.def = def;
this.changed = changed;
}
@Override
public void add(SettingsTable table){
TextField field = new TextField();
field.update(() -> field.setText(settings.getString(name)));
field.changed(() -> {
settings.put(name, field.getText());
if(changed != null){
changed.get(field.getText());
}
});
Table prefTable = table.table().left().padTop(3f).get();
prefTable.add(field);
prefTable.label(() -> title);
addDesc(prefTable);
table.row();
}
}
public static class AreaTextSetting extends TextSetting{
String def;
Cons<String> changed;
public AreaTextSetting(String name, String def, Cons<String> changed){
super(name, def, changed);
}
@Override
public void add(SettingsTable table){
TextArea area = new TextArea("");
area.setPrefRows(5);
area.update(() -> {
area.setText(settings.getString(name));
area.setWidth(table.getWidth());
});
area.changed(() -> {
settings.put(name, area.getText());
if(changed != null){
changed.get(area.getText());
}
});
addDesc(table.label(() -> title).left().padTop(3f).get());
table.row().add(area).left();
table.row();
}
}
}
}

View File

@@ -49,6 +49,7 @@ public class BlockConfigFragment extends Fragment{
}
public void showConfig(Building tile){
if(configTile != null) configTile.onConfigureClosed();
if(tile.configTapped()){
configTile = tile;
@@ -82,6 +83,7 @@ public class BlockConfigFragment extends Fragment{
}
public void hideConfig(){
if(configTile != null) configTile.onConfigureClosed();
configTile = null;
table.actions(Actions.scaleTo(0f, 1f, 0.06f, Interp.pow3Out), Actions.visible(false));
}

View File

@@ -395,7 +395,7 @@ public class Block extends UnlockableContent{
return hasItems;
}
/** Returns whether or not this block can be place on the specified */
/** @return whether or not this block can be placed on the specified tile. */
public boolean canPlaceOn(Tile tile, Team team, int rotation){
return canPlaceOn(tile, team);
}

View File

@@ -84,8 +84,6 @@ public class PowerNode extends PowerBlock{
});
config(Point2[].class, (tile, value) -> {
tile.power.links.clear();
IntSeq old = new IntSeq(tile.power.links);
//clear old

View File

@@ -24,7 +24,6 @@ public class LiquidConverter extends GenericCrafter{
ConsumeLiquid cl = consumes.get(ConsumeType.liquid);
cl.update(false);
outputLiquid.amount = cl.amount;
super.init();
}