package mapped;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import net.runelite.mapping.ObfuscatedGetter;
import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;
import net.runelite.rs.api.RSClientPreferences;

@ObfuscatedName("dl")
public class ClientPreferences implements RSClientPreferences {
   @ObfuscatedName("ab")
   boolean roofsHidden;
   @ObfuscatedName("au")
   boolean hideUsername;
   @ObfuscatedName("aa")
   boolean titleMusicDisabled;
   @ObfuscatedName("ac")
   boolean displayFps;
   @ObfuscatedName("al")
   @ObfuscatedGetter(
      intValue = -125977763
   )
   int field1286;
   @ObfuscatedName("az")
   double brightness;
   @ObfuscatedName("ap")
   @ObfuscatedGetter(
      intValue = 681538859
   )
   int musicVolume;
   @ObfuscatedName("av")
   @ObfuscatedGetter(
      intValue = -392533553
   )
   int soundEffectsVolume;
   @ObfuscatedName("ax")
   @ObfuscatedGetter(
      intValue = 717748859
   )
   int areaSoundEffectsVolume;
   @ObfuscatedName("as")
   @ObfuscatedGetter(
      intValue = -910618713
   )
   int field1291;
   @ObfuscatedName("ay")
   String rememberedUsername;
   @ObfuscatedName("ak")
   @ObfuscatedGetter(
      intValue = -1858072331
   )
   int windowMode;
   @ObfuscatedName("aj")
   final Map parameters;

   ClientPreferences() {
      this.hideUsername = false;
      this.displayFps = false;
      this.brightness = 0.8D;
      this.musicVolume = 127;
      this.soundEffectsVolume = 127;
      this.areaSoundEffectsVolume = 127;
      this.field1291 = -1;
      this.rememberedUsername = null;
      this.windowMode = 1;
      this.parameters = new LinkedHashMap();
      this.method2537_base(true);
   }

   @ObfuscatedSignature(
      descriptor = "(Luj;)V"
   )
   ClientPreferences(Buffer var1) {
      this.hideUsername = false;
      this.displayFps = false;
      this.brightness = 0.8D;
      this.musicVolume = 127;
      this.soundEffectsVolume = 127;
      this.areaSoundEffectsVolume = 127;
      this.field1291 = -1;
      this.rememberedUsername = null;
      this.windowMode = 1;
      this.parameters = new LinkedHashMap();
      if(var1 != null && var1.array != null) {
         int var2 = var1.readUnsignedByte_base();
         if(var2 >= 0 && var2 <= 10) {
            if(var1.readUnsignedByte_base() == 1) {
               this.roofsHidden = true;
            }

            if(var2 > 1) {
               this.titleMusicDisabled = var1.readUnsignedByte_base() == 1;
            }

            if(var2 > 3) {
               this.windowMode = var1.readUnsignedByte_base();
            }

            if(var2 > 2) {
               int var3 = var1.readUnsignedByte_base();

               for(int var4 = 0; var4 < var3; ++var4) {
                  int var5 = var1.readInt_base();
                  int var6 = var1.readInt_base();
                  this.parameters.put(Integer.valueOf(var5), Integer.valueOf(var6));
               }
            }

            if(var2 > 4) {
               this.rememberedUsername = var1.readStringCp1252NullTerminatedOrNull_base();
            }

            if(var2 > 5) {
               this.hideUsername = var1.readBoolean_base();
            }

            if(var2 > 6) {
               this.brightness = (double)var1.readUnsignedByte_base() / 100.0D;
               this.musicVolume = var1.readUnsignedByte_base();
               this.soundEffectsVolume = var1.readUnsignedByte_base();
               this.areaSoundEffectsVolume = var1.readUnsignedByte_base();
            }

            if(var2 > 7) {
               this.field1291 = var1.readUnsignedByte_base();
            }

            if(var2 > 8) {
               this.displayFps = var1.readUnsignedByte_base() == 1;
            }

            if(var2 > 9) {
               this.field1286 = var1.readInt_base();
            }
         } else {
            this.method2537_base(true);
         }
      } else {
         this.method2537_base(true);
      }

   }

   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "(ZB)V",
      garbageValue = "65"
   )
   void method2537_base(boolean var1) {
   }

   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "(I)Luj;",
      garbageValue = "1617415071"
   )
   Buffer method2603() {
      Buffer var1 = new Buffer(417, true);
      var1.writeByte_base(10);
      var1.writeByte_base(this.roofsHidden?1:0);
      var1.writeByte_base(this.titleMusicDisabled?1:0);
      var1.writeByte_base(this.windowMode);
      var1.writeByte_base(this.parameters.size());
      Iterator var2 = this.parameters.entrySet().iterator();

      while(var2.hasNext()) {
         Entry var3 = (Entry)var2.next();
         var1.writeInt_base(((Integer)var3.getKey()).intValue());
         var1.writeInt_base(((Integer)var3.getValue()).intValue());
      }

      var1.writeStringCp1252NullTerminated_base(this.rememberedUsername != null?this.rememberedUsername:"");
      var1.writeBoolean_base(this.hideUsername);
      var1.writeByte_base((int)(this.brightness * 100.0D));
      var1.writeByte_base(this.musicVolume);
      var1.writeByte_base(this.soundEffectsVolume);
      var1.writeByte_base(this.areaSoundEffectsVolume);
      var1.writeByte_base(this.field1291);
      var1.writeByte_base(this.displayFps?1:0);
      var1.writeInt_base(this.field1286);
      return var1;
   }

   @ObfuscatedName("ao")
   @ObfuscatedSignature(
      descriptor = "(ZB)V",
      garbageValue = "-10"
   )
   void method2540_base(boolean var1) {
      this.roofsHidden = var1;
      TextureProvider.savePreferences_base();
   }

   @ObfuscatedName("ab")
   @ObfuscatedSignature(
      descriptor = "(I)Z",
      garbageValue = "-194443239"
   )
   boolean method2541_base() {
      return this.roofsHidden;
   }

   @ObfuscatedName("au")
   @ObfuscatedSignature(
      descriptor = "(ZI)V",
      garbageValue = "-469000967"
   )
   void method2583_base(boolean var1) {
      this.hideUsername = var1;
      TextureProvider.savePreferences_base();
   }

   @ObfuscatedName("aa")
   @ObfuscatedSignature(
      descriptor = "(I)Z",
      garbageValue = "-1669966382"
   )
   boolean method2543_base() {
      return this.hideUsername;
   }

   @ObfuscatedName("ac")
   @ObfuscatedSignature(
      descriptor = "(ZS)V",
      garbageValue = "-9352"
   )
   void method2571_base(boolean var1) {
      this.titleMusicDisabled = var1;
      TextureProvider.savePreferences_base();
   }

   @ObfuscatedName("al")
   @ObfuscatedSignature(
      descriptor = "(I)Z",
      garbageValue = "2135822101"
   )
   boolean method2631_base() {
      return this.titleMusicDisabled;
   }

   @ObfuscatedName("az")
   @ObfuscatedSignature(
      descriptor = "(ZI)V",
      garbageValue = "-1108077215"
   )
   void method2546_base(boolean var1) {
      this.displayFps = var1;
      TextureProvider.savePreferences_base();
   }

   @ObfuscatedName("ap")
   @ObfuscatedSignature(
      descriptor = "(I)V",
      garbageValue = "-482539852"
   )
   void method2547_base() {
      this.method2546_base(!this.displayFps);
   }

   @ObfuscatedName("av")
   @ObfuscatedSignature(
      descriptor = "(I)Z",
      garbageValue = "-609893457"
   )
   boolean method2608_base() {
      return this.displayFps;
   }

   @ObfuscatedName("ax")
   @ObfuscatedSignature(
      descriptor = "(IS)V",
      garbageValue = "-12427"
   )
   void method2549_base(int var1) {
      this.field1286 = var1;
      TextureProvider.savePreferences_base();
   }

   @ObfuscatedName("as")
   @ObfuscatedSignature(
      descriptor = "(B)I",
      garbageValue = "0"
   )
   int method2604_base() {
      return this.field1286;
   }

   @ObfuscatedName("ay")
   void method2551_base(double var1) {
      this.brightness = var1;
      TextureProvider.savePreferences_base();
   }

   @ObfuscatedName("ak")
   @ObfuscatedSignature(
      descriptor = "(I)D",
      garbageValue = "-2063080274"
   )
   double method2548_base() {
      return this.brightness;
   }

   @ObfuscatedName("aj")
   @ObfuscatedSignature(
      descriptor = "(II)V",
      garbageValue = "1063115901"
   )
   void method2553_base(int var1) {
      this.musicVolume = var1;
      TextureProvider.savePreferences_base();
   }

   @ObfuscatedName("am")
   @ObfuscatedSignature(
      descriptor = "(I)I",
      garbageValue = "-1490474605"
   )
   int method2554_base() {
      return this.musicVolume;
   }

   @ObfuscatedName("aq")
   @ObfuscatedSignature(
      descriptor = "(IS)V",
      garbageValue = "256"
   )
   void updateSoundEffectVolume_base(int var1) {
      this.soundEffectsVolume = var1;
      TextureProvider.savePreferences_base();
   }

   @ObfuscatedName("ai")
   @ObfuscatedSignature(
      descriptor = "(I)I",
      garbageValue = "1655896593"
   )
   int method2556_base() {
      return this.soundEffectsVolume;
   }

   @ObfuscatedName("aw")
   @ObfuscatedSignature(
      descriptor = "(II)V",
      garbageValue = "-568127597"
   )
   void method2559_base(int var1) {
      this.areaSoundEffectsVolume = var1;
      TextureProvider.savePreferences_base();
   }

   @ObfuscatedName("ae")
   @ObfuscatedSignature(
      descriptor = "(I)I",
      garbageValue = "564596294"
   )
   int method2605_base() {
      return this.areaSoundEffectsVolume;
   }

   @ObfuscatedName("an")
   @ObfuscatedSignature(
      descriptor = "(Ljava/lang/String;I)V",
      garbageValue = "874203838"
   )
   void method2586_base(String var1) {
      this.rememberedUsername = var1;
      TextureProvider.savePreferences_base();
   }

   @ObfuscatedName("ag")
   @ObfuscatedSignature(
      descriptor = "(B)Ljava/lang/String;",
      garbageValue = "-69"
   )
   String method2593_base() {
      return this.rememberedUsername;
   }

   @ObfuscatedName("ad")
   @ObfuscatedSignature(
      descriptor = "(II)V",
      garbageValue = "608118295"
   )
   void method2561_base(int var1) {
      this.field1291 = var1;
      TextureProvider.savePreferences_base();
   }

   @ObfuscatedName("af")
   @ObfuscatedSignature(
      descriptor = "(B)I",
      garbageValue = "-12"
   )
   int method2562_base() {
      return this.field1291;
   }

   @ObfuscatedName("be")
   @ObfuscatedSignature(
      descriptor = "(IB)V",
      garbageValue = "32"
   )
   void method2563_base(int var1) {
      this.windowMode = var1;
      TextureProvider.savePreferences_base();
   }

   @ObfuscatedName("bd")
   @ObfuscatedSignature(
      descriptor = "(I)I",
      garbageValue = "-1248539592"
   )
   int method2564_base() {
      return this.windowMode;
   }

   @ObfuscatedName("bl")
   @ObfuscatedSignature(
      descriptor = "(Ljava/lang/String;II)V",
      garbageValue = "-1748399566"
   )
   void method2565_base(String var1, int var2) {
      int var3 = this.method2568_base(var1);
      if(this.parameters.size() >= 10 && !this.parameters.containsKey(Integer.valueOf(var3))) {
         Iterator var4 = this.parameters.entrySet().iterator();
         var4.next();
         var4.remove();
      }

      this.parameters.put(Integer.valueOf(var3), Integer.valueOf(var2));
      TextureProvider.savePreferences_base();
   }

   @ObfuscatedName("bi")
   @ObfuscatedSignature(
      descriptor = "(Ljava/lang/String;I)Z",
      garbageValue = "-885731567"
   )
   boolean method2566_base(String var1) {
      int var2 = this.method2568_base(var1);
      return this.parameters.containsKey(Integer.valueOf(var2));
   }

   @ObfuscatedName("bv")
   @ObfuscatedSignature(
      descriptor = "(Ljava/lang/String;I)I",
      garbageValue = "1978025457"
   )
   int method2567_base(String var1) {
      int var2 = this.method2568_base(var1);
      return !this.parameters.containsKey(Integer.valueOf(var2))?0:((Integer)this.parameters.get(Integer.valueOf(var2))).intValue();
   }

   @ObfuscatedName("bf")
   @ObfuscatedSignature(
      descriptor = "(Ljava/lang/String;B)I",
      garbageValue = "8"
   )
   int method2568_base(String var1) {
      return Message.method1245_base(var1.toLowerCase());
   }

   public boolean getHideUsername() {
      return this.hideUsername;
   }

   public int getMusicVolume() {
      return this.musicVolume;
   }

   public void setMusicVolume(int var1) {
      this.musicVolume = var1;
   }

   public int getSoundEffectVolume() {
      return this.soundEffectsVolume;
   }

   public void setSoundEffectVolume(int var1) {
      this.soundEffectsVolume = var1;
   }

   public int getAreaSoundEffectVolume() {
      return this.areaSoundEffectsVolume;
   }

   public void setAreaSoundEffectVolume(int var1) {
      this.areaSoundEffectsVolume = var1;
   }

   public String getRememberedUsername() {
      return this.rememberedUsername;
   }

   public void setRememberedUsername(String var1) {
      this.rememberedUsername = var1;
   }

   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "(II)Lht;",
      garbageValue = "1728806709"
   )
   public static VarbitComposition method2644(int var0) {
      VarbitComposition var1 = (VarbitComposition)VarbitComposition.VarbitDefinition_cached.get((long)var0);
      if(var1 != null) {
         return var1;
      } else {
         byte[] var2 = VarbitComposition.VarbitDefinition_archive.takeFile_base(14, var0);
         var1 = new VarbitComposition();
         if(var2 != null) {
            var1.method3808(new Buffer(var2));
         }

         VarbitComposition.VarbitDefinition_cached.put(var1, (long)var0);
         return var1;
      }
   }

   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "(III)I",
      garbageValue = "2085182056"
   )
   static int method2570_base(int var0, int var1) {
      ItemContainer var2 = (ItemContainer)ItemContainer.itemContainers.get((long)var0);
      return var2 == null?-1:(var1 >= 0 && var1 < var2.ids.length?var2.ids[var1]:-1);
   }

   @ObfuscatedName("ak")
   @ObfuscatedSignature(
      descriptor = "(ZB)V",
      garbageValue = "28"
   )
   static void method2645_base(boolean var0) {
      byte var1 = 0;
      if(!class4.method21_base()) {
         var1 = 12;
      } else if(SpriteMask.client.containsAccessAndRefreshToken_base() || SpriteMask.client.method1347_base() || SpriteMask.client.containsSessionAndCharacterId_base()) {
         var1 = 10;
      }

      UserComparator7.method2966_base(var1);
      if(var0) {
         Login.Login_username = "";
         Client.onUsernameChanged(-1);
         Login.Login_password = "";
         class53.field350 = 0;
         NpcOverrides.otp = "";
      }

      Frames.method5517_base();
      class150.method3281_base();
   }
}
