Skip to content
This repository has been archived by the owner on Apr 22, 2018. It is now read-only.

Commit

Permalink
Merge pull request #4 from edipo2s/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
edipo2s authored Jun 8, 2017
2 parents 9ec2ebc + 142bf3a commit e4389c2
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 51 deletions.
94 changes: 47 additions & 47 deletions .idea/modules/WabbaTrack.iml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ group 'com.ediposouza'
version '0.1'

buildscript {
ext.kotlin_version = '1.1.2-2'
ext.kotlin_version = '1.1.2-4'

repositories {
mavenCentral()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 25 additions & 2 deletions src/main/kotlin/com/ediposouza/TESLTracker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class TESLTracker : App(MainStageView::class) {
companion object {

val APP_NAME = "WabbaTrack"
val APP_VERSION = "0.2.2"
val APP_VERSION = "0.2.3"
val DEBUG_FILE_NAME = "WabbaTrack.debug"
val WABBATRACK_URL = "https://edipo2s.github.io/WabbaTrack/"

Expand Down Expand Up @@ -163,6 +163,8 @@ class TESLTracker : App(MainStageView::class) {
private lateinit var trayPopupMenu: PopupMenu
private lateinit var menuMyDecks: List<Any>
private lateinit var menuImportedDecks: List<Any>
private lateinit var elderScrollDetectionInvalidateJob: Job
private var elderScrollDetectionRunning = false
private val legendsIconStream: InputStream by lazy { TESLTracker::class.java.getResourceAsStream(iconName) }
private val mainWidget: MainWidget by lazy { MainWidget() }
private val loggerController by inject<LoggerController>()
Expand Down Expand Up @@ -251,7 +253,7 @@ class TESLTracker : App(MainStageView::class) {
Mixpanel.trackUser()
}
launch(CommonPool) {
startElderScrollDetection()
startGetWindowTitleCheck()
}
launch(CommonPool) {
delay(500)
Expand Down Expand Up @@ -615,6 +617,25 @@ class TESLTracker : App(MainStageView::class) {
}
}

suspend private fun startGetWindowTitleCheck() {
elderScrollDetectionInvalidateJob = launch(CommonPool) {
delay(DELAY_WINDOW_DETECTION * 2)
Logger.i("ElderScrollDetection thread stop")
elderScrollDetectionRunning = false
}
while (true) {
delay((ELDER_SCROLL_SPS * 1000L).toLong())
Logger.i("Checking ElderScrollDetection...")
if (!elderScrollDetectionRunning) {
Logger.i("Starting ElderScrollDetection thread")
elderScrollDetectionRunning = true
launch(CommonPool) {
startElderScrollDetection()
}
}
}
}

suspend private fun startElderScrollDetection() {
TESLTrackerData.updateCardDB()
Logger.d("Using ${referenceConfig.SCREEN_REFERENCE} as reference")
Expand All @@ -623,6 +644,8 @@ class TESLTracker : App(MainStageView::class) {
}
Logger.i("Waiting Elder scroll legends..")
while (true) {
elderScrollDetectionInvalidateJob.cancel()
elderScrollDetectionInvalidateJob.start()
if (isTESLegendsScreenActive()) {
Logger.i("Elder scroll legends detected!")
Mixpanel.postEventGameDetected()
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/com/ediposouza/data/PHashCards.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ object DHashCards {
"0110111100010001111111100000011011101010001100111010101111100111011000111001110011101010011001010001100010011100011100101" to "masterofthieves",
"1000101010100100000000101100101100011111010101110010010011000011001001101111000001011010000110100001101100100000000010111" to "merricataswala",
"1011011100100110111111111111010011110110000001001001110000001001000000111100111001100101110111010011100101000000000110100" to "militantchieftain",
"0101111000100001000011110100001111010111000111010111000110001001100011001100001111110100101101101111100000110110001110010" to "protectorofthemane",
"1001110000000110000110111100110110110111010111000101101100110001110001000111010010111101000011110001100010111100010010010" to "queenbarenziah",
"0011011000001101001011111110000101011001000000001001111110101001001110000001001010001101000101010011010100001010100101110" to "redbramman",
"0100111000100010110000001110001010101110011000011110100010011000010000011010001000111000101000100001000111111010100010110" to "riftthane",
Expand Down
4 changes: 4 additions & 0 deletions src/main/kotlin/com/ediposouza/state/GameState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ object GameState : StateHandler.TESLState {
playerGoFirst = null
playerDeckClass = null
playerRank = null
playerRankLegend = null
opponentDeckClass = null
opponentRank = null
lastCardDraw = null
Expand Down Expand Up @@ -313,6 +314,9 @@ object GameState : StateHandler.TESLState {
fun isDeckTrackerVisible() = deckTracker.isVisible

fun showDeckTracker(forceShow: Boolean = false) {
if (forceShow) {
deckTracker.resetZoom()
}
if (forceShow || (deckCardsSlot.isNotEmpty() && shouldShowDeckTracker)) {
deckTracker.isVisible = true
}
Expand Down
7 changes: 6 additions & 1 deletion src/main/kotlin/com/ediposouza/ui/DeckTrackerWidget.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ import javax.swing.SwingUtilities
*/
class DeckTrackerWidget : JFrame() {

private val DEFAULT_ZOOM = 0.9f
private val deckCardsSlot: ObservableList<CardSlot> = FXCollections.observableArrayList<CardSlot>()
private var deckTrackerZoom: Float = 0.8f.takeIf { GameState.matchMode == MatchMode.ARENA } ?: 0.9f
private var deckTrackerZoom: Float = 0.8f.takeIf { GameState.matchMode == MatchMode.ARENA } ?: DEFAULT_ZOOM
private lateinit var deckTrackerSize: Dimension

var deckName: String? = null
Expand Down Expand Up @@ -316,6 +317,10 @@ class DeckTrackerWidget : JFrame() {
}
}

fun resetZoom() {
deckTrackerZoom = DEFAULT_ZOOM
}

private fun updateDeckCover() {
val frameCoverStream = TESLTracker::class.java.getResourceAsStream("/UI/frameCover.png")
val deckClass = DeckClass.getClasses(deckCardsSlot.groupBy { it.card.attr }.keys.toList()).firstOrNull()
Expand Down

0 comments on commit e4389c2

Please sign in to comment.