Test round 1 fixes (headless harness, about 8M frames, 731 items, 41 characters, every floor and menu, entity sweeps and 1,100 fuzz runs): EntityList's destructor frees the room's entities on restart (00417e50, a pool leak that crashed long sweeps), the Online Awards stats page (Menu_OnlineAwards, 008e6a80), Mr. Me's wisp errand across rooms, the boss warning count, tooth, coin and stone tear sprite scale, NPC status first-match order, an effect's idle animation range
This commit is contained in:
1 parent
ff2c61a63a
commit
aefd3e2098
24 files changed
+231
-345
No files matched your search
@@ -1023,7 +1023,7 @@ static void beast_background(Entity_NPC& npc, Room& room)
|
||||
bool isWide = room.gridWidth >= BEAST_HORSEMAN_MIN_WIDTH && room.gridHeight >= BEAST_HORSEMAN_MIN_HEIGHT;
|
||||
Vector at = vector_add(room.GetGridPosition(isWide ? room.gridWidth * BEAST_HORSEMAN_ROW + BEAST_HORSEMAN_COLUMN : -1),
|
||||
vector_make(BEAST_HORSEMAN_RIGHT, 0));
|
||||
room.lastAliveBossCount = 0;
|
||||
room.entityList.bossMaxHealth = 0;
|
||||
Entity* horseman = nullptr;
|
||||
if (npc.i1 < BEAST_HORSEMEN)
|
||||
{
|
||||
|
||||
@@ -572,7 +572,7 @@ static bool brownie_death(Entity_NPC& npc, BrownieFrame& frame)
|
||||
npc.health = npc.maxHitPoints * BROWNIE_DANGLE_HEALTH;
|
||||
npc.maxHitPoints = npc.health;
|
||||
}
|
||||
g_game->room->lastAliveBossCount = 0;
|
||||
g_game->room->entityList.bossMaxHealth = 0;
|
||||
npc.entityCollisionClass = ENTCOLL_ALL;
|
||||
npc.state = NPC_STATE_INIT;
|
||||
return true;
|
||||
|
||||
@@ -444,7 +444,7 @@ static void leech_explosion_init(Entity_Effect& explosion)
|
||||
}
|
||||
|
||||
// Part of 005cdb20 (Init's case 142) The whirlpool and its particles take the water's color, the particles on the
|
||||
// floor on one of four idles.
|
||||
// floor on one of four idles (Idle1 to Idle4).
|
||||
static void whirlpool_init(Entity_Effect& whirlpool)
|
||||
{
|
||||
ColorMod& water = g_game->room->fxLayers.fxParams.waterEffectColor;
|
||||
@@ -456,7 +456,7 @@ static void whirlpool_init(Entity_Effect& whirlpool)
|
||||
}
|
||||
|
||||
whirlpool.sortingLayer = SORTING_BACKGROUND;
|
||||
int idle = whirlpool.dropRNG.RandomInt(WHIRLPOOL_PARTICLE_IDLES);
|
||||
int idle = whirlpool.dropRNG.RandomInt(WHIRLPOOL_PARTICLE_IDLES) + 1;
|
||||
whirlpool.sprite.Play("Idle" + std::to_string(idle));
|
||||
whirlpool.sprite.color = water;
|
||||
for (int i = 0; i < 3; i++) whirlpool.sprite.color._offset[i] = WHIRLPOOL_PARTICLE_OFFSET;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "entity/weapon/tear.h"
|
||||
#include "entity/familiar/gello.h"
|
||||
#include "entity/familiar/variants.h"
|
||||
#include "entity/familiar/wisp.h"
|
||||
#include "entity/boss/ai.h"
|
||||
#include "game/game.h"
|
||||
#include "level/generator.h"
|
||||
@@ -904,6 +905,8 @@ void Entity_Familiar::room_enter()
|
||||
case VANISHING_TWIN: vanishing_twin_room_enter(*this); break;
|
||||
case UMBILICAL_BABY: umbilical_baby_room_enter(*this); break;
|
||||
case WISP:
|
||||
wisp_room_enter(*this);
|
||||
[[fallthrough]];
|
||||
case ITEM_WISP: pos = GetOrbitPosition(player->pos); break;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ void erased_enemy_add(Entity& enemy);
|
||||
void wisp_kind_init(Entity_Familiar& wisp, int item);
|
||||
void wisp_kind_colors(Entity_Familiar& wisp);
|
||||
void wisp_kind_update(Entity_Familiar& wisp, WispShot& shot);
|
||||
void wisp_room_enter(Entity_Familiar& wisp);
|
||||
void plum_flute_wisp_target(Entity_Familiar& wisp);
|
||||
void plum_flute_wisp_spray(Entity_Familiar& wisp, int updateSteps);
|
||||
bool wisp_kind_fire(Entity_Familiar& wisp, Vector velocity);
|
||||
|
||||
@@ -213,6 +213,7 @@ constexpr float MONSTER_SPEED_MIN = 0.7f;
|
||||
constexpr uint32_t D8_DELAY_SPREAD = 5;
|
||||
constexpr int D8_DELAY_SHIFT = -2;
|
||||
constexpr int D8_SHIFT_INDEX = 13;
|
||||
constexpr int RED_KEY_WISP_SHIFT_INDEX = 7;
|
||||
constexpr float WAVY_CAP_STACK = 0.75f;
|
||||
constexpr float WAVY_CAP_NULL_STACK = 0.3f;
|
||||
constexpr float WAVY_CAP_ROOT = 0.23f;
|
||||
@@ -1015,6 +1016,24 @@ void plum_flute_wisp_target(Entity_Familiar& wisp)
|
||||
}
|
||||
}
|
||||
|
||||
// Part of 0062bb70 (a new room, a wisp's case): Mr. Me!'s wisp drops its errand and rejoins its ring, Red Key's opens a
|
||||
// red room through the wall its room's spawn seed picks when it can.
|
||||
void wisp_room_enter(Entity_Familiar& wisp)
|
||||
{
|
||||
if (wisp.subtype == COLLECTIBLE_MR_ME)
|
||||
{
|
||||
wisp.keys = MR_ME_IDLE;
|
||||
wisp.velocity = {};
|
||||
if (wisp.orbitLayer < 0) wisp.AddToOrbit(wisp_config(wisp)->layer + WISP_RING_OFFSET);
|
||||
}
|
||||
else if (wisp.subtype == COLLECTIBLE_RED_KEY)
|
||||
{
|
||||
int slot = (int)(rng_make(g_game->room->descriptor->spawnSeed, RED_KEY_WISP_SHIFT_INDEX).Next() % DOOR_SLOT_COUNT);
|
||||
if (!g_game->room->doors[slot] && g_game->CanSpawnDoorOutline(g_game->currentRoomIdx, slot))
|
||||
g_game->MakeRedRoomDoor(g_game->currentRoomIdx, slot);
|
||||
}
|
||||
}
|
||||
|
||||
// The end of 0043aa90 for the Plum Flute's wisp spraying: it flies along a diagonal, spraying blood tears behind it
|
||||
// every fourth update with a fart, its animation facing up or down.
|
||||
void plum_flute_wisp_spray(Entity_Familiar& wisp, int updateSteps)
|
||||
|
||||
@@ -241,6 +241,19 @@ EntityList::EntityList()
|
||||
Reset();
|
||||
}
|
||||
|
||||
// 00417e50 Removes every entity still listed, the persistent ones too, so their pools hand them out again.
|
||||
EntityList::~EntityList()
|
||||
{
|
||||
for (EntityList_EL* list : {&mainEL, &persistentEL})
|
||||
for (size_t i = 0; i < list->size(); i++)
|
||||
{
|
||||
Entity* entity = (*list)[i];
|
||||
entity->ClearReferences();
|
||||
entity->isValid = false;
|
||||
entity->Remove();
|
||||
}
|
||||
}
|
||||
|
||||
// 00418230 Removes every entity but the persistent ones, and starts the lists over with those.
|
||||
void EntityList::Reset()
|
||||
{
|
||||
|
||||
@@ -157,6 +157,7 @@ struct EntityList
|
||||
bool isAnyBaited = false;
|
||||
|
||||
EntityList();
|
||||
~EntityList();
|
||||
EntityList(const EntityList&) = delete;
|
||||
EntityList& operator=(const EntityList&) = delete;
|
||||
|
||||
|
||||
+15
-23
@@ -1270,31 +1270,23 @@ void Entity_NPC::status_overlay_update()
|
||||
(g_game->challenge != CHALLENGE_SPEED && g_game->room->brokenWatchState == BROKEN_WATCH_SLOW);
|
||||
bool isTimeImmune = (flags & (FLAG_FRIENDLY | FLAG_NO_STATUS_EFFECTS)) && type != ENTITY_DEATHS_HEAD;
|
||||
|
||||
// Each status overrides the ones before it, so the last that applies shows. Charm overrides them all.
|
||||
// The first status that applies shows, charm before all, the crown or skull when none does.
|
||||
std::string_view animation;
|
||||
bool isShared = championColorIdx == CHAMPION_KING;
|
||||
if (championColorIdx == CHAMPION_KING) animation = "Crown";
|
||||
bool isShared = true;
|
||||
if (HasEntityFlags(FLAG_CHARM) && !isShadowCharger) animation = "Charm";
|
||||
else if (HasEntityFlags(FLAG_BRIMSTONE_MARKED)) animation = "BrimstoneCurse";
|
||||
else if (HasEntityFlags(FLAG_MAGNETIZED)) animation = "Magnetize";
|
||||
else if (HasEntityFlags(FLAG_BAITED)) animation = "Bait", isShared = false;
|
||||
else if (HasEntityFlags(FLAG_CONFUSION)) animation = "Confuse";
|
||||
else if (HasEntityFlags(FLAG_BURN)) animation = "Burning", isShared = false;
|
||||
else if (HasEntityFlags(FLAG_POISON)) animation = "Poison";
|
||||
else if (HasEntityFlags(FLAG_FEAR)) animation = "Fear";
|
||||
else if (HasEntityFlags(FLAG_BLEED_OUT)) animation = "BleedingOut";
|
||||
else if (HasEntityFlags(FLAG_SLOW) || (isTimeSlowed && !isTimeImmune)) animation = "Slow";
|
||||
else if (HasEntityFlags(FLAG_WEAKNESS)) animation = "Weakness";
|
||||
else if (type == ENTITY_SIREN_HELPER) animation = "EnemyCharm";
|
||||
else if (championColorIdx == CHAMPION_KING) animation = "Crown";
|
||||
else if (championColorIdx == CHAMPION_DEATH) animation = "Skull";
|
||||
|
||||
if (HasEntityFlags(FLAG_CHARM) && !isShadowCharger)
|
||||
{
|
||||
animation = "Charm";
|
||||
isShared = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (HasEntityFlags(FLAG_BRIMSTONE_MARKED)) animation = "BrimstoneCurse";
|
||||
if (HasEntityFlags(FLAG_MAGNETIZED)) animation = "Magnetize";
|
||||
if (HasEntityFlags(FLAG_BAITED)) animation = "Bait", isShared = false;
|
||||
if (HasEntityFlags(FLAG_CONFUSION)) animation = "Confuse";
|
||||
if (HasEntityFlags(FLAG_BURN)) animation = "Burning", isShared = false;
|
||||
if (HasEntityFlags(FLAG_POISON)) animation = "Poison";
|
||||
if (HasEntityFlags(FLAG_FEAR)) animation = "Fear";
|
||||
if (HasEntityFlags(FLAG_BLEED_OUT)) animation = "BleedingOut";
|
||||
if (HasEntityFlags(FLAG_SLOW) || (isTimeSlowed && !isTimeImmune)) animation = "Slow";
|
||||
if (HasEntityFlags(FLAG_WEAKNESS)) animation = "Weakness";
|
||||
if (type == ENTITY_SIREN_HELPER) animation = "EnemyCharm";
|
||||
}
|
||||
if (animation.empty())
|
||||
{
|
||||
if (statusEffectSprite.animState.animData) statusEffectSprite.animState.isPlaying = false;
|
||||
|
||||
@@ -1642,14 +1642,17 @@ static bool is_sized_variant(int variant)
|
||||
variant == TEAR_SPORE;
|
||||
}
|
||||
|
||||
// The sized animation's name for a variant and its number.
|
||||
// The sized animation's name for a variant and its number. Tooth, coin and stone tears have half as many sizes.
|
||||
static std::string sized_animation_name(int variant, int number)
|
||||
{
|
||||
const char* format = "RegularTear%d";
|
||||
if (is_listed(BLOOD_ANIMATION_VARIANTS, variant)) format = "BloodTear%d";
|
||||
bool isHalved = true;
|
||||
if (is_listed(BLOOD_ANIMATION_VARIANTS, variant)) format = "BloodTear%d", isHalved = false;
|
||||
else if (variant == TEAR_TOOTH || variant == TEAR_BLACK_TOOTH) format = "Tooth%dMove";
|
||||
else if (variant == TEAR_COIN) format = "Rotate%d";
|
||||
else if (is_listed(STONE_ANIMATION_VARIANTS, variant)) format = "Stone%dMove";
|
||||
else isHalved = false;
|
||||
if (isHalved) number = std::max(number / 2, 1);
|
||||
|
||||
char name[TEAR_ANIMATION_NAME_SIZE];
|
||||
std::snprintf(name, sizeof(name), format, number);
|
||||
|
||||
+3
-1
@@ -441,9 +441,11 @@ void Game::ResetState()
|
||||
}
|
||||
|
||||
// 007384d0 Replaces the current room with a new one and clears the floor: no rooms, stage, curses or Greed waves.
|
||||
// The old room stays current while it is deleted, as its entities' removal reads it.
|
||||
void Game::level_reset()
|
||||
{
|
||||
room.reset();
|
||||
delete room.get();
|
||||
room.release();
|
||||
room = std::make_unique<Room>();
|
||||
startingRoomIdx = -1;
|
||||
nbRooms = 0;
|
||||
|
||||
+1
-1
@@ -337,7 +337,7 @@ static void room_reset(Room& room)
|
||||
room.entityList.Reset();
|
||||
room.entityIndexCounter = 0;
|
||||
for (Entity* entity : room.entityList.updateEL) entity->index = room.entityIndexCounter++;
|
||||
room.lastAliveBossCount = 0;
|
||||
room.bossesRemaining = 0;
|
||||
for (int i = 0; i < ROOM_ITEM_COUNTER_COUNT; i++)
|
||||
if (!(ROOM_ITEM_COUNTERS_KEPT >> i & 1)) room.itemCounters[i] = 0;
|
||||
|
||||
|
||||
@@ -251,7 +251,6 @@ public:
|
||||
int greedWaveTimer = 0;
|
||||
int gridHeight = 0;
|
||||
int gridWidth = 0;
|
||||
int lastAliveBossCount = 0;
|
||||
int numRainSpawners = 0;
|
||||
int roomClearDelay = 0;
|
||||
int secondBossId = 0;
|
||||
|
||||
@@ -1428,14 +1428,15 @@ void Room::Update()
|
||||
if ((roomType == ROOM_CHALLENGE || roomType == ROOM_BOSSRUSH) && game.ambush.isActive) game.ambush.Update();
|
||||
if (isCardAgainstHumanity) card_against_humanity_fill();
|
||||
|
||||
// The bosses still counted are the living ones from here on, warning when some left without TriggerBossDeath.
|
||||
int bosses = GetAliveBossesCount();
|
||||
if (bosses < 1 && lastAliveBossCount > 0)
|
||||
if (bosses < 1 && bossesRemaining > 0)
|
||||
{
|
||||
if (g_manager->netplayManager.is_online())
|
||||
KAGE_LogMessage(LOG_INFO, (uint8_t*)("[Frame " + std::to_string(game.frameCount) + "] ").c_str());
|
||||
KAGE_LogMessage(LOG_INFO, (uint8_t*)"[warn] last boss died without triggering the deathspawn.\n");
|
||||
}
|
||||
lastAliveBossCount = bosses;
|
||||
bossesRemaining = bosses;
|
||||
entityList.Update(UPDATE_NORMAL);
|
||||
fxLayers.Update(PLAYER_FOLLOW_EASE);
|
||||
|
||||
|
||||
+11
-3
@@ -256,6 +256,10 @@ void MenuManager::menus_init()
|
||||
menuBestiary.Init(menu_position_get(MENU_BESTIARY));
|
||||
log_printf(LOG_INFO, "Menu Custom Challenge Init\n");
|
||||
menuCustomChallenge.Init(menu_position_get(MENU_CUSTOM_CHALLENGE));
|
||||
log_printf(LOG_INFO, "Menu Online Awards Init\n");
|
||||
onlineAwardsPosition = menu_position_get(MENU_ONLINE_AWARDS);
|
||||
online_awards_load();
|
||||
online_awards_reset();
|
||||
}
|
||||
|
||||
// 00988ba0 Drops every menu's sprites, as a run starts.
|
||||
@@ -279,6 +283,7 @@ void MenuManager::unload_graphics()
|
||||
menuBestiary.unload_graphics();
|
||||
menuCustomChallenge.customChallengeSprite.Reset();
|
||||
menuMods.modsMenuSprite.Reset();
|
||||
onlineStatsMenuSprite.Reset();
|
||||
}
|
||||
|
||||
// 00988d80 Loads every menu's sprites again, as the menus come back.
|
||||
@@ -301,6 +306,7 @@ void MenuManager::LoadGraphics()
|
||||
menuBestiary.load_graphics();
|
||||
menuCustomChallenge.LoadGraphics();
|
||||
menuMods.LoadGraphics();
|
||||
online_awards_load();
|
||||
}
|
||||
|
||||
// 00989750 Fades the menus out into the run to the start jingle, loading the loading screen for the start seed.
|
||||
@@ -399,7 +405,7 @@ void MenuManager::Update()
|
||||
color_mod_update();
|
||||
}
|
||||
|
||||
// Steps the selected menu. The online menus are never selected offline.
|
||||
// Steps the selected menu. The online menus besides the awards are never selected offline.
|
||||
void MenuManager::menu_update()
|
||||
{
|
||||
switch (selectedMenuId)
|
||||
@@ -420,6 +426,7 @@ void MenuManager::menu_update()
|
||||
case MENU_BESTIARY: menuBestiary.Update(); break;
|
||||
case MENU_CUSTOM_CHALLENGE: menuCustomChallenge.Update(); break;
|
||||
case MENU_MODS: menuMods.Update(); break;
|
||||
case MENU_ONLINE_AWARDS: online_awards_update(); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@@ -483,6 +490,7 @@ void MenuManager::Render()
|
||||
menuCutscenes.Render();
|
||||
menuCustomChallenge.Render();
|
||||
menuMods.Render();
|
||||
online_awards_render();
|
||||
menuSave.Render();
|
||||
menuDailyChallenge.leaderboard.Render();
|
||||
flySprite.Render(menu_draw_get(vector_make(scrollInterpolationX, scrollInterpolationY)));
|
||||
@@ -732,8 +740,8 @@ SeedsEntry MenuManager::transition_other_apply(MenuState previous, MenuState sta
|
||||
case MENU_ONLINE_LOBBY_LIST:
|
||||
case MENU_ONLINE:
|
||||
case MENU_ONLINE_OPTIONS:
|
||||
case MENU_CREATE_LOBBY:
|
||||
case MENU_ONLINE_AWARDS: return SEEDS_ENTRY_KEEP;
|
||||
case MENU_CREATE_LOBBY: return SEEDS_ENTRY_KEEP;
|
||||
case MENU_ONLINE_AWARDS: online_awards_reset(); return SEEDS_ENTRY_KEEP;
|
||||
default: return SEEDS_ENTRY_RESET;
|
||||
}
|
||||
}
|
||||
|
||||
+19
-1
@@ -124,10 +124,20 @@ constexpr int SOUND_MENU_NOTE_APPEAR = 283;
|
||||
constexpr int SOUND_MENU_NOTE_HIDE = 284;
|
||||
constexpr ColorModState COLOR_MOD_NONE = {1, 1, 1, 0, 0, 1};
|
||||
|
||||
// The directions the online awards page moves its cursor by, each with its hold counter in this order.
|
||||
enum OnlineAwardsDirection
|
||||
{
|
||||
ONLINE_AWARDS_UP,
|
||||
ONLINE_AWARDS_DOWN,
|
||||
ONLINE_AWARDS_LEFT,
|
||||
ONLINE_AWARDS_RIGHT,
|
||||
ONLINE_AWARDS_DIRECTION_COUNT
|
||||
};
|
||||
|
||||
// Copies are never made. Destruction (00986f30) is the default.
|
||||
// The main menu (g_menuManager): every menu laid out on one sheet the view scrolls across, the history of menus
|
||||
// opened, the fades, the fly, the shadow and overlay over everything, and the color modifier it all renders through.
|
||||
// The online menus are offline: they are never built, entered or drawn.
|
||||
// The online menus are offline: they are never built, entered or drawn, but for the online awards page the stats open.
|
||||
class MenuManager
|
||||
{
|
||||
public:
|
||||
@@ -144,6 +154,10 @@ public:
|
||||
KAGE::Graphics::ImagePtr menuOverlayImage;
|
||||
ANM2 flySprite;
|
||||
ANM2 menuShadowSprite;
|
||||
ANM2 onlineStatsMenuSprite;
|
||||
std::array<int, ONLINE_AWARDS_DIRECTION_COUNT> onlineAwardsHoldFrames{};
|
||||
Vector onlineAwardsPosition{};
|
||||
int onlineAwardsSelected = 0;
|
||||
|
||||
Menu_Title menuTitle;
|
||||
Menu_Save menuSave;
|
||||
@@ -208,6 +222,10 @@ private:
|
||||
void overlay_render();
|
||||
void color_mod_render();
|
||||
void fades_render();
|
||||
void online_awards_load();
|
||||
void online_awards_reset();
|
||||
void online_awards_update();
|
||||
void online_awards_render();
|
||||
};
|
||||
|
||||
extern KAGE::Graphics::ImagePtr menuColorModSurface;
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
#include "engine/font.h"
|
||||
#include "game/game.h"
|
||||
#include "game/manager.h"
|
||||
#include "ui/menu/manager.h"
|
||||
#include <string>
|
||||
|
||||
constexpr const char* ONLINE_STATS_ANM2 = "gfx/ui/main menu/OnlineStatsMenu.anm2";
|
||||
constexpr const char* CURSOR_LAYER = "Cursor";
|
||||
constexpr const char* TEXT_START_NULL = "TextStartPos";
|
||||
constexpr const char* DESCRIPTION_NULL = "DescriptionPos";
|
||||
constexpr const char* UNKNOWN_TEXT = "??????";
|
||||
constexpr const char* DESCRIPTION_SUFFIX = "_DESC";
|
||||
|
||||
// The grid: columns of seven awards, three of them.
|
||||
constexpr int AWARD_ROWS = 7;
|
||||
constexpr int AWARD_GRID_SPAN = COOP_AWARD_COUNT - AWARD_ROWS;
|
||||
// A held direction moves once, then again every eighth frame once held past the 39th.
|
||||
constexpr int HOLD_DELAY = 39;
|
||||
constexpr int HOLD_INTERVAL = 8;
|
||||
|
||||
// The text: each column 126 wide with its count 102 in, rows 14 apart, descriptions wrapped at 300.
|
||||
constexpr float COLUMN_WIDTH = 126;
|
||||
constexpr float COUNT_OFFSET_X = 102;
|
||||
constexpr float ROW_HEIGHT = 14;
|
||||
constexpr uint16_t DESCRIPTION_WIDTH = 300;
|
||||
constexpr KColor TEXT_COLOR = kcolor_rgba(0.21176471f, 0.18431373f, 0.1764706f, 1);
|
||||
constexpr float UNKNOWN_ALPHA = 0.8f;
|
||||
|
||||
// The award counters the event counters keep, in the order of COOP_AWARD_KEYS.
|
||||
constexpr int AWARD_COUNTER_FIRST = 500;
|
||||
|
||||
// Loads the online awards page, idling (inlined in MenuManager::Init and MenuManager::LoadGraphics).
|
||||
void MenuManager::online_awards_load()
|
||||
{
|
||||
onlineStatsMenuSprite.Load(ONLINE_STATS_ANM2, GRAPHICS_LOAD);
|
||||
onlineStatsMenuSprite.Play(ANIMATION_IDLE);
|
||||
}
|
||||
|
||||
// 008e71c0 Idles the online awards page (an unforced play) and forgets the held directions.
|
||||
void MenuManager::online_awards_reset()
|
||||
{
|
||||
onlineStatsMenuSprite.Play(ANIMATION_IDLE);
|
||||
onlineAwardsHoldFrames = {};
|
||||
}
|
||||
|
||||
// Whether a direction is held this frame and moves the cursor now, counting how long it has been held.
|
||||
static bool is_direction_step(ButtonAction action, int& held)
|
||||
{
|
||||
if (!is_action(action, ACTION_PRESSED))
|
||||
{
|
||||
held = 0;
|
||||
return false;
|
||||
}
|
||||
bool isStep = held == 0 || (held > HOLD_DELAY && held % HOLD_INTERVAL == 0);
|
||||
held++;
|
||||
return isStep;
|
||||
}
|
||||
|
||||
// 008e7250 (Menu_OnlineAwards::Update) Steps the online awards page every other frame (MenuManager::Update's part),
|
||||
// then back leaves and the directions move the cursor, wrapping within its column or row. The cursor layer shows the
|
||||
// selected award.
|
||||
void MenuManager::online_awards_update()
|
||||
{
|
||||
std::array<int, ONLINE_AWARDS_DIRECTION_COUNT>& held = onlineAwardsHoldFrames;
|
||||
int& selected = onlineAwardsSelected;
|
||||
|
||||
if ((g_manager->framecount & 1) == 0 && onlineStatsMenuSprite.isLoaded) onlineStatsMenuSprite.Update();
|
||||
|
||||
if (is_action(ACTION_MENU_BACK, ACTION_TRIGGERED)) pop_menu();
|
||||
if (is_direction_step(ACTION_MENU_UP, held[ONLINE_AWARDS_UP]))
|
||||
selected += selected % AWARD_ROWS != 0 ? -1 : AWARD_ROWS - 1;
|
||||
if (is_direction_step(ACTION_MENU_DOWN, held[ONLINE_AWARDS_DOWN]))
|
||||
selected += selected % AWARD_ROWS != AWARD_ROWS - 1 ? 1 : 1 - AWARD_ROWS;
|
||||
if (is_direction_step(ACTION_MENU_LEFT, held[ONLINE_AWARDS_LEFT]))
|
||||
selected += selected < AWARD_ROWS ? AWARD_GRID_SPAN : -AWARD_ROWS;
|
||||
if (is_direction_step(ACTION_MENU_RIGHT, held[ONLINE_AWARDS_RIGHT]))
|
||||
selected += selected >= AWARD_GRID_SPAN ? -AWARD_GRID_SPAN : AWARD_ROWS;
|
||||
|
||||
onlineStatsMenuSprite.SetLayerFrame(CURSOR_LAYER, selected);
|
||||
}
|
||||
|
||||
// 008e6a80 (Menu_OnlineAwards::Render) Draws the online awards page, then each award's name and count down its column
|
||||
// (both "??????" faded until won), and the selected award's description wrapped under the grid.
|
||||
// The original reads the null frames of a page with no animation. Nothing is written then.
|
||||
void MenuManager::online_awards_render()
|
||||
{
|
||||
Font& font = g_manager->font1_TeamMeatEx10;
|
||||
std::array<int, EVENT_COUNTER_COUNT>& counters = g_manager->persistentGameData.eventCounters;
|
||||
SpriteDraw draw = menu_draw_get(onlineAwardsPosition);
|
||||
Vector scale = vector_make(1, 1);
|
||||
|
||||
if (onlineStatsMenuSprite.isLoaded) onlineStatsMenuSprite.Render(draw);
|
||||
const NullFrame* textStart = onlineStatsMenuSprite.GetNullFrame(TEXT_START_NULL);
|
||||
const NullFrame* description = onlineStatsMenuSprite.GetNullFrame(DESCRIPTION_NULL);
|
||||
if (!textStart || !description) return;
|
||||
|
||||
Vector start = vector_add(draw.position, textStart->pos);
|
||||
Vector label = start;
|
||||
for (int award = 0; award < COOP_AWARD_COUNT; award++)
|
||||
{
|
||||
int count = counters[AWARD_COUNTER_FIRST + award];
|
||||
bool isWon = count >= 1;
|
||||
KColor color = TEXT_COLOR;
|
||||
if (!isWon) color._alpha = UNKNOWN_ALPHA;
|
||||
if (award > 0 && award % AWARD_ROWS == 0) label = vector_make(label.x + COLUMN_WIDTH, start.y);
|
||||
|
||||
FontSettings labelSettings;
|
||||
font.DrawString(isWon ? g_manager->stringTable.translate(COOP_AWARD_KEYS[award]) : UNKNOWN_TEXT, label, scale,
|
||||
color, labelSettings);
|
||||
FontSettings countSettings(ALIGN_TOP_RIGHT);
|
||||
font.DrawString(std::to_string(count), vector_make(label.x + COUNT_OFFSET_X, label.y), scale, color,
|
||||
countSettings);
|
||||
label.y += ROW_HEIGHT;
|
||||
if (award != onlineAwardsSelected) continue;
|
||||
|
||||
FontSettings descriptionSettings(ALIGN_TOP_CENTER);
|
||||
descriptionSettings.EnableAutoWrap(DESCRIPTION_WIDTH);
|
||||
std::string key = std::string(COOP_AWARD_KEYS[award]) + DESCRIPTION_SUFFIX;
|
||||
font.DrawString(isWon ? g_manager->stringTable.translate(key) : UNKNOWN_TEXT,
|
||||
vector_add(draw.position, description->pos), scale, TEXT_COLOR, descriptionSettings);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user