-
Notifications
You must be signed in to change notification settings - Fork 28
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
054f60c
commit 774bf54
Showing
17 changed files
with
1,301 additions
and
36 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
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,17 @@ | ||
#pragma once | ||
|
||
#include <csight/core> | ||
#include <pu/Plutonium> | ||
#include <vector> | ||
|
||
class PokemonTypeLayout : public pu::ui::Layout { | ||
public: | ||
PU_SMART_CTOR(PokemonTypeLayout) | ||
void SetTypeMatchUps(std::vector<csight::type::TypeMultiplier> defensiveMatchUps, | ||
std::vector<csight::type::TypeMultiplier> offensiveMatchUps); | ||
|
||
private: | ||
void AddMatchUpBlock(std::vector<csight::type::TypeMultiplier> matchUps, std::string header, std::string firstMatchUpName, | ||
std::string secondMatchUpName, u32 baseX); | ||
void AddMatchUpText(std::vector<csight::type::TypeMultiplier> matchUps, std::string matchUpName, u32 x, u32 y); | ||
}; |
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
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,62 @@ | ||
#include <csight/core> | ||
#include <functional> | ||
#include <ui/MainApplication.hpp> | ||
#include <ui/PokemonSprite.hpp> | ||
#include <ui/elements/RoundedRectangle.hpp> | ||
#include <ui/views/PokemonTypeLayout.hpp> | ||
#include <utils/Constants.hpp> | ||
#include <utils/I18N.hpp> | ||
#include <utils/Settings.hpp> | ||
|
||
extern MainApplication::Ref mainApp; | ||
extern Settings gsets; | ||
extern std::shared_ptr<I18N> i18n; | ||
|
||
void PokemonTypeLayout::SetTypeMatchUps(std::vector<csight::type::TypeMultiplier> defensiveMatchUps, | ||
std::vector<csight::type::TypeMultiplier> offensiveMatchUps) { | ||
this->Clear(); | ||
this->AddMatchUpBlock(defensiveMatchUps, "Defense", "Weakness", "Resistance", 50); | ||
this->AddMatchUpBlock(offensiveMatchUps, "Offense", "Strength", "Resistance", 650); | ||
} | ||
|
||
void PokemonTypeLayout::AddMatchUpBlock(std::vector<csight::type::TypeMultiplier> matchUps, std::string header, | ||
std::string firstMatchUpName, std::string secondMatchUpName, u32 baseX) { | ||
u32 baseY = 50; | ||
u32 headerY = baseY + 25; | ||
u32 matchUpY = headerY + 40; | ||
u32 matchUpX = baseX + 25; | ||
auto theme = gsets.GetTheme(); | ||
auto secondMatchUpStart | ||
= std::find_if(matchUps.begin(), matchUps.end(), [](auto typeMatchUp) { return typeMatchUp.multiplier < 1; }); | ||
std::vector<csight::type::TypeMultiplier> firstMatchUp(matchUps.begin(), secondMatchUpStart); | ||
std::vector<csight::type::TypeMultiplier> secondMatchUp(secondMatchUpStart, matchUps.end()); | ||
auto background = RoundedRectangle::New(baseX, baseY, 550, 600, theme.background.light, 5); | ||
auto headerTextBlock = pu::ui::elm::TextBlock::New(matchUpX, headerY, header, 35); | ||
headerTextBlock->SetColor(theme.text.light); | ||
|
||
this->Add(background); | ||
this->Add(headerTextBlock); | ||
this->AddMatchUpText(firstMatchUp, firstMatchUpName, matchUpX, matchUpY); | ||
this->AddMatchUpText(secondMatchUp, secondMatchUpName, matchUpX + 250, matchUpY); | ||
} | ||
|
||
void PokemonTypeLayout::AddMatchUpText(std::vector<csight::type::TypeMultiplier> matchUps, std::string matchUpName, u32 x, | ||
u32 y) { | ||
auto matchUpNameY = y + 25; | ||
auto matchUpYOffset = matchUpNameY + 60; | ||
auto theme = gsets.GetTheme(); | ||
auto matchUpNameTextBlock = pu::ui::elm::TextBlock::New(x, matchUpNameY, matchUpName, 26); | ||
matchUpNameTextBlock->SetColor(theme.text.light); | ||
|
||
this->Add(matchUpNameTextBlock); | ||
|
||
for (u32 i = 0; i < matchUps.size(); i++) { | ||
auto matchUp = matchUps[i]; | ||
auto typeName = csight::utils::getTypeName(matchUp.type); | ||
auto matchUpText = typeName + " " + csight::utils::convertFloatWithPrecision(matchUp.multiplier, 2); | ||
u32 matchUpY = matchUpYOffset + (i * 40); | ||
auto matchUpTextBlock = pu::ui::elm::TextBlock::New(x, matchUpY, matchUpText, 20); | ||
matchUpTextBlock->SetColor(theme.text.light); | ||
this->Add(matchUpTextBlock); | ||
} | ||
} |
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,46 @@ | ||
#pragma once | ||
|
||
#include <algorithm> | ||
#include <csight/Utils.hpp> | ||
#include <csight/lookups/Types.hpp> | ||
#include <future> | ||
#include <string> | ||
#include <switch.h> | ||
#include <vector> | ||
|
||
namespace csight { | ||
class PKM { | ||
public: | ||
virtual u16 GetSpecies() = 0; | ||
virtual std::string GetSpeciesString() = 0; | ||
virtual std::vector<u8> GetIVs() = 0; | ||
virtual bool GetIsShiny() = 0; | ||
virtual ability::Ability GetAbility() = 0; | ||
virtual std::string GetAbilityString() = 0; | ||
virtual u32 GetPID() = 0; | ||
virtual u64 GetRaidSeed() = 0; | ||
virtual u8 GetForm() = 0; | ||
u32 GetPSV() { | ||
u32 pid = this->GetPID(); | ||
return ((pid >> 16 ^ (pid & 0xFFFF)) >> 4); | ||
} | ||
std::pair<type::PokemonType, type::PokemonType> GetTypes() { | ||
auto form = this->GetForm(); | ||
auto species = this->GetSpecies(); | ||
auto resultIterator = std::find_if(type::PokemonTypeList.begin(), type::PokemonTypeList.end(), | ||
[species, form](auto type) { return type.species == species && type.form == form; }); | ||
auto result = resultIterator[0]; | ||
|
||
return std::make_pair(result.type1, result.type2); | ||
} | ||
std::vector<type::TypeMultiplier> GetTypeMatchUps(bool shouldGetWeakness) { | ||
auto types = this->GetTypes(); | ||
auto calculateTypeMatchUps = shouldGetWeakness ? utils::calculateWeakness : utils::calculateStrengths; | ||
auto typeMatchUps = calculateTypeMatchUps(types.first, types.second); | ||
std::sort(typeMatchUps.begin(), typeMatchUps.end(), | ||
[](auto type1, auto type2) { return type1.multiplier > type2.multiplier; }); | ||
|
||
return typeMatchUps; | ||
} | ||
}; | ||
} // namespace csight |
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.