-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: vrc integration editor (partial)
- Loading branch information
Showing
10 changed files
with
255 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...ocopoi.vrc.dressingtools/Editor/Integrations/VRChat/IVRChatIntegrationModuleEditorView.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* File: IVRChatIntegrationModuleEditorView.cs | ||
* Project: DressingTools | ||
* Created Date: Wednesday, August 23th 2023, 7:56:36 pm | ||
* Author: chocopoi ([email protected]) | ||
* ----- | ||
* Copyright (c) 2023 chocopoi | ||
* | ||
* This file is part of DressingTools. | ||
* | ||
* DressingTools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
* | ||
* DressingTools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with DressingTools. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
using System; | ||
using Chocopoi.DressingTools.Lib.UI; | ||
using UnityEngine; | ||
|
||
namespace Chocopoi.DressingTools.Integrations.VRChat | ||
{ | ||
internal interface IVRChatIntegrationModuleEditorView : IEditorView | ||
{ | ||
event Action ConfigChange; | ||
|
||
bool UseCustomCabinetToggleName { get; set; } | ||
string CustomCabinetToggleName { get; set; } | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...i.vrc.dressingtools/Editor/Integrations/VRChat/IVRChatIntegrationModuleEditorView.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
...om.chocopoi.vrc.dressingtools/Editor/Integrations/VRChat/VRChatIntegrationModuleEditor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* File: VRChatIntegrationModuleEditor.cs | ||
* Project: DressingTools | ||
* Created Date: Wednesday, August 23th 2023, 7:56:36 pm | ||
* Author: chocopoi ([email protected]) | ||
* ----- | ||
* Copyright (c) 2023 chocopoi | ||
* | ||
* This file is part of DressingTools. | ||
* | ||
* DressingTools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
* | ||
* DressingTools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with DressingTools. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using Chocopoi.DressingTools.Integration.VRChat.Modules; | ||
using Chocopoi.DressingTools.Lib.UI; | ||
using Chocopoi.DressingTools.Lib.Wearable.Modules; | ||
using Chocopoi.DressingTools.UI.Presenters.Modules; | ||
using Chocopoi.DressingTools.UIBase.Views; | ||
using Chocopoi.DressingTools.Wearable.Modules; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace Chocopoi.DressingTools.Integrations.VRChat | ||
{ | ||
[ExcludeFromCodeCoverage] | ||
[CustomModuleEditor(typeof(VRChatIntegrationModuleProvider))] | ||
internal class VRChatIntegrationModuleEditor : ModuleEditor, IVRChatIntegrationModuleEditorView | ||
{ | ||
public event Action ConfigChange; | ||
|
||
public bool UseCustomCabinetToggleName { get => _useCustomCabinetToggleName; set => _useCustomCabinetToggleName = value; } | ||
public string CustomCabinetToggleName { get => _customCabinetToggleName; set => _customCabinetToggleName = value; } | ||
|
||
private IModuleEditorViewParent _parentView; | ||
private VRChatIntegrationModuleEditorPresenter _presenter; | ||
|
||
private bool _useCustomCabinetToggleName; | ||
private string _customCabinetToggleName; | ||
|
||
public VRChatIntegrationModuleEditor(IModuleEditorViewParent parentView, VRChatIntegrationModuleProvider provider, IModuleConfig target) : base(parentView, provider, target) | ||
{ | ||
_parentView = parentView; | ||
_presenter = new VRChatIntegrationModuleEditorPresenter(this, parentView, (VRChatIntegrationModuleConfig)target); | ||
|
||
_useCustomCabinetToggleName = false; | ||
} | ||
|
||
public override void OnGUI() | ||
{ | ||
ToggleLeft("Use custom cabinet toggle name", ref _useCustomCabinetToggleName, ConfigChange); | ||
BeginDisabled(!_useCustomCabinetToggleName); | ||
{ | ||
EditorGUI.indentLevel += 1; | ||
TextField("Toggle Name", ref _customCabinetToggleName, ConfigChange); | ||
EditorGUI.indentLevel -= 1; | ||
} | ||
EndDisabled(); | ||
} | ||
|
||
public override bool IsValid() => _presenter.IsValid(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ocopoi.vrc.dressingtools/Editor/Integrations/VRChat/VRChatIntegrationModuleEditor.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
97 changes: 97 additions & 0 deletions
97
...oi.vrc.dressingtools/Editor/Integrations/VRChat/VRChatIntegrationModuleEditorPresenter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* File: VRChatIntegrationModuleEditorPresenter.cs | ||
* Project: DressingTools | ||
* Created Date: Wednesday, August 23th 2023, 7:56:36 pm | ||
* Author: chocopoi ([email protected]) | ||
* ----- | ||
* Copyright (c) 2023 chocopoi | ||
* | ||
* This file is part of DressingTools. | ||
* | ||
* DressingTools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
* | ||
* DressingTools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with DressingTools. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
using Chocopoi.DressingTools.Integration.VRChat.Modules; | ||
using Chocopoi.DressingTools.Lib.UI; | ||
using Chocopoi.DressingTools.UIBase.Views; | ||
using Chocopoi.DressingTools.Wearable.Modules; | ||
|
||
namespace Chocopoi.DressingTools.Integrations.VRChat | ||
{ | ||
internal class VRChatIntegrationModuleEditorPresenter | ||
{ | ||
private IVRChatIntegrationModuleEditorView _view; | ||
private IModuleEditorViewParent _parentView; | ||
private VRChatIntegrationModuleConfig _module; | ||
|
||
public VRChatIntegrationModuleEditorPresenter(IVRChatIntegrationModuleEditorView view, IModuleEditorViewParent parentView, VRChatIntegrationModuleConfig module) | ||
{ | ||
_view = view; | ||
_parentView = parentView; | ||
_module = module; | ||
|
||
SubscribeEvents(); | ||
} | ||
|
||
private void SubscribeEvents() | ||
{ | ||
_view.Load += OnLoad; | ||
_view.Unload += OnUnload; | ||
|
||
_view.ForceUpdateView += OnForceUpdateView; | ||
_view.ConfigChange += OnConfigChange; | ||
} | ||
|
||
private void UnsubscribeEvents() | ||
{ | ||
_view.Load -= OnLoad; | ||
_view.Unload -= OnUnload; | ||
|
||
_view.ForceUpdateView -= OnForceUpdateView; | ||
_view.ConfigChange -= OnConfigChange; | ||
} | ||
|
||
private void OnForceUpdateView() | ||
{ | ||
UpdateView(); | ||
} | ||
|
||
private void OnConfigChange() | ||
{ | ||
_module.customCabinetToggleName = _view.UseCustomCabinetToggleName ? _view.CustomCabinetToggleName : null; | ||
} | ||
|
||
public bool IsValid() | ||
{ | ||
return _module.customCabinetToggleName != null ? _module.customCabinetToggleName.Trim() != "" : true; | ||
} | ||
|
||
private void UpdateView() | ||
{ | ||
if (_module.customCabinetToggleName != null) | ||
{ | ||
_view.UseCustomCabinetToggleName = true; | ||
_view.CustomCabinetToggleName = _module.customCabinetToggleName; | ||
} | ||
else | ||
{ | ||
_view.UseCustomCabinetToggleName = false; | ||
_view.CustomCabinetToggleName = ""; | ||
} | ||
} | ||
|
||
private void OnLoad() | ||
{ | ||
UpdateView(); | ||
} | ||
|
||
private void OnUnload() | ||
{ | ||
UnsubscribeEvents(); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...c.dressingtools/Editor/Integrations/VRChat/VRChatIntegrationModuleEditorPresenter.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters