mirror of
https://github.com/leoetlino/project-restoration
synced 2025-10-06 00:32:43 +02:00
game/ui: Update MessageWindow
This commit is contained in:
@@ -6,10 +6,10 @@
|
||||
namespace game {
|
||||
|
||||
namespace ui {
|
||||
class BranchArrow;
|
||||
class Layout;
|
||||
class MessageTextState;
|
||||
class MessageWindow;
|
||||
class Widget;
|
||||
} // namespace ui
|
||||
|
||||
struct StateEnding : State {
|
||||
@@ -24,7 +24,7 @@ struct StateEnding : State {
|
||||
ui::Layout* press_start_layout;
|
||||
ui::MessageWindow* message_window;
|
||||
ui::MessageTextState* text_state;
|
||||
ui::BranchArrow* branch_arrow;
|
||||
ui::Widget* branch_arrow;
|
||||
int ending_status;
|
||||
int message_choice;
|
||||
float timer;
|
||||
|
@@ -183,22 +183,15 @@ struct WidgetPos {
|
||||
ValueChanged(Flag::Visible2, visible, true);
|
||||
}
|
||||
|
||||
void SetOpacity(float opacity) {
|
||||
if (color(3) == opacity)
|
||||
return;
|
||||
color(3) = opacity;
|
||||
ValueChanged(Flag::DefaultOpacity, opacity, 1.0f);
|
||||
}
|
||||
void SetOpacity(float opacity) { Set(&color(3), opacity, Flag::DefaultOpacity, 1.0f); }
|
||||
|
||||
void AddOpacity(float delta, float min = 0.0f, float max = 1.0f) {
|
||||
SetOpacity(std::clamp(color(3) + delta, min, max));
|
||||
}
|
||||
|
||||
void TranslateChanged() {
|
||||
ValueChanged(Flag::DefaultTranslateX, translate.x, 1.0f);
|
||||
ValueChanged(Flag::DefaultTranslateY, translate.y, 1.0f);
|
||||
ValueChanged(Flag::DefaultTranslateZ, translate.z, 1.0f);
|
||||
}
|
||||
void SetTranslateX(float x) { Set(&translate.x, x, Flag::DefaultTranslateX, 0.0f); }
|
||||
void SetTranslateY(float y) { Set(&translate.y, y, Flag::DefaultTranslateY, 0.0f); }
|
||||
void SetTranslateZ(float z) { Set(&translate.z, z, Flag::DefaultTranslateZ, 0.0f); }
|
||||
|
||||
void ScaleChanged() {
|
||||
ValueChanged(Flag::DefaultScaleX, scale.x, 1.0f);
|
||||
@@ -221,6 +214,14 @@ struct WidgetPos {
|
||||
rst::Flags<Flag> active_flags;
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
void Set(T* variable, const T& value, Flag flag, const T& default_value) {
|
||||
if (*variable == value)
|
||||
return;
|
||||
*variable = value;
|
||||
ValueChanged(flag, value, default_value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void ValueChanged(Flag flag, const T& value, const T& default_value) {
|
||||
flags.Set(flag);
|
||||
|
@@ -16,20 +16,19 @@ public:
|
||||
void* vtable_170;
|
||||
void* vtable_174;
|
||||
u8 gap_178[368];
|
||||
u32 field_2E8;
|
||||
u8 gap_2EC[28];
|
||||
int field_308;
|
||||
Layout* note_layouts[8];
|
||||
Widget* plate;
|
||||
u8 gap_30C[4];
|
||||
int field_310;
|
||||
u32 field_314;
|
||||
int field_318;
|
||||
u8 gap_31C[20];
|
||||
int field_330;
|
||||
Widget* e_waitIcon;
|
||||
Widget* itemIcon;
|
||||
Widget* branchArrow;
|
||||
Widget* num_widgets[5];
|
||||
Widget* num_base;
|
||||
u8 gap_334[4];
|
||||
u32 field_338;
|
||||
u8 gap_33C[32];
|
||||
u32 field_35C;
|
||||
u32 field_360;
|
||||
Widget* notes;
|
||||
Widget* note_widgets[8];
|
||||
Layout* e_text_layout;
|
||||
Layout* mainPlateLayout;
|
||||
u32 field_364;
|
||||
int field_368;
|
||||
u8 gap_36C[56];
|
||||
@@ -68,25 +67,25 @@ public:
|
||||
int field_43C;
|
||||
int field_440;
|
||||
GlobalContext* gctx;
|
||||
u32 field_448;
|
||||
u32 field_44C;
|
||||
int field_450;
|
||||
u32 field_454;
|
||||
u8 gap_458[4];
|
||||
int field_45C;
|
||||
int field_460;
|
||||
int field_464;
|
||||
int field_468;
|
||||
int field_46C;
|
||||
int field_470;
|
||||
int field_474;
|
||||
int field_478;
|
||||
int field_47C;
|
||||
int field_480;
|
||||
int field_484;
|
||||
int field_488;
|
||||
int field_48C;
|
||||
int field_490;
|
||||
AnimPlayer* main_player;
|
||||
AnimPlayer* sub_player;
|
||||
AnimPlayer* switch_plate_player;
|
||||
AnimPlayer* ocarina_player;
|
||||
AnimPlayer* localize_plat_eplayer;
|
||||
AnimPlayer* plate_alpha_player;
|
||||
Anim* open;
|
||||
Anim* close;
|
||||
Anim* mapTelop_display;
|
||||
Anim* mapTelop_vanish;
|
||||
Anim* timeTelop_display;
|
||||
Anim* timeTelop_vanish;
|
||||
Anim* keyWait;
|
||||
Anim* branchWait;
|
||||
Anim* textFadein;
|
||||
Anim* textFadeout;
|
||||
Anim* failure;
|
||||
Anim* num_base_anim;
|
||||
Anim* switch_loc_win;
|
||||
u32 field_494;
|
||||
u8 gap_498[1432];
|
||||
u32 field_A30;
|
||||
|
@@ -5,6 +5,7 @@
|
||||
#include "common/utils.h"
|
||||
#include "game/pad.h"
|
||||
#include "game/sound.h"
|
||||
#include "game/ui.h"
|
||||
|
||||
namespace game::ui {
|
||||
|
||||
@@ -12,19 +13,8 @@ int MessageTextState::GetChoicePositionY(int choice) const {
|
||||
return rst::util::GetPointer<int(const MessageTextState&, int)>(0x1C6AD4)(*this, choice);
|
||||
}
|
||||
|
||||
void BranchArrowData::SetPositionY(float new_y) {
|
||||
if (pos_y == new_y)
|
||||
return;
|
||||
pos_y = new_y;
|
||||
flags2 |= 0x200;
|
||||
if (new_y == 0.0)
|
||||
flags |= 0x200;
|
||||
else
|
||||
flags &= ~0x200;
|
||||
}
|
||||
|
||||
void MessageHandleChoice(int* current_choice, const pad::State& pad,
|
||||
const MessageTextState& text_state, BranchArrow& arrow, bool play_sound) {
|
||||
const MessageTextState& text_state, Widget& arrow, bool play_sound) {
|
||||
int new_choice = *current_choice;
|
||||
if (pad.input.new_buttons.IsOneSet(pad::Button::Up, pad::Button::MainStickUp))
|
||||
new_choice -= 1;
|
||||
@@ -35,7 +25,7 @@ void MessageHandleChoice(int* current_choice, const pad::State& pad,
|
||||
}
|
||||
|
||||
void MessageHandleChoice(int* current_choice, int new_choice, const MessageTextState& text_state,
|
||||
BranchArrow& arrow, bool play_sound) {
|
||||
Widget& arrow, bool play_sound) {
|
||||
if (text_state.num_choices <= 0)
|
||||
return;
|
||||
|
||||
@@ -46,8 +36,8 @@ void MessageHandleChoice(int* current_choice, int new_choice, const MessageTextS
|
||||
if (play_sound)
|
||||
sound::PlayEffect(sound::EffectId::NA_SE_SY_CURSOR);
|
||||
|
||||
const float new_y = text_state.GetChoicePositionY(text_state.first_choice_slot + new_choice) + 8;
|
||||
arrow.data.SetPositionY(new_y);
|
||||
arrow.GetPos().SetTranslateY(
|
||||
text_state.GetChoicePositionY(text_state.first_choice_slot + new_choice) + 8);
|
||||
*current_choice = new_choice;
|
||||
}
|
||||
|
||||
|
@@ -8,6 +8,8 @@ struct State;
|
||||
|
||||
namespace game::ui {
|
||||
|
||||
class Widget;
|
||||
|
||||
// XXX: Incomplete.
|
||||
struct MessageTextState {
|
||||
int GetChoicePositionY(int choice) const;
|
||||
@@ -28,27 +30,9 @@ struct MessageTextState {
|
||||
int field_2F4;
|
||||
};
|
||||
|
||||
// XXX: Incomplete.
|
||||
struct BranchArrowData {
|
||||
void SetPositionY(float y);
|
||||
|
||||
u32 field_0;
|
||||
float pos_y;
|
||||
u8 gap_8[64];
|
||||
u32 flags2;
|
||||
u32 flags;
|
||||
};
|
||||
|
||||
// XXX: Incomplete. This is a UI widget.
|
||||
struct BranchArrow {
|
||||
u8 gap_0[60];
|
||||
BranchArrowData data;
|
||||
};
|
||||
|
||||
void MessageHandleChoice(int* current_choice, const pad::State& pad,
|
||||
const MessageTextState& text_state, BranchArrow& arrow,
|
||||
bool play_sound = true);
|
||||
const MessageTextState& text_state, Widget& arrow, bool play_sound = true);
|
||||
void MessageHandleChoice(int* current_choice, int new_choice, const MessageTextState& text_state,
|
||||
BranchArrow& arrow, bool play_sound = true);
|
||||
Widget& arrow, bool play_sound = true);
|
||||
|
||||
} // namespace game::ui
|
||||
|
Reference in New Issue
Block a user