Esempio n. 1
0
 public static PackageItem GetItemByURL(string url)
 {
     if (UtilsStr.StartsWith(url, "ui://"))
     {
         string    pkgId = url.Substring(5, 8);
         string    srcId = url.Substring(13);
         UIPackage pkg   = GetById(pkgId);
         if (pkg != null)
         {
             return(pkg.GetItem(srcId));
         }
     }
     return(null);
 }
Esempio n. 2
0
        protected void LoadContent()
        {
            ClearContent();

            if (_url == null || _url == "")
            {
                return;
            }

            if (UtilsStr.StartsWith(_url, "ui://"))
            {
                string pkgId  = _url.Substring(5, 8);
                string itemid = _url.Substring(13);
                _contentItem = UIPackage.GetItemByURL(_url);
                bool error = false;
                if (_contentItem != null)
                {
                    _contentType         = _contentItem.type;
                    _contentSourceWidth  = _contentItem.width;
                    _contentSourceHeight = _contentItem.height;

                    if (_contentType == "jta")
                    {
                        LoadJtaContent();
                    }
                    else if (_contentType == "sound")
                    {
                        byte[] ba = _contentItem.owner.GetResRawDataById(_contentItem.id);
                        if (ba != null)
                        {
                            //_sound = new SoundExt(ba);
                            //setContent(_sound);
                        }
                        else
                        {
                            error = true;
                        }
                    }
                    else if (_contentItem.imageData != null)
                    {
                        __uiResLoaded(_contentItem.imageData);
                    }
                    else
                    {
                        _contentItem.owner.AddItemCallback(_contentItem, __uiResLoaded);
                        _loading = 2;
                    }
                }
                else
                {
                    error = true;
                }
                if (error)
                {
                    _contentItem = null;
                    SetErrorState();
                }
                return;
            }

            _contentType = UtilsStr.GetFileExt(_url);
            if (_contentType == "png" || _contentType == "jpg")
            {
                _contentType = "image";
            }
            else if (_contentType == "wav" || _contentType == "mp3")
            {
                _contentType = "sound";
            }

            if (_contentType == "jta")
            {
                //    loadJtaContent();
            }
            else if (_contentType == "sound")
            {
                //    _sound = new SoundExt(_url);
                //    setContent(_sound);
            }
            else
            {
                if (_loader == null)
                {
                    _loader = new Loader();
                    _loader.AddEventListenerObsolete(EventContext.COMPLETE, __etcLoaded);
                    _loader.AddEventListenerObsolete(EventContext.ERROR, __etcLoadFailed);
                }
                _loader.load(_url);
                _loading = 1;
            }
        }