Skip to content

Commit

Permalink
1.0.31
Browse files Browse the repository at this point in the history
Icons for caught and shiny entries!
Hopefully fixed tabs rendering over hover-text on Where to Find
  • Loading branch information
Rafacasari committed Jun 30, 2024
1 parent 0e3d816 commit 57a0397
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import com.cobblemon.mod.common.pokemon.Species
import com.cobblemon.mod.common.util.math.fromEulerXYZDegrees
import com.rafacasari.mod.cobbledex.CobbledexConstants.Client.discoveredList
import com.rafacasari.mod.cobbledex.api.classes.DiscoveryRegister
import com.rafacasari.mod.cobbledex.client.gui.CobbledexGUI.Companion.SCALE
import com.rafacasari.mod.cobbledex.client.gui.CobbledexGUI.Companion.TYPE_SPACER
import com.rafacasari.mod.cobbledex.client.gui.CobbledexGUI.Companion.TYPE_SPACER_DOUBLE
import com.rafacasari.mod.cobbledex.client.widget.ImageButton
Expand All @@ -43,6 +42,7 @@ class CobbledexCollectionGUI : Screen(cobbledexTextTranslation("cobbledex")) {
const val BASE_WIDTH: Int = 349
const val BASE_HEIGHT: Int = 205
const val PORTRAIT_SIZE = 58F
const val SCALE = 0.5F

const val LINES_SIZE = 6
const val COLUMN_SIZE = 11
Expand All @@ -65,6 +65,9 @@ class CobbledexCollectionGUI : Screen(cobbledexTextTranslation("cobbledex")) {
private val LEFT_ARROW: Identifier = cobbledexResource("textures/gui/collection/left_arrow.png")
private val RIGHT_ARROW: Identifier = cobbledexResource("textures/gui/collection/right_arrow.png")

private val CAUGHT_ICON: Identifier = cobbledexResource("textures/gui/collection/pokeball.png")
private val SHINY_ICON: Identifier = cobbledexResource("textures/gui/collection/shiny_icon.png")

fun show(skipSound: Boolean = false) {
if (!skipSound) playSound(CobblemonSounds.PC_ON)

Expand Down Expand Up @@ -270,6 +273,9 @@ class CobbledexCollectionGUI : Screen(cobbledexTextTranslation("cobbledex")) {
species?.let {
val isMouseOver = mouseX.toDouble() in entryX .. (entryX + ENTRY_SIZE) && mouseY.toDouble() in entryY .. (entryY + ENTRY_SIZE)
val isDiscovered = discoveredList.contains(species.showdownId())
val isCaught = discoveredList[species.showdownId()]?.any { x -> x.value.status == DiscoveryRegister.RegisterType.CAUGHT } == true
val isShiny = discoveredList[species.showdownId()]?.any { x -> x.value.status == DiscoveryRegister.RegisterType.CAUGHT && x.value.isShiny } == true

if (lastHoveredEntry != species && isMouseOver) {
lastHoveredEntry = species
loadSpecies(species, isDiscovered)
Expand Down Expand Up @@ -321,6 +327,30 @@ class CobbledexCollectionGUI : Screen(cobbledexTextTranslation("cobbledex")) {

context.disableScissor()

if (isCaught) {
blitk(
matrixStack = matrices,
texture = CAUGHT_ICON,
x = (entryX + ENTRY_SIZE - (11 * SCALE) - 1F) / SCALE,
y = (entryY + 1F) / SCALE,
width = 11,
height = 11,
scale = SCALE,
alpha = 0.75f
)

if (isShiny)
blitk(
matrixStack = matrices,
texture = SHINY_ICON,
x = (entryX + ENTRY_SIZE - (11 * SCALE) - 1F) / SCALE,
y = (entryY + ENTRY_SIZE - (11 * SCALE) - 1) / SCALE,
width = 11,
height = 11,
scale = SCALE
)
}

drawScaledText(
context = context,
text = "${species.nationalPokedexNumber}".text(),
Expand All @@ -333,7 +363,6 @@ class CobbledexCollectionGUI : Screen(cobbledexTextTranslation("cobbledex")) {


if (isMouseOver && isDiscovered) {

discoveredList[species.showdownId()]?.let { entry ->
val tooltip: MutableList<Text> = mutableListOf()

Expand Down Expand Up @@ -429,11 +458,7 @@ class CobbledexCollectionGUI : Screen(cobbledexTextTranslation("cobbledex")) {

if ((!config.Collection_NeedCatch || hasCaught) && (!config.Collection_NeedSeen || hasSeen)) {
playSound(CobblemonSounds.PC_CLICK)
CobbledexGUI.openCobbledexScreen(
species.standardForm, setOf(),
skipSound = true,
cameFromCollection = true
)
CobbledexGUI.openCobbledexScreen(species.standardForm, species.standardForm.aspects.toSet(), skipSound = true)
}
return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ class CobbledexGUI(var selectedPokemon: FormData?, var selectedAspects: Set<Stri
Evolutions, PreEvolutions, Forms
}

companion object
{
companion object {
const val BASE_WIDTH: Int = 349
const val BASE_HEIGHT: Int = 205
const val SCALE = 0.5F
Expand All @@ -57,10 +56,10 @@ class CobbledexGUI(var selectedPokemon: FormData?, var selectedAspects: Set<Stri
internal val TYPE_SPACER: Identifier = cobbledexResource("textures/gui/type_spacer.png")
internal val TYPE_SPACER_DOUBLE: Identifier = cobbledexResource("textures/gui/type_spacer_double.png")

var Instance : CobbledexGUI? = null
var Instance: CobbledexGUI? = null


fun openCobbledexScreen(pokemon: FormData? = null, aspects: Set<String>? = null, skipSound: Boolean = false, cameFromCollection: Boolean = false) {
fun openCobbledexScreen(pokemon: FormData? = null, aspects: Set<String>? = null, skipSound: Boolean = false) {
if (!skipSound) playSound(CobblemonSounds.PC_ON)

Instance = CobbledexGUI(pokemon, aspects)
Expand All @@ -73,8 +72,8 @@ class CobbledexGUI(var selectedPokemon: FormData?, var selectedAspects: Set<Stri
}

var previewPokemon: FormData? = null
var selectedTab : CobbledexMenu = CobbledexMenu.Info
var selectedRelatedTab : CobbledexRelatedMenu = CobbledexRelatedMenu.Evolutions
var selectedTab: CobbledexMenu = CobbledexMenu.Info
var selectedRelatedTab: CobbledexRelatedMenu = CobbledexRelatedMenu.Evolutions

// Cache
private var lastLoadedSpecies: Species? = null
Expand Down Expand Up @@ -111,10 +110,30 @@ class CobbledexGUI(var selectedPokemon: FormData?, var selectedAspects: Set<Stri
previewPokemon = null
})

// Initialize Tabs
infoTabButton = CobbledexTab(x, y, x + 114, y + 178, cobbledexTextTranslation("tab.info")) {
selectedTab = CobbledexMenu.Info
defaultTabClickEvent()
}

battleTabButton = CobbledexTab(x, y, x + 151, y + 178, cobbledexTextTranslation("tab.battle")) {
selectedTab = CobbledexMenu.Battle
defaultTabClickEvent()
}

evolveTabButton = CobbledexTab(x, y, x + 188, y + 178, cobbledexTextTranslation("tab.evolve")) {
selectedTab = CobbledexMenu.Evolutions
defaultTabClickEvent()
}

// Add our tabs as a drawable child
addDrawableChild(infoTabButton)
addDrawableChild(battleTabButton)
addDrawableChild(evolveTabButton)

evolutionDisplay = PokemonEvolutionDisplay(x + 260, y + 37)
addDrawableChild(evolutionDisplay)


longTextDisplay = LongTextDisplay(x + 79, y + 18, 179, 158, 2)
addDrawableChild(longTextDisplay)

Expand All @@ -132,40 +151,17 @@ class CobbledexGUI(var selectedPokemon: FormData?, var selectedAspects: Set<Stri

// setPreview to the target or cached Pokémon
// Should be after essential widgets initialization (evolutionDisplay and longTextDisplay)
if (selectedPokemon == null)
{
if (selectedPokemon == null) {
// If there is no selected Pokémon and no preview, set to default
if (previewPokemon == null)
previewPokemon = PokemonSpecies.getByPokedexNumber(1)?.standardForm

this.setPreviewPokemon(previewPokemon)
}
else {
} else {
// selectedPokemon is null which means that it's from right-clicking a entity
this.setPreviewPokemon(selectedPokemon, selectedAspects)
}

// Initialize Tabs
infoTabButton = CobbledexTab(x, y,x + 114, y + 178, cobbledexTextTranslation("tab.info")) {
selectedTab = CobbledexMenu.Info
defaultTabClickEvent()
}

battleTabButton = CobbledexTab(x, y,x + 151, y + 178, cobbledexTextTranslation("tab.battle")) {
selectedTab = CobbledexMenu.Battle
defaultTabClickEvent()
}

evolveTabButton = CobbledexTab(x, y,x + 188, y + 178, cobbledexTextTranslation("tab.evolve")) {
selectedTab = CobbledexMenu.Evolutions
defaultTabClickEvent()
}

// Add our tabs as a drawable child
addDrawableChild(infoTabButton)
addDrawableChild(battleTabButton)
addDrawableChild(evolveTabButton)

addDrawableChild(ArrowButton(true, x + 262, y + 28) {
playSound(CobblemonSounds.GUI_CLICK)

Expand All @@ -180,7 +176,8 @@ class CobbledexGUI(var selectedPokemon: FormData?, var selectedAspects: Set<Stri
playSound(CobblemonSounds.GUI_CLICK)

val newTab = selectedRelatedTab.ordinal + 1
selectedRelatedTab = if (newTab > CobbledexRelatedMenu.entries.size - 1) CobbledexRelatedMenu.Evolutions else CobbledexRelatedMenu.entries[newTab]
selectedRelatedTab =
if (newTab > CobbledexRelatedMenu.entries.size - 1) CobbledexRelatedMenu.Evolutions else CobbledexRelatedMenu.entries[newTab]

updateRelatedSpecies()
evolutionDisplay?.resetScrollPosition()
Expand All @@ -205,7 +202,7 @@ class CobbledexGUI(var selectedPokemon: FormData?, var selectedAspects: Set<Stri
battleTabButton.setActive(selectedTab == CobbledexMenu.Battle)
evolveTabButton.setActive(selectedTab == CobbledexMenu.Evolutions)

when(selectedTab) {
when (selectedTab) {
CobbledexMenu.Info -> {
// Use cache to load spawnDetails
// We don't need to worry about being null, server should send information and packet handler will update automatically
Expand Down Expand Up @@ -370,8 +367,7 @@ class CobbledexGUI(var selectedPokemon: FormData?, var selectedAspects: Set<Stri
super.close()
}

fun setPreviewPokemon(pokemon: FormData?, formAspects: Set<String>? = null)
{
fun setPreviewPokemon(pokemon: FormData?, formAspects: Set<String>? = null) {
// TODO: Implement this when make the shiny/gender buttons
// This should be possible to get all possible choice-features
// Will be useful for Pokémon that have a lot of non-form variants (recolors)
Expand Down Expand Up @@ -417,30 +413,21 @@ class CobbledexGUI(var selectedPokemon: FormData?, var selectedAspects: Set<Stri
offsetY = -10.0
)

val typeOffset = 14f


typeWidget.primaryType = pokemon.primaryType
typeWidget.secondaryType = pokemon.secondaryType


} else {
previewPokemon = null
modelWidget = null

}
}



fun updateRelatedSpecies() {
if (previewPokemon == null || previewPokemon?.species != lastLoadedSpecies)
{
if (previewPokemon == null || previewPokemon?.species != lastLoadedSpecies) {
evolutionDisplay?.clearEvolutions()
return
}

when(selectedRelatedTab) {
when (selectedRelatedTab) {
CobbledexRelatedMenu.Evolutions -> {
// TODO: Rework the evolution display
evolutionDisplay?.selectEvolutions(lastLoadedEvolutions?.mapNotNull {
Expand All @@ -465,7 +452,12 @@ class CobbledexGUI(var selectedPokemon: FormData?, var selectedAspects: Set<Stri
}
}

fun updateInfoPage(species: Species?, spawnDetails: List<SerializablePokemonSpawnDetail>?, itemDrops: List<SerializableItemDrop>?, fromCache: Boolean = false) {
fun updateInfoPage(
species: Species?,
spawnDetails: List<SerializablePokemonSpawnDetail>?,
itemDrops: List<SerializableItemDrop>?,
fromCache: Boolean = false
) {
if (!fromCache) {
// If our call isn't from cache, then we can update the current cache
lastLoadedSpawnDetails = spawnDetails
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mod_id=cobbledex

generated_file_name_addon=-1.20.1
archives_base_name=cobbledex-1.20.1
mod_version=1.0.30
mod_version=1.0.31
mod_description=A mod to track your progress on Cobblemon. Fabric and Forge compatible.
mod_icon=assets/cobbledex/icon.png
repository=https://github.com/rafacasari/cobbledex
Expand Down

0 comments on commit 57a0397

Please sign in to comment.