Ejemplo n.º 1
0
        public void Loop()
        {
            _unprocessedTime = 0;
            _updates         = 0;

            if (EnableRender)
            {
                _renderer.Initialize();
            }

            OnInit.Raise(this, null);

            // TODO: Need a way to break the loop from outside.
            while (IsApplicationIdle())
            {
                LimitFramerate();

                SimulateFrame();
            }
            // TODO: Probably clean up when loop is broken.
        }
Ejemplo n.º 2
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            base.OnAfterRender(firstRender);

            if (firstRender)
            {
                if (OnInit == null)
                {
                    throw new InvalidOperationException("OnInit paramenter must be set");
                }

                if (Interop == null)
                {
                    Interop = new JSInterop <Chart>(JSRuntime);
                }

                var ds = await OnInit.Invoke();

                await Interop.Invoke(this, ChartElement, "chart", nameof(Completed), ds, "", ChartType.ToDescriptionString());
            }
        }
        protected override async Task OnInitializedAsync()
        {
            Parent?.Controls.Add(this);

            if (OnInit.HasDelegate)
            {
                await OnInit.InvokeAsync(EventArgs.Empty);
            }

            await base.OnInitializedAsync();

            if (OnLoad.HasDelegate)
            {
                await OnLoad.InvokeAsync(EventArgs.Empty);
            }

            if (OnPreRender.HasDelegate)
            {
                await OnPreRender.InvokeAsync(EventArgs.Empty);
            }
        }
Ejemplo n.º 4
0
        public void Init(ShelfObject parent)
        {
            Creator = parent;
            OnInit?.Invoke();
            TimeManager.RegisterObject(this);

            foreach (var mf in GetComponentsInChildren <MeshFilter>())
            {
                mf.mesh = mf.sharedMesh;
            }

            foreach (var child in GetComponentsInChildren <Animatable>())
            {
                if (child.GetInstanceID() == GetInstanceID())
                {
                    continue;
                }

                child.Init(null);
            }
        }
Ejemplo n.º 5
0
        protected override void OnWidgetEvent(WidgetEventArgs e)
        {
            switch (e.Type)
            {
            case "key":
                lock (this)
                {
                    if (e.Data == "\r")
                    {
                        string cmd = sb.ToString();
                        sb.Clear();
                        OnLineFeed?.Invoke(this, cmd);
                    }
                    else if (e.Data == "\u007f")
                    {
                        if (sb.Length > 0)
                        {
                            sb.Remove(sb.Length - 1, 1);
                        }
                    }
                    else
                    {
                        sb.Append(e.Data);
                    }
                }
                break;

            case "init":
            {
                OnInit?.Invoke(this, EventArgs.Empty);
            }
            break;
            }

            base.OnWidgetEvent(e);
        }
Ejemplo n.º 6
0
 public void Init()
 {
     OnInit?.Invoke();
 }
Ejemplo n.º 7
0
 protected void InvokeOnInit()
 {
     OnInit?.Invoke();
 }
Ejemplo n.º 8
0
 internal void _OnInit()
 {
     OnInit?.Invoke(this);
     Utils.Call("self.EventStarted = False");
 }
Ejemplo n.º 9
0
        public static void Run(string title, int width, int height, ErrorHandler errorHandler)
        {
            App.errorHandler = errorHandler;

            if (errorHandler != null)
            {
                try { Run(); }
                catch (Exception e) { errorHandler(e); }
            }
            else
            {
                Run();
            }

            void Run()
            {
                if (platform == null)
                {
                    throw new Exception("App has not been initialized.");
                }
                if (Running)
                {
                    throw new Exception("App is already running.");
                }

                Running = true;
                platform.Init(title, width, height);
                platform.CenterWindow();

                platform.OnQuit           += Quit;
                platform.OnWinClose       += Quit;
                platform.OnWinFocusGained += () => Focused = true;
                platform.OnWinFocusLost   += () => Focused = false;

                GL.Init();
                Time.Init(1f / 60f);
                Screen.Init();
                Mouse.Init();
                Keyboard.Init();
                Joystick.Init();

                OnInit?.Invoke();

                double prevTime   = platform.GetTime();
                double frameTimer = 0.0;

                while (Running)
                {
                    platform.PollEvents();

                    if (!Focused && !UpdateWhileFocused)
                    {
                        prevTime = (float)platform.GetTime();
                        continue;
                    }

                    if (Running)
                    {
                        double currTime  = platform.GetTime();
                        double deltaTime = currTime - prevTime;
                        if (deltaTime > 0.0)
                        {
                            FPS = (int)(1.0 / (currTime - prevTime));
                        }
                        prevTime = currTime;

                        if (FixedFramerate)
                        {
                            if (!Screen.VSync)
                            {
                                frameTimer += deltaTime;
                                while (frameTimer >= frameDuration)
                                {
                                    frameTimer -= frameDuration;
                                    Update(frameDuration);
                                }
                            }
                            else
                            {
                                Update(frameDuration);
                            }
                        }
                        else
                        {
                            Update(deltaTime);
                        }

                        void Update(double dt)
                        {
                            Time.PreUpdate((float)dt);
                            Mouse.PreUpdate();

                            OnUpdate?.Invoke();

                            Mouse.PostUpdate();
                            Keyboard.PostUpdate();
                            Joystick.PostUpdate();

                            Texture.UnbindAll();

                            DrawCall.Begin();
                            OnRender?.Invoke();
                            DrawCall.End();

                            platform.SwapBuffers();
                        }
                    }
                }

                OnQuit?.Invoke();

                platform.Quit();
            }
        }
Ejemplo n.º 10
0
 internal void OnConnectedToQuikCall(int port)
 {
     OnConnectedToQuik?.Invoke(port);
     OnInit?.Invoke(port);
 }
Ejemplo n.º 11
0
 private void Init()
 {
     OnInit?.Invoke();
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 设置应用程序,如在过程中发生异常则重启并提醒!
        /// </summary>
        public static void Init(BootFlag flag, string confPath)
        {
            PrepareCms();
            BeforeInit();
            if (!IsInstalled())
            {
                return;
            }
            //初始化目录
            ChkCreate(CmsVariables.TEMP_PATH);
            // 加载配置
            Configuration.LoadCmsConfig(confPath);
            //设置数据库
            CmsDataBase.Initialize($"{Settings.DB_TYPE}://{Settings.DB_CONN}", Settings.DB_PREFIX, Settings.SQL_PROFILE_TRACE);
            //清空临时文件
            //resetTempFiles();
            // 初始化键值存储
            InitKvDb();
            // 加载其他配置
            LoadOtherConfig();
            //获取静态服务器
            //UpdateServerInfo();
            // 正常模式启动
            if ((flag & BootFlag.Normal) != 0)
            {
                BuildOEM = new BuildOEM();

                //
                //TODO:
                //
                //检查网站激活状态
                //SoftwareActivator.VerifyActivation();
                //如果不存在模板文件夹,则创建目录
                if (!Directory.Exists(PhysicPath + "templates/"))
                {
                    Directory.CreateDirectory(PhysicPath + "templates/").Create();
                    //暂时网络安装默认模板(后可使用资源代替)
                    Updater.InstallTemplate("default", "tpl_default.zip");
                }

                _templateManager = new TemplateManager(PhysicPath + CmsVariables.TEMPLATE_PATH);

                // 注册模板
                Template.Register("/" + CmsVariables.TEMPLATE_PATH, true);
                // 注册插件
                //PluginConfig.PLUGIN_FILE_PARTTERN = "*.dll,*.so";
                PluginConfig.PLUGIN_DIRECTORY         = CmsVariables.PLUGIN_PATH;
                PluginConfig.PLUGIN_TMP_DIRECTORY     = CmsVariables.TEMP_PATH + "plugin/";
                PluginConfig.PLUGIN_LOG_OPENED        = true;
                PluginConfig.PLUGIN_LOG_EXCEPT_FORMAT =
                    "** {time} **:{message}\r\nSource:{source}\r\nAddress:{addr}\r\nStack:{stack}\r\n\r\n";
                var pluginPhysicPath = PhysicPath + PluginConfig.PLUGIN_TMP_DIRECTORY;
                if (!Directory.Exists(pluginPhysicPath))
                {
                    Directory.CreateDirectory(pluginPhysicPath).Create();
                }
                // 连接插件
                //todo: plugin
                //CmsPluginContext.Connect();

                // 设置验证码字体
                VerifyCodeGenerator.SetFontFamily(PhysicPath + CmsVariables.FRAMEWORK_ASSETS_PATH + "fonts/comic.ttf");
            }

            OnInit?.Invoke();

            IsInitFinish = true;
        }
Ejemplo n.º 13
0
 public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
 {
     IAPManager.controller = controller;
     IAPManager.extensions = extensions;
     OnInit?.Invoke();
 }
Ejemplo n.º 14
0
 private void Start()
 {
     OnInit?.Invoke();
 }
Ejemplo n.º 15
0
 public override void Init()
 {
     OnInit?.Invoke(Manager);
 }
 protected virtual void Init()
 {
     OnInit?.Invoke(RendWind);
 }
Ejemplo n.º 17
0
 protected override void Start()
 {
     OnInit?.Invoke();
 }
Ejemplo n.º 18
0
 protected override void Start()
 {
     OnInit?.Invoke();
     InvokeRepeating(nameof(UpdateTarget), 0, 0.5f);
     base.Start();
 }
Ejemplo n.º 19
0
 internal void StartInitEvent()
 {
     OnInit?.Invoke();
 }
Ejemplo n.º 20
0
 protected void InvokeOnInit(bool continued, Direction direction, int seq, int seq2, Player[] players)
 {
     OnInit?.Invoke(continued, direction, seq, seq2, players);
 }
Ejemplo n.º 21
0
 public static void DebugInit(IGenContext map) => OnInit?.Invoke(map);