public void OnValueChanged(string tmp) { Debug.Log("Value Changed"); foreach (Transform child in Content) { if (child.gameObject.name == "Property") { var key = child.Find("Key").GetComponent <Text>().text; var value = child.Find("InputField").GetComponent <InputField>().text; if (Properties.ContainsKey(key)) { Properties[key] = value; } else { Properties.Add(key, value); } if (key == "Name") { TypeEventSystem.Send(new ResBlockNameChanged() { MD5 = Properties["MD5"], FileName = Properties["Name"] + Properties["Extension"] }); } } } }
IEnumerator GetAttachments(string itemType, int itemId) { var url = string.Format(AppConfig.JiuquUrl + "/admin-course/item/attachment?itemType={0}&itemId={1}", itemType, itemId); UnityWebRequest webRequest = UnityWebRequest.Get(url); webRequest.SetRequestHeader("Authorization", GetAuthCode()); webRequest.SetRequestHeader("Content-Type", "application/json"); yield return(webRequest.SendWebRequest()); if (webRequest.isNetworkError) { Debug.Log(": Error: " + webRequest.error); } else { var list = JsonConvert.DeserializeObject <List <Attachment> >(webRequest.downloadHandler.text); var attachment = list.Find((item) => item.name == ResName); if (_operation == "upload") { yield return(StartCoroutine(DownloadZip(attachment))); yield return(StartCoroutine(UploadZip(itemId))); var attachmentId = _attachmentId; if (attachment != null) { yield return(StartCoroutine(UpdateArgu(attachment.id.ToString(), itemType, itemId.ToString(), attachment.name, attachmentId))); } else { yield return(StartCoroutine(CreateResArgu(itemType, itemId, attachmentId))); } SimplePopupManager.Instance.CreatePopup("上传成功~~~"); SimplePopupManager.Instance.AddButton("朕知道,退下吧", delegate { Debug.Log("clicked on yes"); }); SimplePopupManager.Instance.ShowPopup(); } else if (_operation == "download") { if (attachment != null) { yield return(StartCoroutine(DownloadZip(attachment))); TypeEventSystem.Send(new FileDragIn() { Path = _zipname, Tag = ResourceTag.Default, Point = new POINT(0, 0) }); } else { SimplePopupManager.Instance.CreatePopup("后台没有" + ResName); SimplePopupManager.Instance.AddButton("朕知道,退下吧", delegate { Debug.Log("clicked on yes"); }); SimplePopupManager.Instance.ShowPopup(); } } } }
public void Execute() { Server.GetAllRemotePackageInfo(list => { RenderEndCommandExecuter.PushCommand(() => { Model.PackageDatas = PackageInfosRequestCache.Get().PackageDatas; TypeEventSystem.Send(new PackageManagerViewUpdate() { PackageDatas = Model.SelectedPackageType, VersionCheck = Model.VersionCheck, }); }); }); Server.GetAllRemotePackageInfoV5((list, categories) => { RenderEndCommandExecuter.PushCommand(() => { Model.PackageDatas = PackageInfosRequestCache.Get().PackageDatas; TypeEventSystem.Send(new PackageManagerViewUpdate() { PackageDatas = Model.SelectedPackageType, VersionCheck = Model.VersionCheck, }); }); }); }
public void TypeEventSystem_UnRegisterTest() { var receivedCount = 0; Action <string> onReceive = (msg) => { receivedCount++; }; TypeEventSystem.Register(onReceive); TypeEventSystem.Register(onReceive); TypeEventSystem.Register(onReceive); TypeEventSystem.Register(onReceive); TypeEventSystem.Register(onReceive); TypeEventSystem.UnRegister(onReceive); TypeEventSystem.UnRegister(onReceive); TypeEventSystem.UnRegister(onReceive); TypeEventSystem.Send("Hello"); Assert.AreEqual(receivedCount, 2); // 为了避免影响其他的单元测试,所以要注销一下 TypeEventSystem.UnRegister(onReceive); TypeEventSystem.UnRegister(onReceive); }
public void ImportToResPanel() { TypeEventSystem.Send(new ClearRescoursePanel()); var dict = getResConfig(DirTools.GetRestoredPNGDir()); foreach (KeyValuePair <string, Dictionary <string, string> > kv in dict) { var properties = kv.Value; var Name = properties["Name"]; var MD5 = properties["MD5"]; var Extension = properties["Extension"]; var fileinfo = new FilePathInfo() { FilePath = DirTools.GetRestoredPNGDir() + "/" + MD5 + Extension, FileName = Name + Extension, Extension = Extension, MD5 = MD5 }; TypeEventSystem.Send(fileinfo); TypeEventSystem.Send(new SetBlockProperties() { MD5 = MD5, properties = properties }); } UIMgr.ClosePanel("UIUploadPanel"); }
void OnFilesAsync(List <string> aFiles, POINT aPos) { var existCsb = aFiles.ToList <string>().Find((file) => file.EndsWith(".csb")) != null; existCsb = false; foreach (var path in aFiles) { if (Directory.Exists(path)) { var files = Directory.GetFiles(path, "*"); // var isCsb = files.ToList<string>().Find((file) => file.EndsWith(".csb")) != null; Directory.GetFiles(path, "*").ForEach((file) => { TypeEventSystem.Send(new FileDragIn() { Path = file, Tag = ResourceTag.Default, Point = aPos }); }); } else if (File.Exists(path)) { TypeEventSystem.Send(new FileDragIn() { Path = path, Tag = ResourceTag.Default, Point = aPos }); } } }
public void Execute() { TypeEventSystem.Send(new LoginSucceed() { InLoginView = Model.InLoginView, Logined = Model.Logined }); }
void Start() { TemplateList.onValueChanged.AddListener((value) => { var text = TemplateList.captionText.text; var template = templates[text]; TypeEventSystem.Send(template); transform.gameObject.SetActive(false); }); }
public void Execute() { Model.InLoginView = false; TypeEventSystem.Send(new LoginSucceed() { Logined = Model.Logined, InLoginView = Model.InLoginView }); }
public void Login() { Service.DoGetToken(mUsername, mPassword, token => { User.Username.Value = mUsername; User.Password.Value = mPassword; User.Token.Value = token; User.Save(); TypeEventSystem.Send(new LoginSucceed()); }); }
void Update() { if (Input.GetMouseButtonDown(0)) { TypeEventSystem.Send(new OnLeftMouseClickEvent()); } if (Input.GetMouseButtonDown(1)) { TypeEventSystem.Send(new OnRightMouseClickEvent()); } }
public void DeleteItem() { if (File.Exists(ResInfo.FileFullName)) { File.Delete(ResInfo.FileFullName); TypeEventSystem.Send(new DeleteItem() { Extension = ResInfo.Extension }); } Destroy(gameObject); }
public void TypeEventSystem_RegisterTest() { var receivedMsg = string.Empty; Action <string> onReceive = (msg) => { receivedMsg = msg; }; TypeEventSystem.Register(onReceive); TypeEventSystem.Send("Hello"); Assert.AreEqual(receivedMsg, "Hello"); // 为了避免影响其他的单元测试,所以要注销一下 TypeEventSystem.UnRegister(onReceive); }
private void Start() { TypeEventSystem.Register <GameStartEvent>(OnGameStartEvent); TypeEventSystem.Register <GameOverEvent>(OnGameOverEvent); TypeEventSystem.Register <ISkillEvent>(OnSkillEvent); TypeEventSystem.Send <GameStartEvent>(); TypeEventSystem.Send(new GameOverEvent() { Score = 100 }); // 要把事件发送给父类 TypeEventSystem.Send <ISkillEvent>(new PlayerSkillAEvent()); TypeEventSystem.Send <ISkillEvent>(new PlayerSkillBEvent()); }
void OnFilesAsync(List <string> aFiles, POINT aPos) { foreach (var path in aFiles) { MessageBoxV2.AddMessage(path); var extension = Path.GetExtension(path); var fileName = Path.GetFileName(path); var md5 = Utils.GetMD5HashFromFile(path); TypeEventSystem.Send(new FilePathInfo() { FilePath = path, Extension = extension, FileName = fileName, MD5 = md5 }); } }
private IEnumerator GO() { yield return(new WaitForSeconds(1f)); FluentText.ChangeWord(humanEvent.TipTexts[Random.Range(0, humanEvent.TipTexts.Length)]); FluentText.ShowPanel(); // Get target position and Move to target pos missionPos = App.Container.Resolve <LevelManager>().GetTargetPos(humanEvent.EventType); SwitchAgentObstacle(true); Agent.SetDestination(RandomNearPos(missionPos, Agent.stoppingDistance / 2)); while (!ArriveTarget()) { yield return(null); // 等待到下一帧 } SwitchAgentObstacle(false); // 到达指定地点后进行结算 if (humanEvent.IsParty) { var lookDir = missionPos - transform.position; lookDir.Set(lookDir.x, 0, lookDir.z); Quaternion q = Quaternion.LookRotation(lookDir); transform.rotation = q; // 播放动画 string anim = humanEvent.PartyAnimations[ Random.Range(0, humanEvent.PartyAnimations.Length)]; animator.PlayInFixedTime(anim, -1, 1f); // 告诉 Manager 自己到达某处聚集点 TypeEventSystem.Send(new PartyNotification(missionPos, transform)); yield return(new WaitForSeconds(2)); FluentText.HidePanel(); } else { ReportMission(done: true); Destroy(gameObject); } }
public void OnPointerClick(PointerEventData eventData) { var pointerId = eventData.pointerId; if (pointerId == -1) { Debug.Log("鼠标左键点击"); } else if (pointerId == -2) { Debug.Log("鼠标右键点击"); TypeEventSystem.Send(new RemoveBlock() { MD5 = Properties["MD5"], Extension = Properties["Extension"] }); Destroy(gameObject); } }
// 告诉 Manager 该项活动是否被阻止,进行记录 private void ReportMission(bool done) { // 活动被阻止 if (!done) { if (humanEvent.IsParty) { TypeEventSystem.Send(new PartyNotification(missionPos, transform, true)); } TypeEventSystem.Send(new MissionExpelledNotification(humanEvent)); } // 活动成功完成 else { TypeEventSystem.Send(new MissionCompletedNotification(humanEvent)); } Debug.Log("Mission: " + humanEvent.EventType.ToString() + (done ? "完成" : "被阻止")); }
public RegisterView() { var usernameLine = new HorizontalLayout().AddTo(this); new LabelView("username:"******"").AddTo(usernameLine); var passwordLine = new HorizontalLayout().AddTo(this); new LabelView("password:"******"").PasswordMode().AddTo(passwordLine); new ButtonView("注册", () => { }).AddTo(this); new ButtonView("返回注册", () => { TypeEventSystem.Send <IPackageLoginCommand>(new OpenRegisterView()); }) .AddTo(this); }
private void OnRefresh(PackageManagerViewUpdate viewUpdateEvent) { mScrollLayout.Clear(); mCategoriesSelectorView.Menus(viewUpdateEvent.Categories); mCategoriesSelectorView.Index.Bind(newIndex => { TypeEventSystem.Send <IEditorStrangeMVCCommand>(new PackageManagerSelectCategoryCommand() { CategoryIndex = newIndex }); }); new SpaceView(2).AddTo(mScrollLayout); foreach (var packageData in viewUpdateEvent.PackageDatas) { new SpaceView(2).AddTo(mScrollLayout); new PackageView(packageData).AddTo(mScrollLayout); } }
public void Init(IQFrameworkContainer container) { // view mRootLayout = new VerticalLayout(); var treeNode = new TreeNode(true, LocaleText.FrameworkPackages).AddTo(mRootLayout); var verticalLayout = new VerticalLayout("box"); treeNode.Add2Spread(verticalLayout); mCategoriesSelectorView = new ToolbarView(0) .AddTo(verticalLayout); mCategoriesSelectorView.Index.Bind(newIndex => { TypeEventSystem.Send <IEditorStrangeMVCCommand>(new PackageManagerSelectCategoryCommand() { CategoryIndex = newIndex }); }); new HeaderView() .AddTo(verticalLayout); var packageList = new VerticalLayout("box") .AddTo(verticalLayout); mScrollLayout = new ScrollLayout() .Height(240) .AddTo(packageList); TypeEventSystem.Register <PackageManagerViewUpdate>(OnRefresh); // 执行 TypeEventSystem.Send <IEditorStrangeMVCCommand>(new PackageManagerStartUpCommand()); var bindingSet = BindKit.CreateBindingSet(this, new PackageManagerViewModel()); }
public void Test() { TypeEventSystem.Send(new FilePathInfo() { FilePath = @"C:\Users\yzqlwt\Dropbox\flash\加减法\brick.png", Extension = ".png", FileName = "brick.png", MD5 = "dddddddddddddddddddddd" }); TypeEventSystem.Send(new FilePathInfo() { FilePath = @"C:\Users\yzqlwt\Dropbox\flash\加减法\元件 2 副本.png", Extension = ".png", FileName = "元件 2 副本.png", MD5 = "dddddddddddddddddddddd111" }); TypeEventSystem.Send(new FilePathInfo() { FilePath = @"C:\Users\yzqlwt\Dropbox\flash\加减法\brick.png", Extension = ".png", FileName = "brick333.png", MD5 = "dddddddddddddddddddddd222" }); }
void ImportZip(string path) { var tempPath = DirTools.GetTempPath(); var unzipPath = tempPath + "/unzip"; if (Directory.Exists(unzipPath)) { DirTools.DeleteFilesAndFolders(unzipPath); } ZipUtil.UnZipFile(path, unzipPath); var isExist = File.Exists(unzipPath + "/ResConfig.json"); var ret = false; if (isExist) { StreamReader sr = new StreamReader(unzipPath + "/ResConfig.json"); if (sr == null) { return; } string json = sr.ReadToEnd(); sr.Close(); var configTemplate = JsonConvert.DeserializeObject <ConfigTemplate>(json); if (configTemplate.resource != null) { ret = true; } } if (ret) { StreamReader sr = new StreamReader(unzipPath + "/ResConfig.json"); if (sr == null) { return; } string json = sr.ReadToEnd(); sr.Close(); var configTemplate = JsonConvert.DeserializeObject <ConfigTemplate>(json); configTemplate.resource.Where((item) => { return(item.Value.Tag != ResourceTag.TagsMap[ResourceTag.TexturePackage]); }).ForEach((item) => { var tag = ResourceTag.TagsMap.Where((tagItem) => { return(tagItem.Value == item.Value.Tag); }) .First().Key; string filepath = ""; if (tag == ResourceTag.None) { filepath = unzipPath + "/none/" + item.Value.Name; } else if (tag == ResourceTag.CocosStudio) { filepath = unzipPath + "/" + item.Value.Name; } Debug.Log(string.Format("从zip导入文件路径{0} 文件Tag{1}", filepath, tag)); TypeEventSystem.Send(new FileDragIn() { Path = filepath, Tag = tag }); }); if (configTemplate.plist != null) { configTemplate.plist.ForEach((name) => { var plistPath = unzipPath + "/plist/" + name + ".plist"; var pngPath = unzipPath + "/plist/" + name + ".png"; Unpacker(plistPath, pngPath); }); configTemplate.resource.Where((item) => { return(item.Value.Tag == ResourceTag.TagsMap[ResourceTag.TexturePackage]); }).ForEach((item) => { var md5 = item.Value.Md5; string imagePath = DirTools.GetRestoredPNGDir() + "/" + md5 + item.Value.Extension; Debug.Log(imagePath); if (File.Exists(imagePath)) { File.Move(imagePath, DirTools.GetRestoredPNGDir() + "/" + item.Value.Name); TypeEventSystem.Send(new FileDragIn() { Path = DirTools.GetRestoredPNGDir() + "/" + item.Value.Name, Tag = ResourceTag.TexturePackage }); } else { Debug.Log("bububu"); } }); } } else { Directory.GetFiles(unzipPath, "*").ForEach((file) => { var extension = System.IO.Path.GetExtension(file); if (extension != ".plist") { TypeEventSystem.Send(new FileDragIn() { Path = file, Tag = ResourceTag.Default }); } else { var pathName = System.IO.Path.GetDirectoryName(file); var fileName = System.IO.Path.GetFileNameWithoutExtension(file); var plistPath = file; var pngPath = pathName + '/' + fileName + ".png"; Unpacker(plistPath, pngPath); var RestoredPath = DirTools.GetRestoredPNGDir(); Directory.GetFiles(RestoredPath, "*").ForEach((filePath) => { TypeEventSystem.Send(new FileDragIn() { Path = filePath, Tag = ResourceTag.Default }); }); } }); } }
// Start is called before the first frame update void Start() { DirTools.ClearTempPath(); TypeEventSystem.Register <FileDragIn>((fileDragIn) => { var path = fileDragIn.Path; System.IO.FileInfo file = new System.IO.FileInfo(path); if (file.Extension == ".zip") { ImportZip(path); return; } else if (file.Extension == ".csb") { // var csbInspector = transform.GetComponent<CsbInspector>(); // var totalInfo = transform.GetComponent<QFramework.Example.UIPanel>().GetTotalInfo(); // totalInfo = totalInfo.Where((info) => { return info.Extension == ".csb"; }).ToList(); // var paths = totalInfo.Select((info) => { return info.FileFullName; }).ToList(); // paths.Add(path); // var totalPaths = new List<string>(); // paths.ForEach((name) => // { // totalPaths.AddRange(csbInspector.GetCsbImagePath(name)); // }); // totalPaths = totalPaths.Select((t) => { return Path.GetFileName(t); }).ToList(); // totalPaths = totalPaths.Distinct().ToList(); // transform.GetComponent<AppData>().CsbImagePaths = totalPaths; } else if (file.Extension == ".png") { // var ret = isCocosStudioImage(path); // if (ret) // { // fileDragIn.Tag = ResourceTag.CocosStudio; // } } var tempPath = DirTools.GetTempPath(); File.Copy(file.FullName, tempPath + "/" + file.Name, true); var md5Code = GetMD5HashFromFile(path); if (md5Code == null) { SimplePopupManager.Instance.CreatePopup(string.Format("{0}可能被占用", fileDragIn.Path)); SimplePopupManager.Instance.AddButton("朕知道了", delegate { }); SimplePopupManager.Instance.ShowPopup(); return; } TypeEventSystem.Send(new FileInfo() { FileName = file.Name, FileFullName = tempPath + "/" + file.Name, Extension = file.Extension, Time = DateTime.Now, MD5 = md5Code, Tag = fileDragIn.Tag, DropType = fileDragIn.Point.x < 860 ? DragDropType.Add : DragDropType.Replace, }); }); if (Application.platform == RuntimePlatform.WindowsEditor) { var path = @"C:\Users\yzqlw\Desktop\png"; Directory.GetFiles(path, "*").ForEach((file) => { TypeEventSystem.Send(new FileDragIn() { Path = file, Tag = ResourceTag.Default }); }); // TypeEventSystem.Send(new FileDragIn() // { // Path = path, // Tag = ResourceTag.Default // }); Invoke("test", 3.0f); } else if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer) { var path = @"/Users/yzqlwt/Desktop/image"; Directory.GetFiles(path, "*").ForEach((file) => { TypeEventSystem.Send(new FileDragIn() { Path = file, Tag = ResourceTag.Default, Point = new POINT(900, 100) }); }); } }
public void Send <T>(T eventKey) { TypeEventSystem.Send <T>(eventKey); }
public void Init(IQFrameworkContainer container) { var bindingSet = BindKit.CreateBindingSet(this, new PackageManagerViewModel() .InjectSelfWithContainer(mPackageManagerApp.Container) .Init()); mRootLayout = new VerticalLayout(); var treeNode = new TreeNode(true, LocaleText.FrameworkPackages).AddTo(mRootLayout); var verticalLayout = new VerticalLayout("box"); treeNode.Add2Spread(verticalLayout); var searchView = new HorizontalLayout("box") .AddTo(verticalLayout); searchView.AddChild(new LabelView("搜索:") .FontBold() .FontSize(12) .Width(40)); searchView.AddChild( new TextView().Height(20) .Do(search => { bindingSet.Bind(search.Content) .For(v => v.OnValueChanged) .To(vm => vm.Search) .CommandParameter(search.Content); }) ); mAccessRightView = new ToolbarView() .Menus(new List <string>() { "all", PackageAccessRight.Public.ToString(), PackageAccessRight.Private.ToString() }) .AddTo(verticalLayout) .Do(self => { bindingSet.Bind(self.Index).For(v => v.Value, v => v.OnValueChanged) .To(vm => vm.AccessRightIndex); }); mCategoriesSelectorView = new ToolbarView() .AddTo(verticalLayout) .Do(self => { bindingSet.Bind(self.Index).For(v => v.Value, v => v.OnValueChanged) .To(vm => vm.CategoryIndex); }); new HeaderView() .AddTo(verticalLayout); var packageList = new VerticalLayout("box") .AddTo(verticalLayout); mScrollLayout = new ScrollLayout() .Height(240) .AddTo(packageList); // 执行 TypeEventSystem.Send <IEditorStrangeMVCCommand>(new PackageManagerStartUpCommand()); bindingSet.Bind().For((v) => v.PackageDatas) .To(vm => vm.PackageDatas); bindingSet.Bind().For(v => v.Categories) .To(vm => vm.Categories); bindingSet.Build(); }
IEnumerator ClickResourceItem() { yield return(new WaitForFixedUpdate()); TypeEventSystem.Send(new ResourceItemClick()); }