Skip to content

Commit

Permalink
Merge pull request #17 from Studio-23-xyz/dialogue-expressions-script…
Browse files Browse the repository at this point in the history
…able

Dialogue expressions scriptable
  • Loading branch information
Warhammer4000 authored Mar 25, 2024
2 parents c54f47c + 1ac0f0f commit 50aa29f
Show file tree
Hide file tree
Showing 28 changed files with 491 additions and 179 deletions.
71 changes: 56 additions & 15 deletions .github/workflows/UPMBranchUpdate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Set Git Config
run: |
git config --global user.email "tazimtazim2012@gmail.com"
git config --global user.name "Warhammer4000"
- name: Checkout Repository
uses: actions/checkout@v2

Expand All @@ -20,29 +25,65 @@ jobs:
- name: Get Package Name from package.json
id: get-package-name
run: echo ::set-output name=package-name::$(jq -r .name ${{ steps.find-package-json.outputs.package-json-path }})

- name: Git Subtree Split
run: git subtree split -P Assets/Packages/${{ steps.get-package-name.outputs.package-name }}/ -b upm



- name: Get Version from package.json
id: get-version
run: echo ::set-output name=version::$(jq -r .version ${{ steps.find-package-json.outputs.package-json-path }})

- name: Git Subtree Split
run: git subtree split -P Assets/Packages/${{ steps.get-package-name.outputs.package-name }}/ -b upm

- name: Push Branch
- name: Rename Samples
run: |
git checkout upm
if [[ -d "Samples" ]]; then
git mv Samples Samples~
rm -f Samples.meta
git config --global user.name 'github-bot'
git config --global user.email 'github-bot@users.noreply.github.com'
git commit -am "fix: Samples => Samples~"
git mv Samples Samples~
rm -f Samples.meta
git commit -am "fix: Samples => Samples~"
fi
git push -f -u origin upm
- name: Create Git Tag
if: steps.get-version.outputs.version != ''
run: |
git tag v${{ steps.get-version.outputs.version }} upm
git push origin --tags
run: git tag v${{ steps.get-version.outputs.version }} upm

- name: Push Tags
run: |
git checkout upm
git push -f -u origin upm
git push --tags
SelfHosted-Publish:
needs: update-and-tag
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: upm
- uses: actions/setup-node@v3
with:
node-version: '20.x'
registry-url: ${{ secrets.NPM_SERVER }}
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

GitHub-Publish:
needs: update-and-tag
runs-on: ubuntu-latest
permissions:
packages: write


steps:
- uses: actions/checkout@v4
with:
ref: upm

- uses: actions/setup-node@v3
with:
node-version: '20.x'

- uses: FrontEndDev-org/publish-node-package-action@v1
with:
target: github
23 changes: 23 additions & 0 deletions .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Qodana
on:
workflow_dispatch:
push:
branches: # Specify your branches here
- main # The 'main' branch

jobs:
qodana:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
checks: write
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
fetch-depth: 0 # a full history is required for pull request analysis
- name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2023.3
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
67 changes: 50 additions & 17 deletions .github/workflows/docgen.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,70 @@
name: docfx-unitypackage
name: docfx for GitHub Pages

on:
workflow_dispatch:
push:
branches:
- main
- 'main'
release:
types: [published]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build-and-deploy:
runs-on: ubuntu-latest
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest.

steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true

- name: Find and copy specific files
run: |
# Look for LICENSE.md, README.md, and CHANGELOG.md in subdirectories
find . -name LICENSE.md -exec cp {} . \;
find . -name README.md -exec cp {} . \;
find . -name CHANGELOG.md -exec cp {} . \;
uses: actions/checkout@v4


- name: Remove csproj files
run: find . -name "*.csproj" -type f -delete
shell: bash

- name: Build
uses: CaseyHofland/docfx-unitypackage@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Deploy
uses: peaceiris/actions-gh-pages@v3

- name: Deploy with DocFX
uses: sator-imaging/docfx-pages@v1
id: deployment
with:
app_name: 'Dialoguesystem'
site_title: 'Dialoguesystem'
site_footer: '<big>&times; Is HTML accepted?</big>'
class_members: 'separatePages'
google_analytics: ''
define_symbols: ''
site_logo: '<logo>.svg'
site_favicon: '<favicon>.svg'
main_js: |
export default {
defaultTheme: 'light',
showLightbox: (img) => true,
iconLinks: [
{
icon: 'github',
href: 'https://github.com/sator-imaging',
title: 'GitHub'
},
],
}
main_css: |
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: _site

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Studio23.SS2.DialogueSystem.Data;
using UnityEditor;
using UnityEditor.Localization.Plugins.XLIFF.V12;
using UnityEngine;

namespace Editor.Data
{
[CustomEditor(typeof(CharacterData))]
public class CharacterDataEditor:UnityEditor.Editor
{
private string newExpressionName = "QUESTIONABLE EMOJI FACE";
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
var charData = target as CharacterData;
newExpressionName = EditorGUILayout.TextField(newExpressionName);
if (!string.IsNullOrEmpty(newExpressionName) && GUILayout.Button("Add new Expression"))
{
AddExpression(charData, newExpressionName);
}
}

public static void AddExpression(CharacterData character, string expressionName)
{
var expression = ScriptableObject.CreateInstance<CharacterExpressionData>();
expression.Character = character;
expression.ExpressionName = expressionName;
expression.name = expression.GetAssetName();
character.Expressions.Add(expression);

AssetDatabase.AddObjectToAsset(expression, character);
AssetDatabase.SaveAssets();
EditorUtility.SetDirty(character);
}
}
}

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,39 @@
using Studio23.SS2.DialogueSystem.Data;
using UnityEditor;
using UnityEngine;

namespace Editor.Data
{
[CustomEditor(typeof(CharacterExpressionData))]
public class CharacterExpressionDataEditor:UnityEditor.Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
var expressionData = target as CharacterExpressionData;
if (GUILayout.Button("RENAME"))
{
Rename(expressionData);
}

if (GUILayout.Button("REMOVE"))
{
RemoveExpression(expressionData);
}
}

public void RemoveExpression(CharacterExpressionData data)
{
data.Character.Expressions.Remove(data);
Undo.DestroyObjectImmediate(data);
AssetDatabase.SaveAssets();
}

public void Rename(CharacterExpressionData data)
{
data.name = data.GetAssetName();
AssetDatabase.SaveAssets();
EditorUtility.SetDirty(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
Expand Up @@ -10,7 +10,6 @@ public class DialogueBaseNodeEditor : NodeEditor
public Color TextColor = Color.white;
private DialogueNodeBase dialogueBase;
private static GUIStyle editorLabelStyle;

public override void OnBodyGUI()
{
if (dialogueBase == null) dialogueBase = target as DialogueNodeBase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ public override void OnBodyGUI()
// Update serialized object's representation
serializedObject.Update();
var dialogueLineNode = target as DialogueLineNodeBase;

DrawLocalizationStringHelperGUI(dialogueLineNode);

base.OnBodyGUI();
}

private void DrawLocalizationStringHelperGUI(DialogueLineNodeBase dialogueLineNode)
{
var collection = LocalizationEditorSettings.GetStringTableCollection(dialogueLineNode.DialogueLocalizedString.TableReference);
var defaultLocaleTable = collection.GetTable(DEFAULT_LOCALE) as StringTable;
if (defaultLocaleTable == null)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System.Linq;
using Studio23.SS2.DialogueSystem.Data;
using UnityEditor;
using UnityEngine;

namespace Editor.Data
{
[CustomPropertyDrawer(typeof(LineSpeakerData))]
public class LineSpeakerDataPropertyDrawer:PropertyDrawer
{
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return base.GetPropertyHeight(property, label) * 3;
}

public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, label, property);
// Don't make child fields be indented
var indent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
// // Calculate rects
// var charRect = new Rect(position.x, position.y, 30, position.height);
// var unitRect = new Rect(position.x + 35, position.y, 50, position.height);
// var nameRect = new Rect(position.x + 90, position.y, position.width - 90, position.height);
//
// // Draw fields - pass GUIContent.none to each so they are drawn without labels
// EditorGUI.PropertyField(unitRect, property.FindPropertyRelative("unit"), GUIContent.none);
// EditorGUI.PropertyField(nameRect, property.FindPropertyRelative("name"), GUIContent.none);
// position.y += 30;
var lineSpeakerData = property.boxedValue as LineSpeakerData;
// EditorGUI.LabelField(position, lineSpeakerData is LineSpeakerData?"asdas":"zz");
var charFieldRect = position;
charFieldRect.height = EditorGUIUtility.singleLineHeight;
EditorGUI.PropertyField(charFieldRect, property.FindPropertyRelative("Character"), new GUIContent("Character"));
if (lineSpeakerData.Character != null)
{
position.y += EditorGUIUtility.singleLineHeight;
var expressions = lineSpeakerData.Character.Expressions.Select(ced => ced.ExpressionName).ToArray();
// EditorGUI.LabelField(position," :" + lineSpeakerData);
if (expressions.Length == 0)
{
EditorGUI.HelpBox(position, "NO EXPRESSIONS", MessageType.Error);
}
else
{
var expressionProp = property.FindPropertyRelative("Expression");

var prevIndex = lineSpeakerData.Character.GetExpressionIndexByName(lineSpeakerData.Expression);
var expressionPopupRect = position;
expressionPopupRect.height = EditorGUIUtility.singleLineHeight;
var expressionIndex = EditorGUI.Popup(expressionPopupRect, prevIndex, expressions);
if (expressionIndex != prevIndex)
{
if (expressionIndex >= 0 && expressionIndex < expressions.Length)
{
expressionProp.objectReferenceValue = lineSpeakerData.Character.Expressions[expressionIndex];
expressionProp.serializedObject.ApplyModifiedProperties();

}
}
position.y += EditorGUIUtility.singleLineHeight;
var expressionFieldRect = position;
expressionFieldRect.height = EditorGUIUtility.singleLineHeight;
EditorGUI.BeginDisabledGroup(true);
EditorGUI.ObjectField(expressionFieldRect, expressionProp, GUIContent.none);
EditorGUI.EndDisabledGroup();
}
}

// Set indent back to what it was
EditorGUI.indentLevel = indent;

EditorGUI.EndProperty();
}
}
}
Loading

0 comments on commit 50aa29f

Please sign in to comment.