2 -- create the webig namespace without reseting if already created in an other file.
7 if (webig
.sheetLists
==nil) then
11 if (webig
.urls
==nil) then
15 function getUCtf8(text
)
16 local uctext
= ucstring()
17 if type(text
) == "string" then
24 function game
:openUrlOnWebig(url
, noblink
, close_if_open
)
25 local winframe
= getUI("ui:interface:open_url_window")
26 if close_if_open
and winframe
~= nil and winframe
.active
== true then
27 winframe
.active
= false
29 WebBrowser
:openWindow("open_url_window", url
)
30 winframe
= getUI("ui:interface:open_url_window")
35 setTopWindow(winframe
)
36 if noblink
== nil then
43 function webig
:addSheet(dst
, sheet
, quality
, quantity
, worned
, user_color
, rm_class_type
, rm_faber_stat_type
)
44 if quality
== nil then quality
=0 end
45 if quantity
== nil then quantity
=0 end
46 if worned
== nil then worned
=0 end
47 if user_color
== nil then user_color
=0 end
48 if rm_class_type
== nil then rm_class_type
=0 end
49 if rm_faber_stat_type
== nil then rm_faber_stat_type
=0 end
50 addDbProp(dst
..":SHEET", sheet
)
51 addDbProp(dst
..":WORNED", worned
)
52 addDbProp(dst
..":QUALITY", quality
)
53 addDbProp(dst
..":QUANTITY", quantity
)
54 addDbProp(dst
..":USER_COLOR", user_color
)
55 addDbProp(dst
..":RM_CLASS_TYPE", rm_class_type
)
56 addDbProp(dst
..":RM_FABER_STAT_TYPE", rm_faber_stat_type
)
57 addDbProp(dst
..":CREATE_TIME", 0)
58 addDbProp(dst
..":SERIAL", 0)
61 function webig
:cleanSheets(db
)
65 function webig
:addSheetList(name
, ctrl
, db
, size
)
66 webig
.sheetLists
[name
] = {}
67 webig
.sheetLists
[name
].ctrl
= ctrl
68 webig
.sheetLists
[name
].db
= db
69 webig
.sheetLists
[name
].selection
= ""
70 webig
.sheetLists
[name
].size
= size
73 function webig
:copyItems(src
, dst
)
74 addDbProp(dst
..":SHEET", getDbProp(src
..":SHEET"))
75 addDbProp(dst
..":WORNED", getDbProp(src
..":WORNED"))
76 addDbProp(dst
..":QUALITY", getDbProp(src
..":QUALITY"))
77 addDbProp(dst
..":QUANTITY", getDbProp(src
..":QUANTITY"))
78 addDbProp(dst
..":USER_COLOR", getDbProp(src
..":USER_COLOR"))
79 addDbProp(dst
..":RM_CLASS_TYPE", getDbProp(src
..":RM_CLASS_TYPE"))
80 addDbProp(dst
..":RM_FABER_STAT_TYPE", getDbProp(src
..":RM_FABER_STAT_TYPE"))
81 addDbProp(dst
..":CREATE_TIME", 0)
82 addDbProp(dst
..":SERIAL", 0)
85 function webig
:swapItems(src
, dst
)
86 local sheet
= getDbProp(dst
..":SHEET")
87 local worned
= getDbProp(dst
..":WORNED")
88 local quality
= getDbProp(dst
..":QUALITY")
89 local quantity
= getDbProp(dst
..":QUANTITY")
90 local user_color
= getDbProp(dst
..":USER_COLOR")
91 local rm_class_type
= getDbProp(dst
..":RM_CLASS_TYPE")
92 local rm_faber_stat_type
= getDbProp(dst
..":RM_FABER_STAT_TYPE")
94 addDbProp(dst
..":SHEET", getDbProp(src
..":SHEET"))
95 addDbProp(dst
..":WORNED", getDbProp(src
..":WORNED"))
96 addDbProp(dst
..":QUALITY", getDbProp(src
..":QUALITY"))
97 addDbProp(dst
..":QUANTITY", getDbProp(src
..":QUANTITY"))
98 addDbProp(dst
..":USER_COLOR", getDbProp(src
..":USER_COLOR"))
99 addDbProp(dst
..":RM_CLASS_TYPE", getDbProp(src
..":RM_CLASS_TYPE"))
100 addDbProp(dst
..":RM_FABER_STAT_TYPE", getDbProp(src
..":RM_FABER_STAT_TYPE"))
101 addDbProp(dst
..":CREATE_TIME", 0)
102 addDbProp(dst
..":SERIAL", 0)
104 addDbProp(src
..":SHEET", sheet
)
105 addDbProp(src
..":WORNED", worned
)
106 addDbProp(src
..":QUALITY", quality
)
107 addDbProp(src
..":QUANTITY", quantity
)
108 addDbProp(src
..":USER_COLOR", user_color
)
109 addDbProp(src
..":RM_CLASS_TYPE", rm_class_type
)
110 addDbProp(src
..":RM_FABER_STAT_TYPE", rm_faber_stat_type
)
111 addDbProp(src
..":CREATE_TIME", 0)
112 addDbProp(src
..":SERIAL", 0)
115 function webig
:deleteItem(src
)
116 addDbProp(src
..":SHEET", 0)
117 addDbProp(src
..":WORNED", 0)
118 addDbProp(src
..":QUALITY", 0)
119 addDbProp(src
..":QUANTITY", 0)
120 addDbProp(src
..":USER_COLOR", 0)
121 addDbProp(src
..":RM_CLASS_TYPE", 0)
122 addDbProp(src
..":RM_FABER_STAT_TYPE", 0)
123 addDbProp(src
..":CREATE_TIME", 0)
124 addDbProp(src
..":SERIAL", 0)
127 function webig
:paramDbSheetSlot(sheet_list
, ctrl
)
128 local ctrlSheet
= webig
.sheetLists
[sheet_list
].ctrl
:find("list:"..ctrl
)
129 if ctrlSheet
~= nil then
130 ctrlSheet
.left_click
="lua"
131 ctrlSheet
.left_click_params
="webig:addOrRemoveDbSheet(\'"..sheet_list
.."\', \'"..ctrl
.."\')"
132 ctrlSheet
.dragable
=true
133 ctrlSheet
.can_drop
=true
134 ctrlSheet
.on_drop
="lua"
135 ctrlSheet
.on_drop_params
="webig:dropDbSheet(\'"..sheet_list
.."\', \'"..ctrl
.."\', \'%src\')"
136 ctrlSheet
.on_can_drop
="lua"
137 ctrlSheet
.on_can_drop_params
="webig:canDropDbSheet(\'"..sheet_list
.."\', \'"..ctrl
.."\', \'%src\')"
141 function webig
:paramDbSheetSelect(sheet_list
, ctrl
, lua_function
)
142 local ctrlSheet
= webig
.sheetLists
[sheet_list
].ctrl
:find("list:"..ctrl
)
143 if ctrlSheet
~= nil then
144 ctrlSheet
.left_click
="lua"
145 ctrlSheet
.left_click_params
=lua_function
.."(\'"..sheet_list
.."\', \'"..ctrl
.."\')"
146 ctrlSheet
.dragable
=false
147 ctrlSheet
.can_drop
=false
151 function webig
:canDropDbSheet(sheet_list
, ctrl
, src
)
152 webig
.sheetLists
[sheet_list
].ctrl
:find("list:"..ctrl
).can_drop
=true
155 function webig
:dropDbSheet(sheet_list
, ctrl
, src
)
156 local db
= webig
.sheetLists
[sheet_list
].db
157 local sl_id
= webig
.sheetLists
[sheet_list
].ctrl
.id
158 if (string.sub(src
, 1, string.len(sl_id
)) == sl_id
) then -- copy from same list sheet
160 for i
=1, string.len(src
) do
161 if string.sub(src
, i
, i
) == ":" then
165 id
= string.sub(src
, pos
, string.len(src
))
166 webig
:swapItems(db
..":"..id
, db
..":"..ctrl
)
170 id
= findReplaceAll(src
, slot
.parent
.id
..":", "")
171 webig
:copyItems("LOCAL:INVENTORY:BAG:"..id
, db
..":"..ctrl
)
177 function webig
:addOrRemoveDbSheet(sheet_list
, ctrl
)
178 local db
= webig
.sheetLists
[sheet_list
].db
179 if getDbProp(db
..":"..ctrl
..":SHEET") == 0 then -- Add item
180 webig
:AddDbSheet(sheet_list
, ctrl
)
182 webig
:removeDbSheetQuantity(sheet_list
, ctrl
)
186 function webig
:AddDbSheet(sheet_list
, ctrl
)
187 runAH(nil, "enter_modal", "group=ui:interface:webig_html_modal")
188 local whm
= getUI("ui:interface:webig_html_modal")
189 whm
.child_resize_h
=false
190 whm
.h
= 44*webig
.sheetLists
[sheet_list
].size
192 whm
= getUI("ui:interface:webig_html_modal:html")
194 if string.sub(sheet_list
, 1, 3) == "ark" then
195 whm
:browse(webig
.ark_modal_urls
[sheet_list
])
197 whm
:refresh() -- url need be setted before
199 webig
.sheetLists
[sheet_list
].selection
= ctrl
202 function webig
:removeDbSheetQuantity(sheet_list
, ctrl
)
203 local db
= webig
.sheetLists
[sheet_list
].db
204 webig
:copyItems(db
..":"..ctrl
, "UI:DROP_DESTROY_ITEM:ITEM")
205 runAH(nil, "set_keyboard_focus", "select_all=true|target=ui:interface:webig_drop_destroy_item_quantity_modal:edit:eb")
206 getUI("ui:interface:webig_drop_destroy_item_quantity_modal:ok_cancel:ok").onclick_l
="lua"
207 getUI("ui:interface:webig_drop_destroy_item_quantity_modal:ok_cancel:ok").params_l
="webig:doRemoveDbSheetQuantity(\'"..sheet_list
.."\', \'"..ctrl
.."\')"
208 getUI("ui:interface:webig_drop_destroy_item_quantity_modal:edit:eb").on_enter
="lua"
209 getUI("ui:interface:webig_drop_destroy_item_quantity_modal:edit:eb").on_enter_params
="webig:doRemoveDbSheetQuantity(\'"..sheet_list
.."\', \'"..ctrl
.."\')"
210 runAH(nil, "enter_modal", "group=ui:interface:webig_drop_destroy_item_quantity_modal")
211 setDbProp("UI:DROP_DESTROY_ITEM:ITEM:QUANTITY", getDbProp(db
..":"..ctrl
..":QUANTITY"))
212 getUI("ui:interface:webig_drop_destroy_item_quantity_modal:edit:eb").input_string
=tostring(getDbProp(db
..":"..ctrl
..":QUANTITY"))
215 function webig
:doRemoveDbSheetQuantity(sheet_list
, ctrl
)
216 local db
= webig
.sheetLists
[sheet_list
].db
217 runAH(nil, "leave_modal", "group=ui:interface:webig_drop_destroy_item_quantity_modal")
218 local new_quantity
= tonumber(getUI("ui:interface:webig_drop_destroy_item_quantity_modal:edit:eb").input_string
)
219 local current_quantity
= getDbProp(db
..":"..ctrl
..":QUANTITY")
220 if new_quantity
>= current_quantity
then
221 webig
:deleteItem(db
..":"..ctrl
)
223 addDbProp(db
..":"..ctrl
..":QUANTITY", new_quantity
)
227 function getUICallerRoot()
228 return getUI(getUICaller().id
:match("(ui:interface:[^:]*):?"))
231 function webig
:openUrl(url
, ui
)
233 getUI("ui:interface:web_transactions"):find("html"):browse(url
)
235 getUI("ui:interface:"..ui
):find("html"):browse(url
)
239 function webig
:openUrlInBg(url
)
240 if webig
.urls
[url
] ~= nil then
241 WebQueue
:push(webig
.urls
[url
])
253 RYZOM_WEBIG_VERSION
= 10469