package crazypants.enderio.machines.config.config;

import java.util.Locale;

import javax.annotation.Nonnull;

import crazypants.enderio.base.Log;
import crazypants.enderio.base.config.config.PersonalConfig;
import info.loenwind.autoconfig.factory.IValue;
import info.loenwind.autoconfig.factory.IValueFactory;
import crazypants.enderio.machines.config.Config;

public final class ClientConfig {

  public static final IValueFactory F = Config.F.section("client");

  public static final IValue<Boolean> jeiUseShortenedPainterRecipes = F.make("jeiUseShortenedPainterRecipes", true, //
      "If true, only a handful of sample painter recipes will be shown in JEI. Enable this if you have timing problems "
          + "starting a world or logging into a server.");

  public static final IValue<Boolean> machineSoundsEnabled = PersonalConfig.machineSoundsEnabled;

  public static final IValue<Float> machineSoundVolume = PersonalConfig.machineSoundsVolume;

  public static final IValue<Boolean> bloodEnabled = new IValue<Boolean>() {
    private final IValue<Integer> bloodEnabledInt = F.make("bloodEnabled", 0, "Should blood be red or green? (-1=green, 0=auto, 1=red)").setRange(-1, 1);
    private boolean hasLogged = false;

    @Override
    public @Nonnull Boolean get() {
      final boolean overrideNeeded = Locale.getDefault().getCountry().equals(Locale.GERMANY.getCountry());
      final Integer value = bloodEnabledInt.get();
      if (overrideNeeded && value == 0) {
        if (!hasLogged) {
          Log.warn("Detected local country '" + Locale.getDefault().getCountry() + "', cencoring blood.");
          hasLogged = true;
        }
        return false;
      } else {
        return value > 0;
      }
    }
  };

}

@@ -202,16 +202,66 @@
 Config;%0A
+import crazypants.enderio.machines.config.Config;%0A
 import i
@@ -358,58 +358,8 @@
 ory;
-%0Aimport crazypants.enderio.machines.config.Config;
 %0A%0Apu
@@ -960,77 +960,111 @@
 %0A  p
-ublic static final IValue%3CBoolean%3E bloodEnabled = new IValue%3C
+rivate enum BloodType implements IValue%3CBoolean%3E %7B%0A    GREEN %7B%0A      @Override%0A      public 
 Boolean
-%3E
+ get
 () %7B
@@ -1072,157 +1072,142 @@
     
-private final IValue%3CInteger%3E bloodEnabledInt = F.make(%22bloodEnabled%22, 0, %22Should blood be red or green? (-1=green, 0=auto, 1=red)%22).setRange(-1, 1);
+    return false;%0A      %7D%0A    %7D,%0A    RED %7B%0A      @Override%0A      public Boolean get() %7B%0A        return true;%0A      %7D%0A    %7D,%0A    AUTO;%0A
 %0A   
@@ -1215,16 +1215,23 @@
 private 
+static 
 boolean 
@@ -1279,17 +1279,8 @@
 lic 
-@Nonnull 
 Bool
@@ -1311,30 +1311,23 @@
 boolean 
-overrideNeeded
+germany
  = Local
@@ -1401,107 +1401,23 @@
     
-final Integer value = bloodEnabledInt.get();%0A      if (overrideNeeded && value == 0) %7B%0A        if (
+if (germany && 
 !has
@@ -1422,26 +1422,24 @@
 asLogged) %7B%0A
-  
         Log.
@@ -1539,18 +1539,16 @@
         
-  
 hasLogge
@@ -1563,22 +1563,18 @@
 ;%0A      
-  %7D%0A  
+%7D%0A
       re
@@ -1582,63 +1582,346 @@
 urn 
-false
+!germany
 ;%0A    
+%7D%0A
   %7D
- else
+%0A%0A  public static final IValue%3CBoolean%3E bloodEnabled = new IValue%3CBoolean%3E()
  %7B%0A
+%0A
     
-    return value %3E 0;%0A      %7D
+private final IValue%3CBloodType%3E bloodEnabledEnum = F.make(%22bloodColor%22, BloodType.AUTO, %22Which color should blood have? (RED, GREEN, AUTO)%22);%0A%0A    @Override%0A    public @Nonnull Boolean get() %7B%0A      return bloodEnabledEnum.get().get();
 %0A   

Fix Slice'n'Splice configuration