public TextTheme geometryThemeFor(ScriptCategory category) { switch (category) { case ScriptCategory.englishLike: return(this.englishLike); case ScriptCategory.dense: return(this.dense); case ScriptCategory.tall: return(this.tall); } return(null); }
public static ThemeData of(BuildContext context, bool shadowThemeOnly = false) { _InheritedTheme inheritedTheme = context.dependOnInheritedWidgetOfExactType <_InheritedTheme>(); if (shadowThemeOnly) { if (inheritedTheme == null || inheritedTheme.theme.isMaterialAppTheme) { return(null); } return(inheritedTheme.theme.data); } MaterialLocalizations localizations = MaterialLocalizations.of(context); ScriptCategory category = ScriptCategory.englishLike; ThemeData theme = inheritedTheme?.theme?.data ?? _kFallbackTheme; return(ThemeData.localize(theme, theme.typography.geometryThemeFor(category))); }
/// <summary> /// Get ScriptParser from file name. /// </summary> /// <param name="fileName">Script file name</param> /// <param name="mapName">Map name used to get script path, use current map name if null or empty</param> /// <param name="category">Category of script belongs.</param> /// <returns></returns> public static ScriptParser GetScriptParser(string fileName, string mapName = null, ScriptCategory category = ScriptCategory.Normal) { if (string.IsNullOrEmpty(fileName)) { return(null); } var path = GetScriptFilePath(fileName, mapName, category); if (!Globals.TheGame.IsInEditMode || (_scriptFileLastWriteTime.ContainsKey(path) && _scriptFileLastWriteTime[path].Equals(File.GetLastWriteTime(path)))) { //Use cached script parser: // *In play mode or // *If file is cached and not modified in edit mode. if (_scriptParserCache.ContainsKey(path)) { return(_scriptParserCache[path]); } } else if (Globals.TheGame.IsInEditMode) { try { // Update last write time _scriptFileLastWriteTime[path] = File.GetLastWriteTime(path); } catch (Exception) { } } //No script parser in cache, create new and add to cache. var parser = new ScriptParser(path); _scriptParserCache[path] = parser; return(parser); }
/// <summary> /// Get script file path from file name. /// </summary> /// <param name="fileName">Script file name</param> /// <param name="mapName">Map name used to get script path, use current map name if null or empty</param> /// <param name="category">Category of script belongs.</param> /// <returns></returns> public static string GetScriptFilePath(string fileName, string mapName = null, ScriptCategory category = ScriptCategory.Normal) { switch (category) { case ScriptCategory.Normal: { if (string.IsNullOrEmpty(mapName)) { mapName = MapBase.MapFileNameWithoutExtension; } var path = @"script\map\" + mapName + @"\" + fileName; if (!File.Exists(path)) { return(@"script\common\" + fileName); } return(path); } case ScriptCategory.Good: return(@"script\goods\" + fileName); default: throw new ArgumentOutOfRangeException("category"); } }
/// <summary> /// Get ScriptParser from file name. /// </summary> /// <param name="fileName">Script file name</param> /// <param name="belongObject">Belong object of returned ScriptParser</param> /// <param name="mapName">Map name used to get script path, use current map name if null or empty</param> /// <param name="category">Category of script belongs.</param> /// <returns></returns> public static ScriptParser GetScriptParser(string fileName, object belongObject = null, string mapName = null, ScriptCategory category = ScriptCategory.Normal) { if (string.IsNullOrEmpty(fileName)) { return(null); } return(new ScriptParser(GetScriptFilePath(fileName, mapName, category), belongObject)); }
/// <summary> /// Get ScriptParser from file name. /// </summary> /// <param name="fileName">Script file name</param> /// <param name="mapName">Map name used to get script path, use current map name if null or empty</param> /// <param name="category">Category of script belongs.</param> /// <returns></returns> public static ScriptParser GetScriptParser(string fileName, string mapName = null, ScriptCategory category = ScriptCategory.Normal) { if (string.IsNullOrEmpty(fileName)) { return(null); } return(GetScriptParserFromPath(GetScriptFilePath(fileName, mapName, category))); }