Skip to content

Commit

Permalink
Add negative infinity AR toggle.
Browse files Browse the repository at this point in the history
  • Loading branch information
Reco1I committed Nov 24, 2023
1 parent f3099dd commit c28f959
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
32 changes: 17 additions & 15 deletions res/layout/fragment_in_game_option.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center"
android:orientation="vertical"
android:translationY="260dp">
android:orientation="vertical">


<RelativeLayout
Expand Down Expand Up @@ -232,21 +231,14 @@
</RelativeLayout>

<!--Pitch shift-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
<CheckBox
android:layout_marginBottom="14dp"
android:layout_marginHorizontal="14dp"
android:gravity="center_vertical">

<CheckBox
android:id="@+id/enableNCwhenSpeedChange"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:saveEnabled="false"
android:text="@string/opt_enablenc_whenspeedchange_title"/>

</LinearLayout>
android:id="@+id/enableNCwhenSpeedChange"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:saveEnabled="false"
android:text="@string/opt_enablenc_whenspeedchange_title"/>

<View
android:layout_width="match_parent"
Expand Down Expand Up @@ -289,6 +281,16 @@

</RelativeLayout>

<!--Negative infinity AR-->
<CheckBox
android:id="@+id/negative_infinity_ar"
android:layout_marginBottom="8dp"
android:layout_marginHorizontal="14dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:saveEnabled="false"
android:text="Force negative infinity AR (Can reduce performance in some devices)"/>

<!--OD-->
<RelativeLayout
android:layout_width="match_parent"
Expand Down
26 changes: 23 additions & 3 deletions src/com/edlplan/ui/fragment/InGameSettingMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@
import ru.nsu.ccfit.zuev.osu.menu.ModMenu;
import ru.nsu.ccfit.zuev.osuplus.R;

import static java.lang.Float.NEGATIVE_INFINITY;

public class InGameSettingMenu extends BaseFragment {

private static InGameSettingMenu menu;

private CheckBox negativeInfinityARToggle;

private View speedModifyRow;
private SeekBar speedModifyBar;
private TextView speedModifyText;
Expand Down Expand Up @@ -109,6 +113,8 @@ private void reload() {
speedModifyRow = findViewById(R.id.speed_modify);
followDelayRow = findViewById(R.id.follow_delay_row);

negativeInfinityARToggle = findViewById(R.id.negative_infinity_ar);

customARBar = findViewById(R.id.custom_ar_bar);
customARText = findViewById(R.id.custom_ar_text);
customARToggle = findViewById(R.id.custom_ar_toggle);
Expand Down Expand Up @@ -304,13 +310,23 @@ private void initializeDifficultyAdjustViews() {
customCSBar.setMax(110);
customHPBar.setMax(110);

negativeInfinityARToggle.setOnCheckedChangeListener(null);
customARToggle.setOnCheckedChangeListener(null);
customODToggle.setOnCheckedChangeListener(null);
customCSToggle.setOnCheckedChangeListener(null);
customHPToggle.setOnCheckedChangeListener(null);

updateDifficultyAdjustValues();

negativeInfinityARToggle.setOnCheckedChangeListener((view, isChecked) -> {

customARToggle.setEnabled(!isChecked);
customARBar.setEnabled(!isChecked);
ModMenu.getInstance().setCustomAR(NEGATIVE_INFINITY);

updateDifficultyAdjustValues();
});

customARToggle.setOnCheckedChangeListener((view, isChecked) -> {

ModMenu.getInstance().setCustomAR(isChecked ? customARBar.getProgress() / 10f : null);
Expand Down Expand Up @@ -414,9 +430,13 @@ private void updateDifficultyAdjustValues() {
var track = GlobalManager.getInstance().getSelectedTrack();

var customAR = ModMenu.getInstance().getCustomAR();
customARBar.setEnabled(customAR != null);
customARToggle.setChecked(customAR != null);
customARBar.setProgress((int) ((customAR != null ? customAR : track != null ? track.getApproachRate() : 10) * 10));
negativeInfinityARToggle.setEnabled(customAR != null && customAR == NEGATIVE_INFINITY);

var isCustom = customAR != null && customAR != NEGATIVE_INFINITY;
customARBar.setEnabled(isCustom);
customARToggle.setEnabled(isCustom);
customARToggle.setChecked(isCustom);
customARBar.setProgress((int) ((isCustom ? customAR : track != null ? track.getApproachRate() : 10) * 10));
customARText.setText(String.valueOf(customARBar.getProgress() / 10f));

var customOD = ModMenu.getInstance().getCustomOD();
Expand Down

0 comments on commit c28f959

Please sign in to comment.