Example #1
0
    void OnGUI()
    {
        GUIStyle styleCmdArea = new GUIStyle();

        styleCmdArea.normal.background = MakeTex(600, 80, Color.white);

        //	info area
        GUILayout.BeginArea(new Rect(10, 10, 600, 80), styleCmdArea);

        GUILayout.BeginHorizontal();
        GUILayout.Label("Platform:", GUILayout.Width(200));
        selectedPlatform = EditorGUILayout.Popup(selectedPlatform, listPlatform.ToArray());
        switch (selectedPlatform)
        {
        case 0:
            if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.Android)
            {
                EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.Android);
                LoadConfigXML(CommonPatcherData.cnfFN);
                LoadVersionXML();
            }
            else
            {
                GUILayout.EndHorizontal();
            }
            break;

        case 1:
            if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.StandaloneWindows)
            {
                EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.StandaloneWindows);
                LoadConfigXML(CommonPatcherData.cnfFN);
                LoadVersionXML();
            }
            else
            {
                GUILayout.EndHorizontal();
            }
            break;
        }

        GUILayout.BeginHorizontal();
        GUILayout.Label("Last Version : " + lastMajorVersion + "." + lastMinorVersion);
        GUILayout.Label(">>>");
        GUILayout.Label("New Version :");
        chkLastMajorVersion = GUILayout.TextField("" + chkLastMajorVersion);
        chkLastMinorVersion = GUILayout.TextField("" + chkLastMinorVersion);
        if (GUILayout.Button("Apply", GUILayout.Width(70)))
        {
            //	apply last version info and make folders and modify xml files.
            if (EditorUtility.DisplayDialog("You know that ?!", "This work just makes a folder for new version and change the text of last version. Later, you can make new resources for next patch when you press the button [Upload to repository].", "I see!!") == true)
            {
                SaveVersionXML();
            }
        }
        if (GUILayout.Button("Rollback", GUILayout.Width(70)))
        {
            string prevVersion = PatchVersion.getPreviousVersion(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.patchVersionFN);
            int    prevMajor   = Convert.ToInt32(prevVersion.Split('_')[1]);
            int    prevMinor   = Convert.ToInt32(prevVersion.Split('_')[2]);

            string curVersion = verDoc.SelectSingleNode("/VERSIONS/PATCH").Attributes["LastVersion"].Value;
            int    curMajor   = Convert.ToInt32(curVersion.Split('_')[1]);
            int    curMinor   = Convert.ToInt32(curVersion.Split('_')[2]);

            if (EditorUtility.DisplayDialog("Caution!!", "Your last version(VER " + curMajor.ToString("D2") + "." + curMinor.ToString("D3") + ") data will remove complete. Are you sure?", "YES", "NO") == true)
            {
                //	check last version
                Debug.Log("Rollback to previous Version >> " + prevVersion);

                //	modify patch.xml file
                verDoc.SelectSingleNode("/VERSIONS/PATCH").Attributes["LastVersion"].Value = prevVersion;
                PatchVersion.removeVersionNode(verDoc, curMajor, curMinor);
                XmlTool.writeXml(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.patchVersionFN, verDoc);

                //	remove assets.xml and files, and backup folder
                string _dn = CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/VER_" + curMajor.ToString("D2") + "/" + curMinor.ToString("D3");
                Directory.Delete(_dn, true);

                //	latest folder change
                Directory.Delete(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.lastVersionRepo, true);
                Directory.Move(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.lastVersionRepo + "_VER_" + curMajor.ToString("D2") + "_" + curMinor.ToString("D3"),
                               CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.lastVersionRepo);

                lastMajorVersion    = prevMajor;
                chkLastMajorVersion = curMajor.ToString("D2");
                lastMinorVersion    = prevMinor;
                chkLastMinorVersion = curMinor.ToString("D3");
            }
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Path :");
        CommonPatcherData.repoPath = GUILayout.TextField(CommonPatcherData.repoPath);
        //	read config file
        if (GUILayout.Button("Read", GUILayout.Width(100)))
        {
            LoadConfigXML(CommonPatcherData.cnfFN);
        }

        if (GUILayout.Button("Save", GUILayout.Width(100)))
        {
            cnfDoc.SelectSingleNode("/ToolConfig/Repository").Attributes ["path"].Value = CommonPatcherData.repoPath;
            SaveConfigXML(CommonPatcherData.cnfFN, cnfDoc);
            MakeLocalRepo();
        }

        GUILayout.EndHorizontal();
        GUILayout.EndArea();

        //	command area
        GUILayout.BeginArea(new Rect(10, 100, 600, 140));
        GUILayout.BeginHorizontal();

        if (GUILayout.Button("Build AssetBundles", GUILayout.Width(150)))
        {
            ActiveABMWType = ABMWType.Build;
            BuildScript.BuildAssetBundles();
            return;
        }

        if (GUILayout.Button("unregisted assets", GUILayout.Width(150)))
        {
            ActiveABMWType = ABMWType.Unregisted;
            checkUnregistedAssets();
        }

        if (GUILayout.Button("All AssetBundles List", GUILayout.Width(150)))
        {
            ActiveABMWType = ABMWType.PatchInfo;
            checkRegistedAssets();
        }

        if (GUILayout.Button("Upload to repository", GUILayout.Width(150)))
        {
            if (EditorUtility.DisplayDialog("Upload !!", "Did you make a folder for new version?! If not, press the button [apply]. This will make a folder and change the version number for new version.", "I DID!!", "Ooops!") == true)
            {
                ActiveABMWType = ABMWType.Upload;
                BuildScript.BuildAssetBundles();

                //	compare all AssetBundles with "repoPath + lastVersionRepo"'s all files
                List <FileInfo> listNew     = new List <FileInfo>();
                List <FileInfo> listModify  = new List <FileInfo>();
                List <FileInfo> listRemoved = new List <FileInfo>();

                {
                    DirectoryInfo latestDir     = new DirectoryInfo(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget);
                    FileInfo []   latestABFiles = latestDir.GetFiles("*.*", SearchOption.AllDirectories);

                    DirectoryInfo buildDir   = new DirectoryInfo(BuildScript.GetAssetBundleBuildPath() + "/" + EditorUserBuildSettings.activeBuildTarget);
                    FileInfo []   newABFiles = buildDir.GetFiles("*.*", SearchOption.AllDirectories);

                    int newIndex = 0;
                    foreach (FileInfo fi in newABFiles)
                    {
                        int latestIndex = 0;
                        foreach (FileInfo latefi in latestABFiles)
                        {
                            int ret = compareFile(fi, latefi);
                            if (ret == 0)                              //	completely different
                            {
                            }
                            else if (ret == 1)                              //	same exactly
                            {
                                break;
                            }
                            else if (ret == 2)                               //	modified
                            {
                                listModify.Add(fi);
                                break;
                            }
                            latestIndex++;
                        }

                        if (latestIndex == latestABFiles.Length)
                        {
                            listNew.Add(fi);
                        }
                        newIndex++;
                    }

                    foreach (FileInfo latefiR in latestABFiles)
                    {
                        int chkIndex = 0;
                        foreach (FileInfo fiR in newABFiles)
                        {
                            if (fiR.Name == latefiR.Name)
                            {
                                break;
                            }
                            chkIndex++;
                        }
                        if (chkIndex == latestABFiles.Length)
                        {
                            listRemoved.Add(latefiR);
                        }
                    }
                }

                //	upload updated AssetBundles to the new repository.
                SaveAssetsXML(listNew, listModify, listRemoved);
            }
        }

        GUILayout.EndHorizontal();
        GUILayout.EndArea();

        //	console area
        GUILayout.BeginArea(new Rect(10, 150, 600, 600));
        switch (ActiveABMWType)
        {
        case ABMWType.Build:

            break;

        case ABMWType.Unregisted:
            ListUnregistedAssets();
            break;

        case ABMWType.PatchInfo:
            ListRegistedAssets();
            break;

        case ABMWType.Upload:

            break;
        }
        GUILayout.EndArea();
    }
Example #2
0
	void OnGUI(){
		GUIStyle styleCmdArea = new GUIStyle();
		styleCmdArea.normal.background = MakeTex(600, 80, Color.white);

		//	info area 
		GUILayout.BeginArea (new Rect (10, 10, 600, 80), styleCmdArea);

		GUILayout.BeginHorizontal();
		GUILayout.Label ("Platform:", GUILayout.Width(200));
		selectedPlatform = EditorGUILayout.Popup( selectedPlatform, listPlatform.ToArray() );
		switch (selectedPlatform) {
		case 0:
			if(EditorUserBuildSettings.activeBuildTarget != BuildTarget.Android){
				EditorUserBuildSettings.SwitchActiveBuildTarget( BuildTarget.Android );
				LoadConfigXML (CommonPatcherData.cnfFN);
				LoadVersionXML ();
			}else
				GUILayout.EndHorizontal();
			break;
		case 1: 
			if(EditorUserBuildSettings.activeBuildTarget != BuildTarget.StandaloneWindows){
				EditorUserBuildSettings.SwitchActiveBuildTarget( BuildTarget.StandaloneWindows );
				LoadConfigXML (CommonPatcherData.cnfFN);
				LoadVersionXML ();
			}else
				GUILayout.EndHorizontal();
			break;
		}

		GUILayout.BeginHorizontal();
		GUILayout.Label ("Last Version : "+ lastMajorVersion + "."+lastMinorVersion);
		GUILayout.Label (">>>");
		GUILayout.Label ("New Version :");
		chkLastMajorVersion = GUILayout.TextField(""+chkLastMajorVersion);
		chkLastMinorVersion = GUILayout.TextField(""+chkLastMinorVersion);
		if (GUILayout.Button ("Apply", GUILayout.Width (70))) {
			//	apply last version info and make folders and modify xml files.
			if(EditorUtility.DisplayDialog("You know that ?!","This work just makes a folder for new version and change the text of last version. Later, you can make new resources for next patch when you press the button [Upload to repository].","I see!!") == true){
				SaveVersionXML();
			}
		}
		if (GUILayout.Button ("Rollback", GUILayout.Width (70))) {

			string prevVersion = PatchVersion.getPreviousVersion( CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.patchVersionFN );
			int prevMajor = Convert.ToInt32(prevVersion.Split('_')[1]);
			int prevMinor = Convert.ToInt32(prevVersion.Split('_')[2]);

			string curVersion = verDoc.SelectSingleNode("/VERSIONS/PATCH").Attributes["LastVersion"].Value;
			int curMajor = Convert.ToInt32(curVersion.Split('_')[1]);
			int curMinor = Convert.ToInt32(curVersion.Split('_')[2]);

			if(EditorUtility.DisplayDialog("Caution!!","Your last version(VER "+ curMajor.ToString ("D2") + "." + curMinor.ToString ("D3") +") data will remove complete. Are you sure?","YES","NO") == true)
			{
				//	check last version
				Debug.Log ( "Rollback to previous Version >> "+  prevVersion);

				//	modify patch.xml file 
				verDoc.SelectSingleNode("/VERSIONS/PATCH").Attributes["LastVersion"].Value = prevVersion;
				PatchVersion.removeVersionNode( verDoc, curMajor, curMinor);
				XmlTool.writeXml(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/"+CommonPatcherData.patchVersionFN , verDoc);

				//	remove assets.xml and files, and backup folder
				string _dn = CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/VER_" + curMajor.ToString ("D2") + "/" + curMinor.ToString ("D3");
				Directory.Delete(_dn,true);

				//	latest folder change
				Directory.Delete(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/"+CommonPatcherData.lastVersionRepo, true);
				Directory.Move ( CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.lastVersionRepo + "_VER_" + curMajor.ToString ("D2") + "_" + curMinor.ToString ("D3"),
				                CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/"+CommonPatcherData.lastVersionRepo);

				lastMajorVersion = prevMajor;
				chkLastMajorVersion = curMajor.ToString ("D2");
				lastMinorVersion = prevMinor;
				chkLastMinorVersion = curMinor.ToString ("D3");
			}
		}
		GUILayout.EndHorizontal();

		GUILayout.BeginHorizontal();
		GUILayout.Label ("Path :");
		CommonPatcherData.repoPath = GUILayout.TextField(CommonPatcherData.repoPath);
		//	read config file
		if (GUILayout.Button ("Read", GUILayout.Width (100))) {
			LoadConfigXML ( CommonPatcherData.cnfFN );
		}

		if (GUILayout.Button ("Save", GUILayout.Width (100))) {
			cnfDoc.SelectSingleNode ("/ToolConfig/Repository").Attributes ["path"].Value = CommonPatcherData.repoPath;
			SaveConfigXML(CommonPatcherData.cnfFN , cnfDoc);
			MakeLocalRepo();
		}

		GUILayout.EndHorizontal();
		GUILayout.EndArea();

		//	command area
		GUILayout.BeginArea (new Rect (10, 100, 600, 140));
		GUILayout.BeginHorizontal();

		if (GUILayout.Button ("Build AssetBundles", GUILayout.Width (150))) {
			ActiveABMWType=ABMWType.Build;
			BuildScript.BuildAssetBundles();
			return;
		}

		if (GUILayout.Button ("unregisted assets", GUILayout.Width (150))) {
			ActiveABMWType=ABMWType.Unregisted;
			checkUnregistedAssets();
		}

		if (GUILayout.Button ("All AssetBundles List", GUILayout.Width (150))) {
			ActiveABMWType=ABMWType.PatchInfo;
			checkRegistedAssets();
		}

		if (GUILayout.Button ("Upload to repository", GUILayout.Width (150))) {

			if(EditorUtility.DisplayDialog("Upload !!","Did you make a folder for new version?! If not, press the button [apply]. This will make a folder and change the version number for new version.","I DID!!", "Ooops!") == true){

				ActiveABMWType=ABMWType.Upload;
				BuildScript.BuildAssetBundles();

				//	compare all AssetBundles with "repoPath + lastVersionRepo"'s all files
				List<FileInfo> listNew = new List<FileInfo>();
				List<FileInfo> listModify = new List<FileInfo>();
				List<FileInfo> listRemoved = new List<FileInfo>();

				{
					DirectoryInfo latestDir = new DirectoryInfo(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget);
					FileInfo [] latestABFiles = latestDir.GetFiles("*.*", SearchOption.AllDirectories);

					DirectoryInfo buildDir = new DirectoryInfo( BuildScript.GetAssetBundleBuildPath() + "/"+EditorUserBuildSettings.activeBuildTarget);
					FileInfo [] newABFiles = buildDir.GetFiles("*.*", SearchOption.AllDirectories);

					int newIndex = 0;
					foreach(FileInfo fi in newABFiles)
					{
						int latestIndex = 0;
						foreach(FileInfo latefi in latestABFiles)
						{
							int ret = compareFile(fi, latefi);
							if( ret == 0){ //	completely different
							}else if( ret == 1){//	same exactly
								break;
							}else if( ret == 2){ //	modified
								listModify.Add(fi);
								break;
							}
							latestIndex++;
						}

						if(latestIndex == latestABFiles.Length)
						{
							listNew.Add(fi);
						}
						newIndex++;
					}

					foreach(FileInfo latefiR in latestABFiles){
						int chkIndex = 0;
						foreach(FileInfo fiR in newABFiles){
							if(fiR.Name == latefiR.Name)
							{
								break;
							}
							chkIndex++;
						}
						if(chkIndex == latestABFiles.Length)
							listRemoved.Add(latefiR);
					}
				}

				//	upload updated AssetBundles to the new repository.
				SaveAssetsXML(listNew, listModify, listRemoved);
			}
		}

		GUILayout.EndHorizontal ();
		GUILayout.EndArea ();

		//	console area
		GUILayout.BeginArea (new Rect (10, 150, 600, 600));
		switch (ActiveABMWType)
		{
		case ABMWType.Build:

			break;
		case ABMWType.Unregisted:
			ListUnregistedAssets ();
			break;
		case ABMWType.PatchInfo:
			ListRegistedAssets ();
			break;	
		case ABMWType.Upload:
			
			break;	
		}
		GUILayout.EndArea ();
	}