コード例 #1
0
ファイル: TestForm.cs プロジェクト: hackerlank/trunk-chatbot
        private void getFramesRelatedToFrame1_Click(object sender, EventArgs e)
        {
            ResetOutput();

            if (frame1.SelectedItem == null)
            {
                MessageBox.Show("Please select frame 1");
                return;
            }

            Frame frame = frame1.SelectedItem as Frame;

            // show related frames
            FrameSet relatedFrames = new FrameSet(false);

            foreach (Frame.FrameRelation relation in SelectedRelations)
            {
                foreach (Frame relatedFrame in frame.GetRelatedFrames(relation, SelectedRelationDirection, recursive.Checked))
                {
                    if (!relatedFrames.Contains(relatedFrame))
                    {
                        output.AppendText(relatedFrame.ToString() + Environment.NewLine);
                        relatedFrames.Add(relatedFrame);
                    }
                }
            }

            numItemsLbl.Text = relatedFrames.Count.ToString() + " related frames";
        }
コード例 #2
0
        public void Initialize()
        {
            _initialized = true;

            if (!File.Exists(_fileName))
            {
                return;
            }

            try
            {
                _fStream = new FileStream(_fileName, FileMode.Open, FileAccess.Read);
                _reader  = new BinaryReader(_fStream);
                int currentVersion = _reader.ReadInt32();
                if (currentVersion < 2)
                {
                    System.Windows.Forms.MessageBox.Show("Wrong version, expecting lib version: " + LibVersion.ToString() + " found version: " + currentVersion.ToString() + ".", _fileName, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, System.Windows.Forms.MessageBoxDefaultButton.Button1);
                    System.Windows.Forms.Application.Exit();
                    return;
                }
                _count = _reader.ReadInt32();

                int frameSeek = 0;
                if (currentVersion >= 3)
                {
                    frameSeek = _reader.ReadInt32();
                }

                _images    = new MImage[_count];
                _indexList = new int[_count];

                for (int i = 0; i < _count; i++)
                {
                    _indexList[i] = _reader.ReadInt32();
                }

                if (currentVersion >= 3)
                {
                    _fStream.Seek(frameSeek, SeekOrigin.Begin);

                    var frameCount = _reader.ReadInt32();

                    if (frameCount > 0)
                    {
                        _frames = new FrameSet();
                        for (int i = 0; i < frameCount; i++)
                        {
                            _frames.Add((MirAction)_reader.ReadByte(), new Frame(_reader));
                        }
                    }
                }
            }
            catch (Exception)
            {
                _initialized = false;
                throw;
            }
        }
コード例 #3
0
ファイル: EdnaDbContext.cs プロジェクト: goaaats/EdnaCore
        public void ImportFromCsv(string path)
        {
            Database.EnsureDeleted();
            Database.Migrate();

            #region WalkableAreaMap

            var walkableAreaMapCsv = ParseCsv(Path.Combine(path, "walkableareamap.csv"));

            foreach (var result in walkableAreaMapCsv)
            {
                if (result.Length != 3)
                {
                    continue;
                }

                WalkableAreaMap.Add(new WalkableAreaMap
                {
                    Id      = int.Parse(result[0]),
                    WamFile = result[2]
                });
            }

            #endregion

            #region Script

            var scriptCsv = ParseCsv(Path.Combine(path, "skript.csv"));

            foreach (var result in scriptCsv)
            {
                System.Diagnostics.Debug.Assert(result.Length <= 5, "SKRIPT column count failed?");

                if (result.Length != 4)
                {
                    continue;
                }

                Script.Add(new Skript()
                {
                    SkriptId     = int.Parse(result[0]),
                    Zeilennummer = int.Parse(result[1]),
                    SkriptAktion = result[2],
                    Kommentar    = result[3]
                });
            }

            #endregion

            #region FrameSet

            var frameSetCsv = ParseCsv(Path.Combine(path, "bildfolge.csv"));

            foreach (var result in frameSetCsv)
            {
                System.Diagnostics.Debug.Assert(result.Length <= 4, "BILDFOLGE column count failed?");

                if (result.Length != 4)
                {
                    continue;
                }

                FrameSet.Add(new Bildfolge()
                {
                    Id           = int.Parse(result[0]),
                    Bezeichnung  = result[1],
                    Anzeigedauer = int.Parse(result[2]),
                    Loop         = bool.Parse(result[3])
                });

                System.Diagnostics.Debug.Assert(!FrameSet.Any(x => x.Id == int.Parse(result[0])), "duplicate BILDFOLGE?");
            }

            #endregion

            SaveChanges();

            #region CharacterAnimationSet

            var characterAnimationSetCsv = ParseCsv(Path.Combine(path, "characteranimationset.csv"));

            foreach (var result in characterAnimationSetCsv)
            {
                System.Diagnostics.Debug.Assert(result.Length <= 7, "CHARACTERANIMATIONSET column count failed?");

                if (result.Length != 7)
                {
                    continue;
                }

                var thisSet = new CharacterAnimationSet()
                {
                    SetId           = int.Parse(result[0]),
                    AktionsmodusId  = int.Parse(result[1]),
                    Bezeichnung     = result[2],
                    LinksBildfolge  = FrameSet.Find(int.Parse(result[3])),
                    RechtsBildfolge = FrameSet.Find(int.Parse(result[4])),
                    VorneBildfolge  = FrameSet.Find(int.Parse(result[5])),
                    HintenBildfolge = FrameSet.Find(int.Parse(result[6])),
                };

                CharacterAnimationSet.Add(thisSet);

                // There are various CAS with null animations
                //System.Diagnostics.Debug.Assert(thisSet.LinksBildfolge != null && thisSet.RechtsBildfolge != null && thisSet.VorneBildfolge != null && thisSet.HintenBildfolge != null, $"CHARACTERANIMATIONSET {thisSet.Bezeichnung} has null bildfolge?");
            }

            #endregion

            #region ChoiceList

            var choiceListCsv = ParseCsv(Path.Combine(path, "choiceliste.csv"));

            foreach (var result in choiceListCsv)
            {
                System.Diagnostics.Debug.Assert(result.Length <= 5, "CHOICELISTE column count failed?");

                if (result.Length != 5)
                {
                    continue;
                }

                var thisSet = new ChoiceListeEntry()
                {
                    ChoiceId      = int.Parse(result[0]),
                    AuswahlNummer = int.Parse(result[1]),
                    Aktiv         = bool.Parse(result[2]),
                    AuswahlText   = result[3],
                    SkriptId      = int.Parse(result[4])
                };

                ChoiceList.Add(thisSet);
            }

            #endregion

            #region Timer

            var timerCsv = ParseCsv(Path.Combine(path, "timer.csv"));

            foreach (var result in timerCsv)
            {
                System.Diagnostics.Debug.Assert(result.Length <= 4, "TIMER column count failed?");

                if (result.Length != 4)
                {
                    continue;
                }

                Timer.Add(new Timer()
                {
                    Id       = int.Parse(result[0]),
                    SkriptId = int.Parse(result[1]),
                    Dauer    = int.Parse(result[2]),
                    Aktiv    = bool.Parse(result[3])
                });
            }

            #endregion

            #region ChoiceList

            var roomCsv = ParseCsv(Path.Combine(path, "raum.csv"));

            foreach (var result in roomCsv)
            {
                System.Diagnostics.Debug.Assert(result.Length <= 13, "RAUM column count failed?");

                if (result.Length > 13 || result.Length < 12)
                {
                    continue;
                }

                var thisRoom = new Raum
                {
                    Id                      = int.Parse(result[0]),
                    Bezeichnung             = result[1],
                    BildDatei               = result[2],
                    MusikDatei              = result[3],
                    WalkableAreaMap         = WalkableAreaMap.Find(int.Parse(result[4])),
                    VSpeed                  = ParseDouble(result[5]),
                    HSpeed                  = ParseDouble(result[6]),
                    BaseYatZeroScale        = ParseDouble(result[7]),
                    BaseYatFullScale        = ParseDouble(result[8]),
                    GuiId                   = int.Parse(result[9]),
                    CharacterAnimationSetId = int.Parse(result[10]),
                    Timer                   = Timer.Find(int.Parse(result[11]))
                };

                Room.Add(thisRoom);
            }

            #endregion

            SaveChanges();
        }