随笔分类 -  Lua及迅雷Bolt引擎

lua 小技巧
摘要:lua 小技巧 1. 把常用的工具函数添加到 _G 里面,所有的文件都可以直接调用: 2. 使用 操作符赋默认值: 3. 使用 操作符实现 C 语言中 的功能 : 4. 获取 UTF 8 字符串中的字符数(中英文混合) : 这种做法跟 UTF 8 格式有关,标准... 阅读全文

posted @ 2015-11-27 18:11 zuibunan 阅读(4302) 评论(0) 推荐(0)

使用 Bolt 实现 GridView 表格控件
摘要:用 Bolt 实现了一个表格控件:1. 提供 Insert,Remove,Get,Set 接口,可以为表格增删数据;2. 通过 ItemClass, ItemSetDataFunc 属性来指定显示数据所用的 itemObj;3. 不会每个 data 都创建 itemObj 来显示, 只为需要显示的数... 阅读全文

posted @ 2015-05-18 10:42 zuibunan 阅读(721) 评论(0) 推荐(0)

lua的table库
摘要:函数列表: table.insert(table,[ pos,] value) table.remove(table[, pos]) table.concat(table[, sep[, i[, j]]]) table.sort(table[, comp]) ... 阅读全文

posted @ 2014-10-23 18:18 zuibunan 阅读(5866) 评论(0) 推荐(0)

lua 打印 table 拷贝table
摘要:-- 打印tablefunction print_lua_table (lua_table, indent) if lua_table == nil or type(lua_table) ~= "table" then return end local functio... 阅读全文

posted @ 2014-09-03 20:40 zuibunan 阅读(4604) 评论(0) 推荐(0)

使用 xlue 实现简单 listbox 控件
摘要:基于 XLUE 实现的 listbox 控件 1. 提供增删查接口,将 obj 作为子控件添加到列表; 2. 提供 Attach/Detach 方法,可以将子控件的事件转发出来; 3. 支持滚动条; 4. 支持鼠标滚轮; 实现过程中的注意点: 1. 使用... 阅读全文

posted @ 2014-08-26 22:14 zuibunan 阅读(506) 评论(0) 推荐(0)

使用 xlue 实现 tips
摘要:经常遇到如下的需求鼠标hover到目标对象一定时间后,弹出tips或者窗口;鼠标离开目标对象一定时间后,隐藏tips或者窗口;鼠标从目标对象移动到弹出的窗口上,这种状况下不隐藏窗口;考虑到这种需求,绘制如下的状态图:如上图所示,将tips的状态分为hide,showing,show,hiding,e... 阅读全文

posted @ 2014-08-15 17:05 zuibunan 阅读(392) 评论(0) 推荐(0)

C 调用 lua 函数
摘要:C 调用 lua 函数 需要考虑的问题: 1. 使用 lua_pcall 可以调用 lua 函数,首先把 lua 函数入栈,然后把参数入栈, lua_pcall(luaState, 参数个数, 返回值个数, 0) ; 2. 为了在事件触发时回调 lua 函数,需要把 lua 函数保存起来,使用 luaL_ref(luaState, LUA_REGISTRYINDEX) 将位... 阅读全文

posted @ 2014-08-07 11:54 zuibunan 阅读(584) 评论(0) 推荐(0)

lua 的 WriteFile 和 ReadFile
摘要:lua 的 ReadFile 和 WriteFile注意:lua 代码中的 string 可以包含二进制数据 string.len(str) 不会被 '\0' 截断从 lua 传入 c 时: 需要传入包含二进制数据的 string 和数据的 size, size 用 string.len(str) ... 阅读全文

posted @ 2014-07-29 18:32 zuibunan 阅读(3728) 评论(1) 推荐(0)

Bolt 动画
摘要:引擎内置的 6 种动画--PosChangeAnimation 平移local ani = XLGetObject("Xunlei.UIEngine.AnimationFactory"):CreateAnimation("PosChangeAnimation")ani:BindObj(imageOb... 阅读全文

posted @ 2014-03-17 22:13 zuibunan 阅读(785) 评论(0) 推荐(0)

lua string函数
摘要:lua的string函数: 参数中的index从1开始,负数的意义是从后开始往前数,比如-1代表最后一个字母 对于string类型的值,可以使用OO的方式处理,如string.byte(s.i)可以被写成s:byte(i) It also sets a metatable for ... 阅读全文

posted @ 2013-12-11 18:28 zuibunan 阅读(2764) 评论(0) 推荐(0)

lua的split函数
摘要:function split(s, delim) if type(delim) ~= "string" or string.len(delim) <= 0 then return end local start = 1 local t = {} while... 阅读全文

posted @ 2013-12-06 11:49 zuibunan 阅读(7633) 评论(0) 推荐(0)

Lua表的构造及遍历
摘要:关于lua中的table,主要的困惑来自于table既可以当array用又可以当record用,有时候就会混淆不清。 lua中的table貌似是用map来实现的,array是语法糖,一种特例。下面是lua中构造table的标准方法:local numbers = {[1]=1, [2]=2, ["... 阅读全文

posted @ 2013-10-09 16:08 zuibunan 阅读(18250) 评论(0) 推荐(0)

导航