添加样板终端按钮显示控制按钮

This commit is contained in:
GaLi 2026-05-25 11:32:43 +08:00
parent fabc2887e1
commit 2a1911490e
4 changed files with 55 additions and 13 deletions

View File

@ -33,8 +33,10 @@ public class ProviderSelectScreen extends Screen {
private static final Set<String> pinnedProviders = new HashSet<>();
private static final String PINNED_CONFIG_PATH = "extendedae_plus/pinned_providers.json";
private static final String AUTO_UPLOAD_UNIQUE_MATCH_KEY = "auto_upload_unique_match";
private static final String SHOW_PROCESSING_BUTTONS_KEY = "show_processing_buttons";
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
private static boolean autoUploadUniqueMatchEnabled = true;
private static boolean showProcessingButtonsEnabled = true;
// 静态初始化块加载置顶配置
static {
@ -65,6 +67,7 @@ public class ProviderSelectScreen extends Screen {
private EditBox searchBox;
// 中文名输入框用于添加映射
private EditBox cnInput;
private Button processingButtonsToggleButton;
private Button autoUploadToggleButton;
private String query = "";
private boolean needsRefresh = false;
@ -154,6 +157,26 @@ public class ProviderSelectScreen extends Screen {
Component.translatable(stateKey));
}
private Component buildProcessingButtonsToggleLabel() {
String stateKey = showProcessingButtonsEnabled
? "extendedae_plus.configuration.state_on"
: "extendedae_plus.configuration.state_off";
return Component.translatable("extendedae_plus.screen.show_processing_buttons",
Component.translatable(stateKey));
}
public static boolean isProcessingButtonsEnabled() {
return showProcessingButtonsEnabled;
}
private void toggleProcessingButtons() {
showProcessingButtonsEnabled = !showProcessingButtonsEnabled;
savePinnedProviders();
if (this.processingButtonsToggleButton != null) {
this.processingButtonsToggleButton.setMessage(this.buildProcessingButtonsToggleLabel());
}
}
private void toggleAutoUploadUniqueMatch() {
autoUploadUniqueMatchEnabled = !autoUploadUniqueMatchEnabled;
savePinnedProviders();
@ -359,8 +382,17 @@ public class ProviderSelectScreen extends Screen {
.build();
this.addRenderableWidget(reload);
int toggleX = centerX + 50;
int toggleY = navY + 30;
int toggleGap = 6;
int toggleWidth = 122;
this.processingButtonsToggleButton = Button.builder(this.buildProcessingButtonsToggleLabel(), b -> this.toggleProcessingButtons())
.bounds(toggleX, toggleY, toggleWidth, 20)
.build();
this.addRenderableWidget(this.processingButtonsToggleButton);
this.autoUploadToggleButton = Button.builder(this.buildAutoUploadToggleLabel(), b -> this.toggleAutoUploadUniqueMatch())
.bounds(centerX + 50, navY + 30, 250, 20)
.bounds(toggleX + toggleWidth + toggleGap, toggleY, toggleWidth, 20)
.build();
this.addRenderableWidget(this.autoUploadToggleButton);
@ -562,6 +594,11 @@ public class ProviderSelectScreen extends Screen {
if (autoUploadElement != null && autoUploadElement.isJsonPrimitive()) {
autoUploadUniqueMatchEnabled = autoUploadElement.getAsBoolean();
}
JsonElement showProcessingButtonsElement = obj.get(SHOW_PROCESSING_BUTTONS_KEY);
if (showProcessingButtonsElement != null && showProcessingButtonsElement.isJsonPrimitive()) {
showProcessingButtonsEnabled = showProcessingButtonsElement.getAsBoolean();
}
} catch (IOException | JsonSyntaxException e) {
// 加载失败时静默处理
}
@ -582,6 +619,7 @@ public class ProviderSelectScreen extends Screen {
}
obj.add("pinned", arr);
obj.addProperty(AUTO_UPLOAD_UNIQUE_MATCH_KEY, autoUploadUniqueMatchEnabled);
obj.addProperty(SHOW_PROCESSING_BUTTONS_KEY, showProcessingButtonsEnabled);
Files.writeString(cfgPath, GSON.toJson(obj));
} catch (IOException e) {

View File

@ -6,6 +6,7 @@ import appeng.client.gui.me.items.PatternEncodingTermScreen;
import appeng.client.gui.me.items.ProcessingEncodingPanel;
import appeng.client.gui.widgets.ActionButton;
import com.extendedae_plus.ExtendedAEPlus;
import com.extendedae_plus.client.screen.ProviderSelectScreen;
import com.extendedae_plus.client.gui.widgets.ScaledTextureButton;
import com.extendedae_plus.mixin.accessor.AbstractContainerScreenAccessor;
import com.extendedae_plus.mixin.accessor.ScreenAccessor;
@ -139,7 +140,8 @@ public abstract class ProcessingEncodingPanelMixin extends EncodingModePanel {
@Inject(method = "setVisible", at = @At("TAIL"), remap = false)
private void eap$updateInjectedButtons(boolean visible, CallbackInfo ci) {
this.cycleOutputBtn.setVisibility(false);
boolean showInjectedButtons = visible && ProviderSelectScreen.isProcessingButtonsEnabled();
this.cycleOutputBtn.setVisibility(visible && !showInjectedButtons);
if (this.eap$mul2Button == null) {
return;
@ -154,16 +156,16 @@ public abstract class ProcessingEncodingPanelMixin extends EncodingModePanel {
eap$ensureAdded(this.eap$swapOutputsButton);
eap$ensureAdded(this.eap$restoreRatioButton);
this.eap$mul2Button.setVisibility(visible);
this.eap$mul3Button.setVisibility(visible);
this.eap$mul5Button.setVisibility(visible);
this.eap$div2Button.setVisibility(visible);
this.eap$div3Button.setVisibility(visible);
this.eap$div5Button.setVisibility(visible);
this.eap$swapOutputsButton.setVisibility(visible);
this.eap$restoreRatioButton.setVisibility(visible);
this.eap$mul2Button.setVisibility(showInjectedButtons);
this.eap$mul3Button.setVisibility(showInjectedButtons);
this.eap$mul5Button.setVisibility(showInjectedButtons);
this.eap$div2Button.setVisibility(showInjectedButtons);
this.eap$div3Button.setVisibility(showInjectedButtons);
this.eap$div5Button.setVisibility(showInjectedButtons);
this.eap$swapOutputsButton.setVisibility(showInjectedButtons);
this.eap$restoreRatioButton.setVisibility(showInjectedButtons);
if (!visible) {
if (!showInjectedButtons) {
return;
}

View File

@ -102,7 +102,8 @@
"extendedae_plus.screen.reload_mapping": "Reload Mapping",
"extendedae_plus.screen.add_mapping": "Add Mapping",
"extendedae_plus.screen.remove_mapping": "Remove Mapping",
"extendedae_plus.screen.auto_upload_unique_match": "Auto Upload on Unique Match: %s",
"extendedae_plus.screen.show_processing_buttons": "Pattern Terminal Buttons Display: %s",
"extendedae_plus.screen.auto_upload_unique_match": "Unique Match Upload: %s",
"extendedae_plus.screen.cn_name": "Chinese Name",
"extendedae_plus.button.choose_provider": "Upload Pattern",
"key.extendedae_plus.create_pattern": "Create Pattern (Ctrl+Q)",

View File

@ -103,7 +103,8 @@
"extendedae_plus.screen.reload_mapping": "重载映射",
"extendedae_plus.screen.add_mapping": "增加映射",
"extendedae_plus.screen.remove_mapping": "删除映射",
"extendedae_plus.screen.auto_upload_unique_match": "唯一匹配时自动上传: %s",
"extendedae_plus.screen.show_processing_buttons": "样板终端按钮显示: %s",
"extendedae_plus.screen.auto_upload_unique_match": "唯一匹配上传: %s",
"extendedae_plus.screen.cn_name": "中文名",
"extendedae_plus.button.choose_provider":"上传样板",
"key.extendedae_plus.create_pattern": "快速创建样板 (Ctrl+Q)",