changes to wotk with protocol 860

This commit is contained in:
Eduardo Bart
2012-01-08 13:42:23 -02:00
parent d04596c5fd
commit fbaa7c8c43
17 changed files with 226 additions and 81 deletions

View File

@@ -7,6 +7,7 @@ Module
onLoad: |
require 'ext/table'
require 'ext/string'
require 'ext/os'
require 'math/point'
require 'math/size'
require 'math/color'

View File

@@ -0,0 +1,6 @@
function os.execute(command)
local f = assert(io.popen(command, 'r'))
local data = assert(f:read('*a'))
f:close()
print(data)
end

View File

@@ -0,0 +1,2 @@
Mouse = {}

View File

@@ -5,20 +5,72 @@ importStyle 'textmessage.otui'
-- private variables
local bottomLabelWidget, centerLabelWidget
local messageTypes = {
first = 12,
{ msgtype = 'MessageOrange', color = '#C87832', showOnConsole = true, showOnWindow = false },
{ msgtype = 'MessageOrange', color = '#C87832', showOnConsole = true, showOnWindow = false },
{ msgtype = 'MessageRed', color = '#C83200', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' },
{ msgtype = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' },
{ msgtype = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' },
{ msgtype = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' },
{ msgtype = 'MessageGreen', color = '#3FBE32', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' },
{ msgtype = 'MessageWhite', color = '#FFFFFF', showOnConsole = false, showOnWindow = true, windowLocation = 'BottomLabel' },
{ msgtype = 'MessageBlue', color = '#3264C8', showOnConsole = true, showOnWindow = false },
{ msgtype = 'MessageRed', color = '#C83200', showOnConsole = true, showOnWindow = false }
local MessageTypes = {
warning = { color = '#F55E5E', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' },
eventAdvance = { color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' },
eventDefault = { color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' },
statusDefault = { color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' },
infoDesc = { color = '#00EB00', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' },
statusSmall = { color = '#FFFFFF', showOnConsole = false, showOnWindow = true, windowLocation = 'BottomLabel' },
consoleOrange = { color = '#FE6500', showOnConsole = true, showOnWindow = false },
consoleBlue = { color = '#9F9DFD', showOnConsole = true, showOnWindow = false },
consoleRed = { color = '#F55E5E', showOnConsole = true, showOnWindow = false }
}
local hideEvent
local MessageTypesMap = {
[12] = MessageTypes.consoleOrange,
[13] = MessageTypes.consoleOrange,
[14] = MessageTypes.warning,
[15] = MessageTypes.eventAdvance,
[15] = MessageTypes.eventDefault,
[16] = MessageTypes.statusDefault,
[17] = MessageTypes.infoDesc,
[18] = MessageTypes.statusSmall,
[19] = MessageTypes.consoleBlue,
[20] = MessageTypes.consoleRed,
--[[
[18] = MessageTypes.consoleRed,
[19] = MessageTypes.consoleOrange,
[20] = MessageTypes.consoleOrange,
[21] = MessageTypes.warning,
[22] = MessageTypes.eventAdvance,
[23] = MessageTypes.eventDefault,
[24] = MessageTypes.statusDefault,
[25] = MessageTypes.infoDesc,
[26] = MessageTypes.statusSmall,
[27] = MessageTypes.consoleBlue
]]--
}
-- private variables
local bottomLabelHideEvent
local centerLabelHideEvent
-- private functions
local function displayMessage(msgtype, msg)
if msgtype.showOnConsole then
-- TODO
end
if msgtype.showOnWindow then
local label
if msgtype.windowLocation == 'BottomLabel' then
label = bottomLabelWidget
elseif msgtype.windowLocation == 'CenterLabel' then
label = centerLabelWidget
end
label:setVisible(true)
label:setText(msg)
label:setStyle(msgtype.windowLocation)
label:setForegroundColor(msgtype.color)
time = #msg * 75
removeEvent(label.hideEvent)
label.hideEvent = scheduleEvent(function() label:setVisible(false) end, time)
end
end
-- public functions
function TextMessage.create()
@@ -26,33 +78,22 @@ function TextMessage.create()
centerLabelWidget = createWidget('UILabel', Game.gameMapPanel)
end
function TextMessage.displayWarning(msg)
TextMessage.display(MessageTypes.warning, msg)
end
function TextMessage.display(msgtypeid, msg)
local msgtype = MessageTypesMap[msgtypeid]
if msgtype == nil then
error('unknown text msg type ' .. msgtypeid)
return
end
displayMessage(msgtype, msg)
end
-- hooked events
function TextMessage.onTextMessage(msgtype, message)
local messageType = messageTypes[msgtype - messageTypes.first]
if messageType.showOnConsole then
-- TODO
end
if messageType.showOnWindow then
local label
if messageType.windowLocation == 'BottomLabel' then
label = bottomLabelWidget
elseif messageType.windowLocation == 'CenterLabel' then
label = centerLabelWidget
end
label:setVisible(true)
label:setText(message)
label:setStyle(messageType.windowLocation)
label:setForegroundColor(messageType.color)
time = #message * 75
removeEvent(hideEvent)
hideEvent = scheduleEvent(function()
label:setVisible(false)
end, time)
end
function TextMessage.onTextMessage(msgtypeid, msg)
TextMessage.display(msgtypeid, msg)
end

View File

@@ -2,10 +2,11 @@
-- you can place any custom user code here
Hotkeys.bind('F1', function() Game.talk('exura gran') end)
Hotkeys.bind('F2', function() Game.talk('exori frigo') end)
Hotkeys.bind('F3', function() Game.talk('exevo flam hur') end)
Hotkeys.bind('F4', function() Game.talk('exevo pan') end)
Hotkeys.bind('F5', function() Game.talk('exani tera') end)
Hotkeys.bind('F2', function() Game.talk('exori mort') end)
Hotkeys.bind('F3', function() Game.talk('exori frigo') end)
Hotkeys.bind('F4', function() Game.talk('exevo vis hur') end)
Hotkeys.bind('F5', function() Game.talk('utani gran hur') end)
Hotkeys.bind('F6', function() Game.talk('exani tera') end)
Hotkeys.bind('Ctrl+R', function() runscript('otclientrc.lua') end)
if rcloaded then