Пример #1
0
 public void UpdateLineByID(DialogLine dl)
 {
     if (connection != null && connection.State == System.Data.ConnectionState.Open)
     {
         SQLiteCommand command = new SQLiteCommand(connection);
         command.CommandText = "UPDATE dialogDb SET " +
                               "character = '" + dl.Character + "'," +
                               "contentGer = '" + dl.ContentGer + "'," +
                               "contentEng = '" + dl.ContentEng + "'," +
                               "previous = '" + dl.previous + "'," +
                               "next0 = '" + dl.next[0] + "'," +
                               "next1 = '" + dl.next[1] + "'," +
                               "next2 = '" + dl.next[2] + "'," +
                               "next3 = '" + dl.next[3] + "'," +
                               "activeNexts = '" + dl.activeNexts + "'," +
                               "isEntry = '" + Convert.ToString(dl.IsEntry) + "'," +
                               "isJump = '" + Convert.ToString(dl.IsJump) + "'," +
                               "requirements = '" + dl.Requirements + "'," +
                               "eventTrigger = '" + dl.EventTrigger + "'," +
                               "audioFileGer = '" + dl.AudioFileGer + "'," +
                               "audioFileEng = '" + dl.AudioFileEng + "'," +
                               "pause = '" + dl.Pause + "' " +
                               "WHERE id = " + dl.Id;
         SQLiteDataReader reader = command.ExecuteReader();
         reader.Close();
         reader.Dispose();
         command.Dispose();
     }
     else
     {
         throw new Exception("Invalid data base connection.");
     }
 }
Пример #2
0
 public void Insert(DialogLine line)
 {
     if (connection != null && connection.State == System.Data.ConnectionState.Open)
     {
         SQLiteCommand command = new SQLiteCommand(connection);
         command.CommandText = "INSERT INTO dialogDb (id, character, contentGer, contentEng, previous, next0, next1, next2, next3, activeNexts, isEntry, isJump, requirements, chapter, scene, dlcNumber, eventTrigger, audioFileGer, audioFileEng, pause) VALUES(" +
                               "NULL, '" +
                               line.Character + "','" +
                               line.ContentGer + "','" +
                               line.ContentEng + "','" +
                               line.previous + "','" +
                               line.next[0] + "','" +
                               line.next[1] + "','" +
                               line.next[2] + "','" +
                               line.next[3] + "','" +
                               line.activeNexts + "','" +
                               Convert.ToString(line.IsEntry) + "','" +
                               Convert.ToString(line.IsJump) + "','" +
                               line.Requirements + "','" +
                               line.DlcId.Chapter + "','" +
                               line.DlcId.Scene + "','" +
                               line.DlcId.DlcNumber + "','" +
                               line.EventTrigger + "','" +
                               line.AudioFileGer + "','" +
                               line.AudioFileEng + "','" +
                               line.Pause + "'" +
                               ")";
         command.ExecuteNonQuery();
         command.Dispose();
     }
     else
     {
         throw new Exception("Invalid data base connection.");
     }
 }
Пример #3
0
        private string UpdateReaderPreview()
        {
            // Control Variables
            int             idCounter  = 0;
            int             startId    = 0;
            DataGridViewRow startRow   = null;
            DialogLine      startLine  = null;
            List <int>      jumpPoints = new List <int>();
            int             idCount    = 0;

            string content = "";

            List <int> idList = new List <int>();

            foreach (DataGridViewRow row in DgvDataBase.Rows)
            {
                idList.Add(Convert.ToInt32(row.Cells[0].Value));
            }
            idCount = idList.Count;

            // Get Start
            foreach (DataGridViewRow row in DgvDataBase.Rows)
            {
                if (Convert.ToInt32(row.Cells[4].Value) == -1)
                {
                    startRow = row;
                }
            }
            startId   = Convert.ToInt32(startRow.Cells[0].Value);
            startLine = db.GetLineById(startId);

            GoThroughNexts(startLine, ref content, ref jumpPoints, ref idCounter, ref idCount);

            return(content);
        }
Пример #4
0
 private void DgvDataBase_SelectionChanged(object sender, EventArgs e)
 {
     try {
         int             rowIndex    = DgvDataBase.SelectedRows[0].Index;
         DataGridViewRow selectedRow = DgvDataBase.Rows[rowIndex];
         int             id          = Convert.ToInt32(selectedRow.Cells[0].Value);
         activeDialogLine         = db.GetLineById(id);
         LblActiveDialogLine.Text = "Active DialogLine: " + activeDialogLine;
         LoadDialogLineContent();
     }
     catch {}
 }
Пример #5
0
        private void CmdAddDialogLine_Click(object sender, EventArgs e)
        {
            if (activeDlc == null || db == null)
            {
                throw new Exception("activeDlc || db== NULL");
            }

            DialogLine dialogLine = new DialogLine(activeDlc);

            db.Insert(dialogLine);
            UpdateDataGridByActiveDlc();
            SelectDgvRowById(db.GetLatestId());
        }
Пример #6
0
        private void GoThroughNexts(DialogLine jumpLine, ref string content, ref List <int> jumpPoints, ref int idCounter, ref int max)
        {
            idCounter++;
            if (idCounter > max)
            {
                return;
            }

            if (jumpLine.IsEntry)
            {
                content += "[ENTRY POINT]\n";
            }

            content += "(" + jumpLine.Id + ") " + jumpLine.Character + ": " + jumpLine.ContentGer;
            int        activeNexts = jumpLine.activeNexts;
            DialogLine currentLine = null;

            jumpPoints.Add(jumpLine.Id);

            if (activeNexts > 1)
            {
                content += " [JUMP]\n";
                for (int j = 0; j < activeNexts; j++)
                {
                    currentLine = db.GetLineById(jumpLine.next[j]);
                    content    += "\t" + (j + 1) + ": " + currentLine.ContentGer + "[JMP->" + jumpLine.next[j] + "]\n";
                }
                content += "\n";
                for (int j = 0; j < activeNexts; j++)
                {
                    currentLine = db.GetLineById(jumpLine.next[j]);
                    GoThroughNexts(currentLine, ref content, ref jumpPoints, ref idCounter, ref max);
                }
            }
            else
            {
                // Is currentLine the last line?
                if (jumpLine.next[0] == 0 || jumpPoints.Contains(jumpLine.next[0]))
                {
                    content += "\nENDE\n\n";
                    return;
                }
                else
                {
                    content    += "\n";
                    currentLine = db.GetLineById(jumpLine.next[0]);
                    GoThroughNexts(currentLine, ref content, ref jumpPoints, ref idCounter, ref max);
                }
            }
        }
Пример #7
0
        private void CmdDeleteDialogLine_Click(object sender, EventArgs e)
        {
            if (activeDialogLine == null || db == null)
            {
                return;
            }
            DialogResult dr = MessageBox.Show("Do you really want to delete the DialogLine from the DataBase? It cannot be restored.", "Delete DialogLineContainer", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr != DialogResult.Yes)
            {
                return;
            }
            db.DeleteLineById(activeDialogLine.Id);
            activeDialogLine = null;
            UpdateDataGridByActiveDlc();
        }
Пример #8
0
        public List <DialogLine> GetLinesByDialogId(DialogLineContainer dlc)
        {
            if (connection != null && connection.State == System.Data.ConnectionState.Open)
            {
                SQLiteCommand command = new SQLiteCommand(connection);
                command.CommandText = "SELECT * " +
                                      "FROM dialogDb WHERE chapter = " + dlc.dialogId.Chapter + " AND scene = " + dlc.dialogId.Scene + " AND dlcNumber = " + dlc.dialogId.DlcNumber + " ORDER BY id ASC";
                SQLiteDataReader reader = command.ExecuteReader();

                List <DialogLine> dialogLinesList = new List <DialogLine>();

                while (reader.Read())
                {
                    DialogLine dl = new DialogLine(dlc);
                    dl.Id           = Convert.ToInt32(reader[0].ToString());
                    dl.Character    = reader[1].ToString();
                    dl.ContentGer   = reader[2].ToString();
                    dl.ContentEng   = reader[3].ToString();
                    dl.previous     = Convert.ToInt32(reader[4].ToString());
                    dl.next[0]      = Convert.ToInt32(reader[5].ToString());
                    dl.next[1]      = Convert.ToInt32(reader[6].ToString());
                    dl.next[2]      = Convert.ToInt32(reader[7].ToString());
                    dl.next[3]      = Convert.ToInt32(reader[8].ToString());
                    dl.activeNexts  = Convert.ToInt32(reader[9].ToString());
                    dl.IsEntry      = Convert.ToBoolean(reader[10]);
                    dl.IsJump       = Convert.ToBoolean(reader[11]);
                    dl.Requirements = reader[12].ToString();
                    dl.EventTrigger = Convert.ToInt32(reader[16].ToString());
                    dl.AudioFileGer = reader[17].ToString();
                    dl.AudioFileEng = reader[18].ToString();
                    dl.Pause        = (float)Convert.ToDouble(reader[19].ToString());
                    Console.WriteLine(dl);
                    dialogLinesList.Add(dl);
                }
                reader.Close();
                reader.Dispose();
                command.Dispose();
                return(dialogLinesList);
            }
            else
            {
                throw new Exception("Invalid data base connection.");
            }
        }
Пример #9
0
        public DialogLine GetLineById(int id)
        {
            if (connection != null && connection.State == System.Data.ConnectionState.Open)
            {
                SQLiteCommand command = new SQLiteCommand(connection);
                command.CommandText = "SELECT * FROM dialogDb WHERE id = " + id;
                SQLiteDataReader reader = command.ExecuteReader();

                DialogLine dl = null;

                while (reader.Read())
                {
                    DialogId dId = new DialogId(Convert.ToInt32(reader[13].ToString()), Convert.ToInt32(reader[14].ToString()), Convert.ToInt32(reader[15].ToString()));
                    dl              = new DialogLine(dId);
                    dl.Id           = Convert.ToInt32(reader[0].ToString());
                    dl.Character    = reader[1].ToString();
                    dl.ContentGer   = reader[2].ToString();
                    dl.ContentEng   = reader[3].ToString();
                    dl.previous     = Convert.ToInt32(reader[4].ToString());
                    dl.next[0]      = Convert.ToInt32(reader[5].ToString());
                    dl.next[1]      = Convert.ToInt32(reader[6].ToString());
                    dl.next[2]      = Convert.ToInt32(reader[7].ToString());
                    dl.next[3]      = Convert.ToInt32(reader[8].ToString());
                    dl.activeNexts  = Convert.ToInt32(reader[9].ToString());
                    dl.IsEntry      = Convert.ToBoolean(reader[10]);
                    dl.IsJump       = Convert.ToBoolean(reader[11]);
                    dl.Requirements = reader[12].ToString();
                    dl.EventTrigger = Convert.ToInt32(reader[16].ToString());
                    dl.AudioFileGer = reader[17].ToString();
                    dl.AudioFileEng = reader[18].ToString();
                    dl.Pause        = (float)Convert.ToDouble(reader[19].ToString());
                    Console.WriteLine(dl);
                }
                reader.Close();
                reader.Dispose();
                command.Dispose();
                return(dl);
            }
            else
            {
                throw new Exception("Invalid data base connection.");
            }
        }