Jump to content

[HELP] GUI help menu on open?


Fabio(GNR)

Recommended Posts

I created a menu with GUIeditor so how do i replace the regular help with the code? code:

GUIEditor_Window = {} 
GUIEditor_Memo = {} 
GUIEditor_Checkbox = {} 
  
GUIEditor_Window[1] = guiCreateWindow(353,134,869,468,"Guns N Roses - welcome - Help",false) 
GUIEditor_Memo[1] = guiCreateMemo(79,55,781,223,"TEXT",false,GUIEditor_Window[1]) 
guiMemoSetReadOnly(GUIEditor_Memo[1],true) 
GUIEditor_Checkbox[1] = guiCreateCheckBox(195,345,20,16,"",false,false,GUIEditor_Window[1]) 
GUIEditor_Memo[2] = guiCreateMemo(231,348,225,29," I like GUNS N ROSES",false,GUIEditor_Window[1]) 
guiMemoSetReadOnly(GUIEditor_Memo[2],true) 
  
  
  
  

Link to comment
with help menu do you mean the one that popups with F9? if yes then you must edit the "helpmanager" if i'm right.

Yes i mean that, Yes i tried but i cant see were to edit it, And does that work with GUIeditor? I only want my own GUI menu not the regular one :D Thanks for quick response !

You can just copy the cords from the GUI window and paste it on the one you want to edit..

Link to comment
with help menu do you mean the one that popups with F9? if yes then you must edit the "helpmanager" if i'm right.

Yes i mean that, Yes i tried but i cant see were to edit it, And does that work with GUIeditor? I only want my own GUI menu not the regular one :D Thanks for quick response !

You can just copy the cords from the GUI window and paste it on the one you want to edit..

long quote, but thanks but im a real noob :D were is that? there are like many guiaddwindow stuff and like that Thanks

And btw i would like to keep it that it opens on joining right?

Link to comment
wndHelp  = guiCreateWindow(.2, .2, .6, .6, "Help", true) 
wndBlock = guiCreateWindow(0, 0, 1, 1, "", true) 
tPanel   = guiCreateTabPanel(0, .05, 1, .85, true, wndHelp) 
btnClose = guiCreateButton(.4, .92, .2, .08, "Close", true, wndHelp) 
  
memo[resource] = guiCreateMemo(.05, .05, .9, .9, helptext, true, tab[resource]) 

Link to comment
wndHelp  = guiCreateWindow(.2, .2, .6, .6, "Help", true) 
wndBlock = guiCreateWindow(0, 0, 1, 1, "", true) 
tPanel   = guiCreateTabPanel(0, .05, 1, .85, true, wndHelp) 
btnClose = guiCreateButton(.4, .92, .2, .08, "Close", true, wndHelp) 
  
memo[resource] = guiCreateMemo(.05, .05, .9, .9, helptext, true, tab[resource]) 

Sorry, but could you explain more precise, im really new to all of this and the format of GUIeditor is different then helpmanager :/ should i post code of helpmanager? And again, Thanks

Link to comment
local localPlayer = getLocalPlayer() 
local rootElement = getRootElement() 
local thisResourceRoot = getResourceRootElement(getThisResource()) 
local pagesXml 
  
local wndHelp, wndBlock, tPanel, btnClose 
local tab = {} 
local memo = {} 
local popupQueue = {} 
  
local HELP_KEY = "F9" 
local HELP_COMMAND = "gamehelp" 
local POPUP_TIMEOUT = 15000 --ms 
local FADE_DELTA = .03 --alpha per frame 
local MAX_ALPHA = .9 
  
addEvent("doShowHelp", true) 
addEvent("doHideHelp", true) 
addEvent("onHelpShown") 
addEvent("onHelpHidden") 
  
addEventHandler("onClientResourceStart", thisResourceRoot,  
    function () 
        wndHelp  = guiCreateWindow(196,93,622,437, "Help", false) 
        wndBlock = guiCreateWindow(0, 0, 1, 1, "", true) 
        tPanel   = guiCreateTabPanel(10,29,602,363, false, wndHelp) 
        btnClose = guiCreateButton(245,396,139,23, "Close", false, wndHelp) 
  
        guiSetVisible(wndHelp, false) 
        guiSetVisible(wndBlock, false) 
         
        guiWindowSetSizable(wndHelp, false) 
        guiSetAlpha(wndBlock, 0) 
         
        addEventHandler("onClientGUIClick", btnClose, 
            function() 
                if source == this then 
                    clientToggleHelp(false) 
                end 
            end 
        ) 
         
        pagesXml = xmlLoadFile("seen.xml") 
        if not pagesXml then 
            pagesXml = xmlCreateFile("seen.xml", "seen") 
        end 
         
        for i, resourceRoot in ipairs(getElementsByType("resource")) do --!w 
            local resource = getResourceFromName(getElementID(resourceRoot)) 
            if resource then 
                addHelpTabFromXML(resource) 
            end 
        end 
         
        addCommandHandler(HELP_COMMAND, clientToggleHelp) 
        bindKey(HELP_KEY, "down", clientToggleHelp) 
    end 
) 
  
addEventHandler("onClientResourceStop", thisResourceRoot, 
    function() 
        showCursor(false) 
    end 
) 
  
-- exports 
function showHelp() 
    return clientToggleHelp(true) 
end 
addEventHandler("doShowHelp", rootElement, showHelp) 
  
function hideHelp() 
    return clientToggleHelp(false) 
end 
addEventHandler("doHideHelp", rootElement, hideHelp) 
  
function addHelpTab(resource, showPopup) 
  
    if showPopup == nil then 
        showPopup = true 
    end 
     
    -- block duplicates 
    if tab[resource] then 
        return false 
    end 
     
    local tabtext = getResourceName(resource) 
     
    local helpnode = getResourceConfig(":" .. getResourceName(resource) .. "/help.xml") 
     
    if helpnode then 
     
        local nameattribute = xmlNodeGetAttribute(helpnode, "title"); 
         
        if nameattribute then 
            tabtext = nameattribute; 
        end 
         
    end 
  
    tab[resource] = guiCreateTab( tabtext , tPanel) 
     
    if showPopup then 
        addHelpPopup(resource) 
    end 
     
    return tab[resource] 
end 
  
function removeHelpTab(resource) 
    if not tab[resource] then 
        return false 
    end 
     
    if memo[resource] then 
        destroyElement(memo[resource]) 
        memo[resource] = nil 
    end 
     
    guiDeleteTab(tab[resource], tPanel) 
    tab[resource] = nil 
     
    return true 
end 
addEventHandler("onClientResourceStop", rootElement, removeHelpTab) 
  
--private 
function addHelpTabFromXML(resource) 
    -- block duplicates 
    if tab[resource] then 
        return false 
    end 
         
    local helpnode = getResourceConfig(":"..getResourceName(resource).."/help.xml") 
    if helpnode then 
        local helptext = xmlNodeGetValue(helpnode) 
        local showPopup = not (xmlNodeGetAttribute(helpnode, "popup") == "no") 
        if helptext then 
            addHelpTab(resource, showPopup) 
            memo[resource] = guiCreateMemo(10,7,583,324, helptext, false, tab[resource]) 
            guiMemoSetReadOnly(memo[resource], true) 
        end 
    end 
end 
addEventHandler("onClientResourceStart", rootElement, addHelpTabFromXML) 
  
function clientToggleHelp(state) 
    if state ~= true and state ~= false then 
        state = not guiGetVisible(wndHelp) 
    end 
    guiSetVisible(wndHelp, state) 
    guiSetVisible(wndBlock, state) 
    if state == true then 
        triggerEvent("onHelpShown", localPlayer) 
        guiBringToFront(wndBlock) 
        guiBringToFront(wndHelp) 
        showCursor(true) 
    else 
        triggerEvent("onHelpHidden", localPlayer) 
        showCursor(false) 
    end 
    return true 
end 
  
local function fadeIn(wnd) 
    local function raiseAlpha() 
        local newAlpha = guiGetAlpha(wnd) + FADE_DELTA 
        if newAlpha <= MAX_ALPHA then 
            guiSetAlpha(wnd, newAlpha) 
        else 
            removeEventHandler("onClientRender", rootElement, raiseAlpha) 
        end 
    end 
    addEventHandler("onClientRender", rootElement, raiseAlpha) 
end 
  
local function fadeOut(wnd) 
    local function lowerAlpha() 
        local newAlpha = guiGetAlpha(wnd) - FADE_DELTA 
        if newAlpha >= 0 then 
            guiSetAlpha(wnd, newAlpha) 
        else 
            removeEventHandler("onClientRender", rootElement, lowerAlpha) 
            destroyElement(wnd) 
             
            table.remove(popupQueue, 1) 
            if #popupQueue > 0 then 
                showHelpPopup(popupQueue[1]) 
            end 
        end 
    end 
    addEventHandler("onClientRender", rootElement, lowerAlpha) 
end 
  
function addHelpPopup(resource) 
    local xmlContents = xmlNodeGetValue(pagesXml) 
    local seenPages = split(xmlContents, string.byte(',')) 
    local resourceName = getResourceName(resource) 
    for i, page in ipairs(seenPages) do 
        if page == resourceName then 
            return 
        end 
    end 
    xmlNodeSetValue(pagesXml, xmlContents..resourceName..",") 
    xmlSaveFile(pagesXml) 
  
    table.insert(popupQueue, resource) 
    if #popupQueue == 1 then 
        showHelpPopup(resource) 
    end 
end 
  
function showHelpPopup(resource) 
    local screenX, screenY = guiGetScreenSize() 
    local wndPopup = guiCreateWindow(0, screenY - 20, screenX, 0, '', false) --350 
     
    local restitle = getResourceName(resource) 
    local helpnode = getResourceConfig(":" .. getResourceName(resource) .. "/help.xml") 
     
    if helpnode then 
     
        local nameattribute = xmlNodeGetAttribute(helpnode, "title"); 
         
        if nameattribute then 
            restitle = nameattribute; 
        end 
         
    end 
     
    local text = 
        "Help page available for ".. restitle .."! ".. 
        "Press "..HELP_KEY.." or type /"..HELP_COMMAND.." to read it." 
         
    guiSetText(wndPopup, text) 
    guiSetAlpha(wndPopup, 0) 
    guiWindowSetMovable(wndPopup, false) 
    guiWindowSetSizable(wndPopup, false) 
     
    fadeIn(wndPopup) 
    setTimer(fadeOut, POPUP_TIMEOUT, 1, wndPopup) 
end 

notice: i've made my own gui window cause you forgot stuff on your GUI like tab panel.

Link to comment
local localPlayer = getLocalPlayer() 
local rootElement = getRootElement() 
local thisResourceRoot = getResourceRootElement(getThisResource()) 
local pagesXml 
  
local wndHelp, wndBlock, tPanel, btnClose 
local tab = {} 
local memo = {} 
local popupQueue = {} 
  
local HELP_KEY = "F9" 
local HELP_COMMAND = "gamehelp" 
local POPUP_TIMEOUT = 15000 --ms 
local FADE_DELTA = .03 --alpha per frame 
local MAX_ALPHA = .9 
  
addEvent("doShowHelp", true) 
addEvent("doHideHelp", true) 
addEvent("onHelpShown") 
addEvent("onHelpHidden") 
  
addEventHandler("onClientResourceStart", thisResourceRoot,  
    function () 
        wndHelp  = guiCreateWindow(196,93,622,437, "Help", false) 
        wndBlock = guiCreateWindow(0, 0, 1, 1, "", true) 
        tPanel   = guiCreateTabPanel(10,29,602,363, false, wndHelp) 
        btnClose = guiCreateButton(245,396,139,23, "Close", false, wndHelp) 
  
        guiSetVisible(wndHelp, false) 
        guiSetVisible(wndBlock, false) 
         
        guiWindowSetSizable(wndHelp, false) 
        guiSetAlpha(wndBlock, 0) 
         
        addEventHandler("onClientGUIClick", btnClose, 
            function() 
                if source == this then 
                    clientToggleHelp(false) 
                end 
            end 
        ) 
         
        pagesXml = xmlLoadFile("seen.xml") 
        if not pagesXml then 
            pagesXml = xmlCreateFile("seen.xml", "seen") 
        end 
         
        for i, resourceRoot in ipairs(getElementsByType("resource")) do --!w 
            local resource = getResourceFromName(getElementID(resourceRoot)) 
            if resource then 
                addHelpTabFromXML(resource) 
            end 
        end 
         
        addCommandHandler(HELP_COMMAND, clientToggleHelp) 
        bindKey(HELP_KEY, "down", clientToggleHelp) 
    end 
) 
  
addEventHandler("onClientResourceStop", thisResourceRoot, 
    function() 
        showCursor(false) 
    end 
) 
  
-- exports 
function showHelp() 
    return clientToggleHelp(true) 
end 
addEventHandler("doShowHelp", rootElement, showHelp) 
  
function hideHelp() 
    return clientToggleHelp(false) 
end 
addEventHandler("doHideHelp", rootElement, hideHelp) 
  
function addHelpTab(resource, showPopup) 
  
    if showPopup == nil then 
        showPopup = true 
    end 
     
    -- block duplicates 
    if tab[resource] then 
        return false 
    end 
     
    local tabtext = getResourceName(resource) 
     
    local helpnode = getResourceConfig(":" .. getResourceName(resource) .. "/help.xml") 
     
    if helpnode then 
     
        local nameattribute = xmlNodeGetAttribute(helpnode, "title"); 
         
        if nameattribute then 
            tabtext = nameattribute; 
        end 
         
    end 
  
    tab[resource] = guiCreateTab( tabtext , tPanel) 
     
    if showPopup then 
        addHelpPopup(resource) 
    end 
     
    return tab[resource] 
end 
  
function removeHelpTab(resource) 
    if not tab[resource] then 
        return false 
    end 
     
    if memo[resource] then 
        destroyElement(memo[resource]) 
        memo[resource] = nil 
    end 
     
    guiDeleteTab(tab[resource], tPanel) 
    tab[resource] = nil 
     
    return true 
end 
addEventHandler("onClientResourceStop", rootElement, removeHelpTab) 
  
--private 
function addHelpTabFromXML(resource) 
    -- block duplicates 
    if tab[resource] then 
        return false 
    end 
         
    local helpnode = getResourceConfig(":"..getResourceName(resource).."/help.xml") 
    if helpnode then 
        local helptext = xmlNodeGetValue(helpnode) 
        local showPopup = not (xmlNodeGetAttribute(helpnode, "popup") == "no") 
        if helptext then 
            addHelpTab(resource, showPopup) 
            memo[resource] = guiCreateMemo(10,7,583,324, helptext, false, tab[resource]) 
            guiMemoSetReadOnly(memo[resource], true) 
        end 
    end 
end 
addEventHandler("onClientResourceStart", rootElement, addHelpTabFromXML) 
  
function clientToggleHelp(state) 
    if state ~= true and state ~= false then 
        state = not guiGetVisible(wndHelp) 
    end 
    guiSetVisible(wndHelp, state) 
    guiSetVisible(wndBlock, state) 
    if state == true then 
        triggerEvent("onHelpShown", localPlayer) 
        guiBringToFront(wndBlock) 
        guiBringToFront(wndHelp) 
        showCursor(true) 
    else 
        triggerEvent("onHelpHidden", localPlayer) 
        showCursor(false) 
    end 
    return true 
end 
  
local function fadeIn(wnd) 
    local function raiseAlpha() 
        local newAlpha = guiGetAlpha(wnd) + FADE_DELTA 
        if newAlpha <= MAX_ALPHA then 
            guiSetAlpha(wnd, newAlpha) 
        else 
            removeEventHandler("onClientRender", rootElement, raiseAlpha) 
        end 
    end 
    addEventHandler("onClientRender", rootElement, raiseAlpha) 
end 
  
local function fadeOut(wnd) 
    local function lowerAlpha() 
        local newAlpha = guiGetAlpha(wnd) - FADE_DELTA 
        if newAlpha >= 0 then 
            guiSetAlpha(wnd, newAlpha) 
        else 
            removeEventHandler("onClientRender", rootElement, lowerAlpha) 
            destroyElement(wnd) 
             
            table.remove(popupQueue, 1) 
            if #popupQueue > 0 then 
                showHelpPopup(popupQueue[1]) 
            end 
        end 
    end 
    addEventHandler("onClientRender", rootElement, lowerAlpha) 
end 
  
function addHelpPopup(resource) 
    local xmlContents = xmlNodeGetValue(pagesXml) 
    local seenPages = split(xmlContents, string.byte(',')) 
    local resourceName = getResourceName(resource) 
    for i, page in ipairs(seenPages) do 
        if page == resourceName then 
            return 
        end 
    end 
    xmlNodeSetValue(pagesXml, xmlContents..resourceName..",") 
    xmlSaveFile(pagesXml) 
  
    table.insert(popupQueue, resource) 
    if #popupQueue == 1 then 
        showHelpPopup(resource) 
    end 
end 
  
function showHelpPopup(resource) 
    local screenX, screenY = guiGetScreenSize() 
    local wndPopup = guiCreateWindow(0, screenY - 20, screenX, 0, '', false) --350 
     
    local restitle = getResourceName(resource) 
    local helpnode = getResourceConfig(":" .. getResourceName(resource) .. "/help.xml") 
     
    if helpnode then 
     
        local nameattribute = xmlNodeGetAttribute(helpnode, "title"); 
         
        if nameattribute then 
            restitle = nameattribute; 
        end 
         
    end 
     
    local text = 
        "Help page available for ".. restitle .."! ".. 
        "Press "..HELP_KEY.." or type /"..HELP_COMMAND.." to read it." 
         
    guiSetText(wndPopup, text) 
    guiSetAlpha(wndPopup, 0) 
    guiWindowSetMovable(wndPopup, false) 
    guiWindowSetSizable(wndPopup, false) 
     
    fadeIn(wndPopup) 
    setTimer(fadeOut, POPUP_TIMEOUT, 1, wndPopup) 
end 

notice: i've made my own gui window cause you forgot stuff on your GUI like tab panel.

Tab panel? I dont have tabs it could be in a tab or something sorry that im soo noobish...so i just paste my lines after: wndhelp etc?

Link to comment

hmm better copy my code and check how i made it ;)

btw, i edited this lines,

24, 25, 26, 27

those are:

wndHelp  = guiCreateWindow(196,93,622,437, "Help", false) 
tPanel   = guiCreateTabPanel(10,29,602,363, false, wndHelp) 
btnClose = guiCreateButton(245,396,139,23, "Close", false, wndHelp) 

and the memo for the text,

line 141:

memo[resource] = guiCreateMemo(10,7,583,324, helptext, false, tab[resource]) 

Link to comment
hmm better copy my code and check how i made it ;)

btw, i edited this lines,

24, 25, 26, 27

those are:

wndHelp  = guiCreateWindow(196,93,622,437, "Help", false) 
tPanel   = guiCreateTabPanel(10,29,602,363, false, wndHelp) 
btnClose = guiCreateButton(245,396,139,23, "Close", false, wndHelp) 

and the memo for the text,

line 141:

memo[resource] = guiCreateMemo(10,7,583,324, helptext, false, tab[resource]) 

Alright, thanks for everthing :mrgreen: I will test tomorrow Thanks again :D

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...