Пример #1
0
    private void Start()
    {
        DialogueDBAdmin.DeleteDatabase("F****r.db");
        DialogueDBAdmin.CreateUniDialogueDB("F****r.db");
        //SQLiteConnection _connection = new SQLiteConnection("Assets/StreamingAssets/F****r.db", SQLiteOpenFlags.ReadWrite);
        DialogueDBConnection _connection = new DialogueDBConnection("F****r.db", SQLiteOpenFlags.ReadWrite);
        DialogueDBManager    _dbManager  = new DialogueDBManager(_connection);

        ConversationEntry con1 = new ConversationEntry("asd1", -1);
        ConversationEntry con2 = new ConversationEntry("asd2", -1);
        ConversationEntry con3 = new ConversationEntry("asd3", -1);
        ConversationEntry con4 = new ConversationEntry("asd4", -1);
        ConversationEntry con5 = new ConversationEntry("asd5", -1);

        ContentEntry coe1 = new ContentEntry("fff1", "ccc1", -1);
        ContentEntry coe2 = new ContentEntry("fff2", "ccc2", -1);
        ContentEntry coe3 = new ContentEntry("fff3", "ccc3", -1);
        ContentEntry coe4 = new ContentEntry("fff4", "ccc4", -1);
        ContentEntry coe5 = new ContentEntry("fff5", "ccc5", -1);

        ExecutionEntry exe1 = new ExecutionEntry("eee1", -1);
        ExecutionEntry exe2 = new ExecutionEntry("eee2", -1);
        ExecutionEntry exe3 = new ExecutionEntry("eee3", -1);
        ExecutionEntry exe4 = new ExecutionEntry("eee4", -1);
        ExecutionEntry exe5 = new ExecutionEntry("eee5", -1);

        ConditionEntry cod1 = new ConditionEntry("ddd1", -1, -1);
        ConditionEntry cod2 = new ConditionEntry("ddd2", -1, -1);
        ConditionEntry cod3 = new ConditionEntry("ddd3", -1, -1);
        ConditionEntry cod4 = new ConditionEntry("ddd4", -1, -1);
        ConditionEntry cod5 = new ConditionEntry("ddd5", -1, -1);

        _dbManager.InsertEntry(con1);
        _dbManager.InsertEntry(con2);
        _dbManager.InsertEntry(con3);
        _dbManager.InsertEntry(con4);
        _dbManager.InsertEntry(con5);
        _dbManager.InsertEntry(coe1);
        _dbManager.InsertEntry(coe2);
        _dbManager.InsertEntry(coe3);
        _dbManager.InsertEntry(coe4);
        _dbManager.InsertEntry(coe5);
        _dbManager.InsertEntry(exe1);
        _dbManager.InsertEntry(exe2);
        _dbManager.InsertEntry(exe3);
        _dbManager.InsertEntry(exe4);
        _dbManager.InsertEntry(exe5);
        _dbManager.InsertEntry(cod1);
        _dbManager.InsertEntry(cod2);
        _dbManager.InsertEntry(cod3);
        _dbManager.InsertEntry(cod4);
        _dbManager.InsertEntry(cod5);

        List <ExecutionEntry> list = _connection.Query <ExecutionEntry>("SELECT *, MAX(ID) FROM ExecutionEntry;");

        foreach (ExecutionEntry ee in list)
        {
            Debug.Log(ee.ExecutionCode);
        }
    }
Пример #2
0
 public void Add(ConditionEntry f)
 {
     if (fields == null)
     {
         fields = new List <ConditionEntry>();
     }
     fields.Add(f);
 }
        private void TextChangedInLeft(object sender, EventArgs e)          // something changed in text field..
        {
            ExtendedControls.ExtTextBoxAutoComplete t  = sender as ExtendedControls.ExtTextBoxAutoComplete;
            Tuple <Group, Group.Conditions>         gc = t.Tag as Tuple <Group, Group.Conditions>;

            if (gc.Item1.variables != null)        // if variables associated
            {
                string text = t.Text;
                foreach (var v in gc.Item1.variables)
                {
                    if (text.Equals(v.Name))
                    {
                        t.SetTipDynamically(toolTip, v.Help ?? "");

                        if (v.DefaultCondition != null)
                        {
                            ExtendedControls.ExtComboBox cb = gc.Item2.cond;

                            if (ConditionEntry.MatchTypeFromString(cb.Text, out ConditionEntry.MatchType mt))
                            {
                                ConditionEntry.Classification mtc    = ConditionEntry.Classify(mt);
                                ConditionEntry.Classification defcls = ConditionEntry.Classify(v.DefaultCondition.Value);

                                if (mtc != defcls)
                                {
                                    System.Diagnostics.Debug.WriteLine("Select cond" + v.DefaultCondition.Value + " cur " + mt);
                                    cb.SelectedItem = ConditionEntry.MatchNames[(int)v.DefaultCondition.Value];
                                }
                            }
                        }

                        return;
                    }
                }
            }

            t.SetTipDynamically(toolTip, "");
        }
Пример #4
0
        public string FromString(string line)
        {
            StringParser sp = new StringParser(line);

            bool multi = false;

            string delimchars = " ";

            if (sp.IsCharMoveOn('('))
            {
                multi      = true;
                delimchars = ") ";
            }

            List <Condition>      cllist = new List <Condition>();
            List <ConditionEntry> ed = new List <ConditionEntry>();
            string innercond = null, outercond = "Or";       // innercond == null until we have one, then it needs to be the same every time

            while (true)
            {
                string var  = sp.NextQuotedWord(delimchars);
                string cond = sp.NextQuotedWord(delimchars);

                if (var == null || cond == null)
                {
                    return("Missing parts of condition");
                }

                MatchType mt;

                if (!MatchTypeFromString(cond, out mt))
                {
                    return("Operator is not recognised");
                }

                string value = "";

                if (!IsUnaryOperation(mt) && !IsNullOperation(mt))
                {
                    value = sp.NextQuotedWord(delimchars);
                    if (value == null)
                    {
                        return("Missing parts of condition");
                    }
                }

                ConditionEntry ce = new ConditionEntry()
                {
                    itemname = var, matchtype = mt, matchstring = value
                };
                ed.Add(ce);

                if (sp.IsCharMoveOn(')'))      // if closing bracket..
                {
                    if (!multi)
                    {
                        return("Closing condition bracket found but no opening ( present");
                    }

                    Condition cl = new Condition();
                    if (!cl.Create("Default", "", "", innercond ?? "Or", outercond))
                    {
                        return("Could not create condition - check inner and outer condition names");
                    }

                    cl.fields = ed;
                    cllist.Add(cl);
                    ed        = new List <ConditionEntry>();
                    innercond = null;

                    if (sp.IsEOL)  // EOL, end of  (cond..cond) outercond ( cond cond)
                    {
                        conditionlist = cllist;
                        return(null);
                    }
                    else
                    {
                        outercond = sp.NextQuotedWord(delimchars);

                        if (outercond == null)
                        {
                            return("Missing outer condition in multiple conditions between brackets");
                        }

                        if (!sp.IsCharMoveOn('(')) // must have another (
                        {
                            return("Missing multiple condition after " + outercond);
                        }
                    }
                }
                else if (sp.IsEOL) // last condition
                {
                    if (multi)
                    {
                        return("Missing closing braket in multiple condition");
                    }

                    Condition cl = new Condition();
                    if (!cl.Create("Default", "", "", innercond ?? "Or", "Or"))
                    {
                        return("Could not create condition - check inner and outer condition names");
                    }

                    cl.fields = ed;
                    cllist.Add(cl);
                    conditionlist = cllist;
                    return(null);
                }
                else
                {
                    string condi = sp.NextQuotedWord(delimchars);

                    if (innercond == null)
                    {
                        innercond = condi;
                    }
                    else if (!innercond.Equals(condi, StringComparison.InvariantCultureIgnoreCase))
                    {
                        return("Differing inner conditions incorrect");
                    }
                }
            }
        }
        public string Check()   // calculate if in error, fill Result with what is valid. Empty string if ok
        {
            Result = new ConditionLists();

            string errorlist = "";

            foreach (Group g in groups)
            {
                string innerc = g.innercond.Text;
                string outerc = g.outercond.Text;
                string evt    = (eventlist != null) ? g.evlist.Text : "Default";

                //System.Diagnostics.Debug.WriteLine("Event {0} inner {1} outer {2} action {3} data '{4}'", evt, innerc, outerc, actionname, actiondata );

                Condition fe = new Condition();

                if (evt.Length == 0)        // must have name
                {
                    errorlist += "Ignored group with empty name" + Environment.NewLine;
                }
                else
                {
                    if (fe.Create(evt, "", "", innerc, outerc)) // create must work
                    {
                        for (int i = 0; i < g.condlist.Count; i++)
                        {
                            Group.Conditions c      = g.condlist[i];
                            string           fieldn = c.fname.Text;
                            string           condn  = c.cond.Text;
                            string           valuen = c.value.Text;

                            if (fieldn.Length > 0 || ConditionEntry.IsNullOperation(condn))
                            {
                                ConditionEntry f = new ConditionEntry();

                                if (f.Create(fieldn, condn, valuen))
                                {
                                    if (valuen.Length == 0 && !ConditionEntry.IsUnaryOperation(condn) && !ConditionEntry.IsNullOperation(condn))
                                    {
                                        errorlist += "Do you want filter '" + fieldn + "' in group '" + fe.eventname + "' to have an empty value" + Environment.NewLine;
                                    }

                                    fe.Add(f);
                                }
                                else
                                {
                                    errorlist += "Cannot create filter '" + fieldn + "' in group '" + fe.eventname + "' check value" + Environment.NewLine;
                                }
                            }
                            else
                            {
                                errorlist += "Ignored empty filter " + (i + 1).ToString(System.Globalization.CultureInfo.InvariantCulture) + " in " + fe.eventname + Environment.NewLine;
                            }
                        }

                        if (fe.fields != null)
                        {
                            Result.Add(fe);
                        }
                        else
                        {
                            errorlist += "No valid filters found in group '" + fe.eventname + "'" + Environment.NewLine;
                        }
                    }
                    else
                    {
                        errorlist += "Cannot create " + evt + " not a normal error please report" + Environment.NewLine;
                    }
                }
            }

            return(errorlist);
        }
        private void FixUpGroups(bool calcminsize = true)      // fixes and positions groups.
        {
            SuspendLayout();
            panelVScroll.SuspendLayout();

            int panelwidth = Math.Max(panelVScroll.Width - panelVScroll.ScrollBarWidth, 10);
            int y          = panelymargin;

            for (int i = 0; i < groups.Count; i++)
            {
                Group g = groups[i];
                g.panel.SuspendLayout();

                // for all groups, see if another group below it has the same event selected as ours

                bool showouter = false;

                if (eventlist != null)
                {
                    for (int j = i - 1; j >= 0; j--)
                    {
                        if (groups[j].evlist.Text.Equals(groups[i].evlist.Text) && groups[i].evlist.Text.Length > 0)
                        {
                            showouter = true;
                        }
                    }

                    showouter = showouter && allowoutercond;     // qualify with outer condition switch
                }
                else
                {
                    showouter = (i > 0) && allowoutercond;       // and enabled/disable the outer condition switch
                }
                // Now position the conditions inside the panel

                int vnextcond = panelymargin;

                int condxoffset = (g.evlist != null) ? (g.evlist.Right + 8) : panelxmargin;
                int farx        = condxoffset; // should never not have a condition but ..

                int panelxspacing = Font.ScalePixels(4);
                int panelyspacing = Font.ScalePixels(6);

                for (int condc = 0; condc < g.condlist.Count; condc++)
                {
                    Group.Conditions c = g.condlist[condc];
                    c.fname.Location = new Point(condxoffset, vnextcond);
                    c.fname.Enabled  = !ConditionEntry.IsNullOperation(c.cond.Text);
                    if (!c.fname.Enabled)
                    {
                        c.fname.Text = "";
                    }

                    c.cond.Location = new Point(c.fname.Right + panelxspacing, vnextcond);

                    c.value.Location = new Point(c.cond.Right + panelxspacing, vnextcond);
                    c.value.Width    = panelwidth - condxoffset - c.fname.Width - 4 - c.cond.Width - 4 - c.del.Width - 4 - c.more.Width - 4 - g.innercond.Width - 4 - g.upbutton.Width + 8;
                    c.value.Enabled  = !ConditionEntry.IsNullOperation(c.cond.Text) && !ConditionEntry.IsUnaryOperation(c.cond.Text);
                    if (!c.value.Enabled)
                    {
                        c.value.Text = "";
                    }

                    c.del.Location  = new Point(c.value.Right + panelxspacing, vnextcond);
                    c.more.Location = new Point(c.del.Right + panelxspacing, vnextcond);
                    c.more.Visible  = (condc == g.condlist.Count - 1);

                    vnextcond += c.fname.Height + panelyspacing;
                    farx       = c.more.Left; // where the innercond/up buttons are
                }

                // and the outer/inner conditions

                g.innercond.Visible  = (g.condlist.Count > 1);        // inner condition on if multiple
                g.innercond.Location = new Point(farx, panelymargin); // inner condition is in same place as more button
                farx = g.innercond.Right + panelxspacing;             // move off

                // and the up button..
                g.upbutton.Visible  = (i != 0 && g.condlist.Count > 0);
                g.upbutton.Location = new Point(farx, panelymargin);

                // allocate space for the outercond if req.
                g.outercond.Enabled = g.outercond.Visible = g.outerlabel.Visible = showouter;       // and enabled/disable the outer condition switch

                if (showouter)
                {
                    g.outercond.Location  = new Point(panelxmargin, vnextcond);
                    g.outerlabel.Location = new Point(g.outercond.Location.X + g.outercond.Width + panelxspacing, g.outercond.Location.Y + 3);
                    vnextcond            += g.outercond.Height + panelyspacing;
                }

                // pos the panel

                g.panel.Location    = new Point(panelxmargin, y + panelVScroll.ScrollOffset);
                g.panel.Size        = new Size(Math.Max(panelwidth - panelxmargin * 2, farx), Math.Max(vnextcond + panelyspacing, g.innercond.Bottom + panelyspacing));
                g.panel.BorderStyle = (g.condlist.Count > 1) ? BorderStyle.FixedSingle : BorderStyle.None;

                y += g.panel.Height + panelyspacing * 2;

                // and make sure actions list is right

                g.panel.ResumeLayout();
            }

            if (allowoutercond || groups.Count == 0)
            {
                buttonMore.Location = new Point(panelxmargin, y + panelVScroll.ScrollOffset);
                buttonMore.Visible  = true;
                y = buttonMore.Bottom;
            }
            else
            {
                buttonMore.Visible = false;
            }

            if (calcminsize)
            {
                onCalcMinsize?.Invoke(y);
            }

            panelVScroll.ResumeLayout();
            ResumeLayout();
            Invalidate(true);
            Update();
        }