package dev.crucifixbeta.mod.modules.impl.client;

import dev.crucifixbeta.mod.modules.Module;
import dev.crucifixbeta.mod.modules.settings.impl.EnumSetting;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.DrawContext;

@Environment(EnvType.CLIENT)
public class Language extends Module {
   public static Language INSTANCE;
   public final EnumSetting<Language.Mode> language = this.add(
      new EnumSetting<>("Language", Language.Mode.English).injectTask(this::syncLanguage)
   );

   public Language() {
      super("Language", Module.Category.Client);
      this.setChinese("\u8bed\u8a00");
      this.language.setChinese("\u8bed\u8a00");
      INSTANCE = this;
      this.syncLanguage();
   }

   @Override
   public void enable() {
      this.state = true;
   }

   @Override
   public void disable() {
      this.state = true;
   }

   @Override
   public boolean isOn() {
      return true;
   }

   @Override
   public void onRender2D(DrawContext ctx, float tickDelta) {
      this.syncLanguage();
   }

   private void syncLanguage() {
      if (ClientSetting.INSTANCE != null) {
         ClientSetting.INSTANCE.chinese.setValueWithoutTask(this.language.getValue() == Language.Mode.Chinese);
      }
   }
@Environment(EnvType.CLIENT)
   public static enum Mode {
      English,
      Chinese;

}
}
