Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
antD97 committed Jan 10, 2022
2 parents bb4ca4e + a0909b5 commit a522890
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
build/
releases/
sdps.conf
bin/
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group 'antD'
version '2.3'
version '2.4'

repositories {
mavenCentral()
Expand Down
6 changes: 3 additions & 3 deletions bundle/readme.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---------- SDPS v2.3 ----------
---------- SDPS v2.4 ----------

SDPS is a handy tool for the game Smite (https://smitegame.com/) that lets you track your in-game
damage in real time. By jumping into a jungle practice match, SDPS makes it easy to compare the
damage of different builds. SDPS uses the in-game combat log, so it will work seamlessly with future
updates containing balance changes, new gods, and new items.

Release: https://github.com/antD97/SmiteDPS/releases/tag/v2.3
For a more detailed readme: https://github.com/antD97/SDPS/tree/v2.3
Release: https://github.com/antD97/SmiteDPS/releases/tag/v2.4
For a more detailed readme: https://github.com/antD97/SDPS/tree/v2.4

--- Usage ---

Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# SDPS

[![GitHub release](https://img.shields.io/github/downloads/antD97/SDPS/v2.3/total)](https://github.com/antD97/SmiteDPS/releases/tag/v2.3)
[![GitHub release](https://img.shields.io/github/downloads/antD97/SDPS/v2.4/total)](https://github.com/antD97/SmiteDPS/releases/tag/v2.4)

SDPS is a handy tool for the game [Smite](https://smitegame.com/) that lets you track your in-game
damage in real time. By jumping into a jungle practice match, SDPS makes it easy to compare the
damage of different builds. SDPS uses the in-game combat log, so it will work seamlessly with future
updates containing balance changes, new gods, and new items.

You can find the download [here](https://github.com/antD97/SmiteDPS/releases/tag/v2.3).
You can find the download [here](https://github.com/antD97/SmiteDPS/releases/tag/v2.4).

## Usage

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/sdps/CombatLogFinder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object CombatLogFinder {
combatLogs.add(f)
}

combatLogs.sort()
combatLogs.sortBy { it.lastModified() }
if (combatLogs.isNotEmpty()) return combatLogs.last()
}

Expand Down
11 changes: 10 additions & 1 deletion src/main/kotlin/sdps/ConfigManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ object ConfigManager {
fun StringBuilder.appendKeyValuePair(key: String, list: List<*>?) {
if (list != null) append("$key=${list.joinToString(",")}\n")
}
fun StringBuilder.appendKeyValuePair(key: String, x: Int?) {
if (x != null) append("$key=$x\n")
}

sb.appendKeyValuePair("loc", loc)
sb.appendKeyValuePair("size", size)
Expand All @@ -42,6 +45,8 @@ object ConfigManager {
sb.appendKeyValuePair("onTop", onTop)
sb.appendKeyValuePair("columnOrder", columnOrder)
sb.appendKeyValuePair("columnWidths", columnWidths)
sb.appendKeyValuePair("rowSize", rowSize)
sb.appendKeyValuePair("updateCheck", updateCheck)

f.writeText(sb.toString())
true
Expand All @@ -68,6 +73,8 @@ object ConfigManager {
"onTop" -> sd.onTop = value.toBoolean()
"columnOrder" -> sd.columnOrder = value.split(",").map { it.trim() }
"columnWidths" -> sd.columnWidths = value.toIntListOrNull()
"rowSize" -> sd.rowSize = value.toInt()
"updateCheck" -> sd.updateCheck = value.toBoolean()
}
}
}
Expand All @@ -81,7 +88,9 @@ object ConfigManager {
var sidebar: Boolean = true,
var onTop: Boolean = false,
var columnOrder: List<String>? = null,
var columnWidths: List<Int>? = null)
var columnWidths: List<Int>? = null,
var rowSize: Int = 12,
var updateCheck: Boolean = true)

/* -------------------------------------------- Util -------------------------------------------- */

Expand Down
10 changes: 7 additions & 3 deletions src/main/kotlin/sdps/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fun main() {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
val jFrame = JFrame()
// min size of window with sidebar
val windowSidebarMinSize = Dimension(300, 407)
val windowSidebarMinSize = Dimension(300, 437)
// min size of window without sidebar
val windowSmallMinSize = Dimension(150, 100)

Expand Down Expand Up @@ -59,13 +59,17 @@ fun main() {
mainPanel.isSidebarEnabled,
mainPanel.isOnTopEnabled,
mainPanel.columnOrder,
mainPanel.columnWidths
mainPanel.columnWidths,
mainPanel.rowSize,
configData.updateCheck
).save()
}
})

// check for new release
UpdateChecker.check(version)
if (configData.updateCheck) {
UpdateChecker.check(version)
}

damageTracker.run()
}
47 changes: 43 additions & 4 deletions src/main/kotlin/sdps/MainPanel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import java.awt.*
import java.awt.event.*
import java.io.File
import javax.swing.*
import javax.swing.event.ChangeEvent
import javax.swing.table.DefaultTableModel
import javax.swing.table.TableColumn

Expand All @@ -34,14 +35,22 @@ class MainPanel(
val columnWidths: List<Int>
get() { return table.columnModel.columns.toList().map { it.width } }

val rowSize: Int
get() { return table.font.size }

/* --------------------------------------- GUI Components --------------------------------------- */

private val colMaxWidth = Int.MAX_VALUE
private val colMinWidth = 15

private val table = JTable(
DefaultTableModel(arrayOf(), arrayOf("Time", "DPS", "Damage", "Σ Damage", "Mitigated", "Σ Mitigated", "Reason")))
.apply { setDefaultEditor(Object::class.java, null) }
.apply {
setDefaultEditor(Object::class.java, null)
font = Font(font.name, font.style, configData.rowSize)
tableHeader.font = font
rowHeight = font.size + 5
}
private val tableScrollPane = JScrollPane(table)
.apply { preferredSize = Dimension(275, 300) }

Expand Down Expand Up @@ -78,6 +87,12 @@ class MainPanel(
isEditable = false
}

private val rowSizeSpinner = JSpinner(SpinnerNumberModel(configData.rowSize, 1, 100, 1))
.apply {
addChangeListener(::rowSizeSpinnerChange)
toolTipText = "Adjust table row size"
}

private val resetTimerButton = JButton("Reset")
.apply {
addActionListener(::resetTimerButtonClick)
Expand Down Expand Up @@ -189,7 +204,15 @@ class MainPanel(

// combat log file
c2.gridy++
add(LabelPanel("Combat log file", combatLogField), c2)
add(LabelPanel("Combat log file", combatLogField, gap = 3), c2)

// row size spinner
c2.gridy++
add(LabelPanel(
"Row Size",
rowSizeSpinner.apply { preferredSize = Dimension(70, preferredSize.height) },
gap = 71
), c2)

// 2x button group
c2.gridy++
Expand Down Expand Up @@ -365,6 +388,9 @@ class MainPanel(
private fun shortcutButtonPress(e: KeyEvent?) {
if (e != null) {
when (e.keyCode) {
KeyEvent.VK_SPACE -> {
println(table.tableHeader.height)
}
KeyEvent.VK_ESCAPE -> {
if (sidebar.isVisible) minimizeSidebarButtonClick(null)
else maximizeSidebarButtonClick(null)
Expand Down Expand Up @@ -428,6 +454,15 @@ class MainPanel(
damageTracker.updateIGN("")
}

/** Sets the font size for the table rows. */
@Suppress("UNUSED_PARAMETER")
private fun rowSizeSpinnerChange(e: ChangeEvent) {
val rowSize = (rowSizeSpinner.model as SpinnerNumberModel).number.toInt()
table.font = Font(font.name, font.style, rowSize)
table.tableHeader.font = table.font
table.rowHeight = table.font.size + 5
}

/** Resets the timer used by the damage tracker. */
@Suppress("UNUSED_PARAMETER")
private fun resetTimerButtonClick(e: ActionEvent?) { damageTracker.resetTimer() }
Expand Down Expand Up @@ -528,15 +563,19 @@ class MainPanel(
}

/** Creates a JPanel with a JLabel followed by the specified JComponents. */
private class LabelPanel(label: String, vararg components: JComponent)
private class LabelPanel(label: String, vararg components: JComponent, gap: Int = 0)
: JPanel(GridBagLayout()) {

init {
val c = GridBagConstraints()

// label
c.gridx = 0; c.gridy = 0
add(JLabel(label), c)
add(JLabel(label).apply {
if (gap > 0) {
preferredSize = Dimension(preferredSize.width + gap, preferredSize.height)
}
}, c)

// components
c.insets = Insets(0, 5, 0, 0)
Expand Down

0 comments on commit a522890

Please sign in to comment.