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.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 if keys[layout] and (#keys[layout].lowercase == 256 and #keys[layout].uppercase == 256) then
-- Thanks NullCascade -- Thanks NullCascade
mwse.memory.writeBytes({address = 0x775148, bytes = keys[layout].lowercase}) mwse.memory.writeBytes({address = 0x775148, bytes = keys[layout].lowercase})
mwse.memory.writeBytes({address = 0x775248, bytes = keys[layout].uppercase}) mwse.memory.writeBytes({address = 0x775248, bytes = keys[layout].uppercase})
changed = true
else else
local message = "Bad keys.lua file, please re-install." local message = "Bad keys.lua file, please re-install."
this.log(message) this.log(message)
tes3.messageBox(string.format("(%s) %s", this.modName, message)) tes3.messageBox(string.format("(%s) %s", this.modName, message))
end end
return changed
end end
return this return this

View file

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

View file

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