Moon64 v1.0.1

This commit is contained in:
KiritoDev 2021-06-22 00:31:10 -05:00
parent cb0e70e98d
commit 6fbd54ae60
7 changed files with 96 additions and 17 deletions

View File

@ -30,6 +30,7 @@
#include <math.h> #include <math.h>
#include "pc/gfx/gfx_pc.h" #include "pc/gfx/gfx_pc.h"
#include "moon/utils/moon-gfx.h" #include "moon/utils/moon-gfx.h"
#include "moon/ui/screens/options/main-view.h"
u16 gDialogColorFadeTimer; u16 gDialogColorFadeTimer;
s8 gLastDialogLineNum; s8 gLastDialogLineNum;
@ -1252,7 +1253,7 @@ void render_pause_red_coins(void) {
s8 x; s8 x;
for (x = 0; x < gRedCoinsCollected; x++) { for (x = 0; x < gRedCoinsCollected; x++) {
print_animated_red_coin(GFX_DIMENSIONS_FROM_RIGHT_EDGE(30) - x * 20, 16); print_animated_red_coin(GFX_DIMENSIONS_FROM_RIGHT_EDGE(12) - x * 20, 30);
} }
} }
@ -1538,6 +1539,7 @@ s16 render_pause_courses_and_castle(void) {
case DIALOG_STATE_VERTICAL: case DIALOG_STATE_VERTICAL:
shade_screen(); shade_screen();
render_pause_my_score_coins(); render_pause_my_score_coins();
drawIngameMenuButtons();
render_pause_red_coins(); render_pause_red_coins();
/* Added support for the "Exit course at any time" cheat */ /* Added support for the "Exit course at any time" cheat */
@ -1563,6 +1565,7 @@ s16 render_pause_courses_and_castle(void) {
case DIALOG_STATE_HORIZONTAL: case DIALOG_STATE_HORIZONTAL:
shade_screen(); shade_screen();
print_hud_pause_colorful_str(); print_hud_pause_colorful_str();
drawIngameMenuButtons();
render_pause_castle_menu_box(160, 143); render_pause_castle_menu_box(160, 143);
render_pause_castle_main_strings(104, 60); render_pause_castle_main_strings(104, 60);

View File

@ -51,8 +51,8 @@ namespace AchievementList {
Achievement* GET_6_LEVEL_STARS = MoonAchievements::bind(new Achievement("achievement.get6MainStars", "textures/moon/achievements/ranks.f.rgba16", "F Rank", "Get all 6 Main Stars in One Level", false, 0, 150, nullptr)); Achievement* GET_6_LEVEL_STARS = MoonAchievements::bind(new Achievement("achievement.get6MainStars", "textures/moon/achievements/ranks.f.rgba16", "F Rank", "Get all 6 Main Stars in One Level", false, 0, 150, nullptr));
Achievement* GET_100_COIN_STAR = MoonAchievements::bind(new Achievement("achievement.get100CoinStar", "textures/moon/achievements/ranks.e.rgba16", "E Rank", "Get a 100 Coin Star in One Level", false, 0, 150, nullptr)); Achievement* GET_100_COIN_STAR = MoonAchievements::bind(new Achievement("achievement.get100CoinStar", "textures/moon/achievements/ranks.e.rgba16", "E Rank", "Get a 100 Coin Star in One Level", false, 0, 150, nullptr));
Achievement* GET_ALL_LVL_COINS = MoonAchievements::bind(new Achievement("achievement.getAllCoins", "textures/moon/achievements/ranks.d.rgba16", "D Rank", "Get all Coins in One Level", false, 0, 150, nullptr)); Achievement* GET_ALL_LVL_COINS = MoonAchievements::bind(new Achievement("achievement.getAllCoins", "textures/moon/achievements/ranks.d.rgba16", "D Rank", "Get all Coins in One Level", false, 0, 150, nullptr));
Achievement* GET_FLOOR_0_STARS = MoonAchievements::bind(new Achievement("achievement.getAllStarsInBasement", "textures/moon/achievements/ranks.b.rgba16", "B Rank", "Get all Main Stars in the Basement", false, 0, 150, nullptr)); Achievement* GET_FLOOR_0_STARS = MoonAchievements::bind(new Achievement("achievement.getAllStarsInBasement", "textures/moon/achievements/ranks.b.rgba16", "B Rank", "Get all Main Stars in the First Floor", false, 0, 150, nullptr));
Achievement* GET_FLOOR_1_STARS = MoonAchievements::bind(new Achievement("achievement.getAllStarsInFloor1", "textures/moon/achievements/ranks.c.rgba16", "C Rank", "Get all Main Stars in the First Floor", false, 0, 150, nullptr)); Achievement* GET_FLOOR_1_STARS = MoonAchievements::bind(new Achievement("achievement.getAllStarsInFloor1", "textures/moon/achievements/ranks.c.rgba16", "C Rank", "Get all Main Stars in the Basement", false, 0, 150, nullptr));
Achievement* GET_FLOOR_2_STARS = MoonAchievements::bind(new Achievement("achievement.getAllStarsInFloor2", "textures/moon/achievements/ranks.a.rgba16", "A Rank", "Get all Main Stars in the Second Floor", false, 0, 150, nullptr)); Achievement* GET_FLOOR_2_STARS = MoonAchievements::bind(new Achievement("achievement.getAllStarsInFloor2", "textures/moon/achievements/ranks.a.rgba16", "A Rank", "Get all Main Stars in the Second Floor", false, 0, 150, nullptr));
Achievement* GET_FLOOR_3_STARS = MoonAchievements::bind(new Achievement("achievement.getAllStarsInFloor3", "textures/moon/achievements/ranks.s.rgba16", "S Rank", "Get all Main Stars in the Third Floor", false, 0, 150, nullptr)); Achievement* GET_FLOOR_3_STARS = MoonAchievements::bind(new Achievement("achievement.getAllStarsInFloor3", "textures/moon/achievements/ranks.s.rgba16", "S Rank", "Get all Main Stars in the Third Floor", false, 0, 150, nullptr));
Achievement* GET_CASTLE_STARS = MoonAchievements::bind(new Achievement("achievement.getAllCastleStars", "textures/moon/achievements/ranks.splus.rgba16", "S+ Rank", "Get all Castle Secret Stars", false, 0, 150, nullptr)); Achievement* GET_CASTLE_STARS = MoonAchievements::bind(new Achievement("achievement.getAllCastleStars", "textures/moon/achievements/ranks.splus.rgba16", "S+ Rank", "Get all Castle Secret Stars", false, 0, 150, nullptr));
@ -73,7 +73,7 @@ namespace AchievementList {
/* Death Achievements */ /* Death Achievements */
Achievement* DEATH_BY_BOSS = MoonAchievements::bind(new Achievement("achievement.deathByBoss", "textures/moon/achievements/deaths.boss.rgba16", "Git Gud", "Get killed by a boss", false, 0, 150, nullptr)); Achievement* DEATH_BY_BOSS = MoonAchievements::bind(new Achievement("achievement.deathByBoss", "textures/moon/achievements/deaths.boss.rgba16", "Git Gud", "Get killed by a boss", false, 0, 150, nullptr));
Achievement* DEATH_BY_FALLING = MoonAchievements::bind(new Achievement("achievement.deathByFalling", "textures/moon/achievements/deaths.falling.rgba16", "My Leg!", "Die by falling", false, 0, 150, nullptr)); Achievement* DEATH_BY_FALLING = MoonAchievements::bind(new Achievement("achievement.deathByFalling", "textures/moon/achievements/deaths.falling.rgba16", "My Leg!", "Die by falling", false, 0, 150, nullptr));
Achievement* DEATH_BY_SAND = MoonAchievements::bind(new Achievement("achievement.deathBySand", "textures/moon/achievements/deaths.quicksand.rgba16", "Sinreked", "Die by sinking sand", false, 0, 150, nullptr)); Achievement* DEATH_BY_SAND = MoonAchievements::bind(new Achievement("achievement.deathBySand", "textures/moon/achievements/deaths.quicksand.rgba16", "Sinked", "Die in the quicksand", false, 0, 150, nullptr));
Achievement* DEATH_BY_CRUSHING = MoonAchievements::bind(new Achievement("achievement.deathByCrushing", "textures/moon/achievements/deaths.crushed.rgba16", "Space Jam", "Get crushed", false, 0, 150, nullptr)); Achievement* DEATH_BY_CRUSHING = MoonAchievements::bind(new Achievement("achievement.deathByCrushing", "textures/moon/achievements/deaths.crushed.rgba16", "Space Jam", "Get crushed", false, 0, 150, nullptr));
Achievement* DEATH_BY_BOWSER = MoonAchievements::bind(new Achievement("achievement.deathByBowser", "textures/moon/achievements/deaths.bowser.rgba16", "Bad Ending", "Get killed by Bowser", false, 0, 150, nullptr)); Achievement* DEATH_BY_BOWSER = MoonAchievements::bind(new Achievement("achievement.deathByBowser", "textures/moon/achievements/deaths.bowser.rgba16", "Bad Ending", "Get killed by Bowser", false, 0, 150, nullptr));
Achievement* DEATH_BY_ENEMY = MoonAchievements::bind(new Achievement("achievement.deathByEnemy", "textures/moon/achievements/deaths.standard.rgba16", "Classic Way", "Get killed by a normal enemy", false, 0, 150, nullptr)); Achievement* DEATH_BY_ENEMY = MoonAchievements::bind(new Achievement("achievement.deathByEnemy", "textures/moon/achievements/deaths.standard.rgba16", "Classic Way", "Get killed by a normal enemy", false, 0, 150, nullptr));
@ -87,7 +87,7 @@ namespace AchievementList {
Achievement* TALK_25_TIMES = MoonAchievements::bind(new Achievement("achievement.talk25Times", "textures/moon/achievements/extras.talker.rgba16", "Olympic Talker", "Talk 25 times with npcs", false, 0, 150, nullptr)); Achievement* TALK_25_TIMES = MoonAchievements::bind(new Achievement("achievement.talk25Times", "textures/moon/achievements/extras.talker.rgba16", "Olympic Talker", "Talk 25 times with npcs", false, 0, 150, nullptr));
Achievement* JUMP_1000_TIMES = MoonAchievements::bind(new Achievement("achievement.jump1000Times", "textures/moon/achievements/extras.swimmer.rgba16", "Olympic Swimmer", "Grab every star that needs Metal Cap without it", false, 0, 150, nullptr)); Achievement* JUMP_1000_TIMES = MoonAchievements::bind(new Achievement("achievement.jump1000Times", "textures/moon/achievements/extras.swimmer.rgba16", "Olympic Swimmer", "Grab every star that needs Metal Cap without it", false, 0, 150, nullptr));
Achievement* WATCH_END_CREDITS = MoonAchievements::bind(new Achievement("achievement.watchEndCredits", "textures/moon/achievements/extras.cake.rgba16", "The Cake Is A Lie?!", "Watch the end credits", false, 0, 150, nullptr)); Achievement* WATCH_END_CREDITS = MoonAchievements::bind(new Achievement("achievement.watchEndCredits", "textures/moon/achievements/extras.cake.rgba16", "The Cake Is A Lie?!", "Watch the end credits", false, 0, 150, nullptr));
Achievement* RELEASE_CHAIN_CHOMP = MoonAchievements::bind(new Achievement("achievement.releaseChainChomp", "textures/moon/achievements/extras.chain-chomp.rgba16", "Who Let The Dog Out?", "Get killed by a boss", false, 0, 150, nullptr)); Achievement* RELEASE_CHAIN_CHOMP = MoonAchievements::bind(new Achievement("achievement.releaseChainChomp", "textures/moon/achievements/extras.chain-chomp.rgba16", "Chain-Chomp Unleashed", "Unleash the Chain-Chomp", false, 0, 150, nullptr));
Achievement* CHEATER = MoonAchievements::bind(new Achievement("achievement.cheater", "mod-icons://Moon64", "What a loser!", "You turned on cheats", false, 0, 150, nullptr)); Achievement* CHEATER = MoonAchievements::bind(new Achievement("achievement.cheater", "mod-icons://Moon64", "What a loser!", "You turned on cheats", false, 0, 150, nullptr));
}; };
@ -339,7 +339,9 @@ namespace Moon {
if(cheatsGotEnabled || gCurrDemoInput) return; if(cheatsGotEnabled || gCurrDemoInput) return;
if(find_if(entries[gCurrSaveFileNum - 1].begin(), entries[gCurrSaveFileNum - 1].end(), [&cae = achievement] (auto &m) -> bool { return cae->id == m->achievement->id; }) != entries[gCurrSaveFileNum - 1].end()) return; if(find_if(entries[gCurrSaveFileNum - 1].begin(), entries[gCurrSaveFileNum - 1].end(), [&cae = achievement] (auto &m) -> bool { return cae->id == m->achievement->id; }) != entries[gCurrSaveFileNum - 1].end()) return;
#ifdef GAME_DEBUG
cout << "Achievement got triggered: " << achievement->title << endl; cout << "Achievement got triggered: " << achievement->title << endl;
#endif
entries[gCurrSaveFileNum - 1].push_back(new AchievementEntry({ .launchTime = 0, .dead = false, .achievement = achievement, .entryID = entries.size() })); entries[gCurrSaveFileNum - 1].push_back(new AchievementEntry({ .launchTime = 0, .dead = false, .achievement = achievement, .entryID = entries.size() }));
} }

View File

@ -142,6 +142,20 @@ void MoonOptMain::Draw(){
MoonScreen::Draw(); MoonScreen::Draw();
} }
extern "C" {
void drawIngameMenuButtons(){
if(!(gGlobalTimer % 20))
stickAnim = !stickAnim;
string basePath = "textures/moon/controller/";
basePath.append(stickAnim ? "stick-down.rgba16" : "stick-up.rgba16");
MoonDrawButton(5, GetScreenHeight() - 24, "Move", basePath, 16, 0, false, false);
MoonDrawButton(7, GetScreenHeight() - 24, "Open settings", "textures/moon/controller/r-btn.rgba16", 10, 4, true, false);
}
}
void MoonOptMain::Dispose(){ void MoonOptMain::Dispose(){
configfile_save(configfile_name()); configfile_save(configfile_name());

View File

@ -1,7 +1,8 @@
#ifndef MoonScreenTest #ifndef MoonScreenTest
#define MoonScreenTest #define MoonScreenTest
#include "moon/ui/interfaces/moon-screen.h"
#ifdef __cplusplus
#include "moon/ui/interfaces/moon-screen.h"
class MoonOptMain : public MoonScreen { class MoonOptMain : public MoonScreen {
public: public:
void Init(); void Init();
@ -13,6 +14,10 @@ private:
void setCategory(int index); void setCategory(int index);
bool stickAnim = 0; bool stickAnim = 0;
}; };
#else
void drawIngameMenuButtons();
#endif
#endif #endif

View File

@ -118,7 +118,7 @@ void MoonDrawButton(int x, int y, std::string text, std::string texture, int siz
x = GetScreenWidth(false) - x; x = GetScreenWidth(false) - x;
int txtWidth = MoonGetTextWidth(text, 0.8, false); int txtWidth = MoonGetTextWidth(text, 0.8, false);
MoonDrawTexture(GFX_DIMENSIONS_FROM_LEFT_EDGE(x) - txtWidth - size - 3, y - 3 + offset, size, size, sys_strdup(texture.c_str())); MoonDrawTexture(GFX_DIMENSIONS_FROM_LEFT_EDGE(x) - txtWidth - size - 5, y - 3 + offset, size, size, sys_strdup(texture.c_str()));
MoonDrawText(x - txtWidth, y, text, 0.8, {255, 255, 255, 255}, true, false); MoonDrawText(x - txtWidth, y, text, 0.8, {255, 255, 255, 255}, true, false);
} }
} }

View File

@ -147,6 +147,11 @@ void unselectWidget(MWValue* base){
} }
void MWValue::Update(){ void MWValue::Update(){
if(IsBtnPressed(MoonButtons::A_BTN) && this->bind.btn != nullptr && this->selected){
this->bind.btn();
return;
}
if(!this->focused) return; if(!this->focused) return;
float xStick = GetStickValue(MoonButtons::L_STICK, false); float xStick = GetStickValue(MoonButtons::L_STICK, false);
@ -154,8 +159,8 @@ void MWValue::Update(){
bool isArray = this->bind.values != NULL && this->bind.index != NULL; bool isArray = this->bind.values != NULL && this->bind.index != NULL;
bool isFloat = this->bind.fvar != NULL; bool isFloat = this->bind.fvar != NULL;
bool isInt = this->bind.ivar != NULL; bool isInt = this->bind.ivar != NULL;
bool isBtn = this->bind.btn != NULL;
bool isBind = this->bind.bindKeys != NULL; bool isBind = this->bind.bindKeys != NULL;
bool isBtn = this->bind.btn != NULL;
float maxValue = isArray ? (*this->bind.values).size() - 1 : this->bind.max - int(isBind); float maxValue = isArray ? (*this->bind.values).size() - 1 : this->bind.max - int(isBind);
float minValue = isArray || isBind ? 0 : this->bind.min; float minValue = isArray || isBind ? 0 : this->bind.min;
@ -163,7 +168,6 @@ void MWValue::Update(){
if(IsBtnPressed(MoonButtons::A_BTN)){ if(IsBtnPressed(MoonButtons::A_BTN)){
if(isBtn){ if(isBtn){
unselectWidget(this);
this->bind.btn(); this->bind.btn();
return; return;
} }

View File

@ -14,6 +14,13 @@
#include "moon/texts/moon-loader.h" #include "moon/texts/moon-loader.h"
#include "moon/utils/moon-env.h" #include "moon/utils/moon-env.h"
#include "moon/achievements/achievements.h"
extern "C" {
#include "pc/platform.h"
#include "game/level_update.h"
}
#define DISCORDLIBFILE "libdiscord-rpc" #define DISCORDLIBFILE "libdiscord-rpc"
// Thanks Microsoft for being non posix compliant // Thanks Microsoft for being non posix compliant
@ -35,8 +42,8 @@
#endif #endif
#define DISCORDLIB DISCORDLIBFILE DISCORDLIBEXT #define DISCORDLIB DISCORDLIBFILE DISCORDLIBEXT
#define DISCORD_APP_ID "709083908708237342" #define DISCORD_APP_ID "856717153431453716"
#define DISCORD_UPDATE_RATE 5 #define DISCORD_UPDATE_RATE 3
using namespace std; using namespace std;
@ -60,6 +67,12 @@ Discord_Shutdown discordShutdown;
Discord_ClearPresence discordClearPresence; Discord_ClearPresence discordClearPresence;
Discord_UpdatePresence discordUpdatePresence; Discord_UpdatePresence discordUpdatePresence;
static s16 lastHealth = -1;
static s16 lastStarAmount = 0;
static s16 lastAchievements = 0;
static s16 lastCourseNum = -1; static s16 lastCourseNum = -1;
static s16 lastActNum = -1; static s16 lastActNum = -1;
bool reloadRPC = false; bool reloadRPC = false;
@ -197,19 +210,55 @@ static void set_state(void) {
} }
} }
void set_logo(void) { string getLevelLogo(){
if (lastCourseNum) switch(lastCourseNum){
snprintf(largeImageKey, sizeof(largeImageKey), "%d", lastCourseNum); case 0:
else return "level-peach";
strcpy(largeImageKey, "0"); case 6:
return "moon64-logo";
case 9:
return "level-3";
case 16:
case 17:
case 18:
return "level-bowser";
default:
return "level-"+to_string(lastCourseNum);
}
}
discordRichPresence.largeImageKey = largeImageKey; void set_logo(void) {
discordRichPresence.largeImageKey = sys_strdup(getLevelLogo().data());
} }
void DiscordReloadPresence() { void DiscordReloadPresence() {
reloadRPC = true; reloadRPC = true;
} }
void set_health(){
if(gCurrCourseNum == 0) return;
if(lastHealth != gHudDisplay.wedges){
lastHealth = gHudDisplay.wedges;
string new_health_icon = "health-"+to_string(lastHealth);
string new_health_text = to_string(lastHealth) + " HP";
discordRichPresence.smallImageKey = sys_strdup(new_health_icon.data());
discordRichPresence.smallImageText = sys_strdup(new_health_text.data());
}
}
void set_image_key(){
if(gCurrCourseNum == 0) return;
int size = entries[gCurrSaveFileNum - 1].size();
if(lastAchievements != size || lastStarAmount != gHudDisplay.stars){
lastAchievements = size;
lastStarAmount = gHudDisplay.stars;
string new_text = to_string(lastStarAmount) + "/120 Stars - " + to_string(lastAchievements) + "/" + to_string(registeredAchievements.size()) + " Achievements";
discordRichPresence.largeImageText = sys_strdup(new_text.data());
}
}
void DiscordUpdatePresence(){ void DiscordUpdatePresence(){
if (!configDiscordRPC || !initd) return; if (!configDiscordRPC || !initd) return;
if (time(NULL) < lastUpdatedTime + DISCORD_UPDATE_RATE) return; if (time(NULL) < lastUpdatedTime + DISCORD_UPDATE_RATE) return;
@ -219,6 +268,8 @@ void DiscordUpdatePresence(){
set_state(); set_state();
set_details(); set_details();
set_logo(); set_logo();
set_health();
set_image_key();
discordUpdatePresence(&discordRichPresence); discordUpdatePresence(&discordRichPresence);
reloadRPC = false; reloadRPC = false;
} }