slight refactor
This commit is contained in:
parent
f2e3846fe1
commit
188257cdee
3 changed files with 18 additions and 8 deletions
|
@ -15,16 +15,14 @@ function this.log(str) mwse.log("[%s] %s", this.modName, str) end
|
|||
|
||||
function this.changedLayout(layout)
|
||||
local changed = false
|
||||
|
||||
if keys[layout] and (#keys[layout].lowercase == 256 and #keys[layout].uppercase == 256) then
|
||||
-- Thanks NullCascade
|
||||
mwse.memory.writeBytes({address = 0x775148, bytes = keys[layout].lowercase})
|
||||
mwse.memory.writeBytes({address = 0x775248, bytes = keys[layout].uppercase})
|
||||
changed = true
|
||||
else
|
||||
local message = "Bad keys.lua file, please re-install."
|
||||
this.log(message)
|
||||
tes3.messageBox(string.format("(%s) %s", this.modName, message))
|
||||
end
|
||||
|
||||
return changed
|
||||
end
|
||||
|
||||
|
|
|
@ -2,9 +2,16 @@ local common = require("celediel.Keyboard Layout Changer.common")
|
|||
local config = require("celediel.Keyboard Layout Changer.config").getConfig()
|
||||
|
||||
local function onInitialized()
|
||||
local message = ""
|
||||
|
||||
if common.changedLayout(config.keyboardLayout) then
|
||||
common.log("Changed layout to " .. config.keyboardLayout)
|
||||
message = "Changed layout to " .. config.keyboardLayout
|
||||
else
|
||||
message = "Bad keys.lua file, please re-install."
|
||||
tes3.messageBox(string.format("(%s) %s", common.modName, message))
|
||||
end
|
||||
|
||||
common.log(message)
|
||||
end
|
||||
|
||||
event.register("initialized", onInitialized)
|
||||
|
|
|
@ -25,12 +25,17 @@ local function createOptions()
|
|||
end
|
||||
|
||||
local function applyLayout()
|
||||
local message = ""
|
||||
|
||||
if common.changedLayout(config.keyboardLayout) then
|
||||
local message = "Changed layout to " .. config.keyboardLayout
|
||||
message = "Changed layout to " .. config.keyboardLayout
|
||||
else
|
||||
message = "Bad keys.lua file, length must be 256."
|
||||
end
|
||||
|
||||
tes3.messageBox(message)
|
||||
common.log(message)
|
||||
end
|
||||
end
|
||||
|
||||
local template = mwse.mcm.createTemplate(common.modName)
|
||||
template:saveOnClose(common.configString, config)
|
||||
|
|
Loading…
Add table
Reference in a new issue