require("ISUI/ISPanelJoypad")

TABAS_BathTimeEntryPanel = ISPanelJoypad:derive("TABAS_BathTimeEntryPanel")

local TABAS_Utils = require("TABAS_Utils")
local TABAS_Panel = require("UI/TABAS_PanelUtils")
local BTO = require("BathTowelsOverhaulUtil")

local CONST = require("UI/TABAS_PanelConst")
local FONT_HGT_SMALL = CONST.SCALE.HGT_SMALL
local BORDER_SPACING = CONST.SCALE.BORDER_SPACING
local HGT_BUTTON = CONST.SCALE.HGT_BUTTON

function TABAS_BathTimeEntryPanel:initialise()
    ISPanelJoypad.initialise(self)
end

function TABAS_BathTimeEntryPanel:createChildren()
	local btnScale = self.btnScale
	local x = BORDER_SPACING
	local y = FONT_HGT_SMALL + BORDER_SPACING*2
	local toggleY = self.btnScale + FONT_HGT_SMALL*1.2 + BORDER_SPACING*2
	local toggleH = FONT_HGT_SMALL * 1.2
	self.buttons = {}

	self.btnInfo = TABAS_Panel.addButton(BORDER_SPACING, BORDER_SPACING, FONT_HGT_SMALL, FONT_HGT_SMALL, self.tex_infoIcon, nil, getText("IGUI_TABAS_EntryConfigInfo"), self, nil, false)
	self.btnInfo.enable = false

	-- make off
	self.btnMakeOff = TABAS_Panel.addButton(x, y, btnScale, btnScale, self.tex_makeoff, nil, "", self, self.onClick, false)
	self.btnMakeOff.tooltipLabel = getText("UI_TABAS_WashOffMakeup")
	self.btnMakeOff.internal = "MAKEOFF"
	table.insert(self.buttons, self.btnMakeOff)

	self.tglMakeOff = ISWidgetAutoToggle:new(x, toggleY, btnScale, toggleH, false, self, self.onMakeOffToggled)
	self.tglMakeOff:initialise()
	self.tglMakeOff.value = self.modOptions:getOption("WashOffMakeup"):getValue()
	self:addChild(self.tglMakeOff)

	x = x + btnScale + BORDER_SPACING*2
	-- auto cloth change
	self.btnAutoCC = TABAS_Panel.addButton(x, y, btnScale, btnScale, self.tex_autoCC, nil, "", self, self.onClick, false)
	self.btnAutoCC.internal = "ACC"
	self.btnAutoCC.tooltipLabel = getText("UI_TABAS_AutoClothesChange")
	table.insert(self.buttons, self.btnAutoCC)

	self.tglAutoCC = ISWidgetAutoToggle:new(x, toggleY, btnScale, toggleH, false, self, self.onAutoCCToggled)
	self.tglAutoCC:initialise()
	self.tglAutoCC.value = self.modOptions:getOption("AutoClothesChange"):getValue()
	self:addChild(self.tglAutoCC)

	x = x + btnScale + BORDER_SPACING*2

	-- bath towel drop box
    self.bathtowelDropBox = ISItemDropBox:new (x, y, btnScale, btnScale, true, self, self.addItem, self.removeItem, self.verifyItem, nil )
    self.bathtowelDropBox.allowDropAlways = true
    self.bathtowelDropBox.onMouseDown = TABAS_BathTimeEntryPanel.clickedDropBox
    self.bathtowelDropBox:setToolTip(true, getText("IGUI_TABAS_BathTowelDropBoxTooltip"))
    self.bathtowelDropBox.player = self.playerObj
    self.bathtowelDropBox:initialise()
    self.bathtowelDropBox.background = false
    -- self.bathtowelDropBox.doHighlight = false
    self.bathtowelDropBox.doBackDropTex = true
    self.bathtowelDropBox.backgroundColorHL = {r=0, g=0, b=0, a=0}
    self.bathtowelDropBox.borderColorHL = {r=0, g=0, b=0, a=0}
    self.bathtowelDropBox:setBackDropTex(self.tex_towel, 0.8, 0.2,0.2,0.2)
    self.bathtowelDropBox.toolTipTextItem = getText("Fluid_Dropbox_Remove")
    self:addChild(self.bathtowelDropBox)
    if getJoypadData(self.playerObj:getPlayerNum()) then
        self.bathtowelDropBoxJoypad = TABAS_Panel.addButton(x, y, btnScale, btnScale, nil, "", "", self, self.onClick, false)
        self.bathtowelDropBoxJoypad.internal = "DROPBOX"
		self.bathtowelDropBoxJoypad.tooltipLabel = getText("IGUI_TABAS_BathTowelDropBoxTooltip")
        self.bathtowelDropBoxJoypad.backgroundColor = {r=0, g=0, b=0, a=0}
		table.insert(self.buttons, self.bathtowelDropBoxJoypad)
	else
		table.insert(self.buttons, self.bathtowelDropBox)
    end

	-- auto dry
	self.tglAutoDry = ISWidgetAutoToggle:new(x, toggleY, btnScale, toggleH, false, self, self.onAutoDryToggled)
	self.tglAutoDry:initialise()
	self.tglAutoDry.value = self.modOptions:getOption("AfterBathingDrySelf"):getValue()
	self:addChild(self.tglAutoDry)

	if self.tglAutoDry.value then
		self:addItemAux(TABAS_Utils.getAvailableTowel(self.playerObj))
	end

	x = x + btnScale + BORDER_SPACING*2
	-- bathing time
	self.btnBathTime = TABAS_Panel.addButton(x, y, btnScale, btnScale, self.tex_bathingTime, nil, "", self, self.onClick, false)
	self.btnBathTime.tooltipLabel = getText("IGUI_TABAS_BathTime")
	self.btnBathTime.enable = false
	table.insert(self.buttons, self.btnBathTime)

	self.bathTimeEntry = ISLabel:new(x + HGT_BUTTON/2 + FONT_HGT_SMALL/2, toggleY, FONT_HGT_SMALL, "30", 1, 1, 1, 1, UIFont.Small, true)
	self.bathTimeEntry:initialise()
	self.bathTimeEntry:instantiate()
	self.bathTimeEntry.center = true
	self:addChild(self.bathTimeEntry)
	
	x = x + btnScale + BORDER_SPACING
	-- + / - button
	self.btnPlus = TABAS_Panel.addButton(x, y + BORDER_SPACING, FONT_HGT_SMALL, FONT_HGT_SMALL, self.tex_plusIcon, nil, nil, self, self.onClick, true)
	self.btnPlus.internal = "TIMEPLUS"

	self.btnMinus = TABAS_Panel.addButton(x, toggleY, FONT_HGT_SMALL, FONT_HGT_SMALL, self.tex_minusIcon, nil, nil, self, self.onClick, true)
	self.btnMinus.internal = "TIMEMINUS"


	self:setWidth(self.btnMinus:getRight() + BORDER_SPACING)
	self:setHeight(self.btnMinus:getBottom() + BORDER_SPACING*2)
	self.btnInfo:setX(self:getWidth() - self.btnInfo:getWidth() - BORDER_SPACING)
    -- self:insertNewLineOfButtons(self.btnPlus, self.btnMinus)
end

function TABAS_BathTimeEntryPanel:onMakeOffToggled(_newState)
	self.tglMakeOff.value = _newState
end

function TABAS_BathTimeEntryPanel:onAutoCCToggled(_newState)
	self.tglAutoCC.value = _newState
end

function TABAS_BathTimeEntryPanel:onAutoDryToggled(_newState)
	if not _newState and self.bathtowelDropBox.storedItem ~= nil then
		self:removeItem()
	end
	self.tglAutoDry.option.value = _newState
end

function TABAS_BathTimeEntryPanel:update()
	-- option toggle update
	self.tglMakeOff.toggleState = self.tglMakeOff.value
	self.tglAutoCC.toggleState = self.tglAutoCC.value
	local towel = self.bathtowelDropBox.storedItem
	self.tglAutoDry.toggleState = towel ~= nil
	self:updateTooltips()
	if BTO then
		self.validTowel = towel and towel:getWetness() < 25
	else
		self.validTowel = towel ~= nil
	end
	if self.bathtowelDropBoxJoypad then
		if towel then
			local icon = towel:getIcon()
			local size = self.bathtowelDropBoxJoypad:getWidth() -4
			self.bathtowelDropBoxJoypad:setImage(icon)
			self.bathtowelDropBoxJoypad:forceImageSize(size, size)
		else
			self.bathtowelDropBoxJoypad:setImage(nil)
		end
	end
end

function TABAS_BathTimeEntryPanel:updateTooltips()
	local value = self.tglMakeOff.toggleState and ": ON" or ": OFF"
	self.btnMakeOff:setTooltip(self.btnMakeOff.tooltipLabel .. value)
	value = self.tglAutoCC.toggleState and ": ON" or ": OFF"
	self.btnAutoCC:setTooltip(self.btnAutoCC.tooltipLabel ..  value)
	self.btnBathTime:setTooltip(self.btnBathTime.tooltipLabel .. ": " .. self.bathTimeEntry:getName() .. " " .. getText("IGUI_Gametime_minutes"))
	if self.bathtowelDropBoxJoypad then
		local bTooltip = self.bathtowelDropBoxJoypad.joypadFocused or self.bathtowelDropBoxJoypad:isMouseOver()
		local text
		if bTooltip ~= self.bathtowelDropBoxJoypad.doTooltip then
			self.bathtowelDropBoxJoypad.doTooltip = bTooltip
			text = bTooltip and self.bathtowelDropBoxJoypad.tooltipLabel or nil
			self.bathtowelDropBoxJoypad:setTooltip(text)
		end
	end
end

function TABAS_BathTimeEntryPanel:prerender()
    ISPanelJoypad.prerender(self)
	self:drawText(self.title, BORDER_SPACING, BORDER_SPACING, self.labelColor.r, self.labelColor.g, self.labelColor.b, self.labelColor.a, UIFont.Small)

	-- button backgrounds
	local btnBGColor = {r=0.2, g=0.2, b=0.2, a=1}
	local backgroundColorMouseOver = {r=0.3, g=0.3, b=0.3, a=1.0}
	for i=1, #self.buttons do
		local btn = self.buttons[i]
		if btn.isButton then
			btn.fade:setFadeIn((btn.mouseOver and btn:isMouseOver()) and btn.enable or btn.joypadFocused or false)
		elseif btn.mouseOverState then -- for ISItemDropBox
			if btn.fade == nil then
				btn.fade = UITransition.new()
			end
			btn.fade:setFadeIn(btn.mouseOverState > 0 or btn.isLocked or btn.joypadFocused or false)
		end
		btn.fade:update()
		local f = btn.fade:fraction()
		local fill = {r=0.4, g=0.4, b=0.4, a=1}
		if btn.pressed then
			btn.backgroundColorPressed = btn.backgroundColorPressed or {}
			btn.backgroundColorPressed.r = backgroundColorMouseOver.r * 0.5
			btn.backgroundColorPressed.g = backgroundColorMouseOver.g * 0.5
			btn.backgroundColorPressed.b = backgroundColorMouseOver.b * 0.5
			btn.backgroundColorPressed.a = backgroundColorMouseOver.a
			fill = btn.backgroundColorPressed
		elseif btn.mouseOverState and btn.mouseOverState > 1 then
			fill = backgroundColorMouseOver
		end
		local c = {
			fill.a * f + btnBGColor.a * (1 - f),
			fill.r * f + btnBGColor.r * (1 - f),
			fill.g * f + btnBGColor.g * (1 - f),
			fill.b * f + btnBGColor.b * (1 - f)
		}
		self:drawTextureScaled(self.bg_button, btn:getX()-2, btn:getY()-2, self.btnScale+4, self.btnScale+4, c[1], c[2], c[3], c[4])
	end
	-- invalid towel border
	if self.bathtowelDropBox.storedItem and not self.validTowel then
		self:drawRectBorder(self.bathtowelDropBox:getX()-2, self.bathtowelDropBox:getY()-2, self.btnScale+4, self.btnScale+4, 1, 1, 0, 0)
	end
	-- time label background
	self:drawTextureScaled(self.bg_label, self.bathTimeEntry:getX()-HGT_BUTTON*0.8, self.bathTimeEntry:getY()+FONT_HGT_SMALL*0.2, self.btnScale-HGT_BUTTON*0.2, FONT_HGT_SMALL*0.8, 0.4,0.2,0.2,0.2)
end


function TABAS_BathTimeEntryPanel:render()
    ISPanelJoypad.render(self)
	self:renderJoypadFocus()
end


function TABAS_BathTimeEntryPanel:onClick(_btn)
	if _btn.internal == "MAKEOFF" then
		self.tglMakeOff.toggleState = not self.tglMakeOff.toggleState
		return self:onMakeOffToggled(self.tglMakeOff.toggleState)
	elseif _btn.internal == "ACC" then
		self.tglAutoCC.toggleState = not self.tglAutoCC.toggleState
		return self:onAutoCCToggled(self.tglAutoCC.toggleState)
	elseif _btn.internal == "DROPBOX" then
		return self:setOrClearItem()
	end

	local currentTime = tonumber(self.bathTimeEntry:getName())
	if _btn.internal == "TIMEPLUS" and currentTime < 120 then
		currentTime = currentTime + 10
	elseif _btn.internal == "TIMEMINUS" and currentTime > 10 then
		currentTime = currentTime - 10
	end
	self.bathTimeEntry:setName(tostring(currentTime))
end

function TABAS_BathTimeEntryPanel:getEntryTime()
	return tonumber(self.bathTimeEntry:getName())
end

function TABAS_BathTimeEntryPanel:setOrClearItem()
    if not self.bathtowelDropBox:isVisible() then return end
    if self.bathtowelDropBox.boxOccupied then
        self.bathtowelDropBox:onRightMouseUp(0, 0) -- remove item
    else
        self.bathtowelDropBox:onMouseDown(0, 0) -- choose item via context menu
    end
end

local function predicateTowel(_item)
	if BTO then
		return _item and _item:hasTag("Wipeable") and not _item:isBroken()
	else
		return _item and _item:getType() == "BathTowel" and instanceof(_item, "DrainableComboItem")
	end
end

function TABAS_BathTimeEntryPanel:clickedDropBox(_x, _y)
    local self = self.parent
	local validItems
	if BTO then
		validItems = TABAS_Utils.getNearbyItems(self.playerObj, self.tfc_Base.square, 1, nil, "Wipeable", predicateTowel)
	else
		validItems = TABAS_Utils.getNearbyItems(self.playerObj, self.tfc_Base.square, 1, "BathTowel", nil)
	end
    if not validItems or validItems:isEmpty() then return end
    local box = self.bathtowelDropBox
    local playerNum = self.playerObj:getPlayerNum()
    local oldFocus = JoypadState.players[playerNum+1] and JoypadState.players[playerNum+1].focus or nil
    local x = box:getAbsoluteX() + box:getWidth()
    local y = box:getAbsoluteY() + box:getY()
    local context = ISContextMenu.get(playerNum, x, y)
	local item, name, option
    for i=1, validItems:size() do
		item = validItems:get(i-1)
		if item then
			name = item:getName()
			option = context:addOption(name, self.bathtowelDropBox, ISItemDropBox.onDropItem, item)
			if item:hasTag("Wipeable") then
				self.bathTowelTooltip(item, option)
			end
			option.iconTexture = item:getIcon()
		end
    end
    context:setAlwaysOnTop(true)
    if oldFocus then
        context.origin = oldFocus
        context.mouseOver = 1
        setJoypadFocus(playerNum, context)
    end
end

function TABAS_BathTimeEntryPanel:addItem(_items)
    local list = ArrayList.new()
    for i=1, #_items do
        local item = _items[i]
        if not list:contains(item) then
            list:add(item)
        end
    end
    if list:size() == 1 then
       self:addItemAux(_items[1])
       return
    end
    local playerNum = self.playerObj:getPlayerNum()
    local context = ISContextMenu.get(playerNum, self.bathtowelDropBox:getAbsoluteX()+16, self.bathtowelDropBox:getAbsoluteY()+16)
    list:clear()
    for i=1, #_items do
        local item = _items[i]
        if not list:contains(item) then
            local option = context:addOption(item:getName(), self, self.addItemAux, item)
            local icon = item:getIcon()
            option.iconTexture = icon
			if item:hasTag("Wipeable") and item:getWetness() < 25 then
				option.notAvailable = true
			end
            list:add(item)
        end
    end
    context.mouseOver = 1
end

function TABAS_BathTimeEntryPanel:addItemAux(_item)
	if not _item then return end
    self.bathtowelDropBox:setStoredItem( _item )
	self.bathtowelDropBox:setToolTip(_item:getTooltip())
end

function TABAS_BathTimeEntryPanel:removeItem()
    self.bathtowelDropBox:setStoredItem(nil)
end

function TABAS_BathTimeEntryPanel:verifyItem(_item)
	return predicateTowel(_item)
end

function TABAS_BathTimeEntryPanel.bathTowelTooltip(towel, option)
	local toolTip = TABAS_Panel.addItemTooltip()
    local labelCol = " <RGB:1,1,0.8> "
    local greenCol = " <RGB:0.5,1,0.5> "
    local yellowCol = " <RGB:1,1,0.5> "
    local redCol = " <RGB:1,0.5,0.5> "
    local whiteCol = " <RGB:1,1,1> "
    local text
    local textCol
    local valueText
    local towelWet = math.ceil(towel:getWetness() or 0)
    local towelDirt = math.ceil(towel:getDirtyness() or 0)
    local towelBlood = math.ceil(towel:getBloodLevel() or 0)
	local wipeBloodAndDirt = SandboxVars.BathTowelsOverhaul.WipesBloodAndDirt
	local showNumValue = PZAPI.ModOptions:getOptions("BathTowelsOverhaul"):getOption("DrySelfContextTooltip"):getValue() == 3
	local towelAbsorb = towel:getModData().Absorbency

	local stainsTooltip

	toolTip.maxLineWidth = 500
	local font = UIFont.Small
	local labelWidth = 0
	labelWidth = math.max(labelWidth, getTextManager():MeasureStringX(font, getText("IGUI_BathTowelsOverhaul_Absorbency") .. ": "))
	labelWidth = math.max(labelWidth, getTextManager():MeasureStringX(font, getText("IGUI_BathTowelsOverhaul_TowelWetness") .. ": "))
	labelWidth = math.max(labelWidth, getTextManager():MeasureStringX(font, getText("IGUI_BathTowelsOverhaul_BodyWetness") .. ": "))
	labelWidth = math.max(labelWidth, getTextManager():MeasureStringX(font, getText("IGUI_BathTowelsOverhaul_NotWetness")))
	-- towel status
	-- towelAbsorbency
	if showNumValue then
		valueText = towelAbsorb or "N"
	else
		if towelAbsorb <= 10 then
			valueText = getText("IGUI_BathTowelsOverhaul_NotGood")
		elseif towelAbsorb < 50 then
			valueText = getText("IGUI_BathTowelsOverhaul_Normal")
		elseif towelAbsorb >= 80 then
			valueText = getText("IGUI_BathTowelsOverhaul_Great")
		else
			valueText = getText("IGUI_BathTowelsOverhaul_Good")
		end
	end
	text = string.format("<LEFT> %s: <RIGHT> <SETX:%d> %s <LINE> ", getText("IGUI_BathTowelsOverhaul_Absorbency"), labelWidth, valueText)
	toolTip.description = toolTip.description .. labelCol .. text
	-- towelWet
	if towelWet < 5 then
		valueText = getText("IGUI_BathTowelsOverhaul_Dry")
		textCol = greenCol
	elseif towelWet < 15 then
		valueText = getText("IGUI_BathTowelsOverhaul_Slightly")
		textCol = whiteCol
	elseif towelWet < 40 then
		valueText = getText("IGUI_BathTowelsOverhaul_Moist")
		textCol = yellowCol
	elseif towelWet > 80 then
		valueText = getText("IGUI_BathTowelsOverhaul_Soaked")
		textCol = redCol
	else
		valueText = getText("IGUI_BathTowelsOverhaul_Wet")
		textCol = yellowCol
	end
	if showNumValue then
		valueText = towelWet
	end
	text = string.format("<LEFT> %s: <RIGHT> <SETX:%d> %s %s <LINE> ", getText("IGUI_StatsAndBody_Wetness"), labelWidth, textCol, valueText)
	toolTip.description = toolTip.description .. labelCol .. text


	if wipeBloodAndDirt then
		stainsTooltip = function(stainName, stain)
			if stain < 5 then
				valueText = getText("IGUI_BathTowelsOverhaul_Clean")
				textCol = greenCol
			elseif stain < 20 then
				valueText = getText("IGUI_BathTowelsOverhaul_Slightly")
				textCol = whiteCol
			elseif stain < 50 then
				valueText = getText("IGUI_BathTowelsOverhaul_Dirty")
				textCol = yellowCol
			elseif stain > 80 then
				valueText = getText("IGUI_BathTowelsOverhaul_Grubby")
				textCol = redCol
			else
				valueText = getText("IGUI_BathTowelsOverhaul_Filthy")
				textCol = yellowCol
			end
			if showNumValue then
				valueText = stain
			end
			text = string.format("<LEFT> %s: <RIGHT> <SETX:%d> %s %s <LINE> ", getText("IGUI_ClothingName_" .. stainName), labelWidth, textCol, valueText)
			toolTip.description = toolTip.description .. labelCol .. text
		end
		stainsTooltip("Bloody", towelBlood)
		stainsTooltip("Dirty", towelDirt)
	end
	option.toolTip = toolTip
	if towelWet > 25 then
		option.notAvailable = true
	end
end

function TABAS_BathTimeEntryPanel:getStoredItem()
	if self.validTowel then
		return self.bathtowelDropBox.storedItem
	end
end

function TABAS_BathTimeEntryPanel:onGainJoypadFocus(joypadData)
	ISPanelJoypad.onGainJoypadFocus(self, joypadData)
	self.joypadIndex = self.prevJoypadIndex or 1
    self.joypadIndexY = 1
	self.joypadButtons = {}
    self.joypadButtonsY = {}
	self:insertNewLineOfButtons(self.btnMakeOff, self.btnAutoCC, self.bathtowelDropBoxJoypad, self.btnBathTime, self.btnInfo)
    self:restoreJoypadFocus(joypadData)
	if not self.mainPanel then -- chache main UI
		self.mainPanel = joypadData.prevfocus
	end
end

function TABAS_BathTimeEntryPanel:onLoseJoypadFocus(joypadData)
    ISPanelJoypad.onLoseJoypadFocus(self, joypadData)
	self.prevJoypadIndex = self.joypadIndex
	self:clearJoypadFocus(joypadData)
end

function TABAS_BathTimeEntryPanel:onJoypadDown(button, joypadData)
    if button == Joypad.BButton then
        self.mainPanel:close()
        return
    end
    if button == Joypad.RBumper then
		self:setJoypadFocused(false, joypadData)
        setJoypadFocus(self.playerObj:getPlayerNum(), self.mainPanel)
		self:onLoseJoypadFocus(joypadData)
		return
    end
    ISPanelJoypad.onJoypadDown(self, button, joypadData)
end

function TABAS_BathTimeEntryPanel:onJoypadDirUp(joypadData)
	if self.btnBathTime.joypadFocused then
		self:onClick(self.btnPlus)
		getSoundManager():playUISound("UIActivateButton")
	end
end

function TABAS_BathTimeEntryPanel:onJoypadDirDown(joypadData)
	if self.btnBathTime.joypadFocused then
		self:onClick(self.btnMinus)
		getSoundManager():playUISound("UIActivateButton")
	end
end

function TABAS_BathTimeEntryPanel:new (x, y, playerObj)
	local btnScale = HGT_BUTTON * 1.55
    local width = HGT_BUTTON*3 + BORDER_SPACING*5 + btnScale

    local height = HGT_BUTTON*3 + btnScale + BORDER_SPACING*2
    local o = ISPanelJoypad:new(x, y, width, height)
    setmetatable(o, self)
    self.__index = self
    o.x = x
    o.y = y
	o.labelColor = CONST.COLOR.labelColor
	o.btnScale = btnScale
	o.title = getText("IGUI_TABAS_BathtubInfo_HowTakeBath")
	o.tex_makeoff = getTexture("media/ui/Icons/tabas_makeoff.png")
	o.tex_towel = getTexture("media/ui/Icons/tabas_bathtowel.png")
	o.tex_autoCC = getTexture("media/ui/Icons/tabas_autoCC.png")
	o.tex_autoDry = getTexture("media/ui/Icons/tabas_tubReheat.png")
	o.tex_bathingTime = getTexture("media/ui/Icons/tabas_bathingTime.png")
	o.tex_plusIcon = getTexture("media/ui/Entity/BTN_Plus_Icon_48x48.png")
	o.tex_minusIcon = getTexture("media/ui/Entity/BTN_Minus_Icon_48x48.png")
	o.tex_infoIcon = getTexture("media/ui/inventoryPanes/Button_Info.png")
	o.bg_button = CONST.TEXTURE.bg_button
	o.bg_label = CONST.TEXTURE.bg_label
	o.bg_label_L = CONST.TEXTURE.bg_label_L
	o.bg_label_R = CONST.TEXTURE.bg_label_R
    o.width = width
    o.height = height
	o.playerObj = playerObj
	o.towel = nil
	o.modOptions = PZAPI.ModOptions:getOptions("TakeABathAndShower")
	o.disableJoypadNavigation = true
	return o
end
