package entities;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.Animation.PlayMode;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.Array;
import com.ld52.agent.Agent;

import Global.Global;
import u.Uinput;
import u.UsefulMethods;

public class PausePerson extends Sprite {
	public enum State {
		MAIN
	};

	public State currentState;
	public State previousState;
	private Animation<TextureRegion> main;
	private float _animBreakingTimer;
	// private Animation<TextureRegion> walkLeft;
	// private Animation<TextureRegion> walkUp;
	// private Animation<TextureRegion> walkDown;
	// maybe just keep a simple ball that animates or something. Animated would definitely be a rec
	// private Texture ppTexture;
	// private TextureRegion ppRegion;
	private TextureAtlas atlasPP;
	private boolean isMain = true;// is the animation set to main
	public Color color;
	public Float speed;
	public Rectangle rect;
	public Rectangle saveGameRect;
	public Rectangle loadGameRect;
	public Rectangle muteSoundRect;
	public Rectangle muteMusicRect;
	public Rectangle keyBindingsRect;
	public Rectangle backRect;
	public Rectangle exitGameRect;
	public Rectangle crouchRect;
	public Rectangle sprintRect;
	public Rectangle keyBindingsBackRect;
	public boolean IsSwitchingToKeyBindings;
	public boolean isLeftKey;
	public boolean isRightKey;
	public boolean isUpKey;
	public boolean isDownKey;
	public boolean isFireKey;
	public boolean isJumpKey;
	public boolean isInventoryKey;
	public boolean isCrouchKey;
	public boolean isSprintKey;
	private int _sw;// sprite width
	private int _sh;// sprite height
	protected int MoveBufferX = 0, MoveBufferY = 0;
	private boolean dark;
	private float fadeTimer;
	private int _os = 35;// rectangle Y offset
	private int _osX = 250;// rectangle X offset
	private int _osMenuTextX = 150;// rectangle X offset
	private int _ppOffset = 35;// rectangle X offset
	// sfx
	private Sound moveUp;
	private Sound moveDown;
	private Sound moveRight;
	private Sound moveLeft;
	private Sound select;
	private Sound back;
	private Sound changeKey;
	/// <summary> //i have no idea if this translates. This is from another collider program because i can't invent this stuff a bizzilions times
	/// Determines how many units represent 1 pixel. Default is 100. Example: A speed of 100 would
	/// move the object 1 pixel per update.
	/// </summary>
	public int SpeedScale = 100;// this... um. did nothing hehehehahahhaha
	public boolean IsBiPolar;

	public PausePerson(float _x, float _y) {
		rect = new Rectangle();
		rect.x = _x;
		rect.y = _y;
		rect.width = 50;
		rect.height = 50;

		// add menu rectangles. :O _os = offset.
		saveGameRect = new Rectangle(Gdx.graphics.getWidth() / 2 - _osX, Gdx.graphics.getHeight() - 200f - _os, 600, 50);// was no _os and 460
		loadGameRect = new Rectangle(Gdx.graphics.getWidth() / 2 - _osX, Gdx.graphics.getHeight() - 250f - _os, 600, 50);// was no _os and 430
		muteSoundRect = new Rectangle(Gdx.graphics.getWidth() / 2 - _osX, Gdx.graphics.getHeight() - 300f - _os, 600, 50);// was no _os and 380
		muteMusicRect = new Rectangle(Gdx.graphics.getWidth() / 2 - _osX, Gdx.graphics.getHeight() - 350f - _os, 600, 50);// was no _os and 330
		keyBindingsRect = new Rectangle(Gdx.graphics.getWidth() / 2 - _osX, Gdx.graphics.getHeight() - 400f - _os, 600, 50);// was no _os and 280
		backRect = new Rectangle(Gdx.graphics.getWidth() / 2 - _osX, Gdx.graphics.getHeight() - 450f - _os, 600, 50);// was no _os and 230
		exitGameRect = new Rectangle(Gdx.graphics.getWidth() / 2 - _osX, Gdx.graphics.getHeight() - 500f - _os, 600, 50);// was no _os and 180
		crouchRect = new Rectangle(Gdx.graphics.getWidth() / 2 - _osX, Gdx.graphics.getHeight() - 550f - _os, 600, 50);// was no _os and 130
		sprintRect = new Rectangle(Gdx.graphics.getWidth() / 2 - _osX, Gdx.graphics.getHeight() - 600f - _os, 600, 50);// was no _os and 80
		keyBindingsBackRect = new Rectangle(Gdx.graphics.getWidth() / 2 - _osX, Gdx.graphics.getHeight() - 650f - _os, 600, 50);// was no _os and 30

		_sw = 50;
		_sh = 50;
		// this is for the animations
		currentState = State.MAIN;
		previousState = State.MAIN;
		_animBreakingTimer = 0f;
		speed = 50f;// how fast the goes//not sure here.
		// sounds
		moveUp = Gdx.audio.newSound(Gdx.files.internal("sfx/click.ogg"));
		moveDown = Gdx.audio.newSound(Gdx.files.internal("sfx/click2.ogg"));
		moveRight = Gdx.audio.newSound(Gdx.files.internal("sfx/click3.ogg"));
		moveLeft = Gdx.audio.newSound(Gdx.files.internal("sfx/click4.ogg"));
		select = Gdx.audio.newSound(Gdx.files.internal("sfx/dryFire.ogg"));
		back = Gdx.audio.newSound(Gdx.files.internal("sfx/spin2.ogg"));
		changeKey = Gdx.audio.newSound(Gdx.files.internal("sfx/spin6.ogg"));
		// get pause person atlas
		atlasPP = new TextureAtlas(Gdx.files.internal("pausePerson.txt"));
		// animated frames
		Array<TextureRegion> frames = new Array<TextureRegion>();
		frames.add(new TextureRegion(atlasPP.findRegion("pausePerson"), (0 * _sw), (0 * _sh), _sw, _sh));
		frames.add(new TextureRegion(atlasPP.findRegion("pausePerson"), (1 * _sw), (0 * _sh), _sw, _sh));
		frames.add(new TextureRegion(atlasPP.findRegion("pausePerson"), (2 * _sw), (0 * _sh), _sw, _sh));
		frames.add(new TextureRegion(atlasPP.findRegion("pausePerson"), (1 * _sw), (0 * _sh), _sw, _sh));
		main = new Animation<TextureRegion>(.05f, frames, PlayMode.LOOP);// was .06f
		frames.clear();// definitely starts right. then we say, when the line is one length + one _sw worth which would be what in actual numbers?
		// these two are specifically sprite settings to set the sprite's initial bounds and region
		// assign random color
		color = new Color(new Color(MathUtils.random(.5f, 1), MathUtils.random(.1f, 1), MathUtils.random(.8f, 1f), 1));
		setBounds(0, 0, _sw, _sh);
		setOriginCenter();
		setRegion(main.getKeyFrame(_animBreakingTimer, true));
	}

	// for all the animations: //this isn't even updated unless i call it from the other screen oh bother. *facepalm*
	public void Update(float dt, OrthographicCamera camera) {
		handleInput(dt, camera);
		Global.P = rect;
	}

	// for all the animations: //this isn't even updated unless i call it from the other screen oh bother. *facepalm*
	public TextureRegion getFrame(float dt, OrthographicCamera camera) {
		Update(dt, camera);

		currentState = getState();

		TextureRegion region;
		switch (currentState) {
		case MAIN:
			region = main.getKeyFrame(_animBreakingTimer, true);
			break;
		default:
			region = main.getKeyFrame(_animBreakingTimer, false);
			break;
		}
		if (isMain)
			_animBreakingTimer += dt;
		else
			_animBreakingTimer = 0;

		return region;
	}

	public State getState() {
		if (isMain)
			return State.MAIN;
		else
			return State.MAIN;
	}

	private void handleInput(float dt, OrthographicCamera camera) {
		// input controls
		boolean isCT = false;
		if (Gdx.input.isKeyJustPressed(Uinput.Right())) {
			// System.out.println("right: " + rect.x + " MW: " + HF.MW);
			isCT = rect.x > Agent.MW - _sw ? true : false;// right
			MoveRight(speed, isCT, dt);
			if (!Global.SetVolumeToZero)
				moveRight.play(2f);
		}
		if (Gdx.input.isKeyJustPressed(Uinput.Left())) {
			// System.out.println("left: " + rect.x + " MW: " + HF.MW);
			isCT = rect.x < -5 ? true : false; // left
			MoveLeft(speed, isCT, dt);
			if (!Global.SetVolumeToZero)
				moveLeft.play(2f);
		}

		if (Gdx.input.isKeyJustPressed(Uinput.Up())) {
			// System.out.println("up: " + rect.y + " MH: " + HF.MH);
			isCT = rect.y > Agent.MH - _sh ? true : false;// down
			MoveUp(speed, isCT, dt);
			if (!Global.SetVolumeToZero)
				moveUp.play(2f);
		}
		if (Gdx.input.isKeyJustPressed(Uinput.Down())) {
			// System.out.println("down: " + rect.y + " MH: " + HF.MH);
			isCT = rect.y < -5 ? true : false;// up
			MoveDown(speed, isCT, dt);
			if (!Global.SetVolumeToZero)
				moveDown.play(2f);
		}
		// i'm putting this here for now TESTING the idea is solid, but it needs to go in the right place to work properly.
		// The entire display needs to change and that's on the screen
		if (rect.y == (Gdx.graphics.getHeight() - 200f - _ppOffset) && Gdx.input.isKeyJustPressed(Input.Keys.ENTER) && !Global.IsKeyBindings
				|| Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && !Global.IsKeyBindings && UsefulMethods.IsMouseInsideRectangle(saveGameRect, camera)) {
			if (!Global.SetVolumeToZero)
				select.play(2f);
		} else if (rect.y == (Gdx.graphics.getHeight() - 250f - _ppOffset) && Gdx.input.isKeyJustPressed(Input.Keys.ENTER) && !Global.IsKeyBindings
				|| Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && !Global.IsKeyBindings && UsefulMethods.IsMouseInsideRectangle(loadGameRect, camera)) {
			if (!Global.SetVolumeToZero)
				select.play(2f);
		} else if (rect.y == (Gdx.graphics.getHeight() - 300f - _ppOffset) && Gdx.input.isKeyJustPressed(Input.Keys.ENTER) && !Global.IsKeyBindings
				|| Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && !Global.IsKeyBindings && UsefulMethods.IsMouseInsideRectangle(muteSoundRect, camera)) {
			if (!Global.SetVolumeToZero)
				select.play(2f);
			if (Global.SetVolumeToZero) {
				Global.SetVolumeToZero = false;
				Agent.GameSettings.putBoolean("isSoundMuted", false);
				Agent.GameSettings.flush();
			} else {
				Global.SetVolumeToZero = true;
				Agent.GameSettings.putBoolean("isSoundMuted", true);
				Agent.GameSettings.flush();
			}
		} else if (rect.y == (Gdx.graphics.getHeight() - 350f - _ppOffset) && Gdx.input.isKeyJustPressed(Input.Keys.ENTER) && !Global.IsKeyBindings
				|| Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && !Global.IsKeyBindings && UsefulMethods.IsMouseInsideRectangle(muteMusicRect, camera)) {
			if (!Global.SetVolumeToZero)
				select.play(2f);
			if (Global.IsMusicPaused) {
				Global.IsMusicPaused = false;
				Agent.GameSettings.putBoolean("isMusicPaused", false);
				Agent.GameSettings.flush();
			} else {
				Global.IsMusicPaused = true;
				Agent.GameSettings.putBoolean("isMusicPaused", true);
				Agent.GameSettings.flush();
			}
		} else if (rect.y == (Gdx.graphics.getHeight() - 400f - _ppOffset) && Gdx.input.isKeyJustPressed(Input.Keys.ENTER) && !Global.IsKeyBindings
				|| Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && !Global.IsKeyBindings
						&& UsefulMethods.IsMouseInsideRectangle(keyBindingsRect, camera)) {
			if (!Global.SetVolumeToZero)
				select.play(2f);
			Global.IsKeyBindings = true;
			rect.y = (Gdx.graphics.getHeight() - 200f - _ppOffset);
		} else if (rect.y == (Gdx.graphics.getHeight() - 450f - _ppOffset) && Gdx.input.isKeyJustPressed(Input.Keys.ENTER) && !Global.IsKeyBindings
				|| Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && !Global.IsKeyBindings && UsefulMethods.IsMouseInsideRectangle(backRect, camera)) {
			if (!Global.SetVolumeToZero)
				back.play(2f);
			Global.IsPaused = false;
		} else if (rect.y == (Gdx.graphics.getHeight() - 500f - _ppOffset) && Gdx.input.isKeyJustPressed(Input.Keys.ENTER) && !Global.IsKeyBindings
				|| Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && !Global.IsKeyBindings && UsefulMethods.IsMouseInsideRectangle(exitGameRect, camera)) {
			if (!Global.SetVolumeToZero)
				select.play(2f);
			Gdx.app.exit();
		} else if (rect.y == (Gdx.graphics.getHeight() - 200f - _ppOffset) && Gdx.input.isKeyJustPressed(Input.Keys.ENTER) && Global.IsKeyBindings
				&& !Global.IsSetKey
				|| Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && Global.IsKeyBindings && !Global.IsSetKey
						&& UsefulMethods.IsMouseInsideRectangle(saveGameRect, camera)) {
			Global.IsSetKey = true;
			isLeftKey = true;
		} else if (rect.y == (Gdx.graphics.getHeight() - 250f - _ppOffset) && Gdx.input.isKeyJustPressed(Input.Keys.ENTER) && Global.IsKeyBindings
				&& !Global.IsSetKey
				|| Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && Global.IsKeyBindings && !Global.IsSetKey
						&& UsefulMethods.IsMouseInsideRectangle(loadGameRect, camera)) {
			Global.IsSetKey = true;
			isRightKey = true;
		} else if (rect.y == (Gdx.graphics.getHeight() - 300f - _ppOffset) && Gdx.input.isKeyJustPressed(Input.Keys.ENTER) && Global.IsKeyBindings
				&& !Global.IsSetKey
				|| Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && Global.IsKeyBindings && !Global.IsSetKey
						&& UsefulMethods.IsMouseInsideRectangle(muteSoundRect, camera)) {
			Global.IsSetKey = true;
			isUpKey = true;
		} else if (rect.y == (Gdx.graphics.getHeight() - 350f - _ppOffset) && Gdx.input.isKeyJustPressed(Input.Keys.ENTER) && Global.IsKeyBindings
				&& !Global.IsSetKey
				|| Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && Global.IsKeyBindings && !Global.IsSetKey
						&& UsefulMethods.IsMouseInsideRectangle(muteMusicRect, camera)) {
			Global.IsSetKey = true;
			isDownKey = true;
		} else if (rect.y == (Gdx.graphics.getHeight() - 400f - _ppOffset) && Gdx.input.isKeyJustPressed(Input.Keys.ENTER) && Global.IsKeyBindings
				&& !Global.IsSetKey
				|| Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && Global.IsKeyBindings && !Global.IsSetKey
						&& UsefulMethods.IsMouseInsideRectangle(keyBindingsRect, camera)) {
			Global.IsSetKey = true;
			isFireKey = true;
		} else if (rect.y == (Gdx.graphics.getHeight() - 450f - _ppOffset) && Gdx.input.isKeyJustPressed(Input.Keys.ENTER) && Global.IsKeyBindings
				&& !Global.IsSetKey
				|| Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && Global.IsKeyBindings && !Global.IsSetKey
						&& UsefulMethods.IsMouseInsideRectangle(backRect, camera)) {
			Global.IsSetKey = true;
			isJumpKey = true;
		} else if (rect.y == (Gdx.graphics.getHeight() - 500f - _ppOffset) && Gdx.input.isKeyJustPressed(Input.Keys.ENTER) && Global.IsKeyBindings
				&& !Global.IsSetKey
				|| Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && Global.IsKeyBindings && !Global.IsSetKey
						&& UsefulMethods.IsMouseInsideRectangle(exitGameRect, camera)) {
			Global.IsSetKey = true;
			isInventoryKey = true;
		} else if (rect.y == (Gdx.graphics.getHeight() - 550f - _ppOffset) && Gdx.input.isKeyJustPressed(Input.Keys.ENTER) && Global.IsKeyBindings
				&& !Global.IsSetKey
				|| Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && Global.IsKeyBindings && !Global.IsSetKey
						&& UsefulMethods.IsMouseInsideRectangle(crouchRect, camera)) {
			Global.IsSetKey = true;
			isCrouchKey = true;
		} else if (rect.y == (Gdx.graphics.getHeight() - 600f - _ppOffset) && Gdx.input.isKeyJustPressed(Input.Keys.ENTER) && Global.IsKeyBindings
				&& !Global.IsSetKey
				|| Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && Global.IsKeyBindings && !Global.IsSetKey
						&& UsefulMethods.IsMouseInsideRectangle(sprintRect, camera)) {
			Global.IsSetKey = true;
			isSprintKey = true;
		} else if (rect.y == (Gdx.graphics.getHeight() - 650f - _ppOffset) && Gdx.input.isKeyJustPressed(Input.Keys.ENTER) && Global.IsKeyBindings
				&& !Global.IsSetKey
				|| Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && Global.IsKeyBindings && !Global.IsSetKey
						&& UsefulMethods.IsMouseInsideRectangle(keyBindingsBackRect, camera)) {
			Global.IsKeyBindings = false;
			if (!Global.SetVolumeToZero)
				back.play(2f);
			rect.y = (Gdx.graphics.getHeight() - 400f - _ppOffset);
		} else if (isLeftKey) {
			if (Gdx.input.isKeyJustPressed(Input.Keys.ANY_KEY) || Gdx.input.isButtonJustPressed(Input.Buttons.LEFT)
					|| Gdx.input.isButtonJustPressed(Input.Buttons.MIDDLE) || Gdx.input.isButtonJustPressed(Input.Buttons.RIGHT)) {
				Agent.GameSettings.putInteger("left_key", Global.KeycodeSet);
				Agent.GameSettings.flush();
				Uinput.LoadDefaultInputs();
				if (!Global.SetVolumeToZero)
					changeKey.play(2f);
				Global.IsSetKey = false;
				isLeftKey = false;
			}
		} else if (isRightKey) {
			if (Gdx.input.isKeyJustPressed(Input.Keys.ANY_KEY) || Gdx.input.isButtonJustPressed(Input.Buttons.LEFT)
					|| Gdx.input.isButtonJustPressed(Input.Buttons.MIDDLE) || Gdx.input.isButtonJustPressed(Input.Buttons.RIGHT)) {
				Agent.GameSettings.putInteger("right_key", Global.KeycodeSet);
				Agent.GameSettings.flush();
				Uinput.LoadDefaultInputs();
				if (!Global.SetVolumeToZero)
					changeKey.play(2f);
				Global.IsSetKey = false;
				isRightKey = false;
			}
		} else if (isUpKey) {
			if (Gdx.input.isKeyJustPressed(Input.Keys.ANY_KEY) || Gdx.input.isButtonJustPressed(Input.Buttons.LEFT)
					|| Gdx.input.isButtonJustPressed(Input.Buttons.MIDDLE) || Gdx.input.isButtonJustPressed(Input.Buttons.RIGHT)) {
				Agent.GameSettings.putInteger("up_key", Global.KeycodeSet);
				Agent.GameSettings.flush();
				Uinput.LoadDefaultInputs();
				if (!Global.SetVolumeToZero)
					changeKey.play(2f);
				Global.IsSetKey = false;
				isUpKey = false;
			}
		} else if (isDownKey) {
			if (Gdx.input.isKeyJustPressed(Input.Keys.ANY_KEY) || Gdx.input.isButtonJustPressed(Input.Buttons.LEFT)
					|| Gdx.input.isButtonJustPressed(Input.Buttons.MIDDLE) || Gdx.input.isButtonJustPressed(Input.Buttons.RIGHT)) {
				Agent.GameSettings.putInteger("down_key", Global.KeycodeSet);
				Agent.GameSettings.flush();
				Uinput.LoadDefaultInputs();
				if (!Global.SetVolumeToZero)
					changeKey.play(2f);
				Global.IsSetKey = false;
				isDownKey = false;
			}
		} else if (isFireKey) {
			if (Gdx.input.isKeyJustPressed(Input.Keys.ANY_KEY) || Gdx.input.isButtonJustPressed(Input.Buttons.LEFT)
					|| Gdx.input.isButtonJustPressed(Input.Buttons.MIDDLE) || Gdx.input.isButtonJustPressed(Input.Buttons.RIGHT)) {
				Agent.GameSettings.putInteger("fire_key", Global.KeycodeSet);
				Agent.GameSettings.flush();
				Uinput.LoadDefaultInputs();
				if (!Global.SetVolumeToZero)
					changeKey.play(2f);
				Global.IsSetKey = false;
				isFireKey = false;
			}
		} else if (isJumpKey) {
			if (Gdx.input.isKeyJustPressed(Input.Keys.ANY_KEY) || Gdx.input.isButtonJustPressed(Input.Buttons.LEFT)
					|| Gdx.input.isButtonJustPressed(Input.Buttons.MIDDLE) || Gdx.input.isButtonJustPressed(Input.Buttons.RIGHT)) {
				Agent.GameSettings.putInteger("jump_key", Global.KeycodeSet);
				Agent.GameSettings.flush();
				Uinput.LoadDefaultInputs();
				if (!Global.SetVolumeToZero)
					changeKey.play(2f);
				Global.IsSetKey = false;
				isJumpKey = false;
			}
		} else if (isInventoryKey) {
			if (Gdx.input.isKeyJustPressed(Input.Keys.ANY_KEY) || Gdx.input.isButtonJustPressed(Input.Buttons.LEFT)
					|| Gdx.input.isButtonJustPressed(Input.Buttons.MIDDLE) || Gdx.input.isButtonJustPressed(Input.Buttons.RIGHT)) {
				Agent.GameSettings.putInteger("inventory_key", Global.KeycodeSet);
				Agent.GameSettings.flush();
				Uinput.LoadDefaultInputs();
				if (!Global.SetVolumeToZero)
					changeKey.play(2f);
				Global.IsSetKey = false;
				isInventoryKey = false;
			}
		} else if (isCrouchKey) {
			if (Gdx.input.isKeyJustPressed(Input.Keys.ANY_KEY) || Gdx.input.isButtonJustPressed(Input.Buttons.LEFT)
					|| Gdx.input.isButtonJustPressed(Input.Buttons.MIDDLE) || Gdx.input.isButtonJustPressed(Input.Buttons.RIGHT)) {
				Agent.GameSettings.putInteger("crouch_key", Global.KeycodeSet);
				Agent.GameSettings.flush();
				Uinput.LoadDefaultInputs();
				if (!Global.SetVolumeToZero)
					changeKey.play(2f);
				Global.IsSetKey = false;
				isCrouchKey = false;
			}
		} else if (isSprintKey) {
			if (Gdx.input.isKeyJustPressed(Input.Keys.ANY_KEY) || Gdx.input.isButtonJustPressed(Input.Buttons.LEFT)
					|| Gdx.input.isButtonJustPressed(Input.Buttons.MIDDLE) || Gdx.input.isButtonJustPressed(Input.Buttons.RIGHT)) {
				Agent.GameSettings.putInteger("sprint_key", Global.KeycodeSet);
				Agent.GameSettings.flush();
				Uinput.LoadDefaultInputs();
				if (!Global.SetVolumeToZero)
					changeKey.play(2f);
				Global.IsSetKey = false;
				isSprintKey = false;
			}
		}
		if (Global.IsSetKey && Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE)) {
			isLeftKey = false;
			isRightKey = false;
			isUpKey = false;
			isDownKey = false;
			isFireKey = false;
			isJumpKey = false;
			isInventoryKey = false;
			isCrouchKey = false;
			isSprintKey = false;
		} else if (IsSwitchingToKeyBindings) {
			IsSwitchingToKeyBindings = false;
			rect.y = (Gdx.graphics.getHeight() - 400f - _ppOffset);
		} else if (Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE)) {
			rect.y = (Gdx.graphics.getHeight() - 200f - _ppOffset);
		}
	}

	public void MoveRight(float speed, boolean isColl, float dt) {
		if (isColl)
			rect.x += 0;
		else
			rect.x += 0;// was speed. trying without * dt
	}

	public void MoveLeft(float speed, boolean isColl, float dt) {
		// test this:
		if (isColl)
			rect.x -= 0;
		else
			rect.x -= 0;// was speed
	}

	public void MoveUp(float speed, boolean isColl, float dt) {
		if (isColl)
			rect.y += 0;
		else
			rect.y += speed;
		// this is after the move. See if it's too far, if so adjust.
		if (Global.IsKeyBindings && rect.y > (Gdx.graphics.getHeight() - 200f - _ppOffset))
			rect.y = (Gdx.graphics.getHeight() - 650f - _ppOffset);
		else if (rect.y > (Gdx.graphics.getHeight() - 200f - _ppOffset))
			rect.y = (Gdx.graphics.getHeight() - 500f - _ppOffset);
	}

	public void MoveDown(float speed, boolean isColl, float dt) {
		if (isColl)
			rect.y -= 0;
		else
			rect.y -= speed;
		// this is after the move. See if it's too far, if so adjust.
		if (Global.IsKeyBindings && rect.y < (Gdx.graphics.getHeight() - 650f - _ppOffset))
			rect.y = (Gdx.graphics.getHeight() - 200f - _ppOffset);
		else if (!Global.IsKeyBindings && rect.y < (Gdx.graphics.getHeight() - 500f - _ppOffset))
			rect.y = (Gdx.graphics.getHeight() - 200f - _ppOffset);
	}

	public void RenderEntirePauseMenu(float dt, Agent game, BitmapFont font, Music rainMusic, OrthographicCamera camera) {
		// the timer needs to run before you set it.
		if (fadeTimer <= .2f)
			dark = true;
		else if (fadeTimer >= 1)
			dark = false;
		if (dark)
			fadeTimer += .02f;
		else
			fadeTimer -= .02f;
		font.setColor(3f, 1f, 3f, fadeTimer);
		font.draw(game.batch, "Game is paused", Gdx.graphics.getWidth() / 2 - 100, Gdx.graphics.getHeight() * .85f);
		if (Global.IsKeyBindings) {
			if (Global.IsSetKey) {
				font.draw(game.batch, "Please Press Any Key To Set Key", Gdx.graphics.getWidth() - 950f, Gdx.graphics.getHeight() - 200f);
				font.draw(game.batch, ":-)", Gdx.graphics.getWidth() - 350f, Gdx.graphics.getHeight() - 250f);
			} else {
				if (UsefulMethods.IsMouseInsideRectangle(saveGameRect, camera))
					font.setColor(fadeTimer, 1f, .5f, .5f);// testing when implemented, set it back to 1f for the alpha.
				else if (rect.y == (Gdx.graphics.getHeight() - 200f - _ppOffset))
					font.setColor(fadeTimer, fadeTimer, 1f, 1f);
				else
					font.setColor(1f, 1f, 1f, 1f);
				font.draw(game.batch, "Left", Gdx.graphics.getWidth() / 2 - _osMenuTextX, Gdx.graphics.getHeight() - 200f);
				font.draw(game.batch, "" + Input.Keys.toString(Uinput.Left()), Gdx.graphics.getWidth() - 750f, Gdx.graphics.getHeight() - 200f);
				if (UsefulMethods.IsMouseInsideRectangle(loadGameRect, camera))
					font.setColor(fadeTimer, 1f, .5f, .5f);// testing when implemented, set it back to 1f for the alpha.
				else if (rect.y == (Gdx.graphics.getHeight() - 250f - _ppOffset))
					font.setColor(fadeTimer, fadeTimer, 1f, 1f);
				else
					font.setColor(1f, 1f, 1f, 1f);
				font.draw(game.batch, "Right", Gdx.graphics.getWidth() / 2 - _osMenuTextX, Gdx.graphics.getHeight() - 250f);
				font.draw(game.batch, "" + Input.Keys.toString(Uinput.Right()), Gdx.graphics.getWidth() - 750f, Gdx.graphics.getHeight() - 250f);
				if (UsefulMethods.IsMouseInsideRectangle(muteSoundRect, camera))
					font.setColor(fadeTimer, 1f, .5f, .5f);// testing when implemented, set it back to 1f for the alpha.
				else if (rect.y == (Gdx.graphics.getHeight() - 300f - _ppOffset))
					font.setColor(fadeTimer, fadeTimer, 1f, 1f);
				else
					font.setColor(1f, 1f, 1f, 1f);
				font.draw(game.batch, "Up", Gdx.graphics.getWidth() / 2 - _osMenuTextX, Gdx.graphics.getHeight() - 300f);
				font.draw(game.batch, "" + Input.Keys.toString(Uinput.Up()), Gdx.graphics.getWidth() - 750f, Gdx.graphics.getHeight() - 300f);
				if (UsefulMethods.IsMouseInsideRectangle(muteMusicRect, camera))
					font.setColor(fadeTimer, 1f, .5f, .5f);// testing when implemented, set it back to 1f for the alpha.
				else if (rect.y == (Gdx.graphics.getHeight() - 350f - _ppOffset))
					font.setColor(fadeTimer, fadeTimer, 1f, 1f);
				else
					font.setColor(1f, 1f, 1f, 1f);
				font.draw(game.batch, "Down", Gdx.graphics.getWidth() / 2 - _osMenuTextX, Gdx.graphics.getHeight() - 350f);
				font.draw(game.batch, "" + Input.Keys.toString(Uinput.Down()), Gdx.graphics.getWidth() - 750f, Gdx.graphics.getHeight() - 350f);
				if (UsefulMethods.IsMouseInsideRectangle(keyBindingsRect, camera))
					font.setColor(fadeTimer, 1f, .5f, .5f);// testing when implemented, set it back to 1f for the alpha.
				else if (rect.y == (Gdx.graphics.getHeight() - 400f - _ppOffset))
					font.setColor(fadeTimer, fadeTimer, 1f, 1f);
				else
					font.setColor(1f, 1f, 1f, 1f);
				font.draw(game.batch, "Fire", Gdx.graphics.getWidth() / 2 - _osMenuTextX, Gdx.graphics.getHeight() - 400f);
				String fireText = "";
				if (Uinput.Fire() == 0)
					fireText = "mouse button left";
				else
					fireText = Input.Keys.toString(Uinput.Fire());
				font.draw(game.batch, "" + fireText, Gdx.graphics.getWidth() / 2 - _osMenuTextX + 200f, Gdx.graphics.getHeight() - 400f);
				if (UsefulMethods.IsMouseInsideRectangle(backRect, camera))
					font.setColor(fadeTimer, 1f, .5f, .5f);// testing when implemented, set it back to 1f for the alpha.
				else if (rect.y == (Gdx.graphics.getHeight() - 450f - _ppOffset))
					font.setColor(fadeTimer, fadeTimer, 1f, 1f);
				else
					font.setColor(1f, 1f, 1f, 1f);
				font.draw(game.batch, "Jump", Gdx.graphics.getWidth() / 2 - _osMenuTextX, Gdx.graphics.getHeight() - 450f);
				font.draw(game.batch, "" + Input.Keys.toString(Uinput.Jump()), Gdx.graphics.getWidth() / 2 - _osMenuTextX + 200f,
						Gdx.graphics.getHeight() - 450f);
				if (UsefulMethods.IsMouseInsideRectangle(exitGameRect, camera))
					font.setColor(fadeTimer, 1f, .5f, .5f);// testing when implemented, set it back to 1f for the alpha.
				else if (rect.y == (Gdx.graphics.getHeight() - 500f - _ppOffset))
					font.setColor(fadeTimer, fadeTimer, 1f, 1f);
				else
					font.setColor(1f, 1f, 1f, 1f);
				font.draw(game.batch, "Reload", Gdx.graphics.getWidth() / 2 - _osMenuTextX, Gdx.graphics.getHeight() - 500f);
				font.draw(game.batch, "" + Input.Keys.toString(Uinput.Inventory()), Gdx.graphics.getWidth() / 2 - _osMenuTextX + 200f,
						Gdx.graphics.getHeight() - 500f);
				if (UsefulMethods.IsMouseInsideRectangle(crouchRect, camera))
					font.setColor(fadeTimer, 1f, .5f, .5f);// testing when implemented, set it back to 1f for the alpha.
				else if (rect.y == (Gdx.graphics.getHeight() - 550f - _ppOffset))
					font.setColor(fadeTimer, fadeTimer, 1f, 1f);
				else
					font.setColor(1f, 1f, 1f, 1f);
				font.draw(game.batch, "Crouch", Gdx.graphics.getWidth() / 2 - _osMenuTextX, Gdx.graphics.getHeight() - 550f);
				font.draw(game.batch, "" + Input.Keys.toString(Uinput.Crouch()), Gdx.graphics.getWidth() / 2 - _osMenuTextX + 200f,
						Gdx.graphics.getHeight() - 550f);
				if (UsefulMethods.IsMouseInsideRectangle(sprintRect, camera))
					font.setColor(fadeTimer, 1f, .5f, .5f);// testing when implemented, set it back to 1f for the alpha.
				else if (rect.y == (Gdx.graphics.getHeight() - 600f - _ppOffset))
					font.setColor(fadeTimer, fadeTimer, 1f, 1f);
				else
					font.setColor(1f, 1f, 1f, 1f);
				font.draw(game.batch, "Sprint", Gdx.graphics.getWidth() / 2 - _osMenuTextX, Gdx.graphics.getHeight() - 600f);
				font.draw(game.batch, "" + Input.Keys.toString(Uinput.Sprint()), Gdx.graphics.getWidth() / 2 - _osMenuTextX + 200f,
						Gdx.graphics.getHeight() - 600f);
				if (UsefulMethods.IsMouseInsideRectangle(keyBindingsBackRect, camera))
					font.setColor(fadeTimer, 1f, .5f, .5f);// testing when implemented, set it back to 1f for the alpha.
				else if (rect.y == (Gdx.graphics.getHeight() - 650f - _ppOffset))
					font.setColor(fadeTimer, fadeTimer, 1f, 1f);
				else
					font.setColor(1f, 1f, 1f, 1f);
				font.draw(game.batch, "Back", Gdx.graphics.getWidth() / 2 - _osMenuTextX, Gdx.graphics.getHeight() - 650f);
				font.draw(game.batch, "ppsst, agent, go back to the pause screen", Gdx.graphics.getWidth() / 2 - _osMenuTextX + 200f,
						Gdx.graphics.getHeight() - 650f);
			}
		} else {
			font.setColor(3f, 1f, 3f, fadeTimer);
			font.draw(game.batch, "Game is paused", Gdx.graphics.getWidth() / 2 - 100, Gdx.graphics.getHeight() * .85f);
			if (UsefulMethods.IsMouseInsideRectangle(saveGameRect, camera))
				font.setColor(fadeTimer, 1f, .5f, .5f);// testing when implemented, set it back to 1f for the alpha.
			else if (rect.y == (Gdx.graphics.getHeight() - 200f - _ppOffset))
				font.setColor(fadeTimer, fadeTimer, 1f, .5f);// testing when implemented, set it back to 1f for the alpha.
			else
				font.setColor(.5f, .5f, .5f, 1f);// testing when implemented, set it back to 1f for each.
			font.draw(game.batch, "Save Game", Gdx.graphics.getWidth() / 2 - _osMenuTextX, Gdx.graphics.getHeight() - 200f);
			if (UsefulMethods.IsMouseInsideRectangle(loadGameRect, camera))
				font.setColor(fadeTimer, 1f, .5f, .5f);// testing when implemented, set it back to 1f for the alpha.
			else if (rect.y == (Gdx.graphics.getHeight() - 250f - _ppOffset))
				font.setColor(fadeTimer, fadeTimer, 1f, .5f);// testing when implemented, set it back to 1f for the alpha.
			else
				font.setColor(.5f, .5f, .5f, 1f);// testing when implemented, set it back to 1f for each.
			font.draw(game.batch, "Load Game", Gdx.graphics.getWidth() / 2 - _osMenuTextX, Gdx.graphics.getHeight() - 250f);
			if (UsefulMethods.IsMouseInsideRectangle(muteSoundRect, camera))
				font.setColor(fadeTimer, 1f, .5f, 1f);
			else if (rect.y == (Gdx.graphics.getHeight() - 300f - _ppOffset))
				font.setColor(fadeTimer, fadeTimer, 1f, 1f);
			else
				font.setColor(1f, 1f, 1f, 1f);
			font.draw(game.batch, "Mute Sound      (shhh)", Gdx.graphics.getWidth() / 2 - _osMenuTextX, Gdx.graphics.getHeight() - 300f);
			if (Global.SetVolumeToZero) {
				font.draw(game.batch, "[X]", Gdx.graphics.getWidth() / 2 - _osMenuTextX + 200f, Gdx.graphics.getHeight() - 300f);
			} else {
				font.draw(game.batch, "[ ]", Gdx.graphics.getWidth() / 2 - _osMenuTextX + 200f, Gdx.graphics.getHeight() - 300f);
			}
			if (UsefulMethods.IsMouseInsideRectangle(muteMusicRect, camera))
				font.setColor(fadeTimer, 1f, .5f, 1f);
			else if (rect.y == (Gdx.graphics.getHeight() - 350f - _ppOffset))
				font.setColor(fadeTimer, fadeTimer, 1f, 1f);
			else
				font.setColor(1f, 1f, 1f, 1f);
			font.draw(game.batch, "Mute Music      (shhh)", Gdx.graphics.getWidth() / 2 - _osMenuTextX, Gdx.graphics.getHeight() - 350f);
			if (Global.IsMusicPaused) {
				rainMusic.pause();
				font.draw(game.batch, "[X]", Gdx.graphics.getWidth() / 2 - _osMenuTextX + 200f, Gdx.graphics.getHeight() - 350f);
			} else {
				rainMusic.play();
				font.draw(game.batch, "[ ]", Gdx.graphics.getWidth() / 2 - _osMenuTextX + 200f, Gdx.graphics.getHeight() - 350f);
			}
			if (UsefulMethods.IsMouseInsideRectangle(keyBindingsRect, camera))
				font.setColor(fadeTimer, 1f, .5f, 1f);
			else if (rect.y == (Gdx.graphics.getHeight() - 400f - _ppOffset))
				font.setColor(fadeTimer, fadeTimer, 1f, 1f);
			else
				font.setColor(1f, 1f, 1f, 1f);
			font.draw(game.batch, "Key Bindings", Gdx.graphics.getWidth() / 2 - _osMenuTextX, Gdx.graphics.getHeight() - 400f);
			if (UsefulMethods.IsMouseInsideRectangle(backRect, camera))
				font.setColor(fadeTimer, 1f, .5f, 1f);
			else if (rect.y == (Gdx.graphics.getHeight() - 450f - _ppOffset))
				font.setColor(fadeTimer, fadeTimer, 1f, 1f);
			else
				font.setColor(1f, 1f, 1f, 1f);
			font.draw(game.batch, "Back", Gdx.graphics.getWidth() / 2 - _osMenuTextX, Gdx.graphics.getHeight() - 450f);
			if (UsefulMethods.IsMouseInsideRectangle(exitGameRect, camera))
				font.setColor(fadeTimer, 1f, .5f, 1f);
			else if (rect.y == (Gdx.graphics.getHeight() - 500f - _ppOffset))
				font.setColor(fadeTimer, fadeTimer, 1f, 1f);
			else
				font.setColor(1f, 1f, 1f, 1f);
			font.draw(game.batch, "eek! too scary. Close Game! //==:::=- - - - ><>  :O", Gdx.graphics.getWidth() / 2 - _osMenuTextX,
					Gdx.graphics.getHeight() - 500f);
		}
		// the pause person actor should be able to be used now to move up and down the menu and navigate the menu. Or if mouse interaction is fine, use
		// that.
		game.batch.setColor(color);
		game.batch.draw(getFrame(dt, camera), rect.x + fadeTimer, rect.y);
		game.batch.end();

	}
}
