Пример #1
0
/*
 *              /// <summary>
 *              /// ラベルからファイルパスを取得
 *              /// </summary>
 *              /// <param name="name">キャラ名</param>
 *              /// <param name="label">ラベル</param>
 *              /// <returns>ファイルパス</returns>
 *              public string LabelToPath(string name, string label)
 *              {
 *                      //既に絶対URLならそのまま
 *                      if (UtageToolKit.IsAbsoluteUri(label))
 *                      {
 *                              return label;
 *                      }
 *                      else
 *                      {
 *                              string key = ToFileKey(name, label);
 *                              AdvCharacterSettingData data = FindData(key);
 *                              if (data == null)
 *                              {
 *                                      //ラベルをそのままファイル名扱いに
 *                                      return label;
 *                              }
 *                              else
 *                              {
 *                                      return data.FilePath;
 *                              }
 *                      }
 *              }
 */

        public AdvCharacterInfo ParseCharacterInfo(string nameText, string patternLabel, out string erroMsg)
        {
            string characterTag = "";
            bool   isHide       = false;
            string msg          = "";
            Func <string, string, bool> callbackTagParse = (tagName, arg) =>
            {
                switch (tagName)
                {
                case "Off":
                    isHide = true;
                    return(true);

                case "Character":
                    characterTag = arg;
                    return(true);

                default:
                    msg = "Unkownn Tag <" + tagName + ">";
                    return(false);
                }
            };

            patternLabel = ParserUtil.ParseTagTextToString(patternLabel, callbackTagParse);
            erroMsg      = msg;
            if (!string.IsNullOrEmpty(characterTag) && !Contains(characterTag))
            {
                if (!string.IsNullOrEmpty(erroMsg))
                {
                    erroMsg += "\n";
                }
                erroMsg = "Unknown Character [" + characterTag + "] ";
            }
            return(GetCharacterInfoSub(nameText, characterTag, patternLabel, isHide));
        }
Пример #2
0
        public static string ParsePatternOnly(AdvCommand command)
        {
            return(ParserUtil.ParseTagTextToString(
                       command.ParseCellOptional <string>(AdvColumnName.Arg2, ""),
                       (tagName, arg) =>
            {
                bool failed = false;
                switch (tagName)
                {
                case "Off":
                    //非表示タグ
                    break;

                case "Character":
                    //キャラクターラベルの指定タグ
                    break;

                default:
                    failed = true;
                    break;
                }
                return !failed;
            }));
        }
/*
 *              /// <summary>
 *              /// ラベルからファイルパスを取得
 *              /// </summary>
 *              /// <param name="name">キャラ名</param>
 *              /// <param name="label">ラベル</param>
 *              /// <returns>ファイルパス</returns>
 *              public string LabelToPath(string name, string label)
 *              {
 *                      //既に絶対URLならそのまま
 *                      if (UtageToolKit.IsAbsoluteUri(label))
 *                      {
 *                              return label;
 *                      }
 *                      else
 *                      {
 *                              string key = ToFileKey(name, label);
 *                              AdvCharacterSettingData data = FindData(key);
 *                              if (data == null)
 *                              {
 *                                      //ラベルをそのままファイル名扱いに
 *                                      return label;
 *                              }
 *                              else
 *                              {
 *                                      return data.FilePath;
 *                              }
 *                      }
 *              }
 */

        public AdvCharacterInfo GetCharacterInfo(string nameText, string patternLabel)
        {
            string characterTag = "";
            bool   isHide       = false;
            Func <string, string, bool> callbackTagParse = (tagName, arg) =>
            {
                switch (tagName)
                {
                case "Off":
                    isHide = true;
                    return(true);

                case "Character":
                    characterTag = arg;
                    return(true);

                default:
                    return(false);
                }
            };

            patternLabel = ParserUtil.ParseTagTextToString(patternLabel, callbackTagParse);
            return(GetCharacterInfoSub(nameText, characterTag, patternLabel, isHide));
        }
Пример #4
0
        public static AdvCharacterInfo Create(AdvCommand command, AdvSettingDataManager dataManager)
        {
            if (command.IsEmptyCell(AdvColumnName.Arg1))
            {
                return(null);
            }

            //名前
            string nameText       = command.ParseCell <string>(AdvColumnName.Arg1);
            string characterLabel = nameText;
            //第二引数を解析
            //基本的にはパターン名だが
            //キャラクターラベルの指定タグがあったり、非表示タグする
            bool   isHide  = false;
            string erroMsg = "";
            string pattern = ParserUtil.ParseTagTextToString(
                command.ParseCellOptional <string>(AdvColumnName.Arg2, ""),
                (tagName, arg) =>
            {
                bool failed = false;
                switch (tagName)
                {
                case "Off":
                    //非表示タグ
                    isHide = true;
                    break;

                case "Character":
                    //キャラクターラベルの指定タグ
                    characterLabel = arg;
                    break;

                default:
                    erroMsg = "Unkownn Tag <" + tagName + ">";
                    failed  = true;
                    break;
                }
                return(!failed);
            });

            if (!string.IsNullOrEmpty(erroMsg))
            {
                Debug.LogError(erroMsg);
                return(null);
            }

            if (!dataManager.CharacterSetting.Contains(characterLabel))
            {
                //そもそもキャラ表示がない場合、名前表示のみになる
                return(new AdvCharacterInfo(characterLabel, nameText, pattern, isHide, null));
            }

            AdvCharacterSettingData data = dataManager.CharacterSetting.GetCharacterData(characterLabel, pattern);

            //キャラの表示情報の記述エラー
            if (data == null)
            {
                Debug.LogError(command.ToErrorString(characterLabel + ", " + pattern + " is not contained in Chactecter Sheet"));
                return(null);
            }
            //名前テキストをキャラクターシートの定義に変更
            if (!string.IsNullOrEmpty(data.NameText) && nameText == characterLabel)
            {
                nameText = data.NameText;
            }
            return(new AdvCharacterInfo(characterLabel, nameText, pattern, isHide, data.Graphic));
        }