Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuancheng Zhang committed Oct 26, 2020
2 parents d964aac + e212a1f commit fcda3f5
Show file tree
Hide file tree
Showing 17 changed files with 68 additions and 90 deletions.
17 changes: 11 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
Smap/AutoSave_*
Code/Csv/*.lua
Code/CSV/*.lua
Code/Luas/*.csv
Code/Lua/*.csv
Code/LUA/*.csv
smap/AutoSave_*
xls/*.lua
xls/*.csv
csv/*.lua
csv/*.xls
csv/*.xlsm
csv/*.xlsx
code/*.csv
code/*.xls
code/*.xlsm
code/*.xlsx
*.smap.storage
*.iso
~$*
Expand Down
2 changes: 1 addition & 1 deletion Smap/avatar-ava.smap

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions ava-x2l.zip
Git LFS file not shown
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,13 @@ end
--- 初始化
function Client:InitClient()
print('[Client] InitClient()')
self:InitRandomSeed()
self:InitClientCustomEvents()
self:PreloadCsv()
self:PreloadXls()
self:GenInitAndUpdateList()
self:RunInitDefault()
AnimationMain:Init()
self:InitOtherModules()
end

--- 预加载所有的CSV表格
function Client:PreloadCsv()
print('[Client] PreloadCsv()')
CsvUtil.PreloadCsv(Config.ClientPreload, Csv, Config)
end

--- 预加载所有的Excel Lua Table
function Client:PreloadXls()
print('[Client] PreloadXls()')
XlsUtil.PreloadXls(Config.ClientPreload, Xls, Config)
end

--- 初始化客户端的CustomEvent
function Client:InitClientCustomEvents()
if localPlayer.C_Event == nil then
Expand All @@ -68,6 +54,11 @@ function Client:RunInitDefault()
end
end

--- 初始化客户端随机种子
function Client:InitRandomSeed()
math.randomseed(os.time())
end

--- 初始化包含Init()方法的模块
function Client:InitOtherModules()
for _, m in ipairs(initList) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ end
--- 初始化
function Server:InitServer()
print('[Server] InitServer()')
self:InitRandomSeed()
self:InitServerCustomEvents()
self:InitCsvAndXls()
self:PreloadCsv()
self:PreloadXls()
self:GenInitAndUpdateList()
self:RunInitDefault()
self:InitOtherModules()
Expand All @@ -53,18 +52,6 @@ function Server:InitCsvAndXls()
end
end

--- 预加载所有的CSV表格
function Server:PreloadCsv()
print('[Client] PreloadCsv()')
CsvUtil.PreloadCsv(Config.ServerPreload, Csv, Config)
end

--- 预加载所有的Excel Lua Table
function Server:PreloadXls()
print('[Server] PreloadXls()')
XlsUtil.PreloadXls(Config.ServerPreload, Xls, Config)
end

--- 生成需要Init和Update的模块列表
function Server:GenInitAndUpdateList()
ModuleUtil.GetModuleListWithFunc(Module.S_Module, 'InitDefault', initDefaultList)
Expand All @@ -79,6 +66,11 @@ function Server:RunInitDefault()
end
end

--- 初始化服务器随机种子
function Server:InitRandomSeed()
math.randomseed(os.time())
end

--- 初始化包含Init()方法的模块
function Server:InitOtherModules()
for _, m in ipairs(initList) do
Expand Down
3 changes: 1 addition & 2 deletions code/['World']['Global']['ModuleRequireScript'].Script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ ModuleUtil.LoadModules(Framework)

-- Globle Defines, Server and Clinet Modules
ModuleUtil.LoadModules(Define)
ModuleUtil.LoadModules(Xls)
ModuleUtil.LoadXlsModules(Xls, Config)
ModuleUtil.LoadModules(Module.S_Module)
ModuleUtil.LoadModules(Module.C_Module)

-- Plugin Modules
AnimationMain = require(world.Global.Plugin.FUNC_UIAnimation.Code.AnimationMainModule)
GuideSystem = require(world.Global.Plugin.FUNC_Guide.GuideSystemModule)
Original file line number Diff line number Diff line change
Expand Up @@ -330,14 +330,8 @@ end

--向给定table的指定位置插入数值(tab:被插入表,index:序号)
function LinkedList:CopyTo(tab, index)
if type(tab) ~= 'table' then
error('[LinkedList] bad argument "table"')
return
end
if index < 1 then
error('[LinkedList] Index out of range')
return
end
assert(type(tab) == 'table', '[LinkedList] bad argument "table"')
assert(index >= 1, '[LinkedList] Index out of range')
local ptrnode = self.First
if ptrnode == nil then
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,28 @@ local ModuleUtil = {}
--- 加载模块目录
-- @param _root 模块目录的节点
function ModuleUtil.LoadModules(_root)
if _root == nil then
error('[ModuleUtil] Node does NOT exist!')
end
local tmp, name = _root:GetChildren()
assert(_root, '[ModuleUtil] Node does NOT exist!')
local tmp = _root:GetChildren()
for _, v in pairs(tmp) do
name = (v.Name):gsub('Module', '')
print('[ModuleUtil] Load: ' .. name)
_G[name] = require(v)
end
end

--- 加载XLS表格目录
-- @param _root 模块目录的节点
function ModuleUtil.LoadXlsModules(_root, _config)
assert(_root, '[ModuleUtil] Node does NOT exist!')
assert(_config, '[ModuleUtil] Config does NOT exist!')
local tmp = _root:GetChildren()
for _, v in pairs(tmp) do
name = (v.Name):gsub('XlsModule', '')
print('[ModuleUtil] Load: ' .. name)
_config[name] = require(v)
end
end

--- 加载多个模块目录
function ModuleUtil.LoadAllModules(...)
local args = table.pack(...)
Expand All @@ -34,15 +45,9 @@ end
-- @param @string _fn 方法名 function_name
-- @param @table _list 存放的table
function ModuleUtil.GetModuleListWithFunc(_root, _fn, _list)
if _root == nil then
error('[ModuleUtil] Node does NOT exist!')
end
if string.isnilorempty(_fn) then
error('[ModuleUtil] Function name is nil or empty!')
end
if _list == nil then
error('[ModuleUtil] List is NOT initialized!')
end
assert(_root, '[ModuleUtil] Node does NOT exist!')
assert(not string.isnilorempty(_fn), '[ModuleUtil] Function name is nil or empty!')
assert(_list, '[ModuleUtil] List is NOT initialized!')
local tmp, name = _root:GetChildren()
for _, v in pairs(tmp) do
name = (v.Name):gsub('Module', '')
Expand All @@ -52,6 +57,7 @@ function ModuleUtil.GetModuleListWithFunc(_root, _fn, _list)
end
end

--- 新建一个模块实例(ServerBase or ClientBase)
function ModuleUtil.New(_name, _baseClass)
local t = class(_name, _baseClass)
return t, t:GetSelf()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,10 @@ end
-- @return timer id
-- @see https://www.w3schools.com/jsref/met_win_settimeout.asp
function TimeUtil.SetTimeout(_func, _seconds)
if _func == nil then
error('TimeUtil.SetTimeout() _func 不能为空')
return
elseif _seconds < 0 then
error('TimeUtil.SetTimeout() 延迟时间需大于等于0')
return
elseif _seconds == 0 then
print('TimeUtil.SetTimeout() 事件立即执行')
assert(_func, '[TimeUtil] TimeUtil.SetTimeout() _func 不能为空')
assert(_seconds >= 0, '[TimeUtil] TimeUtil.SetTimeout() 延迟时间需大于等于0')
if _seconds == 0 then
print('[TimeUtil] TimeUtil.SetTimeout() 事件立即执行')
invoke(_func)
return
end
Expand All @@ -115,13 +111,8 @@ end
-- @return timer id
-- @see https://www.w3schools.com/jsref/met_win_setinterval.asp
function TimeUtil.SetInterval(_func, _seconds)
if _func == nil then
error('TimeUtil.SetInterval() _func 不能为空')
return
elseif _seconds <= 0 then
error('TimeUtil.SetInterval() 延迟时间需大于0')
return
end
assert(_func, '[TimeUtil] TimeUtil.SetInterval() _func 不能为空')
assert(_seconds > 0, '[TimeUtil] TimeUtil.SetInterval() 延迟时间需大于0')
local id = #eventList + 1
-- convert to milliseconds
local ms = math.floor(_seconds * 1000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ end
--- 类型解析配置表
local parser = {
int = function(_raw)
return tonumber(_raw)
return math.floor(tonumber(_raw))
end,
float = function(_raw)
return tonumber(_raw)
Expand Down
3 changes: 0 additions & 3 deletions csv/['World']['Global']['Csv']['Message'].Table.csv

This file was deleted.

3 changes: 0 additions & 3 deletions csv/['World']['Global']['Csv']['Sound'].Table.csv

This file was deleted.

9 changes: 0 additions & 9 deletions csv/['World']['Global']['Csv']['UIAnimation'].Table.csv

This file was deleted.

3 changes: 3 additions & 0 deletions xls/ExampleTable1.xls
Git LFS file not shown
3 changes: 3 additions & 0 deletions xls/GlobalSetting.xls
Git LFS file not shown
3 changes: 3 additions & 0 deletions xls/LanguagePack.xls
Git LFS file not shown
3 changes: 3 additions & 0 deletions xls/Sound.xls
Git LFS file not shown

0 comments on commit fcda3f5

Please sign in to comment.