123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- local d3dmenu = {}
-
- function d3dmenu.status_txt(bool)
- if bool then
- return "ON"
- end
- return "OFF"
- end
-
- function d3dmenu.init_options(hook) --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
- 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 d3dmenu.finit_options(separator, hook) --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
- local mrecord = nil --result from CE's get MemoryRecordByDescription
- --File Format: Memory Record descriptions first half, labels on the second half.
- -- IF the separator has not been hit, and neither is current like the separator mark
- for line in io.lines(filename) do
- if (not hit_separator) and (line ~= separator) then --read in memory record strings
- mrecord = addresses.getMemoryRecordByDescription(line)
- if mrecord then --must be valid result
- Options.size = Options.size + 1
- OStrings[Options.size] = line
- OStates[Options.size] = mrecord.Active
- end
- elseif (not hit_separator) and line == separator then
- hit_separator = true --mark status for reading displayed labels
- else --read in displayed labels
- OLabels[index] = line
- Options[index] = hook.createTextContainer(fmap, 0,
- text_offset + (text_height_base * text_height_factor),
- OLabels[index]..d3dmenu.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 d3dmenu.createD3Dmenu(CE_hook)
- background = createPicture()
- bitmap = background.getBitmap()
- bitmap.setHeight(1)
- bitmap.setWidth(1)
- canvas = bitmap.getCanvas()
- canvas.setPixel(0,0, 0xffffff) --White overlay
- bgtexture = CE_hook.createTexture(background)
- bgsprite = CE_hook.createSprite(bgtexture)
- bgsprite.Width = 200
- bgsprite.Height = 200
- bgsprite.X = 0 --centered horizontally
- bgsprite.Alphablend = 0.5
-
- highlight = createPicture()
- bitmap = highlight.getBitmap()
- bitmap.setHeight(1)
- bitmap.setWidth(1)
- canvas = bitmap.getCanvas()
- canvas.setPixel(0,0, 0x9FB4BA) --highlight color
- hltexture = CE_hook.createTexture(highlight)
- hlsprite = CE_hook.createSprite(hltexture)
- hlsprite.Visible = false --not yet
- hlsprite.X = 0 --line up with background
- hlsprite.Width = 200
-
- font = createFont()
- 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
- end
-
- 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])
- end
-
- function d3dmenu.option_click(object, x, y)
- 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
- end
-
- function d3dmenu.toggle_display()
- bgsprite.Visible = not bgsprite.Visible
- hlsprite.Visible = not hlsprite.Visible
- for i = 1, Options.size do
- Options[i].Visible = not Options[i].Visible
- end
- end
-
- function d3dmenu.highlight_selected()
- hlsprite.Y = 50 + (fmap.Height * (selected_option - 1))
- end
-
- function d3dmenu.destroyD3Dmenu()
- --Clean up... everything.
- bgsprite.destroy()
- bgtexture.destroy()
- hlsprite.destroy()
- hltexture.destroy()
- background.destroy()
- highlight.destroy()
- bitmap.destroy()
- if Options ~= nil then
- for i = 1, Options.size do
- Options[i].destroy()
- end
- end
- fmap.destroy()
- font.destroy()
- canvas.destroy()
- end
-
- return d3dmenu
|