Rethinking structure a bit
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
local StaticData = require("TOC/StaticData")
|
||||
local ModDataHandler = require("TOC/Handlers/ModDataHandler")
|
||||
local DataController = require("TOC/Controllers/DataController")
|
||||
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
|
||||
local CutLimbHandler = require("TOC/UI/CutLimbInteractions")
|
||||
local WoundCleaningHandler = require("TOC/UI/WoundCleaningInteraction")
|
||||
|
||||
local CutLimbHandler = require("TOC/UI/Interactions/CutLimbHandler")
|
||||
local WoundCleaningHandler = require("TOC/UI/Interactions/WoundCleaningHandler")
|
||||
------------------------
|
||||
|
||||
|
||||
|
||||
local isReady = false
|
||||
|
||||
@@ -105,7 +109,7 @@ end
|
||||
local limbName = highestAmputations[side]
|
||||
TOC_DEBUG.print("Drawing " .. tostring(limbName) .. " for " .. username)
|
||||
|
||||
local cicTime = ModDataHandler.GetInstance(username):getCicatrizationTime(limbName)
|
||||
local cicTime = DataController.GetInstance(username):getCicatrizationTime(limbName)
|
||||
redColor = GetColorFromCicatrizationTime(cicTime, limbName)
|
||||
|
||||
local sexPl
|
||||
@@ -204,16 +208,16 @@ end
|
||||
local bodyPartTypeStr = BodyPartType.ToString(bodyPart:getType())
|
||||
local limbName = StaticData.LIMBS_IND_STR[bodyPartTypeStr]
|
||||
if limbName then
|
||||
local modDataHandler = ModDataHandler.GetInstance(username)
|
||||
if modDataHandler:getIsCut(limbName) and modDataHandler:getIsVisible(limbName) then
|
||||
if modDataHandler:getIsCicatrized(limbName) then
|
||||
if modDataHandler:getIsCauterized(limbName) then
|
||||
local dcInst = DataController.GetInstance(username)
|
||||
if dcInst:getIsCut(limbName) and dcInst:getIsVisible(limbName) then
|
||||
if dcInst:getIsCicatrized(limbName) then
|
||||
if dcInst:getIsCauterized(limbName) then
|
||||
self:drawText("- " .. getText("IGUI_HealthPanel_Cauterized"), x, y, 0.58, 0.75, 0.28, 1, UIFont.Small)
|
||||
else
|
||||
self:drawText("- " .. getText("IGUI_HealthPanel_Cicatrized"), x, y, 0.28, 0.89, 0.28, 1, UIFont.Small)
|
||||
end
|
||||
else
|
||||
local cicaTime = modDataHandler:getCicatrizationTime(limbName)
|
||||
local cicaTime = dcInst:getCicatrizationTime(limbName)
|
||||
|
||||
-- Show it in percentage
|
||||
local maxCicaTime = StaticData.LIMBS_CICATRIZATION_TIME_IND_NUM[limbName]
|
||||
@@ -221,7 +225,7 @@ end
|
||||
self:drawText("- " .. getText("IGUI_HealthPanel_Cicatrization") .. string.format(" %.2f", percentage) .. "%", x, y, 0.89, 0.28, 0.28, 1, UIFont.Small)
|
||||
y = y + fontHgt
|
||||
|
||||
local scaledDirtyness = math.floor(modDataHandler:getWoundDirtyness(limbName) * 100)
|
||||
local scaledDirtyness = math.floor(dcInst:getWoundDirtyness(limbName) * 100)
|
||||
self:drawText("- " .. getText("IGUI_HealthPanel_WoundDirtyness") .. string.format(" %d", scaledDirtyness) .. "%", x, y, 0.89, 0.28, 0.28, 1, UIFont.Small)
|
||||
end
|
||||
y = y + fontHgt
|
||||
@@ -247,7 +251,7 @@ end
|
||||
end
|
||||
|
||||
local patientUsername = self:getPatient():getUsername()
|
||||
local mdh = ModDataHandler.GetInstance(patientUsername)
|
||||
local mdh = DataController.GetInstance(patientUsername)
|
||||
for i=1,bodyParts:size() do
|
||||
local bodyPart = bodyParts:get(i-1)
|
||||
local bodyPartTypeStr = BodyPartType.ToString(bodyPart:getType())
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
local BaseHandler = require("TOC/UI/HealthPanelBaseHandler")
|
||||
local CutLimbAction = require("TOC/TimedActions/CutLimbAction")
|
||||
local BaseHandler = require("TOC/UI/Interactions/HealthPanelBaseHandler")
|
||||
local StaticData = require("TOC/StaticData")
|
||||
local ModDataHandler = require("TOC/Handlers/ModDataHandler")
|
||||
local DataController = require("TOC/Controllers/DataController")
|
||||
|
||||
local CutLimbAction = require("TOC/TimedActions/CutLimbAction")
|
||||
---------------------
|
||||
|
||||
-- TODO Add interaction to cut and bandage!
|
||||
@@ -96,7 +97,7 @@ local function AddInvAmputationOptions(player, context, sawItem, stitchesItem, b
|
||||
|
||||
for i = 1, #StaticData.LIMBS_STR do
|
||||
local limbName = StaticData.LIMBS_STR[i]
|
||||
if not ModDataHandler.GetInstance():getIsCut(limbName) then
|
||||
if not DataController.GetInstance():getIsCut(limbName) then
|
||||
local limbTranslatedName = getText("ContextMenu_Limb_" .. limbName)
|
||||
subMenu:addOption(limbTranslatedName, player, PerformAction, player, limbName, sawItem, stitchesItem, bandageItem)
|
||||
end
|
||||
@@ -177,7 +178,7 @@ end
|
||||
function CutLimbHandler:addToMenu(context)
|
||||
TOC_DEBUG.print("CutLimbHandler addToMenu")
|
||||
local types = self:getAllItemTypes(self.items.ITEMS)
|
||||
if #types > 0 and StaticData.BODYLOCS_IND_BPT[self.limbName] and not ModDataHandler.GetInstance():getIsCut(self.limbName) then
|
||||
if #types > 0 and StaticData.BODYLOCS_IND_BPT[self.limbName] and not DataController.GetInstance():getIsCut(self.limbName) then
|
||||
TOC_DEBUG.print("addToMenu, types > 0")
|
||||
for i=1, #types do
|
||||
context:addOption(getText("ContextMenu_Amputate"), self, self.onMenuOptionSelected, types[i])
|
||||
@@ -199,7 +200,7 @@ end
|
||||
function CutLimbHandler:isValid()
|
||||
TOC_DEBUG.print("CutLimbHandler isValid")
|
||||
self:checkItems()
|
||||
return not ModDataHandler.GetInstance():getIsCut(self.limbName)
|
||||
return not DataController.GetInstance():getIsCut(self.limbName)
|
||||
end
|
||||
|
||||
function CutLimbHandler:perform(previousAction, itemType)
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
local BaseHandler = require("TOC/UI/HealthPanelBaseHandler")
|
||||
local BaseHandler = require("TOC/UI/Interactions/HealthPanelBaseHandler")
|
||||
local CommonMethods = require("TOC/CommonMethods")
|
||||
local ModDataHandler = require("TOC/Handlers/ModDataHandler")
|
||||
local DataController = require("TOC/Controllers/DataController")
|
||||
|
||||
local CleanWoundAction = require("TOC/TimedActions/CleanWoundAction")
|
||||
-------------------------
|
||||
@@ -60,11 +60,11 @@ function WoundCleaningHandler:isValid()
|
||||
-- todo get username
|
||||
if self.limbName == nil then return false end
|
||||
|
||||
local modDataHandler = ModDataHandler.GetInstance(self.username)
|
||||
local dcInst = DataController.GetInstance(self.username)
|
||||
|
||||
--and modDataHandler:getWoundDirtyness(self.limbName) > 0.1
|
||||
--and dcInst:getWoundDirtyness(self.limbName) > 0.1
|
||||
|
||||
return modDataHandler:getIsCut(self.limbName) and not modDataHandler:getIsCicatrized(self.limbName)
|
||||
return dcInst:getIsCut(self.limbName) and not dcInst:getIsCicatrized(self.limbName)
|
||||
--return self:getItemOfType(self.items.ITEMS, itemType)
|
||||
end
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
-- TODO Separate UI to craft prosthesis... No just use the crafting menu you mook
|
||||
@@ -1,5 +1,5 @@
|
||||
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
|
||||
local ModDataHandler = require("TOC/Handlers/ModDataHandler")
|
||||
local DataController = require("TOC/Controllers/DataController")
|
||||
---------------
|
||||
|
||||
|
||||
@@ -17,14 +17,14 @@ Events.OnFillInventoryObjectContextMenu.Add(AddInventorySurgeryMenu)
|
||||
|
||||
-- TODO We need a class to handle operations, this is just a placeholder
|
||||
local function Cauterize(limbName)
|
||||
local modDataHandler = ModDataHandler.GetInstance()
|
||||
modDataHandler:setCicatrizationTime(limbName, 0)
|
||||
modDataHandler:setIsCicatrized(limbName, true)
|
||||
modDataHandler:setIsCauterized(limbName, true)
|
||||
local dcInst = DataController.GetInstance()
|
||||
dcInst:setCicatrizationTime(limbName, 0)
|
||||
dcInst:setIsCicatrized(limbName, true)
|
||||
dcInst:setIsCauterized(limbName, true)
|
||||
|
||||
-- we don't care bout the depended limbs, since they're alread "cicatrized"
|
||||
|
||||
modDataHandler:apply()
|
||||
dcInst:apply()
|
||||
end
|
||||
|
||||
---@param playerNum number
|
||||
@@ -36,8 +36,8 @@ local function AddOvenContextMenu(playerNum, context, worldObjects, test)
|
||||
|
||||
local pl = getSpecificPlayer(playerNum)
|
||||
|
||||
local modDataHandler = ModDataHandler.GetInstance()
|
||||
if not modDataHandler:getIsAnyLimbCut() then return end
|
||||
local dcInst = DataController.GetInstance()
|
||||
if not dcInst:getIsAnyLimbCut() then return end
|
||||
local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(pl:getUsername())
|
||||
|
||||
local stoveObj = nil
|
||||
@@ -63,7 +63,7 @@ local function AddOvenContextMenu(playerNum, context, worldObjects, test)
|
||||
|
||||
-- We need to let the player cauterize ONLY the visible one!
|
||||
local limbName = k
|
||||
if modDataHandler:getIsVisible(limbName) and not modDataHandler:getIsCicatrized(limbName) then
|
||||
if dcInst:getIsVisible(limbName) and not dcInst:getIsCicatrized(limbName) then
|
||||
if addMainOption == false then
|
||||
-- Adds the cauterize option ONLY when it's needed
|
||||
local optionMain = context:addOption(getText("ContextMenu_Cauterize"), nil)
|
||||
|
||||
Reference in New Issue
Block a user