don't display changing layout message if layout not changed

This commit is contained in:
Lilian Jónsdóttir 2020-07-11 14:38:39 -07:00
parent 8d540d65c3
commit ce0f90c86e
3 changed files with 12 additions and 7 deletions

View file

@ -13,16 +13,19 @@ this.modInfo = "Allows use of non-qwerty keyboard layouts.\n\nCurrently supporte
function this.log(str) mwse.log("[%s] %s", this.modName, str) end
function this.changeLayout(layout)
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
return this

View file

@ -2,8 +2,9 @@ local common = require("Keyboard Layout Changer.common")
local config = require("Keyboard Layout Changer.config").getConfig()
local function onInitialized()
common.log("Changing layout to " .. config.keyboardLayout)
common.changeLayout(config.keyboardLayout)
if common.changedLayout(config.keyboardLayout) then
common.log("Changed layout to " .. config.keyboardLayout)
end
end
event.register("initialized", onInitialized)

View file

@ -25,10 +25,11 @@ local function createOptions()
end
local function applyLayout()
local message = "Changing layout to " .. config.keyboardLayout
tes3.messageBox(message)
common.log(message)
common.changeLayout(config.keyboardLayout)
if common.changedLayout(config.keyboardLayout) then
local message = "Changed layout to " .. config.keyboardLayout
tes3.messageBox(message)
common.log(message)
end
end
local template = mwse.mcm.createTemplate(common.modName)