Exemplo n.º 1
0
    void OnGUI_Version(AgentSetVersion version)
    {
        GUIStyle version_style;

        EditorGUILayout.LabelField("All Plugins", BoldLabel);
        scroll = EditorGUILayout.BeginScrollView(scroll, GUILayout.Height(180));
        for (int i = 0; i < plugins.Agents.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();
            if (version.hasPlugin(plugins.Agents[i].filename))
            {
                AgentVersion v = version.getVersionOfPlugin(plugins.Agents[i].filename);
                v.status = EditorGUILayout.Toggle(v.status, GUILayout.MaxWidth(50));
                if (v.status == false)
                {
                    version_style = NormalLabel;
                }
                else
                {
                    {
                        if (v.isVersionReady(version))
                        {
                            if (v.isManifestReady(manifest) && v.isStringsReady(exist_strings))
                            {
                                version_style = GreenLabel;
                            }
                            else
                            {
                                version_style = YellowLabel;
                            }
                        }
                        else
                        {
                            version_style = RedLabel;
                        }
                    }
                }
            }
            else
            {
                bool status = EditorGUILayout.Toggle(false, GUILayout.MaxWidth(50));
                if (status == true)
                {
                    version.addPlugin().ImportFromManifest(plugins.Agents[i], true);
                    version_style = RedLabel;
                }
                else
                {
                    version_style = NormalLabel;
                }
            }
            EditorGUILayout.LabelField(plugins.Agents[i].filename, version_style);
            if (GUILayout.Button("...", PositiveButton))
            {
                agent = plugins.Agents[i];
            }
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.EndScrollView();
    }
 public static AgentSetVersion LoadVersionFromFile(string path)
 {
     AgentSetVersion av = new AgentSetVersion();
     System.IO.StreamReader reader = new System.IO.StreamReader(path);
     string xmldata = reader.ReadToEnd();
     reader.Close();
     XmlDocument doc = new XmlDocument();
     doc.LoadXml(xmldata);
     XmlNode agent = doc.GetElementsByTagName(AgentDependency.Element.AgentSet)[0];
     av.Read(agent);
     doc.Clone();
     return av;
 }
Exemplo n.º 3
0
    public static void                      SaveVersionToFile(string path, AgentSetVersion version)
    {
        XmlTextWriter writer = new XmlTextWriter(path, System.Text.Encoding.UTF8);

        writer.Indentation = 4;
        writer.Formatting  = Formatting.Indented;
        writer.Settings.NewLineHandling     = NewLineHandling.Entitize;
        writer.Settings.NewLineOnAttributes = true;
        writer.WriteStartDocument();
        writer.WriteComment("This file is generated by Android Plugin Manager (created by Peyman Abdi peyman[at]nemo-games[dot]com).");
        version.Write(writer);
        writer.Close();
        AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
    }
Exemplo n.º 4
0
    public static AgentSetVersion   LoadVersionFromFile(string path)
    {
        AgentSetVersion av = new AgentSetVersion();

        System.IO.StreamReader reader = new System.IO.StreamReader(path);
        string xmldata = reader.ReadToEnd();

        reader.Close();
        XmlDocument doc = new XmlDocument();

        doc.LoadXml(xmldata);
        XmlNode agent = doc.GetElementsByTagName(AgentDependency.Element.AgentSet)[0];

        av.Read(agent);
        doc.Clone();
        return(av);
    }
Exemplo n.º 5
0
    public static List <AgentSetVersion> GetVersionsFromPath(string path, AgentDependency deps)
    {
        List <AgentSetVersion> versions = new List <AgentSetVersion>();

        string[] allnames = System.IO.Directory.GetFiles(path);
        for (int i = 0; i < allnames.Length; i++)
        {
            if (allnames[i].EndsWith(".xml"))
            {
                bool            isvalid = true;
                AgentSetVersion newv    = LoadVersionFromFile(allnames[i]);
                for (int j = 0; j < newv.Plugins.Count; j++)
                {
                    AgentVersion plug = newv.Plugins[j];
                    if (deps.getAgentWithFilename(plug.filename) != null)
                    {
                        plug.ManifestSource = deps.getAgentWithFilename(plug.filename);
                    }
                    else
                    {
                        newv.Plugins.RemoveAt(j);
                        j--; continue;
                    }
                }
                if (isvalid)
                {
                    versions.Add(newv);
                }
                else
                {
                    Debug.Log("Could not add version from file: " + allnames[i] + ". Version missmatch or something like that!");
                }
            }
        }
        return(versions);
    }
Exemplo n.º 6
0
 public bool isVersionReady(AgentSetVersion s)
 {
     if (status)
     {
         for (int i = 0; i < MetaData.Count; i++) if (MetaData[i].value == "NOT SET") return false;
         for (int i = 0; i < Strings.Count; i++) if (Strings.strings[i].value == "NOT SET") return false;
         for (int i = 0; i < ManifestSource.RequiredAgents.Count; i++)
             if (!s.isPluginActive(ManifestSource.RequiredAgents[i])) return false;
     }
     return true;
 }
Exemplo n.º 7
0
 public void OnGUI()
 {
     EditorGUILayout.BeginVertical();
     EditorGUILayout.LabelField("Versions", BoldLabel);
     EditorGUILayout.BeginHorizontal();
     new_version = EditorGUILayout.TextField("New Version", new_version);
     if (GUILayout.Button("New", GUILayout.MaxWidth(100)))
     {
         AgentSetVersion newver = new AgentSetVersion();
         newver.name = new_version;
         new_version = "";
         newver.bundleid = PlayerSettings.bundleIdentifier;
         newver.versionName = PlayerSettings.bundleVersion;
         newver.versionCode = PlayerSettings.Android.bundleVersionCode.ToString();
         if (!newver.name.EndsWith(".xml")) newver.name += ".xml";
         Versions.Add(newver);
     }
     EditorGUILayout.EndHorizontal();
     scroll = EditorGUILayout.BeginScrollView(scroll, GUILayout.Height(180));
     for (int i = 0; i < Versions.Count; i++)
     {
         EditorGUILayout.BeginHorizontal("Box");
         EditorGUILayout.LabelField(Versions[i].name + "  Bundle:" + Versions[i].bundleid, getVersionStyle(Versions[i]));
         if (GUILayout.Button("...", PositiveButton))
         {
             EditingVersion = Versions[i];
         }
         EditorGUILayout.EndHorizontal();
     }
     EditorGUILayout.EndScrollView();
     if (EditingVersion != null)
     {
         EditorGUILayout.LabelField("Version Properties", BoldLabel);
         EditingVersion.bundleid = EditorGUILayout.TextField("Package", EditingVersion.bundleid);
         EditingVersion.versionCode = EditorGUILayout.TextField("Version Code", EditingVersion.versionCode);
         EditingVersion.versionName = EditorGUILayout.TextField("Version Name", EditingVersion.versionName);
         EditorGUILayout.LabelField("Pre Definitions", BoldLabel);
         EditorGUILayout.BeginHorizontal("Box");
         new_def = EditorGUILayout.TextField("New Definition", new_def);
         if (GUILayout.Button("+", PositiveButton))
         {
             EditingVersion.PreDefine.Add(new_def);
             new_def = "";
         }
         EditorGUILayout.EndHorizontal();
         for (int i = 0; i < EditingVersion.PreDefine.Count; i++)
         {
             EditorGUILayout.BeginHorizontal();
             if (GUILayout.Button("-", NegetiveButton))
             {
                 EditingVersion.PreDefine.RemoveAt(i);
                 i--;
                 continue;
             }
             EditingVersion.PreDefine[i] = EditorGUILayout.TextField(EditingVersion.PreDefine[i]);
             EditorGUILayout.EndHorizontal();
         }
     }
     EditorGUILayout.EndVertical();
 }
Exemplo n.º 8
0
 public GUIStyle getVersionStyle(AgentSetVersion ver)
 {
     if (ver.isVersionReady())
     {
         if (ver.isManifestReady(manifest))
             return GreenLabel;
         else
             return YellowLabel;
     } else return RedLabel;
 }
Exemplo n.º 9
0
 public void OnGUI(AgentVersion version, AgentDependency deps, AgentSetVersion vset)
 {
     GUIStyle status_style = GreenLabel;
     if (version.MetaData.Count > 0)
     {
         EditorGUILayout.LabelField("Meta-Datas", SubBoldLabel);
         for (int i = 0; i < version.MetaData.Count; i++)
         {
             version.MetaData[i].value = EditorGUILayout.TextField(version.MetaData[i].name, version.MetaData[i].value);
             version.MetaData[i].resource = EditorGUILayout.TextField("Resource", version.MetaData[i].resource);
         }
     } else EditorGUILayout.LabelField("No Meta-Data is Required", SubBoldLabel);
     if (version.ManifestSource.Strings.Count > 0)
     {
         EditorGUILayout.LabelField("Strings", SubBoldLabel);
         for (int i = 0; i < version.Strings.Count; i++)
         {
             version.Strings.strings[i].value =
                 EditorGUILayout.TextField(version.Strings.strings[i].name,
                     version.Strings.strings[i].value);
         }
     } else EditorGUILayout.LabelField("No String Resource is Required", SubBoldLabel);
     if (version.ManifestSource.Permission.Count > 0)
     {
         EditorGUILayout.LabelField("Permissions", SubBoldLabel);
         status_style = GreenLabel;
         for (int i = 0; i < version.ManifestSource.Permission.Count; i++)
         {
             status_style = GreenLabel;
             string perm = version.ManifestSource.Permission[i].name;
             if (!manifest.hasPermission(perm)) status_style = RedLabel;
             EditorGUILayout.LabelField(perm, status_style);
         }
     } else EditorGUILayout.LabelField("No Permission is Required", SubBoldLabel);
     if (version.ManifestSource.Activity.Count > 0)
     {
         EditorGUILayout.LabelField("Activities", SubBoldLabel);
         for (int i = 0; i < version.ManifestSource.Activity.Count; i++)
         {
             ManifestActivity act = version.ManifestSource.Activity[i];
             status_style = GreenLabel;
             if (!manifest.hasActivity(act.name)) status_style = RedLabel;
             EditorGUILayout.LabelField(act.name, status_style);
             for (int j = 0; j < act.meta_data.Count; j++)
             {
                 act.meta_data[j].value = EditorGUILayout.TextField(act.meta_data[j].name, act.meta_data[j].value);
                 act.meta_data[j].resource = EditorGUILayout.TextField("Resource", act.meta_data[j].resource);
             }
         }
     } else EditorGUILayout.LabelField("No Activity is Required", SubBoldLabel);
     if (version.ManifestSource.RequiredAgents.Count > 0)
     {
         EditorGUILayout.LabelField("Dependencies", SubBoldLabel);
         for (int i = 0; i < version.ManifestSource.RequiredAgents.Count; i++)
         {
             status_style = GreenLabel;
             if (!deps.hasAgent(version.ManifestSource.RequiredAgents[i]))
             {
                 status_style = RedLabel;
                 EditorGUILayout.LabelField("Warning: No plugin with filename: " + version.ManifestSource.RequiredAgents[i] +
                     " found. Maybe your Plugin Manager is out-dated.", YellowLabel);
             } else if (!vset.isPluginActive(version.ManifestSource.RequiredAgents[i]))
                 status_style = RedLabel;
             EditorGUILayout.LabelField(version.ManifestSource.RequiredAgents[i], status_style);
         }
     } else EditorGUILayout.LabelField("No Additional Plugins Required");
 }
 public static void SaveVersionToFile(string path, AgentSetVersion version)
 {
     XmlTextWriter	writer = new XmlTextWriter(path, System.Text.Encoding.UTF8);
     writer.Indentation = 4;
     writer.Formatting = Formatting.Indented;
     writer.Settings.NewLineHandling = NewLineHandling.Entitize;
     writer.Settings.NewLineOnAttributes = true;
     writer.WriteStartDocument();
     writer.WriteComment("This file is generated by Android Plugin Manager (created by Peyman Abdi peyman[at]nemo-games[dot]com).");
     version.Write(writer);
     writer.Close();
     AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
 }
 public static string GetVersionFilename(AgentSetVersion v)
 {
     return AgentVersion.VersionsPath + v.name;
 }
 void OnGUI_Version(AgentSetVersion version)
 {
     GUIStyle version_style;
     EditorGUILayout.LabelField("All Plugins", BoldLabel);
     scroll = EditorGUILayout.BeginScrollView(scroll, GUILayout.Height(180));
     for (int i = 0; i < plugins.Agents.Count; i++)
     {
         EditorGUILayout.BeginHorizontal();
         if (version.hasPlugin(plugins.Agents[i].filename))
         {
             AgentVersion v = version.getVersionOfPlugin(plugins.Agents[i].filename);
             v.status = EditorGUILayout.Toggle(v.status, GUILayout.MaxWidth(50));
             if (v.status == false)
                 version_style = NormalLabel;
             else
             {
                 {
                     if (v.isVersionReady(version))
                     {
                         if (v.isManifestReady(manifest) && v.isStringsReady(exist_strings)) version_style = GreenLabel;
                         else version_style = YellowLabel;
                     } else version_style = RedLabel;
                 }
             }
         } else
         {
             bool status = EditorGUILayout.Toggle(false, GUILayout.MaxWidth(50));
             if (status == true)
             {
                 version.addPlugin().ImportFromManifest(plugins.Agents[i], true);
                 version_style = RedLabel;
             } else
                 version_style = NormalLabel;
         }
         EditorGUILayout.LabelField(plugins.Agents[i].filename, version_style);
         if (GUILayout.Button("...", PositiveButton))
         {
             agent = plugins.Agents[i];
         }
         EditorGUILayout.EndHorizontal();
     }
     EditorGUILayout.EndScrollView();
 }
    private void ApplyVersion(AgentSetVersion v)
    {
        PlayerSettings.bundleVersion = v.versionName;
        PlayerSettings.Android.bundleVersionCode = int.Parse(v.versionCode);
        PlayerSettings.bundleIdentifier = v.bundleid;
        manifest.package = v.bundleid;
        manifest.versionCode = v.versionCode;
        manifest.versionName = v.versionName;

        PreDefinitions = v.PreDefine.ToArray();
        SetPreDefinitions();

        System.IO.Directory.CreateDirectory(Application.dataPath + "/Plugins/Android/");
        System.IO.Directory.CreateDirectory(Application.dataPath + "/Plugins/Android/res");
        System.IO.Directory.CreateDirectory(Application.dataPath + "/Plugins/Android/libs");

        foreach (AgentManifest mans in plugins.Agents)
        {
            if (!v.hasPlugin(mans.filename))
            {
                SetPluginDefinition(SearchPathForFilename(Application.dataPath, mans.filename), false);
                RemoveDependencies(mans);
            } else if (v.getVersionOfPlugin(mans.filename).status == false)
            {
                SetPluginDefinition(SearchPathForFilename(Application.dataPath, mans.filename), false);
                RemoveDependencies(v.getVersionOfPlugin(mans.filename));
            }
        }
        foreach (AgentManifest mans in plugins.Agents)
        {
            if (v.hasPlugin(mans.filename))
            {
                AgentVersion plug = v.getVersionOfPlugin(mans.filename);
                if (plug.status)
                {
                    SetPluginDefinition(SearchPathForFilename(Application.dataPath, mans.filename), true);
                    AddPluginDependencies(plug);
                }
            }
        }
        AndroidManifestEditor.SaveManifestToFile(Manifest.ManifestFile, manifest);
        ManifestResource current_strings;
        if (System.IO.File.Exists(ManifestResource.StringsFilename))
            current_strings = StringEditor.LoadResourcesFromFile(ManifestResource.StringsFilename);
        else
            current_strings = new ManifestResource();
        for (int i = 0; i < strings.Count; i++)
        {
            if (current_strings.hasName(strings.strings[i].name))
                current_strings.setValue(strings.strings[i].name, strings.strings[i]);
            else
                current_strings.addString(strings.strings[i].name, strings.strings[i]);
        }
        StringEditor.SaveResourcesToFile(ManifestResource.StringsFilename, current_strings);
        Debug.Log("Done :)");
    }
Exemplo n.º 14
0
 public static string                                    GetVersionFilename(AgentSetVersion v)
 {
     return(AgentVersion.VersionsPath + v.name);
 }
Exemplo n.º 15
0
    private void            ApplyVersion(AgentSetVersion v)
    {
        PlayerSettings.bundleVersion             = v.versionName;
        PlayerSettings.Android.bundleVersionCode = int.Parse(v.versionCode);
        PlayerSettings.bundleIdentifier          = v.bundleid;
        manifest.package     = v.bundleid;
        manifest.versionCode = v.versionCode;
        manifest.versionName = v.versionName;

        PreDefinitions = v.PreDefine.ToArray();
        SetPreDefinitions();

        System.IO.Directory.CreateDirectory(Application.dataPath + "/Plugins/Android/");
        System.IO.Directory.CreateDirectory(Application.dataPath + "/Plugins/Android/res");
        System.IO.Directory.CreateDirectory(Application.dataPath + "/Plugins/Android/libs");

        foreach (AgentManifest mans in plugins.Agents)
        {
            if (!v.hasPlugin(mans.filename))
            {
                SetPluginDefinition(SearchPathForFilename(Application.dataPath, mans.filename), false);
                RemoveDependencies(mans);
            }
            else if (v.getVersionOfPlugin(mans.filename).status == false)
            {
                SetPluginDefinition(SearchPathForFilename(Application.dataPath, mans.filename), false);
                RemoveDependencies(v.getVersionOfPlugin(mans.filename));
            }
        }
        foreach (AgentManifest mans in plugins.Agents)
        {
            if (v.hasPlugin(mans.filename))
            {
                AgentVersion plug = v.getVersionOfPlugin(mans.filename);
                if (plug.status)
                {
                    SetPluginDefinition(SearchPathForFilename(Application.dataPath, mans.filename), true);
                    AddPluginDependencies(plug);
                }
            }
        }
        AndroidManifestEditor.SaveManifestToFile(Manifest.ManifestFile, manifest);
        ManifestResource current_strings;

        if (System.IO.File.Exists(ManifestResource.StringsFilename))
        {
            current_strings = StringEditor.LoadResourcesFromFile(ManifestResource.StringsFilename);
        }
        else
        {
            current_strings = new ManifestResource();
        }
        for (int i = 0; i < strings.Count; i++)
        {
            if (current_strings.hasName(strings.strings[i].name))
            {
                current_strings.setValue(strings.strings[i].name, strings.strings[i]);
            }
            else
            {
                current_strings.addString(strings.strings[i].name, strings.strings[i]);
            }
        }
        StringEditor.SaveResourcesToFile(ManifestResource.StringsFilename, current_strings);
        Debug.Log("Done :)");
    }