backup
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ do local modules = {}
|
||||
modules[name] = module and M
|
||||
import (green_t)
|
||||
private.aux = setmetatable(t, mt)
|
||||
private.p.set = inspect
|
||||
private.p.set = function(v) inspect(nil, v) end
|
||||
end)()
|
||||
end
|
||||
modules[name].import (modules.core.I)
|
||||
|
||||
+3
-3
@@ -45,7 +45,7 @@ do
|
||||
end
|
||||
|
||||
do local id = 0
|
||||
function private.id.get() id = id + 1; return id end
|
||||
function private.unique_id.get() id = id + 1; return id end
|
||||
end
|
||||
|
||||
function public.kill_listener(listener_id)
|
||||
@@ -57,7 +57,7 @@ function public.kill_thread(thread_id)
|
||||
end
|
||||
|
||||
function public.event_listener(event, cb)
|
||||
local listener_id = id
|
||||
local listener_id = unique_id
|
||||
listeners[listener_id] = {event=event, cb=cb, kill=function(...) temp=arg if arg.n == 0 or arg[1] then kill_listener(listener_id) end end}
|
||||
event_frame:RegisterEvent(event)
|
||||
return listener_id
|
||||
@@ -68,7 +68,7 @@ function public.on_next_event(event, callback)
|
||||
end
|
||||
|
||||
function public.thread(k, ...) temp=arg
|
||||
local thread_id = id
|
||||
local thread_id = unique_id
|
||||
threads[thread_id] = T('k', L(k, unpack(arg)))
|
||||
return thread_id
|
||||
end
|
||||
|
||||
+12
-7
@@ -302,10 +302,10 @@ function public.editbox(parent)
|
||||
editbox:SetTextInsets(1.5, 1.5, 3, 3)
|
||||
editbox:SetMaxLetters(nil)
|
||||
editbox:SetHeight(24)
|
||||
editbox:SetTextColor(0, 0, 0, 0)
|
||||
-- editbox:SetTextColor(0, 0, 0, 0)
|
||||
set_content_style(editbox)
|
||||
local function colorize() this.display:SetText((this.colorizer or nop)(this:GetText()) or this:GetText()) end
|
||||
local function format() this.display:SetText((this.formatter or this.colorizer or nop)(this:GetText()) or this:GetText()) end
|
||||
local function colorize() end -- this.display:SetText((this.colorizer or id)(this:GetText())) end
|
||||
local function format() end-- this.display:SetText((this.formatter or this.colorizer or id)(this:GetText())) end
|
||||
editbox:SetScript('OnEscapePressed', function()
|
||||
this:ClearFocus()
|
||||
;(this.escape or nop)()
|
||||
@@ -316,7 +316,7 @@ function public.editbox(parent)
|
||||
this.focused = true
|
||||
this:HighlightText()
|
||||
this:SetScript('OnUpdate', function()
|
||||
this.cursor:SetAlpha(mod(floor((GetTime()-this.cursor.last_change) * 2 + 1), 2))
|
||||
this.cursor:SetAlpha(mod(floor((GetTime() - this.cursor.last_change) * 2 + 1), 2))
|
||||
end)
|
||||
;(this.focus_gain or nop)()
|
||||
end)
|
||||
@@ -338,16 +338,21 @@ function public.editbox(parent)
|
||||
end)
|
||||
editbox:SetScript('OnChar', function() (this.char or nop)() end)
|
||||
do
|
||||
local last_click
|
||||
local last_click = T('t', 0)
|
||||
editbox:SetScript('OnMouseDown', function()
|
||||
local x, y = GetCursorPosition()
|
||||
-- local offset = x - editbox:GetLeft()*editbox:GetEffectiveScale() TODO use a fontstring to measure getstringwidth for structural highlighting
|
||||
-- editbox:Insert'<ksejfkj>' TODO use insert with special tags to determine cursor position
|
||||
-- or use an overlay with itemlinks
|
||||
if last_click and GetTime() - last_click.t < .5 and x == last_click.x and y == last_click.y then
|
||||
if GetTime() - last_click.t < .5 and x == last_click.x and y == last_click.y then
|
||||
thread(function() editbox:HighlightText() end)
|
||||
end
|
||||
last_click = {t=GetTime(), x=x, y=y}
|
||||
wipe(last_click)
|
||||
last_click.t = GetTime()
|
||||
last_click.x = x
|
||||
last_click.y = y
|
||||
-- __(last_click) :t(GetTime()) :x(x) :y(y) TODO
|
||||
|
||||
end)
|
||||
end
|
||||
function editbox:Enable()
|
||||
|
||||
+32
-16
@@ -1,31 +1,47 @@
|
||||
local function print(msg)
|
||||
DEFAULT_CHAT_FRAME:AddMessage(RED_FONT_COLOR_CODE .. msg)
|
||||
DEFAULT_CHAT_FRAME:AddMessage(msg, 1, 0, 0)
|
||||
end
|
||||
|
||||
local function format_key(k)
|
||||
return type(k) == 'string' and k or '[' .. tostring(k) .. ']'
|
||||
end
|
||||
|
||||
local function format_value(v)
|
||||
return type(v) == 'string' and '"' .. v .. '"' or tostring(v)
|
||||
end
|
||||
|
||||
function inspect(...)
|
||||
for i = 1, arg.n do
|
||||
print('arg' .. i..' = ' .. format_value(arg[i]))
|
||||
if type(arg[i]) == 'table' and next(arg[i]) then
|
||||
print('{')
|
||||
for k, v in arg[i] do
|
||||
print(' ' .. format_key(k) .. ' = ' .. format_value(v))
|
||||
end
|
||||
print('}')
|
||||
local function print_table(t, max_depth, depth)
|
||||
local indent = strrep(' ', depth * 4)
|
||||
for k, v in t do
|
||||
print(indent .. format_key(k) .. ' = ' .. format_value(v))
|
||||
if type(v) == 'table' and next(v) and depth < max_depth then
|
||||
print(indent .. '{')
|
||||
print_table(v, max_depth, depth + 1)
|
||||
print(indent .. '}')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local depth
|
||||
|
||||
function inspect(_, ...)
|
||||
arg.n = nil
|
||||
print_table(arg, depth or 2, 0)
|
||||
depth = nil
|
||||
return unpack(arg)
|
||||
end
|
||||
|
||||
p = setmetatable({}, {
|
||||
__metatable = false,
|
||||
__pow = function(self, v) self(v); return v end,
|
||||
__sub = function(self, v) self(v); return v end,
|
||||
__call = function(_, ...) return inspect(unpack(arg)) end,
|
||||
})
|
||||
local mt = { __metatable=false, __call=inspect, __div=inspect }
|
||||
|
||||
function mt:__index(key)
|
||||
if type(key) == 'number' then
|
||||
depth = key
|
||||
elseif type(key) == 'function' then
|
||||
print('#' .. key())
|
||||
else
|
||||
print('#' .. key)
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
p = setmetatable({}, mt)
|
||||
+3
-3
@@ -10,7 +10,7 @@ local function declaration_error() error('Declaration error.') end
|
||||
local function collision_error(key) error('"%s" already exists.', key) end
|
||||
local function nil_error(key) if key then error('"%s" is nil.', key) else error('Callee is nil') end end
|
||||
|
||||
local nop = function() end
|
||||
local nop, id = function() end, function(v) return v end
|
||||
|
||||
local function prototype() local eq = function() return true end
|
||||
return setmetatable({__metatable=false, __eq=eq}, {__metatable=false, __eq=eq, __call=function(self, t) return setmetatable(t, self) end})
|
||||
@@ -85,8 +85,8 @@ function mt:__index(key)
|
||||
if key ~= 'module' then return nil end
|
||||
local interface, environment, declarator = INTERFACE {}, ENVIRONMENT {}, DECLARATOR {}
|
||||
self = {
|
||||
access = {_G=PRIVATE, I=PRIVATE, M=PRIVATE, public=PRIVATE, private=PRIVATE, import=PRIVATE, _=PRIVATE, error=PRIVATE, nop=PRIVATE},
|
||||
[CALL] = {_G=_G, I=interface, M=environment, import=function(interface) import(self, interface) end, error=error, nop=nop},
|
||||
access = {_G=PRIVATE, I=PRIVATE, M=PRIVATE, public=PRIVATE, private=PRIVATE, import=PRIVATE, _=PRIVATE, error=PRIVATE, nop=PRIVATE, id=PRIVATE},
|
||||
[CALL] = {_G=_G, I=interface, M=environment, import=function(interface) import(self, interface) end, error=error, nop=nop, id=id},
|
||||
[INDEX] = {public=function() return declarator.public end, private=function() return declarator.private end},
|
||||
[NEWINDEX] = {_=nop},
|
||||
declarator = declarator,
|
||||
|
||||
+2
-2
@@ -75,8 +75,8 @@ function set_unit_start_price(amount)
|
||||
end
|
||||
|
||||
function get_unit_buyout_price()
|
||||
local money_text = unit_buyout_price:GetText()
|
||||
return aux.money.from_string(money_text) or 0
|
||||
local money_text = p/unit_buyout_price:GetText()
|
||||
return p/aux.money.from_string(money_text) or 0
|
||||
end
|
||||
|
||||
function set_unit_buyout_price(amount)
|
||||
|
||||
+6
-4
@@ -203,13 +203,10 @@ function create_frames()
|
||||
label:SetPoint('LEFT', checkbox, 'RIGHT', 4, 1)
|
||||
label:SetText('Hide this item')
|
||||
hide_checkbox = checkbox
|
||||
end
|
||||
local function money_input()
|
||||
|
||||
|
||||
end
|
||||
do
|
||||
local editbox = gui.editbox(frame.parameters)
|
||||
editbox.name = 'start'
|
||||
editbox:SetPoint('TOPRIGHT', -71, -60)
|
||||
editbox:SetWidth(180)
|
||||
editbox:SetHeight(22)
|
||||
@@ -227,6 +224,7 @@ function create_frames()
|
||||
editbox.change = function() refresh = true end
|
||||
editbox.enter = function() this:ClearFocus() end
|
||||
editbox.focus_loss = function()
|
||||
p = this.SetText
|
||||
this:SetText(money.to_string(get_unit_start_price(), true, nil, 3, nil, true))
|
||||
end
|
||||
do
|
||||
@@ -245,6 +243,7 @@ function create_frames()
|
||||
end
|
||||
do
|
||||
local editbox = gui.editbox(frame.parameters)
|
||||
editbox.name = 'buy'
|
||||
editbox:SetPoint('TOPRIGHT', unit_start_price, 'BOTTOMRIGHT', 0, -19)
|
||||
editbox:SetWidth(180)
|
||||
editbox:SetHeight(22)
|
||||
@@ -262,6 +261,7 @@ function create_frames()
|
||||
editbox.change = function() refresh = true end
|
||||
editbox.enter = function() this:ClearFocus() end
|
||||
editbox.focus_loss = function()
|
||||
p(this.SetText)
|
||||
this:SetText(money.to_string(get_unit_buyout_price(), true, nil, 3, nil, true))
|
||||
end
|
||||
do
|
||||
@@ -277,6 +277,8 @@ function create_frames()
|
||||
buyout_price_percentage = label
|
||||
end
|
||||
unit_buyout_price = editbox
|
||||
local o = editbox.SetText
|
||||
function editbox:SetText(v) p(v) o(self, v) end
|
||||
end
|
||||
do
|
||||
local btn = gui.button(frame.parameters, 14)
|
||||
|
||||
Reference in New Issue
Block a user