private void SetScreen(Screen screen, bool put) { if (_loadingScreen != null && _loadingScreen.IsOnLoadComplete()) { return; } try { lock (this) { if (screen == null) { this.isInstance = false; throw new LSysException("Cannot create a [Screen] instance !"); } //screen.SetOnLoadState(false); if (_currentScreen == null) { _currentScreen = screen; } else { KillScreen(screen); } this.isInstance = true; screen.OnCreate(LSystem.viewSize.GetWidth(), LSystem.viewSize.GetHeight()); RealtimeProcess process = new RealtimeProcessImpl(this, screen); process.SetProcessType(GameProcessType.Initialize); process.SetDelay(0); RealtimeProcessManager.Get().AddProcess(process); if (put) { _screens.Add(screen); } _loadingScreen = null; } } catch (System.Exception cause) { LSystem.Error("Update Screen failed: " + screen, cause); } }
internal virtual void Call(Level level, string msg, System.Exception e) { if (LSystem.IsConsoleLog()) { if (collector != null) { collector.Logged(level, msg, e); } if (level.id >= minLevel.id) { CallNativeLog(level, msg, e); LGame game = LSystem.Base; if (game != null) { LSetting setting = game.setting; // 待实现GLEx /* LProcess process = LSystem.GetProcess(); * if (process != null && (setting.isDebug || setting.isDisplayLog)) * { * LColor color = LColor.white; * if (level.id > Level.INFO.id) * { * color = LColor.red; * } * if (process != null) * { * if (e == null) * { * process.addLog(msg, color); * } * else * { * process.addLog(msg + " [ " + e.getMessage() + " ] ", color); * } * } */ } } } if (e != null) { OnError(e); } }
protected internal virtual void ViewportChanged(Scale scale, int viewWidth, int viewHeight) { Display d = game.Display(); LSystem.viewSize.SetSize((int)(viewWidth / LSystem.GetScaleWidth()), (int)(viewHeight / LSystem.GetScaleHeight())); if (viewMatrix != null) { LSystem.viewSize.GetMatrix().Mul(viewMatrix); } this.scale = scale; this.viewPixelWidth = viewWidth; this.viewPixelHeight = viewHeight; this.viewSizeM.width = game.setting.Scaling() ? LSystem.InvXScaled(viewPixelWidth) : scale.InvScaled(viewPixelWidth); this.viewSizeM.height = game.setting.Scaling() ? LSystem.InvXScaled(viewPixelHeight) : scale.InvScaled(viewPixelHeight); if (d != null) { d.Resize(LSystem.viewSize.GetWidth(), LSystem.viewSize.GetHeight()); } }
internal void Update(LTimerContext c) { try { switch (type) { case DRAW_USER: /*DrawListener<Screen> drawing = screen._drawListener; * if (drawing != null) * { * drawing.update(c.timeSinceLastUpdate); * }*/ screen.Alter(c); break; case DRAW_SPRITE: /*screen.spriteRun = (screen.sprites != null && screen.sprites.size() > 0); * if (screen.spriteRun) * { * screen.sprites.update(c.timeSinceLastUpdate); * }*/ break; case DRAW_DESKTOP: /* screen.desktopRun = (screen.desktop != null && screen.desktop.size() > 0); * if (screen.desktopRun) * { * screen.desktop.update(c.timeSinceLastUpdate); * }*/ break; case DRAW_EMPTY: default: break; } } catch (System.Exception cause) { LSystem.Error("Screen update() dispatch failure", cause); } }
private void KillScreen(Screen screen) { try { lock (_currentScreen) { if (_currentScreen != null) { _currentScreen.Destroy(); } if (screen == _currentScreen) { screen.Pause(); } screen.Destroy(); _currentScreen = screen; } } catch (System.Exception cause) { LSystem.Error("Destroy screen failure", cause); } }
public Vector2f ConvertXY(float x, float y) { float newX = ((x - GetX()) / (LSystem.GetScaleWidth())); float newY = ((y - GetY()) / (LSystem.GetScaleHeight())); if (isInstance && _currentScreen.IsTxUpdate()) { float oldW = GetWidth(); float oldH = GetHeight(); float newW = GetWidth() * GetScaleX(); float newH = GetHeight() * GetScaleY(); float offX = oldW / 2f - newW / 2f; float offY = oldH / 2f - newH / 2f; float nx = (newX - offX); float ny = (newY - offY); int r = (int)GetRotation(); switch (r) { case -90: offX = oldH / 2f - newW / 2f; offY = oldW / 2f - newH / 2f; nx = (newX - offY); ny = (newY - offX); _tmpLocaltion.Set(nx / GetScaleX(), ny / GetScaleY()).RotateSelf(-90); _tmpLocaltion.Set(-(_tmpLocaltion.x - GetWidth()), MathUtils.Abs(_tmpLocaltion.y)); break; case 0: case 360: _tmpLocaltion.Set(nx / GetScaleX(), ny / GetScaleY()); break; case 90: offX = oldH / 2f - newW / 2f; offY = oldW / 2f - newH / 2f; nx = (newX - offY); ny = (newY - offX); _tmpLocaltion.Set(nx / GetScaleX(), ny / GetScaleY()).RotateSelf(90); _tmpLocaltion.Set(-_tmpLocaltion.x, MathUtils.Abs(_tmpLocaltion.y - GetHeight())); break; case -180: case 180: _tmpLocaltion.Set(nx / GetScaleX(), ny / GetScaleY()).RotateSelf(GetRotation()).AddSelf(GetWidth(), GetHeight()); break; default: // 原则上不处理非水平角度的触点 _tmpLocaltion.Set(newX, newY); break; } } else { _tmpLocaltion.Set(newX, newY); } if (IsFlipX() || IsFlipY()) { HelperUtils.Local2Global(IsFlipX(), IsFlipY(), GetWidth() / 2, GetHeight() / 2, _tmpLocaltion.x, _tmpLocaltion.y, _tmpLocaltion); return(_tmpLocaltion); } return(_tmpLocaltion); }
public override float Yscale() { return(_graphics.game.setting.Scaling() ? LSystem.GetScaleHeight() : _graphics.scale.factor); }
public static float InvYScaled(float length) { return(length / LSystem.GetScaleWidth()); }