//解析原生返回数据 public static void ResolverForNativeMsg(string content) { // Debug.Log($"ResolverForNativeMsg::{content}"); NativeMessage nativeMessage = JsonHelper.FromJson <NativeMessage>(content); NativeCallType type = (NativeCallType)nativeMessage.type; switch (type) { case NativeCallType.GetSafeArea: //适配刘海屏 SafeArea safeArea = JsonHelper.FromJson <SafeArea>(nativeMessage.content); NativeManager.Instance.safeArea = safeArea; break; case NativeCallType.AwakeByURL: //URL唤醒 string awakeContent = nativeMessage.content; // Debug.Log($"游戏被唤起,参数为:{awakeContent}"); Game.Hotfix.OnAwakeByURL?.Invoke(awakeContent); break; case NativeCallType.GetGPS: //获取GPS定位 GPSInfo gPSInfo = JsonHelper.FromJson <GPSInfo>(nativeMessage.content); // Debug.Log($"获取GPS信息返回:statue={gPSInfo.status},lan={gPSInfo.latitude},long={gPSInfo.longitude},name={gPSInfo.locationName}"); Game.Hotfix.OnGetGPS?.Invoke(string.Format("{0},{1},{2},{3}", gPSInfo.status, gPSInfo.longitude, gPSInfo.latitude, gPSInfo.locationName)); break; case NativeCallType.TakeHeadImage: //获取头像图片路径 // Debug.Log("ongetHead"); Game.Hotfix.OnGetHeadImagePath?.Invoke(nativeMessage.content); break; case NativeCallType.InAppPurchase: InAppPurchaseInfo purchaseInfo = JsonHelper.FromJson <InAppPurchaseInfo>(nativeMessage.content); Game.Hotfix.OnInAppPurchaseCallBack?.Invoke(string.Format("{0},{1},{2},{3},{4}", purchaseInfo.status, purchaseInfo.productId, purchaseInfo.orderId, purchaseInfo.transactionId, purchaseInfo.receiptData)); break; case NativeCallType.IMMes: Game.Hotfix.OnGroupMes?.Invoke(nativeMessage.content); break; case NativeCallType.IMOpearteMes: Game.Hotfix.OnOpearteMes?.Invoke(nativeMessage.content); break; case NativeCallType.IMServerMes: Game.Hotfix.OnServerMes?.Invoke(nativeMessage.content); break; case NativeCallType.EMULATORINFO: Game.Hotfix.OnEmulatorInfo?.Invoke(nativeMessage.content); break; default: Debug.Log($"error nativeMessage.type {nativeMessage.type} content = {nativeMessage.content}"); break; } }
private void ShowCharacter() { Vector2 deviceScreenSize = SafeArea.GetDeviceScreenSize(); this.characterCameraView = new CharacterCameraView(CMD_CharacterDetailed.DataChg, (int)deviceScreenSize.x, (int)deviceScreenSize.y); this.renderTextureObject.mainTexture = this.characterCameraView.renderTex; }
private void LoadDeviceInfo() { this.deviceScreenSize = SafeArea.GetDeviceScreenSize(); this.safeAreaSize = SafeArea.GetSafeArea(); this.margin.left = Mathf.CeilToInt(this.safeAreaSize.x); this.margin.right = Mathf.CeilToInt(this.deviceScreenSize.x - (this.safeAreaSize.x + this.safeAreaSize.width)); this.margin.bottom = Mathf.CeilToInt(this.safeAreaSize.y); this.margin.top = Mathf.CeilToInt(this.deviceScreenSize.y - (this.safeAreaSize.y + this.safeAreaSize.height)); }
public static void InitSafeArea(Transform canvasTransform) { _safeArea = new SafeArea { topOffset = (Screen.height - Screen.safeArea.yMax) / canvasTransform.localScale.y, bottomOffset = Screen.safeArea.yMin / canvasTransform.localScale.y, leftOffset = Screen.safeArea.xMin / canvasTransform.localScale.x, rightOffset = (Screen.width - Screen.safeArea.xMax) / canvasTransform.localScale.x }; }
protected float getVerticalOffset(SafeArea safeArea) { RectOffset safeAreaOffset = safeAreaService.GetSafeAreaOffset(); switch (safeArea) { case SafeArea.Top: return safeAreaOffset.top; case SafeArea.Bottom: return safeAreaOffset.bottom; default: return 0f; } }
static void OnDrawGizmo(SafeArea safeArea, GizmoType gizmoType) { var canvas = safeArea.GetComponentInParent <Canvas>(); if (canvas == null || canvas.rootCanvas.renderMode == RenderMode.WorldSpace) { return; } var safeAreaRectTransform = safeArea.GetComponent <RectTransform>(); if ((gizmoType & GizmoType.InSelectionHierarchy) > 0 || Selection.activeTransform != null && Selection.activeTransform.IsChildOf(safeAreaRectTransform)) { DrawGizmo(safeAreaRectTransform); } }
public CharacterCameraView(MonsterData monsterData) : this(monsterData, (int)SafeArea.GetDeviceScreenSize().x, (int)SafeArea.GetDeviceScreenSize().y) { }
public override Widget build(BuildContext context) { D.assert(MaterialD.debugCheckHasMaterialLocalizations(context)); ThemeData themeData = Theme.of(context); ScaffoldState scaffold = Scaffold.of(context, nullOk: true); ModalRoute parentRoute = ModalRoute.of(context); bool hasDrawer = scaffold?.hasDrawer ?? false; bool hasEndDrawer = scaffold?.hasEndDrawer ?? false; bool canPop = parentRoute?.canPop ?? false; bool useCloseButton = parentRoute is PageRoute && ((PageRoute)parentRoute).fullscreenDialog; IconThemeData appBarIconTheme = this.widget.iconTheme ?? themeData.primaryIconTheme; TextStyle centerStyle = this.widget.textTheme?.title ?? themeData.primaryTextTheme.title; TextStyle sideStyle = this.widget.textTheme?.body1 ?? themeData.primaryTextTheme.body1; if (this.widget.toolbarOpacity != 1.0f) { float opacity = new Interval(0.25f, 1.0f, curve: Curves.fastOutSlowIn).transform(this.widget.toolbarOpacity); if (centerStyle?.color != null) { centerStyle = centerStyle.copyWith(color: centerStyle.color.withOpacity(opacity)); } if (sideStyle?.color != null) { sideStyle = sideStyle.copyWith(color: sideStyle.color.withOpacity(opacity)); } appBarIconTheme = appBarIconTheme.copyWith( opacity: opacity * (appBarIconTheme.opacity ?? 1.0f) ); } Widget leading = this.widget.leading; if (leading == null && this.widget.automaticallyImplyLeading) { if (hasDrawer) { leading = new IconButton( icon: new Icon(Icons.menu), onPressed: this._handleDrawerButton, tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip); } else { if (canPop) { leading = useCloseButton ? (Widget) new CloseButton() : new BackButton(); } } } if (leading != null) { leading = new ConstrainedBox( constraints: BoxConstraints.tightFor(width: AppBarUtils._kLeadingWidth), child: leading); } Widget title = this.widget.title; if (title != null) { title = new DefaultTextStyle( style: centerStyle, softWrap: false, overflow: TextOverflow.ellipsis, child: title); } Widget actions = null; if (this.widget.actions != null && this.widget.actions.isNotEmpty()) { actions = new Row( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: this.widget.actions); } else if (hasEndDrawer) { actions = new IconButton( icon: new Icon(Icons.menu), onPressed: this._handleDrawerButtonEnd, tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip); } Widget toolbar = new NavigationToolbar( leading: leading, middle: title, trailing: actions, centerMiddle: this.widget._getEffectiveCenterTitle(themeData).Value, middleSpacing: this.widget.titleSpacing); Widget appBar = new ClipRect( child: new CustomSingleChildLayout( layoutDelegate: new _ToolbarContainerLayout(), child: IconTheme.merge( data: appBarIconTheme, child: new DefaultTextStyle( style: sideStyle, child: toolbar) ) ) ); if (this.widget.bottom != null) { appBar = new Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: new List <Widget> { new Flexible( child: new ConstrainedBox( constraints: new BoxConstraints(maxHeight: Constants.kToolbarHeight), child: appBar ) ), this.widget.bottomOpacity == 1.0f ? (Widget)this.widget.bottom : new Opacity( opacity: new Interval(0.25f, 1.0f, curve: Curves.fastOutSlowIn).transform(this.widget .bottomOpacity), child: this.widget.bottom ) } ); } if (this.widget.primary) { appBar = new SafeArea( top: true, child: appBar); } appBar = new Align( alignment: Alignment.topCenter, child: appBar); if (this.widget.flexibleSpace != null) { appBar = new Stack( fit: StackFit.passthrough, children: new List <Widget> { this.widget.flexibleSpace, appBar } ); } Brightness brightness = this.widget.brightness ?? themeData.primaryColorBrightness; SystemUiOverlayStyle overlayStyle = brightness == Brightness.dark ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark; return(new AnnotatedRegion <SystemUiOverlayStyle>( value: overlayStyle, child: new Material( color: this.widget.backgroundColor ?? themeData.primaryColor, elevation: this.widget.elevation, child: appBar ))); }
public static void SetSafeArea(BindableObject view, SafeArea value) => view.SetValue(SafeAreaProperty, value);
public override Widget build(BuildContext context) { MediaQueryData mediaQueryData = MediaQuery.of(context); D.assert(widget.animation != null); ThemeData theme = Theme.of(context); ColorScheme colorScheme = theme.colorScheme; SnackBarThemeData snackBarTheme = theme.snackBarTheme; bool isThemeDark = theme.brightness == Brightness.dark; Brightness brightness = isThemeDark ? Brightness.light : Brightness.dark; Color themeBackgroundColor = isThemeDark ? colorScheme.onSurface : Color.alphaBlend(colorScheme.onSurface.withOpacity(0.80f), colorScheme.surface); ThemeData inverseTheme = new ThemeData( brightness: brightness, backgroundColor: themeBackgroundColor, colorScheme: new ColorScheme( primary: colorScheme.onPrimary, primaryVariant: colorScheme.onPrimary, secondary: isThemeDark ? colorScheme.primaryVariant : colorScheme.secondary, secondaryVariant: colorScheme.onSecondary, surface: colorScheme.onSurface, background: themeBackgroundColor, error: colorScheme.onError, onPrimary: colorScheme.primary, onSecondary: colorScheme.secondary, onSurface: colorScheme.surface, onBackground: colorScheme.background, onError: colorScheme.error, brightness: brightness ), snackBarTheme: snackBarTheme ); TextStyle contentTextStyle = snackBarTheme.contentTextStyle ?? inverseTheme.textTheme.subtitle1; SnackBarBehavior snackBarBehavior = widget.behavior ?? snackBarTheme.behavior ?? SnackBarBehavior.fix; bool isFloatingSnackBar = snackBarBehavior == SnackBarBehavior.floating; float snackBarPadding = isFloatingSnackBar ? 16.0f : 24.0f; CurvedAnimation heightAnimation = new CurvedAnimation(parent: widget.animation, curve: SnackBarUtils._snackBarHeightCurve); CurvedAnimation fadeInAnimation = new CurvedAnimation(parent: widget.animation, curve: SnackBarUtils._snackBarFadeInCurve); CurvedAnimation fadeOutAnimation = new CurvedAnimation( parent: widget.animation, curve: SnackBarUtils._snackBarFadeOutCurve, reverseCurve: new Threshold(0.0f) ); var childrenList = new List <Widget>() { new SizedBox(width: snackBarPadding), new Expanded( child: new Container( padding: EdgeInsets.symmetric(vertical: SnackBarUtils._singleLineVerticalPadding), child: new DefaultTextStyle( style: contentTextStyle, child: widget.content ) ) ) }; if (widget.action != null) { childrenList.Add(new ButtonTheme( textTheme: ButtonTextTheme.accent, minWidth: 64.0f, padding: EdgeInsets.symmetric(horizontal: snackBarPadding), child: widget.action )); } else { childrenList.Add(new SizedBox(width: snackBarPadding)); } Widget snackBar = new SafeArea( top: false, bottom: !isFloatingSnackBar, child: new Row( crossAxisAlignment: CrossAxisAlignment.center, children: childrenList ) ); float elevation = widget.elevation ?? snackBarTheme.elevation ?? 6.0f; Color backgroundColor = widget.backgroundColor ?? snackBarTheme.backgroundColor ?? inverseTheme.backgroundColor; ShapeBorder shape = widget.shape ?? snackBarTheme.shape ?? (isFloatingSnackBar ? new RoundedRectangleBorder(borderRadius: BorderRadius.circular(4.0f)) : null); snackBar = new Material( shape: shape, elevation: elevation, color: backgroundColor, child: new Theme( data: inverseTheme, child: mediaQueryData.accessibleNavigation ? snackBar : new FadeTransition( opacity: fadeOutAnimation, child: snackBar ) ) ); if (isFloatingSnackBar) { snackBar = new Padding( padding: EdgeInsets.fromLTRB(15.0f, 5.0f, 15.0f, 10.0f), child: snackBar ); } snackBar = new Dismissible( key: Key.key("dismissible"), direction: DismissDirection.down, resizeDuration: null, onDismissed: (DismissDirection? direction) => { Scaffold.of(context).removeCurrentSnackBar(reason: SnackBarClosedReason.swipe); }, child: snackBar ); Widget snackBarTransition = null; if (mediaQueryData.accessibleNavigation) { snackBarTransition = snackBar; } else if (isFloatingSnackBar) { snackBarTransition = new FadeTransition( opacity: fadeInAnimation, child: snackBar ); } else { snackBarTransition = new AnimatedBuilder( animation: heightAnimation, builder: (BuildContext subContext, Widget subChild) => { return(new Align( alignment: AlignmentDirectional.topStart, heightFactor: heightAnimation.value, child: subChild )); }, child: snackBar ); } return(new ClipRect(child: snackBarTransition)); }
public override Widget build(BuildContext context) { MediaQueryData mediaQueryData = MediaQuery.of(context); D.assert(this.animation != null); ThemeData theme = Theme.of(context); ThemeData darkTheme = new ThemeData( brightness: Brightness.dark, accentColor: theme.accentColor, accentColorBrightness: theme.accentColorBrightness ); List <Widget> children = new List <Widget> { new SizedBox(width: SnackBarUtils._kSnackBarPadding), new Expanded( child: new Container( padding: EdgeInsets.symmetric(vertical: SnackBarUtils._kSingleLineVerticalPadding), child: new DefaultTextStyle( style: darkTheme.textTheme.subhead, child: this.content) ) ) }; if (this.action != null) { children.Add(ButtonTheme.bar( padding: EdgeInsets.symmetric(horizontal: SnackBarUtils._kSnackBarPadding), textTheme: ButtonTextTheme.accent, child: this.action )); } else { children.Add(new SizedBox(width: SnackBarUtils._kSnackBarPadding)); } CurvedAnimation heightAnimation = new CurvedAnimation(parent: this.animation, curve: SnackBarUtils._snackBarHeightCurve); CurvedAnimation fadeAnimation = new CurvedAnimation(parent: this.animation, curve: SnackBarUtils._snackBarFadeCurve, reverseCurve: new Threshold(0.0f)); Widget snackbar = new SafeArea( top: false, child: new Row( children: children, crossAxisAlignment: CrossAxisAlignment.center ) ); snackbar = new Dismissible( key: Key.key("dismissible"), direction: DismissDirection.down, resizeDuration: null, onDismissed: (DismissDirection? direction) => { Scaffold.of(context).removeCurrentSnackBar(reason: SnackBarClosedReason.swipe); }, child: new Material( elevation: 6.0f, color: this.backgroundColor ?? SnackBarUtils._kSnackBackground, child: new Theme( data: darkTheme, child: mediaQueryData.accessibleNavigation ? snackbar : new FadeTransition( opacity: fadeAnimation, child: snackbar ) ) ) ); return(new ClipRect( child: mediaQueryData.accessibleNavigation ? snackbar : new AnimatedBuilder( animation: heightAnimation, builder: (BuildContext subContext, Widget child) => { return new Align( alignment: Alignment.topLeft, heightFactor: heightAnimation.value, child: child ); }, child: snackbar ) )); }
public static bool IsDisengageNeeded() { if (!Me.IsAlive || Me.IsFalling || Me.IsCasting) { return(false); } if (Me.Stunned || Me.Rooted || Me.IsStunned() || Me.IsRooted()) { return(false); } if (NextDisengageAllowed > DateTime.Now) { return(false); } useRocketJump = false; if (!SpellManager.CanCast("Disengage", Me, false, false)) { if (!SingularSettings.Instance.UseRacials || Me.Race != WoWRace.Goblin || !SpellManager.CanCast("Rocket Jump", Me, false, false)) { return(false); } useRocketJump = true; } mobToGetAwayFrom = SafeArea.NearestEnemyMobAttackingMe; if (mobToGetAwayFrom == null) { return(false); } if (mobToGetAwayFrom.Distance > mobToGetAwayFrom.MeleeDistance() + 3f) { return(false); } if (Me.Level > (mobToGetAwayFrom.Level + (mobToGetAwayFrom.Elite ? 10 : 5)) && Me.HealthPercent > 20) { return(false); } SafeArea sa = new SafeArea(); sa.MinScanDistance = 16; // average disengage distance on flat ground sa.MaxScanDistance = sa.MinScanDistance; sa.RaysToCheck = 36; sa.LineOfSightMob = Me.CurrentTarget; sa.MobToRunFrom = mobToGetAwayFrom; sa.CheckLineOfSightToSafeLocation = true; sa.CheckSpellLineOfSightToMob = false; safeSpot = sa.FindLocation(); if (safeSpot == WoWPoint.Empty) { Logger.Write(Color.Cyan, "DIS: no safe landing spots found for {0}", useRocketJump ? "Rocket Jump" : "Disengage"); return(false); } Logger.Write(Color.Cyan, "DIS: Attempt safe {0} due to {1} @ {2:F1} yds", useRocketJump ? "Rocket Jump" : "Disengage", mobToGetAwayFrom.Name, mobToGetAwayFrom.Distance); return(true); }
static bool IsChildOfPlayerLocalUI(SafeArea safeArea) { var parent = safeArea.transform.parent; return(parent != null && parent.GetComponent <PlayerLocalUI>() != null); }