Exemplo n.º 1
0
        public static Task PreloadContent(ContentManager content)
        {
            if (_contentLoad != null)
            {
                return(_contentLoad);
            }

            return(_contentLoad = Task.Factory.StartNew(delegate
            {
                if (_scriptEntityFactory == null)
                {
                    _scriptEntityFactory = new ScriptEntityFactory(content);

                    var preloadEntities = _scriptEntityFactory.AvailableEntities(content)
                                          .Select(s =>
                    {
                        try
                        {
                            return _scriptEntityFactory.LoadEntity(content, s, new Vector2(0, 0));
                        }
                        catch (Exception ex)
                        {
                            Log.Error(Tag, ex);
                            return null;
                        }
                    })
                                          .ToList();
                }
            }));
        }
Exemplo n.º 2
0
        private void mWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            ScriptEntitys.Clear();

            string            scriptTypes = "script|warp|shop|cashshop|monster|boss_monster|mapflag";
            Regex             regexEntity = new Regex("^(.+)\t(" + scriptTypes + ")\t(.+)\t([^{\n]*){?", RegexOptions.Multiline | RegexOptions.CultureInvariant | RegexOptions.Compiled);
            MatchCollection   matches     = regexEntity.Matches(mText);
            int               matchCount  = matches.Count;
            List <FoldMarker> newFoldings = new List <FoldMarker>();

            foreach (Match match in matches)
            {
                string matchString = match.Groups[0].Captures[0].Value.TrimEnd();                 // trim possible \r
                string w1          = match.Groups[1].Captures[0].Value;
                string w2          = match.Groups[2].Captures[0].Value;
                string w3          = match.Groups[3].Captures[0].Value;
                string w4          = match.Groups[4].Captures[0].Value;
                int    offsetStart = match.Index;
                int    offsetEnd   = 0;
                string safeW2      = w2.ToLower().Trim();
                if (safeW2 == "monster" || safeW2 == "boss_monster" || safeW2 == "shop" || safeW2 == "cashshop")
                {
                    offsetEnd = match.Index + matchString.Length;
                }
                else
                {
                    // Search closing bracket
                    offsetEnd = GetBodyEnd(match.Index + matchString.Length);
                    // Add folding
                    newFoldings.Add(new FoldMarker(Editor.Document, offsetStart + match.Length - 1, (offsetEnd - offsetStart - match.Length + 1), "...", false));
                }

                ScriptEntity en = ScriptEntityFactory.CreateEntity(w1, w2, w3, w4, offsetStart, offsetEnd);
                ScriptEntitys.Add(en);
            }

            matches = null;
            mText   = null;

            Editor.Document.FoldingManager.UpdateFoldings(newFoldings);
        }