Using derma elements for an RPG-like menu system?

Right now I’ve got a camera system that behaves a bit like your classical RPG-type setup, where you right click to control your rotation and left click to rotate the camera around yourself, while using the WASD keys to run around.

This is great, but I’m running into a problem as far as interactive menus are concerned. Derma buttons only seem to take input when MakePopup is enabled, which disables keyboard input for the rest of the game. This is problematic because players are supposed to use the mouse and keyboard simultaneously to interact with things, and it kind of sucks they won’t be able to do that. Is there a simple way to get derma to respond to the clicker without MakePopup being called, or will I have to go and make my own VGUI class?

Also, the mouse input for scroll wheels doesn’t work. :wink:

How it looks so far:

http://img27.imageshack.us/img27/8590/gmflatgrass0002ra.jpg

TL;DR: I want to be able to select the menu buttons on the right to access the spellbook, options menu, etc., but I can’t because when MakePopup is called the movement part of the game is unresponsive.

Any help would be appreciated.

Thanks!

you might be able to Jerry rig it, say if the w key is down and the menu is up walk forward. i can’t give am example/ show code since I’m not home atm

Wow nice dude! Will you release this when done?

Yup, most likely over workshop or in the gamemodes forum.

YAY :smiley:

That’s why I want to find out if there’s a more simple way to do it. More time to code in gameplay features. :smile:

Does Player:KeyDown still function with a menu up? If so, just manually run +forward etc if the menu is open.

This doesn’t work, sadly.

Then use PANEL.OnKeyCodePressed and do it that way

It’ll detect the keypresses and execute code, but nothing pertaining to moving the player around will work for some reason. Huh.

Maybe it’s just a bool I have to switch off somewhere. :v:

-snip- Didn’t read all the way through

Do you mean this ?

[lua]PANEL:SetKeyboardInputEnabled( false )[/lua]

I used that in my rts, i’m pretty sure that’s what he’s looking for.

Here is this if you’re lazy.

if not, you could basically set it up so the players movement is controlled by the panels input, that’d work too.

That did the trick! Got the buttons working how I want them, however I have another problem. It’s a familiarity problem, since I’m not used to coding in lua.

The way I have the spellbar set up, calling the function makes a new layer of spells atop the old ones. This isn’t good. Problem is I’m not sure how to do it any other way.

Could someone enlighten me?

Here’s the relevant code:



function hudCommand(num)
    if (num > 0 and num <=5 )then
        spellbar_derma(num)
    end
end
 
function spellbar_derma(num)
 
    local scrW = ScrW()
    local scrH = ScrH()
    local iconSize = scrH*0.05
    local mySpells = {
                        1,
                        2,
                        3,
                        4,
                        5
    }
    local actionButtons = {}
     
    for i = 1, 5, 1 do
        spellButtons* = {}
        spellButtons* = vgui.Create("DImageButton")
        spellButtons*:SetImage(LocalPlayer():GetNWString("SpellIcon"..i..""))
        spellButtons*:SetPos((scrW*0.4)+(scrH*0.0425*i), scrH*0.9425)
        spellButtons*:SetSize(scrH*0.04, scrH*0.04)
        spellButtons*:SetText("1")
        spellButtons*.spellID = LocalPlayer():GetNWInt("GetSpellID"..i.."")
        spellButtons*.DoClick = function() 
        runSpell(spellButtons*.spellID) 
        spellButtons*:SetDisabled(true)
        timer.Simple(0.05, function()
        spellButtons*:SetColor(Color(255, 0, 0, 100))
        end)
        timer.Simple(0.5, function() 
            spellButtons*:SetDisabled(false)
            spellButtons*:SetColor(Color(255, 255, 255, 255))
            end)
        end
    end
     
    if(num> 0 and num <= 5) then
        spellButtons[num]:DoClick()
    end
     
end


Delete your old buttons.

[lua]
if spellButtons* then spellButtons*:Remove() end[/lua]

Throwing that in doesn’t seem to make a difference…

[lua]
function spellbar_derma(num)

local scrW = ScrW()
local scrH = ScrH()
local iconSize = scrH*0.05
local mySpells = {
                    1,
                    2,
                    3,
                    4,
                    5
}
local actionButtons = {}
 
for i = 1, 5, 1 do
	if ( spellButtons* != nil) then -- unless it somehow gets set to false for some reason.
		spellButtons* = nil;
	end;
    spellButtons* = vgui.Create("DImageButton")
    spellButtons*:SetImage(LocalPlayer():GetNWString("SpellIcon"..i..""))
    spellButtons*:SetPos((scrW*0.4)+(scrH*0.0425*i), scrH*0.9425)
    spellButtons*:SetSize(scrH*0.04, scrH*0.04)
    spellButtons*:SetText("1")
    spellButtons*.spellID = LocalPlayer():GetNWInt("GetSpellID"..i.."")
    spellButtons*.DoClick = function() 
    runSpell(spellButtons*.spellID) 
    spellButtons*:SetDisabled(true)
    timer.Simple(0.05, function()
    spellButtons*:SetColor(Color(255, 0, 0, 100))
    end)
    timer.Simple(0.5, function() 
        spellButtons*:SetDisabled(false)
        spellButtons*:SetColor(Color(255, 255, 255, 255))
        end)
    end
end
 
if(num&gt; 0 and num &lt;= 5) then
    spellButtons[num]:DoClick()
end

end
[/lua]

idk about the hud element you’re using so before you set it to nil, you probably want to use the remove method on it.

Ps there is no need at all to do spellButtons* = {}. because when you use vgui.Create it sets it to panel object( in this case DImageButton ) which is a table anyway.

i’d be able to help you more but the way you’re doing this is pretty oddball.