Minor Fix on Advanced Setting UI (#459)
* [FIX] Input refinment on Advanced Settings Add a browse for server and make the source input more than readonlymain
parent
6e0ef2347a
commit
8fe73be7ae
|
|
@ -28,6 +28,7 @@ namespace MCPForUnity.Editor.Windows.Components.Settings
|
||||||
private Button clearUvxButton;
|
private Button clearUvxButton;
|
||||||
private VisualElement uvxPathStatus;
|
private VisualElement uvxPathStatus;
|
||||||
private TextField gitUrlOverride;
|
private TextField gitUrlOverride;
|
||||||
|
private Button browseGitUrlButton;
|
||||||
private Button clearGitUrlButton;
|
private Button clearGitUrlButton;
|
||||||
private TextField deploySourcePath;
|
private TextField deploySourcePath;
|
||||||
private Button browseDeploySourceButton;
|
private Button browseDeploySourceButton;
|
||||||
|
|
@ -76,6 +77,7 @@ namespace MCPForUnity.Editor.Windows.Components.Settings
|
||||||
clearUvxButton = Root.Q<Button>("clear-uv-button");
|
clearUvxButton = Root.Q<Button>("clear-uv-button");
|
||||||
uvxPathStatus = Root.Q<VisualElement>("uv-path-status");
|
uvxPathStatus = Root.Q<VisualElement>("uv-path-status");
|
||||||
gitUrlOverride = Root.Q<TextField>("git-url-override");
|
gitUrlOverride = Root.Q<TextField>("git-url-override");
|
||||||
|
browseGitUrlButton = Root.Q<Button>("browse-git-url-button");
|
||||||
clearGitUrlButton = Root.Q<Button>("clear-git-url-button");
|
clearGitUrlButton = Root.Q<Button>("clear-git-url-button");
|
||||||
deploySourcePath = Root.Q<TextField>("deploy-source-path");
|
deploySourcePath = Root.Q<TextField>("deploy-source-path");
|
||||||
browseDeploySourceButton = Root.Q<Button>("browse-deploy-source-button");
|
browseDeploySourceButton = Root.Q<Button>("browse-deploy-source-button");
|
||||||
|
|
@ -124,6 +126,8 @@ namespace MCPForUnity.Editor.Windows.Components.Settings
|
||||||
browseUvxButton.clicked += OnBrowseUvxClicked;
|
browseUvxButton.clicked += OnBrowseUvxClicked;
|
||||||
clearUvxButton.clicked += OnClearUvxClicked;
|
clearUvxButton.clicked += OnClearUvxClicked;
|
||||||
|
|
||||||
|
browseGitUrlButton.clicked += OnBrowseGitUrlClicked;
|
||||||
|
|
||||||
gitUrlOverride.RegisterValueChangedCallback(evt =>
|
gitUrlOverride.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
string url = evt.newValue?.Trim();
|
string url = evt.newValue?.Trim();
|
||||||
|
|
@ -147,6 +151,25 @@ namespace MCPForUnity.Editor.Windows.Components.Settings
|
||||||
OnHttpServerCommandUpdateRequested?.Invoke();
|
OnHttpServerCommandUpdateRequested?.Invoke();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
deploySourcePath.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
string path = evt.newValue?.Trim();
|
||||||
|
if (string.IsNullOrEmpty(path) || path == "Not set")
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MCPServiceLocator.Deployment.SetStoredSourcePath(path);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
EditorUtility.DisplayDialog("Invalid Source", ex.Message, "OK");
|
||||||
|
UpdateDeploymentSection();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
browseDeploySourceButton.clicked += OnBrowseDeploySourceClicked;
|
browseDeploySourceButton.clicked += OnBrowseDeploySourceClicked;
|
||||||
clearDeploySourceButton.clicked += OnClearDeploySourceClicked;
|
clearDeploySourceButton.clicked += OnClearDeploySourceClicked;
|
||||||
deployButton.clicked += OnDeployClicked;
|
deployButton.clicked += OnDeployClicked;
|
||||||
|
|
@ -250,12 +273,25 @@ namespace MCPForUnity.Editor.Windows.Components.Settings
|
||||||
McpLog.Info("uv path override cleared");
|
McpLog.Info("uv path override cleared");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnBrowseGitUrlClicked()
|
||||||
|
{
|
||||||
|
string picked = EditorUtility.OpenFolderPanel("Select Server folder", string.Empty, string.Empty);
|
||||||
|
if (!string.IsNullOrEmpty(picked))
|
||||||
|
{
|
||||||
|
gitUrlOverride.value = picked;
|
||||||
|
EditorPrefs.SetString(EditorPrefKeys.GitUrlOverride, picked);
|
||||||
|
OnGitUrlChanged?.Invoke();
|
||||||
|
OnHttpServerCommandUpdateRequested?.Invoke();
|
||||||
|
McpLog.Info($"Server source override set to: {picked}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateDeploymentSection()
|
private void UpdateDeploymentSection()
|
||||||
{
|
{
|
||||||
var deployService = MCPServiceLocator.Deployment;
|
var deployService = MCPServiceLocator.Deployment;
|
||||||
|
|
||||||
string sourcePath = deployService.GetStoredSourcePath();
|
string sourcePath = deployService.GetStoredSourcePath();
|
||||||
deploySourcePath.value = string.IsNullOrEmpty(sourcePath) ? "Not set" : sourcePath;
|
deploySourcePath.value = sourcePath ?? string.Empty;
|
||||||
|
|
||||||
deployTargetLabel.text = $"Target: {deployService.GetTargetDisplayPath()}";
|
deployTargetLabel.text = $"Target: {deployService.GetTargetDisplayPath()}";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
<ui:VisualElement class="path-override-controls">
|
<ui:VisualElement class="path-override-controls">
|
||||||
<ui:TextField name="git-url-override" placeholder-text="/path/to/Server or git+https://..." class="override-field" />
|
<ui:TextField name="git-url-override" placeholder-text="/path/to/Server or git+https://..." class="override-field" />
|
||||||
|
<ui:Button name="browse-git-url-button" text="Select" class="icon-button" />
|
||||||
<ui:Button name="clear-git-url-button" text="Clear" class="icon-button" />
|
<ui:Button name="clear-git-url-button" text="Clear" class="icon-button" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
<ui:Label text="Examples:" class="help-text" style="margin-top: 5px;" />
|
<ui:Label text="Examples:" class="help-text" style="margin-top: 5px;" />
|
||||||
|
|
@ -47,7 +48,7 @@
|
||||||
<ui:Label text="MCP For Unity Source Folder:" class="override-label" />
|
<ui:Label text="MCP For Unity Source Folder:" class="override-label" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
<ui:VisualElement class="path-override-controls">
|
<ui:VisualElement class="path-override-controls">
|
||||||
<ui:TextField name="deploy-source-path" readonly="true" class="override-field" />
|
<ui:TextField name="deploy-source-path" class="override-field" />
|
||||||
<ui:Button name="browse-deploy-source-button" text="Select" class="icon-button" />
|
<ui:Button name="browse-deploy-source-button" text="Select" class="icon-button" />
|
||||||
<ui:Button name="clear-deploy-source-button" text="Clear" class="icon-button" />
|
<ui:Button name="clear-deploy-source-button" text="Clear" class="icon-button" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue