mirror of
https://gitlab.com/2009scape/tools/rs09-thanos-tool.git
synced 2026-08-01 14:39:20 -06:00
Add an inverse percent column.
This commit is contained in:
parent
20d6e42366
commit
a96020f3eb
1 changed files with 9 additions and 2 deletions
|
|
@ -201,6 +201,7 @@ class DropTableEditor(val table: NPCDropTable) : JFrame("Editing ${if(table.ids.
|
|||
mainModel.addColumn("Max Amt")
|
||||
mainModel.addColumn("Weight")
|
||||
mainModel.addColumn("(%)")
|
||||
mainModel.addColumn("(1/%)")
|
||||
|
||||
defaultModel.addColumn("ID")
|
||||
defaultModel.addColumn("Name")
|
||||
|
|
@ -312,6 +313,7 @@ class DropTableEditor(val table: NPCDropTable) : JFrame("Editing ${if(table.ids.
|
|||
fun getPercentage(weight: Double, table: WeightBasedTable): String{
|
||||
return "${round((weight / table.totalWeight) * 100.0,4)}%"
|
||||
}
|
||||
|
||||
fun round(value: Double, places: Int): Double {
|
||||
require(places >= 0)
|
||||
var bd: BigDecimal = BigDecimal.valueOf(value)
|
||||
|
|
@ -328,7 +330,7 @@ class DropTableEditor(val table: NPCDropTable) : JFrame("Editing ${if(table.ids.
|
|||
charmModel.addRow(arrayOf(item.id,TableData.getItemName(item.id),item.minAmt,item.maxAmt,item.weight,getPercentage(item.weight,table.charmTable)))
|
||||
}
|
||||
for(item in table){
|
||||
mainModel.addRow(arrayOf(item.id,TableData.getItemName(item.id),item.minAmt,item.maxAmt,item.weight,getPercentage(item.weight,table)))
|
||||
mainModel.addRow(arrayOf(item.id,TableData.getItemName(item.id),item.minAmt,item.maxAmt,item.weight,getPercentage(item.weight,table),getInversePercentage(item.weight, table)))
|
||||
}
|
||||
isVisible = true
|
||||
}
|
||||
|
|
@ -337,6 +339,10 @@ class DropTableEditor(val table: NPCDropTable) : JFrame("Editing ${if(table.ids.
|
|||
return "${round((weight / table.totalWeight) * 100.0,2)}%"
|
||||
}
|
||||
|
||||
fun getInversePercentage(weight: Double, table: WeightBasedTable): String {
|
||||
return "${1.0/(weight / table.totalWeight)}"
|
||||
}
|
||||
|
||||
fun updateCharmPercentages(){
|
||||
for(i in 0 until charmModel.rowCount){
|
||||
charmModel.setValueAt(getPercentage(table.charmTable[i].weight,table.charmTable),i,5)
|
||||
|
|
@ -346,6 +352,7 @@ class DropTableEditor(val table: NPCDropTable) : JFrame("Editing ${if(table.ids.
|
|||
fun updateMainPercentages(){
|
||||
for(i in 0 until mainModel.rowCount){
|
||||
mainModel.setValueAt(getPercentage(table[i].weight,table),i,5)
|
||||
mainModel.setValueAt(getInversePercentage(table[i].weight,table),i,6)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -355,4 +362,4 @@ class DropTableEditor(val table: NPCDropTable) : JFrame("Editing ${if(table.ids.
|
|||
bd = bd.setScale(places, RoundingMode.HALF_UP)
|
||||
return bd.toDouble()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue