Browse Source

New d3d menu functions operational.

master
4 years ago
parent
commit
5df84fa8e3
1 changed files with 12 additions and 6 deletions
  1. 12
    6
      luas/d3dmenu.lua

+ 12
- 6
luas/d3dmenu.lua View File

@@ -1,6 +1,7 @@
local d3dmenu = {}
-- append to display menu. D3D.destroyD3Dmenu()
-- returns string representation of boolean.
function d3dmenu.status_txt(bool)
if bool then
return "ON"
@@ -16,6 +17,7 @@ end
---------------------------------]]--
-- create a single new option for the menu.
-- no return value
function d3dmenu.new_option(id, label, index, th, h)
OStrings[index] = id
OLabels[index] = label
@@ -24,12 +26,13 @@ function d3dmenu.new_option(id, label, index, th, h)
fmap,
0,
50 + (th * (index - 1)),
OLabels[index]..status_txt(OStates[index])
OLabels[index]..d3dmenu.status_txt(OStates[index])
)
end
-- default settings for options if file is not found.
-- parameter 'txth' = text height.
-- return memory record descriptions and menu labels.
function d3dmenu.defaults()
-- preset strings come from names of memory records
local presets = {
@@ -60,6 +63,7 @@ end
-- reads in the file and stores information as strings.
-- parameter 'f' = file descriptor (Lua metatable).
-- parameter 'sep' = separator.
-- returns memory record description and menu labels.
function d3dmenu.fromfile(f, sep)
-- 'Outstrs' = output strings.
-- 'Outlabels' = output labels.
@@ -68,7 +72,6 @@ function d3dmenu.fromfile(f, sep)
Outstrs.size = 0
local sephit = false -- 'sephit' = separator hit,
-- whether or not string 'sep' has been encountered.
local memrec = nil -- memory record, verify if one exists with string.
local index = 1 -- starting index for initialization of labels.
for line in f:lines() do
if (not sephit) and (line ~= sep) then
@@ -89,6 +92,8 @@ function d3dmenu.fromfile(f, sep)
end -- end function
-- create and bind d3dmenu options with CE memory records.
-- global variables are declared here.
-- no return value.
function d3dmenu.init(hook)
Options = {} --text containers
Options.size = 0
@@ -112,6 +117,7 @@ function d3dmenu.init(hook)
for i = 1, ids.size do
d3dmenu.new_option(ids[i], labels[i], i, txt_height, hook)
end
Options.size = ids.size
selected_option = 1
end
@@ -255,10 +261,10 @@ function d3dmenu.createD3Dmenu(CE_hook)
fmap = CE_hook.createFontmap(font)
hlsprite.Height = fmap.Height
hlsprite.Visible = true
if (not d3dmenu.finit_options(":", CE_hook)) then --if file not found
d3dmenu.init_options(CE_hook)
end
--d3dmenu.init(CE_hook)
-- if (not d3dmenu.finit_options(":", CE_hook)) then --if file not found
-- d3dmenu.init_options(CE_hook)
-- end
d3dmenu.init(CE_hook)
end
--[[---------------------------------

Loading…
Cancel
Save