Browse Source

Added cleaner code for D3D menu; needs debugging.

master
4 years ago
parent
commit
3957c21645
2 changed files with 8765 additions and 673 deletions
  1. 8643
    670
      DMC4SE-Data&Dev.CT
  2. 122
    3
      luas/d3dmenu.lua

+ 8643
- 670
DMC4SE-Data&Dev.CT
File diff suppressed because it is too large
View File


+ 122
- 3
luas/d3dmenu.lua View File

@@ -1,5 +1,6 @@
local d3dmenu = {}
-- append to display menu. D3D.destroyD3Dmenu()
function d3dmenu.status_txt(bool)
if bool then
return "ON"
@@ -7,6 +8,119 @@ function d3dmenu.status_txt(bool)
return "OFF"
end
--[[---------------------------------
D3D Options Creation
Reorganized and to be integrated.
---------------------------------]]--
-- create a single new option for the menu.
function d3dmenu.new_option(id, label, index, th, h)
OStrings[index] = id
OLabels[index] = label
OStates[index] = addresses.getMemoryRecordByDescription(OStrings[index]).Active
Options[index] = h.createTextContainer(
fmap,
0,
50 + (th * (index - 1)),
OLabels[index]..status_txt(OStates[index])
)
end
-- default settings for options if file is not found.
-- parameter 'txth' = text height.
function d3dmenu.defaults()
-- preset strings come from names of memory records
local presets = {
'Disable Camera Events (No "Screen Blink", but Some Issues in Missions)',
'Auto-Skip Cutscenes (Checking This Enables Everything Under This Section)',
'Disable Bloody Palace Timer',
'No One Dies (Effect Takes Precedence Over Damage Modifiers)',
'No One Takes Damage',
'Enemy 1-Hit Kill',
'Allow Trick Down (Air) without DT',
'"Berial Fire Lost" (Checking this Enables Everything Under This Section)'
}
local plabels = {
"Disable Camera Events: ",
"Auto-Skip Cutscenes: ",
"Disable Bloody Palace Timer: ",
"No One Dies: ",
"No One Takes Damage: ",
"Enemy 1-Hit Kill: ",
"Vergil, No DT - Allow Trick Down: ",
"Berial Fire Lost: "
}
-- both 'presets' and 'plabels' must be of the same length.
presets.size = 8
return presets, plabels
end
-- reads in the file and stores information as strings.
-- parameter 'f' = file descriptor (Lua metatable).
-- parameter 'sep' = separator.
function d3dmenu.fromfile(f, sep)
-- 'Outstrs' = output strings.
-- 'Outlabels' = output labels.
local Outstrs = {}
local Outlabels = {}
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
-- current line is not 'sep' and 'sep' has never been encountered.
-- check if current line is a description that exists in Cheat Table.
Outstrs.size = Outstrs.size + 1
Outstrs[Outstrs.size] = line
elseif (not sephit) and line == sep then
-- current line is 'sep', and 'sep' is encountered.
sephit = true
else
-- current line is not 'sep' and 'sep' has been encountered.
Outlabels[index] = line
index = index + 1
end --end if
end --end for loop
return Outstrs, Outlabels
end -- end function
-- create and bind d3dmenu options with CE memory records.
function d3dmenu.init(hook)
Options = {} --text containers
Options.size = 0
OLabels = {} --menu label
OStates = {} --booleans
OStrings = {} --identifying memory record descriptions
addresses = getAddressList()
local filename = TrainerOrigin.."d3dmenu-ops.txt"
local file = io.open(filename, "r")
local txt_height = fmap.Height
-- these are lists of strings of the same length
-- ids is the list with the 'size' attribute
local ids = {} -- memory record descriptions
local labels = {} -- menu label
if file == nil then
ids, labels = d3dmenu.defaults()
else
ids, labels = d3dmenu.fromfile(file, ":")
end
file:close()
for i = 1, ids.size do
d3dmenu.new_option(ids[i], labels[i], i, txt_height, hook)
end
selected_option = 1
end
--[[---------------------------------
D3D Menu Creation
Mostly old and to be replaced.
---------------------------------]]--
function d3dmenu.init_options(hook) --default if no file is found
--A bit obtuse, but less so
--Menu options are manually chosen
@@ -144,12 +258,17 @@ function d3dmenu.createD3Dmenu(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
--[[---------------------------------
D3D Menu Operations
---------------------------------]]--
function d3dmenu.execute_selected()
OStates[selected_option] = not OStates[selected_option]
addresses.getMemoryRecordByDescription(OStrings[selected_option]).Active = OStates[selected_option]
Options[selected_option].Text = OLabels[selected_option]..status_txt(OStates[selected_option])
Options[selected_option].Text = OLabels[selected_option]..d3dmenu.status_txt(OStates[selected_option])
end
function d3dmenu.option_click(object, x, y)
@@ -157,8 +276,8 @@ function d3dmenu.option_click(object, x, y)
--see which Option was clicked
if (object == Options[i]) then
selected_option = i
execute_selected()
highlight_selected()
d3dmenu.execute_selected()
d3dmenu.highlight_selected()
end
end
end

Loading…
Cancel
Save