private static void ShowInstanceUi <T>(UiInfo uiInfo, bool fromBack, Action <T> notify = null, Type classType = null) where T : UiInstance { Type typeKey = classType ?? typeof(T); //存在缓存 if (InstDic.ContainsKey(typeKey)) { UiInstance inst = InstDic[typeKey]; AfterLoadInstance(inst, uiInfo, fromBack, notify); } else { //已经在加载中 bool bLoading; if (InstLoadState.TryGetValue(uiInfo.ViewPath, out bLoading) && bLoading) { //do noting } else { //加载 InstLoadState[uiInfo.ViewPath] = true; UiInstance.LoadUi(uiInfo, uiInfo.ViewPath, typeKey, inst => { InstLoadState[uiInfo.ViewPath] = false; InstDic[typeKey] = inst; AfterLoadInstance(inst, uiInfo, fromBack, notify); }); } } }
// Start is called before the first frame update void Start() { uiInfo = GameObject.FindGameObjectWithTag("UiInfo").GetComponent <UiInfo>(); playerMovement = gameObject.GetComponent <Movement>(); currentHealth = startingHealth; managerPowerUp = GetComponent <PowerUpManger>(); }
private static void AfterLoadInstance <T>(UiInstance inst, UiInfo uiInfo, bool fromBack, Action <T> notify) where T : UiInstance { inst.UiInfo = uiInfo; ShowUiView(inst, uiInfo.Layer); inst.AfterOnShow(fromBack); if (notify != null) { notify.Invoke(inst as T); } }
private void EntityChangedCallback(UiInfo changedEntity) { try { foreach (CallbackData innerCallbackData in usersOnline) { innerCallbackData.UserCallback.OnEntityChanged(changedEntity); } } catch (Exception) { } }
} // 먹은 코인의 숫자다. void Start() { _coinObjPool = MyTools.LoadObject(MyTools.LoadType.COIN_OBJECT_POOL); _nguiCoinObj = MyTools.LoadObject(MyTools.LoadType.NGUI_COIN_OBJ); if (_nguiCoinObj != null) { _uiInfo = _nguiCoinObj.GetComponent <UiInfo>(); } if (_uiInfo == null) { MyTools.LoadObjectMessage(false, "PickupCoin.cs -> UiInfo component"); } coinCnt = 0; }
public static UiInfo DealPrefab(string path) { var uiInfo = new UiInfo(); uiInfo.Components = new List <ComponentInfo>(); var prefab = AssetDatabase.LoadAssetAtPath(path, typeof(GameObject)) as GameObject; var transform = prefab.transform; uiInfo.UiName = prefab.name; uiInfo.UiLayer = "NormalLayer"; DealChildren(transform, ref uiInfo.Components, ""); return(uiInfo); }
private void AddNewContactCallback(UiInfo contactCreator, User addedContact) { try { foreach (CallbackData innerCallbackData in usersOnline) { if (innerCallbackData.User.Id == addedContact.Id) { innerCallbackData.UserCallback.OnNewContactAdded(contactCreator); } } } catch (Exception) { } }
private void RemoveContactCallback(UiInfo contactRemover, User removedContact) { try { foreach (CallbackData innerCallbackData in usersOnline) { if (innerCallbackData.User.Id == removedContact.Id) { innerCallbackData.UserCallback.OnContactRemoved(contactRemover); } } } catch (Exception) { } }
private static T CacheShowInstanceUi <T>(UiInfo uiInfo, bool fromBack, Type classType = null) where T : UiInstance { Type typeKey = classType ?? typeof(T); //存在缓存 if (InstDic.ContainsKey(typeKey)) { UiInstance inst = InstDic[typeKey]; if (inst != null) { AfterLoadInstanceNoCallBack <T>(inst, fromBack, uiInfo); return(inst as T); } else { Debug.LogError("存在缓存情况 CacheShowInstanceUi inst is null, :" + uiInfo.ViewPath); } } else { //已经在加载中 bool bLoading; if (InstLoadState.TryGetValue(uiInfo.ViewPath, out bLoading) && bLoading) { //do noting } else { //加载 InstLoadState[uiInfo.ViewPath] = true; var inst = UiInstance.ShowImmediately(uiInfo.ViewPath, typeKey); if (inst != null) { InstLoadState[uiInfo.ViewPath] = false; InstDic[typeKey] = inst; AfterLoadInstanceNoCallBack <T>(inst, fromBack, uiInfo); return(inst as T); } else { Debug.LogError("新加载情况 CacheShowInstanceUi inst is null, :" + uiInfo.ViewPath); } } } return(null); }
public static void loadPicture(UserServiceClient userServiceClient, UiInfo uiInfos) { lock (contactsMonitor) { var chatFile = FileServiceClient.getChatFileById(uiInfos.ImageId); if (chatFile?.Source?.Length > 0) { var memstr = new MemoryStream(chatFile.Source); Dispatcher.CurrentDispatcher.Invoke(() => { uiInfos.UiImage = Image.FromStream(memstr); }); } else { Dispatcher.CurrentDispatcher.Invoke(() => { uiInfos.UiImage = ImageHelper.GetDefImage(); }); } } }
public override void OnContactRemoved(UiInfo newContact) { try { var foundedUiInfo = ContactsList.FirstOrDefault(c => c.UniqueName == newContact.UniqueName); if (foundedUiInfo != null) { var temp = new List <UiInfo>(); temp.AddRange(ContactsList); ContactsList.Remove(foundedUiInfo); ContactsList = temp; } } catch (Exception) { } }
public void Init() { try { List <UiInfo> tempUiInfos = new List <UiInfo>(); Task.Run((() => { try { _group = UserServiceClient.GetChatGroup(_groupUiInfo.UniqueName); tempUiInfos = UserServiceClient.GetGroupParticipants(_group.Id); UiInfo currentUserUiInfo = tempUiInfos.FirstOrDefault(info => info.UniqueName == GlobalBase.CurrentUser.Login); tempUiInfos.Remove(currentUserUiInfo); GlobalBase.loadPictures(UserServiceClient, tempUiInfos); } catch (Exception) { } })).ContinueWith(task => { try { GroupMemberList = tempUiInfos; GroupName = _group.Name; CurrentGroupName = _group.Name; GroupMembersAmount = GroupMemberList.Count.ToString(); SetAvatarForUI(); } catch (Exception) { } }); } catch (Exception) { } }
public override void OnNewContactAdded(UiInfo newContact) { try { var foundedUiInfo = ContactsList.FirstOrDefault(c => c.UniqueName == newContact.UniqueName); if (foundedUiInfo == null) { var temp = new List <UiInfo>(); temp.AddRange(ContactsList); GlobalBase.loadPicture(UserServiceClient, newContact); temp.Add(newContact); ContactsList = temp; } } catch (Exception) { } }
public void Load() { FolderBrowserDialog fb = new FolderBrowserDialog(); if (fb.ShowDialog() == DialogResult.OK) { string path = fb.SelectedPath; string iniPath = path + "\\config.ini"; if (File.Exists(iniPath) == false) { MessageBox.Show("配置文件不存在"); } _ProcessName = Common.ReadIni("form", "name", iniPath, ""); using (FileStream sr = new FileStream(path + "\\form.jpg", FileMode.Open)) { _Bitmap = new Bitmap(sr); sr.Close(); } Dictionary <string, string> ui_loca = Common.ReadIniSecAllValue("UI_Location", iniPath); Dictionary <string, string> click_loca = Common.ReadIniSecAllValue("UI_ClickPoint", iniPath); foreach (string key in ui_loca.Keys) { UiInfo ui = new UiInfo(); ImageInfo imageInfo = new ImageInfo(); using (FileStream sr = new FileStream(path + "\\" + key + ".jpg", FileMode.Open)) { imageInfo._img = new Bitmap(sr); sr.Close(); } imageInfo._screenLoca1 = imageInfo._relativeLocal = GetPoint(ui_loca[key]); ui._img = imageInfo; ui._clickLoca = GetPoint(click_loca[key]); _ListUi.Add(ui); } } }
public static void R <T>(string viewPath, UiLayer layer, UiLoadType loadType) where T : UiInstance { var fullName = typeof(T).FullName; if (fullName != null && RegisteredUi.ContainsKey(fullName)) { return; } var uiInfo = new UiInfo { Type = typeof(T), ViewPath = viewPath, Layer = layer, LoadType = loadType, }; var name = typeof(T).FullName; if (name != null) { RegisteredUi[name] = uiInfo; } }
public static void LoadUi(UiInfo uiInfo, string resource, Type typeUi, Action <UiInstance> notify) { ResourceMgr.Load(resource, obj => { ResourceMgr.InstantiateX(obj, uiObject => { uiObject.SetActiveSafe(true); var script = GameObjectTools.AddComponent(uiObject, typeUi); UiInstance ui = script as UiInstance; if (ui) { ui.UiInfo = uiInfo; ui.OnLoadFinish(); notify(ui); } else { Debug.LogError(string.Format("Load UI fail ui == null resource{0}", resource)); } }); }); }
public override void OnEntityChanged(UiInfo changedEntity) { try { if (changedEntity.UniqueName == GlobalBase.CurrentUser.Login) { GlobalBase.UpdateProfileUi.Invoke(); } else { foreach (var uiInfo in ContactsList) { if (uiInfo.UniqueName == changedEntity.UniqueName) { GlobalBase.UpdateContactList(); break; } } } } catch (Exception) { } }
private void Start() { playerMovement = gameObject.GetComponent <Movement>(); uiInfo = GameObject.FindGameObjectWithTag("UiInfo").GetComponent <UiInfo>(); }
private static void AfterLoadInstanceNoCallBack <T>(UiInstance inst, bool fromBack, UiInfo uiInfo) where T : UiInstance { inst.UiInfo = uiInfo; ShowUiView(inst, uiInfo.Layer); inst.AfterOnShow(fromBack); }
// Start is called before the first frame update void Start() { uiInfo = GameObject.FindGameObjectWithTag("UiInfo").GetComponent <UiInfo>(); }
public virtual void OnNewContactAdded(UiInfo newContact) { //throw new NotImplementedException(); }
//public RectOffset cardBoardProcess => ConstantInstance.GetComponent<HorizontalLayoutGroup>(); //public static float targetCardBoardProcess=> cardBoardProcess; private void Awake() => Instance = this;
public virtual void OnEntityChanged(UiInfo changedEntity) { //throw new NotImplementedException(); }