Update jGui
This commit is contained in:
2
jGui
2
jGui
Submodule jGui updated: 6b16892d64...424959c6d6
@@ -245,18 +245,10 @@ public class Utils {
|
||||
|
||||
logger.trace("Opening crash report popup GUI");
|
||||
GuiCrashReportPopup popup = new GuiCrashReportPopup(container, crashReportStr);
|
||||
Futures.addCallback(popup.getFuture(), new FutureCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(@Nullable Void result) {
|
||||
logger.trace("Crash report popup closed");
|
||||
if (onClose != null) {
|
||||
onClose.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
logger.error("During error popup:", t);
|
||||
popup.onClosed(() -> {
|
||||
logger.trace("Crash report popup closed");
|
||||
if (onClose != null) {
|
||||
onClose.run();
|
||||
}
|
||||
});
|
||||
return popup;
|
||||
@@ -329,18 +321,10 @@ public class Utils {
|
||||
LOGGER.trace("Minimal mode active, denying action, opening popup");
|
||||
|
||||
MinimalModeUnsupportedPopup popup = new MinimalModeUnsupportedPopup(container);
|
||||
Futures.addCallback(popup.getFuture(), new FutureCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(@Nullable Void result) {
|
||||
LOGGER.trace("Minimal mode popup closed");
|
||||
if (onPopupClosed != null) {
|
||||
onPopupClosed.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
LOGGER.error("During minimal mode popup:", t);
|
||||
popup.onClosed(() -> {
|
||||
LOGGER.trace("Minimal mode popup closed");
|
||||
if (onPopupClosed != null) {
|
||||
onPopupClosed.run();
|
||||
}
|
||||
});
|
||||
return false;
|
||||
|
||||
@@ -53,13 +53,13 @@ public class PlayerOverviewGui extends GuiScreen implements Closeable {
|
||||
public final GuiCheckbox checkAll = new GuiCheckbox(contentPanel){
|
||||
@Override
|
||||
public void onClick() {
|
||||
playersScrollable.forEach(IGuiCheckbox.class).setChecked(true);
|
||||
playersScrollable.invokeAll(IGuiCheckbox.class, e -> e.setChecked(true));
|
||||
}
|
||||
}.setLabel("").setChecked(true).setTooltip(new GuiTooltip().setI18nText("replaymod.gui.playeroverview.showall"));
|
||||
public final GuiCheckbox uncheckAll = new GuiCheckbox(contentPanel){
|
||||
@Override
|
||||
public void onClick() {
|
||||
playersScrollable.forEach(IGuiCheckbox.class).setChecked(false);
|
||||
playersScrollable.invokeAll(IGuiCheckbox.class, e -> e.setChecked(false));
|
||||
}
|
||||
}.setLabel("").setChecked(false).setTooltip(new GuiTooltip().setI18nText("replaymod.gui.playeroverview.hideall"));
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ import net.minecraft.util.Util;
|
||||
//$$ import org.lwjgl.Sys;
|
||||
//#endif
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.imageio.ImageReader;
|
||||
import javax.imageio.stream.ImageInputStream;
|
||||
@@ -116,36 +115,27 @@ public class GuiYoutubeUpload extends GuiScreen {
|
||||
public final GuiButton thumbnailButton = new GuiButton().onClick(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Futures.addCallback(
|
||||
GuiFileChooserPopup.openLoadGui(GuiYoutubeUpload.this, "replaymod.gui.load",
|
||||
ImageIO.getReaderFileSuffixes()).getFuture(),
|
||||
new FutureCallback<File>() {
|
||||
@Override
|
||||
public void onSuccess(@Nullable File result) {
|
||||
if (result != null) {
|
||||
thumbnailButton.setLabel(result.getName());
|
||||
Image image;
|
||||
try {
|
||||
thumbnailImage = IOUtils.toByteArray(new FileInputStream(result));
|
||||
ImageInputStream in = ImageIO.createImageInputStream(new ByteArrayInputStream(thumbnailImage));
|
||||
ImageReader reader = ImageIO.getImageReaders(in).next();
|
||||
thumbnailFormat = reader.getFormatName().toLowerCase();
|
||||
image = Image.read(new ByteArrayInputStream(thumbnailImage));
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
thumbnailImage = null;
|
||||
image = null;
|
||||
}
|
||||
thumbnail.setTexture(image);
|
||||
inputValidation.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
throw new RuntimeException(t);
|
||||
}
|
||||
});
|
||||
GuiFileChooserPopup.openLoadGui(
|
||||
GuiYoutubeUpload.this,
|
||||
"replaymod.gui.load",
|
||||
ImageIO.getReaderFileSuffixes()
|
||||
).onAccept(file -> {
|
||||
thumbnailButton.setLabel(file.getName());
|
||||
Image image;
|
||||
try {
|
||||
thumbnailImage = IOUtils.toByteArray(new FileInputStream(file));
|
||||
ImageInputStream in = ImageIO.createImageInputStream(new ByteArrayInputStream(thumbnailImage));
|
||||
ImageReader reader = ImageIO.getImageReaders(in).next();
|
||||
thumbnailFormat = reader.getFormatName().toLowerCase();
|
||||
image = Image.read(new ByteArrayInputStream(thumbnailImage));
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
thumbnailImage = null;
|
||||
image = null;
|
||||
}
|
||||
thumbnail.setTexture(image);
|
||||
inputValidation.run();
|
||||
});
|
||||
}
|
||||
}).setSize(200, 20).setI18nLabel("replaymod.gui.videothumbnail");
|
||||
|
||||
@@ -191,7 +181,7 @@ public class GuiYoutubeUpload extends GuiScreen {
|
||||
}
|
||||
|
||||
private void setState(boolean uploading) {
|
||||
forEach(GuiElement.class).setEnabled(!uploading);
|
||||
invokeAll(GuiElement.class, e -> e.setEnabled(!uploading));
|
||||
uploadButton.setEnabled();
|
||||
if (uploading) {
|
||||
uploadButton.onClick(() -> {
|
||||
|
||||
@@ -65,18 +65,15 @@ public class GuiKeyframeRepository extends GuiScreen implements Closeable, Typea
|
||||
public final GuiButton overwriteButton = new GuiButton().onClick(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GuiYesNoPopup popup = GuiYesNoPopup.open(GuiKeyframeRepository.this,
|
||||
GuiYesNoPopup.open(GuiKeyframeRepository.this,
|
||||
new GuiLabel().setI18nText("replaymod.gui.keyframerepo.overwrite").setColor(Colors.BLACK)
|
||||
).setYesI18nLabel("gui.yes").setNoI18nLabel("gui.no");
|
||||
Utils.addCallback(popup.getFuture(), doIt -> {
|
||||
if (doIt) {
|
||||
for (Entry entry : selectedEntries) {
|
||||
timelines.put(entry.name, currentTimeline);
|
||||
}
|
||||
overwriteButton.setDisabled();
|
||||
save();
|
||||
).setYesI18nLabel("gui.yes").setNoI18nLabel("gui.no").onAccept(() -> {
|
||||
for (Entry entry : selectedEntries) {
|
||||
timelines.put(entry.name, currentTimeline);
|
||||
}
|
||||
}, Throwable::printStackTrace);
|
||||
overwriteButton.setDisabled();
|
||||
save();
|
||||
});
|
||||
}
|
||||
}).setSize(75, 20).setI18nLabel("replaymod.gui.overwrite").setDisabled();
|
||||
public final GuiButton saveAsButton = new GuiButton().onClick(new Runnable() {
|
||||
@@ -103,21 +100,11 @@ public class GuiKeyframeRepository extends GuiScreen implements Closeable, Typea
|
||||
&& !timelines.containsKey(nameField.getText()));
|
||||
}
|
||||
});
|
||||
Futures.addCallback(popup.getFuture(), new FutureCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean save) {
|
||||
if (save) {
|
||||
String name = nameField.getText();
|
||||
timelines.put(name, currentTimeline);
|
||||
list.getListPanel().addElements(null, new Entry(name));
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
popup.onAccept(() -> {
|
||||
String name = nameField.getText();
|
||||
timelines.put(name, currentTimeline);
|
||||
list.getListPanel().addElements(null, new Entry(name));
|
||||
save();
|
||||
});
|
||||
}
|
||||
}).setSize(75, 20).setI18nLabel("replaymod.gui.saveas");
|
||||
@@ -161,50 +148,29 @@ public class GuiKeyframeRepository extends GuiScreen implements Closeable, Typea
|
||||
&& !timelines.containsKey(nameField.getText()));
|
||||
}
|
||||
});
|
||||
Futures.addCallback(popup.getFuture(), new FutureCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean save) {
|
||||
if (save) {
|
||||
String name = nameField.getText();
|
||||
timelines.put(name, timelines.remove(selectedEntry.name));
|
||||
selectedEntry.name = name;
|
||||
selectedEntry.label.setText(name);
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
popup.onAccept(() -> {
|
||||
String name = nameField.getText();
|
||||
timelines.put(name, timelines.remove(selectedEntry.name));
|
||||
selectedEntry.name = name;
|
||||
selectedEntry.label.setText(name);
|
||||
save();
|
||||
});
|
||||
}
|
||||
}).setSize(75, 20).setI18nLabel("replaymod.gui.rename").setDisabled();
|
||||
public final GuiButton removeButton = new GuiButton().onClick(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GuiYesNoPopup popup = GuiYesNoPopup.open(GuiKeyframeRepository.this,
|
||||
GuiYesNoPopup.open(GuiKeyframeRepository.this,
|
||||
new GuiLabel().setI18nText("replaymod.gui.keyframerepo.delete").setColor(Colors.BLACK)
|
||||
).setYesI18nLabel("replaymod.gui.delete").setNoI18nLabel("replaymod.gui.cancel");
|
||||
Futures.addCallback(popup.getFuture(), new FutureCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean delete) {
|
||||
if (delete) {
|
||||
for (Entry entry : selectedEntries) {
|
||||
timelines.remove(entry.name);
|
||||
list.getListPanel().removeElement(entry);
|
||||
}
|
||||
|
||||
selectedEntries.clear();
|
||||
updateButtons();
|
||||
save();
|
||||
}
|
||||
).setYesI18nLabel("replaymod.gui.delete").setNoI18nLabel("replaymod.gui.cancel").onAccept(() -> {
|
||||
for (Entry entry : selectedEntries) {
|
||||
timelines.remove(entry.name);
|
||||
list.getListPanel().removeElement(entry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
selectedEntries.clear();
|
||||
updateButtons();
|
||||
save();
|
||||
});
|
||||
}
|
||||
}).setSize(75, 20).setI18nLabel("replaymod.gui.remove").setDisabled();
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.replaymod.render.gui;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.InstanceCreator;
|
||||
@@ -39,7 +37,6 @@ import net.minecraft.client.gui.screen.NoticeScreen;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.util.crash.CrashReport;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
@@ -131,25 +128,13 @@ public class GuiRenderSettings extends AbstractGuiPopup<GuiRenderSettings> {
|
||||
encodingPresetDropdown.getSelectedValue().getFileExtension());
|
||||
popup.setFolder(outputFile.getParentFile());
|
||||
popup.setFileName(outputFile.getName());
|
||||
Futures.addCallback(
|
||||
popup.getFuture(),
|
||||
new FutureCallback<File>() {
|
||||
@Override
|
||||
public void onSuccess(@Nullable File result) {
|
||||
if (result != null) {
|
||||
if (!result.getName().equals(outputFile.getName())) {
|
||||
userDefinedOutputFileName = true;
|
||||
}
|
||||
outputFile = result;
|
||||
outputFileButton.setLabel(result.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
throw new RuntimeException(t);
|
||||
}
|
||||
});
|
||||
popup.onAccept(file -> {
|
||||
if (!file.getName().equals(outputFile.getName())) {
|
||||
userDefinedOutputFileName = true;
|
||||
}
|
||||
outputFile = file;
|
||||
outputFileButton.setLabel(file.getName());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -401,10 +386,10 @@ public class GuiRenderSettings extends AbstractGuiPopup<GuiRenderSettings> {
|
||||
case CUBIC:
|
||||
case EQUIRECTANGULAR:
|
||||
case ODS:
|
||||
stabilizePanel.forEach(IGuiCheckbox.class).setEnabled();
|
||||
stabilizePanel.invokeAll(IGuiCheckbox.class, GuiElement::setEnabled);
|
||||
break;
|
||||
default:
|
||||
stabilizePanel.forEach(IGuiCheckbox.class).setDisabled();
|
||||
stabilizePanel.invokeAll(IGuiCheckbox.class, GuiElement::setDisabled);
|
||||
}
|
||||
|
||||
// Enable/Disable Spherical FOV slider
|
||||
|
||||
@@ -93,7 +93,7 @@ public class GuiEditMarkerPopup extends AbstractGuiPopup<GuiEditMarkerPopup> imp
|
||||
|
||||
popup.setLayout(new VerticalLayout().setSpacing(5))
|
||||
.addElements(new VerticalLayout.Data(0.5), title, inputs, buttons);
|
||||
popup.forEach(IGuiLabel.class).setColor(Colors.BLACK);
|
||||
popup.invokeAll(IGuiLabel.class, e -> e.setColor(Colors.BLACK));
|
||||
|
||||
nameField.setText(Strings.nullToEmpty(marker.getName()));
|
||||
timeField.setValue(marker.getTime());
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.replaymod.replay.gui.screen;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.SettableFuture;
|
||||
import com.replaymod.render.gui.GuiRenderQueue;
|
||||
import com.replaymod.render.rendering.VideoRenderer;
|
||||
@@ -63,6 +60,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.replaymod.replay.ReplayModReplay.LOGGER;
|
||||
@@ -151,67 +149,46 @@ public class GuiReplayViewer extends GuiScreen {
|
||||
popup.getYesButton().setEnabled(!nameField.getText().isEmpty()
|
||||
&& !new File(file.getParentFile(), Utils.replayNameToFileName(nameField.getText())).exists());
|
||||
});
|
||||
Futures.addCallback(popup.getFuture(), new FutureCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean delete) {
|
||||
if (delete) {
|
||||
// Sanitize their input
|
||||
String name = nameField.getText().trim();
|
||||
// This file is what they want
|
||||
File targetFile = new File(file.getParentFile(), Utils.replayNameToFileName(name));
|
||||
try {
|
||||
// Finally, try to move it
|
||||
FileUtils.moveFile(file, targetFile);
|
||||
} catch (IOException e) {
|
||||
// We failed (might also be their OS)
|
||||
e.printStackTrace();
|
||||
getMinecraft().openScreen(new NoticeScreen(
|
||||
//#if MC>=11400
|
||||
GuiReplayViewer.this::display,
|
||||
new TranslatableText("replaymod.gui.viewer.delete.failed1"),
|
||||
new TranslatableText("replaymod.gui.viewer.delete.failed2")
|
||||
//#else
|
||||
//$$ I18n.format("replaymod.gui.viewer.delete.failed1"),
|
||||
//$$ I18n.format("replaymod.gui.viewer.delete.failed2")
|
||||
//#endif
|
||||
));
|
||||
return;
|
||||
}
|
||||
list.load();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
t.printStackTrace();
|
||||
popup.onAccept(() -> {
|
||||
// Sanitize their input
|
||||
String newName = nameField.getText().trim();
|
||||
// This file is what they want
|
||||
File targetFile = new File(file.getParentFile(), Utils.replayNameToFileName(newName));
|
||||
try {
|
||||
// Finally, try to move it
|
||||
FileUtils.moveFile(file, targetFile);
|
||||
} catch (IOException e) {
|
||||
// We failed (might also be their OS)
|
||||
e.printStackTrace();
|
||||
getMinecraft().openScreen(new NoticeScreen(
|
||||
//#if MC>=11400
|
||||
GuiReplayViewer.this::display,
|
||||
new TranslatableText("replaymod.gui.viewer.delete.failed1"),
|
||||
new TranslatableText("replaymod.gui.viewer.delete.failed2")
|
||||
//#else
|
||||
//$$ I18n.format("replaymod.gui.viewer.delete.failed1"),
|
||||
//$$ I18n.format("replaymod.gui.viewer.delete.failed2")
|
||||
//#endif
|
||||
));
|
||||
return;
|
||||
}
|
||||
list.load();
|
||||
});
|
||||
}
|
||||
}).setSize(73, 20).setI18nLabel("replaymod.gui.rename").setDisabled();
|
||||
public final GuiButton deleteButton = new GuiButton().onClick(() -> {
|
||||
for (GuiReplayEntry entry : list.getSelected()) {
|
||||
String name = entry.name.getText();
|
||||
GuiYesNoPopup popup = GuiYesNoPopup.open(GuiReplayViewer.this,
|
||||
GuiYesNoPopup.open(GuiReplayViewer.this,
|
||||
new GuiLabel().setI18nText("replaymod.gui.viewer.delete.linea").setColor(Colors.BLACK),
|
||||
new GuiLabel().setI18nText("replaymod.gui.viewer.delete.lineb", name + Formatting.RESET).setColor(Colors.BLACK)
|
||||
).setYesI18nLabel("replaymod.gui.delete").setNoI18nLabel("replaymod.gui.cancel");
|
||||
Futures.addCallback(popup.getFuture(), new FutureCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean delete) {
|
||||
if (delete) {
|
||||
try {
|
||||
FileUtils.forceDelete(entry.file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
list.load();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
t.printStackTrace();
|
||||
).setYesI18nLabel("replaymod.gui.delete").setNoI18nLabel("replaymod.gui.cancel").onAccept(() -> {
|
||||
try {
|
||||
FileUtils.forceDelete(entry.file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
list.load();
|
||||
});
|
||||
}
|
||||
}).setSize(73, 20).setI18nLabel("replaymod.gui.delete").setDisabled();
|
||||
|
||||
@@ -155,7 +155,7 @@ public abstract class GuiEditKeyframe<T extends GuiEditKeyframe<T>> extends Abst
|
||||
|
||||
link(timeMinField, timeSecField, timeMSecField);
|
||||
|
||||
popup.forEach(IGuiLabel.class).setColor(Colors.BLACK);
|
||||
popup.invokeAll(IGuiLabel.class, e -> e.setColor(Colors.BLACK));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -194,7 +194,7 @@ public abstract class GuiEditKeyframe<T extends GuiEditKeyframe<T>> extends Abst
|
||||
|
||||
link(timestampMinField, timestampSecField, timestampMSecField, timeMinField, timeSecField, timeMSecField);
|
||||
|
||||
popup.forEach(IGuiLabel.class).setColor(Colors.BLACK);
|
||||
popup.invokeAll(IGuiLabel.class, e -> e.setColor(Colors.BLACK));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -252,7 +252,7 @@ public abstract class GuiEditKeyframe<T extends GuiEditKeyframe<T>> extends Abst
|
||||
|
||||
link(xField, yField, zField, yawField, pitchField, rollField, timeMinField, timeSecField, timeMSecField);
|
||||
|
||||
popup.forEach(IGuiLabel.class).setColor(Colors.BLACK);
|
||||
popup.invokeAll(IGuiLabel.class, e -> e.setColor(Colors.BLACK));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -399,23 +399,12 @@ public class GuiPathing {
|
||||
}
|
||||
|
||||
public void clearKeyframesButtonPressed() {
|
||||
GuiYesNoPopup popup = GuiYesNoPopup.open(replayHandler.getOverlay(),
|
||||
GuiYesNoPopup.open(replayHandler.getOverlay(),
|
||||
new GuiLabel().setI18nText("replaymod.gui.clearcallback.title").setColor(Colors.BLACK)
|
||||
).setYesI18nLabel("gui.yes").setNoI18nLabel("gui.no");
|
||||
Futures.addCallback(popup.getFuture(), new FutureCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean delete) {
|
||||
if (delete) {
|
||||
mod.clearCurrentTimeline();
|
||||
if (entityTracker != null) {
|
||||
mod.getCurrentTimeline().setEntityTracker(entityTracker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
t.printStackTrace();
|
||||
).setYesI18nLabel("gui.yes").setNoI18nLabel("gui.no").onAccept(() -> {
|
||||
mod.clearCurrentTimeline();
|
||||
if (entityTracker != null) {
|
||||
mod.getCurrentTimeline().setEntityTracker(entityTracker);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user