Window 사용 제한 특수 기호 막기 #209
@@ -53,7 +53,7 @@ namespace Studio.UI
|
|||||||
var projectName = GetProjectName();
|
var projectName = GetProjectName();
|
||||||
var projectPath = GetProjectRoute();
|
var projectPath = GetProjectRoute();
|
||||||
|
|
||||||
if (!IsProjectNameVaild(projectName) || !IsProjectExistVaild())
|
if (!IsProjectNameVaild(projectName) || !IsProjectExistVaild(projectName) || IsWindowRestrictedKey(projectName))
|
||||||
{
|
{
|
||||||
InputFieldHighlight(InputField_ProjectName);
|
InputFieldHighlight(InputField_ProjectName);
|
||||||
return;
|
return;
|
||||||
@@ -107,18 +107,32 @@ namespace Studio.UI
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private bool IsProjectExistVaild()
|
private bool IsProjectExistVaild(string projectName)
|
||||||
{
|
{
|
||||||
var projectPath = InputField_ProjectRoute.text;
|
var projectNameAndExtension = $"{projectName}.ocs";
|
||||||
var projectNameAndExtension = $"{InputField_ProjectName.text}.ocs";
|
|
||||||
|
|
||||||
var filePath = Path.Combine(projectPath, projectNameAndExtension);
|
if (File.Exists(projectNameAndExtension))
|
||||||
if (File.Exists(filePath))
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
private bool IsWindowRestrictedKey(string input)
|
||||||
|
{
|
||||||
|
char[] invalidChars = Path.GetInvalidFileNameChars();
|
||||||
|
|
||||||
|
if (input[0] == ' ')
|
||||||
|
return true;
|
||||||
|
|
||||||
|
foreach (char c in input)
|
||||||
|
{
|
||||||
|
if (invalidChars.Contains(c))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
private void InputFieldHighlight(TMP_InputField inputField)
|
private void InputFieldHighlight(TMP_InputField inputField)
|
||||||
{
|
{
|
||||||
CoroutineRunner.instance.StartCoroutine(Blink(inputField));
|
CoroutineRunner.instance.StartCoroutine(Blink(inputField));
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using Studio.Core;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using TriLibCore.SFB;
|
using TriLibCore.SFB;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@@ -47,7 +48,7 @@ namespace Studio.UI
|
|||||||
var projectName = GetProjectName();
|
var projectName = GetProjectName();
|
||||||
var projectPath = GetProjectRoute();
|
var projectPath = GetProjectRoute();
|
||||||
|
|
||||||
if (!IsProjectNameVaild(projectName) || !IsProjectExistVaild())
|
if (!IsProjectNameVaild(projectName) || !IsProjectExistVaild(projectName) || IsWindowRestrictedKey(projectName))
|
||||||
{
|
{
|
||||||
InputFieldHighlight(InputField_ProjectName);
|
InputFieldHighlight(InputField_ProjectName);
|
||||||
return;
|
return;
|
||||||
@@ -99,18 +100,32 @@ namespace Studio.UI
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private bool IsProjectExistVaild()
|
private bool IsProjectExistVaild(string projectName)
|
||||||
{
|
{
|
||||||
var projectPath = InputField_ProjectRoute.text;
|
var projectNameAndExtension = $"{projectName}.ocs";
|
||||||
var projectNameAndExtension = $"{InputField_ProjectName.text}.ocs";
|
|
||||||
|
|
||||||
var filePath = Path.Combine(projectPath, projectNameAndExtension);
|
if (File.Exists(projectNameAndExtension))
|
||||||
if (File.Exists(filePath))
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
private bool IsWindowRestrictedKey(string input)
|
||||||
|
{
|
||||||
|
char[] invalidChars = Path.GetInvalidFileNameChars();
|
||||||
|
|
||||||
|
if (input[0] == ' ')
|
||||||
|
return true;
|
||||||
|
|
||||||
|
foreach (char c in input)
|
||||||
|
{
|
||||||
|
if (invalidChars.Contains(c))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
private void InputFieldHighlight(TMP_InputField inputField)
|
private void InputFieldHighlight(TMP_InputField inputField)
|
||||||
{
|
{
|
||||||
CoroutineRunner.instance.StartCoroutine(Blink(inputField));
|
CoroutineRunner.instance.StartCoroutine(Blink(inputField));
|
||||||
|
|||||||
Reference in New Issue
Block a user