Adding top button option for trophy pop up

This commit is contained in:
Dmugetsu 2025-02-28 10:40:43 -06:00
parent 99c7fc4049
commit ba556cb404
5 changed files with 46 additions and 11 deletions

View File

@ -53,6 +53,7 @@ static bool isShaderDebug = false;
static bool isShowSplash = false; static bool isShowSplash = false;
static bool isAutoUpdate = false; static bool isAutoUpdate = false;
static bool isAlwaysShowChangelog = false; static bool isAlwaysShowChangelog = false;
static bool isTopSideTrophy = false;
static bool isLeftSideTrophy = false; static bool isLeftSideTrophy = false;
static bool isNullGpu = false; static bool isNullGpu = false;
static bool shouldCopyGPUBuffers = false; static bool shouldCopyGPUBuffers = false;
@ -270,6 +271,10 @@ bool alwaysShowChangelog() {
return isAlwaysShowChangelog; return isAlwaysShowChangelog;
} }
bool TopSideTrophy() {
return isTopSideTrophy;
}
bool leftSideTrophy() { bool leftSideTrophy() {
return isLeftSideTrophy; return isLeftSideTrophy;
} }
@ -381,6 +386,9 @@ void setAutoUpdate(bool enable) {
void setAlwaysShowChangelog(bool enable) { void setAlwaysShowChangelog(bool enable) {
isAlwaysShowChangelog = enable; isAlwaysShowChangelog = enable;
} }
void setTopSideTrophy(bool enable) {
isTopSideTrophy = enable;
}
void setLeftSideTrophy(bool enable) { void setLeftSideTrophy(bool enable) {
isLeftSideTrophy = enable; isLeftSideTrophy = enable;
} }
@ -737,6 +745,7 @@ void load(const std::filesystem::path& path) {
isShowSplash = toml::find_or<bool>(general, "showSplash", true); isShowSplash = toml::find_or<bool>(general, "showSplash", true);
isAutoUpdate = toml::find_or<bool>(general, "autoUpdate", false); isAutoUpdate = toml::find_or<bool>(general, "autoUpdate", false);
isAlwaysShowChangelog = toml::find_or<bool>(general, "alwaysShowChangelog", false); isAlwaysShowChangelog = toml::find_or<bool>(general, "alwaysShowChangelog", false);
isTopSideTrophy = toml::find_or<bool>(general, "TopSideTrophy", false);
isLeftSideTrophy = toml::find_or<bool>(general, "leftSideTrophy", false); isLeftSideTrophy = toml::find_or<bool>(general, "leftSideTrophy", false);
separateupdatefolder = toml::find_or<bool>(general, "separateUpdateEnabled", false); separateupdatefolder = toml::find_or<bool>(general, "separateUpdateEnabled", false);
compatibilityData = toml::find_or<bool>(general, "compatibilityEnabled", false); compatibilityData = toml::find_or<bool>(general, "compatibilityEnabled", false);
@ -888,6 +897,7 @@ void save(const std::filesystem::path& path) {
data["General"]["showSplash"] = isShowSplash; data["General"]["showSplash"] = isShowSplash;
data["General"]["autoUpdate"] = isAutoUpdate; data["General"]["autoUpdate"] = isAutoUpdate;
data["General"]["alwaysShowChangelog"] = isAlwaysShowChangelog; data["General"]["alwaysShowChangelog"] = isAlwaysShowChangelog;
data["General"]["TopSideTrophy"] = isTopSideTrophy;
data["General"]["leftSideTrophy"] = isLeftSideTrophy; data["General"]["leftSideTrophy"] = isLeftSideTrophy;
data["General"]["separateUpdateEnabled"] = separateupdatefolder; data["General"]["separateUpdateEnabled"] = separateupdatefolder;
data["General"]["compatibilityEnabled"] = compatibilityData; data["General"]["compatibilityEnabled"] = compatibilityData;
@ -1018,6 +1028,7 @@ void setDefaultValues() {
isShowSplash = false; isShowSplash = false;
isAutoUpdate = false; isAutoUpdate = false;
isAlwaysShowChangelog = false; isAlwaysShowChangelog = false;
isTopSideTrophy = false;
isLeftSideTrophy = false; isLeftSideTrophy = false;
isNullGpu = false; isNullGpu = false;
shouldDumpShaders = false; shouldDumpShaders = false;

View File

@ -63,6 +63,7 @@ bool collectShadersForDebug();
bool showSplash(); bool showSplash();
bool autoUpdate(); bool autoUpdate();
bool alwaysShowChangelog(); bool alwaysShowChangelog();
bool TopSideTrophy();
bool leftSideTrophy(); bool leftSideTrophy();
bool nullGpu(); bool nullGpu();
bool copyGPUCmdBuffers(); bool copyGPUCmdBuffers();
@ -77,6 +78,7 @@ void setCollectShaderForDebug(bool enable);
void setShowSplash(bool enable); void setShowSplash(bool enable);
void setAutoUpdate(bool enable); void setAutoUpdate(bool enable);
void setAlwaysShowChangelog(bool enable); void setAlwaysShowChangelog(bool enable);
void setTopSideTrophy(bool enable);
void setLeftSideTrophy(bool enable); void setLeftSideTrophy(bool enable);
void setNullGpu(bool enable); void setNullGpu(bool enable);
void setAllowHDR(bool enable); void setAllowHDR(bool enable);

View File

@ -27,6 +27,7 @@ namespace Libraries::NpTrophy {
std::optional<TrophyUI> current_trophy_ui; std::optional<TrophyUI> current_trophy_ui;
std::queue<TrophyInfo> trophy_queue; std::queue<TrophyInfo> trophy_queue;
std::mutex queueMtx; std::mutex queueMtx;
bool isTopSide;
bool isLeftSide; bool isLeftSide;
double trophy_timer; double trophy_timer;
@ -34,6 +35,7 @@ TrophyUI::TrophyUI(const std::filesystem::path& trophyIconPath, const std::strin
const std::string_view& rarity) const std::string_view& rarity)
: trophy_name(trophyName), trophy_type(rarity) { : trophy_name(trophyName), trophy_type(rarity) {
isTopSide = Config::TopSideTrophy();
isLeftSide = Config::leftSideTrophy(); isLeftSide = Config::leftSideTrophy();
trophy_timer = Config::getTrophyNotificationDuration(); trophy_timer = Config::getTrophyNotificationDuration();
@ -115,8 +117,8 @@ float fade_out_duration = 0.5f; // Final fade duration
void TrophyUI::Draw() { void TrophyUI::Draw() {
const auto& io = GetIO(); const auto& io = GetIO();
float AdjustWidth = io.DisplaySize.x / 1280; float AdjustWidth = io.DisplaySize.x / 1920;
float AdjustHeight = io.DisplaySize.y / 720; float AdjustHeight = io.DisplaySize.y / 1080;
const ImVec2 window_size{ const ImVec2 window_size{
std::min(io.DisplaySize.x, (350 * AdjustWidth)), std::min(io.DisplaySize.x, (350 * AdjustWidth)),
std::min(io.DisplaySize.y, (70 * AdjustHeight)), std::min(io.DisplaySize.y, (70 * AdjustHeight)),
@ -125,21 +127,33 @@ void TrophyUI::Draw() {
elapsed_time += io.DeltaTime; elapsed_time += io.DeltaTime;
float progress = std::min(elapsed_time / animation_duration, 1.0f); float progress = std::min(elapsed_time / animation_duration, 1.0f);
// left or right position float final_pos_x, start_x;
float final_pos_x; float final_pos_y, start_y;
if (isLeftSide) {
start_pos.x = -window_size.x; if (isTopSide) {
start_x = (io.DisplaySize.x - window_size.x) * 0.5f;
start_y = -window_size.y;
final_pos_x = start_x;
final_pos_y = 50 * AdjustHeight;
} else if (isLeftSide) {
start_x = -window_size.x;
start_y = 50 * AdjustHeight;
final_pos_x = 20 * AdjustWidth; final_pos_x = 20 * AdjustWidth;
final_pos_y = start_y;
} else { } else {
start_pos.x = io.DisplaySize.x; start_x = io.DisplaySize.x;
start_y = 50 * AdjustHeight;
final_pos_x = io.DisplaySize.x - window_size.x - 20 * AdjustWidth; final_pos_x = io.DisplaySize.x - window_size.x - 20 * AdjustWidth;
final_pos_y = start_y;
} }
ImVec2 current_pos = ImVec2(start_pos.x + (final_pos_x - start_pos.x) * progress, ImVec2 current_pos = ImVec2(start_x + (final_pos_x - start_x) * progress,
start_pos.y + (target_pos.y - start_pos.y) * progress); start_y + (final_pos_y - start_y) * progress);
trophy_timer -= io.DeltaTime; trophy_timer -= io.DeltaTime;
ImGui::SetNextWindowPos(current_pos);
// If the remaining time of the trophy is less than or equal to 1 second, the fade-out begins. // If the remaining time of the trophy is less than or equal to 1 second, the fade-out begins.
if (trophy_timer <= 1.0f) { if (trophy_timer <= 1.0f) {
float fade_out_time = 1.0f - (trophy_timer / 1.0f); float fade_out_time = 1.0f - (trophy_timer / 1.0f);

View File

@ -418,8 +418,9 @@ void SettingsDialog::LoadValuesFromConfig() {
ui->disableTrophycheckBox->setChecked( ui->disableTrophycheckBox->setChecked(
toml::find_or<bool>(data, "General", "isTrophyPopupDisabled", false)); toml::find_or<bool>(data, "General", "isTrophyPopupDisabled", false));
ui->popUpDurationSpinBox->setValue(Config::getTrophyNotificationDuration()); ui->popUpDurationSpinBox->setValue(Config::getTrophyNotificationDuration());
ui->radioButton_Top->setChecked(Config::TopSideTrophy());
ui->radioButton_Left->setChecked(Config::leftSideTrophy()); ui->radioButton_Left->setChecked(Config::leftSideTrophy());
ui->radioButton_Right->setChecked(!ui->radioButton_Left->isChecked()); ui->radioButton_Right->setChecked(!(ui->radioButton_Left->isChecked() || ui->radioButton_Top->isChecked()));
ui->BGMVolumeSlider->setValue(toml::find_or<int>(data, "General", "BGMvolume", 50)); ui->BGMVolumeSlider->setValue(toml::find_or<int>(data, "General", "BGMvolume", 50));
ui->discordRPCCheckbox->setChecked( ui->discordRPCCheckbox->setChecked(
toml::find_or<bool>(data, "General", "enableDiscordRPC", true)); toml::find_or<bool>(data, "General", "enableDiscordRPC", true));
@ -706,6 +707,7 @@ void SettingsDialog::UpdateSettings() {
Config::setIsMotionControlsEnabled(ui->motionControlsCheckBox->isChecked()); Config::setIsMotionControlsEnabled(ui->motionControlsCheckBox->isChecked());
Config::setisTrophyPopupDisabled(ui->disableTrophycheckBox->isChecked()); Config::setisTrophyPopupDisabled(ui->disableTrophycheckBox->isChecked());
Config::setTrophyNotificationDuration(ui->popUpDurationSpinBox->value()); Config::setTrophyNotificationDuration(ui->popUpDurationSpinBox->value());
Config::setTopSideTrophy(ui->radioButton_Top->isChecked());
Config::setLeftSideTrophy(ui->radioButton_Left->isChecked()); Config::setLeftSideTrophy(ui->radioButton_Left->isChecked());
Config::setPlayBGM(ui->playBGMCheckBox->isChecked()); Config::setPlayBGM(ui->playBGMCheckBox->isChecked());
Config::setAllowHDR(ui->enableHDRCheckBox->isChecked()); Config::setAllowHDR(ui->enableHDRCheckBox->isChecked());

View File

@ -1284,6 +1284,12 @@
<property name="text"> <property name="text">
<string>Trophy Notification Position</string> <string>Trophy Notification Position</string>
</property> </property>
</widget>
<item>
<widget class="QRadioButton" name="radioButton_Top">
<property name="text">
<string>Top</string>
</property>
</widget> </widget>
</item> </item>
<item> <item>