Ejemplo n.º 1
0
        /// <summary>
        /// コンストラクター
        /// </summary>
        public dlgMapTest(AllDB dbList, MapOneData mapData)
        {
            this.InitializeComponent();
            Common.EnableDoubleBuffering(this);
            this.dbList  = dbList;
            this.mapData = mapData;

            //変数種別リストを生成する
            this.cmbValueType.Items.Clear();
            for (var i = 0; i <= (int)Database.DBValueIndices.CommonString + 1; i++)
            {
                switch ((Database.DBValueIndices)i)
                {
                case Database.DBValueIndices.CommonFlag:
                    this.cmbValueType.Items.Add($"{i}:スクリプト共通フラグ");
                    break;

                case Database.DBValueIndices.CommonInteger:
                    this.cmbValueType.Items.Add($"{i}:スクリプト共通整数");
                    break;

                case Database.DBValueIndices.CommonString:
                    this.cmbValueType.Items.Add($"{i}:スクリプト共通文字列");
                    break;

                default:
                    this.cmbValueType.Items.Add($"{i}:イベント個別変数");
                    break;
                }
            }

            //変数リストは暫定的なので無効化
            this.cmbValues.Items.Clear();
            this.cmbValues.Enabled = false;

            //イベントリストを生成
            //イベントリストはイベント個別変数が選択されたときのみ有効なので初期状態では無効化とする
            this.cmbEVs.Items.Clear();
            for (int i = 0; i < mapData.EVCount; i++)
            {
                this.cmbEVs.Items.Add($"{mapData[i].VisibleID}:{mapData[i].Name}");
            }
            this.cmbEVs.Enabled = false;

            //既存リストを生成する
            var list = new List <ListViewItem>();
            var buf  = Settings.Default.Last_MapTestValueData;
            var spl  = buf.Split(Resources.Split_SimpleList.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

            foreach (var statement in spl)
            {
                var add = new ListViewItem();
                buf = statement;

                //FixedIDを取得する
                string fixedID   = null;
                int    evFixedID = -1;
                string value     = "";
                if (statement.Contains("="))
                {
                    //スクリプト共通変数
                    fixedID = statement.Substring(2, statement.IndexOf("=") - 2);    //頭2文字以降の文字列から = まで
                    value   = Common.CutDoubleQuotation(statement.Substring(statement.IndexOf("=") + 1));
                }
                else
                {
                    //イベント個別変数
                    var regux = new Regex(Resources.Requx_SQSelfValueForMapTest);
                    var match = regux.Match(statement);
                    if (!match.Success || match.Groups.Count != 4)
                    {
                        //無効なフォーマット
                        continue;
                    }
                    if (!int.TryParse(match.Groups[1].Value, out evFixedID))
                    {
                        //無効なフォーマット
                        continue;
                    }
                    fixedID = match.Groups[2].Value;
                    value   = match.Groups[3].Value;
                }
                add.Text = fixedID.ToString();

                //種別を判定する
                var subDB          = -1;
                var valueTypeIndex = -1;
                var type           = buf.Substring(0, 2);
                if (type == Resources.SQ_UserFlag)
                {
                    subDB          = (int)Database.DBValueIndices.CommonFlag;
                    valueTypeIndex = subDB;
                }
                else if (type == Resources.SQ_UserInteger)
                {
                    subDB          = (int)Database.DBValueIndices.CommonInteger;
                    valueTypeIndex = subDB;
                }
                else if (type == Resources.SQ_UserString)
                {
                    subDB          = (int)Database.DBValueIndices.CommonString;
                    valueTypeIndex = subDB;
                }
                else
                {
                    //イベント個別変数
                    subDB          = (int)Database.DBValueIndices.SelfEvent;
                    valueTypeIndex = this.cmbValueType.Items.Count - 1;
                }

                //種別と変数名をセットする
                add.SubItems.Add(this.cmbValueType.Items[valueTypeIndex].ToString());
                add.SubItems.Add(Database.GetIDNameFromFixedID(this.dbList[Database.DBIndices.Value].DBs[subDB], int.Parse(fixedID)));

                //値をセットする
                add.SubItems.Add(value);

                if (evFixedID != -1)
                {
                    //イベントをセットする
                    add.SubItems.Add(this.getEVVisibleIDNamePairFromFixedID(evFixedID) ?? $"{dlgMapTest.NotFoundEVIDPrefix}:{evFixedID}");
                }
                else
                {
                    add.SubItems.Add("");
                }

                list.Add(add);
            }

            //リスト列を設定する
            this.uctlListEditor.SetupList(new string[] { "種別", "変数", "値", "イベント" }, list, true, 1);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// タイルデータを読み込みます。
        /// </summary>
        public static MapOneData LoadTileData(string rPath)
        {
            if (!File.Exists(ProjectManager.ProjectPath + rPath))
            {
                return(null);
            }

            var newData = new MapOneData();

            MapOneData.OutOfEdit = true;

            //タイル部
            using (var R = new StreamReader(Common.OpenFileReadOnly(ProjectManager.ProjectPath + rPath), Common.SJIS)) {
                var buf = "";

                //ヘッダー情報
                newData.Name                   = R.ReadLine();
                newData.GUID                   = R.ReadLine();
                newData.MapSize                = Common.StringToSize(R.ReadLine()); //ここでタイル配列が初期化される
                newData.MapLoopOption          = (Map.MapLoopType) int.Parse(R.ReadLine());
                newData.TilesetFixedID         = int.Parse(R.ReadLine());
                newData.MoveSpeed              = (Map.Speed) int.Parse(R.ReadLine());
                newData.BaseMapFileName        = R.ReadLine();
                newData.BGM                    = new Media.SoundObject(R.ReadLine());
                newData.BGS                    = new Media.SoundObject(R.ReadLine());
                newData.BackPictureFileName    = R.ReadLine();
                newData.BackPictureScrollType  = (Map.ScrollType) int.Parse(R.ReadLine());
                newData.BackPictureScrollSpeed = int.Parse(R.ReadLine());
                newData.FogFileName            = R.ReadLine();
                newData.FogScrollType          = (Map.ScrollType) int.Parse(R.ReadLine());
                newData.FogScrollSpeed         = int.Parse(R.ReadLine());
                newData.FogBlendMode           = (Media.BlendMode) int.Parse(R.ReadLine());

                buf = R.ReadLine();
                var spl = buf.Split(Resources.Split_LongData.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                newData.EncounterUnits = new List <int>();
                foreach (var fixedID in spl)
                {
                    newData.EncounterUnits.Add(int.Parse(fixedID));
                }

                newData.EncounterRate      = int.Parse(R.ReadLine());
                newData.BattleBackFileName = R.ReadLine();

                R.ReadLine();       //空行

                //タイルデータ
                for (var l = (int)Map.Layer.Low; l <= (int)Map.Layer.Shadow; l++)
                {
                    for (var y = 0; y < newData.MapSize.Height; y++)
                    {
                        //1行丸ごと読み込んでしまうと、サイズが大きすぎた場合にデータが落ちてしまうので1文字ずつ読み込む
                        var x    = 0;
                        var temp = "";
                        buf = "";
                        do
                        {
                            temp = ((char)(R.Read())).ToString();
                            if (temp != Resources.Split_LongData)
                            {
                                buf += temp;
                            }
                            else
                            {
                                var sub = buf.Split(Resources.Split_Argument.ToCharArray());

                                // 1/4 タイル情報が先行する
                                newData.LayerTiles[l, x, y].SetQuarters(
                                    int.Parse(sub[(int)Map.QuarterTile.LeftTop]),
                                    int.Parse(sub[(int)Map.QuarterTile.RightTop]),
                                    int.Parse(sub[(int)Map.QuarterTile.LeftBottom]),
                                    int.Parse(sub[(int)Map.QuarterTile.RightBottom])
                                    );

                                //タイルレイヤーにはタイルパレット位置が含まれている
                                if (sub.Length > (int)Map.QuarterTile.Count)
                                {
                                    newData.LayerTiles[l, x, y].PalletPosition = Common.StringToPoint(sub[(int)Map.QuarterTile.Count]);
                                }
                                buf = "";
                                x++;
                            }
                        } while (x < newData.MapSize.Width);
                        R.ReadLine();   //残りの改行コードを読み捨て
                    }
                    R.ReadLine();       //空行読み捨て
                }
            }
            MapOneData.OutOfEdit = false;
            return(newData);
        }