Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
lurim-nhn committed Dec 6, 2019
2 parents 4074217 + 7316f41 commit 2ee2242
Show file tree
Hide file tree
Showing 2,444 changed files with 133,840 additions and 0 deletions.
49 changes: 49 additions & 0 deletions GamebaseSample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Unity
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
[Bb]uilds/

# IDE directory
.vs/
.idea/
.vscode/

# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb

# Unity3D generated meta files
*.pidb.meta

# Unity3D Generated File On Crash Reports
sysinfo.txt

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb

# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
9 changes: 9 additions & 0 deletions GamebaseSample/Assets/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

168 changes: 168 additions & 0 deletions GamebaseSample/Assets/Editor/GamebasePlistManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
using GamebaseSample;
using NE.XcodeEditor;
using System.Collections.Generic;
using System.IO;

public class GamebasePlistManager
{
private const string KEY_URL_TYPES = "CFBundleURLTypes";
private const string KEY_URL_NAME = "CFBundleURLName";
private const string KEY_URL_SCHEMES = "CFBundleURLSchemes";
private const string KEY_LS_APPLICATION_QUERIES_SCHEMES = "LSApplicationQueriesSchemes";

private static GamebasePlistManager instance;

public List<string> facebookWhiteList;

private PlistDocument plist;
private PlistElementDict rootDict;
private PlistElementArray URLTypesArray;

public static GamebasePlistManager GetInstance()
{
if (instance == null)
instance = new GamebasePlistManager();

return instance;
}

public void LoadPlist(string path)
{
if (plist != null)
return;

const string fileName = "Info.plist";
string filePath = Path.Combine(path, fileName);

plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(filePath));

rootDict = plist.root;

if (null == rootDict)
{
Logger.Error(string.Format("Plist parsing error:{0}", filePath), this, "LoadPlist");
}
}

public void SetIDPAppID(string IDPIdKey, string IDPId)
{
if (rootDict.values.ContainsKey (IDPIdKey)) {
rootDict.values.Remove (IDPIdKey);
}

rootDict.SetString(IDPIdKey, IDPId);
}

public void SetWhiteList(string[] whiteList)
{
PlistElementArray LSApplicationQueriesSchemesArray;

if (rootDict.values.ContainsKey(KEY_LS_APPLICATION_QUERIES_SCHEMES))
LSApplicationQueriesSchemesArray = rootDict.values[KEY_LS_APPLICATION_QUERIES_SCHEMES].AsArray();
else
LSApplicationQueriesSchemesArray = rootDict.CreateArray(KEY_LS_APPLICATION_QUERIES_SCHEMES);

for (int i = 0; i < whiteList.Length; i++)
{
if (HasStringValue(LSApplicationQueriesSchemesArray, whiteList[i]) == false)
LSApplicationQueriesSchemesArray.AddString(whiteList[i]);
}
}

public void SetList(string key, string[] list)
{
PlistElementArray array;

if (rootDict.values.ContainsKey(key))
array = rootDict.values[key].AsArray();
else
array = rootDict.CreateArray(key);

for (int i = 0; i < list.Length; i++)
{
if (HasStringValue(array, list[i]) == false)
array.AddString(list[i]);
}
}

public void SetURLSchemes(string URLSchemesValue, bool hasURLIdentifier = false, string URLIdentifier = null)
{
if (rootDict.values.ContainsKey(KEY_URL_TYPES))
{
if (URLTypesArray == null)
URLTypesArray = rootDict.values[KEY_URL_TYPES].AsArray();

if (hasURLIdentifier)
CreateURLSchemes(URLSchemesValue, hasURLIdentifier, URLIdentifier);
else
AddURLSchemes(URLSchemesValue);
}
else
{
URLTypesArray = rootDict.CreateArray(KEY_URL_TYPES);
CreateURLSchemes(URLSchemesValue, hasURLIdentifier, URLIdentifier);
}
}

public void SavePlist(string path)
{
const string fileName = "Info.plist";
string filePath = Path.Combine(path, fileName);

File.WriteAllText(filePath, plist.WriteToString());
}

private void CreateURLSchemes(string URLSchemesValue, bool hasURLIdentifier = false, string URLIdentifier = "")
{
for (var i = 0; i < URLTypesArray.values.Count; i++)
{
var dict = URLTypesArray.values[i].AsDict();
if (string.IsNullOrEmpty(URLIdentifier) == false && dict.values.ContainsKey(KEY_URL_NAME))
{
if (dict.values[KEY_URL_NAME].AsString() == URLIdentifier)
return;
}
}

PlistElementDict URLTypesDict = URLTypesArray.AddDict();

if (hasURLIdentifier)
URLTypesDict.SetString(KEY_URL_NAME, URLIdentifier);

PlistElementArray innerArray = URLTypesDict.CreateArray(KEY_URL_SCHEMES);
innerArray.AddString(URLSchemesValue);
}

private void AddURLSchemes(string URLSchemesValue)
{
int i;

for (i=0 ; i<URLTypesArray.values.Count ; i++)
{
if (URLTypesArray.values[i].AsDict().values.ContainsKey(KEY_URL_NAME))
continue;
else
{
PlistElementArray URLSchemesArray = URLTypesArray.values[i].AsDict()[KEY_URL_SCHEMES].AsArray();
if (HasStringValue(URLSchemesArray, URLSchemesValue) == false)
URLSchemesArray.AddString(URLSchemesValue);

return;
}
}

CreateURLSchemes(URLSchemesValue);
}

private bool HasStringValue(PlistElementArray array, string value)
{
for (var i = 0; i < array.values.Count; i++)
{
if (array.values[i].AsString() == value)
return true;
}

return false;
}
}
12 changes: 12 additions & 0 deletions GamebaseSample/Assets/Editor/GamebasePlistManager.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2ee2242

Please sign in to comment.