예제 #1
0
        private void restoryYarn(yarnFile f, bool log = false)
        {
            if (log)
            {
                Log("Restoring original dialogue content of " + f.yarnFileName + ".txt...", true);
            }

            string yarnDir = AppDomain.CurrentDomain.BaseDirectory + @"\yarn files";

            if (!Directory.Exists(yarnDir))
            {
                Directory.CreateDirectory(yarnDir);
            }

            string yarnPath = Path.Combine(yarnDir, f.yarnFileName) + ".txt";

            File.WriteAllText(yarnPath, f.originalContent);

            UnityAssetFile.write(f.yarnFileName, ref rootz);

            f.lastModified = File.GetLastWriteTime(yarnPath);
            f.edited       = false;

            JsonUtil.saveYarnDictionary(rootz);

            if (log)
            {
                Log("Restoring original dialogue content of " + f.yarnFileName + ".txt done", true);
            }
        }
예제 #2
0
        private void OnChanged(object source, FileSystemEventArgs e)
        {
            if (!setupRunning)
            {
                watcher.EnableRaisingEvents = false;
                System.Timers.Timer fwt = new System.Timers.Timer();
                fwt.Interval = 5;
                fwt.Elapsed += delegate {
                    watcher.EnableRaisingEvents = true;
                    fwt.Stop();
                };
                fwt.Start();

                string yarnFile = e.Name.Replace(".txt", "");

                Log("Detected change to " + e.Name, true);

                UnityAssetFile.write(yarnFile, ref rootz);

                DataGridViewRow row = dgvFiles.Rows
                                      .Cast <DataGridViewRow>()
                                      .Where(r => r.Cells["columnFile"].Value.ToString().Equals(e.Name))
                                      .First();

                updateDgvFilesRow(row.Index);
            }
        }
예제 #3
0
        private void dgvFiles_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                e.RowIndex >= 0 && senderGrid.Rows[0].Cells[1].Value.ToString() != "Please \"Run Setup\" on the \"More\" tab")
            {
                string buttonText   = senderGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                string yarnFileName = senderGrid.Rows[e.RowIndex].Cells["columnFile"].Value.ToString();
                if (buttonText.Contains("Open"))
                {
                    string yarnFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"yarn files", yarnFileName);

                    Debug.WriteLine(yarnFilePath);
                    if (String.IsNullOrEmpty(rootz.textEd))
                    {
                        frmEditor frmEd = new frmEditor();
                        frmEd.yarnFile = yarnFileName;
                        frmEd.yarnPath = yarnFilePath;
                        frmEd.Show();
                    }
                    else
                    {
                        DirectoryInfo    yarnFileInfo = new DirectoryInfo(yarnFilePath);
                        ProcessStartInfo editorInfo   = new ProcessStartInfo();
                        editorInfo.FileName  = rootz.textEd;
                        editorInfo.Arguments = String.Format(@"""{0}""", yarnFileInfo.FullName);
                        Process.Start(editorInfo);
                    }

                    dgvFiles.ClearSelection();
                }
                else if (buttonText.Contains("Write"))
                {
                    UnityAssetFile.write(yarnFileName.Replace(".txt", ""), ref rootz);

                    updateDgvFilesRow(e.RowIndex);
                }
                else if (buttonText.Contains("Reset"))
                {
                    bool watcherStatus = watcher.EnableRaisingEvents;
                    //tabControl1.SelectedIndex = 0;
                    watcher.EnableRaisingEvents = false;
                    updateWatcherButton();
                    tabControl1.Update();

                    restoryYarn(rootz.yarnFiles[yarnFileName.Replace(".txt", "")], true);

                    updateDgvFilesRow(e.RowIndex);
                    if (watcherStatus == true)
                    {
                        watcher.EnableRaisingEvents = true;
                        updateWatcherButton();
                    }
                }
            }
        }
예제 #4
0
 private void btnWrite_Click(object sender, EventArgs e) //for testing
 {
     btnWrite.Enabled = false;
     UnityAssetFile.write("BusStation.yarn", ref rootz);
     btnWrite.Enabled = true;
 }