protected void RefreshButton(ShopItemListItem itm, ThemeData theme) { if (theme.cost > PlayerData.instance.coins) { itm.buyButton.interactable = false; itm.pricetext.color = Color.red; } else { itm.pricetext.color = Color.black; } if (theme.premiumCost > PlayerData.instance.premium) { itm.buyButton.interactable = false; itm.premiumText.color = Color.red; } else { itm.premiumText.color = Color.black; } if (PlayerData.instance.themes.Contains(theme.themeName)) { itm.buyButton.interactable = false; itm.buyButton.image.sprite = itm.disabledButtonSprite; itm.buyButton.transform.GetChild(0).GetComponent <UnityEngine.UI.Text>().text = "Owned"; } }
private static void UpdateItem( DatabaseItem item, string icon) { var info = (DatabaseInfo)item.Info; if (info.HasPassword) { item.PasswordIcon = ThemeData .GetImageSource("unlock"); } else { item.PasswordIcon = null; } if (!string.IsNullOrEmpty(icon)) { item.UpdatedIcon = ThemeData .GetImageSource(icon); } else { item.UpdatedIcon = null; } }
static ThemeData _buildLightTheme() { Color primaryColor = new Color(0xFF0175c2); Color secondaryColor = new Color(0xFF13B9FD); ColorScheme colorScheme = ColorScheme.light().copyWith( primary: primaryColor, secondary: secondaryColor ); ThemeData baseTheme = ThemeData.light(); return(baseTheme.copyWith( colorScheme: colorScheme, primaryColor: primaryColor, buttonColor: primaryColor, indicatorColor: Colors.white, splashColor: Colors.white24, splashFactory: InkRipple.splashFactory, accentColor: secondaryColor, canvasColor: Colors.white, scaffoldBackgroundColor: Colors.white, backgroundColor: Colors.white, errorColor: new Color(0xFFB00020), buttonTheme: new ButtonThemeData( colorScheme: colorScheme, textTheme: ButtonTextTheme.primary ), textTheme: _buildTextTheme(baseTheme.textTheme), primaryTextTheme: _buildTextTheme(baseTheme.primaryTextTheme), accentTextTheme: _buildTextTheme(baseTheme.accentTextTheme) )); }
static ThemeData _buildDarkTheme() { Color primaryColor = new Color(0xFF0175c2); Color secondaryColor = new Color(0xFF13B9FD); ThemeData baseTheme = ThemeData.dark(); ColorScheme colorScheme = ColorScheme.dark().copyWith( primary: primaryColor, secondary: secondaryColor ); return(baseTheme.copyWith( primaryColor: primaryColor, buttonColor: primaryColor, indicatorColor: Colors.white, accentColor: secondaryColor, canvasColor: new Color(0xFF202124), scaffoldBackgroundColor: new Color(0xFF202124), backgroundColor: new Color(0xFF202124), errorColor: new Color(0xFFB00020), buttonTheme: new ButtonThemeData( colorScheme: colorScheme, textTheme: ButtonTextTheme.primary ), textTheme: _buildTextTheme(baseTheme.textTheme), primaryTextTheme: _buildTextTheme(baseTheme.primaryTextTheme), accentTextTheme: _buildTextTheme(baseTheme.accentTextTheme) )); }
public override Widget build(BuildContext context) { ThemeData theme = Theme.of(context); return(ListView.builder( itemCount: this.suggestions.Count, itemBuilder: (BuildContext _context, int i) => { string suggestion = this.suggestions[i]; return new ListTile( leading: this.query.isEmpty() ? new Icon(Icons.history) : new Icon(null), title: new RichText( text: new TextSpan( text: suggestion.Substring(0, this.query.Length), style: theme.textTheme.subhead.copyWith(fontWeight: FontWeight.bold), children: new List <TextSpan> { new TextSpan( text: suggestion.Substring(this.query.Length), style: theme.textTheme.subhead ) } ) ), onTap: () => { this.onSelected(suggestion); } ); } )); }
public static void DrawFontAssetProperties(ThemeData themeData, int propertyIndex, SerializedObject serializedObject, Object[] targets, ThemeTarget target, ColorName componentColorName, Color initialGUIColor) { GUIStyle buttonStyleDisabled = Styles.GetStyle(Styles.StyleName.CheckBoxDisabled); GUIStyle buttonStyleEnabled = Styles.GetStyle(Styles.StyleName.CheckBoxEnabled); #if dUI_TextMeshPro if (themeData.FontAssetLabels.Count != themeData.ActiveVariant.FontAssets.Count) { foreach (LabelId labelId in themeData.FontAssetLabels.Where(labelId => !themeData.ActiveVariant.ContainsFontAsset(labelId.Id))) { themeData.ActiveVariant.AddFontAssetProperty(labelId.Id); } } #endif for (int i = 0; i < themeData.FontAssetLabels.Count; i++) { LabelId fontAssetProperty = themeData.FontAssetLabels[i]; int index = i; bool selected = i == propertyIndex; GUILayout.BeginHorizontal(); { GUI.color = DGUI.Colors.PropertyColor(componentColorName); if (GUILayout.Button(GUIContent.none, selected ? buttonStyleEnabled : buttonStyleDisabled)) { if (serializedObject.isEditingMultipleObjects) { DoozyUtils.UndoRecordObjects(targets, UILabels.UpdateValue); foreach (Object o in targets) { var themeTarget = (ThemeTarget)o; if (themeTarget == null) { continue; } themeTarget.PropertyId = themeData.FontAssetLabels[index].Id; themeTarget.UpdateTarget(themeData); } } else { DoozyUtils.UndoRecordObject(target, UILabels.UpdateValue); target.PropertyId = themeData.FontAssetLabels[index].Id; target.UpdateTarget(themeData); } } GUI.color = initialGUIColor; GUILayout.Space(DGUI.Properties.Space(2)); GUI.enabled = selected; DGUI.Label.Draw(fontAssetProperty.Label, selected ? Size.L : Size.M); GUI.enabled = true; } GUILayout.EndHorizontal(); GUILayout.Space(DGUI.Properties.Space()); } }
public override Widget build(BuildContext context, SwiperPluginConfig config) { ThemeData themeData = Theme.of(context); Color activeColor = this.activeColor ?? themeData.primaryColor; Color color = this.color ?? themeData.scaffoldBackgroundColor; if (Axis.vertical == config.scrollDirection) { return(new Column( key: key, mainAxisSize: MainAxisSize.min, children: new List <Widget> { new Text( data: (config.activeIndex + 1).ToString(), style: new TextStyle(color: activeColor, fontSize: activeFontSize) ), new Text( "/", style: new TextStyle(color: color, fontSize: fontSize) ), new Text( data: config.itemCount.ToString(), style: new TextStyle(color: color, fontSize: fontSize) ) } )); } else { return(new Row( key: key, mainAxisSize: MainAxisSize.min, children: new List <Widget> { new Text( data: (config.activeIndex + 1).ToString(), style: new TextStyle(color: activeColor, fontSize: activeFontSize) ), new Text( " /" + config.itemCount.ToString(), style: new TextStyle(color: color, fontSize: fontSize) ) } )); } }
public override Widget build(BuildContext context) { ThemeData theme = Theme.of(context); bool isDark = theme.brightness == Brightness.dark; float textScaleFactor = MediaQuery.textScaleFactorOf(context); List <Widget> titleChildren = new List <Widget> { new Text( this.demo.title, style: theme.textTheme.subhead.copyWith( color: isDark ? Colors.white : new Color(0xFF202124) ) ), }; if (this.demo.subtitle != null) { titleChildren.Add( new Text( this.demo.subtitle, style: theme.textTheme.body1.copyWith( color: isDark ? Colors.white : new Color(0xFF60646B) ) ) ); } return(new RawMaterialButton( padding: EdgeInsets.zero, splashColor: theme.primaryColor.withOpacity(0.12f), highlightColor: Colors.transparent, onPressed: () => { this._launchDemo(context); }, child: new Container( constraints: new BoxConstraints(minHeight: HomeUtils._kDemoItemHeight *textScaleFactor), child: new Row( children: new List <Widget> { new Container( width: 56.0f, height: 56.0f, alignment: Alignment.center, child: new Icon( this.demo.icon, size: 24.0f, color: isDark ? Colors.white : HomeUtils._kUIWidgetsBlue ) ), new Expanded( child: new Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.stretch, children: titleChildren ) ), new SizedBox(width: 44.0f), } ) ) )); }
private void Awake() { ThemeData currentTheme = themeDataContainer.GetThemeData(DataManager.currentThemeId.GetValue()); Instantiate(currentTheme.BackgroundPrefab, parent.position, Quaternion.identity, parent); this.enabled = false; }
private void Awake() { ThemeData currentTheme = themeDataContainer.GetThemeData(DataManager.currentThemeId.GetValue()); Instantiate(currentTheme.BlackHoleSprite, blackHole.position, Quaternion.identity, blackHole); this.enabled = false; }
public override Widget build(BuildContext context, SwiperPluginConfig config) { ThemeData themeData = Theme.of(context); Color activeColor = this.activeColor ?? themeData.primaryColor; Color color = this.color ?? themeData.scaffoldBackgroundColor; List <Widget> list = new List <Widget>(); if (config.itemCount > 20) { UnityEngine.Debug.LogWarning( "The itemCount is too big, we suggest use FractionPaginationBuilder instead of DotSwiperPaginationBuilder in this sitituation"); } int itemCount = config.itemCount; int activeIndex = config.activeIndex; for (int i = 0; i < itemCount; ++i) { bool active = i == activeIndex; Size size = active ? this.activeSize : this.size; list.Add(new SizedBox( width: size.width, height: size.height, child: new Container( color: active ? activeColor : color, key: Key.key("pagination_$i"), margin: EdgeInsets.all(space) ) )); } if (config.scrollDirection == Axis.vertical) { return(new Column( key: key, mainAxisSize: MainAxisSize.min, children: list )); } else { return(new Row( key: key, mainAxisSize: MainAxisSize.min, children: list )); } }
public void Buy(ThemeData t) { PlayerData.instance.coins -= t.cost; PlayerData.instance.premium -= t.premiumCost; PlayerData.instance.AddTheme(t.themeName); PlayerData.instance.Save(); #if UNITY_ANALYTICS // Using Analytics Standard Events v0.3.0 var transactionId = System.Guid.NewGuid().ToString(); var transactionContext = "store"; var level = PlayerData.instance.rank.ToString(); var itemId = t.themeName; var itemType = "non_consumable"; var itemQty = 1; AnalyticsEvent.ItemAcquired( AcquisitionType.Soft, transactionContext, itemQty, itemId, itemType, level, transactionId ); if (t.cost > 0) { AnalyticsEvent.ItemSpent( AcquisitionType.Soft, // Currency type transactionContext, t.cost, itemId, PlayerData.instance.coins, // Balance itemType, level, transactionId ); } if (t.premiumCost > 0) { AnalyticsEvent.ItemSpent( AcquisitionType.Premium, // Currency type transactionContext, t.premiumCost, itemId, PlayerData.instance.premium, // Balance itemType, level, transactionId ); } #endif // Repopulate to change button accordingly. Populate(); }
private ThemeVariantData DrawViewThemesViewVariantsSprite(ThemeData themeData) { ThemeVariantData deleteVariant = null; float rowHeight = GetThemePropertyRowHeight(m_selectedThemeTab) - DGUI.Properties.Space(5); GUILayout.BeginHorizontal(); { foreach (ThemeVariantData variant in themeData.Variants.Where(variant => variant != null)) { GUILayout.BeginVertical(GUILayout.Width(m_themeVariantColumnWidth), GUILayout.Height(rowHeight)); { deleteVariant = DrawThemeVariantButton(themeData, variant); if (deleteVariant != null) { GUILayout.EndVertical(); break; } for (int propertyIndex = 0; propertyIndex < themeData.SpriteLabels.Count; propertyIndex++) { GUILayout.BeginHorizontal(GUILayout.Width(m_themeVariantColumnWidth)); { GUILayout.FlexibleSpace(); EditorGUI.BeginChangeCheck(); var sprite = (Sprite)EditorGUILayout.ObjectField(GUIContent.none, variant.Sprites[propertyIndex].Sprite, typeof(Sprite), false, GUILayout.Width(rowHeight), GUILayout.Height(rowHeight)); if (EditorGUI.EndChangeCheck()) { themeData.UndoRecord(UILabels.UpdateValue); variant.Sprites[propertyIndex] = new SpriteId(variant.Sprites[propertyIndex].Id, sprite); themeData.SetDirty(false); UpdateAllThemeTargets(themeData); } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Space(DGUI.Properties.Space()); DrawHorizontalDivider(); GUILayout.Space(DGUI.Properties.Space()); } } GUILayout.EndVertical(); } DrawThemeAddVariantButton(themeData); GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); return(deleteVariant); }
private ThemeVariantData DrawThemeVariantButton(ThemeData themeData, ThemeVariantData variant) { ThemeVariantData deleteVariant = null; if (EditMode.faded > 0.01f) { string variantName = variant.VariantName; GUILayout.BeginHorizontal(GUILayout.Width(m_themeVariantColumnWidth)); { GUILayout.Space(DGUI.Properties.Space(1 - EditMode.faded)); if (DGUI.Button.IconButton.Minus()) { deleteVariant = variant; } GUILayout.Space(DGUI.Properties.Space(2 * (1 - EditMode.faded))); EditorGUI.BeginChangeCheck(); variantName = EditorGUILayout.TextField(variantName); } GUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { themeData.UndoRecord(UILabels.UpdateValue); variant.VariantName = variantName; themeData.SetDirty(false); } } else { bool activeVariant = themeData.ActiveVariant.Id.Equals(variant.Id); if (DGUI.Button.Draw(variant.VariantName, activeVariant ? CurrentViewColorName : DGUI.Colors.DisabledBackgroundColorName, activeVariant ? CurrentViewColorName : DGUI.Colors.DisabledTextColorName, activeVariant, m_themeVariantButtonHeight, m_themeVariantColumnWidth)) { themeData.ActivateVariant(variant); themeData.SetDirty(false); UpdateAllThemeTargets(themeData); } } if (EditMode.faded > 0.01f) { GUILayout.Space(DGUI.Properties.Space(2)); } GUILayout.Space(DGUI.Properties.Space(4)); DrawHorizontalDivider(); GUILayout.Space(DGUI.Properties.Space()); return(deleteVariant); }
private void Awake() { ThemeData currentTheme = themeDataContainer.GetThemeData(DataManager.currentThemeId.GetValue()); Instantiate(currentTheme.MeteorSprite, meteor.position, Quaternion.identity, meteor); effectsController.deathEffectPrefab = currentTheme.MeteorDeathEffect; this.enabled = false; }
private void RpcSwitchTheme(byte themeIndex) { CurrentTheme = ChunkDatabase.Themes[themeIndex]; // Send [theme switched] Messenger.Instance.Send(this, new ThemeSwitchedMessage() { Theme = CurrentTheme }); }
//@override public override Widget build(BuildContext context, SwiperPluginConfig config) { ThemeData themeData = Theme.of(context); Color color = this.color ?? themeData.primaryColor; Color disableColor = this.disableColor ?? themeData.disabledColor; Color prevColor; Color nextColor; if (config.loop) { prevColor = nextColor = color; } else { bool next = config.activeIndex < config.itemCount - 1; bool prev = config.activeIndex > 0; prevColor = prev ? color : disableColor; nextColor = next ? color : disableColor; } Widget child; if (config.scrollDirection == Axis.horizontal) { child = new Row( key: key, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: new List <Widget> { buildButton(config, prevColor, iconPrevious, 0, true), buildButton(config, nextColor, iconNext, 0, false) } ); } else { child = new Column( key: key, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: new List <Widget> { buildButton(config, prevColor, iconPrevious, -3, true), buildButton(config, nextColor, iconNext, -3, false) } ); } return(new Container( height: float.PositiveInfinity, child: child, width: float.PositiveInfinity )); }
public static void DrawButtonTheme(ThemeData themeData, ColorName componentColorName) { if (DGUI.Button.Dynamic.DrawIconButton(Styles.GetStyle(Styles.StyleName.IconThemeManager), UILabels.Themes, Size.S, TextAlign.Left, componentColorName, componentColorName, DGUI.Properties.SingleLineHeight + DGUI.Properties.Space(2), false)) { DoozyWindow.Open(DoozyWindow.View.Themes); DoozyWindow.Instance.CurrentThemeId = themeData.Id; } }
public ParentItem(string path) { if (path == null) { throw new ArgumentNullException("path"); } _path = path; Title = "Parent Folder"; Icon = ThemeData.GetImage("parent"); }
public static void DrawColorProperties(ThemeData themeData, int propertyIndex, SerializedObject serializedObject, Object[] targets, ThemeTarget target, Color initialGUIColor) { GUIStyle colorButtonStyle = Styles.GetStyle(Styles.StyleName.ColorButton); GUIStyle colorButtonSelectedStyle = Styles.GetStyle(Styles.StyleName.ColorButtonSelected); for (int i = 0; i < themeData.ColorLabels.Count; i++) { LabelId colorProperty = themeData.ColorLabels[i]; int index = i; bool selected = i == propertyIndex; GUILayout.BeginHorizontal(); { if (!selected) { GUILayout.Space((colorButtonSelectedStyle.fixedWidth - colorButtonStyle.fixedWidth) / 2); } GUI.color = themeData.ActiveVariant.Colors[i].Color; { if (GUILayout.Button(GUIContent.none, selected ? colorButtonSelectedStyle : colorButtonStyle)) { if (serializedObject.isEditingMultipleObjects) { DoozyUtils.UndoRecordObjects(targets, UILabels.UpdateValue); foreach (Object o in targets) { var themeTarget = (ThemeTarget)o; if (themeTarget == null) { continue; } themeTarget.PropertyId = themeData.ColorLabels[index].Id; themeTarget.UpdateTarget(themeData); } } else { DoozyUtils.UndoRecordObject(target, UILabels.UpdateValue); target.PropertyId = themeData.ColorLabels[index].Id; target.UpdateTarget(themeData); } } } GUI.color = initialGUIColor; GUILayout.Space(DGUI.Properties.Space(2)); GUI.enabled = selected; DGUI.Label.Draw(colorProperty.Label, selected ? Size.L : Size.M, selected ? colorButtonSelectedStyle.fixedHeight : colorButtonStyle.fixedHeight); GUI.enabled = true; } GUILayout.EndHorizontal(); GUILayout.Space(DGUI.Properties.Space()); } }
private void ProcessThemeUpdated() { ThemeData data = themeController.GetCurrentTheme(); if (musicSource.clip != data.Music.AudioClip) { musicSource.volume = data.Music.Volume; musicSource.clip = data.Music.AudioClip; musicSource.Play(); } }
private ThemeVariantData DrawViewThemesViewVariantsFontAsset(ThemeData themeData) { ThemeVariantData deleteVariant = null; GUILayout.BeginHorizontal(); { foreach (ThemeVariantData variant in themeData.Variants.Where(variant => variant != null)) { GUILayout.BeginVertical(GUILayout.Width(m_themeVariantColumnWidth)); { deleteVariant = DrawThemeVariantButton(themeData, variant); if (deleteVariant != null) { GUILayout.EndVertical(); break; } for (int propertyIndex = 0; propertyIndex < themeData.FontAssetLabels.Count; propertyIndex++) { GUILayout.BeginHorizontal(GUILayout.Width(m_themeVariantColumnWidth)); { #if dUI_TextMeshPro GUILayout.FlexibleSpace(); EditorGUI.BeginChangeCheck(); var fontAsset = (TMP_FontAsset)EditorGUILayout.ObjectField(GUIContent.none, variant.FontAssets[propertyIndex].FontAsset, typeof(TMP_FontAsset), false, GUILayout.Width(m_themeVariantColumnWidth)); if (EditorGUI.EndChangeCheck()) { themeData.UndoRecord(UILabels.UpdateValue); variant.FontAssets[propertyIndex] = new FontAssetId(variant.FontAssets[propertyIndex].Id, fontAsset); themeData.SetDirty(false); UpdateAllThemeTargets(themeData); } GUILayout.FlexibleSpace(); #endif } GUILayout.EndHorizontal(); GUILayout.Space(DGUI.Properties.Space()); DrawHorizontalDivider(); GUILayout.Space(DGUI.Properties.Space()); } } GUILayout.EndVertical(); } DrawThemeAddVariantButton(themeData); GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); return(deleteVariant); }
private int GetThemeIndex(int id) { for (int i = 0; i < themes.Length; i++) { ThemeData theme = themes[i]; if (theme.Id == id) { return(i); } } return(-1); }
public static void DrawActiveVariant(ThemeData themeData, ColorName componentColorName) { DGUI.Line.Draw(false, componentColorName, true, () => { GUILayout.Space(DGUI.Properties.Space(2)); DGUI.Label.Draw(UILabels.ActiveVariant + " : ", Size.S, componentColorName, DGUI.Properties.SingleLineHeight); GUILayout.Space(DGUI.Properties.Space()); DGUI.Label.Draw(themeData.ActiveVariant.VariantName, Size.L, DGUI.Properties.SingleLineHeight); GUILayout.Space(DGUI.Properties.Space(2)); }); }
private void Awake() { ThemeData currentTheme = themeDataContainer.GetThemeData(DataManager.currentThemeId.GetValue()); sprite.sprite = currentTheme.UfoSprite; gun.BulletPrefab = currentTheme.UfoBulletPrefab; effectsController.deathEffectPrefab = currentTheme.UfoDeathEffect; Instantiate(currentTheme.UfoTrail, ufoTrailParent.position, Quaternion.identity, ufoTrailParent); this.enabled = false; }
private ThemeVariantData DrawViewThemesViewVariantsColor(ThemeData themeData) { ThemeVariantData deleteVariant = null; GUILayout.BeginHorizontal(); { foreach (ThemeVariantData variant in themeData.Variants.Where(variant => variant != null)) { GUILayout.BeginVertical(GUILayout.Width(m_themeVariantColumnWidth)); { deleteVariant = DrawThemeVariantButton(themeData, variant); if (deleteVariant != null) { GUILayout.EndVertical(); break; } for (int propertyIndex = 0; propertyIndex < themeData.ColorLabels.Count; propertyIndex++) { GUILayout.BeginHorizontal(GUILayout.Width(m_themeVariantColumnWidth)); { GUILayout.FlexibleSpace(); EditorGUI.BeginChangeCheck(); Color color = EditorGUILayout.ColorField(GUIContent.none, variant.Colors[propertyIndex].Color, GUILayout.Width(DGUI.Properties.DefaultFieldWidth)); if (EditorGUI.EndChangeCheck()) { themeData.UndoRecord(UILabels.UpdateValue); variant.Colors[propertyIndex] = new ColorId(variant.Colors[propertyIndex].Id, color); themeData.SetDirty(false); UpdateAllThemeTargets(themeData); } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); GUILayout.Space(DGUI.Properties.Space()); DrawHorizontalDivider(); GUILayout.Space(DGUI.Properties.Space()); } } GUILayout.EndVertical(); } DrawThemeAddVariantButton(themeData); GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); return(deleteVariant); }
public void SetUp(ThemeData data) { theme = data.GetTheme(themeNumber); if (theme == null) { Destruct(); return; } image.sprite = theme.Sprite; CheckIfUnlocked(); CheckIfSelected(); }
private void DrawViewThemesProperties(ThemeData themeData) { GUILayout.BeginArea(ThemesPropertiesAreaRect); GUILayout.BeginScrollView(new Vector2(0, m_themesVariantsScrollPosition.y), false, false, GUIStyle.none, GUIStyle.none); { GUILayout.Space(m_themeVariantButtonHeight); GUILayout.Space(DGUI.Properties.Space(2)); DrawViewThemesViewProperties(themeData, m_selectedThemeTab); GUILayout.Space(DGUI.Properties.SingleLineHeight * 2 + GUI.skin.horizontalScrollbar.fixedHeight); } GUILayout.EndScrollView(); GUILayout.EndArea(); }
private void UpdateIds() { if (!Database.Contains(TargetNode.ThemeId)) { TargetNode.ThemeId = Database.Themes[0].Id; } m_theme = Database.GetThemeData(TargetNode.ThemeId); if (!m_theme.ContainsVariant(TargetNode.VariantId)) { TargetNode.VariantId = m_theme.Variants[0].Id; } }
// Start is called before the first frame update void Start() { // load current theme int themeIndex = UnityEngine.Random.Range(0, 16); currentTheme = Resources.Load <ThemeData>("theme_data_" + themeIndex); // create bg GameObject newBg = Instantiate(currentTheme.bgPrefab, transform); ballSpriteIndex = UnityEngine.Random.Range(0, allBallSprites.Count); ballCreator.CreateFirstBalls(60); }
public static ThemeData GetHtml(ThemeData theme) { theme.Main = ToHtml(theme.Main); theme.Foreground = ToHtml(theme.Foreground); theme.Background = ToHtml(theme.Background); theme.Identifier = ToHtml(theme.Identifier); theme.Keyword = ToHtml(theme.Keyword); theme.StringColor = ToHtml(theme.StringColor); theme.User = ToHtml(theme.User); theme.User2 = ToHtml(theme.User2); theme.Comment = ToHtml(theme.Comment); theme.Error = ToHtml(theme.Error); theme.Operator = ToHtml(theme.Operator); theme.MarginColor = ToHtml(theme.MarginColor); theme.Preprocessor = ToHtml(theme.Preprocessor); theme.NumberColor = ToHtml(theme.NumberColor); return theme; }
public ActionResult ThemeGenerator(string forecolor, string backcolor, string maincolor, string contrast, string markupLowContrast) { Response.ContentType = "Text/vssettings"; ThemeData[] arr = new ThemeData[2]; ThemeData themeData = null; try { themeData = ColorFactory.GetThemeDataBright(forecolor, backcolor, maincolor, contrast); } catch (InvalidColorException) { TempData["Error"] = "Must supply valid color information!"; return View("Index"); } catch (InvalidContrastException) { TempData["Error"] = "Must supply valid contrast information!"; return View("Index"); } arr[0] = themeData; if ((markupLowContrast != null) && (bool.Parse(markupLowContrast))) { ThemeData markupData = ColorFactory.GetThemeDataBright(forecolor, backcolor, maincolor, "50"); arr[1] = markupData; ViewData["theme"] = arr; return View(); } arr[0] = themeData; arr[1] = themeData; ViewData["theme"] = arr; return View(); }
/// <summary> /// Recursively navigates the tree to build a JSON string. /// </summary> /// <param name="tree">The parent tree.</param> /// <param name="parentNode">The parent node.</param> /// <param name="indexPath">Used for creating IDs for nodes.</param> void RecursiveBuild(Dictionary<string, ListDictionary> tree, Node parentNode, string indexPath) { var index = 0; foreach (var treeLevel in tree) { // Determine the current level. const char levelSplitter = GlobalManager.LevelSplitter; var currentLevel = indexPath.Count(character => character == levelSplitter); var groupLevel = _globalManager.TreeLevels[currentLevel]; // Determine the node's ID. var idPrefix = GetIdPrefix(groupLevel); var newIndexPath = indexPath + levelSplitter + index++; var nodeId = idPrefix + newIndexPath; // Determine the node's name. var groupKey = treeLevel.Key; string nodeName; switch (groupLevel) { case "Sprint": // Needs to happen here for sorting by key purposes before this. var sprintIndex = groupKey.IndexOf("Sprint", StringComparison.Ordinal); nodeName = sprintIndex == -1 ? groupKey : groupKey.Substring(sprintIndex); break; case "Quarter": case "Team": case "Product": case "Theme": nodeName = groupKey; break; case "PBI": // Cut off the PBI's ID # that was added to guarantee uniqueness. nodeName = groupKey.Substring(0, groupKey.LastIndexOf(levelSplitter)); break; default: throw new Exception("Work item type: " + groupLevel + ", is not supported."); } // Determine the node's effort. var effort = (double)treeLevel.Value["effort"]; // Determine the node's size. double size; var sizeType = _globalManager.SizeLevels[currentLevel]; if (sizeType == "Effort") { size = effort == 0 ? 1 : effort; } else // "Aligning" and "Nothing". { size = 1; } // Determine the node's color. var color = ""; if (groupLevel != "PBI" && groupLevel != "Theme") // PBIs and Themes have special color systems. { color = _globalManager.GetColor(groupLevel, groupKey); } // Make the appropriate data object. Data nodeData; switch (groupLevel) { case "PBI": var pbi = (SimpleWorkItem)treeLevel.Value["simpleWorkItem"]; color = GlobalManager.GetPbiColor(pbi); nodeData = new PbiData(size, color, pbi.Effort, pbi.Id, pbi.Priority, pbi.State); break; case "Theme": var mainTheme = (string)treeLevel.Value["mainTheme"]; color = _globalManager.GetMainThemeColor(mainTheme); var priority = _globalManager.GetMainThemePriority(mainTheme); nodeData = new ThemeData(size, color, effort, priority); break; case "Team": var velocity = (double)treeLevel.Value["velocity"]; nodeData = new TeamData(size, color, effort, velocity); break; case "Product": case "Sprint": case "Quarter": nodeData = new Data(size, color, effort); break; default: throw new Exception("Work item type: " + groupLevel + ", is not supported."); } // Build the node and add it to the parent node. var childNode = new Node { children = new List<Node>(), data = nodeData, id = nodeId, name = nodeName }; parentNode.children.Add(childNode); // Continue recursion if there are more nested lists. var unsortedChildren = treeLevel.Value["children"] as Dictionary<string, ListDictionary>; if (unsortedChildren != null && unsortedChildren.Count > 0) // Count check is needed when multiple levels have "Aligning". { var nextLevel = currentLevel + 1; var sortedChildren = SortManager.SortCollection(unsortedChildren, _globalManager.TreeLevels[nextLevel], _globalManager.SortLevels[nextLevel]); RecursiveBuild(sortedChildren, childNode, newIndexPath); } } }
public static ThemeData GetThemeDataBright(string forecolor, string backcolor, string maincolor, string contrastString) { Regex rex = new Regex("^#?([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?$"); if (!rex.IsMatch(forecolor) || !rex.IsMatch(backcolor) || !rex.IsMatch(maincolor)) { throw new InvalidColorException(); } double dblContrast; if ((!double.TryParse(contrastString, out dblContrast)) || (dblContrast > 180) || (dblContrast < 0)) { throw new InvalidContrastException(); } var theme = new ThemeData(); int contrast = (int)double.Parse(contrastString); Color main = ColorTranslator.FromHtml(maincolor); Color fore = ColorTranslator.FromHtml(forecolor); Color back = ColorTranslator.FromHtml(backcolor); int shadeMultiplyer = back.R + back.G + back.B > 382.5 ? -1 : 1; if (contrast == 0) { contrast = 1; } theme.Main = main.ToHexString(); theme.Foreground = fore.ToHexString(); theme.Background = back.ToHexString(); theme.Identifier = fore.ToHexString(); theme.Keyword = theme.Main; theme.StringColor = main.ChangeHue((int)(contrast / double.Parse(ConfigurationManager.AppSettings["string"]))) .ToHexString(); theme.NumberColor = main.ChangeHue((int) (contrast/double.Parse(ConfigurationManager.AppSettings["number"]))) .ToHexString(); theme.User = main.ChangeHue((int)(contrast)) .ToHexString(); theme.User2 = main.ChangeHue((int)(contrast)) .ChangeSaturation(-1 * shadeMultiplyer * 30) .ToHexString(); theme.Comment = fore.ChangeBrightness(30 * shadeMultiplyer * -1 ) .ToHexString(); theme.Error = ColorTranslator.FromHtml("#F00000") .ToHexString(); theme.Operator = fore .ToHexString(); theme.MarginColor = back.ToHexString(); theme.Preprocessor = main .ChangeHue((int)(contrast / double.Parse(ConfigurationManager.AppSettings["preprocessor"]))) .ToHexString(); return theme; }