mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 23:40:01 +07:00
TechPickerScreen colors - skinnable and prettier Future Tech (#9033)
This commit is contained in:
@ -20,17 +20,28 @@ class UiElementDocsWriter {
|
||||
val startIndex = originalLines.indexOf(startMarker).takeIf { it != -1 } ?: (endIndex + 1)
|
||||
|
||||
val elements = mutableListOf<String>()
|
||||
val backgroundRegex = Regex("""getUiBackground\((\X*?)"(?<path>.*)"[ ,\n\r]*((BaseScreen\.)?skinStrings\.(?<default>.*)Shape)?\X*?\)""")
|
||||
val colorRegex = Regex("""
|
||||
getUIColor\s*\(\s* # function call, whitespace around opening round bracket optional. All \s also allow line breaks!
|
||||
"(?<path>[^"]*)"\s* # captures "path", anything between double-quotes, not allowing for embedded quotes
|
||||
(?:,\s* # group for optional default parameter
|
||||
(?:default\s*=\s*)? # allow for named parameter
|
||||
(?:Colors\s*\(|colorFromRGB\s*\(|Color\.) # recognize only Color constructor, colorFromRGB helper, or Color.* constants as argument
|
||||
(?<default>[^)]*) # capture "default" up until a closing round bracket
|
||||
)\s*\) # ends default parameter group and checks closing round bracket of the getUIColor call
|
||||
""", RegexOption.COMMENTS)
|
||||
|
||||
for (file in srcFile.walk()) {
|
||||
if (file.path.endsWith(".kt")) {
|
||||
val results = Regex("getUiBackground\\((\\X*?)\"(?<path>.*)\"[ ,\n\r]*((BaseScreen\\.)?skinStrings\\.(?<defaultShape>.*)Shape)?\\X*?\\)")
|
||||
.findAll(file.readText())
|
||||
for (result in results) {
|
||||
val sourceText = file.readText()
|
||||
val matches: Sequence<MatchResult> =
|
||||
backgroundRegex.findAll(sourceText) + colorRegex.findAll(sourceText)
|
||||
for (result in matches) {
|
||||
val path = result.groups["path"]?.value
|
||||
val name = path?.takeLastWhile { it != '/' } ?: ""
|
||||
val defaultShape = result.groups["defaultShape"]?.value
|
||||
val default = result.groups["default"]?.value
|
||||
if (name.isNotBlank())
|
||||
elements.add("| ${path!!.dropLast(name.length)} | $name | $defaultShape | |")
|
||||
elements.add("| ${path!!.dropLast(name.length)} | $name | $default | |")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user