diff --git a/media/lua/client/TOC_CutLimb.lua b/media/lua/client/ActionsMethods/TOC_CutLimb.lua similarity index 100% rename from media/lua/client/TOC_CutLimb.lua rename to media/lua/client/ActionsMethods/TOC_CutLimb.lua diff --git a/media/lua/client/TOC_LocalActions.lua b/media/lua/client/ActionsMethods/TOC_LocalActions.lua similarity index 89% rename from media/lua/client/TOC_LocalActions.lua rename to media/lua/client/ActionsMethods/TOC_LocalActions.lua index 1ad255e..8f54b2d 100644 --- a/media/lua/client/TOC_LocalActions.lua +++ b/media/lua/client/ActionsMethods/TOC_LocalActions.lua @@ -1,3 +1,10 @@ +------------------------------------------ +-------- THE ONLY CURE BUT BETTER -------- +------------------------------------------ +------------- LOCAL ACTIONS -------------- + + + function TocCutLocal(_, player, part_name) if TocGetSawInInventory(player) ~= nil then ISTimedActionQueue.add(ISCutLimb:new(player, player, part_name)) diff --git a/media/lua/client/TOC_OperateLimb.lua b/media/lua/client/ActionsMethods/TOC_OperateLimb.lua similarity index 100% rename from media/lua/client/TOC_OperateLimb.lua rename to media/lua/client/ActionsMethods/TOC_OperateLimb.lua diff --git a/media/lua/client/TOC_ProsthesisMethods.lua b/media/lua/client/ActionsMethods/TOC_ProsthesisMethods.lua similarity index 96% rename from media/lua/client/TOC_ProsthesisMethods.lua rename to media/lua/client/ActionsMethods/TOC_ProsthesisMethods.lua index a5c74c5..56c4d81 100644 --- a/media/lua/client/TOC_ProsthesisMethods.lua +++ b/media/lua/client/ActionsMethods/TOC_ProsthesisMethods.lua @@ -37,7 +37,7 @@ end ---Unequip a prosthesis clothing item and returns it to the inventory as a normal item ---@param part_name string -function TheOnlyCure.UnequipProsthesis(patient, part_name, equipped_prosthesis) +function TocUnequipProsthesis(patient, part_name, equipped_prosthesis) local toc_data = patient:getModData().TOC diff --git a/media/lua/client/TOC_ContextMenus.lua b/media/lua/client/Interface/TOC_ContextMenus.lua similarity index 98% rename from media/lua/client/TOC_ContextMenus.lua rename to media/lua/client/Interface/TOC_ContextMenus.lua index 71bbc2a..3026e5c 100644 --- a/media/lua/client/TOC_ContextMenus.lua +++ b/media/lua/client/Interface/TOC_ContextMenus.lua @@ -1,6 +1,6 @@ -- TODO this should be moved -function TryToToResetEverythingOtherPlayer(_, patient, surgeon) +local function TryToToResetEverythingOtherPlayer(_, patient, surgeon) sendClientCommand(surgeon, "TOC", "AskToResetEverything", { patient:getOnlineID() }) end diff --git a/media/lua/client/TOC_UI.lua b/media/lua/client/Interface/TOC_UI.lua similarity index 91% rename from media/lua/client/TOC_UI.lua rename to media/lua/client/Interface/TOC_UI.lua index 38e622d..11466ed 100644 --- a/media/lua/client/TOC_UI.lua +++ b/media/lua/client/Interface/TOC_UI.lua @@ -288,6 +288,54 @@ local function OnClickTocMainUI(button, args) end +-- Generic TOC action, used in OnClickTocDescUI +local function TryTocAction(_, part_name, action, surgeon, patient) + -- TODO at this point surgeon doesnt do anything. We'll fix this later + + -- Check if SinglePlayer + if not isServer() and not isClient() then + + if action == "Cut" then + TocCutLocal(_, surgeon, part_name) + elseif action == "Operate" then + TocOperateLocal(_, surgeon, part_name, false) + elseif action == "Equip" then + TocEquipProsthesisLocal(_, surgeon, part_name) + elseif action == "Unequip" then + TocUnequipProsthesisLocal(_, surgeon, part_name) + end + else + local ui = GetConfirmUIMP() + if not ui then + CreateTocConfirmUIMP() + ui = GetConfirmUIMP() + end + + if patient == nil then + patient = surgeon + end + + + if action == "Cut" then + AskCanCutLimb(patient, part_name) + elseif action == "Operate" then + AskCanOperateLimb(patient, part_name) + elseif action == "Equip" then + AskCanEquipProsthesis(patient, part_name) + elseif action == "Unequip" then + AskCanUnequipProsthesis(patient, part_name) + end + + ui.actionAct = action + ui.partNameAct = part_name + ui.patient = patient + + SendCommandToConfirmUIMP("Wait server") + + end +end + + local function OnClickTocDescUI(button, args) -- Gets every arg from main @@ -540,6 +588,24 @@ function ISNewHealthPanel.onClick_TOC(button) Events.OnTick.Add(TocRefreshPlayerMenu) end + + -- Set the correct main title + -- TODO sizes of the menu are strange in MP, they're not consistent with SP + local separated_username = {} + + for v in string.gmatch(patient:getUsername(), "%u%l+") do + table.insert(separated_username, v) + end + + local main_title + if separated_username[1] == nil then + main_title = patient:getUsername() .. " - TOC" + else + main_title = separated_username[1] .. " " .. separated_username[2] .. " - TOC" + end + + main_ui:setTitle(main_title) + main_ui:toggle() main_ui:setInCenterOfScreen() diff --git a/media/lua/client/TOC_Client.lua b/media/lua/client/TOC_ClientCommands.lua similarity index 99% rename from media/lua/client/TOC_Client.lua rename to media/lua/client/TOC_ClientCommands.lua index 0629b0d..b7ecd81 100644 --- a/media/lua/client/TOC_Client.lua +++ b/media/lua/client/TOC_ClientCommands.lua @@ -139,7 +139,7 @@ Commands["UnequipProsthesis"] = function(arg) local arg = arg["toSend"] - TheOnlyCure.UnequipProsthesis(arg[1], arg[2]) + TheOnlyCure.TocUnequipProsthesis(arg[1], arg[2]) end diff --git a/media/lua/client/TOC_Debug.lua b/media/lua/client/TOC_Debug.lua index 7990b16..c44c920 100644 --- a/media/lua/client/TOC_Debug.lua +++ b/media/lua/client/TOC_Debug.lua @@ -1,3 +1,8 @@ +------------------------------------------ +-------- THE ONLY CURE BUT BETTER -------- +------------------------------------------ +------------ DEBUG FUNCTIONS ------------- + -- Side functions local function TocGetAmputationFullTypeFromInventory(player, side, limb) @@ -105,9 +110,15 @@ function TocResetClothingItemBodyLocation(player, side, limb) prosthesis_item = nil -- reset it end end + ----------------------------------------------------------------------- + + + +------ TEST FUNCTIONS, DON'T USE THESE!!! --------------- + function TocTestBodyLocations() local group = BodyLocations.getGroup("Human") diff --git a/media/lua/client/TOC_HelperFunctions.lua b/media/lua/client/TOC_HelperFunctions.lua index 3c1c349..d369004 100644 --- a/media/lua/client/TOC_HelperFunctions.lua +++ b/media/lua/client/TOC_HelperFunctions.lua @@ -9,7 +9,7 @@ end -- Unequip Prosthesis -function PartNameToBodyLocationProsthesis(name) +local function PartNameToBodyLocationProsthesis(name) if name == "Right_Hand" then return "TOC_ArmRightProsthesis" end if name == "Right_LowerArm" then return "TOC_ArmRightProsthesis" end if name == "Right_UpperArm" then return "TOC_ArmRightProsthesis" end @@ -18,7 +18,7 @@ function PartNameToBodyLocationProsthesis(name) if name == "Left_UpperArm" then return "TOC_ArmLeftProsthesis" end end -function PartNameToBodyLocationAmputation(name) +local function PartNameToBodyLocationAmputation(name) if name == "Right_Hand" then return "TOC_ArmRight" end if name == "Right_LowerArm" then return "TOC_ArmRight" end if name == "Right_UpperArm" then return "TOC_ArmRight" end diff --git a/media/lua/client/TOC_main.lua b/media/lua/client/TOC_Init.lua similarity index 82% rename from media/lua/client/TOC_main.lua rename to media/lua/client/TOC_Init.lua index 8a03387..147b180 100644 --- a/media/lua/client/TOC_main.lua +++ b/media/lua/client/TOC_Init.lua @@ -1,3 +1,8 @@ +------------------------------------------ +-------- THE ONLY CURE BUT BETTER -------- +------------------------------------------ +------------- INIT FUNCTIONS ------------- + if not TheOnlyCure then TheOnlyCure = {} end @@ -22,8 +27,6 @@ local function TocCutLimbForTrait(player, limbs_data, part_name) limbs_data[v].is_cicatrized = true end end - --- Sub function of TocSetInitData local function TocUpdateBaseData(mod_data) -- TODO The prosthetic knife needs to be a weapon first and foremost, so other than a @@ -197,8 +200,6 @@ local function TocSetInitData(mod_data, player) end - - function TheOnlyCure.InitTheOnlyCure(_, player) local mod_data = player:getModData() @@ -211,8 +212,7 @@ function TheOnlyCure.InitTheOnlyCure(_, player) end - -function TheOnlyCure.DeclareTraits() +local function TocDeclareTraits() local amp1 = TraitFactory.addTrait("Amputee_Hand", getText("UI_trait_Amputee_Hand"), -8, getText("UI_trait_Amputee_Hand_desc"), false, false) amp1:addXPBoost(Perks.Left_Hand, 4) @@ -232,52 +232,6 @@ function TheOnlyCure.DeclareTraits() TraitFactory.setMutualExclusive("Amputee_LowerArm", "Amputee_UpperArm") end -function TryTocAction(_, part_name, action, surgeon, patient) - -- TODO add checks so that we don't show these menus if a player has already beeen operated or amputated - -- TODO at this point surgeon doesnt do anything. We'll fix this later - - -- Check if SinglePlayer - if not isServer() and not isClient() then - - if action == "Cut" then - TocCutLocal(_, surgeon, part_name) - elseif action == "Operate" then - TocOperateLocal(_, surgeon, part_name, false) - elseif action == "Equip" then - TocEquipProsthesisLocal(_, surgeon, part_name) - elseif action == "Unequip" then - TocUnequipProsthesisLocal(_, surgeon, part_name) - end - else - local ui = GetConfirmUIMP() - if not ui then - CreateTocConfirmUIMP() - ui = GetConfirmUIMP() - end - - if patient == nil then - patient = surgeon - end - - - if action == "Cut" then - AskCanCutLimb(patient, part_name) - elseif action == "Operate" then - AskCanOperateLimb(patient, part_name) - elseif action == "Equip" then - AskCanEquipProsthesis(patient, part_name) - elseif action == "Unequip" then - AskCanUnequipProsthesis(patient, part_name) - end - - ui.actionAct = action - ui.partNameAct = part_name - ui.patient = patient - - SendCommandToConfirmUIMP("Wait server") - - end -end Events.OnCreatePlayer.Add(TheOnlyCure.InitTheOnlyCure) -Events.OnGameBoot.Add(TheOnlyCure.DeclareTraits) +Events.OnGameBoot.Add(TocDeclareTraits) diff --git a/media/lua/client/TimedActions/ISUninstallProsthesis.lua b/media/lua/client/TimedActions/ISUninstallProsthesis.lua index e55bda7..0326a34 100644 --- a/media/lua/client/TimedActions/ISUninstallProsthesis.lua +++ b/media/lua/client/TimedActions/ISUninstallProsthesis.lua @@ -58,7 +58,7 @@ function ISUninstallProsthesis:perform() SendUnequipProsthesis(self.patient, self.part_name, self.item) else - TheOnlyCure.UnequipProsthesis(self.patient, self.part_name, self.item) + TheOnlyCure.TocUnequipProsthesis(self.patient, self.part_name, self.item) end ISBaseTimedAction.perform(self) diff --git a/media/lua/shared/translate/EN/Sandbox_EN.txt b/media/lua/shared/translate/EN/Sandbox_EN.txt index 4d7abb0..38a7342 100644 --- a/media/lua/shared/translate/EN/Sandbox_EN.txt +++ b/media/lua/shared/translate/EN/Sandbox_EN.txt @@ -6,4 +6,9 @@ Sandbox_EN = { Sandbox_TOC_CicatrizationSpeedMultiplier = "Cicatrization speed multiplier", Sandbox_TOC_CicatrizationSpeedMultiplier_tooltip = "Customize this to make the cicatrization process faster", + + Sandbox_TOC_AmputationTimeMultiplier = "Amputation Time Scaler", + Sandbox_TOC_AmputationTimeMultiplier_tooltip = "Scales the amount of time multplying added after amputation" + + } \ No newline at end of file diff --git a/media/sandbox-options.txt b/media/sandbox-options.txt index 6cb0242..7e46a18 100644 --- a/media/sandbox-options.txt +++ b/media/sandbox-options.txt @@ -20,4 +20,16 @@ option TOC.CicatrizationSpeedMultiplier page = TOC, translation = TOC_CicatrizationSpeedMultiplier, +} + +option TOC.AmputationTimeMultiplier +{ + type = integer, + min = 1, + max = 10, + default = 1, + page = TOC, + translation = TOC_AmputationTimeMultiplier + + } \ No newline at end of file