Exemple #1
0
        private void Entry_PopOut(object sender, RoutedEventArgs e, ListView lv, int index)
        {
            ObjectStructure tOS = (ObjectStructure)database.data[index][lv.SelectedIndex];

            Misc.PopOut po = new Misc.PopOut();

            po.Title = tOS.Name;

            buildOSView(po.elements, tOS, 0);

            po.Show();
        }
Exemple #2
0
        public void add(string label = "")
        {
            Console.WriteLine("pure name is " + pureName);
            ObjectStructure os = getPure();

            if (label != "")
            {
                if (labels != null && labels.Count() > REFS.Count())
                {
                    for (int i = 0; i < os.fieldexportnames.Count; i++)
                    {
                        os.fieldexportnames[i] = labels[REFS.Count];
                    }
                }
            }
            REFS.Add(os);
        }
Exemple #3
0
        public void addFromData(string path)
        {
            //File.WriteAllText(path + os.Name + ".txt", os.getData());

            int    ind      = tabMain.SelectedIndex;
            string n        = ((TabItem)tabMain.Items[ind]).Header.ToString();
            string compPath = "config/Templates/" + n + "/" + path + ".txt";

            string s = File.ReadAllText(compPath);
            var    deserializeSettings = new JsonSerializerSettings {
                TypeNameHandling = TypeNameHandling.All
            };

            ObjectStructure os = JsonConvert.DeserializeObject <ObjectStructure>(s);

            database.addItem(ind, ObjectStructure.fromString(s, loadManifest(n)));
        }
Exemple #4
0
        private void Entry_Template(object sender, RoutedEventArgs e, ListView lv, int index)
        {
            int    ind = tabMain.SelectedIndex;
            string n   = ((TabItem)tabMain.Items[ind]).Header.ToString();

            ObjectStructure os = ((ObjectStructure)database.data[index][lv.SelectedIndex]);

            string path = "config/Templates/" + n + "/";

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

            File.WriteAllText(path + os.Name + ".txt", os.getData());

            objectTemplates.subclasses[n].Add(new Misc.SubclassHelper(os.Name));
        }
Exemple #5
0
        public void jsonPaste(object sender, RoutedEventArgs e)
        {
            int    ind = tabMain.SelectedIndex;
            string n   = ((TabItem)tabMain.Items[ind]).Header.ToString();
            var    deserializeSettings = new JsonSerializerSettings {
                TypeNameHandling = TypeNameHandling.All
            };
            string s = Clipboard.GetText();

            try
            {
                ObjectStructure os = JsonConvert.DeserializeObject <ObjectStructure>(s);

                database.addItem(ind, ObjectStructure.fromString(s, loadManifest(n)));
            }
            catch
            {
                Console.WriteLine("error in paste");
            }
        }
Exemple #6
0
 public void addItem(int dbc, ObjectStructure o)
 {
     data[dbc].Add(o);
     o.setObserver(ContentCollectionChangedsub);
 }
Exemple #7
0
        public string exportObjectStructure(FlatBase.GJDB database, FlatBase.ObjectStructure os, string catName, int id)
        {
            string json = "{";

            json += "\"$id\" : \"" + catName + id.ToString() + "\",";
            int c = 0;

            foreach (object o in os.FIELDS)
            {
                if (o is ObjectHeader)
                {
                    c++;
                    continue;
                }

                string safeName = os.fieldexportnames[c].Split('>')[0];
                json += "\"" + safeName + "\":";

                if (!(o is int) && !(o is ArrayStructure))
                {
                    json += "\"";
                }

                if (o is OReference)
                {
                    json += (o as OReference).REF;
                }
                else if (o is ArrayStructure)
                {
                    json += "[";
                    ArrayStructure AS = o as ArrayStructure;
                    //json += AS.save(database);
                    json += exportArray(database, AS);

                    /*foreach (ObjectStructure aos in AS.REFS)
                     * {
                     *  //json += aos.save() + ",";
                     * }*/
                    json += "]";
                }
                else
                {
                    json += o.ToString();
                }
                if (!(o is int) && !(o is ArrayStructure))
                {
                    json += "\"";
                }

                c++;

                if (c < os.FIELDS.Count)
                {
                    json += ",";
                }
            }

            json += "}";

            Console.WriteLine(c.ToString() + " fields exported");

            return(json);
        }
Exemple #8
0
        public static ObjectStructure loadManifest(string catName, ObjectStructure parent = null, ObjectStructure ovrrd = null, bool readOverride = false)
        {
            string[] s       = new string[1];
            int      offsetC = 0;

            if (!readOverride)
            {
                s = File.ReadAllLines("config/" + catName + ".txt");
            }
            else
            {
                s = catName.Split('\n');
            }


            ObjectStructure nost = new ObjectStructure();

            if (ovrrd != null)
            {
                nost = ovrrd;
            }

            int c = 0;

            for (int i = 0; i < s.Count(); i++)
            {
                if (s[i].Count() <= 0)
                {
                    continue;
                }

                if (s[i][0] == '#')
                {
                    continue;
                }

                string clipped = s[i].Split(' ')[1];

                if (s[i][0] == 'I')
                {
                    ObjectStructure ret = loadManifest(clipped, parent, nost);
                    offsetC += ret.FIELDS.Count;
                    continue;
                }

                if (s[i][0] == '!')
                {
                    nost.weightpools.Add(clipped, new Misc.weightpool());
                    Console.WriteLine(clipped + " weightpool");
                    continue;
                }

                if (s[i][0] == 'b')
                {
                    nost.FIELDS.Add(false);
                }

                if (s[i][0] == 'h')
                {
                    nost.FIELDS.Add(new ObjectHeader(clipped));
                }

                if (s[i][0] == 'i')
                {
                    nost.FIELDS.Add(0);
                }

                if (s[i][0] == 'f')
                {
                    nost.FIELDS.Add(0.0f);
                }

                if (s[i][0] == 'C')
                {
                    nost.FIELDS.Add(new Color());
                }

                if (s[i][0] == 'c')
                {
                    nost.FIELDS.Add(new Misc.CodeStructure());
                }

                if (s[i][0] == 'S')
                {
                    nost.FIELDS.Add(new Misc.FilePathStructure());
                }

                if (s[i][0] == 's')
                {
                    nost.FIELDS.Add("New Entry");
                    if (s[i][1] == 'N')
                    {
                        nost.setOverride(offsetC + c);
                    }
                }

                if (s[i][0] == 'm')
                {
                    Console.WriteLine("M");
                }

                if (s[i][0] == 'W')
                {
                    if (parent == null)
                    {
                        nost.FIELDS.Add(new Misc.WeightedGroup(nost.weightpools[clipped]));
                    }
                    else
                    {
                        nost.FIELDS.Add(new Misc.WeightedGroup(parent.weightpools[clipped]));
                    }
                }

                if (s[i][0] == 'E')
                {
                    nost.FIELDS.Add(new EnumField(clipped));
                }

                if (s[i][0] == 'l')
                {
                    nost.FIELDS.Add(new TagField(clipped));
                }

                if (s[i][0] == 'r')
                {
                    OReferenceList orl = new OReferenceList();
                    clipped = s[i].Split(' ')[2];
                    orl.setRA(Int32.Parse(clipped));
                    nost.FIELDS.Add(orl);
                }

                if (s[i][0] == 'R')
                {
                    OReference or = new OReference();
                    clipped = s[i].Split(' ')[2];
                    or.setRA(Int32.Parse(clipped));
                    nost.FIELDS.Add(or);
                }

                if (s[i][0] == 'G')
                {
                    intArray iA = new intArray(100);
                    nost.FIELDS.Add(iA);
                }

                if (s[i][0] == 'A')
                {
                    string eVAL = s[i].Remove(0, 1);



                    ArrayStructure aStruct = new ArrayStructure(eVAL, nost);
                    nost.FIELDS.Add(aStruct);
                }

                if (s[i][0] == 'T')
                {
                    List <ObjectStructure> dummytuple = new List <ObjectStructure>();
                    bool skipped = false;
                    foreach (string TT in s[i].Split(' '))
                    {
                        if (!skipped)
                        {
                            skipped = true;
                            continue;
                        }
                        ObjectStructure os = loadManifest(TT, parent);
                        Console.WriteLine(os.FIELDS.Count + " fields in tuple");
                        dummytuple.Add(os);
                    }

                    nost.FIELDS.Add(new Misc.TupleStructure(dummytuple));
                }

                nost.fieldexportnames.Add(clipped);
                c++;
            }

            return(nost);
        }
Exemple #9
0
        public void buildOSView(Panel tar, ObjectStructure os, int depth)
        {
            if (depth == 0)
            {
                tar.Children.Clear();
            }
            int c = 0;

            foreach (Object o in os.FIELDS)
            {
                //TODO: Switch statement
                if (o is bool)
                {
                    FieldSnippets.fsnipBool fsb = new FieldSnippets.fsnipBool();
                    fsb.labelTitle.Content = os.fieldexportnames[c];
                    fsb.toggleVal.Content  = os.fieldexportnames[c][0];

                    fsb.toggleVal.DataContext = os;
                    fsb.toggleVal.SetBinding(ToggleButton.IsCheckedProperty,
                                             new Binding()
                    {
                        Path = new PropertyPath("FIELDS[" + c + "]"), Source = os
                    });

                    //fsb.container.Width = 400 - (depth * 100);

                    tar.Children.Add(fsb);
                    c++;

                    continue;
                }

                if (o is Int64 || o is int || o is Int32)
                {
                    FieldSnippets.fsnipNumber fsn = new FieldSnippets.fsnipNumber(false);

                    fsn.labelTitle.Content = os.fieldexportnames[c];

                    Binding intBinding = new Binding();
                    intBinding.Path      = new PropertyPath("FIELDS[" + c + "]");
                    intBinding.Source    = os;
                    intBinding.Converter = new Misc.IntegerConverter();

                    fsn.numVal.SetBinding(TextBox.TextProperty,
                                          intBinding);

                    //fsn.container.Width = 400 - (depth * 200);

                    tar.Children.Add(fsn);

                    c++;
                    continue;
                }

                if (o is float || o is double)
                {
                    FieldSnippets.fsnipNumber fsn = new FieldSnippets.fsnipNumber(false);

                    Binding intBinding = new Binding();
                    intBinding.Path      = new PropertyPath("FIELDS[" + c + "]");
                    intBinding.Source    = os;
                    intBinding.Converter = new Misc.FloatConverter();

                    fsn.numVal.SetBinding(TextBox.TextProperty,
                                          intBinding);

                    fsn.container.Width = 400 - (depth * 200);

                    tar.Children.Add(fsn);

                    c++;
                    continue;
                }

                if (o is string)
                {
                    FieldSnippets.fsnipString fss = new FieldSnippets.fsnipString(3);

                    fss.title.Text            = os.fieldexportnames[c];
                    fss.textValue.DataContext = os;

                    Binding textBind = new Binding();
                    textBind.Path   = new PropertyPath("FIELDS[" + c + "]");
                    textBind.Source = os;
                    textBind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;

                    fss.textValue.SetBinding(TextBox.TextProperty,
                                             textBind);

                    tar.Children.Add(fss);

                    c++;
                    continue;
                }

                if (o is EnumField)
                {
                    FieldSnippets.fsnipEnum es = new FieldSnippets.fsnipEnum();
                    EnumField ef = o as EnumField;
                    es.labelTitle.Content = os.fieldexportnames[c];

                    Binding options = new Binding();
                    options.Path   = new PropertyPath("fields");
                    options.Source = em.getEnum(ef.reference);

                    Binding value = new Binding();
                    value.Path   = new PropertyPath("selected");
                    value.Source = ef;

                    es.comboEnum.SetBinding(ComboBox.ItemsSourceProperty, options);
                    es.comboEnum.SetBinding(ComboBox.SelectedIndexProperty, value);

                    tar.Children.Add(es);
                    c++;
                    continue;
                }

                if (o is Misc.FilePathStructure)
                {
                    Misc.FilePathStructure    fp = o as Misc.FilePathStructure;
                    FieldSnippets.fsnipSprite sp = new FieldSnippets.fsnipSprite(fp);


                    Binding lhs = new Binding();
                    lhs.Path   = new PropertyPath("PATH");
                    lhs.Source = o;
                    lhs.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;

                    Binding rhs = new Binding();
                    rhs.Path   = new PropertyPath("PATH");
                    rhs.Source = o;
                    rhs.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;

                    sp.Path.SetBinding(TextBox.TextProperty, lhs);
                    sp.Render.SetBinding(Image.SourceProperty, rhs);

                    tar.Children.Add(sp);
                    c++;
                    continue;
                }

                if (o is Misc.CodeStructure)
                {
                    Misc.CodeStructure      fp  = o as Misc.CodeStructure;
                    FieldSnippets.fsnipCode cde = new FieldSnippets.fsnipCode();
                    cde.title.Text = os.fieldexportnames[c];

                    Binding lhs = new Binding();
                    lhs.Path   = new PropertyPath("CODE");
                    lhs.Source = o;
                    lhs.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;

                    cde.codeBox.SetBinding(BindableAvalonEditor.TextProperty, lhs);

                    tar.Children.Add(cde);
                    c++;
                    continue;
                }

                if (o is TagField)
                {
                    TagField tf = o as TagField;
                    FieldSnippets.fsnipTags es = new FieldSnippets.fsnipTags(TagManager.tags["Global"], tf);

                    es.tagList.DataContext = o;
                    Binding textBind = new Binding();
                    textBind.Path                = new PropertyPath("value");
                    textBind.Source              = o;
                    textBind.Converter           = new Misc.TagChipConverter(tf.value);
                    textBind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;

                    es.tagList.SetBinding(ListView.ItemsSourceProperty,
                                          textBind);

                    //es.tagList.SetBinding(ListView.ItemsSourceProperty, value);

                    tar.Children.Add(es);
                    c++;
                    continue;
                }



                if (o is ObjectHeader)
                {
                    FieldSnippets.fsnipHeader fsh = new FieldSnippets.fsnipHeader((o as ObjectHeader).Name);
                    tar.Children.Add(fsh);
                    c++;
                    continue;
                }

                if (o is intArray)
                {
                    FieldSnippets.fsnipIntArray fsh = new FieldSnippets.fsnipIntArray();

                    Binding binding = new Binding();
                    binding.Path   = new PropertyPath("FIELDS[" + c + "]");
                    binding.Source = os;

                    //fsh.SetBinding(FieldSnippets.fsnipIntArray.ValuesProperty,
                    //    binding);

                    tar.Children.Add(fsh);
                    c++;
                    continue;
                }

                if (o is OReference)
                {
                    FieldSnippets.fsnipOReferenceSingleton fsor = new FieldSnippets.fsnipOReferenceSingleton("Spells", o as OReference,
                                                                                                             database.data[(o as OReference).getRA()]);

                    //fsor.lView.ItemsSource = ((OReferenceList)o).refnames;

                    MultiBinding mb = new MultiBinding();

                    Binding lhs = new Binding();
                    lhs.Path   = new PropertyPath("REF");
                    lhs.Source = o;

                    Binding rhs = new Binding();
                    rhs.Source = database.data[(o as OReference).getRA()];

                    mb.Bindings.Add(lhs);
                    mb.Bindings.Add(rhs);

                    mb.Converter = new Misc.ORefSingleConverter();


                    fsor.textDisplay.DataContext = o;
                    fsor.textDisplay.SetBinding(Label.ContentProperty,
                                                mb);


                    tar.Children.Add(fsor);
                    c++;
                    continue;
                }

                if (o is OReferenceList)
                {
                    FieldSnippets.fsnipOReference fsor = new FieldSnippets.fsnipOReference("Spells", o as OReferenceList,
                                                                                           database.data[(o as OReferenceList).getRA()]);

                    //fsor.lView.ItemsSource = ((OReferenceList)o).refnames;

                    MultiBinding mb = new MultiBinding();

                    Binding lhs = new Binding();
                    lhs.Path   = new PropertyPath("REFS");
                    lhs.Source = o;

                    Binding rhs = new Binding();
                    rhs.Source = database.data[(o as OReferenceList).getRA()];

                    mb.Bindings.Add(lhs);
                    mb.Bindings.Add(rhs);

                    mb.Converter = new Misc.ORefConverter();


                    fsor.lView.DataContext = o;
                    fsor.lView.SetBinding(ListView.ItemsSourceProperty,
                                          mb);


                    tar.Children.Add(fsor);
                    c++;
                    continue;
                }

                if (o is Misc.TupleStructure)
                {
                    Grid g = new Grid();
                    g.Background          = new SolidColorBrush(Color.FromArgb(255, (byte)255, (byte)255, (byte)0));
                    g.HorizontalAlignment = HorizontalAlignment.Stretch;
                    g.Margin            = new Thickness(0);
                    g.UseLayoutRounding = false;

                    Console.WriteLine((o as Misc.TupleStructure).fields.Count + " fc");
                    int gc = 0;
                    foreach (ObjectStructure tb in (o as Misc.TupleStructure).fields)
                    {
                        g.ColumnDefinitions.Add(new ColumnDefinition());
                        Grid sp = new Grid();
                        sp.HorizontalAlignment = HorizontalAlignment.Stretch;
                        sp.Background          = new SolidColorBrush(Color.FromArgb(255, (byte)0, (byte)255, (byte)255));

                        buildOSView(sp, tb, 1);

                        Grid.SetColumn(sp, gc);
                        g.Children.Add(sp);
                        gc++;
                    }

                    tar.Children.Add(g);
                }

                if (o is Color)
                {
                    Color col = (Color)o;

                    Binding colorBinding = new Binding();
                    colorBinding.Path      = new PropertyPath("FIELDS[" + c + "]");
                    colorBinding.Source    = os;
                    colorBinding.Converter = new Misc.FloatConverter();

                    FieldSnippets.fsnipColor colSnip = new FieldSnippets.fsnipColor();
                    colSnip.picker.SetBinding(ColorPicker.ColorProperty, colorBinding);


                    tar.Children.Add(colSnip);
                }

                if (o is ArrayStructure)
                {
                    FieldSnippets.fsnipArray fsor = new FieldSnippets.fsnipArray((o as ArrayStructure).pureName.Split(' ')[1], this, o as ArrayStructure);

                    fsor.lView.DataContext = os;
                    Binding itemBind = new Binding();
                    itemBind.Path   = new PropertyPath("REFS");
                    itemBind.Source = o;
                    itemBind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
                    itemBind.Converter           = new Misc.AStructConverter(this, (ArrayStructure)o);



                    fsor.lView.SetBinding(ListView.ItemsSourceProperty,
                                          itemBind);

                    tar.Children.Add(fsor);
                    c++;
                    continue;
                }

                if (o is Misc.WeightedGroup)
                {
                    FieldSnippets.fsnipSlider fsor = new FieldSnippets.fsnipSlider();

                    Binding lhs = new Binding();
                    lhs.Path   = new PropertyPath("POINTS");
                    lhs.Source = o;
                    lhs.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;

                    Binding rhs = new Binding();
                    rhs.Path   = new PropertyPath("points");
                    rhs.Source = (o as Misc.WeightedGroup).tiedWP;
                    rhs.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;

                    fsor.Slider.SetBinding(Slider.ValueProperty, lhs);
                    fsor.NumDisplay.SetBinding(Label.ContentProperty, lhs);
                    fsor.Slider.SetBinding(Slider.MaximumProperty, rhs);

                    tar.Children.Add(fsor);
                    c++;
                    continue;
                }
            }
        }