(Lua, ASMx86) Replication of Devil May Cry 4's debug functions for it's re-released version.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

d3dmenu.lua 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. local d3dmenu = {}
  2. function d3dmenu.status_txt(bool)
  3. if bool then
  4. return "ON"
  5. end
  6. return "OFF"
  7. end
  8. function d3dmenu.init_options(hook) --default if no file is found
  9. --A bit obtuse, but less so
  10. --Menu options are manually chosen
  11. --Right now adding in stuff from the addreslist by i.d makes a menu I don't really want.
  12. Options = {} --text containers
  13. Options.size = 8
  14. OLabels = {} --for text container - shorter version of label
  15. OStates = {} --booleans
  16. OStrings = {} --identifying memory record descriptions
  17. selected_option = 1 --used as index
  18. addresses = getAddressList()
  19. local txtheight = fmap.Height
  20. OStrings[1] = 'Disable Camera Events (No "Screen Blink", but Some Issues in Missions)'
  21. OLabels[1] = "Disable Camera Events: "
  22. OStates[1] = addresses.getMemoryRecordByDescription(OStrings[1]).Active
  23. Options[1] = hook.createTextContainer(fmap, 0, 50,
  24. OLabels[1]..status_txt(OStates[1]))
  25. OStrings[2] = 'Auto-Skip Cutscenes (Checking This Enables Everything Under This Section)'
  26. OLabels[2] = "Auto-Skip Cutscenes: "
  27. OStates[2] = addresses.getMemoryRecordByDescription(OStrings[2]).Active
  28. Options[2] = hook.createTextContainer(fmap, 0, 50+txtheight,
  29. OLabels[2]..status_txt(OStates[2]))
  30. OStrings[3] = 'Disable Bloody Palace Timer'
  31. OLabels[3] = "Disable Bloody Palace Timer: "
  32. OStates[3] = addresses.getMemoryRecordByDescription(OStrings[3]).Active
  33. Options[3] = hook.createTextContainer(fmap, 0, 50+txtheight*2,
  34. OLabels[3]..status_txt(OStates[3]))
  35. OStrings[4] = 'No One Dies (Effect Takes Precedence Over Damage Modifiers)'
  36. OLabels[4] = "No One Dies: "
  37. OStates[4] = addresses.getMemoryRecordByDescription(OStrings[4]).Active
  38. Options[4] = hook.createTextContainer(fmap, 0, 50+txtheight*3,
  39. OLabels[4]..status_txt(OStates[4]))
  40. OStrings[5] = 'No One Takes Damage'
  41. OLabels[5] = "No One Takes Damage: "
  42. OStates[5] = addresses.getMemoryRecordByDescription(OStrings[5]).Active
  43. Options[5] = hook.createTextContainer(fmap, 0, 50+txtheight*4,
  44. OLabels[5]..status_txt(OStates[5]))
  45. OStrings[6] = 'Enemy 1-Hit Kill'
  46. OLabels[6] = "Enemy 1-Hit Kill: "
  47. OStates[6] = addresses.getMemoryRecordByDescription(OStrings[6]).Active
  48. Options[6] = hook.createTextContainer(fmap, 0, 50+txtheight*5,
  49. OLabels[6]..status_txt(OStates[6]))
  50. OStrings[7] = 'Allow Trick Down (Air) without DT'
  51. OLabels[7] = "Vergil, No DT - Allow Trick Down: "
  52. OStates[7] = addresses.getMemoryRecordByDescription(OStrings[7]).Active
  53. Options[7] = hook.createTextContainer(fmap, 0, 50+txtheight*6,
  54. OLabels[7]..status_txt(OStates[7]))
  55. OStrings[8] = '"Berial Fire Lost" (Checking this Enables Everything Under This Section)'
  56. OLabels[8] = "Berial Fire Lost: "
  57. OStates[8] = addresses.getMemoryRecordByDescription(OStrings[8]).Active
  58. Options[8] = hook.createTextContainer(fmap, 0, 50+txtheight*7,
  59. OLabels[8]..status_txt(OStates[8]))
  60. end
  61. function d3dmenu.finit_options(separator, hook) --from file if found
  62. local filename = TrainerOrigin.."d3dmenu-ops.txt"
  63. local file = io.open(filename, "r")
  64. if file == nil then
  65. return false
  66. end
  67. Options = {} --text containers
  68. Options.size = 0 --how many elements in list
  69. OLabels = {} --for text container - shorter version of label
  70. OStates = {} --booleans
  71. OStrings = {} --identifying memory record descriptions
  72. selected_option = 1 --used as index
  73. addresses = getAddressList()
  74. local text_height_base = fmap.Height
  75. local text_height_factor = 0
  76. local text_offset = 50
  77. local hit_separator = false
  78. local index = 1
  79. local mrecord = nil --result from CE's get MemoryRecordByDescription
  80. --File Format: Memory Record descriptions first half, labels on the second half.
  81. -- IF the separator has not been hit, and neither is current like the separator mark
  82. for line in io.lines(filename) do
  83. if (not hit_separator) and (line ~= separator) then --read in memory record strings
  84. mrecord = addresses.getMemoryRecordByDescription(line)
  85. if mrecord then --must be valid result
  86. Options.size = Options.size + 1
  87. OStrings[Options.size] = line
  88. OStates[Options.size] = mrecord.Active
  89. end
  90. elseif (not hit_separator) and line == separator then
  91. hit_separator = true --mark status for reading displayed labels
  92. else --read in displayed labels
  93. OLabels[index] = line
  94. Options[index] = hook.createTextContainer(fmap, 0,
  95. text_offset + (text_height_base * text_height_factor),
  96. OLabels[index]..d3dmenu.status_txt(OStates[index]))
  97. index = index + 1 --next iteration; next index
  98. text_height_factor = text_height_factor + 1 --next Option is displayed 1 line down
  99. end --end check hit separator status
  100. end --end for loop
  101. return true
  102. end --end function
  103. function d3dmenu.createD3Dmenu(CE_hook)
  104. background = createPicture()
  105. bitmap = background.getBitmap()
  106. bitmap.setHeight(1)
  107. bitmap.setWidth(1)
  108. canvas = bitmap.getCanvas()
  109. canvas.setPixel(0,0, 0xffffff) --White overlay
  110. bgtexture = CE_hook.createTexture(background)
  111. bgsprite = CE_hook.createSprite(bgtexture)
  112. bgsprite.Width = 200
  113. bgsprite.Height = 200
  114. bgsprite.X = 0 --centered horizontally
  115. bgsprite.Alphablend = 0.5
  116. highlight = createPicture()
  117. bitmap = highlight.getBitmap()
  118. bitmap.setHeight(1)
  119. bitmap.setWidth(1)
  120. canvas = bitmap.getCanvas()
  121. canvas.setPixel(0,0, 0x9FB4BA) --highlight color
  122. hltexture = CE_hook.createTexture(highlight)
  123. hlsprite = CE_hook.createSprite(hltexture)
  124. hlsprite.Visible = false --not yet
  125. hlsprite.X = 0 --line up with background
  126. hlsprite.Width = 200
  127. font = createFont()
  128. fmap = CE_hook.createFontmap(font)
  129. hlsprite.Height = fmap.Height
  130. hlsprite.Visible = true
  131. if (not d3dmenu.finit_options(":", CE_hook)) then --if file not found
  132. d3dmenu.init_options(CE_hook)
  133. end
  134. end
  135. function d3dmenu.execute_selected()
  136. OStates[selected_option] = not OStates[selected_option]
  137. addresses.getMemoryRecordByDescription(OStrings[selected_option]).Active = OStates[selected_option]
  138. Options[selected_option].Text = OLabels[selected_option]..status_txt(OStates[selected_option])
  139. end
  140. function d3dmenu.option_click(object, x, y)
  141. for i = 1, Options.size do
  142. --see which Option was clicked
  143. if (object == Options[i]) then
  144. selected_option = i
  145. execute_selected()
  146. highlight_selected()
  147. end
  148. end
  149. end
  150. function d3dmenu.toggle_display()
  151. bgsprite.Visible = not bgsprite.Visible
  152. hlsprite.Visible = not hlsprite.Visible
  153. for i = 1, Options.size do
  154. Options[i].Visible = not Options[i].Visible
  155. end
  156. end
  157. function d3dmenu.highlight_selected()
  158. hlsprite.Y = 50 + (fmap.Height * (selected_option - 1))
  159. end
  160. function d3dmenu.destroyD3Dmenu()
  161. --Clean up... everything.
  162. bgsprite.destroy()
  163. bgtexture.destroy()
  164. hlsprite.destroy()
  165. hltexture.destroy()
  166. background.destroy()
  167. highlight.destroy()
  168. bitmap.destroy()
  169. if Options ~= nil then
  170. for i = 1, Options.size do
  171. Options[i].destroy()
  172. end
  173. end
  174. fmap.destroy()
  175. font.destroy()
  176. canvas.destroy()
  177. end
  178. return d3dmenu