Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 【 LICENCE 】
- --------------------------------------------------------------------------------
- -- The MIT License (MIT)
- --
- -- Copyright (c) mece from opencheattables.org
- --
- -- Permission is hereby granted, free of charge, to any person obtaining a
- -- copy of this software and associated documentation files (the "Software"),
- -- to deal in the Software without restriction, including without limitation
- -- the rights to use, copy, modify, merge, publish, distribute, sublicense,
- -- and/or sell copies of the Software, and to permit persons to whom the
- -- Software is furnished to do so, subject to the following conditions:
- --
- -- The above copyright notice and this permission notice shall be included in
- -- all copies or substantial portions of the Software.
- --
- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- -- DEALINGS IN THE SOFTWARE.
- --------------------------------------------------------------------------------
- -- 【 FILE INFO 】
- -- ㅤ❖ This is an extention for Cheat Engine 7.4 (https://cheatengine.org)
- --
- -- 【 FEATURES 】
- -- ㅤ❖ Replaces CE 'MainForm.Caption' and 'App.Title' with current table name
- -- ㅤㅤ 1. CE was used to open CT file from file system:
- -- ㅤㅤ 2. CE opens CT from itself:
- -- ㅤㅤ 3. CT was saved as a file from CE
- -- ㅤㅤ 4. CE opens process while CT opened
- -- ㅤㅤ 5. CE opens CT with auto attach script:
- -- ㅤㅤ user runs/rejects lua script; prosess attach succeed or failed
- -- ㅤ❖ Replaces CE Open & Save dialogs 'InitialDir' and 'Filename' fields
- -- ㅤㅤ with current table path
- --
- -- 【 HOW TO INSTALL 】
- -- ㅤ❖ Place the .lua file in CE autorun folder. Could be:
- -- ㅤㅤ C:\Program Files\Cheat Engine 7.4\autorun
- --
- -- 【 CHANGE LOG 】
- -- ㅤ⋯ 2022-23-07 ⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯
- -- ㅤ❖ added handling of additional cases
- -- ㅤ⋯ 2022-07-17 ⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯
- -- ㅤ❖ initial version
- --
- -- 【 CONTACT THE AUTHOR 】
- -- ㅤ❖ https://opencheattables.org/viewforum.php?f=14
- -- ㅤ❖ https://forum.cheatengine.org/viewforum.php?f=130
- --
- ------------------------------------------------------------------------------
- local mf = getMainForm()
- local app = getApplication()
- local currentPath = nil
- local originalCaption = mf.Caption
- ------------------------------------------------------------------------------
- -- Get CE cmd line, where params[1] is path to CE
- local function getCEParams()
- local cmd_line = readStringLocal(executeCodeLocal('GetCommandLineA'), 512)
- local params = {}
- for param in cmd_line:gmatch('"(.-)"') do params[#params + 1] = param end
- return params
- end
- ------------------------------------------------------------------------------
- local function getNewCaption(path)
- local name = extractFileName(path)
- if name and name ~= "" then
- return name .. " - " .. originalCaption
- else
- return originalCaption
- end
- end
- ------------------------------------------------------------------------------
- local function displayTableName(path)
- local newCaption = getNewCaption(path)
- mf.Caption = newCaption
- app.Title = newCaption
- local newPath = extractFilePath(path)
- mf.SaveDialog1.Filename = path
- mf.OpenDialog1.Filename = path
- mf.SaveDialog1.InitialDir = newPath
- mf.OpenDialog1.InitialDir = newPath
- end
- ------------------------------------------------------------------------------
- local originalOnTableLoad
- if _G.onTableLoad then
- originalOnTableLoad = onTableLoad
- end
- ------------------------------------------------------------------------------
- local function OnTableLoad(before)
- if originalOnTableLoad then originalOnTableLoad(before) end
- if before then
- if currentPath == nil then
- -- CE was used to open CT file from file system
- -- the path to CT is in cmdline
- local params = getCEParams()
- if #params > 1 then
- -- assuming the first param is path to CT
- currentPath = getCEParams()[2]
- displayTableName(currentPath)
- end
- end
- else
- -- When CE opens CT from itself 'mf.SaveDialog1.Filename' is updated but
- -- only after some delay from the table load finished
- local timer = createTimer(mf)
- timer.Interval = 500
- timer.OnTimer = function(thisTimer)
- displayTableName(mf.SaveDialog1.Filename)
- thisTimer.destroy()
- end
- end
- end
- _G.onTableLoad = OnTableLoad
- ------------------------------------------------------------------------------
- local originalOnProcessOpened
- if mf.OnProcessOpened then
- originalOnProcessOpened = mf.OnProcessOpened
- end
- ------------------------------------------------------------------------------
- local function OnProcessOpened(processid, processhandle, caption)
- if originalOnProcessOpened then originalOnProcessOpened(processid, processhandle, caption) end
- -- prevent CE from replacing the path with ExpectedTableName
- displayTableName(currentPath)
- end
- mf.OnProcessOpened = OnProcessOpened
- ------------------------------------------------------------------------------
- local originalOnCloseSaveDialog
- if mf.SaveDialog1.OnClose then
- originalOnCloseSaveDialog = mf.SaveDialog1.OnClose
- end
- ------------------------------------------------------------------------------
- local function OnCloseSaveDialog(sender)
- if originalOnCloseSaveDialog then originalOnCloseSaveDialog(sender) end
- displayTableName(mf.SaveDialog1.Filename)
- end
- mf.SaveDialog1.OnClose = OnCloseSaveDialog
- ------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement