Window 사용 제한 특수 기호 막기
This commit is contained in:
@@ -53,7 +53,7 @@ namespace Studio.UI
|
||||
var projectName = GetProjectName();
|
||||
var projectPath = GetProjectRoute();
|
||||
|
||||
if (!IsProjectNameVaild(projectName) || !IsProjectExistVaild())
|
||||
if (!IsProjectNameVaild(projectName) || !IsProjectExistVaild(projectName) || IsWindowRestrictedKey(projectName))
|
||||
{
|
||||
InputFieldHighlight(InputField_ProjectName);
|
||||
return;
|
||||
@@ -107,18 +107,32 @@ namespace Studio.UI
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private bool IsProjectExistVaild()
|
||||
private bool IsProjectExistVaild(string projectName)
|
||||
{
|
||||
var projectPath = InputField_ProjectRoute.text;
|
||||
var projectNameAndExtension = $"{InputField_ProjectName.text}.ocs";
|
||||
|
||||
var filePath = Path.Combine(projectPath, projectNameAndExtension);
|
||||
if (File.Exists(filePath))
|
||||
var projectNameAndExtension = $"{projectName}.ocs";
|
||||
|
||||
if (File.Exists(projectNameAndExtension))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
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)
|
||||
{
|
||||
CoroutineRunner.instance.StartCoroutine(Blink(inputField));
|
||||
|
||||
@@ -2,6 +2,7 @@ using Studio.Core;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using TriLibCore.SFB;
|
||||
using UnityEngine;
|
||||
@@ -47,7 +48,7 @@ namespace Studio.UI
|
||||
var projectName = GetProjectName();
|
||||
var projectPath = GetProjectRoute();
|
||||
|
||||
if (!IsProjectNameVaild(projectName) || !IsProjectExistVaild())
|
||||
if (!IsProjectNameVaild(projectName) || !IsProjectExistVaild(projectName) || IsWindowRestrictedKey(projectName))
|
||||
{
|
||||
InputFieldHighlight(InputField_ProjectName);
|
||||
return;
|
||||
@@ -99,18 +100,32 @@ namespace Studio.UI
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private bool IsProjectExistVaild()
|
||||
private bool IsProjectExistVaild(string projectName)
|
||||
{
|
||||
var projectPath = InputField_ProjectRoute.text;
|
||||
var projectNameAndExtension = $"{InputField_ProjectName.text}.ocs";
|
||||
var projectNameAndExtension = $"{projectName}.ocs";
|
||||
|
||||
var filePath = Path.Combine(projectPath, projectNameAndExtension);
|
||||
if (File.Exists(filePath))
|
||||
if (File.Exists(projectNameAndExtension))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
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)
|
||||
{
|
||||
CoroutineRunner.instance.StartCoroutine(Blink(inputField));
|
||||
|
||||
Reference in New Issue
Block a user