public object[] doSetLua(bool Independent) { object[] ret = null; try { destoryLua(); if (Independent) { lua = new LuaEnv(); } else { lua = mainLua; } CLUtlLua.addLuaLoader(lua); if (!string.IsNullOrEmpty(luaPath)) { ret = CLUtlLua.doLua(lua, luaPath); if (ret != null && ret.Length > 0) { luaTable = (LuaTable)(ret [0]); } else { Debug.LogError("SetLua no luatable returned !! ==" + luaPath); } } } catch (System.Exception e) { Debug.LogError("[" + gameObject.name + "]" + e); } return(ret); }
public void appendList(object data, bool isNeedRePosition, bool isCalculatePosition) { ArrayList _list = null; if (data is LuaTable) { _list = CLUtlLua.luaTableVals2List((LuaTable)data); } else if (data is ArrayList) { _list = (ArrayList)data; } else if (data is object[]) { _list = new ArrayList(); _list.AddRange((object[])data); } if (_list != null) { list.AddRange(_list); } if (RealCellCount > itemList.Count) { //说明之前加载的数据没有占用完所有单元 _appendList(_list, isCalculatePosition); if (isNeedRePosition) { table.Reposition(); } } }
public void insertList(object data, bool isNeedRePosition, bool isCalculatePosition) { ArrayList _list = null; if (data is LuaTable) { _list = CLUtlLua.luaTableVals2List((LuaTable)data); } else if (data is ArrayList) { _list = (ArrayList)data; } else if (data is object[]) { _list = new ArrayList(); _list.AddRange((object[])data); } times = (int)(_list.Count / RealCellCount); //------------------------------------------------ CLUILoopTableCell uiw = null; CLUILoopTableCell targetUIW = null; int newDataCount = _list.Count; Transform t = null; int _startIndex = 0; if (itemList != null && itemList.Count > 0) { _startIndex = NumEx.stringToInt(itemList [0].name); for (int i = 0; i < itemList.Count; i++) { uiw = itemList [i]; if (uiw == null) { continue; } uiw.name = NumEx.nStrForLen(newDataCount + _startIndex + i, 6); } } //------------------------------------------------ if (RealCellCount > itemList.Count) { Debug.Log("说明之前加载的数据没有占用完所有单元"); //说明之前加载的数据没有占用完所有单元 _insertList(_list, isCalculatePosition); if (isNeedRePosition) { table.Reposition(); } } //------------------------------------------------ if (list != null) { _list.AddRange(list); } list = _list; }
void _initList(object data, object onRefreshCurrentPage, int defaltPage) { Start(); canDrag = true; if (isReverse) { flag = -1; } object[] list = null; if (data is LuaTable) { ArrayList _list = CLUtlLua.luaTableVals2List((LuaTable)data); list = _list.ToArray(); _list.Clear(); _list = null; } else if (data is ArrayList) { list = ((ArrayList)data).ToArray(); } this.data = data; this.dataList = list; this.onRefreshCurrentPage = onRefreshCurrentPage; if (defaltPage >= list.Length || defaltPage < 0) { return; } currCell = defaltPage; initCellPos(currCell); }
public void initSerializeFunc() { LuaEnv serializelua = null; if (serializeInMainThread) { serializelua = lua.lua; } else { serializelua = new LuaEnv(); } CLUtlLua.addLuaLoader(serializelua); object[] ret = CLUtlLua.doLua(serializelua, serializeluaPath); if (ret != null && ret.Length > 0) { luaTable = (LuaTable)(ret [0]); packMsgFunc = luaTable.GetInPath <TcpPackMessageAndSendFunc>("packMsg"); unPackMsgFunc = luaTable.GetInPath <TcpUnpackMessageFunc>("unpackMsg"); } else { Debug.LogError("SetLua no luatable returned !! ==" + serializeluaPath); } }
ArrayList wrapList(object data) { ArrayList _list = null; if (data is LuaTable) { _list = CLUtlLua.luaTableVals2List((LuaTable)data); } else if (data is ArrayList) { _list = (ArrayList)data; } else if (data is object[]) { _list = new ArrayList(); _list.AddRange((object[])data); } if (_list == null) { _list = new ArrayList(); } return(_list); }
public virtual void doRestart() { CLPanelManager.destoryAllPanel(); FileEx.cleanCache(); CLUtlLua.cleanFileBytesCacheMap(); //CLUtlLua.isFinishAddLoader = false; CLUIInit.self.clean(); //重新把配置清空 CLMaterialPool.materialTexRefCfg = null; if (mainLua != null) { destoryLua(); // mainLua.Dispose (); // mainLua = null; resetMainLua(); } else { resetMainLua(); } luaTable = null; lua = null; Start(); }
public static void resetList(object parent, GameObject prefabChild, object data, System.Type itype, GameObject nextPage, bool isShowNoneContent, object initCallback, bool isReposition, bool isPlayTween, float tweenSpeed = 0.2f) { object[] list = null; if (data is LuaTable) { ArrayList _list = CLUtlLua.luaTableVals2List((LuaTable)data); list = _list.ToArray(); _list.Clear(); _list = null; } else if (data is ArrayList) { list = ((ArrayList)data).ToArray(); } if ((list == null || list.Length == 0) && isShowNoneContent) { //mtoast = NGUIPublic.toast (mtoast, USWarnMsg.warnMsgNoContent ()); } if (parent == null) { return; } bool isTable = false; if (typeof(UIGrid) == parent.GetType()) { isTable = false; } else if (typeof(UITable) == parent.GetType()) { isTable = true; } else { return; } Transform parentTf = null; if (isTable) { //((UITable)parent).sorting = UITable.Sorting.Alphabetic; parentTf = ((UITable)parent).transform; } else { ((UIGrid)parent).sorted = true; parentTf = ((UIGrid)parent).transform; } Transform go; int i = 0, j = 0; // bool isNeedReposition = false; string childName = ""; for (i = 0; i < parentTf.childCount && list != null && j < list.Length; i++) { childName = NumEx.nStrForLen(i, 5); #if UNITY_5_6_OR_NEWER go = parentTf.Find(childName); #else go = parentTf.FindChild(childName); #endif if (go != null) { if (go.GetComponent(itype) != null) { NGUITools.SetActive(go.gameObject, true); Utl.doCallback(initCallback, go.GetComponent <CLCellBase> (), list [j]); NGUITools.updateAll(go.transform); if (isPlayTween) { resetCellTween(i, parent, go.gameObject, tweenSpeed); } if ((j + 1) == list.Length && nextPage != null) { nextPage.transform.localPosition = Vector3.zero; nextPage.transform.parent = go; if (!isTable) { nextPage.transform.localPosition = new Vector3(0, -((UIGrid)parent).cellHeight, 0); } } j++; } } } while (i < parentTf.childCount) { childName = NumEx.nStrForLen(i, 5); #if UNITY_5_6_OR_NEWER go = parentTf.Find(childName); #else go = parentTf.FindChild(childName); #endif if (go != null && go.gameObject.activeSelf) { if (go.GetComponent(itype) != null) { NGUITools.SetActive(go.gameObject, false); // isNeedReposition = true; } } i++; } while (list != null && j < list.Length) { go = NGUITools.AddChild(parentTf.gameObject, prefabChild).transform; // isNeedReposition = true; childName = NumEx.nStrForLen(j, 5); go.name = childName; Utl.doCallback(initCallback, go.GetComponent <CLCellBase> (), list [j]); NGUITools.updateAll(go.transform); if (isPlayTween) { resetCellTween(j, parent, go.gameObject, tweenSpeed); } if ((j + 1) == list.Length && nextPage != null) { nextPage.transform.localPosition = Vector3.zero; nextPage.transform.parent = go; if (!isTable) { nextPage.transform.localPosition = new Vector3(0, -((UIGrid)parent).cellHeight, 0); } } j++; } if (!isPlayTween) { if (isReposition) { if (!isTable) { ((UIGrid)parent).enabled = true; ((UIGrid)parent).Start(); ((UIGrid)parent).Reposition(); ((UIGrid)parent).repositionNow = true; UIScrollView sv = ((UIGrid)parent).transform.parent.GetComponent <UIScrollView> (); if (sv != null) { sv.ResetPosition(); } } else { ((UITable)parent).enabled = true; ((UITable)parent).Start(); ((UITable)parent).Reposition(); ((UITable)parent).repositionNow = true; UIScrollView sv = ((UITable)parent).transform.parent.GetComponent <UIScrollView> (); if (sv != null) { sv.ResetPosition(); } } } } }
void _setList(object data, object initCellCallback, object onEndListCallback, bool isNeedRePosition, bool isCalculatePosition = false) { ArrayList _list = null; if (data == null) { _list = new ArrayList(); } else if (data is LuaTable) { _list = CLUtlLua.luaTableVals2List((LuaTable)data); } else if (data is ArrayList) { _list = (ArrayList)data; } else if (data is object[]) { _list = new ArrayList(); _list.AddRange((object[])data); } else { _list = new ArrayList(); } try { this.data = data; this.list = _list; this.initCellCallback = initCellCallback; this.onEndListCallback = onEndListCallback; if (!isFinishInit) { init(); } int tmpIndex = 0; times = 0; itemList.Clear(); for (int i = 0; i < cachedTransform.childCount; ++i) { Transform t = cachedTransform.GetChild(i); CLUILoopTableCell uiw = t.GetComponent <CLUILoopTableCell> (); tmpIndex = i; // uiw.name = string.Format ("{0:D5}", tmpIndex); uiw.name = NumEx.nStrForLen(tmpIndex, 6); if (tmpIndex >= 0 && tmpIndex < this.list.Count) { NGUITools.SetActive(t.gameObject, true); Utl.doCallback(this.initCellCallback, t.GetComponent <CLCellBase> (), list [tmpIndex]); if (uiw.isSetWidgetSize) { BoxCollider box = uiw.GetComponent <BoxCollider> (); if (box != null) { box.size = Vector2.zero; } uiw.widget.SetDimensions(0, 0); } NGUITools.updateAll(uiw.transform); if (uiw.isSetWidgetSize) { Bounds bound = NGUIMath.CalculateRelativeWidgetBounds(t, false); uiw.widget.SetDimensions((int)(bound.size.x), (int)(bound.size.y)); } if (!isNeedRePosition) { if (itemList.Count > 0) { CLUILoopTableCell targetUIW = itemList [itemList.Count - 1]; setPosition(uiw, targetUIW, table.direction); } } itemList.Add(uiw); } else { NGUITools.SetActive(t.gameObject, false); } } if (isNeedRePosition) { resetClip(); table.Reposition(); if (scrollView != null) { scrollView.ResetPosition(); } } } catch (System.Exception e) { Debug.LogError(e); } }
public void refreshContentOnly(object data, bool isRePositionTable) { ArrayList _list = null; if (data == null) { _list = new ArrayList(); } else if (data is LuaTable) { _list = CLUtlLua.luaTableVals2List((LuaTable)data); } else if (data is ArrayList) { _list = (ArrayList)data; } else if (data is object[]) { _list = new ArrayList(); _list.AddRange((object[])data); } else { _list = new ArrayList(); } list = _list; if (RealCellCount > itemList.Count) { setList(list, this.initCellCallback); } else { Transform t = null; int tmpIndex = 0; CLUILoopTableCell cell = null; CLUILoopTableCell preCell = null; //for (int i = 0; i < cachedTransform.childCount; ++i) { for (int i = 0; i < itemList.Count; i++) { //t = cachedTransform.GetChild (i); cell = itemList[i]; if (!cell.gameObject.activeSelf) { continue; } tmpIndex = int.Parse(cell.name); //cell = t.GetComponent<CLUILoopTableCell> (); if (cell != null) { Utl.doCallback(this.initCellCallback, cell, list [tmpIndex]); } if (cell.isSetWidgetSize) { BoxCollider box = cell.GetComponent <BoxCollider>(); if (box != null) { box.size = Vector2.zero; } cell.widget.SetDimensions(0, 0); } NGUITools.updateAll(cell.transform); if (cell.isSetWidgetSize) { Bounds bound = NGUIMath.CalculateRelativeWidgetBounds(t, false); cell.widget.SetDimensions((int)(bound.size.x), (int)(bound.size.y)); } if (isRePositionTable) { if (preCell != null) { setPosition(cell, preCell, table.direction); } } preCell = cell; } } }