Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rkusa committed Jan 10, 2019
1 parent 5fc89eb commit cc777d8
Showing 1 changed file with 19 additions and 23 deletions.
42 changes: 19 additions & 23 deletions Scripts/Hooks/scratchpad-hook.lua
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
function scratchpad_load()

package.path = package.path..";.\\LuaSocket\\?.lua;"..'.\\Scripts\\?.lua;'.. '.\\Scripts\\UI\\?.lua;'
package.cpath = package.cpath..";.\\LuaSocket\\?.dll;"

local JSON = loadfile("Scripts\\JSON.lua")()
local lfs = require('lfs')
local U = require('me_utilities')
local Skin = require('Skin')
local DialogLoader = require('DialogLoader')
local Tools = require('tools')
local Input = require('Input')

local isHidden = true
local keyboardLocked = false
local window = nil
package.path = package.path..";.\\Scripts\\?.lua;.\\Scripts\\UI\\?.lua;"

local lfs = require("lfs")
local U = require("me_utilities")
local Skin = require("Skin")
local DialogLoader = require("DialogLoader")
local Tools = require("tools")
local Input = require("Input")

local isHidden = true
local keyboardLocked = false
local window = nil
local windowDefaultSkin = nil
local windowSkinHidden = Skin.windowSkinChatMin()
local panel = nil
local textarea = nil
local windowSkinHidden = Skin.windowSkinChatMin()
local panel = nil
local textarea = nil

local scratchpad = {
logFile = io.open(lfs.writedir()..[[Logs\Scratchpad.log]], "w")
}

function scratchpad.loadConfiguration()
scratchpad.log("Loading config file...")
local tbl = Tools.safeDoFile(lfs.writedir() .. 'Config/ScratchpadConfig.lua', false)
local tbl = Tools.safeDoFile(lfs.writedir() .. "Config/ScratchpadConfig.lua", false)
if (tbl and tbl.config) then
scratchpad.log("Configuration exists...")
scratchpad.config = tbl.config
Expand All @@ -49,7 +47,7 @@ function scratchpad_load()
end

function scratchpad.saveConfiguration()
U.saveInFile(scratchpad.config, 'config', lfs.writedir() .. 'Config/ScratchpadConfig.lua')
U.saveInFile(scratchpad.config, "config", lfs.writedir() .. "Config/ScratchpadConfig.lua")
end

function scratchpad.log(str)
Expand Down Expand Up @@ -81,12 +79,10 @@ function scratchpad_load()
end

function scratchpad.createWindow()
window = DialogLoader.spawnDialogFromFile(lfs.writedir() .. 'Scripts\\Scratchpad\\ScratchpadWindow.dlg', cdata)
window = DialogLoader.spawnDialogFromFile(lfs.writedir() .. "Scripts\\Scratchpad\\ScratchpadWindow.dlg", cdata)
windowDefaultSkin = window:getSkin()
panel = window.Box
textarea = panel.ScratchpadEditBox



-- setup textarea
local skin = textarea:getSkin()
Expand All @@ -106,7 +102,7 @@ function scratchpad_load()
end
end)
textarea:addKeyDownCallback(function(self, keyName, unicode)
if keyName == 'escape' then
if keyName == "escape" then
self:setFocused(false)
unlockKeyboardInput(true)
end
Expand Down

0 comments on commit cc777d8

Please sign in to comment.