public void sendEvent(CORE_EVENT_TYPE type, string param, bool sendImmediately = true) { List <string> paramList = new List <string>(); paramList.Add(param); sendEvent(type, paramList, sendImmediately); }
public void unregisteEventHandler(CORE_EVENT_TYPE evt, EventHandler handler) { if (mEventHandlerList.ContainsKey(evt)) { mEventHandlerList[evt].Remove(handler); } }
public void registeEventHandler(CORE_EVENT_TYPE evt, EventHandler handler) { if (!mEventHandlerList.ContainsKey(evt)) { List <EventHandler> handlerList = new List <EventHandler>(); mEventHandlerList.Add(evt, handlerList); } mEventHandlerList[evt].Add(handler); }
public void sendEvent(CORE_EVENT_TYPE type, List <string> param = null, bool sendImmediately = true) { // 如果是立即发送的事件,则需要根据初始化标记判断是否应该立即发送 if (sendImmediately) { sendImmediately = mInitFlag; } if (EditorBase.mEventSystem != null) { EditorBase.mEventSystem.pushEvent(type, param, sendImmediately); } }
public void pushEvent(CORE_EVENT_TYPE evt, List <string> paramList, bool sendImmediately = true) { // 如果立即发送事件,则遍历事件列表,将事件发给每个事件处理者 if (sendImmediately) { if (!mEventParamCountList.ContainsKey(evt)) { return; } int eventParamCount = mEventParamCountList[evt]; if (mEventHandlerList.ContainsKey(evt)) { foreach (var item in mEventHandlerList[evt]) { if ((eventParamCount == 0 && paramList == null) || (eventParamCount == paramList.Count)) { item.notifyEvent(evt, paramList); } else { logError("error : param list size error! should have param count : " + eventParamCount + ", cur param count : " + paramList.Count + ", event : %d" + evt); } } } } // 如果不立即发送事件,则将事件放入事件缓冲里面 else { mEventLock.waitForUnlock(); EventBuffer buffer = new EventBuffer(); buffer.mType = evt; buffer.mParams = paramList; mEventBuffer.Add(buffer); mEventLock.unlock(); } }
public void notifyEvent(CORE_EVENT_TYPE type, List <string> param) { if (type == CORE_EVENT_TYPE.CET_ERROR_LOG) { mOKDialog.setTitle("错误!"); mOKDialog.setInfo(param[0]); mOKDialog.ShowDialog(); } else if (type == CORE_EVENT_TYPE.CET_INFO_LOG) { mOKDialog.setTitle("提示!"); mOKDialog.setInfo(param[0]); mOKDialog.ShowDialog(); } else if (type == CORE_EVENT_TYPE.CET_STOP_PROGRAM) { mRunning = false; } else if (type == CORE_EVENT_TYPE.CET_START_DOWNLOAD_VERSION) { mBusyInfo.setInfo("正在下载版本号..."); mBusyInfo.Show(); } else if (type == CORE_EVENT_TYPE.CET_START_DOWNLOAD_LIST_FILE) { mBusyInfo.setInfo("正在下载列表文件...0%"); mBusyInfo.Show(); } else if (type == CORE_EVENT_TYPE.CET_DOWNLOADING_LIST_FILE) { mBusyInfo.setInfo("正在下载列表文件..." + param[0] + "%"); mBusyInfo.Show(); } // 版本文件下载完毕 else if (type == CORE_EVENT_TYPE.CET_NEW_VERSION) { if (StringUtility.stringToBool(param[0])) { mBusyInfo.Hide(); Show(); mYesNoDialog.setInfo("发现有新版本,是否要更新?(更新会将所有配置文件恢复默认值)"); bool?ret = mYesNoDialog.ShowDialog(); EditorBase.mDownloadManager.startUpdateGame(ret == true); if (ret != true) { downloadDone(true); } } else { finishDownload(); mBusyInfo.Hide(); downloadDone(true); } } // 版本文件和列表文件检查完毕,开始下载资源 else if (type == CORE_EVENT_TYPE.CET_START_DOWNLOAD) { startDownload(); } // 所有文件下载完毕,正在更新文件 else if (type == CORE_EVENT_TYPE.CET_UPDATING_FILE) { mBusyInfo.Show(); mBusyInfo.setInfo("正在更新文件...0%"); } else if (type == CORE_EVENT_TYPE.CET_UPDATING_PROGRESS) { float progress = StringUtility.stringToFloat(param[0]); mBusyInfo.setInfo("正在更新文件..." + StringUtility.floatToString(progress * 100.0f, 3) + "%"); } // 更新完成,所有资源与服务器上同步完成 else if (type == CORE_EVENT_TYPE.CET_UPDATE_DONE) { finishDownload(); downloadDone(true); } // 列表文件下载完毕,开始对比本地文件 else if (type == CORE_EVENT_TYPE.CET_START_GENERATE_LOCAL_FILE) { notifyStartGenerateLocalFile(); mBusyInfo.Show(); mBusyInfo.setInfo("正在检查本地文件...0/" + param[0]); } // 正在对比本地文件 else if (type == CORE_EVENT_TYPE.CET_GENERATING_LOCAL_FILE) { mBusyInfo.setInfo("正在检查本地文件..." + param[1] + "/" + param[0]); } // 文件对比完成 else if (type == CORE_EVENT_TYPE.CET_FINISH_GENERATE_LOCAL_FILE) { notifyFinishGenerateLocalFile(); mBusyInfo.Hide(); } // 取消下载更新 else if (type == CORE_EVENT_TYPE.CET_CANCEL_UPDATE) { downloadDone(false); } // 对比所有文件后未发现需要更新的文件 else if (type == CORE_EVENT_TYPE.CET_NOTHING_UPDATE) { notifyNothingUpdate(); downloadDone(true); } // 有文件上传完毕 else if (type == CORE_EVENT_TYPE.CET_FINISH_UPLOAD) { ; } // 所有文件上传完毕 else if (type == CORE_EVENT_TYPE.CET_ALL_UPLOADED) { uploadDone(); } }
public void sendDelayEvent(CORE_EVENT_TYPE type, List <string> param = null) { sendEvent(type, param, false); }
public void sendDelayEvent(CORE_EVENT_TYPE type, string param) { sendEvent(type, param, false); }