trying to fix menu for MP
This commit is contained in:
@@ -49,7 +49,7 @@ local function otherPlayerLocal(_, partName, action, surgeon, patient)
|
||||
ui.actionAct = action;
|
||||
ui.partNameAct = partName;
|
||||
ui.patient = patient;
|
||||
--SetConfirmUIMP("Wait server")
|
||||
SetConfirmUIMP("Wait server")
|
||||
|
||||
|
||||
|
||||
@@ -139,8 +139,6 @@ function ISWorldObjectContextMenu.OnFillTOCMenu(player, context, worldObjects, t
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- why local?
|
||||
function ISWorldObjectContextMenu.OnFillOperateWithOven(player, context, worldObjects, test)
|
||||
local player_obj = getSpecificPlayer(player)
|
||||
--local clickedPlayer
|
||||
@@ -181,23 +179,6 @@ end
|
||||
|
||||
|
||||
|
||||
-- if instanceof(vtest, "IsoStove") and (player_obj:HasTrait("Brave") or player_obj:getPerkLevel(Perks.Strength) >= 6) then
|
||||
-- --if v:getCurrentTemperature() > 250 then
|
||||
-- local rootMenu = context:addOption(getText('UI_ContextMenu_OperateOven'), worldObjects, nil);
|
||||
-- local subMenu = context:getNew(context);
|
||||
-- context:addSubMenu(rootMenu, subMenu)
|
||||
|
||||
-- for k_bodypart, v_bodypart in pairs(GetBodyParts()) do
|
||||
-- -- todo this is awful but it should work
|
||||
-- if modData.TOC[v_bodypart].is_cut and not modData.TOC[v_bodypart].is_operated then
|
||||
-- subMenu:addOption(getText('UI_ContextMenu_' .. v_bodypart), worldObjects, operateLocal, v_bodypart);
|
||||
|
||||
-- end
|
||||
|
||||
|
||||
-- end
|
||||
-- --end
|
||||
-- end
|
||||
|
||||
|
||||
|
||||
@@ -205,46 +186,5 @@ end
|
||||
|
||||
|
||||
|
||||
-- for _,object in ipairs(worldobjects) do
|
||||
-- local square = object:getSquare()
|
||||
-- if square then
|
||||
-- local movingObjects = square:getMovingObjects()
|
||||
-- for i = 0, movingObjects:size() - 1 do
|
||||
-- local o = movingObjects:get(i)
|
||||
-- if instanceof(o, "IsoPlayer") then
|
||||
-- clickedPlayer = o;
|
||||
-- print("Found player")
|
||||
|
||||
-- end
|
||||
-- end
|
||||
-- if clickedPlayer then
|
||||
-- -- Pretty sure this check is kinda broken
|
||||
-- if not ((-1 < clickedPlayer:getX() - player:getX() and clickedPlayer:getX() - player:getX() < 1) and (-1 < clickedPlayer:getY() - player:getY() and clickedPlayer:getY() - player:getY() < 1)) then
|
||||
-- return false;
|
||||
-- end
|
||||
-- local rootOption = context:addOption("The Only Cure on " .. clickedPlayer:getUsername());
|
||||
-- local rootMenu = context:getNew(context);
|
||||
-- local cutOption = rootMenu:addOption("Cut");
|
||||
-- local operateOption = rootMenu:addOption("Operate");
|
||||
-- local cutMenu = context:getNew(context);
|
||||
-- local operateMenu = context:getNew(context);
|
||||
|
||||
-- context:addSubMenu(rootOption, rootMenu);
|
||||
-- context:addSubMenu(cutOption, cutMenu);
|
||||
-- context:addSubMenu(operateOption, operateMenu);
|
||||
-- -- todo add checks so that we don't show these menus if a player has already beeen operated or amputated
|
||||
-- for k, v in ipairs(GetBodyParts()) do
|
||||
-- cutMenu:addOption(getText('UI_ContextMenu_' .. v), worldobjects, otherPlayerLocal, v, "Cut", clickedPlayer)
|
||||
-- operateMenu:addOption(getText('UI_ContextMenu_' .. v), worldobjects, otherPlayerLocal, v, "Operate", clickedPlayer);
|
||||
|
||||
-- end
|
||||
|
||||
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
|
||||
|
||||
--Events.OnTick.Add(TheOnlyCure.CheckState);
|
||||
Events.OnFillWorldObjectContextMenu.Add(ISWorldObjectContextMenu.OnFillOperateWithOven) -- this is probably too much
|
||||
Events.OnFillWorldObjectContextMenu.Add(ISWorldObjectContextMenu.OnFillTOCMenu)
|
||||
@@ -130,8 +130,12 @@ end
|
||||
-- end Usefull
|
||||
|
||||
-- Function to update text/button of UIs
|
||||
local function setDescUI(partName)
|
||||
local modData = getPlayer():getModData().TOC;
|
||||
local function setDescUI(player, partName)
|
||||
|
||||
--we can easily fix this crap from here for MP compat
|
||||
|
||||
-- TODO set correct player
|
||||
local modData = player:getModData().TOC;
|
||||
local partData = modData[partName];
|
||||
descUI["textTitle"]:setText(getDisplayText_TOC(partName));
|
||||
descUI.partNameAct = partName;
|
||||
@@ -384,13 +388,16 @@ end
|
||||
local function mainPress(button, args)
|
||||
descUI:open();
|
||||
descUI:setPositionPixel(mainUI:getRight(), mainUI:getY());
|
||||
setDescUI(args.part);
|
||||
setDescUI(args.player, args.part)
|
||||
end
|
||||
|
||||
local function descPress(button, args)
|
||||
local player = getPlayer();
|
||||
local playerInv = player:getInventory();
|
||||
if args.option == "Cut" then
|
||||
|
||||
|
||||
-- TODO Change to correct player
|
||||
local modData = player:getModData().TOC;
|
||||
-- Do not cut if prothesis equip
|
||||
if (string.find(descUI.partNameAct, "Right") and (modData["RightHand"].has_prothesis_equipped or modData["RightForearm"].has_prothesis_equipped))
|
||||
@@ -418,27 +425,42 @@ end
|
||||
|
||||
|
||||
-- Make the UIS
|
||||
local function makeMainUI()
|
||||
local function makeMainUI(character)
|
||||
|
||||
|
||||
mainUI = NewUI();
|
||||
mainUI:setTitle("The only cure main menu");
|
||||
mainUI:setTitle("The Only Cure Menu");
|
||||
mainUI:setWidthPercent(0.1);
|
||||
|
||||
mainUI:addImageButton("b11", "", mainPress);
|
||||
mainUI["b11"]:addArg("part", "RightArm");
|
||||
mainUI:addImageButton("b11", "", mainPress)
|
||||
mainUI["b11"]:addArg("part", "RightArm")
|
||||
mainUI["b11"]:addArg("player", character)
|
||||
|
||||
|
||||
mainUI:addImageButton("b12", "", mainPress);
|
||||
mainUI["b12"]:addArg("part", "LeftArm");
|
||||
mainUI["b12"]:addArg("player", character)
|
||||
|
||||
mainUI:nextLine();
|
||||
|
||||
mainUI:addImageButton("b21", "", mainPress);
|
||||
mainUI["b21"]:addArg("part", "RightForearm");
|
||||
mainUI["b21"]:addArg("player", character)
|
||||
|
||||
|
||||
mainUI:addImageButton("b22", "", mainPress);
|
||||
mainUI["b22"]:addArg("part", "LeftForearm");
|
||||
mainUI["b22"]:addArg("player", character)
|
||||
|
||||
mainUI:nextLine();
|
||||
|
||||
mainUI:addImageButton("b31", "", mainPress);
|
||||
mainUI["b31"]:addArg("part", "RightHand");
|
||||
mainUI["b31"]:addArg("player", character)
|
||||
|
||||
mainUI:addImageButton("b32", "", mainPress);
|
||||
mainUI["b32"]:addArg("part", "LeftHand");
|
||||
mainUI["b32"]:addArg("player", character)
|
||||
|
||||
mainUI:saveLayout();
|
||||
end
|
||||
@@ -469,7 +491,7 @@ local function makeDescUI()
|
||||
descUI:addEmpty();
|
||||
descUI:nextLine();
|
||||
|
||||
descUI:addText("textEtat", "Is Cut !", "Medium", "Center");
|
||||
descUI:addText("textEtat", "Is Cut!", "Medium", "Center");
|
||||
descUI["textEtat"]:setColor(1, 1, 0, 0);
|
||||
descUI:nextLine();
|
||||
|
||||
@@ -547,6 +569,24 @@ function MakeConfirmUIMP()
|
||||
confirmUIMP:close();
|
||||
end
|
||||
|
||||
|
||||
function ISHealthPanel:OnCreateTheOnlyCureUI()
|
||||
|
||||
-- how do we pass the correct player here?
|
||||
--print(self.character)
|
||||
if ISHealthPanel.otherPlayer then
|
||||
makeMainUI(ISHealthPanel.otherPlayer)
|
||||
else
|
||||
makeMainUI(getPlayer())
|
||||
end
|
||||
makeDescUI()
|
||||
makeConfirmUI()
|
||||
|
||||
if isClient() then MakeConfirmUIMP() end
|
||||
mainUI:close()
|
||||
end
|
||||
|
||||
|
||||
local function onCreateUI()
|
||||
makeMainUI();
|
||||
makeDescUI();
|
||||
@@ -555,14 +595,15 @@ local function onCreateUI()
|
||||
mainUI:close();
|
||||
end
|
||||
|
||||
Events.OnCreateUI.Add(onCreateUI)
|
||||
Events.OnCreateUI.Add(ISHealthPanel.OnCreateTheOnlyCureUI)
|
||||
|
||||
|
||||
-- Add button to health panel
|
||||
function ISNewHealthPanel.onClick_TOC(button)
|
||||
mainUI:toggle();
|
||||
mainUI:setInCenterOfScreen();
|
||||
setImageMainUI();
|
||||
|
||||
mainUI:toggle()
|
||||
mainUI:setInCenterOfScreen()
|
||||
setImageMainUI()
|
||||
end
|
||||
|
||||
local ISHealthPanel_createChildren = ISHealthPanel.createChildren
|
||||
@@ -572,8 +613,9 @@ function ISHealthPanel:createChildren()
|
||||
|
||||
self.fitness:setWidth(self.fitness:getWidth()/1.5);
|
||||
|
||||
self.TOCButton = ISButton:new(self.fitness:getRight(), self.healthPanel.y, 20, 20, "", self, ISNewHealthPanel.onClick_TOC);
|
||||
self.TOCButton:setImage(getTexture("media/ui/TOC/iconForMenu.png"));
|
||||
--TODO make it bigger
|
||||
self.TOCButton = ISButton:new(self.fitness:getRight(), self.healthPanel.y, 20, 20, "", self, ISNewHealthPanel.onClick_TOC)
|
||||
self.TOCButton:setImage(getTexture("media/ui/TOC/iconForMenu.png"))
|
||||
self.TOCButton.anchorTop = false
|
||||
self.TOCButton.anchorBottom = true
|
||||
self.TOCButton:initialise();
|
||||
@@ -589,4 +631,8 @@ local ISHealthPanel_render = ISHealthPanel.render
|
||||
function ISHealthPanel:render()
|
||||
ISHealthPanel_render(self);
|
||||
self.TOCButton:setY(self.fitness:getY());
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user