-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d3c7349
commit 4d62199
Showing
16 changed files
with
303 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
dist/src/main/kotlin/kr/toxicity/hud/background/HudBackground.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package kr.toxicity.hud.background | ||
|
||
import kr.toxicity.hud.image.ImageLocation | ||
import kr.toxicity.hud.image.LoadedImage | ||
|
||
class HudBackground( | ||
val name: String, | ||
|
||
val left: LoadedImage, | ||
val right: LoadedImage, | ||
val body: LoadedImage, | ||
|
||
val location: ImageLocation, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package kr.toxicity.hud.image | ||
|
||
class LocatedImage( | ||
val image: LoadedImage, | ||
val location: ImageLocation, | ||
val scale: Double | ||
) |
9 changes: 9 additions & 0 deletions
9
dist/src/main/kotlin/kr/toxicity/hud/layout/BackgroundLayout.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package kr.toxicity.hud.layout | ||
|
||
import kr.toxicity.hud.api.component.WidthComponent | ||
|
||
class BackgroundLayout( | ||
val left: WidthComponent, | ||
val right: WidthComponent, | ||
val body: WidthComponent | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
dist/src/main/kotlin/kr/toxicity/hud/manager/BackgroundManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package kr.toxicity.hud.manager | ||
|
||
import kr.toxicity.hud.background.HudBackground | ||
import kr.toxicity.hud.image.ImageLocation | ||
import kr.toxicity.hud.resource.GlobalResource | ||
import kr.toxicity.hud.util.* | ||
import java.io.File | ||
|
||
object BackgroundManager: BetterHudManager { | ||
|
||
private val backgroundMap = HashMap<String, HudBackground>() | ||
|
||
override fun start() { | ||
|
||
} | ||
|
||
fun getBackground(name: String) = backgroundMap[name] | ||
|
||
override fun reload(resource: GlobalResource) { | ||
val folder = DATA_FOLDER.subFolder("backgrounds") | ||
val outputParent = resource.textures.subFolder("background") | ||
backgroundMap.clear() | ||
folder.forEach { | ||
if (it.extension == "yml") { | ||
runCatching { | ||
val yaml = it.toYaml() | ||
val name = it.nameWithoutExtension | ||
val backgroundFolder = folder.subFolder(name) | ||
val output = outputParent.subFolder(name) | ||
fun getImage(imageName: String) = File(backgroundFolder, "$imageName.png") | ||
.ifNotExist("this image doesn't exist: $imageName.png in $name") | ||
.toImage() | ||
.removeEmptyWidth() | ||
.ifNull("this image is empty: $imageName.png in $name").apply { | ||
image.save(output.subFile("$imageName.png")) | ||
} | ||
backgroundMap[name] = HudBackground( | ||
name, | ||
getImage("left"), | ||
getImage("right"), | ||
getImage("body"), | ||
ImageLocation(yaml) | ||
) | ||
}.onFailure { e -> | ||
warn("Unable to load this yml: ${it.name}") | ||
warn("Reason: ${e.message}") | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun end() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,6 +162,5 @@ object DatabaseManagerImpl: BetterHudManager, DatabaseManager { | |
} | ||
|
||
override fun end() { | ||
current.close() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.