Add sorting tag usage info tooltip

This commit is contained in:
Firenoo committed 2023-03-18 17:30:40 -07:00
1 parent be08ab0047
commit d35708c08b
4 files changed
+25 -11

No files matched your search

@@ -49,6 +49,16 @@ class GuiAdvancedMemoryCard(msg: S2CListP2P) : GuiScreen(), TextureBound {
private var mode = msg.memoryInfo.mode
private var modeString = getModeString()
private val modeButton by lazy { GuiButton(0, guiLeft + 8, guiTop + 190, 256, 20, modeString) }
private val sortRules: List<String> by lazy {
listOf(
"§b§n" + I18n.format("gui.advanced_memory_card.sortinfo1"),
"§9@in§7 - " + I18n.format("gui.advanced_memory_card.sortinfo2"),
"§6@out§7 - " + I18n.format("gui.advanced_memory_card.sortinfo3"),
"§a@b§7 - " + I18n.format("gui.advanced_memory_card.sortinfo4"),
"§c@u§7 - " + I18n.format("gui.advanced_memory_card.sortinfo5"),
"§7" + I18n.format("gui.advanced_memory_card.sortinfo6")
)
}
private val selectedInfo: InfoWrapper?
get() = infos.selectedInfo
@@ -141,6 +151,9 @@ class GuiAdvancedMemoryCard(msg: S2CListP2P) : GuiScreen(), TextureBound {
drawInformation()
if(renameBar.isVisible && !renameBar.isFocused) renameBar.setFocus(true)
renameBar.drawTextBox()
if (searchBar.isMouseIn(mouseX, mouseY)) {
drawHoveringText(sortRules, guiLeft, guiTop + ySize - 40, fontRendererObj)
}
super.drawScreen(mouseX, mouseY, partialTicks)
}
@@ -21,10 +21,7 @@ class InfoFilter {
* filter list.
*/
fun updateFilter(query: String) {
// I spent 10 minutes on this until I gave up... regex wtf
// https://stackoverflow.com/questions/366202/regex-for-splitting-a-string-using-space-when-not-surrounded-by-single-or-double
val regex = "[^\\s\"']+|\"([^\"]*)\"|'([^']*)'".toRegex()
val tokens = regex.findAll(query)
val tokens = SEARCH_REGEX.findAll(query)
activeFilters.clear()
tokens.forEach {
when {
@@ -74,5 +71,9 @@ enum class Filter(val pattern: Regex, val filter: (InfoWrapper, List<String>?) -
}
false
});
}
// I spent 10 minutes on this until I gave up... regex wtf
// https://stackoverflow.com/questions/366202/regex-for-splitting-a-string-using-space-when-not-surrounded-by-single-or-double
val SEARCH_REGEX = "[^\\s\"']+|\"([^\"]*)\"|'([^']*)'".toRegex()
@@ -102,12 +102,6 @@ class InfoList (initList: Collection<InfoWrapper>,
else -> it.frequency + Short.MAX_VALUE
}
}
// filtered = sorted.filter {
// it.frequency.toHexString().contains(searchStr.uppercase()) ||
// it.frequency.toHexString().format4().contains(searchStr.uppercase()) ||
// it.name.lowercase().contains(searchStr.lowercase()) ||
// it.code == selectedEntry
// }
}
/**
@@ -5,6 +5,12 @@ gui.advanced_memory_card.select=Select
gui.advanced_memory_card.bind=Bind
gui.advanced_memory_card.pos=Pos: %d, %d, %d Side: %s
gui.advanced_memory_card.name=Name: %s
gui.advanced_memory_card.sortinfo1=Sorting tags
gui.advanced_memory_card.sortinfo2=Show Input P2Ps only
gui.advanced_memory_card.sortinfo3=Show Output P2Ps only
gui.advanced_memory_card.sortinfo4=Show Bound P2Ps only
gui.advanced_memory_card.sortinfo5=Show Unbound P2Ps only
gui.advanced_memory_card.sortinfo6=Tags are space separated and are combined w/ the AND operator.
gui.advanced_memory_card.extra.channel=Channels used: %s
gui.advanced_memory_card.extra.none=No Extra Info
gui.advanced_memory_card.mode.input=Mode: Bind Input