﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using UnityEngine;
using RimWorld;

namespace Rimworld_Animations {

    public class RJWAnimationSettings : ModSettings {

        public static bool orgasmQuiver, rapeShiver, soundOverride = true, hearts = true, controlGenitalRotation = false,
            PlayAnimForNonsexualActs = true;

        //probably move this setting to a different mod menu if moving rjw parts of code
        public static bool playVoices = true, playHumanlikeVoicesAsDefault = true;
        public static float floatRangeInRenderTreeMenu = 1f;

        public static bool offsetTab = false, debugMode = false;
        public static float shiverIntensity = 2f;

        public override void ExposeData() {

            base.ExposeData();
            Scribe_Values.Look(ref playVoices, "RJWAnimations_PlayVoices", true);
            Scribe_Values.Look(ref playHumanlikeVoicesAsDefault, "RJWAnimations-playHumanlikeVoicesAsDefault", true);
            Scribe_Values.Look(ref debugMode, "RJWAnimations-AnimsDebugMode", false);
            Scribe_Values.Look(ref offsetTab, "RJWAnimations-EnableOffsetTab", false);
            Scribe_Values.Look(ref controlGenitalRotation, "RJWAnimations-controlGenitalRotation", false);
            Scribe_Values.Look(ref orgasmQuiver, "RJWAnimations-orgasmQuiver");
            Scribe_Values.Look(ref rapeShiver, "RJWAnimations-rapeShiver");
            Scribe_Values.Look(ref hearts, "RJWAnimation-heartsOnLovin");
            Scribe_Values.Look(ref PlayAnimForNonsexualActs, "RJWAnims-PlayAnimForNonsexualActs");
            Scribe_Values.Look(ref soundOverride, "RJWAnimations-rjwAnimSoundOverride", true);
            Scribe_Values.Look(ref shiverIntensity, "RJWAnimations-shiverIntensity", 2f);
            Scribe_Values.Look(ref floatRangeInRenderTreeMenu, "RJWAnimations-FloatRangeRenderMenu", 1f);
            //todo: save offsetsByDefName

        }

    }

    public class RJW_Animations : Mod {

        public RJW_Animations(ModContentPack content) : base(content) {
            GetSettings<RJWAnimationSettings>();

        }

        public override void DoSettingsWindowContents(Rect inRect) {

            Listing_Standard listingStandard = new Listing_Standard();
            listingStandard.Begin(inRect);

            listingStandard.CheckboxLabeled("RimAnim_SoundOverride".Translate(), ref RJWAnimationSettings.soundOverride);
            listingStandard.CheckboxLabeled("RimAnim_GenitalRotation".Translate(), ref RJWAnimationSettings.controlGenitalRotation);
            listingStandard.CheckboxLabeled("RimAnim_OrgasmQuiver".Translate(), ref RJWAnimationSettings.orgasmQuiver);
            listingStandard.CheckboxLabeled("RimAnim_RapeShiver".Translate(), ref RJWAnimationSettings.rapeShiver);
            listingStandard.CheckboxLabeled("RimAnim_HeartsDuringLovin".Translate(), ref RJWAnimationSettings.hearts);
            listingStandard.CheckboxLabeled("RimAnim_PlayNonsexual".Translate(), ref RJWAnimationSettings.PlayAnimForNonsexualActs);
            listingStandard.CheckboxLabeled("RimAnim_AnimManagerTab".Translate(), ref RJWAnimationSettings.offsetTab);
            listingStandard.CheckboxLabeled("RimAnim_Voices".Translate(), ref RJWAnimationSettings.playVoices);
            if (RJWAnimationSettings.playVoices)
            {
                listingStandard.CheckboxLabeled("RimAnim_HumanlikeVoicesDefault".Translate(), ref RJWAnimationSettings.playHumanlikeVoicesAsDefault);
            }
            
            listingStandard.Label("RimAnim_ShiverIntensity".Translate() + RJWAnimationSettings.shiverIntensity);
            RJWAnimationSettings.shiverIntensity = listingStandard.Slider(RJWAnimationSettings.shiverIntensity, 0.0f, 12f);

            listingStandard.Label("RimAnim_FloatRangeRenderTree".Translate() + RJWAnimationSettings.floatRangeInRenderTreeMenu);
            RJWAnimationSettings.floatRangeInRenderTreeMenu = listingStandard.Slider(RJWAnimationSettings.floatRangeInRenderTreeMenu, 0.1f, 12f);

            listingStandard.CheckboxLabeled("RimAnim_DebugMode".Translate(), ref RJWAnimationSettings.debugMode);

           
            listingStandard.End();
            base.DoSettingsWindowContents(inRect);
        }

        public override void WriteSettings() {
            base.WriteSettings();
            OffsetMainButtonDefOf.OffsetManager.buttonVisible = RJWAnimationSettings.offsetTab;

        }

        public override string SettingsCategory() {
            return "RimAnim_ModSettings".Translate();
        }
    }
}
