Skip to content

Commit

Permalink
Attempt at updating this
Browse files Browse the repository at this point in the history
if this doesn't work please report issue so I can drop this branch
  • Loading branch information
SolDev69 committed Nov 7, 2024
2 parents f2f5cd2 + ace444c commit 6e84857
Show file tree
Hide file tree
Showing 31 changed files with 470 additions and 808 deletions.
827 changes: 159 additions & 668 deletions LICENSE

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ SolCraftLauncher is a fork of PojavLauncher with more technical added features,

* It can run almost every version of Minecraft, allowing you to use .jar only installers to install modloaders such as [Forge](https://files.minecraftforge.net/) and [Fabric](http://fabricmc.net/), mods like [OptiFine](https://optifine.net) and [LabyMod](https://www.labymod.net/en), as well as hack clients like [Wurst](https://www.wurstclient.net/), and much more!

* For more details [check out our wiki](https://github.com/PojavLauncherTeam/PojavLauncher/wiki)
* For more details [check out our wiki](https://pojavlauncherteam.github.io/)
## Some notes to start with
- We do not have an official TikTok account. No one from the dev team makes TikTok videos.
- The official Twitter for PojavLauncher is [@PLaunchTeam](https://twitter.com/PLaunchTeam). Any others (most notably @PojavLauncher) are fake, please report them to Twitter's moderation team.
- The official Twitter for PojavLauncher is [@PLaunchTeam](https://twitter.com/PLaunchTeam). Any others (most notably @PojavLauncher) are fake.

## Navigation
- [Introduction](#introduction)
Expand Down
2 changes: 1 addition & 1 deletion app_pojavlauncher/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ dependencies {
implementation 'com.github.PojavLauncherTeam:portrait-sdp:ed33e89cbc'
implementation 'com.github.PojavLauncherTeam:portrait-ssp:6c02fd739b'
implementation 'com.github.Mathias-Boulay:ExtendedView:1.0.0'
implementation 'com.github.Mathias-Boulay:android_gamepad_remapper:06184ddbce'
implementation 'com.github.Mathias-Boulay:android_gamepad_remapper:2.0.3'
implementation 'com.github.Mathias-Boulay:virtual-joystick-android:2e7aa25e50'

// implementation 'com.intuit.sdp:sdp-android:1.0.5'
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1716170694497
1731000005209
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1716170694527
1731000005256
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;

Expand All @@ -21,21 +20,26 @@ public class ExitActivity extends AppCompatActivity {
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int code = -1;
boolean isSignal = false;
Bundle extras = getIntent().getExtras();
if(extras != null) {
code = extras.getInt("code",-1);
isSignal = extras.getBoolean("isSignal", false);
}

int message = isSignal ? R.string.mcn_signal_title : R.string.mcn_exit_title;

new AlertDialog.Builder(this)
.setMessage(getString(R.string.mcn_exit_title,code))
.setMessage(getString(message,code))
.setPositiveButton(R.string.main_share_logs, (dialog, which) -> shareLog(this))
.setOnDismissListener(dialog -> ExitActivity.this.finish())
.show();
}

public static void showExitMessage(Context ctx, int code) {
public static void showExitMessage(Context ctx, int code, boolean isSignal) {
Intent i = new Intent(ctx,ExitActivity.class);
i.putExtra("code",code);
i.putExtra("isSignal", isSignal);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ctx.startActivity(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ private void runCraft(String versionId, JMinecraftVersionList.Version version) t
Tools.releaseRenderersCache();
}
MinecraftAccount minecraftAccount = PojavProfile.getCurrentProfileContent(this, null);
Logger.appendToLog("--------- beginning with launcher debug");
Logger.appendToLog("--------- Starting game with Launcher Debug!");
printLauncherInfo(versionId, Tools.isValidString(minecraftProfile.javaArgs) ? minecraftProfile.javaArgs : LauncherPreferences.PREF_CUSTOM_JAVA_ARGS);
JREUtils.redirectAndPrintJRELog();
LauncherProfiles.load();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public class MinecraftGLSurface extends View implements GrabListener {
.remapLeftShoulder(true)
.remapRightShoulder(true)
.remapLeftTrigger(true)
.remapRightTrigger(true));
.remapRightTrigger(true)
.remapDpad(true));

/* Resolution scaler option, allow downsizing a window */
private final float mScaleFactor = LauncherPreferences.PREF_SCALE_FACTOR/100f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public class GamepadButton extends GamepadEmulatedButton {

@Override
protected void onDownStateChanged(boolean isDown) {
if(isToggleable && isDown){
if(isToggleable) {
if(!isDown) return;
mIsToggled = !mIsToggled;
Gamepad.sendInput(keycodes, mIsToggled);
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package net.kdt.pojavlaunch.customcontrols.gamepad;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.Spinner;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.SwitchCompat;
import androidx.recyclerview.widget.RecyclerView;

import net.kdt.pojavlaunch.EfficientAndroidLWJGLKeycode;
Expand Down Expand Up @@ -152,15 +153,17 @@ protected void onDownStateChanged(boolean isDown) {
}
}

public class ViewHolder extends RecyclerView.ViewHolder implements AdapterView.OnItemSelectedListener, View.OnClickListener {
public class ViewHolder extends RecyclerView.ViewHolder implements AdapterView.OnItemSelectedListener, View.OnClickListener, CompoundButton.OnCheckedChangeListener {
private static final int COLOR_ACTIVE_BUTTON = 0x2000FF00;
private final Context mContext;
private final ImageView mButtonIcon;
private final ImageView mExpansionIndicator;
private final Spinner[] mKeySpinners;
private final View mExpandedView;
private final SwitchCompat mToggleableSwitch;
private final TextView mKeycodeLabel;
private int mAttachedPosition = -1;
private GamepadEmulatedButton mAttachedButton;
private short[] mKeycodes;

public ViewHolder(@NonNull View itemView) {
Expand All @@ -170,6 +173,8 @@ public ViewHolder(@NonNull View itemView) {
mExpandedView = itemView.findViewById(R.id.controller_mapper_expanded_view);
mExpansionIndicator = itemView.findViewById(R.id.controller_mapper_expand_button);
mKeycodeLabel = itemView.findViewById(R.id.controller_mapper_keycode_label);
mToggleableSwitch = itemView.findViewById(R.id.controller_mapper_toggleable_switch);
mToggleableSwitch.setOnCheckedChangeListener(this);
View defaultView = itemView.findViewById(R.id.controller_mapper_default_view);
defaultView.setOnClickListener(this);
mKeySpinners = new Spinner[4];
Expand All @@ -192,6 +197,15 @@ private void attach(int index) {

GamepadEmulatedButton realButton = mRealButtons[index];

mAttachedButton = realButton;

if(realButton instanceof GamepadButton) {
mToggleableSwitch.setChecked(((GamepadButton)realButton).isToggleable);
mToggleableSwitch.setVisibility(View.VISIBLE);
}else {
mToggleableSwitch.setVisibility(View.GONE);
}

mKeycodes = realButton.keycodes;

int spinnerIndex;
Expand All @@ -217,6 +231,7 @@ private void attach(int index) {
private void detach() {
mRebinderButtons[mAttachedPosition].changeViewHolder(null);
mAttachedPosition = -1;
mAttachedButton = null;
}
private void setPressed(boolean pressed) {
itemView.setBackgroundColor(pressed ? COLOR_ACTIVE_BUTTON : Color.TRANSPARENT);
Expand Down Expand Up @@ -276,6 +291,17 @@ public void onClick(View view) {
mExpandedView.setVisibility(View.GONE);
}
}

@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
if(!(mAttachedButton instanceof GamepadButton)) return;
((GamepadButton)mAttachedButton).isToggleable = checked;
try {
GamepadMapStore.save();
}catch (Exception e) {
Tools.showError(compoundButton.getContext(), e);
}
}
}

@Override
Expand All @@ -299,15 +325,13 @@ public void attachGrabListener(GrabListener grabListener) {
grabListener.onGrabState(mGrabState);
}

// Cannot do it another way
@SuppressLint("NotifyDataSetChanged")
public void setGrabState(boolean newState) {
mGrabState = newState;
if(mGamepadGrabListener != null) mGamepadGrabListener.onGrabState(newState);
if(mGrabState == mOldState) return;
updateRealButtons();
updateStickIcons();
notifyDataSetChanged();
notifyItemRangeChanged(0, mRebinderButtons.length);
mOldState = mGrabState;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public boolean onTouchEvent(MotionEvent event) {
else mDropGesture.submit();
// Determine the hotbar slot
float x = event.getX();
if(x < 0 || x > mWidth) {
// Ignore positions equal to mWidth because they would translate into an out-of-bounds hotbar index
if(x < 0 || x >= mWidth) {
// If out of bounds, cancel the hotbar gesture to avoid dropping items on last hotbar slots
mDropGesture.cancel();
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public class GamepadMapperFragment extends Fragment implements
.remapLeftShoulder(true)
.remapRightShoulder(true)
.remapLeftTrigger(true)
.remapRightTrigger(true);
.remapRightTrigger(true)
.remapDpad(true);
private final Handler mExitHandler = new Handler(Looper.getMainLooper());
private final Runnable mExitRunnable = () -> {
Activity activity = getActivity();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.kdt.pojavlaunch.fragments;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
Expand All @@ -20,20 +21,27 @@
public class LocalLoginFragment extends Fragment {
public static final String TAG = "LOCAL_LOGIN_FRAGMENT";

private final Pattern mUsernameValidationPattern;
private EditText mUsernameEditText;

public LocalLoginFragment(){
super(R.layout.fragment_local_login);
mUsernameValidationPattern = Pattern.compile("^[a-zA-Z0-9_]*$");
}

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
mUsernameEditText = view.findViewById(R.id.login_edit_email);
view.findViewById(R.id.login_button).setOnClickListener(v -> {
if(!checkEditText()) return;
if(!checkEditText()) {
Context context = v.getContext();
Tools.dialog(context, context.getString(R.string.local_login_bad_username_title), context.getString(R.string.local_login_bad_username_text));
return;
}

ExtraCore.setValue(ExtraConstants.MOJANG_LOGIN_TODO, new String[]{
mUsernameEditText.getText().toString(), "" });
mUsernameEditText.getText().toString(), ""
});

Tools.swapFragment(requireActivity(), MainMenuFragment.class, MainMenuFragment.TAG, null);
});
Expand All @@ -45,13 +53,11 @@ private boolean checkEditText(){

String text = mUsernameEditText.getText().toString();

Pattern pattern = Pattern.compile("[^a-zA-Z0-9_]");
Matcher matcher = pattern.matcher(text);

Matcher matcher = mUsernameValidationPattern.matcher(text);
return !(text.isEmpty()
|| text.length() < 3
|| text.length() > 16
|| matcher.find()
|| !matcher.find()
|| new File(Tools.DIR_ACCOUNT_NEW + "/" + text + ".json").exists()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public MainMenuFragment(){
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
Button mNewsButton = view.findViewById(R.id.news_button);
Button mDiscordButton = view.findViewById(R.id.discord_button);
Button mCustomControlButton = view.findViewById(R.id.custom_control_button);
Button mInstallJarButton = view.findViewById(R.id.install_jar_button);
Button mShareLogsButton = view.findViewById(R.id.share_logs_button);
Expand All @@ -43,6 +44,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
mVersionSpinner = view.findViewById(R.id.mc_version_spinner);

mNewsButton.setOnClickListener(v -> Tools.openURL(requireActivity(), Tools.URL_HOME));
mDiscordButton.setOnClickListener(v -> Tools.openURL(requireActivity(), getString(R.string.discord_invite)));
mCustomControlButton.setOnClickListener(v -> startActivity(new Intent(requireContext(), CustomControlsActivity.class)));
mInstallJarButton.setOnClickListener(v -> runInstallerWithConfirmation(false));
mInstallJarButton.setOnLongClickListener(v->{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,18 @@ private void loadValues(@NonNull String profile, @NonNull Context context){
private MinecraftProfile getProfile(@NonNull String profile){
MinecraftProfile minecraftProfile;
if(getArguments() == null) {
minecraftProfile = new MinecraftProfile(LauncherProfiles.mainProfileJson.profiles.get(profile));
// EDGE CASE: User leaves Pojav in background. Pojav gets terminated in the background.
// Current selected fragment and its arguments are saved.
// User returns to Pojav. Android restarts process and reinitializes fragment without
// going to the main screen. mainProfileJson and profiles left uninitialized, which
// results in a crash.
// Reload the profiles to avoid this edge case.
LauncherProfiles.load();
MinecraftProfile originalProfile = LauncherProfiles.mainProfileJson.profiles.get(profile);
// EDGE CASE: User edits the JSON, so the profile that was edited no longer exists.
// Create a brand new profile as a fallback for this case.
if(originalProfile != null) minecraftProfile = new MinecraftProfile(originalProfile);
else minecraftProfile = MinecraftProfile.createTemplate();
mProfileKey = profile;
}else{
minecraftProfile = MinecraftProfile.createTemplate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public SelectAuthFragment(){
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
Button mMicrosoftButton = view.findViewById(R.id.button_microsoft_authentication);
Button mLocalButton = view.findViewById(R.id.button_local_authentication);

mMicrosoftButton.setOnClickListener(v -> Tools.swapFragment(requireActivity(), MicrosoftLoginFragment.class, MicrosoftLoginFragment.TAG, null));
mLocalButton.setOnClickListener(v -> Tools.swapFragment(requireActivity(), LocalLoginFragment.class, LocalLoginFragment.TAG, null));
}
}
}
15 changes: 5 additions & 10 deletions app_pojavlauncher/src/main/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ LOCAL_SRC_FILES := tinywrapper/main.c tinywrapper/string_utils.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/tinywrapper
include $(BUILD_SHARED_LIBRARY)

$(call import-module,prefab/bytehook)
LOCAL_PATH := $(HERE_PATH)

include $(CLEAR_VARS)
# Link GLESv2 for test
LOCAL_LDLIBS := -ldl -llog -landroid
# -lGLESv2
LOCAL_MODULE := pojavexec
LOCAL_SHARED_LIBRARIES := bytehook
# LOCAL_CFLAGS += -DDEBUG
# -DGLES_TEST
LOCAL_SRC_FILES := \
Expand All @@ -39,6 +43,7 @@ LOCAL_SRC_FILES := \
input_bridge_v3.c \
jre_launcher.c \
utils.c \
stdio_is.c \
driver_helper/nsbypass.c

ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
Expand All @@ -55,16 +60,6 @@ LOCAL_LDFLAGS := -z global
include $(BUILD_SHARED_LIBRARY)
#endif

$(call import-module,prefab/bytehook)
LOCAL_PATH := $(HERE_PATH)

include $(CLEAR_VARS)
LOCAL_MODULE := istdio
LOCAL_SHARED_LIBRARIES := bytehook
LOCAL_SRC_FILES := \
stdio_is.c
include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := pojavexec_awt
LOCAL_SRC_FILES := \
Expand Down
2 changes: 1 addition & 1 deletion app_pojavlauncher/src/main/jni/environ/environ.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct solcraft_environ_s {
JavaVM* dalvikJavaVMPtr;
JNIEnv* dalvikJNIEnvPtr_ANDROID;
long showingWindow;
bool isInputReady, isCursorEntered, isUseStackQueueCall, isPumpingEvents;
bool isInputReady, isCursorEntered, isUseStackQueueCall, shouldUpdateMouse;
int savedWidth, savedHeight;
#define ADD_CALLBACK_WWIN(NAME) \
GLFW_invoke_##NAME##_func* GLFW_invoke_##NAME;
Expand Down
Loading

0 comments on commit 6e84857

Please sign in to comment.