mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-10-25 20:22:20 +00:00
[Feature] Shift to pause terminal view movement (#256)
Co-authored-by: Caedis <Caedis@users.noreply.github.com> Co-authored-by: Martin Robertz <dream-master@gmx.net> Co-authored-by: Maya <10861407+serenibyss@users.noreply.github.com>
This commit is contained in:
3 files changed
+144
-66
No files matched your search
@@ -587,6 +587,18 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
|
||||
memoryText = this.searchField.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleKeyboardInput() {
|
||||
super.handleKeyboardInput();
|
||||
|
||||
// Pause the terminal when holding shift
|
||||
this.repo.setPaused(hasShiftDown());
|
||||
}
|
||||
|
||||
private boolean hasShiftDown() {
|
||||
return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
|
||||
}
|
||||
|
||||
public void bindTextureBack(final String file) {
|
||||
final ResourceLocation loc = new ResourceLocation(FluidCraft.MODID, "textures/" + file);
|
||||
this.mc.getTextureManager().bindTexture(loc);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.glodblock.github.client.me;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.crossmod.thaumcraft.AspectUtil;
|
||||
@@ -15,7 +15,6 @@ import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.widgets.IScrollSource;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
@@ -30,12 +29,61 @@ public class EssentiaRepo extends FluidRepo {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void updateView() {
|
||||
this.view.clear();
|
||||
if (this.paused) {
|
||||
// Update existing view with new data
|
||||
for (int i = 0; i < this.view.size(); i++) {
|
||||
IAEItemStack entry = this.view.get(i);
|
||||
IAEItemStack serverEntry = this.list.findPrecise(entry);
|
||||
if (serverEntry == null) {
|
||||
entry.setStackSize(0);
|
||||
} else {
|
||||
this.view.set(i, serverEntry);
|
||||
}
|
||||
}
|
||||
|
||||
// Append newly added item stacks to the end of the view
|
||||
Set<IAEItemStack> viewSet = new HashSet<>(this.view);
|
||||
ArrayList<IAEItemStack> entriesToAdd = new ArrayList<>();
|
||||
for (IAEItemStack serverEntry : this.list) {
|
||||
if (!viewSet.contains(serverEntry)) {
|
||||
entriesToAdd.add(serverEntry);
|
||||
}
|
||||
}
|
||||
addEntriesToView(entriesToAdd);
|
||||
} else {
|
||||
this.view.clear();
|
||||
this.view.ensureCapacity(this.list.size());
|
||||
addEntriesToView(this.list);
|
||||
}
|
||||
|
||||
// Do not sort if paused
|
||||
if (!this.paused) {
|
||||
final Enum<?> SortBy = this.sortSrc.getSortBy();
|
||||
final Enum<?> SortDir = this.sortSrc.getSortDir();
|
||||
|
||||
FluidSorters.setDirection((appeng.api.config.SortDir) SortDir);
|
||||
FluidSorters.init();
|
||||
|
||||
if (SortBy == SortOrder.MOD) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_MOD);
|
||||
} else if (SortBy == SortOrder.AMOUNT) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_SIZE);
|
||||
} else if (SortBy == SortOrder.INVTWEAKS) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
|
||||
} else {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
// Update the display
|
||||
this.dsp.clear();
|
||||
|
||||
this.view.ensureCapacity(this.list.size());
|
||||
this.dsp.ensureCapacity(this.list.size());
|
||||
for (final IAEItemStack is : this.view) {
|
||||
this.dsp.add(is.getItemStack());
|
||||
}
|
||||
}
|
||||
|
||||
private void addEntriesToView(Iterable<IAEItemStack> entries) {
|
||||
final Enum<?> viewMode = this.sortSrc.getSortDisplay();
|
||||
final Enum<?> searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
|
||||
if (searchMode == SearchBoxMode.NEI_AUTOSEARCH || searchMode == SearchBoxMode.NEI_MANUAL_SEARCH) {
|
||||
@@ -59,7 +107,11 @@ public class EssentiaRepo extends FluidRepo {
|
||||
}
|
||||
}
|
||||
|
||||
for (IAEItemStack is : this.list) {
|
||||
for (IAEItemStack is : entries) {
|
||||
if (!AspectUtil.isEssentiaGas(ItemFluidDrop.getAeFluidStack(is))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.myPartitionList != null) {
|
||||
if (!this.myPartitionList.isListed(is)) {
|
||||
continue;
|
||||
@@ -88,40 +140,6 @@ public class EssentiaRepo extends FluidRepo {
|
||||
this.view.add(is);
|
||||
}
|
||||
}
|
||||
|
||||
final Enum<?> SortBy = this.sortSrc.getSortBy();
|
||||
final Enum<?> SortDir = this.sortSrc.getSortDir();
|
||||
|
||||
FluidSorters.setDirection((appeng.api.config.SortDir) SortDir);
|
||||
FluidSorters.init();
|
||||
|
||||
if (SortBy == SortOrder.MOD) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_MOD);
|
||||
} else if (SortBy == SortOrder.AMOUNT) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_SIZE);
|
||||
} else if (SortBy == SortOrder.INVTWEAKS) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
|
||||
} else {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_NAME);
|
||||
}
|
||||
|
||||
for (final IAEItemStack is : this.view) {
|
||||
this.dsp.add(is.getItemStack());
|
||||
}
|
||||
Iterator<IAEItemStack> it1 = this.view.iterator();
|
||||
while (it1.hasNext()) {
|
||||
IAEFluidStack fluid = ItemFluidDrop.getAeFluidStack(it1.next());
|
||||
if (!AspectUtil.isEssentiaGas(fluid)) {
|
||||
it1.remove();
|
||||
}
|
||||
}
|
||||
Iterator<ItemStack> it2 = this.dsp.iterator();
|
||||
while (it2.hasNext()) {
|
||||
FluidStack fluid = ItemFluidDrop.getFluidStack(it2.next());
|
||||
if (!AspectUtil.isEssentiaGas(fluid)) {
|
||||
it2.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,6 +13,8 @@ package com.glodblock.github.client.me;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -52,6 +54,7 @@ public class FluidRepo implements IDisplayRepo {
|
||||
|
||||
protected String searchString = "";
|
||||
protected IPartitionList<IAEItemStack> myPartitionList;
|
||||
protected boolean paused = false;
|
||||
private String NEIWord = null;
|
||||
private boolean hasPower;
|
||||
|
||||
@@ -100,12 +103,60 @@ public class FluidRepo implements IDisplayRepo {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void updateView() {
|
||||
this.view.clear();
|
||||
if (this.paused) {
|
||||
// Update existing view with new data
|
||||
for (int i = 0; i < this.view.size(); i++) {
|
||||
IAEItemStack entry = this.view.get(i);
|
||||
IAEItemStack serverEntry = this.list.findPrecise(entry);
|
||||
if (serverEntry == null) {
|
||||
entry.setStackSize(0);
|
||||
} else {
|
||||
this.view.set(i, serverEntry);
|
||||
}
|
||||
}
|
||||
|
||||
// Append newly added item stacks to the end of the view
|
||||
Set<IAEItemStack> viewSet = new HashSet<>(this.view);
|
||||
ArrayList<IAEItemStack> entriesToAdd = new ArrayList<>();
|
||||
for (IAEItemStack serverEntry : this.list) {
|
||||
if (!viewSet.contains(serverEntry)) {
|
||||
entriesToAdd.add(serverEntry);
|
||||
}
|
||||
}
|
||||
addEntriesToView(entriesToAdd);
|
||||
} else {
|
||||
this.view.clear();
|
||||
this.view.ensureCapacity(this.list.size());
|
||||
addEntriesToView(this.list);
|
||||
}
|
||||
|
||||
// Do not sort if paused
|
||||
if (!paused) {
|
||||
final Enum<?> SortBy = this.sortSrc.getSortBy();
|
||||
final Enum<?> SortDir = this.sortSrc.getSortDir();
|
||||
|
||||
FluidSorters.setDirection((appeng.api.config.SortDir) SortDir);
|
||||
FluidSorters.init();
|
||||
|
||||
if (SortBy == SortOrder.MOD) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_MOD);
|
||||
} else if (SortBy == SortOrder.AMOUNT) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_SIZE);
|
||||
} else if (SortBy == SortOrder.INVTWEAKS) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
|
||||
} else {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
this.dsp.clear();
|
||||
|
||||
this.view.ensureCapacity(this.list.size());
|
||||
this.dsp.ensureCapacity(this.list.size());
|
||||
for (final IAEItemStack is : this.view) {
|
||||
this.dsp.add(is.getItemStack());
|
||||
}
|
||||
}
|
||||
|
||||
private void addEntriesToView(Iterable<IAEItemStack> entries) {
|
||||
final Enum<?> viewMode = this.sortSrc.getSortDisplay();
|
||||
final Enum<?> searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
|
||||
if (searchMode == SearchBoxMode.NEI_AUTOSEARCH || searchMode == SearchBoxMode.NEI_MANUAL_SEARCH) {
|
||||
@@ -131,7 +182,7 @@ public class FluidRepo implements IDisplayRepo {
|
||||
}
|
||||
}
|
||||
|
||||
for (IAEItemStack is : this.list) {
|
||||
for (IAEItemStack is : entries) {
|
||||
if (this.myPartitionList != null) {
|
||||
if (!this.myPartitionList.isListed(is)) {
|
||||
continue;
|
||||
@@ -168,26 +219,6 @@ public class FluidRepo implements IDisplayRepo {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Enum<?> SortBy = this.sortSrc.getSortBy();
|
||||
final Enum<?> SortDir = this.sortSrc.getSortDir();
|
||||
|
||||
FluidSorters.setDirection((appeng.api.config.SortDir) SortDir);
|
||||
FluidSorters.init();
|
||||
|
||||
if (SortBy == SortOrder.MOD) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_MOD);
|
||||
} else if (SortBy == SortOrder.AMOUNT) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_SIZE);
|
||||
} else if (SortBy == SortOrder.INVTWEAKS) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
|
||||
} else {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_NAME);
|
||||
}
|
||||
|
||||
for (final IAEItemStack is : this.view) {
|
||||
this.dsp.add(is.getItemStack());
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateNEI(final String filter) {
|
||||
@@ -245,4 +276,21 @@ public class FluidRepo implements IDisplayRepo {
|
||||
public void setSearchString(@Nonnull final String searchString) {
|
||||
this.searchString = searchString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPaused() {
|
||||
return this.paused;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPaused(boolean paused) {
|
||||
if (this.paused != paused) {
|
||||
this.paused = paused;
|
||||
|
||||
// Update view when un-paused
|
||||
if (!paused) {
|
||||
updateView();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user