Skip to content

Commit

Permalink
Update Editor windows
Browse files Browse the repository at this point in the history
  • Loading branch information
sschmid committed Nov 25, 2018
1 parent cd3ce84 commit fbd81f1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 26 deletions.
13 changes: 11 additions & 2 deletions .bee/entitas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ DEPS=(
"../DesperateDevs/DesperateDevs.CodeGeneration.Unity.Plugins/bin/Release/"
"../DesperateDevs/DesperateDevs.Unity.Editor/bin/Release/"
"../DesperateDevs/DesperateDevs.CodeGeneration.CodeGenerator.Unity.Editor/Compile.cs"
"../DesperateDevs/DesperateDevs.CodeGeneration.CodeGenerator.Unity.Editor/DesperateDevs.CodeGeneration.CodeGenerator.Unity.Editor/Images/"
)
ENTITAS_PROJECTS=(
'Entitas'
Expand Down Expand Up @@ -77,6 +78,10 @@ DESPERATEDEVS_EDITOR=(
'DesperateDevs.CodeGeneration.dll'
'DesperateDevs.Unity.Editor.dll'
)
DESPERATEDEVS_IMAGES=(
'JennyHeader.png'
'JennyHeader.png.meta'
)
DESPERATEDEVS_PLUGINS=(
'DesperateDevs.CodeGeneration.Plugins.dll'
'DesperateDevs.CodeGeneration.Unity.Plugins.dll'
Expand Down Expand Up @@ -113,9 +118,10 @@ entitas::collect_entitas_unity() {
local images_dir="${entitas_editor_dir}/Images"
local desperatedevs_dir="${BUILD_SRC}/Unity/Entitas/Assets/DesperateDevs"
local desperatedevs_editor_dir="${desperatedevs_dir}/Editor"
local desperatedevs_images_dir="${desperatedevs_editor_dir}/Images"
local desperatedevs_plugins_dir="${desperatedevs_editor_dir}/Plugins"
utils::clean_dir "${entitas_dir}" "${entitas_editor_dir}" "${entitas_plugins_dir}" "${images_dir}" \
"${desperatedevs_dir}" "${desperatedevs_editor_dir}" "${desperatedevs_plugins_dir}"
"${desperatedevs_dir}" "${desperatedevs_editor_dir}" "${desperatedevs_images_dir}" "${desperatedevs_plugins_dir}"

for p in "${ENTITAS_PROJECTS[@]}"; do utils::sync "${p}/bin/Release/" "${entitas_dir}"; done
utils::sync "${DEPS_DIR}/" "${entitas_dir}"
Expand All @@ -124,6 +130,7 @@ entitas::collect_entitas_unity() {
for f in "${IMAGES[@]}"; do utils::sync "${f}" "${images_dir}"; done
for f in "${DESPERATEDEVS[@]}"; do mv "${entitas_dir}/${f}" "${desperatedevs_dir}"; done
for f in "${DESPERATEDEVS_EDITOR[@]}"; do mv "${entitas_dir}/${f}" "${desperatedevs_editor_dir}"; done
for f in "${DESPERATEDEVS_IMAGES[@]}"; do mv "${entitas_dir}/${f}" "${desperatedevs_images_dir}"; done
for f in "${DESPERATEDEVS_PLUGINS[@]}"; do mv "${entitas_dir}/${f}" "${desperatedevs_plugins_dir}"; done
}

Expand All @@ -135,9 +142,10 @@ entitas::collect_entitas_with_blueprints_unity() {
local images_dir="${entitas_editor_dir}/Images"
local desperatedevs_dir="${BUILD_SRC}/Unity/Entitas/Assets/DesperateDevs"
local desperatedevs_editor_dir="${desperatedevs_dir}/Editor"
local desperatedevs_images_dir="${desperatedevs_editor_dir}/Images"
local desperatedevs_plugins_dir="${desperatedevs_editor_dir}/Plugins"
utils::clean_dir "${entitas_dir}" "${entitas_editor_dir}" "${entitas_plugins_dir}" "${images_dir}" \
"${desperatedevs_dir}" "${desperatedevs_editor_dir}" "${desperatedevs_plugins_dir}"
"${desperatedevs_dir}" "${desperatedevs_editor_dir}" "${desperatedevs_images_dir}" "${desperatedevs_plugins_dir}"

for p in "${ENTITAS_PROJECTS[@]}"; do utils::sync "${p}/bin/Release/" "${entitas_dir}"; done
for p in "${BLUEPRINTS_PROJECTS[@]}"; do utils::sync "${p}/bin/Release/" "${entitas_dir}"; done
Expand All @@ -149,6 +157,7 @@ entitas::collect_entitas_with_blueprints_unity() {
for d in "${IMAGES[@]}"; do utils::sync "${d}" "${images_dir}"; done
for f in "${DESPERATEDEVS[@]}"; do mv "${entitas_dir}/${f}" "${desperatedevs_dir}"; done
for f in "${DESPERATEDEVS_EDITOR[@]}"; do mv "${entitas_dir}/${f}" "${desperatedevs_editor_dir}"; done
for f in "${DESPERATEDEVS_IMAGES[@]}"; do mv "${entitas_dir}/${f}" "${desperatedevs_images_dir}"; done
for f in "${DESPERATEDEVS_PLUGINS[@]}"; do mv "${entitas_dir}/${f}" "${desperatedevs_plugins_dir}"; done
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,58 @@
using UnityEditor;
using UnityEngine;

namespace Entitas.Migration.Unity.Editor {

public class MigrationWindow : EditorWindow {

namespace Entitas.Migration.Unity.Editor
{
public class MigrationWindow : EditorWindow
{
[MenuItem("Tools/Entitas/Migrate...", false, 1000)]
public static void OpenMigrate() {
EditorLayout
.GetWindow<MigrationWindow>("Entitas Migration - " + CheckForUpdates.GetLocalVersion(), new Vector2(415f, 564))
.Show();
public static void OpenMigrate()
{
var window = GetWindow<MigrationWindow>(true, "Entitas Migration - " + CheckForUpdates.GetLocalVersion());
window.minSize = new Vector2(415f, 564);
window.Show();
}

Texture2D _headerTexture;
IMigration[] _migrations;
bool[] _showMigration;
Vector2 _scrollViewPosition;

void OnEnable() {
void OnEnable()
{
_headerTexture = EditorLayout.LoadTexture("l:EntitasHeader");
_migrations = getMigrations();
_showMigration = new bool[_migrations.Length];
_showMigration[0] = true;
}

static IMigration[] getMigrations() {
static IMigration[] getMigrations()
{
return AppDomain.CurrentDomain
.GetInstancesOf<IMigration>()
.OrderByDescending(instance => instance.GetType().FullName)
.ToArray();
}

void OnGUI() {
void OnGUI()
{
_scrollViewPosition = EditorGUILayout.BeginScrollView(_scrollViewPosition);
{
EditorLayout.DrawTexture(_headerTexture);

var descriptionStyle = new GUIStyle(GUI.skin.label);
descriptionStyle.wordWrap = true;
for (int i = 0; i < _migrations.Length; i++) {
for (int i = 0; i < _migrations.Length; i++)
{
var migration = _migrations[i];
_showMigration[i] = EditorLayout.DrawSectionHeaderToggle(migration.version, _showMigration[i]);
if (_showMigration[i]) {
if (_showMigration[i])
{
EditorLayout.BeginSectionContent();
{
EditorGUILayout.LabelField(migration.description, descriptionStyle);
if (GUILayout.Button("Apply migration " + migration.version)) {
if (GUILayout.Button("Apply migration " + migration.version))
{
migrate(migration, this);
}
}
Expand All @@ -61,15 +68,17 @@ void OnGUI() {
EditorGUILayout.EndScrollView();
}

static void migrate(IMigration migration, MigrationWindow window) {
static void migrate(IMigration migration, MigrationWindow window)
{
var shouldMigrate = EditorUtility.DisplayDialog("Migrate",
"You are about to migrate your source files. " +
"Make sure that you have committed your current project or that you have a backup of your project before you proceed.",
"I have a backup - Migrate",
"Cancel"
);

if (shouldMigrate) {
if (shouldMigrate)
{
window.Close();
EditorUtility.DisplayDialog("Migrate",
"Please select the folder, " + migration.workingDirectory + ".",
Expand All @@ -78,14 +87,18 @@ static void migrate(IMigration migration, MigrationWindow window) {

var path = "Assets/";
path = EditorUtility.OpenFolderPanel(migration.version + ": " + migration.workingDirectory, path, string.Empty);
if (!string.IsNullOrEmpty(path)) {
if (!string.IsNullOrEmpty(path))
{
var changedFiles = migration.Migrate(path);
Debug.Log("Applying " + migration.version);
foreach (var file in changedFiles) {
foreach (var file in changedFiles)
{
MigrationUtils.WriteFiles(changedFiles);
Debug.Log("Migrated " + file.fileName);
}
} else {
}
else
{
throw new Exception("Could not complete migration! Selected path was invalid!");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ public class EntitasPreferencesWindow : PreferencesWindow
[MenuItem(EntitasMenuItems.preferences, false, EntitasMenuItemPriorities.preferences)]
public static void OpenPreferences()
{
var window = EditorLayout.GetWindow<EntitasPreferencesWindow>(
"Entitas " + CheckForUpdates.GetLocalVersion(),
new Vector2(415f, 350)
);

var window = GetWindow<EntitasPreferencesWindow>(true, "Entitas " + CheckForUpdates.GetLocalVersion());
window.minSize = new Vector2(415f, 348f);
window.Initialize(
"Entitas.properties",
Environment.UserName + ".userproperties",
Expand Down

0 comments on commit fbd81f1

Please sign in to comment.