Jump to content

Adding a tab to the info panel window


Squall4120

Recommended Posts

Hello,

I've been looking for a good way to add a new tab to the info panel window that has the character info, skills, health, protection, and temperature panel tabs. I came up with a solution, but I'm not entirely satisfied with it. I did some searching on the forums and I didn't see a solution. Sorry if I missed it.

 

I tried the following and it works for the most part except when you take over player 1 with a controller. The game recreates their info panel window and the new one won't have the new tab. Otherwise, starting a new character with either keyboard or controller will work.

local function createTestPanel(playerNum)
    local infoPanel = getPlayerInfoPanel(playerNum)
    if not infoPanel then return end

    infoPanel.testView = ISTestPanel:new(getSpecificPlayer(playerNum), 0, 8, infoPanel.width, infoPanel.height - 8)
    infoPanel.testView:initialise()
    infoPanel.testView.infoText = "Test"
    infoPanel.panel:addView("Test", infoPanel.testView)
end

local function createTestJoypadPanel()
    local playerNum = 0
    local joypadData = JoypadState.joypads[playerNum + 1]
    if joypadData.controller then
        createTestPanel(playerNum)
    end
end

-----

Events.OnCreatePlayer.Add(createTestPanel)
Events.OnGameStart.Add(createTestJoypadPanel)

 

I found the following solution that will always work every time the info panel window is created, but overwriting a function just feels bad.

local oldCreateChildren = ISCharacterInfoWindow.createChildren

function ISCharacterInfoWindow:createChildren()
    oldCreateChildren(self)
    self.testView = ISTestPanel:new(getSpecificPlayer(self.playerNum), 0, 8, self.width, self.height - 8)
    self.testView:initialise()
    self.testView.infoText = "Test"
    self.panel:addView("Test", self.testView)
end

 

Does anyone have a better solution they're willing to share?

 

Thanks in advance!

Edited by Squall4120
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...