Refreshing UI working
This commit is contained in:
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -43,6 +43,7 @@
|
|||||||
"ISDropItemAction",
|
"ISDropItemAction",
|
||||||
"BloodBodyPartType",
|
"BloodBodyPartType",
|
||||||
"ISInventoryPane",
|
"ISInventoryPane",
|
||||||
"ModData"
|
"ModData",
|
||||||
|
"isDebugEnabled"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -193,32 +193,24 @@ Commands["AcceptResetEverything"] = function(arg)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Base stuff
|
|
||||||
Commands["GivePlayerData"] = function(arg)
|
|
||||||
local surgeon_id = arg[1]
|
|
||||||
local patient = getPlayerByOnlineID(arg[2])
|
|
||||||
local toc_data = patient:getModData().TOC
|
|
||||||
sendClientCommand(patient, "TOC", "SendPlayerData", { surgeon_id, toc_data })
|
|
||||||
end
|
|
||||||
|
|
||||||
Commands["SendTocData"] = function(arg)
|
|
||||||
print("Sending TOC data")
|
-- Cut Limb stuff
|
||||||
|
Commands["AcceptDamageOtherPlayer"] = function(arg)
|
||||||
|
|
||||||
|
local patient_id = arg[1]
|
||||||
local patient = getPlayerByOnlineID(arg[1])
|
local patient = getPlayerByOnlineID(arg[1])
|
||||||
|
local part_name = arg[2]
|
||||||
MP_other_player_toc_data = arg[2]
|
TocDamagePlayerDuringAmputation(patient, part_name)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Base stuff
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function OnTocServerCommand(module, command, args)
|
local function OnTocServerCommand(module, command, args)
|
||||||
if module == 'TOC' then
|
if module == 'TOC' then
|
||||||
print("OnTocServerCommand " .. command)
|
print("TOC: On Toc Server Command " .. command)
|
||||||
if Commands[command] then
|
if Commands[command] then
|
||||||
print("Found command, executing it now")
|
print("Found command, executing it now")
|
||||||
args = args or {}
|
args = args or {}
|
||||||
|
|||||||
@@ -89,6 +89,19 @@ function TocGetSawInInventory(surgeon)
|
|||||||
return item
|
return item
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function TocDamagePlayerDuringAmputation(patient, part_name)
|
||||||
|
local body_part_type = TocGetBodyPartTypeFromPartName(part_name)
|
||||||
|
local body_damage = patient:getBodyDamage()
|
||||||
|
local body_damage_part = body_damage:getBodyPart(body_part_type)
|
||||||
|
|
||||||
|
|
||||||
|
body_damage_part:setBleeding(true)
|
||||||
|
body_damage_part:setCut(true)
|
||||||
|
body_damage_part:setBleedingTime(ZombRand(10, 20))
|
||||||
|
end
|
||||||
|
|
||||||
-- OperateLimb
|
-- OperateLimb
|
||||||
function SetBodyPartsStatusAfterOperation(player, limbs_data, part_name, use_oven)
|
function SetBodyPartsStatusAfterOperation(player, limbs_data, part_name, use_oven)
|
||||||
--for _, v in ipairs(GetBodyParts()) do
|
--for _, v in ipairs(GetBodyParts()) do
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ local function OnClickTocMainUI(button, args)
|
|||||||
|
|
||||||
desc_ui:open()
|
desc_ui:open()
|
||||||
desc_ui:setPositionPixel(main_ui:getRight(), main_ui:getY())
|
desc_ui:setPositionPixel(main_ui:getRight(), main_ui:getY())
|
||||||
SetupTocDescUI(main_ui.surgeon, main_ui.patient, args.limbs_data, args.part_name) -- surgeon is generic.
|
SetupTocDescUI(main_ui.surgeon, main_ui.patient, main_ui.limbs_data, args.part_name) -- surgeon is generic.
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -360,12 +360,8 @@ function SetupTocMainUI(surgeon, patient, limbs_data)
|
|||||||
main_ui.patient = patient
|
main_ui.patient = patient
|
||||||
|
|
||||||
if limbs_data then
|
if limbs_data then
|
||||||
main_ui["b11"]:addArg("limbs_data", limbs_data)
|
|
||||||
main_ui["b12"]:addArg("limbs_data", limbs_data)
|
main_ui.limbs_data = limbs_data
|
||||||
main_ui["b21"]:addArg("limbs_data", limbs_data)
|
|
||||||
main_ui["b22"]:addArg("limbs_data", limbs_data)
|
|
||||||
main_ui["b31"]:addArg("limbs_data", limbs_data)
|
|
||||||
main_ui["b32"]:addArg("limbs_data", limbs_data)
|
|
||||||
|
|
||||||
main_ui["b11"]:setPath(GetImageName("Right_UpperArm", limbs_data))
|
main_ui["b11"]:setPath(GetImageName("Right_UpperArm", limbs_data))
|
||||||
main_ui["b12"]:setPath(GetImageName("Left_UpperArm", limbs_data))
|
main_ui["b12"]:setPath(GetImageName("Left_UpperArm", limbs_data))
|
||||||
@@ -534,45 +530,28 @@ local ISHealthPanel_render = ISHealthPanel.render
|
|||||||
-- Add button to health panel
|
-- Add button to health panel
|
||||||
|
|
||||||
|
|
||||||
TocTempTable = {
|
|
||||||
TempPatient = nil,
|
|
||||||
TempSurgeon = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function ISNewHealthPanel.onClick_TOC(button)
|
function ISNewHealthPanel.onClick_TOC(button)
|
||||||
|
|
||||||
local surgeon = button.otherPlayer
|
local surgeon = button.otherPlayer
|
||||||
local patient = button.character
|
local patient = button.character
|
||||||
|
|
||||||
|
TocTempTable.patient = patient
|
||||||
|
TocTempTable.surgeon = surgeon
|
||||||
|
|
||||||
|
-- MP Handling
|
||||||
if surgeon then
|
if surgeon then
|
||||||
|
|
||||||
|
|
||||||
if surgeon == patient then
|
if surgeon == patient then
|
||||||
SetupTocMainUI(surgeon, surgeon, surgeon:getModData().TOC.Limbs)
|
Events.OnTick.Add(TocRefreshPlayerMenu)
|
||||||
|
|
||||||
else
|
else
|
||||||
-- MP stuff, try to get the other player data and display it on the surgeon display
|
Events.OnTick.Add(TocRefreshOtherPlayerMenu) -- MP stuff, try to get the other player data and display it on the surgeon display
|
||||||
print("TOC: Checking part_data for " .. patient:getUsername())
|
|
||||||
if ModData.get("TOC_PLAYER_DATA")[patient:getUsername()] ~= nil then
|
|
||||||
local other_player_part_data = ModData.get("TOC_PLAYER_DATA")[patient:getUsername()]
|
|
||||||
|
|
||||||
SetupTocMainUI(surgeon, patient, other_player_part_data[1])
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--sendClientCommand(surgeon, "TOC", "GetPlayerData", { surgeon:getOnlineID(), patient:getOnlineID() })
|
|
||||||
|
|
||||||
--TocTempTable.TempPatient = patient
|
|
||||||
--TocTempTable.TempSurgeon = surgeon
|
|
||||||
|
|
||||||
-- Wait for ack
|
|
||||||
--Events.OnTick.Add(TocWaitForOnlinePlayerData)
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- This is when surgeon doesnt exist for some reason.
|
-- SP Handling
|
||||||
SetupTocMainUI(patient, patient, patient:getModData().TOC.Limbs)
|
Events.OnTick.Add(TocRefreshPlayerMenu)
|
||||||
end
|
end
|
||||||
|
|
||||||
main_ui:toggle()
|
main_ui:toggle()
|
||||||
@@ -580,28 +559,54 @@ function ISNewHealthPanel.onClick_TOC(button)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function TocWaitForOnlinePlayerData(numberTicks)
|
|
||||||
if MP_other_player_toc_data ~= nil then
|
|
||||||
SetupTocMainUI(TocTempTable.TempSurgeon, TocTempTable.TempPatient, MP_other_player_toc_data)
|
|
||||||
|
|
||||||
|
|
||||||
TocTempTable.TempSurgeon = nil
|
|
||||||
TocTempTable.TempPatient = nil
|
TocTempTable = {patient = nil, surgeon = nil}
|
||||||
MP_other_player_toc_data = nil
|
|
||||||
Events.OnTick.Remove(TocWaitForOnlinePlayerData)
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function ISHealthPanel:createChildren()
|
function ISHealthPanel:createChildren()
|
||||||
ISHealthPanel_createChildren(self)
|
ISHealthPanel_createChildren(self)
|
||||||
|
|
||||||
--self.fitness:setWidth(self.fitness:getWidth() / 1.5)
|
self.fitness:setWidth(self.fitness:getWidth() / 1.2)
|
||||||
|
|
||||||
self.TOCButton = ISButton:new(self.fitness:getRight() + 25, self.healthPanel.y, 70, 20, "The Only Cure", self,
|
self.TOCButton = ISButton:new(self.fitness:getRight() + 10, self.healthPanel.y, 70, 20, "The Only Cure", self,
|
||||||
ISNewHealthPanel.onClick_TOC)
|
ISNewHealthPanel.onClick_TOC)
|
||||||
--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
|
||||||
|
|||||||
@@ -161,6 +161,7 @@ function TheOnlyCure.UpdateEveryOneMinute()
|
|||||||
-- Updates toc data in a global way, basically player:transmitModData but it works
|
-- Updates toc data in a global way, basically player:transmitModData but it works
|
||||||
-- Sends only Limbs since the other stuff is mostly static
|
-- Sends only Limbs since the other stuff is mostly static
|
||||||
if toc_data ~= nil then
|
if toc_data ~= nil then
|
||||||
|
-- TODO make it so that we dont send it constantly
|
||||||
sendClientCommand(player, 'TOC', 'ChangePlayerState', { toc_data.Limbs } )
|
sendClientCommand(player, 'TOC', 'ChangePlayerState', { toc_data.Limbs } )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -41,17 +41,13 @@ function ISCutLimb:start()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.patient == self.surgeon then
|
||||||
|
TocDamagePlayerDuringAmputation(self.patient, self.part_name)
|
||||||
|
else
|
||||||
|
sendClientCommand(self.surgeon, "TOC", "AskDamageOtherPlayer", {self.patient:getOnlineID(), self.part_name})
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- TODO this doesn't work when doing it on another player
|
|
||||||
local body_part_type = TocGetBodyPartTypeFromPartName(self.part_name)
|
|
||||||
local body_damage = self.patient:getBodyDamage()
|
|
||||||
local body_damage_part = body_damage:getBodyPart(body_part_type)
|
|
||||||
|
|
||||||
|
|
||||||
body_damage_part:setBleeding(true)
|
|
||||||
body_damage_part:setCut(true)
|
|
||||||
body_damage_part:setBleedingTime(ZombRand(10, 20))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,28 +5,26 @@
|
|||||||
local TOC_Commands = {}
|
local TOC_Commands = {}
|
||||||
|
|
||||||
|
|
||||||
--TODO how does this work
|
|
||||||
TOC_Commands["SendServer"] = function(player, arg)
|
TOC_Commands["SendServer"] = function(player, arg)
|
||||||
local otherPlayer = getPlayerByOnlineID(arg["To"])
|
local otherPlayer = getPlayerByOnlineID(arg["To"])
|
||||||
print("The Only Cure Command: ", arg['command'])
|
|
||||||
sendServerCommand(otherPlayer, "TOC", arg["command"], arg)
|
sendServerCommand(otherPlayer, "TOC", arg["command"], arg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- To make the UI Work
|
|
||||||
TOC_Commands["GetPlayerData"] = function(_, arg)
|
-- Cut Limb stuff
|
||||||
local surgeon_id = arg[1]
|
TOC_Commands["AskDamageOtherPlayer"] = function(_, arg)
|
||||||
local patient_id = arg[2]
|
|
||||||
local patient = getPlayerByOnlineID(arg[2])
|
local patient = getPlayerByOnlineID(arg[1])
|
||||||
sendServerCommand(patient, "TOC", "GivePlayerData", { surgeon_id, patient_id })
|
local patient_id = arg[1]
|
||||||
|
local part_name = arg[2]
|
||||||
|
|
||||||
|
sendServerCommand(patient, "TOC", "AcceptDamageOtherPlayer", {patient_id, part_name})
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
TOC_Commands["SendPlayerData"] = function(_, arg)
|
|
||||||
local surgeon = getPlayerByOnlineID(arg[1])
|
|
||||||
local surgeon_id = arg[1]
|
|
||||||
local toc_data = arg[2]
|
|
||||||
sendServerCommand(surgeon, "TOC", "SendTocData", { surgeon_id, toc_data })
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -40,6 +38,9 @@ TOC_Commands["AskToResetEverything"] = function(_, arg)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
------ Global Mod Data -----------
|
------ Global Mod Data -----------
|
||||||
|
|
||||||
function TOC_OnInitGlobalModData()
|
function TOC_OnInitGlobalModData()
|
||||||
@@ -49,6 +50,7 @@ end
|
|||||||
Events.OnInitGlobalModData.Add(TOC_OnInitGlobalModData)
|
Events.OnInitGlobalModData.Add(TOC_OnInitGlobalModData)
|
||||||
|
|
||||||
TOC_Commands.OnClientCommand = function(module, command, playerObj, args)
|
TOC_Commands.OnClientCommand = function(module, command, playerObj, args)
|
||||||
|
|
||||||
if module == 'TOC' and TOC_Commands[command] then
|
if module == 'TOC' and TOC_Commands[command] then
|
||||||
TOC_Commands[command](playerObj, args)
|
TOC_Commands[command](playerObj, args)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user