Code: Select all
function showMenu() --causes renderMenu() to run every frame
party.party:addConnector('onDrawGui', self.go.id, "renderMenu")
GameMode.setEnableControls(false)
end
function hideMenu() --stops renderMenu() from running every frame
party.party:removeConnector('onDrawGui', self.go.id, "renderMenu")
GameMode.setEnableControls(true)
end
-- menu button text table
supported = {"English","French","Spanish","Croation", "Polish","Dutch","Italian", "Zulu", "Czech", "Norwegian", "German", "Sweedish"}
language_choice = nil --can be checked for the user's language selection.
--menu
function renderMenu(self, context)
--panel
local X, Y = context.width /2 -236, context.height /2 -190
context.drawGuiItem2("ConfirmDialog", X, Y, 0, 0, 430,300, 493, 335 )
--buttons
local state
local language = nil
local count = 1
local selection = nil
local buttons = {}
X, Y = context.width /2 -206 , context.height /2 -118 --image placement
context.font('medium')
for z = 1,4 do
for c = 1, 3 do
if count > #supported then break
end
local offset = 0
state = context.button(supported[count], X, Y, 140, 37)
context.drawImage2("mod_assets/textures/button_atlas.dds", X, Y, 0,iff(state==nil,0,80), 140, 40, 140, 40)
context.color(0,0,0,255)
context.drawText(supported[count], X + 71-(5*#supported[count])+ offset, Y + 26 +offset)
context.color(255,255,255,255)
if (state~=nil and context.mouseDown(0)) or selected == count then offset = 1
context.drawImage2("mod_assets/textures/button_atlas.dds", X, Y, 0,41, 140, 39, 140, 40)
selected = count context.color(96,184,255,255) language = supported[count]
end
context.drawText(supported[count], X + 70-(5*#supported[count])+ offset, Y + 25+ offset)
context.color(255,255,255,255)
if state then selection = count mousePressed = true
end
X=X+140 --button width
count = count +1
end
Y=Y+37
X=X-420
end
X, Y = context.width /2, context.height /2 --image placement
context.font("large")
if not language then language = "Choose a language" end
if language or selected then
context.color(0,0,0,255)
context.drawText(language, X-(6 * #language)+1, Y-150)
context.color(255,255,255,255)
context.drawText(language, X-(6 * #language), Y-151 )
end
context.drawGuiItem("ButtonApply", X-45, Y+42)
local apply = (context.button("apply", X-45, Y+42, 92,32))
if apply then
context.drawGuiItem("ButtonApplyHover", X-45, Y+42) -- ButtonApply
playSound("click_up")
party.party:removeConnector('onDrawGui', self.go.id, "menu")
if selected then language_choice = language end
hideMenu()
end
if selection then
playSound("click_down")
end
end