Curation round 5: Game construction, FXLayers, PlayerManager, the menus; the main menu renders
Eight agents took over ScoreSheet, DeathmatchManager, giantbook and boss overlays, FXLayers, PlayerManager, the menu manager with the save and prompt flow, twelve menus (character wheel, options, challenges, daily (offline), special seeds, leaderboard (local), collection, bestiary, stats, controller select, key config, cutscenes), console text input and gamepad hot-plug through platform listeners. Integration moved input to device ids. KAGE's projection matrix now reaches the 'ProjectionMatrix' uniform the basic shaders from afterbirthp.a declare, as well as the exe's 'Transform', which takes the color-mod and HQ4X passes from black to correct output. Under gdb with stubs skipped, the intro, title, file select, main menu and character wheel render as in the game. 1330 functions taken over, boot path 261/615. build/isaac stops at OnlineEmotes::init in Game::LoadConfigXmls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fd8b965350
commit
233d5123e8
128 files changed
+10194
-36967
No files matched your search
@@ -0,0 +1,287 @@
|
||||
#include "generic_prompt.h"
|
||||
#include "log.h"
|
||||
#include "manager.h"
|
||||
#include "menu_manager.h"
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
|
||||
constexpr const char* PROMPT_ANM2 = "gfx/ui/Prompt_YesNo.anm2";
|
||||
constexpr const char* PROMPT_SMALL_ANM2 = "gfx/ui/Prompt_YesNo_Small.anm2";
|
||||
constexpr const char* ANIMATION_APPEAR = "Appear";
|
||||
constexpr const char* ANIMATION_DISAPPEAR = "Dissappear";
|
||||
constexpr const char* TEXT_TOP_NULL = "TextTop";
|
||||
constexpr int CURSOR_LAYER = 1;
|
||||
constexpr int SMALL_SHEET_LAYER = 2;
|
||||
constexpr uint32_t PROMPT_TEXT_ARGB = 0xff362f2d;
|
||||
constexpr float TITLE_LINE_HEIGHT = 17;
|
||||
constexpr float TITLE_BODY_GAP = 12;
|
||||
constexpr float BODY_LINE_HEIGHT = 13;
|
||||
|
||||
constexpr const char* SPINNER_ANM2 = "gfx/ui/LoadingSpinner.anm2";
|
||||
constexpr const char* GAME_VERSION = "v1.9.7.17";
|
||||
constexpr const char* BETA_TEXT =
|
||||
"Welcome to The Binding of Isaac: Repentance+ Beta!\\n\\nThis is a fully featured beta, but be aware that it may "
|
||||
"crash or have other issues. Repentance+ uses its own save files and your Repentance saves are not touched so in "
|
||||
"the event of save issues, your backups remain intact.\\n\\nReport bugs to isaac@nicalis.com with the subject "
|
||||
"line\\n#Repentance+Beta %s\\n\\nEnjoy playing online!";
|
||||
constexpr const char* DATA_COLLECTION_TEXT =
|
||||
"By playing online multiplayer, you agree to the collection of data limited to your Steam username, Steam ID, "
|
||||
"installation directory, save data and game version number.\\n\\nThis data is collected only for and in relation "
|
||||
"to online bug fixing. If you don’t consent to this data collection, you may opt-out by not participating in "
|
||||
"online multiplayer mode. If you are under the age of 18 and/or do not have parental consent, you must opt out.";
|
||||
constexpr const char* ACCEPT_TEXT[] = {"ACCEPT", "I CONSENT"};
|
||||
constexpr const char* DECLINE_TEXT[] = {"DENY", "I DO NOT CONSENT"};
|
||||
constexpr int DISCLAIMER_TEXT_SIZE = 516;
|
||||
constexpr int ACCEPT_RESULT = 1;
|
||||
constexpr int DECLINE_RESULT = 2;
|
||||
constexpr int ACCEPT_CHOICE = 0;
|
||||
constexpr int DECLINE_CHOICE = 1;
|
||||
constexpr float CHOICES_GAP = 35;
|
||||
constexpr float DISCLAIMER_LINE_HEIGHT = 0.75f;
|
||||
constexpr float DISCLAIMER_WIDTH = 0.9f;
|
||||
constexpr uint64_t CHOICES_WAIT_MS = 5000;
|
||||
constexpr float SPINNER_DROP = 0.33f;
|
||||
constexpr float SPINNER_SCALE = 0.8f;
|
||||
constexpr unsigned int FILTER_LINEAR = 1;
|
||||
|
||||
// The disclaimer on screen: its popup, which disclaimer it is, who hears the answer, and the spinner shown while its
|
||||
// choices wait.
|
||||
struct DisclaimerState
|
||||
{
|
||||
ANM2 spinner;
|
||||
DisclaimerCallback callback = nullptr;
|
||||
void* userData = nullptr;
|
||||
Disclaimer disclaimer = DISCLAIMER_NONE;
|
||||
int popupId = -1;
|
||||
};
|
||||
|
||||
static DisclaimerState disclaimerState;
|
||||
|
||||
// 008378e0 Loads the large or small prompt sheet, with nothing chosen.
|
||||
void GenericPrompt::Initialize(PromptSize size)
|
||||
{
|
||||
sprite.Load(size == PROMPT_SMALL ? PROMPT_SMALL_ANM2 : PROMPT_ANM2, GRAPHICS_LOAD);
|
||||
submittedSelection = PROMPT_ANSWER_NONE;
|
||||
currentSelection = PROMPT_CHOICE_NO;
|
||||
isOnlineVote = false;
|
||||
}
|
||||
|
||||
// 008380f0 Plays the sheet in on no, unless it is already coming in, for a local answer or an online vote.
|
||||
void GenericPrompt::Show(PromptVote vote)
|
||||
{
|
||||
submittedSelection = PROMPT_ANSWER_NONE;
|
||||
currentSelection = PROMPT_CHOICE_NO;
|
||||
sprite.Play(ANIMATION_APPEAR);
|
||||
isOnlineVote = vote == PROMPT_ONLINE_VOTE;
|
||||
}
|
||||
|
||||
// 00838190 Plays the sheet out, unless it is already going.
|
||||
void GenericPrompt::Disappear()
|
||||
{
|
||||
sprite.Play(ANIMATION_DISAPPEAR);
|
||||
}
|
||||
|
||||
// 00838210 Whether the sheet is on screen and moving, which holds the game still.
|
||||
bool GenericPrompt::IsActive() const
|
||||
{
|
||||
return sprite.animState.animData && sprite.animState.isPlaying;
|
||||
}
|
||||
|
||||
// 00838230 Sets the two title lines and the three body lines, empty ones left out, and hides the small sheet's third
|
||||
// layer.
|
||||
void GenericPrompt::SetText(const std::array<std::string, PROMPT_LINES>& lines)
|
||||
{
|
||||
std::copy(lines.begin(), lines.begin() + PROMPT_TITLE_LINES, titleLines.begin());
|
||||
std::copy(lines.begin() + PROMPT_TITLE_LINES, lines.end(), bodyLines.begin());
|
||||
if ((int)sprite.layerStates.size() > SMALL_SHEET_LAYER) sprite.GetLayer(SMALL_SHEET_LAYER)->isVisible = false;
|
||||
}
|
||||
|
||||
// 00837fe0 Left and right swap the answer. Confirm, once the sheet idles, submits it and plays the sheet out, or
|
||||
// sends it as the vote. Offline no netplay player owns the prompt, so any device answers.
|
||||
void GenericPrompt::handle_input()
|
||||
{
|
||||
if (is_action(ACTION_MENU_LEFT, ACTION_TRIGGERED) || is_action(ACTION_MENU_RIGHT, ACTION_TRIGGERED))
|
||||
currentSelection = currentSelection == PROMPT_CHOICE_NO ? PROMPT_CHOICE_YES : PROMPT_CHOICE_NO;
|
||||
if (!is_action(ACTION_MENU_CONFIRM, ACTION_TRIGGERED) || !sprite.IsPlaying(ANIMATION_IDLE)) return;
|
||||
|
||||
submittedSelection = currentSelection == PROMPT_CHOICE_YES ? PROMPT_ANSWER_YES : PROMPT_ANSWER_NO;
|
||||
if (isOnlineVote) online_vote_send(currentSelection == PROMPT_CHOICE_NO);
|
||||
else Disappear();
|
||||
}
|
||||
|
||||
// 00837ab0 Reads the input if asked, steps the sheet, idles it once it came in, and puts the cursor on the answer.
|
||||
void GenericPrompt::Update(PromptInput input)
|
||||
{
|
||||
if (input == PROMPT_INPUT_READ) handle_input();
|
||||
sprite.Update();
|
||||
if (sprite.animState.animData && !sprite.animState.isPlaying && sprite.GetAnimation() == ANIMATION_APPEAR)
|
||||
sprite.Play(ANIMATION_IDLE);
|
||||
sprite.SetLayerFrame(CURSOR_LAYER, currentSelection);
|
||||
}
|
||||
|
||||
// 00837c10 Draws the sheet at the screen center while it moves, then the title lines centered on its TextTop null in
|
||||
// the larger font and the body lines under them in the smaller one, at the null's scale.
|
||||
void GenericPrompt::Render()
|
||||
{
|
||||
if (!IsActive()) return;
|
||||
|
||||
Manager& manager = *g_manager;
|
||||
Vector center = vector_make(g_screenWidth * 0.5f, g_screenHeight * 0.5f);
|
||||
SpriteDraw draw;
|
||||
draw.position = center;
|
||||
sprite.Render(draw);
|
||||
|
||||
const NullFrame* textTop = sprite.GetNullFrame(TEXT_TOP_NULL);
|
||||
if (!textTop) return;
|
||||
|
||||
KColor color = kcolor_argb(PROMPT_TEXT_ARGB);
|
||||
FontSettings settings;
|
||||
float lineY = textTop->pos.y;
|
||||
auto line_draw = [&](Font& font, const std::string& text, float lineHeight)
|
||||
{
|
||||
if (text.empty()) return;
|
||||
|
||||
float left = center.x + textTop->pos.x - (float)font.GetStringWidth(text) * 0.5f * textTop->scale.x;
|
||||
font.DrawString(text, vector_make(left, center.y + lineY), textTop->scale, color, settings);
|
||||
lineY += textTop->scale.y * lineHeight;
|
||||
};
|
||||
|
||||
for (const std::string& line : titleLines) line_draw(manager.font3_TeamMeatEx16, line, TITLE_LINE_HEIGHT);
|
||||
lineY += textTop->scale.y * TITLE_BODY_GAP;
|
||||
for (const std::string& line : bodyLines) line_draw(manager.font2_TeamMeatEx12, line, BODY_LINE_HEIGHT);
|
||||
}
|
||||
|
||||
// 009c0870 Makes a popup's choice (counted among its choices) wait or pickable again: its result moves to the inactive
|
||||
// id and back. A waiting choice loses the selection, and the first one to come back takes an empty selection.
|
||||
void popup_choice_set(Popup& popup, int choice, ChoiceState state)
|
||||
{
|
||||
std::vector<PopupLine>& lines = popup.desc.lines;
|
||||
int index = 0;
|
||||
|
||||
while (index < (int)lines.size())
|
||||
{
|
||||
bool isChoice = lines[index].id != POPUP_LINE_TEXT || lines[index].inactiveId != POPUP_LINE_TEXT;
|
||||
if (isChoice && choice-- == 0) break;
|
||||
index++;
|
||||
}
|
||||
if (index == (int)lines.size()) return;
|
||||
|
||||
PopupLine& line = lines[index];
|
||||
int& from = state == CHOICE_ACTIVE ? line.inactiveId : line.id;
|
||||
int& to = state == CHOICE_ACTIVE ? line.id : line.inactiveId;
|
||||
if (to != POPUP_LINE_TEXT) return;
|
||||
|
||||
to = from;
|
||||
from = POPUP_LINE_TEXT;
|
||||
if (popup.selectedLine == index)
|
||||
{
|
||||
popup.select_move(-1);
|
||||
if (popup.selectedLine == index) popup.selectedLine = POPUP_NO_SELECTION;
|
||||
}
|
||||
else if (popup.selectedLine == POPUP_NO_SELECTION && state == CHOICE_ACTIVE) popup.selectedLine = index;
|
||||
}
|
||||
|
||||
// 00420930 Records an accepted disclaimer in the options and saves them, tells the caller, and frees the slot.
|
||||
static void disclaimer_closed(int* result, void*)
|
||||
{
|
||||
OptionsConfig& options = g_manager->optionsConfig;
|
||||
bool isAccepted = *result == ACCEPT_RESULT;
|
||||
|
||||
if (isAccepted && disclaimerState.disclaimer != DISCLAIMER_NONE)
|
||||
{
|
||||
(disclaimerState.disclaimer == DISCLAIMER_BETA ? options.isPublicBetaAccepted :
|
||||
options.isDataCollectionDisclaimerAccepted) = true;
|
||||
options.Save();
|
||||
}
|
||||
if (disclaimerState.callback) disclaimerState.callback(isAccepted, disclaimerState.userData);
|
||||
disclaimerState.popupId = -1;
|
||||
disclaimerState.disclaimer = DISCLAIMER_NONE;
|
||||
disclaimerState.callback = nullptr;
|
||||
disclaimerState.userData = nullptr;
|
||||
}
|
||||
|
||||
// 00420760 Lets the choices be picked once the disclaimer has shown five seconds, ending the wait and its spinner.
|
||||
static void disclaimer_wait_update(Popup& popup, void*)
|
||||
{
|
||||
if (popup.get_elapsed_ms() < CHOICES_WAIT_MS) return;
|
||||
|
||||
popup_choice_set(popup, ACCEPT_CHOICE, CHOICE_ACTIVE);
|
||||
popup_choice_set(popup, DECLINE_CHOICE, CHOICE_ACTIVE);
|
||||
popup.desc.updateCallback = nullptr;
|
||||
popup.desc.updateContext = nullptr;
|
||||
popup.desc.renderCallback = nullptr;
|
||||
popup.desc.renderContext = nullptr;
|
||||
}
|
||||
|
||||
// 004207c0 Spins the loading spinner every other frame and draws it a third of the popup's height below its center,
|
||||
// at the popup's scale.
|
||||
static void disclaimer_wait_render(Popup& popup, void*)
|
||||
{
|
||||
ANM2& spinner = disclaimerState.spinner;
|
||||
Vector center = popup.get_center();
|
||||
Vector scale = popup.scale.get();
|
||||
SpriteDraw draw;
|
||||
|
||||
if ((g_manager->framecount & 1) == 0) spinner.Update();
|
||||
draw.position = vector_make(center.x, center.y + popup.get_size().y * SPINNER_DROP);
|
||||
spinner.scale = vector_make(scale.x * SPINNER_SCALE, scale.y * SPINNER_SCALE);
|
||||
spinner.Render(draw);
|
||||
spinner.scale = vector_make(1, 1);
|
||||
}
|
||||
|
||||
// 00420190 Asks once for the beta or data collection disclaimer: the text over its choices, which wait five seconds
|
||||
// behind a spinner. False when it was already accepted. The callback hears whether it was accepted.
|
||||
// The original names the spinner from the game folder, with resources/ in front.
|
||||
// It shows an empty popup for any other disclaimer. Nothing shows here.
|
||||
bool show_beta_disclaimer_popup(Disclaimer disclaimer, DisclaimerCallback callback, void* userData)
|
||||
{
|
||||
Manager& manager = *g_manager;
|
||||
OptionsConfig& options = manager.optionsConfig;
|
||||
ANM2& spinner = disclaimerState.spinner;
|
||||
|
||||
if (disclaimerState.popupId != -1) log_printf(LOG_ASSERT, "Disclaimer popup is already running\n");
|
||||
if (!spinner.isLoaded)
|
||||
{
|
||||
spinner.Load(SPINNER_ANM2, GRAPHICS_LOAD);
|
||||
spinner.Play(ANIMATION_IDLE);
|
||||
LayerState* layer = spinner.GetLayer(0);
|
||||
layer->minFilterMode = FILTER_LINEAR;
|
||||
layer->magFilterMode = FILTER_LINEAR;
|
||||
}
|
||||
if (disclaimer == DISCLAIMER_NONE) return false;
|
||||
if (disclaimer == DISCLAIMER_BETA ? options.isPublicBetaAccepted : options.isDataCollectionDisclaimerAccepted)
|
||||
return false;
|
||||
|
||||
disclaimerState.disclaimer = disclaimer;
|
||||
disclaimerState.callback = callback;
|
||||
disclaimerState.userData = userData;
|
||||
|
||||
MessagePopup desc(&manager.font2_TeamMeatEx12, disclaimer_closed, nullptr, vector_make(POPUP_SIZE_FIT, POPUP_SIZE_FIT));
|
||||
PopupLine line;
|
||||
char text[DISCLAIMER_TEXT_SIZE];
|
||||
std::snprintf(text, sizeof(text), BETA_TEXT, GAME_VERSION);
|
||||
line.text = disclaimer == DISCLAIMER_BETA ? text : DATA_COLLECTION_TEXT;
|
||||
desc.line_add(line);
|
||||
line.text = ACCEPT_TEXT[disclaimer];
|
||||
line.id = ACCEPT_RESULT;
|
||||
line.offset.y = CHOICES_GAP;
|
||||
desc.line_add(line);
|
||||
line.text = DECLINE_TEXT[disclaimer];
|
||||
line.id = DECLINE_RESULT;
|
||||
line.offset.y = 0;
|
||||
desc.line_add(line);
|
||||
|
||||
desc.lineHeightScale = DISCLAIMER_LINE_HEIGHT;
|
||||
desc.maxWidthFraction = DISCLAIMER_WIDTH;
|
||||
desc.cancelResult = DECLINE_RESULT;
|
||||
desc.initialSelection = 1;
|
||||
desc.isInactiveShown = false;
|
||||
desc.updateCallback = disclaimer_wait_update;
|
||||
desc.renderCallback = disclaimer_wait_render;
|
||||
disclaimerState.popupId = manager.popupQueue.push(desc);
|
||||
|
||||
Popup* popup = manager.popupQueue.find(disclaimerState.popupId);
|
||||
popup_choice_set(*popup, ACCEPT_CHOICE, CHOICE_INACTIVE);
|
||||
popup_choice_set(*popup, DECLINE_CHOICE, CHOICE_INACTIVE);
|
||||
return true;
|
||||
}
|
||||
Reference in new issue
Block a user