11package net .kdt .pojavlaunch .fragments ;
22
3- import static net .kdt .pojavlaunch .Tools .dialogOnUiThread ;
43import static net .kdt .pojavlaunch .Tools .hasNoOnlineProfileDialog ;
54import static net .kdt .pojavlaunch .Tools .hasOnlineProfile ;
65import static net .kdt .pojavlaunch .Tools .openPath ;
7- import static net .kdt .pojavlaunch .Tools .runOnUiThread ;
86import static net .kdt .pojavlaunch .Tools .shareLog ;
97
10- import android .app .Dialog ;
118import android .content .Intent ;
129import android .os .Bundle ;
1310import android .view .View ;
1714
1815import androidx .annotation .NonNull ;
1916import androidx .annotation .Nullable ;
20- import androidx .appcompat .app .AlertDialog ;
2117import androidx .fragment .app .Fragment ;
2218
2319import com .kdt .mcgui .mcVersionSpinner ;
@@ -39,63 +35,93 @@ public class MainMenuFragment extends Fragment {
3935
4036 private mcVersionSpinner mVersionSpinner ;
4137
42- public MainMenuFragment (){
38+ public MainMenuFragment () {
4339 super (R .layout .fragment_launcher );
4440 }
4541
4642 @ Override
4743 public void onViewCreated (@ NonNull View view , @ Nullable Bundle savedInstanceState ) {
48- Button mNewsButton = view .findViewById (R .id .news_button );
49- Button mDiscordButton = view .findViewById (R .id .discord_button );
50- Button mCustomControlButton = view .findViewById (R .id .custom_control_button );
51- Button mInstallJarButton = view .findViewById (R .id .install_jar_button );
52- Button mShareLogsButton = view .findViewById (R .id .share_logs_button );
53- Button mOpenDirectoryButton = view .findViewById (R .id .open_files_button );
44+ Button mNewsButton = view .findViewById (R .id .news_button );
45+ Button mDiscordButton = view .findViewById (R .id .discord_button );
46+ Button mCustomControlButton = view .findViewById (R .id .custom_control_button );
47+ Button mInstallJarButton = view .findViewById (R .id .install_jar_button );
48+ Button mShareLogsButton = view .findViewById (R .id .share_logs_button );
49+ Button mManageModsButton = view .findViewById (R .id .open_files_button );
50+ Button mOpenDirectoryButton = view .findViewById (R .id .open_directory_button );
51+ Button mModStoreButton = view .findViewById (R .id .mod_store_button );
5452
5553 ImageButton mEditProfileButton = view .findViewById (R .id .edit_profile_button );
5654 Button mPlayButton = view .findViewById (R .id .play_button );
5755 mVersionSpinner = view .findViewById (R .id .mc_version_spinner );
5856
57+ // Wiki
5958 mNewsButton .setOnClickListener (v -> Tools .openURL (requireActivity (), Tools .URL_HOME ));
59+
60+ // Discord
6061 mDiscordButton .setOnClickListener (v -> Tools .openURL (requireActivity (), getString (R .string .discord_invite )));
61- mCustomControlButton .setOnClickListener (v -> startActivity (new Intent (requireContext (), CustomControlsActivity .class )));
62+
63+ // Custom controls
64+ mCustomControlButton .setOnClickListener (v ->
65+ startActivity (new Intent (requireContext (), CustomControlsActivity .class )));
66+
67+ // Mod Store → individual mod search
68+ if (mModStoreButton != null )
69+ mModStoreButton .setOnClickListener (v ->
70+ Tools .swapFragment (requireActivity (), ModsSearchFragment .class , ModsSearchFragment .TAG , null ));
71+
72+ // Execute .jar
6273 if (hasOnlineProfile ()) {
6374 mInstallJarButton .setOnClickListener (v -> runInstallerWithConfirmation (false ));
6475 mInstallJarButton .setOnLongClickListener (v -> {
6576 runInstallerWithConfirmation (true );
6677 return true ;
6778 });
68- } else mInstallJarButton .setOnClickListener (v -> hasNoOnlineProfileDialog (requireActivity ()));
69- mEditProfileButton .setOnClickListener (v -> mVersionSpinner .openProfileEditor (requireActivity ()));
70-
71- mPlayButton .setOnClickListener (v -> {
72- ExtraCore .setValue (ExtraConstants .LAUNCH_GAME , true );
73- });
74-
75- mShareLogsButton .setOnClickListener ((v ) -> shareLog (requireContext ()));
76-
77- mOpenDirectoryButton .setOnClickListener ((v )-> {
78- if (Tools .isDemoProfile (v .getContext ())){ // Say a different message when on demo profile since they might see the hidden demo folder
79- hasNoOnlineProfileDialog (getActivity (), getString (R .string .demo_unsupported ), getString (R .string .change_account ));
80- } else if (!hasOnlineProfile ()) { // Otherwise display the generic pop-up to log in
81- hasNoOnlineProfileDialog (requireActivity ());
82- } else openPath (v .getContext (), getCurrentProfileDirectory (), false );
79+ } else {
80+ mInstallJarButton .setOnClickListener (v -> hasNoOnlineProfileDialog (requireActivity ()));
81+ }
82+
83+ // Share logs
84+ if (mShareLogsButton != null )
85+ mShareLogsButton .setOnClickListener (v -> shareLog (requireContext ()));
86+
87+ // Manage Mods & Tools → new UI
88+ mManageModsButton .setOnClickListener (v ->
89+ Tools .swapFragment (requireActivity (), ManageModsFragment .class , ManageModsFragment .TAG , null ));
90+
91+ // Open game directory (original behaviour)
92+ if (mOpenDirectoryButton != null ) {
93+ mOpenDirectoryButton .setOnClickListener (v -> {
94+ if (Tools .isDemoProfile (v .getContext ())) {
95+ hasNoOnlineProfileDialog (getActivity (),
96+ getString (R .string .demo_unsupported ), getString (R .string .change_account ));
97+ } else if (!hasOnlineProfile ()) {
98+ hasNoOnlineProfileDialog (requireActivity ());
99+ } else {
100+ openPath (v .getContext (), getCurrentProfileDirectory (), false );
101+ }
102+ });
103+ }
83104
84- });
105+ // Edit profile
106+ mEditProfileButton .setOnClickListener (v -> mVersionSpinner .openProfileEditor (requireActivity ()));
85107
108+ // Play
109+ mPlayButton .setOnClickListener (v -> ExtraCore .setValue (ExtraConstants .LAUNCH_GAME , true ));
86110
87- mNewsButton .setOnLongClickListener ((v )->{
111+ // Long-press wiki → gamepad mapper (hidden)
112+ mNewsButton .setOnLongClickListener (v -> {
88113 Tools .swapFragment (requireActivity (), GamepadMapperFragment .class , GamepadMapperFragment .TAG , null );
89114 return true ;
90115 });
91116 }
92117
93118 private File getCurrentProfileDirectory () {
94- String currentProfile = LauncherPreferences .DEFAULT_PREF .getString (LauncherPreferences .PREF_KEY_CURRENT_PROFILE , null );
95- if (!Tools .isValidString (currentProfile )) return new File (Tools .DIR_GAME_NEW );
119+ String currentProfile = LauncherPreferences .DEFAULT_PREF
120+ .getString (LauncherPreferences .PREF_KEY_CURRENT_PROFILE , null );
121+ if (!Tools .isValidString (currentProfile )) return new File (Tools .DIR_GAME_NEW );
96122 LauncherProfiles .load ();
97123 MinecraftProfile profileObject = LauncherProfiles .mainProfileJson .profiles .get (currentProfile );
98- if (profileObject == null ) return new File (Tools .DIR_GAME_NEW );
124+ if (profileObject == null ) return new File (Tools .DIR_GAME_NEW );
99125 return Tools .getGameDirPath (profileObject );
100126 }
101127
0 commit comments