Exemplo n.º 1
0
 public el_omnibox(document doc, GameObject parent, Icontainer container) : base(doc)
 {
     Parent = parent;
     _editObj.transform.SetParent(Parent.transform, false);
     _edit = _editObj.AddComponent <InputField>();
     //_edit.KeyPress += _edit_KeyPress;
 }
Exemplo n.º 2
0
 public static string resolve_name(string name, Icontainer callback)
 {
     for (var i = 0; g_def_colors[i].name != null; i++)
     {
         if (string.Equals(name, g_def_colors[i].name, StringComparison.OrdinalIgnoreCase))
         {
             return(g_def_colors[i].rgb);
         }
     }
     if (callback != null)
     {
         return(callback.resolve_color(name));
     }
     return(string.Empty);
 }
Exemplo n.º 3
0
        //we are going to base the best item on an accumulation of points based on every stat difference for the item
        private static Iitem CompareItems(Iitem bestItem, Iitem comparee)
        {
            List <int>   scores    = new List <int>();
            List <Iitem> bothItems = new List <Iitem> {
                bestItem, comparee
            };

            int index = 0;

            foreach (Iitem item in bothItems)
            {
                Iclothing  clothing  = item as Iclothing;
                Iweapon    weapon    = item as Iweapon;
                Icontainer container = item as Icontainer;

                if (clothing != null)
                {
                    scores[index] += (int)clothing.CurrentDefense;
                }

                if (weapon != null)
                {
                    scores[index] += (int)(weapon.CurrentMaxDamage - weapon.CurrentMinDamage);
                    scores[index] += (int)weapon.AttackSpeed;
                    //TODO: will need to figure out wear effects and player/target attack effects
                }

                if (container != null)
                {
                    scores[index] += (int)container.WeightLimit / 100;
                    scores[index] += (int)container.ReduceCarryWeightBy * 100;
                }

                index++;
            }

            if (scores[1] > scores[0])
            {
                bestItem = bothItems[1];
            }

            return(bestItem);
        }
Exemplo n.º 4
0
        public static document createFromUTF8(string str, Icontainer container, Iscript script, context ctx, css user_styles = null)
        {
            var doc           = new document(container, script, ctx); // Create litehtml::document
            var root_elements = new List <element>();

            using (var gumbo = new Gumbo.Gumbo(str))                        // parse document into GumboOutput
                doc.create_node(gumbo.Document.Root, root_elements, true);  // Create litehtml::elements.
            if (root_elements.Count != 0)
            {
                doc._root = root_elements.Back();
            }
            // Let's process created elements tree
            if (doc._root != null)
            {
                doc.container.get_media_features(doc._media);
                doc._root.apply_stylesheet(ctx.master_css); // apply master CSS
                doc._root.parse_attributes();               // parse elements attributes
                foreach (var css in doc._css)               // parse style sheets linked in document
                {
                    doc._styles.parse_stylesheet(css.text, css.baseurl, doc, !string.IsNullOrEmpty(css.media) ? media_query_list.create_from_string(css.media, doc) : null);
                }
                doc._styles.sort_selectors(); // Sort css selectors using CSS rules.
                if (doc._media_lists.Count != 0)
                {
                    doc.update_media_lists(doc._media);  // get current media features
                }
                doc._root.apply_stylesheet(doc._styles); // Apply parsed styles.
                if (user_styles != null)
                {
                    doc._root.apply_stylesheet(user_styles); // Apply user styles if any
                }
                doc._root.parse_styles();                    // Parse applied styles in the elements
                doc.fix_tables_layout();                     // Now the _tabular_elements is filled with tabular elements. We have to check the tabular elements for missing table elements and create the anonymous boxes in visual table layout
                doc._root.init();                            // Fanaly initialize elements
            }
            return(doc);
        }
Exemplo n.º 5
0
 public static web_color from_string(string str, Icontainer callback)
 {
     if (string.IsNullOrEmpty(str))
     {
         return(new web_color(0, 0, 0));
     }
     if (str[0] == '#')
     {
         var red   = string.Empty;
         var green = string.Empty;
         var blue  = string.Empty;
         if (str.Length - 1 == 3)
         {
             red   += str[1];
             red   += str[1];
             green += str[2];
             green += str[2];
             blue  += str[3];
             blue  += str[3];
         }
         else if (str.Length - 1 == 6)
         {
             red   += str[1];
             red   += str[2];
             green += str[3];
             green += str[4];
             blue  += str[5];
             blue  += str[6];
         }
         return(new web_color
         {
             red = (byte)Convert.ToInt64(red, 16),
             green = (byte)Convert.ToInt64(green, 16),
             blue = (byte)Convert.ToInt64(blue, 16)
         });
     }
     else if (str.StartsWith("rgb"))
     {
         var s   = str;
         var pos = s.IndexOf("(");
         if (pos != -1)
         {
             s = s.Substring(pos + 1);
         }
         pos = s.IndexOf(")");
         if (pos != -1)
         {
             s = s.Remove(pos, s.Length - pos);
         }
         var tokens = new List <string>();
         html.split_string(s, tokens, ", \t");
         var clr = new web_color();
         if (tokens.Count >= 1)
         {
             clr.red = (byte)(int.TryParse(tokens[0], out var v) ? v : 0);
         }
         if (tokens.Count >= 2)
         {
             clr.green = (byte)(int.TryParse(tokens[1], out var v) ? v : 0);
         }
         if (tokens.Count >= 3)
         {
             clr.blue = (byte)(int.TryParse(tokens[2], out var v) ? v : 0);
         }
         if (tokens.Count >= 4)
         {
             clr.alpha = (byte)((double.TryParse(tokens[3], out var v) ? v : 0.0) * 255.0);
         }
         return(clr);
     }
     else
     {
         var rgb = resolve_name(str, callback);
         if (!string.IsNullOrEmpty(rgb))
         {
             return(from_string(rgb, callback));
         }
     }
     return(new web_color(0, 0, 0));
 }
Exemplo n.º 6
0
 public el_omnibox(document doc, Control parent, Icontainer container) : base(doc)
 {
     Parent = parent;
     Parent.Controls.Add(_edit);
     _edit.KeyPress += _edit_KeyPress;
 }
Exemplo n.º 7
0
 public document(Icontainer container, Iscript script, context ctx)
 {
     _container = container;
     _script    = script;
     _context   = ctx;
 }
Exemplo n.º 8
0
 public static document createFromString(string str, Icontainer container, Iscript script, context ctx, css user_styles = null) => createFromUTF8(Encoding.UTF8.GetString(Encoding.Default.GetBytes(str)), container, script, ctx, user_styles);
Exemplo n.º 9
0
 public document(Icontainer container, script_engine script, context ctx) : base()
 {
     _container = container;
     _script    = script;
     _context   = ctx;
 }