Skip to content

Commit

Permalink
Show OT gender on Pokemon summary screen
Browse files Browse the repository at this point in the history
  • Loading branch information
zaksabeast committed Jul 2, 2020
1 parent f8365fb commit bb40948
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions CaptureSight-Applet/source/ui/views/PokemonSummaryView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace ui {
ADD_BODY_ROW(m_miscTable, friendshipTranslationKey, "app", std::to_string(pkm->getCurrentFriendship()));
ADD_BODY_ROW(m_miscTable, "EC", "app", csight::utils::convertNumToHexString(pkm->getEncryptionConstant()));
ADD_BODY_ROW(m_miscTable, "PID", "app", csight::utils::convertNumToHexString(pkm->getPID()));
ADD_BODY_ROW(m_miscTable, "OT Gender", "app", pkm->getOTGenderString());

m_ivTable = new brls::Table();
m_ivTable->addRow(brls::TableRowType::HEADER, "IVs");
Expand Down
7 changes: 7 additions & 0 deletions libcsight/include/csight/Gender.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace csight {
enum Gender {
Male = 0,
Female = 1,
Genderless = 2,
};
}
2 changes: 2 additions & 0 deletions libcsight/include/csight/PK8.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ namespace csight {
u8 getHTFriendship();
u8 getOTFriendship();
u8 getCurrentFriendship();
Gender getOTGender();
std::string PK8::getOTGenderString();
u64 getRaidSeed();
std::future<u64> getRaidSeedAsync();
u16 getForm();
Expand Down
3 changes: 3 additions & 0 deletions libcsight/include/csight/Utils.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <csight/Gender.hpp>
#include <csight/RaidTemplateTables.hpp>
#include <csight/Shiny.hpp>
#include <csight/lookups/Types.hpp>
Expand Down Expand Up @@ -54,6 +55,8 @@ namespace csight::utils {

std::string getShinyTypeString(shiny::ShinyType type);

std::string getGenderString(Gender gender);

std::vector<type::TypeMultiplier> calculateWeakness(type::PokemonType type1, type::PokemonType type2);

std::string convertFloatWithPrecision(float num, u32 precision);
Expand Down
1 change: 1 addition & 0 deletions libcsight/include/csight/core
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <csight/Den.hpp>
#include <csight/DenHashes.hpp>
#include <csight/GameReader.hpp>
#include <csight/Gender.hpp>
#include <csight/PK8.hpp>
#include <csight/RNG.hpp>
#include <csight/RaidDetails.hpp>
Expand Down
8 changes: 8 additions & 0 deletions libcsight/source/csight/PK8.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <algorithm>
#include <csight/CalculateRaidSeed.hpp>
#include <csight/Gender.hpp>
#include <csight/PK8.hpp>
#include <csight/PKM.hpp>
#include <csight/RNG.hpp>
Expand Down Expand Up @@ -197,6 +198,13 @@ namespace csight {

u8 PK8::getCurrentFriendship() { return this->getCurrentHandler() == 0 ? this->getOTFriendship() : this->getHTFriendship(); }

Gender PK8::getOTGender() {
u8 genderByte = *(u8 *)(m_data + 0x125) >> 7;
return genderByte < 2 ? (Gender)genderByte : Gender::Genderless;
}

std::string PK8::getOTGenderString() { return utils::getGenderString(this->getOTGender()); }

u64 PK8::getRaidSeed() { return raid::calculateRaidSeed(this->getEncryptionConstant(), this->getPID(), this->getIVs()); }

std::future<u64> PK8::getRaidSeedAsync() {
Expand Down
12 changes: 12 additions & 0 deletions libcsight/source/csight/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ namespace csight::utils {
}
}

std::string getGenderString(Gender gender) {
switch (gender) {
case Gender::Male:
return "Male";
case Gender::Female:
return "Female";
case Gender::Genderless:
default:
return "Genderless";
}
}

std::vector<type::TypeMultiplier> calculateWeakness(type::PokemonType type1, type::PokemonType type2) {
auto type1Weaknesses = weaknessChart[type1];
auto type2Weaknesses = weaknessChart[type2];
Expand Down

0 comments on commit bb40948

Please sign in to comment.