Example #1
0
 /// <summary>
 ///     Shows the Login Screen to a new User Session
 /// </summary>
 /// <param name="session"></param>
 private void WelcomeScreenDisplay(SessionBase session)
 {
     EchoToClient(session, new byte[] { 0x1B, 0x5B, 0x32, 0x4A });
     EchoToClient(session, new byte[] { 0x1B, 0x5B, 0x48 });
     EchoToClient(session, _resourceManager.GetResource("MBBSEmu.Assets.login.ans").ToArray());
     EchoToClient(session, Encoding.ASCII.GetBytes("\r\n "));
     session.SessionState = EnumSessionState.LoginUsernameDisplay;
 }
Example #2
0
        /// <summary>
        ///     Shows the Login Screen to a new User Session
        /// </summary>
        /// <param name="session"></param>
        private void WelcomeScreenDisplay(SessionBase session)
        {
            EchoToClient(session, new byte[] { 0x1B, 0x5B, 0x32, 0x4A });
            EchoToClient(session, new byte[] { 0x1B, 0x5B, 0x48 });
            //Load File if specified in appsettings.json and display if it exists, else display default
            var ansiLoginFileName = _configuration.ANSILogin;

            EchoToClient(session,
                         File.Exists(ansiLoginFileName)
                    ? File.ReadAllBytes(ansiLoginFileName).ToArray()
                    : _resourceManager.GetResource("MBBSEmu.Assets.login.ans").ToArray());
            EchoToClient(session, Encoding.ASCII.GetBytes("\r\n "));
            session.SessionState = EnumSessionState.LoginUsernameDisplay;
        }
Example #3
0
        /// <summary>
        ///     Shows the Login Screen to a new User Session
        /// </summary>
        /// <param name="session"></param>
        private void WelcomeScreenDisplay(SessionBase session)
        {
            session.SendToClient(ANSI_ERASE_DISPLAY);
            session.SendToClient(ANSI_RESET_CURSOR);
            //Load File if specified in appsettings.json and display if it exists, else display default
            var ansiLoginFileName = _configuration.ANSILogin;

            session.SendToClient(
                File.Exists(ansiLoginFileName)
                    ? File.ReadAllBytes(ansiLoginFileName).ToArray()
                    : _resourceManager.GetResource("MBBSEmu.Assets.login.ans").ToArray());
            session.SendToClient(Encoding.ASCII.GetBytes("\r\n "));
            session.SessionState = EnumSessionState.LoginUsernameDisplay;
        }
Example #4
0
 private void CopyFilesToTempPath(IResourceManager resourceManager)
 {
     foreach (var file in _btrieveFiles)
     {
         File.WriteAllBytes(Path.Combine(_modulePath, file), resourceManager.GetResource($"MBBSEmu.Tests.Assets.{file}").ToArray());
     }
 }
Example #5
0
        public override Document LoadDocument(DocumentSettings settings, DocumentInfo?sourceInfo, string specifier, DocumentCategory category, DocumentContextCallback contextCallback)
        {
            var alias = ResourceModuleUtils.GetResourceAlias(specifier);

            if (alias is object)
            {
                var resource = _resourceManager.GetResource(alias);

                if (resource is object)
                {
                    var script = _resourceScriptFactory.CreateFromExtension(resource, Path.GetExtension(alias));

                    if (script is object)
                    {
                        return(new StringDocument(new DocumentInfo(specifier)
                        {
                            Category = ModuleCategory.Standard
                        }, script));
                    }
                }
            }

            throw new FileNotFoundException($"The resource {alias} was not found");

            //return _defaultLoader.LoadDocument(settings, sourceInfo, specifier, category, contextCallback);
        }
Example #6
0
 public static string Menu(this IResourceManager resourceManager, string resourceKey)
 {
     return(resourceManager.GetResource(
                Thread.CurrentThread.CurrentUICulture.Name,
                ResourceManagerParameters.MenuKey,
                resourceKey));
 }
Example #7
0
        public GameObject Show(UIMap.Id _viewId)
        {
            Loggr.Log("attempt to instantiate: " + _viewId.ToString());

            if (resourceManager == null)
            {
                Debug.Log("NULLLLL");
            }

            if (uiElements.ContainsKey(_viewId))
            {
                Loggr.Log("already exist: " + _viewId.ToString());
                return(uiElements[_viewId]);
            }

            var resourcePath = UIMap.GetPath(_viewId);
            var view         = resourceManager.GetResource <GameObject>(resourcePath);

            var instance = GameObject.Instantiate(view as GameObject) as GameObject;

            instance.transform.SetParent(container.transform);
            instance.transform.localPosition = Vector3.zero;

            localeService.SetAllTexts(instance.gameObject);

            uiElements[_viewId] = instance;

            return(instance);
        }
Example #8
0
        public void GetInstance(IResourceManager resourceManager)
        {
            var resource = resourceManager.GetResource();

            Console.WriteLine(resource.Display());

            Console.ReadLine();
        }
Example #9
0
        public void onInit()
        {
            services = (SCSServices)Game.Services.GetService(typeof(SCSServices));
            resourceManager = (IResourceManager)Game.Services.GetService(typeof(IResourceManager));

            controller = new Controller(Game);
            controller.onInit();

            btnSpace = new Button(Game, services.SpriteBatch, resourceManager.GetResource<Texture2D>(Shared.Resources.ctrlButtonSpace), resourceManager.GetResource<Texture2D>(Shared.Resources.ctrlButtonSpace));
            btnSpace.Canvas.Bound.Position = new Vector2(622, 392);
            btnSpace.FitSizeByImage();

            controller.OnLeftFreeTap += new ControlEventHandler(btnUp_OnLeftFreeTap);
            controller.OnRightFreeTap += new ControlEventHandler(controller_OnRightFreeTap);
            controller.OnUpFreeTap += new ControlEventHandler(controller_OnUpFreeTap);
            controller.OnDownFreeTap += new ControlEventHandler(controller_OnDownFreeTap);

            btnSpace.OnPressed += new ButtonEventHandler(btnSpace_onClick);

            dispatcher.AddTarget(controller);

            controlManager.Add(btnSpace);
        }
Example #10
0
        public string GetSql(string key)
        {
            if (string.IsNullOrWhiteSpace(key))
            {
                throw new ArgumentNullException(nameof(key));
            }

            lock (sqlDict)
            {
                if (sqlDict.ContainsKey(key))
                {
                    return(sqlDict[key]);
                }
            }

            var subSqlName = GetSubSqlName(key);

            var file = CalcSqlFileName(key, subSqlName);

            var resource = _resourceManager.GetResource(file);

            var sqlContent = GetSql(resource);

            lock (sqlDict)
            {
                if (resource == null)
                {
                    sqlDict[key] = null;

                    return(null);
                }
                else if (string.IsNullOrWhiteSpace(subSqlName))
                {
                    sqlDict[key] = sqlContent;

                    return(sqlContent);
                }
                else if (Load(key, subSqlName, sqlContent))
                {
                    return(sqlDict[key]);
                }
                else
                {
                    sqlDict[key] = null;

                    return(null);
                }
            }
        }
Example #11
0
        /// <summary>
        /// 必须确保dialog的assetbundle已经缓存在字典后调用
        /// </summary>
        /// <param name="dialogName"></param>
        /// <returns></returns>
        private UIWindow CreateDialog(string dialogName)
        {
            if (string.IsNullOrEmpty(dialogName))
            {
                return(null);
            }

            var assetBundleName = DialogAssetBundleMap.GetAssetBundleName(dialogName);
            var prefab          = _resource.GetResource <GameObject>(assetBundleName, dialogName);

            if (!prefab)
            {
                return(null);
            }

            return(_dialogFactory.Create(prefab));
        }
Example #12
0
 /// <summary>
 /// Returns a <code>Template</code> from the resource manager
 /// </summary>
 /// <param name="name">The name of the desired template.</param>
 /// <param name="encoding">Character encoding of the template</param>
 /// <returns>The template.</returns>
 /// <exception cref="ResourceNotFoundException">
 /// if template not found from any available source.
 /// </exception>
 /// <exception cref="ParseErrorException">
 /// if template cannot be parsed due to syntax (or other) error.
 /// </exception>
 /// <exception cref="Exception">
 /// if an error occurs in template initialization
 /// </exception>
 public Template GetTemplate(String name, String encoding)
 {
     return((Template)resourceManager.GetResource(name, ResourceType.Template, encoding));
 }
Example #13
0
        private IEnumerator InstantiateWindowCoroutine(UIWindowType windowType, UISwitchTask curTask)
        {
            if (curTask == null)
            {
                yield break;
            }

            if (windowType == UIWindowType.Null)
            {
                yield break;
            }

            if (!NeedInstantiate(windowType))
            {
                yield break;
            }

            var prefabPath = GetPrefabPath(windowType);
            var prefabName = GetPrefabName(windowType);

            if (string.IsNullOrEmpty(prefabPath) || string.IsNullOrEmpty(prefabName))
            {
                yield break;
            }

            _dialogManager.ShowWaitingDialog(true, 10);

            _resource.StartLoadResource(prefabPath, prefabName);

            while (!_resource.HasCached(prefabPath))
            {
                yield return(null);
            }

            var           prefab = _resource.GetResource <GameObject>(prefabPath, prefabName);
            RectTransform target = null;

            switch (windowType)
            {
            case UIWindowType.Game:
                var game = _gameWindowFactory.Create(prefab);
                target = game.GetComponent <RectTransform>();
                break;

            case UIWindowType.LoginMode:
                var loginMode = _loginModeWindowFactory.Create(prefab);
                target = loginMode.GetComponent <RectTransform>();
                break;

            case UIWindowType.Portal:
                var portal = _portalWindowFactory.Create(prefab);
                target = portal.GetComponent <RectTransform>();
                break;

            case UIWindowType.Room:
                var room = _roomWindowFactory.Create(prefab);
                target = room.GetComponent <RectTransform>();
                break;

            case UIWindowType.Seat:
                var seat = _seatWindowFactory.Create(prefab);
                target = seat.GetComponent <RectTransform>();
                break;
            }

            _dialogManager.ShowWaitingDialog(false);

            if (target == null)
            {
                yield break;
            }

            target.SetParent(_gameCanvas.GetWindowParent(), false);
            target.anchoredPosition = BornPosition;

            curTask.ToWindow = target;

            yield return(null);
        }
Example #14
0
 public static string Menu(this IResourceManager resourceManager, string language, string resourceKey)
 {
     return(resourceManager.GetResource(language,
                                        ResourceManagerParameters.MenuKey,
                                        resourceKey));
 }
Example #15
0
        public void Update()
        {
            if (Status != StatusChecking)
            {
                return;
            }

            // 更新WaitingImage:
            if (WaitingImage)
            {
                var tr        = WaitingImage.transform;
                var curAngle  = tr.rotation.eulerAngles.z;
                var destAngle = curAngle - (360f / WaitingRotateTime) * Time.deltaTime;
                if (destAngle < 0)
                {
                    destAngle += 360f;
                }
                tr.rotation = Quaternion.Euler(0, 0, destAngle);
            }

            // 检查图片是否已经存在。
            if (!ContentImage)
            {
                return;
            }

            if (Time.time - LastCheckTime < _checkInterval)
            {
                return;
            }

            LastCheckTime = Time.time;

            Sprite sprite;

            if (_downLoadByUrl)
            {
                sprite = _resourceCache.LoadSpriteFromLocalFile(PicName);
            }
            else
            {
                if (string.IsNullOrEmpty(ResourcePath))
                {
                    MyLog.ErrorWithFrame(name, "从图片名找不到Assetbundle :" + PicName);
                    return;
                }

                sprite = _resource.GetResource <Sprite>(ResourcePath, PicName);
                if (sprite)
                {
                    _resourceCache.AddSpriteToCache(PicName, sprite);
                }
            }

            if (sprite)
            {
                ContentImage.sprite = sprite;
                if (NativeSize)
                {
                    ContentImage.SetNativeSize();
                }

                SwitchToStatus(StatusComplete);
            }
        }