This commit is contained in:
Pao
2023-02-26 20:14:23 +01:00
parent a2e906b318
commit 6d2be51cd4
9 changed files with 329 additions and 317 deletions

View File

@@ -212,7 +212,7 @@ JCIO.CutLimb = function(partName, surgeonFactor, bandageTable, painkillerTable)
-- A check for is_cut shouldn't be necessary here since if we've got here we've already checked it out enough -- A check for isCut shouldn't be necessary here since if we've got here we've already checked it out enough
if limbsData[partName].isCut == false then if limbsData[partName].isCut == false then
limbsData[partName].isCut = true limbsData[partName].isCut = true
@@ -276,7 +276,7 @@ JCIO.CutLimb = function(partName, surgeonFactor, bandageTable, painkillerTable)
TocSetBloodOnAmputation(getPlayer(), adjacentBodyPart) TocSetBloodOnAmputation(getPlayer(), adjacentBodyPart)
if partName == "Left_Foot" or partName == "Right_Foot" then if partName == "Left_Foot" or partName == "Right_Foot" then
JCIOAnims.SetMissingFootAnimation(true) JCIO_Anims.SetMissingFootAnimation(true)
end end
end end

View File

@@ -1,70 +1,76 @@
-- RE DO ALL OVER THIS CRAP
local main_ui, desc_ui, confirm_ui, confirm_ui_mp if JCIO_UI == nil then
JCIO_UI = {}
end
local mainUI, descUI, confirmUI, confirmUIMP
------------------------- -------------------------
-- MP stuff? -- MP stuff
local function PrerenderFuncMP() local function PrerenderFuncMP()
local toSee = confirm_ui_mp local toSee = confirmUIMP
if confirm_ui_mp.responseReceive then if confirmUIMP.responseReceive then
if not confirm_ui_mp.responseCan then if not confirmUIMP.responseCan then
getPlayer():Say("I can't do that !") getPlayer():Say("I can't do that !")
confirm_ui_mp.responseReceive = false confirmUIMP.responseReceive = false
confirm_ui_mp:close() confirmUIMP:close()
return false; return false;
end end
-- Prerender basically hooks onto SendCommandToConfirmUI, dunno how but it does -- Prerender basically hooks onto SendCommandToConfirmUI, dunno how but it does
SendCommandToConfirmUIMP(confirm_ui_mp.responseAction, confirm_ui_mp.responseIsBitten, SendCommandToConfirmUIMP(confirmUIMP.responseAction, confirmUIMP.responseIsBitten,
confirm_ui_mp.responseUserName, confirm_ui_mp.responsePartName); confirmUIMP.responseUserName, confirmUIMP.responsePartName);
end end
end end
----------------------- -----------------------
-- Getters -- Getters
function GetConfirmUIMP() function GetConfirmUIMP()
return confirm_ui_mp; return confirmUIMP;
end end
------------------------------ ------------------------------
-- UI Visible stuff functions -- UI Visible stuff functions
local function GetImageName(part_name, limbs_data) local function GetImageName(partName, limbsData)
local name = "" local name = ""
local part_data = limbs_data[part_name] local part_data = limbsData[partName]
if part_data.is_cut and part_data.is_cicatrized and part_data.is_prosthesis_equipped then -- Cut and equip if part_data.isCut and part_data.isCicatrized and part_data.isProsthesisEquipped then -- Cut and equip
if part_name == "Right_Hand" or part_name == "Left_Hand" then if partName == "Right_Hand" or partName == "Left_Hand" then
name = "media/ui/TOC/" .. part_name .. "/Hook.png" name = "media/ui/TOC/" .. partName .. "/Hook.png"
else else
name = "media/ui/TOC/" .. part_name .. "/Prothesis.png" name = "media/ui/TOC/" .. partName .. "/Prothesis.png"
end end
elseif part_data.is_cut and part_data.is_cicatrized and not part_data.is_prosthesis_equipped and elseif part_data.isCut and part_data.isCicatrized and not part_data.isProsthesisEquipped and
part_data.is_amputation_shown then -- Cut and heal part_data.isAmputationShown then -- Cut and heal
name = "media/ui/TOC/" .. part_name .. "/Cut.png" name = "media/ui/TOC/" .. partName .. "/Cut.png"
elseif part_data.is_cut and not part_data.is_cicatrized and part_data.is_amputation_shown and elseif part_data.isCut and not part_data.isCicatrized and part_data.isAmputationShown and
not part_data.is_operated then -- Cut not heal not part_data.isOperated then -- Cut not heal
name = "media/ui/TOC/" .. part_name .. "/Bleed.png" name = "media/ui/TOC/" .. partName .. "/Bleed.png"
elseif part_data.is_cut and not part_data.is_cicatrized and part_data.is_amputation_shown and part_data.is_operated then -- Cut not heal elseif part_data.isCut and not part_data.isCicatrized and part_data.isAmputationShown and part_data.isOperated then -- Cut not heal
name = "media/ui/TOC/" .. part_name .. "/Operate.png" name = "media/ui/TOC/" .. partName .. "/Operate.png"
elseif part_data.is_cut and not part_data.is_amputation_shown then -- Empty (like hand if forearm cut) elseif part_data.isCut and not part_data.isAmputationShown then -- Empty (like hand if forearm cut)
name = "media/ui/TOC/Empty.png" name = "media/ui/TOC/Empty.png"
elseif not part_data.is_cut and elseif not part_data.isCut and
-- FIXME This doesn't work in MP on another player since we're trying to retrieve bodyDamage from another player -- FIXME This doesn't work in MP on another player since we're trying to retrieve bodyDamage from another player
getPlayer():getBodyDamage():getBodyPart(TocGetBodyPartFromPartName(part_name)):bitten() then -- Not cut but bitten getPlayer():getBodyDamage():getBodyPart(TocGetBodyPartFromPartName(partName)):bitten() then -- Not cut but bitten
name = "media/ui/TOC/" .. part_name .. "/Bite.png" name = "media/ui/TOC/" .. partName .. "/Bite.png"
else -- Not cut else -- Not cut
name = "media/ui/TOC/" .. part_name .. "/Base.png" name = "media/ui/TOC/" .. partName .. "/Base.png"
end end
-- If foreaerm equip, change hand -- If foreaerm equip, change hand
if part_name == "Right_Hand" and limbs_data["Right_LowerArm"].is_prosthesis_equipped then if partName == "Right_Hand" and limbsData["Right_LowerArm"].isProsthesisEquipped then
name = "media/ui/TOC/" .. part_name .. "/Hook.png" name = "media/ui/TOC/" .. partName .. "/Hook.png"
elseif part_name == "Left_Hand" and limbs_data["Left_LowerArm"].is_prosthesis_equipped then elseif partName == "Left_Hand" and limbsData["Left_LowerArm"].isProsthesisEquipped then
name = "media/ui/TOC/" .. part_name .. "/Hook.png" name = "media/ui/TOC/" .. partName .. "/Hook.png"
end end
return name return name
end end
@@ -72,29 +78,29 @@ end
------------------------------------------ ------------------------------------------
-- Check functions -- Check functions
local function IsProsthesisInstalled(part_data) local function IsProsthesisInstalled(partData)
return part_data.is_cut and part_data.is_cicatrized and part_data.is_prosthesis_equipped return partData.isCut and partData.isCicatrized and partData.isProsthesisEquipped
end end
local function CanProsthesisBeEquipped(part_data) local function CanProsthesisBeEquipped(partData)
return part_data.is_cut and part_data.is_cicatrized and not part_data.is_prosthesis_equipped and return partData.isCut and partData.isCicatrized and not partData.isProsthesisEquipped and
part_data.is_amputation_shown partData.isAmputationShown
end end
local function IsAmputatedLimbHealed(part_data) local function IsAmputatedLimbHealed(partData)
return part_data.is_cut and not part_data.is_cicatrized and part_data.is_amputation_shown return partData.isCut and not partData.isCicatrized and partData.isAmputationShown
end end
local function IsAmputatedLimbToBeVisible(part_data) local function IsAmputatedLimbToBeVisible(partData)
return part_data.is_cut and not part_data.is_amputation_shown return partData.isCut and not partData.isAmputationShown
end end
local function IsPartBitten(part_data, part_name) local function IsPartBitten(partData, partName)
return not part_data.is_cut and return not partData.isCut and
getPlayer():getBodyDamage():getBodyPart(TocGetBodyPartFromPartName(part_name)):bitten() getPlayer():getBodyDamage():getBodyPart(TocGetBodyPartFromPartName(partName)):bitten()
end end
local function FindMinMax(lv) local function FindMinMax(lv)
@@ -137,145 +143,145 @@ end
----------------------------------------- -----------------------------------------
-- Setup stuff with variables and shit -- Setup stuff with variables and shit
local function SetupTocMainUI(surgeon, patient, limbs_data) JCIO_UI.SetupMainUI = function(surgeon, patient, limbsData)
main_ui.surgeon = surgeon -- we shouldn't need an arg for this mainUI.surgeon = surgeon -- we shouldn't need an arg for this
main_ui.patient = patient mainUI.patient = patient
if limbs_data then if limbsData then
main_ui.limbs_data = limbs_data mainUI.limbs_data = limbsData
main_ui["b11"]:setPath(GetImageName("Right_UpperArm", limbs_data)) mainUI["b11"]:setPath(GetImageName("Right_UpperArm", limbsData))
main_ui["b12"]:setPath(GetImageName("Left_UpperArm", limbs_data)) mainUI["b12"]:setPath(GetImageName("Left_UpperArm", limbsData))
main_ui["b21"]:setPath(GetImageName("Right_LowerArm", limbs_data)) mainUI["b21"]:setPath(GetImageName("Right_LowerArm", limbsData))
main_ui["b22"]:setPath(GetImageName("Left_LowerArm", limbs_data)) mainUI["b22"]:setPath(GetImageName("Left_LowerArm", limbsData))
main_ui["b31"]:setPath(GetImageName("Right_Hand", limbs_data)) mainUI["b31"]:setPath(GetImageName("Right_Hand", limbsData))
main_ui["b32"]:setPath(GetImageName("Left_Hand", limbs_data)) mainUI["b32"]:setPath(GetImageName("Left_Hand", limbsData))
main_ui["b41"]:setPath(GetImageName("Right_Foot", limbs_data)) mainUI["b41"]:setPath(GetImageName("Right_Foot", limbsData))
main_ui["b42"]:setPath(GetImageName("Left_Foot", limbs_data)) mainUI["b42"]:setPath(GetImageName("Left_Foot", limbsData))
end end
end end
local function SetupTocDescUI(surgeon, patient, limbs_data, part_name) JCIO_UI.SetupDescUI = function(surgeon, patient, limbsData, partName)
desc_ui["textTitle"]:setText(getText("UI_ContextMenu_" .. part_name)) descUI["textTitle"]:setText(getText("UI_ContextMenu_" .. partName))
desc_ui.part_name = part_name descUI.part_name = partName
desc_ui.surgeon = surgeon descUI.surgeon = surgeon
desc_ui.patient = patient descUI.patient = patient
local part_data = limbs_data[part_name] local partData = limbsData[partName]
if IsProsthesisInstalled(part_data) then if IsProsthesisInstalled(partData) then
-- Limb cut with prosthesis -- Limb cut with prosthesis
desc_ui["status"]:setText("Prosthesis equipped") descUI["status"]:setText("Prosthesis equipped")
desc_ui["status"]:setColor(1, 0, 1, 0) descUI["status"]:setColor(1, 0, 1, 0)
desc_ui["b1"]:setText("Unequip") descUI["b1"]:setText("Unequip")
desc_ui["b1"]:addArg("option", "Unequip") descUI["b1"]:addArg("option", "Unequip")
desc_ui["b1"]:setVisible(true) descUI["b1"]:setVisible(true)
elseif CanProsthesisBeEquipped(part_data) then elseif CanProsthesisBeEquipped(partData) then
-- Limb cut but no prosthesis -- Limb cut but no prosthesis
desc_ui["status"]:setText("Amputated and healed") descUI["status"]:setText("Amputated and healed")
desc_ui["status"]:setColor(1, 0, 1, 0) descUI["status"]:setColor(1, 0, 1, 0)
-- Another check for UpperArm -- Another check for UpperArm
if part_name == "Right_UpperArm" or part_name == "Left_UpperArm" then if partName == "Right_UpperArm" or partName == "Left_UpperArm" then
desc_ui["b1"]:setVisible(false) descUI["b1"]:setVisible(false)
else else
desc_ui["b1"]:setText("Equip") descUI["b1"]:setText("Equip")
desc_ui["b1"]:addArg("option", "Equip") descUI["b1"]:addArg("option", "Equip")
desc_ui["b1"]:setVisible(true) descUI["b1"]:setVisible(true)
end end
-- Limb cut but still healing -- Limb cut but still healing
elseif IsAmputatedLimbHealed(part_data) then elseif IsAmputatedLimbHealed(partData) then
-- Limb cut and healed, no prosthesis equipped -- Limb cut and healed, no prosthesis equipped
if part_data.is_operated then if partData.isOperated then
desc_ui["b1"]:setVisible(false) -- no operate prompt descUI["b1"]:setVisible(false) -- no operate prompt
if part_data.cicatrization_time > 1000 then if partData.cicatrizationTime > 1000 then
desc_ui["status"]:setText("Still a long way to go") descUI["status"]:setText("Still a long way to go")
desc_ui["status"]:setColor(1, 0.8, 1, 0.2); descUI["status"]:setColor(1, 0.8, 1, 0.2);
elseif part_data.cicatrization_time > 500 then elseif partData.cicatrizationTime > 500 then
desc_ui["status"]:setText("Starting to get better") descUI["status"]:setText("Starting to get better")
desc_ui["status"]:setColor(1, 0.8, 1, 0.2) descUI["status"]:setColor(1, 0.8, 1, 0.2)
elseif part_data.cicatrization_time > 100 then elseif partData.cicatrizationTime > 100 then
desc_ui["status"]:setText("Almost cicatrized") descUI["status"]:setText("Almost cicatrized")
desc_ui["status"]:setColor(1, 0.8, 1, 0.2) descUI["status"]:setColor(1, 0.8, 1, 0.2)
end end
else else
-- Set the operate button -- Set the operate button
desc_ui["b1"]:setText("Operate") descUI["b1"]:setText("Operate")
desc_ui["b1"]:addArg("option", "Operate") descUI["b1"]:addArg("option", "Operate")
desc_ui["b1"]:setVisible(true) descUI["b1"]:setVisible(true)
if part_data.cicatrization_time > 1000 then if partData.cicatrizationTime > 1000 then
desc_ui["status"]:setText("It hurts so much...") descUI["status"]:setText("It hurts so much...")
desc_ui["status"]:setColor(1, 1, 0, 0) descUI["status"]:setColor(1, 1, 0, 0)
elseif part_data.cicatrization_time > 500 then elseif partData.cicatrizationTime > 500 then
desc_ui["status"]:setText("It still hurts a lot") descUI["status"]:setText("It still hurts a lot")
desc_ui["status"]:setColor(1, 0.8, 1, 0.2) descUI["status"]:setColor(1, 0.8, 1, 0.2)
elseif part_data.cicatrization_time > 500 then elseif partData.cicatrizationTime > 500 then
desc_ui["status"]:setText("I think it's almost over...") descUI["status"]:setText("I think it's almost over...")
desc_ui["status"]:setColor(1, 0.8, 1, 0.2) descUI["status"]:setColor(1, 0.8, 1, 0.2)
end end
end end
elseif IsAmputatedLimbToBeVisible(part_data) then elseif IsAmputatedLimbToBeVisible(partData) then
-- Limb cut and not visible (ex: hand after having amputated forearm) -- Limb cut and not visible (ex: hand after having amputated forearm)
desc_ui["status"]:setText("Nothing here") descUI["status"]:setText("Nothing here")
desc_ui["status"]:setColor(1, 1, 1, 1) descUI["status"]:setColor(1, 1, 1, 1)
desc_ui["b1"]:setVisible(false) descUI["b1"]:setVisible(false)
elseif CheckIfCanBeCut(part_name, limbs_data) then elseif CheckIfCanBeCut(partName, limbsData) then
-- Everything else -- Everything else
-- TODO add check for cuts and scratches -- TODO add check for cuts and scratches
desc_ui["status"]:setText("Not cut") descUI["status"]:setText("Not cut")
desc_ui["status"]:setColor(1, 1, 1, 1) descUI["status"]:setColor(1, 1, 1, 1)
if TocGetSawInInventory(surgeon) and not CheckIfProsthesisAlreadyInstalled(limbs_data, part_name) then if TocGetSawInInventory(surgeon) and not CheckIfProsthesisAlreadyInstalled(limbsData, partName) then
desc_ui["b1"]:setVisible(true) descUI["b1"]:setVisible(true)
desc_ui["b1"]:setText("Cut") descUI["b1"]:setText("Cut")
desc_ui["b1"]:addArg("option", "Cut") descUI["b1"]:addArg("option", "Cut")
elseif TocGetSawInInventory(surgeon) and CheckIfProsthesisAlreadyInstalled(limbs_data, part_name) then elseif TocGetSawInInventory(surgeon) and CheckIfProsthesisAlreadyInstalled(limbsData, partName) then
desc_ui["b1"]:setVisible(true) descUI["b1"]:setVisible(true)
desc_ui["b1"]:setText("Remove prosthesis before") descUI["b1"]:setText("Remove prosthesis before")
desc_ui["b1"]:addArg("option", "Nothing") descUI["b1"]:addArg("option", "Nothing")
else else
desc_ui["b1"]:setVisible(false) descUI["b1"]:setVisible(false)
end end
else else
desc_ui["status"]:setText("Not cut") descUI["status"]:setText("Not cut")
desc_ui["status"]:setColor(1, 1, 1, 1) descUI["status"]:setColor(1, 1, 1, 1)
desc_ui["b1"]:setVisible(true) descUI["b1"]:setVisible(true)
desc_ui["b1"]:setText("Remove prosthesis before") descUI["b1"]:setText("Remove prosthesis before")
desc_ui["b1"]:addArg("option", "Nothing") descUI["b1"]:addArg("option", "Nothing")
end end
-- Prosthesis Level -- Prosthesis Level
if string.find(part_name, "Right") then if string.find(partName, "Right") then
local lv = patient:getPerkLevel(Perks.Right_Hand) + 1 local lv = patient:getPerkLevel(Perks.Right_Hand) + 1
desc_ui["textLV2"]:setText("Level: " .. lv .. " / 10") descUI["textLV2"]:setText("Level: " .. lv .. " / 10")
local xp = patient:getXp():getXP(Perks.Right_Hand) local xp = patient:getXp():getXP(Perks.Right_Hand)
local min, max = FindMinMax(lv) local min, max = FindMinMax(lv)
desc_ui["pbarNLV"]:setMinMax(min, max) descUI["pbarNLV"]:setMinMax(min, max)
desc_ui["pbarNLV"]:setValue(xp) descUI["pbarNLV"]:setValue(xp)
else else
local lv = patient:getPerkLevel(Perks.Left_Hand) + 1 local lv = patient:getPerkLevel(Perks.Left_Hand) + 1
desc_ui["textLV2"]:setText("Level: " .. lv .. " / 10") descUI["textLV2"]:setText("Level: " .. lv .. " / 10")
local xp = patient:getXp():getXP(Perks.Left_Hand) local xp = patient:getXp():getXP(Perks.Left_Hand)
local min, max = FindMinMax(lv) local min, max = FindMinMax(lv)
desc_ui["pbarNLV"]:setMinMax(min, max) descUI["pbarNLV"]:setMinMax(min, max)
desc_ui["pbarNLV"]:setValue(xp) descUI["pbarNLV"]:setValue(xp)
end end
end end
@@ -285,9 +291,9 @@ end
-- On Click Functions -- On Click Functions
local function OnClickTocMainUI(button, args) local function OnClickTocMainUI(button, args)
desc_ui:open() descUI:open()
desc_ui:setPositionPixel(main_ui:getRight(), main_ui:getY()) descUI:setPositionPixel(mainUI:getRight(), mainUI:getY())
SetupTocDescUI(main_ui.surgeon, main_ui.patient, main_ui.limbs_data, args.part_name) -- surgeon is generic. JCIO_UI.SetupDescUI(mainUI.surgeon, mainUI.patient, mainUI.limbs_data, args.part_name) -- surgeon is generic.
end end
@@ -342,32 +348,32 @@ end
local function OnClickTocDescUI(button, args) local function OnClickTocDescUI(button, args)
-- Gets every arg from main -- Gets every arg from main
local patient = desc_ui.patient local patient = descUI.patient
local surgeon = desc_ui.surgeon local surgeon = descUI.surgeon
if args.option ~= "Nothing" then if args.option ~= "Nothing" then
TryTocAction(_, desc_ui.part_name, args.option, surgeon, patient) TryTocAction(_, descUI.part_name, args.option, surgeon, patient)
end end
main_ui:close() mainUI:close()
end end
local function OnClickTocConfirmUIMP(button, args) local function OnClickTocConfirmUIMP(button, args)
local player = getPlayer() local player = getPlayer()
if confirm_ui_mp.actionAct == "Cut" and args.option == "yes" then if confirmUIMP.actionAct == "Cut" and args.option == "yes" then
ISTimedActionQueue.add(ISCutLimb:new(confirm_ui_mp.patient, player, confirm_ui_mp.partNameAct)) ISTimedActionQueue.add(ISCutLimb:new(confirmUIMP.patient, player, confirmUIMP.partNameAct))
elseif confirm_ui_mp.actionAct == "Operate" and args.option == "yes" then elseif confirmUIMP.actionAct == "Operate" and args.option == "yes" then
local playerInv = player:getInventory() local playerInv = player:getInventory()
local item = playerInv:getItemFromType('TOC.Real_surgeon_kit') or playerInv:getItemFromType('TOC.Surgeon_kit') or local item = playerInv:getItemFromType('TOC.Real_surgeon_kit') or playerInv:getItemFromType('TOC.Surgeon_kit') or
playerInv:getItemFromType('TOC.Improvised_surgeon_kit') playerInv:getItemFromType('TOC.Improvised_surgeon_kit')
if item then if item then
ISTimedActionQueue.add(ISOperateLimb:new(confirm_ui_mp.patient, player, item, confirm_ui_mp.partNameAct, ISTimedActionQueue.add(ISOperateLimb:new(confirmUIMP.patient, player, item, confirmUIMP.partNameAct,
false)) false))
else else
player:Say("I need a kit") player:Say("I need a kit")
end end
elseif confirm_ui_mp.actionAct == "Equip" and args.option == "yes" then elseif confirmUIMP.actionAct == "Equip" and args.option == "yes" then
local surgeon_inventory = player:getInventory() local surgeon_inventory = player:getInventory()
local prosthesis_to_equip = surgeon_inventory:getItemFromType('TOC.MetalHand') or local prosthesis_to_equip = surgeon_inventory:getItemFromType('TOC.MetalHand') or
@@ -375,21 +381,21 @@ local function OnClickTocConfirmUIMP(button, args)
surgeon_inventory:getItemFromType('TOC.WoodenHook') surgeon_inventory:getItemFromType('TOC.WoodenHook')
if prosthesis_to_equip then if prosthesis_to_equip then
ISTimedActionQueue.add(ISInstallProsthesis:new(player, confirm_ui_mp.patient, prosthesis_to_equip, ISTimedActionQueue.add(ISInstallProsthesis:new(player, confirmUIMP.patient, prosthesis_to_equip,
confirm_ui_mp.partNameAct)) confirmUIMP.partNameAct))
else else
player:Say("I don't have a prosthesis right now") player:Say("I don't have a prosthesis right now")
end end
elseif confirm_ui_mp.actionAct == "Unequip" and args.option == "yes" then elseif confirmUIMP.actionAct == "Unequip" and args.option == "yes" then
-- We can't check if the player has a prosthesis right now, we need to do it later -- We can't check if the player has a prosthesis right now, we need to do it later
-- TODO should check if player has a prosthesis equipped before doing it -- TODO should check if player has a prosthesis equipped before doing it
-- TODO Player is surgeon, but we don't have a confirm_ui_mp.surgeon... awful awful awful -- TODO Player is surgeon, but we don't have a confirm_ui_mp.surgeon... awful awful awful
-- TODO Workaround for now, we'd need to send data from patient before doing it since we can't access his inventory from the surgeon -- TODO Workaround for now, we'd need to send data from patient before doing it since we can't access his inventory from the surgeon
if confirm_ui_mp.patient == player then if confirmUIMP.patient == player then
ISTimedActionQueue.add(ISUninstallProsthesis:new(player, confirm_ui_mp.patient, confirm_ui_mp.partNameAct)) ISTimedActionQueue.add(ISUninstallProsthesis:new(player, confirmUIMP.patient, confirmUIMP.partNameAct))
else else
player:Say("I can't do that, they need to do it themselves") player:Say("I can't do that, they need to do it themselves")
@@ -401,8 +407,8 @@ local function OnClickTocConfirmUIMP(button, args)
end end
confirm_ui_mp:close() confirmUIMP:close()
confirm_ui_mp.responseReceive = false confirmUIMP.responseReceive = false
end end
@@ -410,172 +416,216 @@ end
-- CREATE UI SECTION -- CREATE UI SECTION
local function CreateTocMainUI() local function CreateTocMainUI()
main_ui = NewUI() mainUI = NewUI()
main_ui:setTitle("The Only Cure Menu") mainUI:setTitle("The Only Cure Menu")
main_ui:setWidthPercent(0.1) mainUI:setWidthPercent(0.1)
main_ui:addImageButton("b11", "", OnClickTocMainUI) mainUI:addImageButton("b11", "", OnClickTocMainUI)
main_ui["b11"]:addArg("part_name", "Right_UpperArm") mainUI["b11"]:addArg("part_name", "Right_UpperArm")
main_ui:addImageButton("b12", "", OnClickTocMainUI) mainUI:addImageButton("b12", "", OnClickTocMainUI)
main_ui["b12"]:addArg("part_name", "Left_UpperArm") mainUI["b12"]:addArg("part_name", "Left_UpperArm")
main_ui:nextLine() mainUI:nextLine()
main_ui:addImageButton("b21", "", OnClickTocMainUI) mainUI:addImageButton("b21", "", OnClickTocMainUI)
main_ui["b21"]:addArg("part_name", "Right_LowerArm") mainUI["b21"]:addArg("part_name", "Right_LowerArm")
main_ui:addImageButton("b22", "", OnClickTocMainUI) mainUI:addImageButton("b22", "", OnClickTocMainUI)
main_ui["b22"]:addArg("part_name", "Left_LowerArm") mainUI["b22"]:addArg("part_name", "Left_LowerArm")
main_ui:nextLine() mainUI:nextLine()
main_ui:addImageButton("b31", "", OnClickTocMainUI) mainUI:addImageButton("b31", "", OnClickTocMainUI)
main_ui["b31"]:addArg("part_name", "Right_Hand") mainUI["b31"]:addArg("part_name", "Right_Hand")
main_ui:addImageButton("b32", "", OnClickTocMainUI) mainUI:addImageButton("b32", "", OnClickTocMainUI)
main_ui["b32"]:addArg("part_name", "Left_Hand") mainUI["b32"]:addArg("part_name", "Left_Hand")
main_ui:nextLine() mainUI:nextLine()
main_ui:addImageButton("b41", "", OnClickTocMainUI) mainUI:addImageButton("b41", "", OnClickTocMainUI)
main_ui["b41"]:addArg("part_name", "Right_Foot") mainUI["b41"]:addArg("part_name", "Right_Foot")
main_ui:addImageButton("b42", "", OnClickTocMainUI) mainUI:addImageButton("b42", "", OnClickTocMainUI)
main_ui["b42"]:addArg("part_name", "Left_Foot") mainUI["b42"]:addArg("part_name", "Left_Foot")
main_ui:saveLayout() mainUI:saveLayout()
end end
-- Create a temporary desc UI with fake data (for now) -- Create a temporary desc UI with fake data (for now)
local function CreateTocDescUI() local function CreateTocDescUI()
desc_ui = NewUI() descUI = NewUI()
desc_ui:setTitle("The only cure description"); descUI:setTitle("The only cure description");
desc_ui:isSubUIOf(main_ui) descUI:isSubUIOf(mainUI)
desc_ui:setWidthPixel(250) descUI:setWidthPixel(250)
desc_ui:setColumnWidthPixel(1, 100) descUI:setColumnWidthPixel(1, 100)
desc_ui:addText("textTitle", "Right arm", "Large", "Center") descUI:addText("textTitle", "Right arm", "Large", "Center")
desc_ui:nextLine() descUI:nextLine()
desc_ui:addText("textLV2", "Level 3/10", _, "Center") descUI:addText("textLV2", "Level 3/10", _, "Center")
desc_ui:nextLine() descUI:nextLine()
desc_ui:addText("textLV", "Next LV:", _, "Right") descUI:addText("textLV", "Next LV:", _, "Right")
desc_ui:addProgressBar("pbarNLV", 39, 0, 100) descUI:addProgressBar("pbarNLV", 39, 0, 100)
desc_ui["pbarNLV"]:setMarginPixel(10, 6) descUI["pbarNLV"]:setMarginPixel(10, 6)
desc_ui:nextLine() descUI:nextLine()
desc_ui:addEmpty("border1") descUI:addEmpty("border1")
desc_ui:setLineHeightPixel(1) descUI:setLineHeightPixel(1)
desc_ui["border1"]:setBorder(true) descUI["border1"]:setBorder(true)
desc_ui:nextLine() descUI:nextLine()
desc_ui:addEmpty() descUI:addEmpty()
desc_ui:nextLine() descUI:nextLine()
desc_ui:addText("status", "Temporary", "Medium", "Center") descUI:addText("status", "Temporary", "Medium", "Center")
desc_ui["status"]:setColor(1, 1, 0, 0) descUI["status"]:setColor(1, 1, 0, 0)
desc_ui:nextLine() descUI:nextLine()
desc_ui:addEmpty() descUI:addEmpty()
desc_ui:nextLine() descUI:nextLine()
desc_ui:addButton("b1", "Operate", OnClickTocDescUI) descUI:addButton("b1", "Operate", OnClickTocDescUI)
desc_ui:saveLayout() descUI:saveLayout()
end end
function CreateTocConfirmUIMP() function CreateTocConfirmUIMP()
confirm_ui_mp = NewUI() confirmUIMP = NewUI()
confirm_ui_mp.responseReceive = false confirmUIMP.responseReceive = false
confirm_ui_mp:addText("text1", "Are you sure?", "Title", "Center"); confirmUIMP:addText("text1", "Are you sure?", "Title", "Center");
confirm_ui_mp:setLineHeightPixel(getTextManager():getFontHeight(confirm_ui_mp.text1.font) + 10) confirmUIMP:setLineHeightPixel(getTextManager():getFontHeight(confirmUIMP.text1.font) + 10)
confirm_ui_mp:nextLine(); confirmUIMP:nextLine();
confirm_ui_mp:addText("text4", "", "Medium", "Center"); confirmUIMP:addText("text4", "", "Medium", "Center");
confirm_ui_mp:setLineHeightPixel(getTextManager():getFontHeight(confirm_ui_mp.text4.font) + 10) confirmUIMP:setLineHeightPixel(getTextManager():getFontHeight(confirmUIMP.text4.font) + 10)
confirm_ui_mp:nextLine(); confirmUIMP:nextLine();
confirm_ui_mp:addText("text2", "", _, "Center"); confirmUIMP:addText("text2", "", _, "Center");
confirm_ui_mp:nextLine(); confirmUIMP:nextLine();
confirm_ui_mp:addText("text3", "", _, "Center"); confirmUIMP:addText("text3", "", _, "Center");
confirm_ui_mp:nextLine(); confirmUIMP:nextLine();
confirm_ui_mp:addEmpty(); confirmUIMP:addEmpty();
confirm_ui_mp:nextLine(); confirmUIMP:nextLine();
confirm_ui_mp:addEmpty(); confirmUIMP:addEmpty();
confirm_ui_mp:addButton("b1", "Yes", OnClickTocConfirmUIMP); confirmUIMP:addButton("b1", "Yes", OnClickTocConfirmUIMP);
confirm_ui_mp.b1:addArg("option", "yes"); confirmUIMP.b1:addArg("option", "yes");
confirm_ui_mp:addEmpty(); confirmUIMP:addEmpty();
confirm_ui_mp:addButton("b2", "No", OnClickTocConfirmUIMP); confirmUIMP:addButton("b2", "No", OnClickTocConfirmUIMP);
confirm_ui_mp:addEmpty(); confirmUIMP:addEmpty();
confirm_ui_mp:nextLine(); confirmUIMP:nextLine();
confirm_ui_mp:addEmpty(); confirmUIMP:addEmpty();
confirm_ui_mp:saveLayout(); confirmUIMP:saveLayout();
confirm_ui_mp:addPrerenderFunction(PrerenderFuncMP); confirmUIMP:addPrerenderFunction(PrerenderFuncMP);
confirm_ui_mp:close(); confirmUIMP:close();
end end
-- We create everything from here -- We create everything from here
function OnCreateTheOnlyCureUI()
JCIO_UI.OnCreate = function()
CreateTocMainUI() CreateTocMainUI()
CreateTocDescUI() CreateTocDescUI()
CreateTocConfirmUIMP() CreateTocConfirmUIMP()
if isClient() then CreateTocConfirmUIMP() end if isClient() then CreateTocConfirmUIMP() end
main_ui:close() mainUI:close()
end end
-------------------------------------------- --------------------------------------------
-- MP Confirm (I should add it to client too but hey not sure how it works tbh) -- MP Confirm (I should add it to client too but hey not sure how it works tbh)
function SendCommandToConfirmUIMP(action, isBitten, userName, partName) function SendCommandToConfirmUIMP(action, isBitten, userName, partName)
confirm_ui_mp:setInCenterOfScreen() confirmUIMP:setInCenterOfScreen()
confirm_ui_mp:bringToTop() confirmUIMP:bringToTop()
confirm_ui_mp:open() confirmUIMP:open()
if action ~= "Wait server" then if action ~= "Wait server" then
confirm_ui_mp["text4"]:setText("You're gonna " .. confirmUIMP["text4"]:setText("You're gonna " ..
action .. " the " .. getText("UI_ContextMenu_" .. partName) .. " of " .. userName) action .. " the " .. getText("UI_ContextMenu_" .. partName) .. " of " .. userName)
confirm_ui_mp["text2"]:setText("Are you sure?") confirmUIMP["text2"]:setText("Are you sure?")
confirm_ui_mp["text2"]:setColor(1, 0, 0, 0) confirmUIMP["text2"]:setColor(1, 0, 0, 0)
confirm_ui_mp["b1"]:setVisible(true) confirmUIMP["b1"]:setVisible(true)
confirm_ui_mp["b2"]:setVisible(true) confirmUIMP["b2"]:setVisible(true)
else else
confirm_ui_mp["text4"]:setText(action) confirmUIMP["text4"]:setText(action)
confirm_ui_mp["text3"]:setText("") confirmUIMP["text3"]:setText("")
confirm_ui_mp["text2"]:setText("") confirmUIMP["text2"]:setText("")
confirm_ui_mp["b1"]:setVisible(false) confirmUIMP["b1"]:setVisible(false)
confirm_ui_mp["b2"]:setVisible(false) confirmUIMP["b2"]:setVisible(false)
end end
end end
-------------------------------------------- --------------------------------------------
-- Add TOC element to Health Panel -- Add TOC element to Health Panel
TocTempTable = {patient = nil, surgeon = nil}
JCIO.RefreshClientMenu = function(_)
if mainUI:getIsVisible() == false then
Events.OnTick.Remove(JCIO.RefreshClientMenu)
TocTempTable.patient = nil
TocTempTable.surgeon = nil
else
local limbs_data = TocTempTable.patient:getModData().TOC.Limbs
JCIO_UI.SetupMainUI(TocTempTable.patient, TocTempTable.patient, limbs_data)
end
end
JCIO.RefreshOtherPlayerMenu = function(_)
if mainUI:getIsVisible() == false then
Events.OnTick.Remove(JCIO.RefreshOtherPlayerMenu)
TocTempTable.patient = nil
TocTempTable.surgeon = nil
else
if ModData.get("TOC_PLAYER_DATA")[TocTempTable.patient:getUsername()] ~= nil then
local other_player_part_data = ModData.get("TOC_PLAYER_DATA")[TocTempTable.patient:getUsername()]
JCIO_UI.SetupMainUI(TocTempTable.surgeon, TocTempTable.patient, other_player_part_data[1])
end
end
end
local ISHealthPanel_createChildren = ISHealthPanel.createChildren local ISHealthPanel_createChildren = ISHealthPanel.createChildren
local ISHealthPanel_render = ISHealthPanel.render local ISHealthPanel_render = ISHealthPanel.render
-- Add button to health panel -- Add button to health panel
function ISNewHealthPanel.onClickJCIO(button)
function ISNewHealthPanel.onClick_TOC(button)
local surgeon = button.otherPlayer local surgeon = button.otherPlayer
local patient = button.character local patient = button.character
@@ -588,80 +638,42 @@ function ISNewHealthPanel.onClick_TOC(button)
if surgeon == patient then if surgeon == patient then
Events.OnTick.Add(TocRefreshPlayerMenu) Events.OnTick.Add(JCIO.RefreshClientMenu)
else else
Events.OnTick.Add(TocRefreshOtherPlayerMenu) -- MP stuff, try to get the other player data and display it on the surgeon display Events.OnTick.Add(JCIO.RefreshOtherPlayerMenu) -- MP stuff, try to get the other player data and display it on the surgeon display
end end
else else
-- SP Handling -- SP Handling
Events.OnTick.Add(TocRefreshPlayerMenu) Events.OnTick.Add(JCIO.RefreshClientMenu)
end end
-- Set the correct main title -- Set the correct main title
-- TODO sizes of the menu are strange in MP, they're not consistent with SP -- TODO sizes of the menu are strange in MP, they're not consistent with SP
local separated_username = {} local separatedUsername = {}
for v in string.gmatch(patient:getUsername(), "%u%l+") do for v in string.gmatch(patient:getUsername(), "%u%l+") do
table.insert(separated_username, v) table.insert(separatedUsername, v)
end end
local main_title local main_title
if separated_username[1] == nil then if separatedUsername[1] == nil then
main_title = patient:getUsername() .. " - TOC" main_title = patient:getUsername() .. " - JCIO"
else else
main_title = separated_username[1] .. " " .. separated_username[2] .. " - TOC" main_title = separatedUsername[1] .. " " .. separatedUsername[2] .. " - JCIO"
end end
main_ui:setTitle(main_title) mainUI:setTitle(main_title)
main_ui:toggle() mainUI:toggle()
main_ui:setInCenterOfScreen() mainUI:setInCenterOfScreen()
end end
TocTempTable = {patient = nil, surgeon = nil}
function TocRefreshPlayerMenu(_)
if main_ui:getIsVisible() == false then
Events.OnTick.Remove(TocRefreshPlayerMenu)
TocTempTable.patient = nil
TocTempTable.surgeon = nil
else
local limbs_data = TocTempTable.patient:getModData().TOC.Limbs
SetupTocMainUI(TocTempTable.patient, TocTempTable.patient, limbs_data)
end
end
function TocRefreshOtherPlayerMenu(_)
if main_ui:getIsVisible() == false then
Events.OnTick.Remove(TocRefreshOtherPlayerMenu)
TocTempTable.patient = nil
TocTempTable.surgeon = nil
else
if ModData.get("TOC_PLAYER_DATA")[TocTempTable.patient:getUsername()] ~= nil then
local other_player_part_data = ModData.get("TOC_PLAYER_DATA")[TocTempTable.patient:getUsername()]
SetupTocMainUI(TocTempTable.surgeon, TocTempTable.patient, other_player_part_data[1])
end
end
end
function ISHealthPanel:createChildren() function ISHealthPanel:createChildren()
ISHealthPanel_createChildren(self) ISHealthPanel_createChildren(self)
@@ -669,7 +681,7 @@ function ISHealthPanel:createChildren()
self.fitness:setWidth(self.fitness:getWidth() / 1.4) self.fitness:setWidth(self.fitness:getWidth() / 1.4)
self.TOCButton = ISButton:new(self.fitness:getRight() + 10, self.healthPanel.y, 60, 20, "", self, self.TOCButton = ISButton:new(self.fitness:getRight() + 10, self.healthPanel.y, 60, 20, "", self,
ISNewHealthPanel.onClick_TOC) ISNewHealthPanel.onClickJCIO)
self.TOCButton:setImage(getTexture("media/ui/TOC/iconForMenu.png")) self.TOCButton:setImage(getTexture("media/ui/TOC/iconForMenu.png"))
self.TOCButton.anchorTop = false self.TOCButton.anchorTop = false
self.TOCButton.anchorBottom = true self.TOCButton.anchorBottom = true
@@ -687,4 +699,4 @@ function ISHealthPanel:render()
end end
-- EVENTS -- EVENTS
Events.OnCreateUI.Add(OnCreateTheOnlyCureUI) Events.OnCreateUI.Add(JCIO_UI.OnCreate)

View File

@@ -1,11 +1,11 @@
-- Thanks to Glytcher and Matías N. Salas for helping out with this -- Thanks to Glytcher and Matías N. Salas for helping out with this
if JCIOAnims == nil then if JCIO_Anims == nil then
JCIOAnims = {} JCIO_Anims = {}
end end
JCIOAnims.SetMissingFootAnimation = function(check) JCIO_Anims.SetMissingFootAnimation = function(check)
local player = getPlayer() local player = getPlayer()
player:setVariable("IsCrawling", tostring(check)) player:setVariable("IsCrawling", tostring(check))
@@ -17,9 +17,9 @@ JCIOAnims.SetMissingFootAnimation = function(check)
end end
end end
JCIOAnims.CheckAndSetMissingFootAnims = function(modData) JCIO_Anims.CheckAndSetMissingFootAnims = function(modData)
if modData.JCIO.limbs["Left_Foot"].isCut or modData.JCIO.limbs["Right_Foot"].isCut then if modData.JCIO.limbs["Left_Foot"].isCut or modData.JCIO.limbs["Right_Foot"].isCut then
JCIOAnims.SetMissingFootAnimation(true) JCIO_Anims.SetMissingFootAnimation(true)
end end
end end

View File

@@ -4,17 +4,17 @@
---------- COMPATIBILITY FUNCS ----------- ---------- COMPATIBILITY FUNCS -----------
if JCIOCompat == nil then if JCIO_Compat == nil then
JCIOCompat = {} JCIO_Compat = {}
end end
-- Gets the old status and turns it into the new. -- Gets the old status and turns it into the new.
JCIOCompat.CheckCompatibilityWithOlderVersions = function(modData) JCIO_Compat.CheckCompatibilityWithOlderVersions = function(modData)
if modData.TOC ~= nil then if modData.TOC ~= nil then
print("JCIO: found old data from TOC") print("JCIO: found old data from TOC")
if modData.TOC.Limbs ~= nil then if modData.TOC.Limbs ~= nil then
JCIOCompat.MapOldDataToNew(modData) JCIO_Compat.MapOldDataToNew(modData)
modData.TOC = nil -- Deletes the old mod data stuff modData.TOC = nil -- Deletes the old mod data stuff
else else
print("JCIO: something is wrong, couldn't find Limbs table in old TOC modData") print("JCIO: something is wrong, couldn't find Limbs table in old TOC modData")
@@ -27,7 +27,7 @@ JCIOCompat.CheckCompatibilityWithOlderVersions = function(modData)
end end
JCIOCompat.MapOldDataToNew = function(modData) JCIO_Compat.MapOldDataToNew = function(modData)
local oldNamesTable = { "RightHand", "RightForearm", "RightArm", "LeftHand", "LeftForearm", "LeftArm" } local oldNamesTable = { "RightHand", "RightForearm", "RightArm", "LeftHand", "LeftForearm", "LeftArm" }
local newNamesTable = { "Right_Hand", "Right_LowerArm", "Right_UpperArm", "Left_Hand", "Left_LowerArm", "Left_UpperArm" } local newNamesTable = { "Right_Hand", "Right_LowerArm", "Right_UpperArm", "Left_Hand", "Left_LowerArm", "Left_UpperArm" }

View File

@@ -41,7 +41,7 @@ JCIO.CutLimbForTrait = function(player, jcioModData, partName)
local limbsData = jcioModData.limbs local limbsData = jcioModData.limbs
local amputationClothingItem = player:getInventory():AddItem("TOC.Amputation_" .. partName) local amputationClothingItem = player:getInventory():AddItem("TOC.Amputation_" .. partName)
JCIOVisuals.SetTextureForAmputation(amputationClothingItem, player, true) JCIO_Visuals.SetTextureForAmputation(amputationClothingItem, player, true)
player:setWornItem(amputationClothingItem:getBodyLocation(), amputationClothingItem) player:setWornItem(amputationClothingItem:getBodyLocation(), amputationClothingItem)
limbsData[partName].isCut = true limbsData[partName].isCut = true
@@ -179,15 +179,15 @@ JCIO.Init = function(_, player)
if modData.JCIO == nil then if modData.JCIO == nil then
JCIO.SetInitData(modData, player) JCIO.SetInitData(modData, player)
else else
JCIOCompat.CheckCompatibilityWithOlderVersions(modData) JCIO_Compat.CheckCompatibilityWithOlderVersions(modData)
JCIOAnims.CheckAndSetMissingFootAnims(modData) JCIO_Anims.CheckAndSetMissingFootAnims(modData)
end end
-- Compat fix with older versions -- Compat fix with older versions
if modData.TOC ~= nil then if modData.TOC ~= nil then
print("JCIO: found older data from TOC or TOCBB") print("JCIO: found older data from TOC or TOCBB")
JCIOCompat.CheckCompatibilityWithOlderVersions(modData) JCIO_Compat.CheckCompatibilityWithOlderVersions(modData)
end end
end end

View File

@@ -4,12 +4,12 @@
------------ VISUALS FUNCTIONS ----------- ------------ VISUALS FUNCTIONS -----------
if JCIOVisuals == nil then if JCIO_Visuals == nil then
JCIOVisuals = {} JCIO_Visuals = {}
end end
JCIOVisuals.SetTextureForAmputation = function(item, player, cicatrized) JCIO_Visuals.SetTextureForAmputation = function(item, player, cicatrized)
local humanVisual = player:getHumanVisual() local humanVisual = player:getHumanVisual()
local textureString = humanVisual:getSkinTexture() local textureString = humanVisual:getSkinTexture()
@@ -40,7 +40,7 @@ JCIOVisuals.SetTextureForAmputation = function(item, player, cicatrized)
end end
JCIOVisuals.SetBloodOnAmputation = function(player, bodyPart) JCIO_Visuals.SetBloodOnAmputation = function(player, bodyPart)
local bodyPartType = bodyPart:getType() local bodyPartType = bodyPart:getType()
local bloodBodyPartType local bloodBodyPartType

View File

@@ -77,7 +77,7 @@ function TocResetEverything()
-- Reset special flag for legs amputations -- Reset special flag for legs amputations
JCIOAnims.SetMissingFootAnimation(false) JCIO_Anims.SetMissingFootAnimation(false)
end end
@@ -98,7 +98,7 @@ function TocResetClothingItemBodyLocation(player, side, limb)
player:removeWornItem(amputationItem) player:removeWornItem(amputationItem)
player:getInventory():Remove(amputationItem) player:getInventory():Remove(amputationItem)
amputationItem = playerInv:AddItem(amputationItemName) amputationItem = playerInv:AddItem(amputationItemName)
JCIOVisuals.SetTextureForAmputation(amputationItem, player, limbsData[side .. "_" .. limb].is_cicatrized) JCIO_Visuals.SetTextureForAmputation(amputationItem, player, limbsData[side .. "_" .. limb].is_cicatrized)
player:setWornItem(amputationItem:getBodyLocation(), amputationItem) player:setWornItem(amputationItem:getBodyLocation(), amputationItem)
end end
amputationItem = nil -- reset it amputationItem = nil -- reset it

View File

@@ -122,7 +122,7 @@ local function SetHealthStatusForBodyPart(partData, partName, player)
local amputatedClothingItem = playerInv:FindAndReturn(amputatedClothingItemName) local amputatedClothingItem = playerInv:FindAndReturn(amputatedClothingItemName)
player:removeWornItem(amputatedClothingItem) player:removeWornItem(amputatedClothingItem)
JCIOVisuals.SetTextureForAmputation(amputatedClothingItem, player, true) JCIO_Visuals.SetTextureForAmputation(amputatedClothingItem, player, true)
player:setWornItem(amputatedClothingItem:getBodyLocation(), amputatedClothingItem) player:setWornItem(amputatedClothingItem:getBodyLocation(), amputatedClothingItem)
if (not player:HasTrait("Brave")) and ZombRand(1, 11) > 5 then if (not player:HasTrait("Brave")) and ZombRand(1, 11) > 5 then