Recipe fixes, replaced spaces with tabs

This commit is contained in:
paulevsGitch 2021-12-15 13:08:15 +03:00
parent 5ca6a92dd0
commit d8de624fd1
60 changed files with 1816 additions and 1851 deletions

View file

@ -9,64 +9,64 @@ import java.util.List;
@Environment(EnvType.CLIENT)
public class GridColumn extends GridContainer {
GridColumn(double width) {
super(width);
}
GridColumn(double width) {
super(width);
}
GridColumn(double width, GridLayout.GridValueType widthType) {
super(width, widthType);
}
GridColumn(double width, GridLayout.GridValueType widthType) {
super(width, widthType);
}
public GridRow addRow() {
return addRow(VerticalAlignment.TOP);
}
public GridRow addRow() {
return addRow(VerticalAlignment.TOP);
}
public GridRow addRow(VerticalAlignment align) {
GridRow row = new GridRow(1.0, widthType==GridValueType.INHERIT?GridValueType.INHERIT:GridLayout.GridValueType.PERCENTAGE, align);
this.cells.add(row);
return row;
}
public GridRow addRow(VerticalAlignment align) {
GridRow row = new GridRow(1.0, widthType==GridValueType.INHERIT?GridValueType.INHERIT:GridLayout.GridValueType.PERCENTAGE, align);
this.cells.add(row);
return row;
}
public void addSpacerRow() {
this.addSpacerRow(4);
}
public void addSpacerRow() {
this.addSpacerRow(4);
}
public void addSpacerRow(int height) {
GridCell cell = new GridCell(1.0, height, GridValueType.PERCENTAGE, null, null);
this.cells.add(cell);
}
public void addSpacerRow(int height) {
GridCell cell = new GridCell(1.0, height, GridValueType.PERCENTAGE, null, null);
this.cells.add(cell);
}
@Override
public int calculateWidth(final int parentWidth){
if (widthType == GridValueType.INHERIT) {
return cells.stream()
.filter(row->row.widthType == GridValueType.INHERIT)
.map(row -> row.buildElement(0, 0, 1, 0, 0, null).width)
.reduce(0, (p, c) -> Math.max(p, c));
@Override
public int calculateWidth(final int parentWidth){
if (widthType == GridValueType.INHERIT) {
return cells.stream()
.filter(row->row.widthType == GridValueType.INHERIT)
.map(row -> row.buildElement(0, 0, 1, 0, 0, null).width)
.reduce(0, (p, c) -> Math.max(p, c));
} else {
return super.calculateWidth(parentWidth);
}
}
} else {
return super.calculateWidth(parentWidth);
}
}
@Override
protected GridElement buildElementAt(int left, int inTop, int width, final List<GridElement> collector) {
int height = 0;
int top = inTop;
@Override
protected GridElement buildElementAt(int left, int inTop, int width, final List<GridElement> collector) {
int height = 0;
int top = inTop;
if (widthType == GridValueType.INHERIT) {
if (widthType == GridValueType.INHERIT) {
width = calculateWidth(width);
}
for (GridCellDefinition row : cells) {
GridElement element = row.buildElement(width, 0, 1, left, top, collector);
top += element.height;
height += element.height;
}
for (GridCellDefinition row : cells) {
GridElement element = row.buildElement(width, 0, 1, left, top, collector);
top += element.height;
height += element.height;
}
return new GridElement(left, inTop, width, height);
}
return new GridElement(left, inTop, width, height);
}
}

View file

@ -3,8 +3,8 @@ package ru.bclib.gui.screens;
import net.minecraft.network.chat.Component;
public interface AtomicProgressListener {
public void incAtomic(int maxProgress);
public void resetAtomic();
public void stop();
public void progressStage(Component component);
public void incAtomic(int maxProgress);
public void resetAtomic();
public void stop();
public void progressStage(Component component);
}

View file

@ -11,41 +11,41 @@ import ru.bclib.gui.gridlayout.GridRow;
@Environment(EnvType.CLIENT)
public class ConfirmRestartScreen extends BCLibScreen {
private final Component description;
private final ConfirmRestartScreen.Listener listener;
private final Component description;
private final ConfirmRestartScreen.Listener listener;
public ConfirmRestartScreen(ConfirmRestartScreen.Listener listener) {
this(listener, null);
}
public ConfirmRestartScreen(ConfirmRestartScreen.Listener listener) {
this(listener, null);
}
public ConfirmRestartScreen(ConfirmRestartScreen.Listener listener, Component message) {
super(new TranslatableComponent("title.bclib.confirmrestart"));
public ConfirmRestartScreen(ConfirmRestartScreen.Listener listener, Component message) {
super(new TranslatableComponent("title.bclib.confirmrestart"));
this.description = message==null?new TranslatableComponent("message.bclib.confirmrestart"):message;
this.listener = listener;
}
this.description = message==null?new TranslatableComponent("message.bclib.confirmrestart"):message;
this.listener = listener;
}
protected void initLayout() {
final int BUTTON_HEIGHT = 20;
grid.addRow().addMessage(this.description, this.font, Alignment.CENTER);
grid.addSpacerRow();
GridRow row = grid.addRow();
row.addFiller();
row.addButton(CommonComponents.GUI_PROCEED, BUTTON_HEIGHT, font, (button) -> {
listener.proceed();
});
row.addFiller();
}
protected void initLayout() {
final int BUTTON_HEIGHT = 20;
grid.addRow().addMessage(this.description, this.font, Alignment.CENTER);
grid.addSpacerRow();
GridRow row = grid.addRow();
row.addFiller();
row.addButton(CommonComponents.GUI_PROCEED, BUTTON_HEIGHT, font, (button) -> {
listener.proceed();
});
row.addFiller();
}
public boolean shouldCloseOnEsc() {
return false;
}
public boolean shouldCloseOnEsc() {
return false;
}
@Environment(EnvType.CLIENT)
public interface Listener {
void proceed();
}
@Environment(EnvType.CLIENT)
public interface Listener {
void proceed();
}
}

View file

@ -12,49 +12,49 @@ import ru.bclib.gui.gridlayout.GridRow;
@Environment(EnvType.CLIENT)
public class LevelFixErrorScreen extends BCLibScreen {
private final String[] errors;
final Listener onContinue;
public LevelFixErrorScreen(Screen parent, String[] errors, Listener onContinue) {
super(parent, new TranslatableComponent("title.bclib.datafixer.error"), 10, true);
this.errors = errors;
this.onContinue = onContinue;
}
@Override
protected void initLayout() {
grid.addSpacerRow();
grid.addRow().addMessage(new TranslatableComponent("message.bclib.datafixer.error"), font, GridLayout.Alignment.CENTER);
grid.addSpacerRow(8);
GridRow row = grid.addRow();
row.addSpacer(10);
GridColumn col = row.addColumn(300, GridLayout.GridValueType.CONSTANT);
for (String error : errors){
TextComponent dash = new TextComponent("-");
row = col.addRow();
row.addString(dash, this);
row.addSpacer(4);
row.addString(new TextComponent(error), this);
}
grid.addSpacerRow(8);
row = grid.addRow();
row.addFiller();
row.addButton(new TranslatableComponent("title.bclib.datafixer.error.continue"), 0.5f, 20, font, (n)-> {
onClose();
onContinue.doContinue(true);
});
row.addSpacer();
row.addButton(CommonComponents.GUI_CANCEL, 20, font, (n)-> {
this.minecraft.setScreen(null);
});
row.addFiller();
}
@Environment(EnvType.CLIENT)
public interface Listener {
void doContinue(boolean markFixed);
}
private final String[] errors;
final Listener onContinue;
public LevelFixErrorScreen(Screen parent, String[] errors, Listener onContinue) {
super(parent, new TranslatableComponent("title.bclib.datafixer.error"), 10, true);
this.errors = errors;
this.onContinue = onContinue;
}
@Override
protected void initLayout() {
grid.addSpacerRow();
grid.addRow().addMessage(new TranslatableComponent("message.bclib.datafixer.error"), font, GridLayout.Alignment.CENTER);
grid.addSpacerRow(8);
GridRow row = grid.addRow();
row.addSpacer(10);
GridColumn col = row.addColumn(300, GridLayout.GridValueType.CONSTANT);
for (String error : errors){
TextComponent dash = new TextComponent("-");
row = col.addRow();
row.addString(dash, this);
row.addSpacer(4);
row.addString(new TextComponent(error), this);
}
grid.addSpacerRow(8);
row = grid.addRow();
row.addFiller();
row.addButton(new TranslatableComponent("title.bclib.datafixer.error.continue"), 0.5f, 20, font, (n)-> {
onClose();
onContinue.doContinue(true);
});
row.addSpacer();
row.addButton(CommonComponents.GUI_CANCEL, 20, font, (n)-> {
this.minecraft.setScreen(null);
});
row.addFiller();
}
@Environment(EnvType.CLIENT)
public interface Listener {
void doContinue(boolean markFixed);
}
}

View file

@ -26,193 +26,193 @@ import java.util.stream.Collectors;
@Environment(EnvType.CLIENT)
public class ModListScreen extends BCLibScreen {
private final List<ModUtil.ModInfo> mods;
private final HelloClient.IServerModMap serverInfo;
private final Component description;
private final Component buttonTitle;
private final List<ModUtil.ModInfo> mods;
private final HelloClient.IServerModMap serverInfo;
private final Component description;
private final Component buttonTitle;
private static List<ModUtil.ModInfo> extractModList(Map<String, ModUtil.ModInfo> mods){
List<ModUtil.ModInfo> list = new LinkedList<ModUtil.ModInfo>();
ModUtil.getMods().forEach((id, info) -> list.add(info));
return list;
}
public ModListScreen(Screen parent, Component title, Component description, Map<String, ModUtil.ModInfo> mods, HelloClient.IServerModMap serverInfo) {
this(parent, title, description, CommonComponents.GUI_BACK, mods, serverInfo);
}
public ModListScreen(Screen parent, Component title, Component description, List<ModUtil.ModInfo> mods, HelloClient.IServerModMap serverInfo) {
this(parent, title, description, CommonComponents.GUI_BACK, mods, serverInfo);
}
public ModListScreen(Screen parent, Component title, Component description, Component button, Map<String, ModUtil.ModInfo> mods, HelloClient.IServerModMap serverInfo) {
this(parent, title, description, button, extractModList(mods), serverInfo);
}
private static List<ModUtil.ModInfo> extractModList(Map<String, ModUtil.ModInfo> mods){
List<ModUtil.ModInfo> list = new LinkedList<ModUtil.ModInfo>();
ModUtil.getMods().forEach((id, info) -> list.add(info));
return list;
}
public ModListScreen(Screen parent, Component title, Component description, Map<String, ModUtil.ModInfo> mods, HelloClient.IServerModMap serverInfo) {
this(parent, title, description, CommonComponents.GUI_BACK, mods, serverInfo);
}
public ModListScreen(Screen parent, Component title, Component description, List<ModUtil.ModInfo> mods, HelloClient.IServerModMap serverInfo) {
this(parent, title, description, CommonComponents.GUI_BACK, mods, serverInfo);
}
public ModListScreen(Screen parent, Component title, Component description, Component button, Map<String, ModUtil.ModInfo> mods, HelloClient.IServerModMap serverInfo) {
this(parent, title, description, button, extractModList(mods), serverInfo);
}
public ModListScreen(Screen parent, Component title, Component description, Component button, List<ModUtil.ModInfo> mods, HelloClient.IServerModMap serverInfo) {
super(parent, title, 10, true);
this.mods = mods;
this.serverInfo = serverInfo;
this.description = description;
this.buttonTitle = button;
}
public ModListScreen(Screen parent, Component title, Component description, Component button, List<ModUtil.ModInfo> mods, HelloClient.IServerModMap serverInfo) {
super(parent, title, 10, true);
this.mods = mods;
this.serverInfo = serverInfo;
this.description = description;
this.buttonTitle = button;
}
public static List<String> localMissing(HelloClient.IServerModMap serverInfo){
return serverInfo.keySet()
.stream()
.filter(modid -> !ModUtil.getMods().keySet().stream().filter(mod -> mod.equals(modid)).findFirst().isPresent()).collect(Collectors.toList());
}
public static List<String> localMissing(HelloClient.IServerModMap serverInfo){
return serverInfo.keySet()
.stream()
.filter(modid -> !ModUtil.getMods().keySet().stream().filter(mod -> mod.equals(modid)).findFirst().isPresent()).collect(Collectors.toList());
}
public static List<String> serverMissing(HelloClient.IServerModMap serverInfo){
return ModUtil.getMods().entrySet()
.stream()
.filter(entry -> entry.getValue().metadata.getEnvironment() != ModEnvironment.CLIENT)
.map(entry -> entry.getKey())
.filter(modid -> !serverInfo.keySet().stream().filter(mod -> mod.equals(modid)).findFirst().isPresent()).collect(Collectors.toList());
}
public static List<String> serverMissing(HelloClient.IServerModMap serverInfo){
return ModUtil.getMods().entrySet()
.stream()
.filter(entry -> entry.getValue().metadata.getEnvironment() != ModEnvironment.CLIENT)
.map(entry -> entry.getKey())
.filter(modid -> !serverInfo.keySet().stream().filter(mod -> mod.equals(modid)).findFirst().isPresent()).collect(Collectors.toList());
}
public static void addModDesc(GridColumn grid, java.util.List<ModUtil.ModInfo> mods, HelloClient.IServerModMap serverInfo, GridScreen parent) {
final int STATE_OK = 6;
final int STATE_SERVER_MISSING_CLIENT_MOD = 5;
final int STATE_MISSING_NOT_OFFERED = 4;
final int STATE_VERSION_NOT_OFFERED = 3;
final int STATE_VERSION = 2;
final int STATE_SERVER_MISSING = 1;
final int STATE_MISSING = 0;
public static void addModDesc(GridColumn grid, java.util.List<ModUtil.ModInfo> mods, HelloClient.IServerModMap serverInfo, GridScreen parent) {
final int STATE_OK = 6;
final int STATE_SERVER_MISSING_CLIENT_MOD = 5;
final int STATE_MISSING_NOT_OFFERED = 4;
final int STATE_VERSION_NOT_OFFERED = 3;
final int STATE_VERSION = 2;
final int STATE_SERVER_MISSING = 1;
final int STATE_MISSING = 0;
List<Triple<String, Integer, String>> items = new LinkedList<>();
if (serverInfo!=null) {
serverInfo.keySet()
.stream()
.filter(modid -> !mods.stream().filter(mod -> mod.metadata.getId().equals(modid)).findFirst().isPresent())
.forEach(modid -> {
HelloClient.OfferedModInfo nfo = serverInfo.get(modid);
String stateString = nfo.version();
if (nfo.size()>0) {
stateString = "Version: " + stateString + ", Size: " + PathUtil.humanReadableFileSize(nfo.size());
}
if (nfo.canDownload()) {
stateString += ", offered by server";
}
List<Triple<String, Integer, String>> items = new LinkedList<>();
if (serverInfo!=null) {
serverInfo.keySet()
.stream()
.filter(modid -> !mods.stream().filter(mod -> mod.metadata.getId().equals(modid)).findFirst().isPresent())
.forEach(modid -> {
HelloClient.OfferedModInfo nfo = serverInfo.get(modid);
String stateString = nfo.version();
if (nfo.size()>0) {
stateString = "Version: " + stateString + ", Size: " + PathUtil.humanReadableFileSize(nfo.size());
}
if (nfo.canDownload()) {
stateString += ", offered by server";
}
items.add(new Triple<>(modid, nfo.canDownload()?STATE_MISSING:STATE_MISSING_NOT_OFFERED, stateString));
});
}
items.add(new Triple<>(modid, nfo.canDownload()?STATE_MISSING:STATE_MISSING_NOT_OFFERED, stateString));
});
}
mods.forEach(mod -> {
String serverVersion = null;
int serverSize = 0;
int state = STATE_OK;
if (serverInfo != null) {
final String modID = mod.metadata.getId();
mods.forEach(mod -> {
String serverVersion = null;
int serverSize = 0;
int state = STATE_OK;
if (serverInfo != null) {
final String modID = mod.metadata.getId();
HelloClient.OfferedModInfo data = serverInfo.get(modID);
if (data!=null) {
final String modVer = data.version();
final int size = data.size();
if (!modVer.equals(mod.getVersion())) {
state = data.canDownload()?STATE_VERSION:STATE_VERSION_NOT_OFFERED;
serverVersion = modVer;
serverSize = size;
}
} else if (mod.metadata.getEnvironment() == ModEnvironment.CLIENT){
state = STATE_SERVER_MISSING_CLIENT_MOD;
} else {
state = STATE_SERVER_MISSING;
}
}
HelloClient.OfferedModInfo data = serverInfo.get(modID);
if (data!=null) {
final String modVer = data.version();
final int size = data.size();
if (!modVer.equals(mod.getVersion())) {
state = data.canDownload()?STATE_VERSION:STATE_VERSION_NOT_OFFERED;
serverVersion = modVer;
serverSize = size;
}
} else if (mod.metadata.getEnvironment() == ModEnvironment.CLIENT){
state = STATE_SERVER_MISSING_CLIENT_MOD;
} else {
state = STATE_SERVER_MISSING;
}
}
String stateString = mod.metadata.getVersion().toString();
if (serverVersion!=null) {
stateString = "Client: " + stateString;
stateString += ", Server: " + serverVersion;
if (serverSize>0) {
stateString += ", Size: " + PathUtil.humanReadableFileSize(serverSize);
}
}
if (mod.metadata.getEnvironment() == ModEnvironment.CLIENT) {
stateString+= ", client-only";
} else if (mod.metadata.getEnvironment() == ModEnvironment.SERVER) {
stateString+= ", server-only";
}
items.add(new Triple<>(mod.metadata.getName(), state, stateString));
});
String stateString = mod.metadata.getVersion().toString();
if (serverVersion!=null) {
stateString = "Client: " + stateString;
stateString += ", Server: " + serverVersion;
if (serverSize>0) {
stateString += ", Size: " + PathUtil.humanReadableFileSize(serverSize);
}
}
if (mod.metadata.getEnvironment() == ModEnvironment.CLIENT) {
stateString+= ", client-only";
} else if (mod.metadata.getEnvironment() == ModEnvironment.SERVER) {
stateString+= ", server-only";
}
items.add(new Triple<>(mod.metadata.getName(), state, stateString));
});
items.stream()
.sorted(Comparator.comparing(a -> a.second + a.first.toLowerCase(Locale.ROOT)))
.forEach(t -> {
final String name = t.first;
final int state = t.second;
final String stateString = t.third;
items.stream()
.sorted(Comparator.comparing(a -> a.second + a.first.toLowerCase(Locale.ROOT)))
.forEach(t -> {
final String name = t.first;
final int state = t.second;
final String stateString = t.third;
int color = GridLayout.COLOR_RED;
final String typeText;
if (state==STATE_VERSION || state==STATE_VERSION_NOT_OFFERED) {
typeText = "[VERSION]";
if (state == STATE_VERSION_NOT_OFFERED) {
color = GridLayout.COLOR_YELLOW;
}
} else if (state==STATE_MISSING || state==STATE_MISSING_NOT_OFFERED) {
typeText = "[MISSING]";
if (state == STATE_MISSING_NOT_OFFERED) {
color = GridLayout.COLOR_YELLOW;
}
} else if (state==STATE_SERVER_MISSING || state == STATE_SERVER_MISSING_CLIENT_MOD) {
if (state == STATE_SERVER_MISSING_CLIENT_MOD) {
color = GridLayout.COLOR_CYAN;
typeText = "[OK]";
} else {
typeText = "[NOT ON SERVER]";
}
} else {
color = GridLayout.COLOR_DARK_GREEN;
typeText = "[OK]";
}
TextComponent dash = new TextComponent("-");
TextComponent typeTextComponent = new TextComponent(typeText);
GridRow row = grid.addRow();
int color = GridLayout.COLOR_RED;
final String typeText;
if (state==STATE_VERSION || state==STATE_VERSION_NOT_OFFERED) {
typeText = "[VERSION]";
if (state == STATE_VERSION_NOT_OFFERED) {
color = GridLayout.COLOR_YELLOW;
}
} else if (state==STATE_MISSING || state==STATE_MISSING_NOT_OFFERED) {
typeText = "[MISSING]";
if (state == STATE_MISSING_NOT_OFFERED) {
color = GridLayout.COLOR_YELLOW;
}
} else if (state==STATE_SERVER_MISSING || state == STATE_SERVER_MISSING_CLIENT_MOD) {
if (state == STATE_SERVER_MISSING_CLIENT_MOD) {
color = GridLayout.COLOR_CYAN;
typeText = "[OK]";
} else {
typeText = "[NOT ON SERVER]";
}
} else {
color = GridLayout.COLOR_DARK_GREEN;
typeText = "[OK]";
}
TextComponent dash = new TextComponent("-");
TextComponent typeTextComponent = new TextComponent(typeText);
GridRow row = grid.addRow();
row.addString(dash, parent);
row.addString(dash, parent);
row.addSpacer(4);
row.addString(new TextComponent(name), parent);
row.addSpacer(4);
row.addString(new TextComponent(name), parent);
row.addSpacer(4);
row.addString(typeTextComponent, color, parent);
row.addSpacer(4);
row.addString(typeTextComponent, color, parent);
if (!stateString.isEmpty()) {
row = grid.addRow();
row.addSpacer(4 + parent.getWidth(dash));
row.addString(new TextComponent(stateString), GridLayout.COLOR_GRAY, parent);
}
if (!stateString.isEmpty()) {
row = grid.addRow();
row.addSpacer(4 + parent.getWidth(dash));
row.addString(new TextComponent(stateString), GridLayout.COLOR_GRAY, parent);
}
grid.addSpacerRow();
});
}
grid.addSpacerRow();
});
}
@Override
protected void initLayout() {
if (description != null) {
grid.addSpacerRow();
grid.addRow().addMessage(description, font, GridLayout.Alignment.CENTER);
grid.addSpacerRow(8);
}
@Override
protected void initLayout() {
if (description != null) {
grid.addSpacerRow();
grid.addRow().addMessage(description, font, GridLayout.Alignment.CENTER);
grid.addSpacerRow(8);
}
GridRow row = grid.addRow();
row.addSpacer(10);
GridColumn col = row.addColumn(200, GridLayout.GridValueType.CONSTANT);
addModDesc(col, mods, serverInfo, this);
GridRow row = grid.addRow();
row.addSpacer(10);
GridColumn col = row.addColumn(200, GridLayout.GridValueType.CONSTANT);
addModDesc(col, mods, serverInfo, this);
grid.addSpacerRow(8);
row = grid.addRow();
row.addFiller();
row.addButton(buttonTitle, 20, font, (n)-> {
onClose();
});
row.addFiller();
}
grid.addSpacerRow(8);
row = grid.addRow();
row.addFiller();
row.addButton(buttonTitle, 20, font, (n)-> {
onClose();
});
row.addFiller();
}
}