Browse Source

In-game menu is now based on lists.

master
5 years ago
parent
commit
93c3a0f61f
2 changed files with 844 additions and 748 deletions
  1. 714
    642
      DevilMayCry4SpecialEdition.CT
  2. 130
    106
      luas/d3dmenu.lua

+ 714
- 642
DevilMayCry4SpecialEdition.CT
File diff suppressed because it is too large
View File


+ 130
- 106
luas/d3dmenu.lua View File

@@ -1,44 +1,112 @@
function init_options()
selected_option = 1 --global, access for click event and script execution
function status_txt(bool)
if bool then
return "ON"
end
return "OFF"
end
function init_options() --default if no file is found
--A bit obtuse, but less so
--Menu options are manually chosen
--Right now adding in stuff from the addreslist by i.d makes a menu I don't really want.
Options = {} --text containers
Options.size = 8
OLabels = {} --for text container - shorter version of label
OStates = {} --booleans
OStrings = {} --identifying memory record descriptions
selected_option = 1 --used as index
addresses = getAddressList()
local txtheight = fmap.Height
local txtstatus = "ON"
opt1 = 'Disable Camera Events (No "Screen Blink", but Some Issues in Missions)'
Option1State = addresses.getMemoryRecordByDescription(opt1).Active
if Option1State then
txtstatus = "ON"
else
txtstatus = "OFF"
end
Option1 = hook.createTextContainer(fmap, 0, 50,
"Disable Camera Events: "..txtstatus)
opt2 = 'Auto-Skip Cutscenes (Checking This Enables Everything Under This Section)'
Option2State = addresses.getMemoryRecordByDescription(opt2).Active
if Option2State then
txtstatus = "ON"
else
txtstatus = "OFF"
end
Option2 = hook.createTextContainer(fmap, 0, 50+txtheight,
"Auto-Skip Cutscenes: "..txtstatus)
opt3 = 'Disable Bloody Palace Timer'
Option3State = addresses.getMemoryRecordByDescription(opt3).Active
if Option3State then
txtstatus = "ON"
else
txtstatus = "OFF"
end
Option3 = hook.createTextContainer(fmap, 0, 50+txtheight*2,
"Disable Timer: "..txtstatus)
OStrings[1] = 'Disable Camera Events (No "Screen Blink", but Some Issues in Missions)'
OLabels[1] = "Disable Camera Events: "
OStates[1] = addresses.getMemoryRecordByDescription(OStrings[1]).Active
Options[1] = hook.createTextContainer(fmap, 0, 50,
OLabels[1]..status_txt(OStates[1]))
OStrings[2] = 'Auto-Skip Cutscenes (Checking This Enables Everything Under This Section)'
OLabels[2] = "Auto-Skip Cutscenes: "
OStates[2] = addresses.getMemoryRecordByDescription(OStrings[2]).Active
Options[2] = hook.createTextContainer(fmap, 0, 50+txtheight,
OLabels[2]..status_txt(OStates[2]))
OStrings[3] = 'Disable Bloody Palace Timer'
OLabels[3] = "Disable Bloody Palace Timer: "
OStates[3] = addresses.getMemoryRecordByDescription(OStrings[3]).Active
Options[3] = hook.createTextContainer(fmap, 0, 50+txtheight*2,
OLabels[3]..status_txt(OStates[3]))
OStrings[4] = 'No One Dies (Effect Takes Precedence Over Damage Modifiers)'
OLabels[4] = "No One Dies: "
OStates[4] = addresses.getMemoryRecordByDescription(OStrings[4]).Active
Options[4] = hook.createTextContainer(fmap, 0, 50+txtheight*3,
OLabels[4]..status_txt(OStates[4]))
OStrings[5] = 'No One Takes Damage'
OLabels[5] = "No One Takes Damage: "
OStates[5] = addresses.getMemoryRecordByDescription(OStrings[5]).Active
Options[5] = hook.createTextContainer(fmap, 0, 50+txtheight*4,
OLabels[5]..status_txt(OStates[5]))
OStrings[6] = 'Enemy 1-Hit Kill'
OLabels[6] = "Enemy 1-Hit Kill: "
OStates[6] = addresses.getMemoryRecordByDescription(OStrings[6]).Active
Options[6] = hook.createTextContainer(fmap, 0, 50+txtheight*5,
OLabels[6]..status_txt(OStates[6]))
OStrings[7] = 'Allow Trick Down (Air) without DT'
OLabels[7] = "Vergil, No DT - Allow Trick Down: "
OStates[7] = addresses.getMemoryRecordByDescription(OStrings[7]).Active
Options[7] = hook.createTextContainer(fmap, 0, 50+txtheight*6,
OLabels[7]..status_txt(OStates[7]))
OStrings[8] = '"Berial Fire Lost" (Checking this Enables Everything Under This Section)'
OLabels[8] = "Berial Fire Lost: "
OStates[8] = addresses.getMemoryRecordByDescription(OStrings[8]).Active
Options[8] = hook.createTextContainer(fmap, 0, 50+txtheight*7,
OLabels[8]..status_txt(OStates[8]))
end
function createD3Dmenu()
if background ~= nil then
bgsprite.destroy()
bgtexture.destroy()
function finit_options(separator) --from file if found
local filename = TrainerOrigin.."d3dmenu-ops.txt"
local file = io.open(filename, "r")
if file == nil then
return false
end
Options = {} --text containers
Options.size = 0 --how many elements in list
OLabels = {} --for text container - shorter version of label
OStates = {} --booleans
OStrings = {} --identifying memory record descriptions
selected_option = 1 --used as index
addresses = getAddressList()
local text_height_base = fmap.Height
local text_height_factor = 0
local text_offset = 50
local hit_separator = false
local index = 1
--File Format: Memory Record descriptions first half, labels on the second half.--
for line in io.lines(filename) do
if (not hit_separator) then --read in memory record strings
if (line ~= separator) then--check if separator indicator has been reached
Options.size = Options.size + 1 --nope. no increment in Lua
OStrings[Options.size] = line
OStates[Options.size] = addresses.getMemoryRecordByDescription(OStrings[Options.size]).Active
else
hit_separator = true --mark status for reading displayed labels
end --end check separator string
else --read in displayed labels
OLabels[index] = line
Options[index] = hook.createTextContainer(fmap, 0,
text_offset + (text_height_base * text_height_factor),
OLabels[index]..status_txt(OStates[index]))
index = index + 1 --next iteration; next index
text_height_factor = text_height_factor + 1 --next Option is displayed 1 line down
end --end check hit separator status
end --end for loop
return true
end --end function
function createD3Dmenu()
background = createPicture()
bitmap = background.getBitmap()
bitmap.setHeight(1)
@@ -52,10 +120,6 @@ function createD3Dmenu()
bgsprite.X = 0 --centered horizontally
bgsprite.Alphablend = 0.5
if highlight ~= nil then
hlsprite.destroy()
hltexture.destroy()
end
highlight = createPicture()
bitmap = highlight.getBitmap()
bitmap.setHeight(1)
@@ -72,80 +136,38 @@ function createD3Dmenu()
fmap = hook.createFontmap(font)
hlsprite.Height = fmap.Height
hlsprite.Visible = true
init_options()
end
function execute_selected()
local toggle = "OFF"
if (selected_option == 1) then --no switch statements in Lua
Option1State = not Option1State
addresses.getMemoryRecordByDescription(opt1).Active = Option1State
if (Option1State) then
toggle = "ON"
else
toggle = "OFF"
end
Option1.Text = "Disable Camera Events: "..toggle
elseif (selected_option == 2) then
Option2State = not Option2State
addresses.getMemoryRecordByDescription(opt2).Active = Option2State
if (Option2State) then
toggle = "ON"
else
toggle = "OFF"
end
Option2.Text = "Auto-Skip Cutscenes: "..toggle
elseif (selected_option == 3) then
Option3State = not Option3State
addresses.getMemoryRecordByDescription(opt3).Active = Option3State
if (Option3State) then
toggle = "ON"
else
toggle = "OFF"
end
Option3.Text = "Disable Timer: "..toggle
if (not finit_options(":")) then --if file not found
init_options()
end
end
function highlight_selected()
hlsprite.Y = 50 + (fmap.Height * (selected_option - 1))
function 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])
end
function option_click(object, x, y)
if (object == Option1) then
selected_option = 1
execute_selected()
elseif (object == Option2) then
selected_option = 2
execute_selected()
elseif (object == Option3) then
selected_option = 3
execute_selected()
end
highlight_selected()
end
function keypress(virtualkey, character)
--Unused. DMC4SE seems to use DINPUT8 which this functionality is incompatible with.
if (virtualkey == VK_DOWN) and (selected_option < 3) then
selected_option = selected_option + 1 --AFAIK no '++' or '--' operators in Lua
end
if (virtualkey == VK_UP) and (selected_option > 1) then
selected_option = selected_option - 1 --No += operator either. Eh.
end
if (virtualkey == VK_RETURN) then
execute_option()
for i = 1, Options.size do
--see which Option was clicked
if (object == Options[i]) then
selected_option = i
execute_selected()
highlight_selected()
end
end
highlight_selected()
return false --Do not pass input to the game.
end
function toggle_display()
bgsprite.Visible = not bgsprite.Visible
hlsprite.Visible = not hlsprite.Visible
Option1.Visible = not Option1.Visible
Option2.Visible = not Option2.Visible
Option3.Visible = not Option3.Visible
for i = 1, Options.size do
Options[i].Visible = not Options[i].Visible
end
end
function highlight_selected()
hlsprite.Y = 50 + (fmap.Height * (selected_option - 1))
end
function destroyD3Dmenu()
@@ -157,10 +179,12 @@ function destroyD3Dmenu()
background.destroy()
highlight.destroy()
bitmap.destroy()
Option1.destroy()
Option2.destroy()
Option3.destroy()
if Options ~= nil then
for i = 1, Options.size do
Options[i].destroy()
end
end
fmap.destroy()
font.destroy()
canvas.destroy()
end
end

Loading…
Cancel
Save