Skip to content

Commit

Permalink
Feat[Menu]: hide menu view
Browse files Browse the repository at this point in the history
  • Loading branch information
ShirosakiMio committed Oct 16, 2024
1 parent 0de402b commit cd72b57
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
14 changes: 13 additions & 1 deletion FCL/src/main/java/com/tungsten/fcl/control/GameMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.tungsten.fcl.control.keyboard.TouchCharInput;
import com.tungsten.fcl.control.view.GameItemBar;
import com.tungsten.fcl.control.view.LogWindow;
import com.tungsten.fcl.control.view.MenuView;
import com.tungsten.fcl.control.view.TouchPad;
import com.tungsten.fcl.control.view.ViewManager;
import com.tungsten.fcl.setting.Controller;
Expand Down Expand Up @@ -119,9 +120,14 @@ public class GameMenu implements MenuCallback, View.OnClickListener {
private FCLButton gamepadButtonBinding;
private FCLButton forceExit;

private Thread showFpsThread;
private long time = 0;

private MenuView menuView;

public void setMenuView(MenuView menuView) {
this.menuView = menuView;
}

public FCLActivity getActivity() {
return activity;
}
Expand Down Expand Up @@ -332,6 +338,7 @@ private void refreshViewGroupList(FCLSpinner<ControlViewGroup> spinner) {
@SuppressLint("SetTextI18n")
private void initRightMenu() {
FCLSwitch lockMenuSwitch = findViewById(R.id.switch_lock_view);
FCLSwitch hideMenuSwitch = findViewById(R.id.switch_hide_view);
FCLSwitch showFps = findViewById(R.id.switch_show_fps);
FCLSwitch disableSoftKeyAdjustSwitch = findViewById(R.id.switch_soft_keyboard_adjust);
FCLSwitch disableGestureSwitch = findViewById(R.id.switch_gesture);
Expand Down Expand Up @@ -373,6 +380,11 @@ private void initRightMenu() {
FXUtils.bindBoolean(gyroSwitch, menuSetting.getEnableGyroscopeProperty());
FXUtils.bindBoolean(showLogSwitch, menuSetting.getShowLogProperty());

hideMenuSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
menuView.setVisibility(isChecked ? View.INVISIBLE : View.VISIBLE);
((DrawerLayout) getLayout()).setDrawerLockMode(isChecked ? DrawerLayout.LOCK_MODE_UNLOCKED : DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
});

showFps.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isSimulated()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public void setup() {
MenuView menuView = new MenuView(gameMenu.getActivity());
menuView.setElevation(114.0f);
menuView.setup(gameMenu);
gameMenu.setMenuView(menuView);
gameMenu.getBaseLayout().addView(menuView);
menuView.initPosition();
gameMenu.hideAllViewsProperty().addListener(observable -> menuView.setAlpha(gameMenu.isHideAllViews() ? 0 : 1));
Expand Down
22 changes: 21 additions & 1 deletion FCL/src/main/res/layout/menu_right.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,26 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/divider_func" />

<com.tungsten.fcllibrary.component.view.FCLTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:singleLine="true"
android:text="@string/menu_settings_hide_view"
android:textSize="12sp"
app:auto_text_tint="true"
app:layout_constraintBottom_toBottomOf="@id/switch_hide_view"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/switch_hide_view" />

<com.tungsten.fcllibrary.component.view.FCLSwitch
android:id="@+id/switch_hide_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/switch_lock_view" />

<com.tungsten.fcllibrary.component.view.FCLTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -89,7 +109,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/switch_lock_view" />
app:layout_constraintTop_toBottomOf="@id/switch_hide_view" />

<com.tungsten.fcllibrary.component.view.FCLTextView
android:layout_width="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions FCL/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@
<string name="menu_settings_gyro">陀螺仪</string>
<string name="menu_settings_gyro_sensitivity">陀螺仪灵敏度</string>
<string name="menu_settings_lock_view">锁定菜单键</string>
<string name="menu_settings_hide_view">隐藏菜单键</string>
<string name="menu_settings_show_fps">显示FPS</string>
<string name="menu_settings_mouse">鼠标</string>
<string name="menu_settings_mouse_mode">鼠标控制模式</string>
Expand Down
1 change: 1 addition & 0 deletions FCL/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@
<string name="menu_settings_gyro">Gyroscope</string>
<string name="menu_settings_gyro_sensitivity">Gyro Sensitivity</string>
<string name="menu_settings_lock_view">Lock Menu View</string>
<string name="menu_settings_hide_view">Hide Menu View</string>
<string name="menu_settings_show_fps">Show FPS</string>
<string name="menu_settings_mouse">Mouse</string>
<string name="menu_settings_mouse_mode">Mouse Mode</string>
Expand Down

0 comments on commit cd72b57

Please sign in to comment.