Skip to content

Commit

Permalink
🔩 Merge pull request #6 from CarterGames/pre-release (0.4.0 Release)
Browse files Browse the repository at this point in the history
📦 0.4.0 Release
  • Loading branch information
JonathanMCarter authored Dec 19, 2024
2 parents 7b8b6fa + 48dfd80 commit 253aefe
Show file tree
Hide file tree
Showing 113 changed files with 3,714 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using CarterGames.Standalone.NotionData.Filters;
using UnityEditor;
using UnityEngine;

Expand Down Expand Up @@ -65,7 +67,7 @@ private static void DownloadAll()
}
else
{
var window = CreateWindow<DownloadAllHandler>("Download Notion Data");
var window = GetWindow<DownloadAllHandler>(true, "Download Notion Data");
window.maxSize = new Vector2(400, 400);
}
}
Expand Down Expand Up @@ -158,7 +160,11 @@ private static void ProcessNextAsset()

NotionApiRequestHandler.ResetRequestData();

var requestData = new NotionRequestData(asset, databaseId, assetObject.Fp("databaseApiKey").stringValue, assetObject.Fp("sortProperties").ToSortPropertyArray(), true);
var filters = (NotionFilterContainer) assetObject.GetType().BaseType!
.GetField("filters", BindingFlags.NonPublic | BindingFlags.Instance)
!.GetValue(assetObject.targetObject);

var requestData = new NotionRequestData(asset, databaseId, assetObject.Fp("databaseApiKey").stringValue, assetObject.Fp("sortProperties").ToSortPropertyArray(), filters, true);
NotionApiRequestHandler.WebRequestPostWithAuth(requestData);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public sealed class NotionDataAssetCreator : EditorWindow
[MenuItem("Tools/Carter Games/Standalone/Notion Data/Asset Creator", priority = 20)]
private static void ShowWindow()
{
var window = GetWindow<NotionDataAssetCreator>();
var window = GetWindow<NotionDataAssetCreator>(true);
window.titleContent = new GUIContent("Notion Data Asset Creator");
window.Show();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

using System.Linq;
using System.Reflection;
using CarterGames.Standalone.NotionData.Filters;
using CarterGames.Standalone.NotionData.ThirdParty;
using UnityEditor;
using UnityEngine;

Expand Down Expand Up @@ -50,7 +52,7 @@ public override void OnInspectorGUI()
EditorGUILayout.Space(1.5f);
GeneralUtilEditor.DrawHorizontalGUILine();

DrawPropertiesExcluding(serializedObject, "sortProperties");
DrawPropertiesExcluding(serializedObject, "sortProperties", "filters");
}


Expand All @@ -67,11 +69,15 @@ private void RenderNotionSettings()

EditorGUILayout.BeginHorizontal();

// Coming... eventually...
// if (GUILayout.Button("Filters"))
// {
//
// }

var filterTotal = ((NotionFilterContainer) target.GetType().BaseType!
.GetField("filters", BindingFlags.NonPublic | BindingFlags.Instance)
!.GetValue(serializedObject.targetObject)).TotalFilters;

if (GUILayout.Button($"Filters ({filterTotal})"))
{
EditorWindowFilterGUI.OpenWindow(serializedObject);
}

if (GUILayout.Button($"Sorting ({serializedObject.Fp("sortProperties").arraySize})"))
{
Expand All @@ -85,11 +91,11 @@ private void RenderNotionSettings()
string.IsNullOrEmpty(serializedObject.Fp("linkToDatabase").stringValue));


GUILayout.Space(5f);
GUILayout.Space(1.5f);

GUI.backgroundColor = Color.green;

if (GUILayout.Button("Download Data"))
if (GUILayout.Button("Download Data", GUILayout.Height(22.5f)))
{
if (Application.internetReachability == NetworkReachability.NotReachable)
{
Expand All @@ -109,8 +115,13 @@ private void RenderNotionSettings()

NotionApiRequestHandler.ResetRequestData();

var requestData = new NotionRequestData((DataAsset) serializedObject.targetObject, databaseId, serializedObject.Fp("databaseApiKey").stringValue, serializedObject.Fp("sortProperties").ToSortPropertyArray());

var sorts = serializedObject.Fp("sortProperties").ToSortPropertyArray();
var filters = (NotionFilterContainer) target.GetType().BaseType!
.GetField("filters", BindingFlags.NonPublic | BindingFlags.Instance)
!.GetValue(serializedObject.targetObject);

var requestData = new NotionRequestData((DataAsset) serializedObject.targetObject, databaseId, serializedObject.Fp("databaseApiKey").stringValue, sorts, filters);

NotionApiRequestHandler.WebRequestPostWithAuth(requestData);
}

Expand Down Expand Up @@ -145,15 +156,7 @@ private void OnDataReceived(NotionRequestResult data)

private void OnErrorReceived(NotionRequestError error)
{
if (error.Message.Contains("Could not find sort property"))
{
EditorUtility.DisplayDialog("Notion Data Download", $"Download failed ({error.Error}):\n{error.Message}", "Continue");
}
else
{
EditorUtility.DisplayDialog("Notion Data Download", "Download failed, please see console for errors and try again", "Continue");
}

EditorUtility.DisplayDialog("Notion Data Download", $"Download failed ({error.Error}):\n{error.Message}", "Continue");

NotionApiRequestHandler.DataReceived.Remove(OnDataReceived);
NotionApiRequestHandler.RequestError.Remove(OnErrorReceived);
Expand Down

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2024 Carter Games
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

using System;
using System.Collections.Generic;

namespace CarterGames.Standalone.NotionData.Editor
{
[Serializable]
public class SearchGroup<T>
{
public string Key { get; private set; }
public List<SearchItem<T>> Values { get; private set; }


public bool IsValidGroup => !string.IsNullOrEmpty(Key);



public SearchGroup(string groupName, List<SearchItem<T>> values)
{
Key = groupName;
Values = values;
}


public SearchGroup(List<SearchItem<T>> values)
{
Key = string.Empty;
Values = values;
}
}
}

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2024 Carter Games
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

using UnityEditor.Experimental.GraphView;
using UnityEngine;

namespace CarterGames.Standalone.NotionData.Editor
{
public static class SearchHelper
{
public static SearchTreeEntry CreateGroup(string title, int level)
{
return new SearchTreeGroupEntry(new GUIContent(title))
{
level = level,
};
}


public static SearchTreeEntry CreateEntry(string title, int level, object data)
{
return new SearchTreeEntry(new GUIContent(" " + title))
{
level = level,
userData = data
};
}
}
}

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2024 Carter Games
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

using System;

namespace CarterGames.Standalone.NotionData.Editor
{
[Serializable]
public class SearchItem<T>
{
public string Key { get; private set; }
public T Value { get; private set; }


public static SearchItem<T> Set(string key, T item)
{
return new SearchItem<T>()
{
Key = key,
Value = item
};
}
}
}

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

Loading

0 comments on commit 253aefe

Please sign in to comment.