예제 #1
0
 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();
     }
 }
예제 #2
0
        public void init()
        {
            string gymID = SystemUtility.getRegistryValue("Software\\北京踏行天际科技发展有限公司\\电能动力4.0", "REGISTE_CODE");

            if (gymID == "")
            {
                mOKDialog.setInfo("找不到设备的注册信息!");
                mOKDialog.ShowDialog();
                exit();
                return;
            }
            // 如果游戏已经运行则直接退出
            if (SystemUtility.isProgressRunning(CommonDefine.GAME_NAME))
            {
                mOKDialog.setInfo("游戏已经运行!");
                mOKDialog.ShowDialog();
                exit();
                return;
            }
            mEditorCore.init();
            registeEventHandler();
            mStartTime      = DateTime.Now;
            mTimer          = new DispatcherTimer();
            mTimer.Interval = TimeSpan.FromMilliseconds(30);
            mTimer.Tick    += Tick;
            mTimer.Start();
            // 默认隐藏窗口
            Hide();

            setAutoCloseUploaded(false);
            setAutoStartGame(true);

            // 判断当前目录下是否有需要上传的文件
            // 只上传崩溃产生的文件,文件夹名格式20XX-XX-XX_XXXXX
            List <string> folders = new List <string>();
            string        path    = "./";

            FileUtility.findDirectory(path, ref folders, false);
            for (int i = 0; i < folders.Count;)
            {
                // 移除./
                folders[i] = folders[i].Substring(path.Length, folders[i].Length - path.Length);
                // 符合条件的文件夹保留,其余的移除
                if (folders[i].Length > 11 && StringUtility.startWith(folders[i], "20") && folders[i][4] == '-' && folders[i][7] == '-' && folders[i][10] == '_')
                {
                    ++i;
                }
                else
                {
                    folders.RemoveAt(i);
                }
            }
            List <string> files = new List <string>();
            int           count = folders.Count;

            for (int i = 0; i < count; ++i)
            {
                FileUtility.findFiles(folders[i], ref files);
            }
            List <FileUploadInfo> uploadFiles = new List <FileUploadInfo>();
            int uploadCount = files.Count;

            for (int i = 0; i < uploadCount; ++i)
            {
                FileUploadInfo info = new FileUploadInfo();
                info.mFileName   = files[i];
                info.mUploadPath = gymID + "/" + StringUtility.getFilePath(files[i]);
                uploadFiles.Add(info);
            }
            start(uploadFiles);
        }