mirror of
https://github.com/palera1n/palera1n.git
synced 2026-10-21 09:47:01 +02:00
feat(wx/tui): add --force-enable-ssv to options
This commit is contained in:
2 files changed
+207
-97
No files matched your search
@@ -69,14 +69,16 @@ void TuiSettingsPanel::draw(int sy, int sx, int selected) {
|
||||
!!(palerain_flags & palerain_option_safemode),
|
||||
!!(palerain_flags & palerain_option_verbose_boot),
|
||||
!!(palerain_flags & palerain_option_force_revert),
|
||||
!!(palerain_flags & palerain_option_flower_chain)
|
||||
!!(palerain_flags & palerain_option_flower_chain),
|
||||
!!(palerain_flags & palerain_option_ssv)
|
||||
};
|
||||
|
||||
const char *labels[] = {
|
||||
"Safe Mode",
|
||||
"Verbose Boot",
|
||||
"Restore System",
|
||||
"Dark Blockchain"
|
||||
"Dark Blockchain",
|
||||
"Force Enable SSV Flag"
|
||||
};
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
@@ -98,20 +100,25 @@ void TuiSettingsPanel::draw(int sy, int sx, int selected) {
|
||||
if (selected == i + 1) attroff(A_REVERSE);
|
||||
}
|
||||
|
||||
mvprintw(sy + 13, content_x, "Jailbreak Type:");
|
||||
mvprintw(sy + 13, content_x, "[%c] ", states[4] ? 'x' : ' ');
|
||||
if (selected == 5) attron(A_REVERSE);
|
||||
mvprintw(sy + 14, content_x + 2, "(%c) Rootless", is_rootful ? ' ' : 'x');
|
||||
printw("%s", labels[4]);
|
||||
if (selected == 5) attroff(A_REVERSE);
|
||||
|
||||
mvprintw(sy + 15, content_x, "Jailbreak Type:");
|
||||
if (selected == 6) attron(A_REVERSE);
|
||||
mvprintw(sy + 15, content_x + 2, "(%c) Rootful", is_rootful ? 'x' : ' ');
|
||||
mvprintw(sy + 16, content_x + 2, "(%c) Rootless", is_rootful ? ' ' : 'x');
|
||||
if (selected == 6) attroff(A_REVERSE);
|
||||
|
||||
mvprintw(sy + 17, content_x, "Rootful Options:");
|
||||
if (selected == 7) attron(A_REVERSE);
|
||||
mvprintw(sy + 17, content_x + 2, "(%c) Rootful", is_rootful ? 'x' : ' ');
|
||||
if (selected == 7) attroff(A_REVERSE);
|
||||
|
||||
mvprintw(sy + 19, content_x, "Rootful Options:");
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
const int item_idx = 7 + i;
|
||||
const int row = sy + 18 + i;
|
||||
const int item_idx = 8 + i;
|
||||
const int row = sy + 20 + i;
|
||||
const bool active = is_rootful;
|
||||
const bool is_selected = selected == item_idx;
|
||||
const bool checked = setup_selection == i;
|
||||
@@ -171,34 +178,35 @@ void TuiSettingsPanel::handle_enter(int selected, int sy, int sx) {
|
||||
case 2: edit_boot_args(sy, sx); break;
|
||||
case 3: palerain_flags ^= palerain_option_force_revert; break;
|
||||
case 4: palerain_flags ^= palerain_option_flower_chain; break;
|
||||
case 5:
|
||||
case 5: palerain_flags ^= palerain_option_ssv; break;
|
||||
case 6:
|
||||
palerain_flags &= ~(palerain_option_rootless | palerain_option_rootful);
|
||||
palerain_flags &= ~(palerain_option_setup_rootful | palerain_option_setup_partial_root);
|
||||
palerain_flags |= palerain_option_rootless;
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
palerain_flags &= ~(palerain_option_rootless | palerain_option_rootful);
|
||||
palerain_flags &= ~(palerain_option_setup_rootful | palerain_option_setup_partial_root);
|
||||
palerain_flags |= palerain_option_rootful;
|
||||
break;
|
||||
case 7:
|
||||
if (palerain_flags & palerain_option_rootful) {
|
||||
palerain_flags &= ~(palerain_option_setup_rootful | palerain_option_setup_partial_root);
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
if (palerain_flags & palerain_option_rootful) {
|
||||
palerain_flags &= ~(palerain_option_setup_rootful | palerain_option_setup_partial_root);
|
||||
palerain_flags |= palerain_option_setup_rootful;
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
if (palerain_flags & palerain_option_rootful) {
|
||||
palerain_flags &= ~(palerain_option_setup_rootful | palerain_option_setup_partial_root);
|
||||
palerain_flags |= palerain_option_setup_rootful;
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
if (palerain_flags & palerain_option_rootful) {
|
||||
palerain_flags &= ~(palerain_option_setup_rootful | palerain_option_setup_partial_root);
|
||||
palerain_flags |= palerain_option_setup_partial_root;
|
||||
}
|
||||
break;
|
||||
case 10: GetFrame()->ShowMain(0); break;
|
||||
case 11: GetFrame()->ShowMain(0); break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +215,7 @@ void TuiSettingsPanel::handle_device_update(const DeviceState& state) {
|
||||
}
|
||||
|
||||
bool TuiSettingsPanel::is_button_enabled(int btn_idx) const {
|
||||
if (btn_idx >= 7 && btn_idx <= 9) {
|
||||
if (btn_idx >= 8 && btn_idx <= 10) {
|
||||
return (palerain_flags & palerain_option_rootful) != 0;
|
||||
}
|
||||
|
||||
|
||||
+181
-79
@@ -30,6 +30,7 @@
|
||||
#include "SettingsPanel.hpp"
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/notebook.h>
|
||||
#include <wx/mstream.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/bitmap.h>
|
||||
@@ -41,78 +42,100 @@
|
||||
#include "../paleinfo.h"
|
||||
#include "../gen/embedded/logo.h"
|
||||
|
||||
auto createTitle = [](wxWindow* parent, const wxString& text)
|
||||
{
|
||||
auto* title = new wxStaticText(parent, wxID_ANY, text);
|
||||
|
||||
wxFont font = title->GetFont();
|
||||
font.SetPointSize(font.GetPointSize() - 1);
|
||||
font.SetWeight(wxFONTWEIGHT_BOLD);
|
||||
|
||||
title->SetFont(font);
|
||||
|
||||
|
||||
return title;
|
||||
};
|
||||
|
||||
auto createDescription = [](wxWindow* parent, const wxString& text)
|
||||
{
|
||||
auto* description = new wxStaticText(parent, wxID_ANY, text, wxDefaultPosition, wxDefaultSize, wxST_WRAP);
|
||||
|
||||
wxFont font = description->GetFont();
|
||||
font.SetPointSize(font.GetPointSize() - 2);
|
||||
description->SetFont(font);
|
||||
|
||||
return description;
|
||||
};
|
||||
|
||||
SettingsPanel::SettingsPanel(MainFrame* frame, wxWindow* parent)
|
||||
: DevicePanel(frame, parent)
|
||||
{
|
||||
auto* root = new wxBoxSizer(wxHORIZONTAL);
|
||||
auto* left = new wxBoxSizer(wxVERTICAL);
|
||||
auto* right = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
wxMemoryInputStream stream(embedded_logo_png, embedded_logo_png_len);
|
||||
wxImage img(stream, wxBITMAP_TYPE_PNG);
|
||||
wxBitmap bmp(img);
|
||||
|
||||
auto* logo = new wxStaticBitmap(this, wxID_ANY, bmp);
|
||||
auto* logoText = new wxStaticText(this, wxID_ANY, "Options");
|
||||
auto* right = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
left->Add(new wxStaticText(this, wxID_ANY,
|
||||
"You may set the following options. If you don't know what they mean you'll probably have no reason to set them.",
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
wxST_WRAP
|
||||
), 0, wxALL, 10);
|
||||
), 0, wxTOP | wxLEFT | wxRIGHT, 10);
|
||||
|
||||
auto* optionSafemode = new wxCheckBox(this, wxID_ANY, "Safe Mode");
|
||||
auto* optionVerbose = new wxCheckBox(this, wxID_ANY, "Verbose Boot");
|
||||
auto* optionRevert = new wxCheckBox(this, wxID_ANY, "Restore System");
|
||||
auto* optionDarkBlockchain = new wxCheckBox(this, wxID_ANY, "Dark Blockchain");
|
||||
auto* bootArgs = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize);
|
||||
auto* rootType = new wxRadioBox(
|
||||
this,
|
||||
wxID_ANY,
|
||||
"Jailbreak Type",
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
2,
|
||||
(const wxString[]){
|
||||
"Rootless",
|
||||
"Rootful"
|
||||
},
|
||||
1,
|
||||
wxRA_SPECIFY_COLS
|
||||
);
|
||||
auto* notebook = new wxNotebook(this, wxID_ANY);
|
||||
auto* generalPage = new wxPanel(notebook);
|
||||
auto* advancedPage = new wxPanel(notebook);
|
||||
|
||||
auto* setupMode = new wxRadioBox(
|
||||
this,
|
||||
wxID_ANY,
|
||||
"Rootful Options",
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
3,
|
||||
(const wxString[]){
|
||||
"Boot",
|
||||
"Create FakeFS",
|
||||
"Create BindFS"
|
||||
},
|
||||
1,
|
||||
wxRA_SPECIFY_COLS
|
||||
);
|
||||
//
|
||||
// Controls
|
||||
//
|
||||
auto* optionSafemode = new wxCheckBox(generalPage, wxID_ANY, "Safe Mode");
|
||||
auto* optionVerbose = new wxCheckBox(generalPage, wxID_ANY, "Verbose Boot");
|
||||
auto* optionRevert = new wxCheckBox(generalPage, wxID_ANY, "Restore System");
|
||||
auto* optionDarkBlockchain = new wxCheckBox(generalPage, wxID_ANY, "Dark Blockchain");
|
||||
|
||||
auto* rootless = new wxRadioButton(generalPage, wxID_ANY, "Rootless", wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
|
||||
auto* rootful = new wxRadioButton(generalPage, wxID_ANY, "Rootful");
|
||||
|
||||
auto* setupBoot = new wxRadioButton(generalPage, wxID_ANY, "Boot", wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
|
||||
auto* setupFakeFS = new wxRadioButton(generalPage, wxID_ANY, "Create fakeFS");
|
||||
auto* setupBindFS = new wxRadioButton(generalPage, wxID_ANY, "Create Partial fakeFS");
|
||||
|
||||
auto* bootArgs = new wxTextCtrl(advancedPage, wxID_ANY);
|
||||
auto* optionForceEnableSSV = new wxCheckBox(advancedPage, wxID_ANY, "Force Enable SSV Flag");
|
||||
|
||||
//
|
||||
// Load
|
||||
//
|
||||
optionSafemode->SetValue(palerain_flags & palerain_option_safemode);
|
||||
optionVerbose->SetValue(palerain_flags & palerain_option_verbose_boot);
|
||||
optionRevert->SetValue(palerain_flags & palerain_option_force_revert);
|
||||
optionDarkBlockchain->SetValue(palerain_flags & palerain_option_flower_chain);
|
||||
|
||||
bootArgs->SetValue(wxString(boot_args, wxConvUTF8));
|
||||
if (palerain_flags & palerain_option_rootful)
|
||||
rootType->SetSelection(1);
|
||||
else
|
||||
rootType->SetSelection(0);
|
||||
optionForceEnableSSV->SetValue(palerain_flags & palerain_option_ssv);
|
||||
|
||||
rootless->SetValue(!(palerain_flags & palerain_option_rootful));
|
||||
rootful->SetValue(palerain_flags & palerain_option_rootful);
|
||||
|
||||
if (palerain_flags & palerain_option_setup_rootful)
|
||||
setupMode->SetSelection(1);
|
||||
setupFakeFS->SetValue(true);
|
||||
else if (palerain_flags & palerain_option_setup_partial_root)
|
||||
setupMode->SetSelection(2);
|
||||
setupBindFS->SetValue(true);
|
||||
else
|
||||
setupMode->SetSelection(0);
|
||||
setupMode->Enable(rootType->GetSelection() == 1);
|
||||
setupBoot->SetValue(true);
|
||||
|
||||
bool isRootful = rootful->GetValue();
|
||||
|
||||
setupBoot->Enable(true);
|
||||
setupFakeFS->Enable(isRootful);
|
||||
setupBindFS->Enable(isRootful);
|
||||
|
||||
optionSafemode->Bind(wxEVT_CHECKBOX, [&](wxCommandEvent& e)
|
||||
{
|
||||
@@ -121,6 +144,7 @@ SettingsPanel::SettingsPanel(MainFrame* frame, wxWindow* parent)
|
||||
else
|
||||
palerain_flags &= ~palerain_option_safemode;
|
||||
});
|
||||
|
||||
optionVerbose->Bind(wxEVT_CHECKBOX, [&](wxCommandEvent& e)
|
||||
{
|
||||
if (e.IsChecked())
|
||||
@@ -128,6 +152,7 @@ SettingsPanel::SettingsPanel(MainFrame* frame, wxWindow* parent)
|
||||
else
|
||||
palerain_flags &= ~palerain_option_verbose_boot;
|
||||
});
|
||||
|
||||
optionRevert->Bind(wxEVT_CHECKBOX, [&](wxCommandEvent& e)
|
||||
{
|
||||
if (e.IsChecked())
|
||||
@@ -135,6 +160,7 @@ SettingsPanel::SettingsPanel(MainFrame* frame, wxWindow* parent)
|
||||
else
|
||||
palerain_flags &= ~palerain_option_force_revert;
|
||||
});
|
||||
|
||||
optionDarkBlockchain->Bind(wxEVT_CHECKBOX, [&](wxCommandEvent& e)
|
||||
{
|
||||
if (e.IsChecked())
|
||||
@@ -142,60 +168,136 @@ SettingsPanel::SettingsPanel(MainFrame* frame, wxWindow* parent)
|
||||
else
|
||||
palerain_flags &= ~palerain_option_flower_chain;
|
||||
});
|
||||
|
||||
bootArgs->Bind(wxEVT_TEXT, [&](wxCommandEvent& e)
|
||||
{
|
||||
wxString value = e.GetString();
|
||||
if (value.length() > (sizeof(boot_args) - 0x20)) {
|
||||
|
||||
if (value.length() > (sizeof(boot_args) - 0x20))
|
||||
return;
|
||||
}
|
||||
snprintf(boot_args, sizeof(boot_args), "%s", value.ToStdString().c_str());
|
||||
|
||||
snprintf(boot_args, sizeof(boot_args),
|
||||
"%s",
|
||||
value.ToStdString().c_str());
|
||||
});
|
||||
rootType->Bind(wxEVT_RADIOBOX, [setupMode](wxCommandEvent& e)
|
||||
|
||||
optionForceEnableSSV->Bind(wxEVT_CHECKBOX, [&](wxCommandEvent& e)
|
||||
{
|
||||
palerain_flags &= ~(palerain_option_rootless | palerain_option_rootful);
|
||||
palerain_flags &= ~(palerain_option_setup_rootful | palerain_option_setup_partial_root);
|
||||
|
||||
setupMode->Enable(e.GetSelection() == 1);
|
||||
setupMode->SetSelection(0);
|
||||
|
||||
if (e.GetSelection() == 0)
|
||||
palerain_flags |= palerain_option_rootless;
|
||||
if (e.IsChecked())
|
||||
palerain_flags |= palerain_option_ssv;
|
||||
else
|
||||
palerain_flags |= palerain_option_rootful;
|
||||
palerain_flags &= ~palerain_option_ssv;
|
||||
});
|
||||
|
||||
setupMode->Bind(wxEVT_RADIOBOX, [&](wxCommandEvent& e)
|
||||
rootless->Bind(wxEVT_RADIOBUTTON,
|
||||
[setupBoot, setupFakeFS, setupBindFS](wxCommandEvent&)
|
||||
{
|
||||
palerain_flags &= ~(palerain_option_setup_rootful | palerain_option_setup_partial_root);
|
||||
palerain_flags &= ~(palerain_option_rootless |
|
||||
palerain_option_rootful |
|
||||
palerain_option_setup_rootful |
|
||||
palerain_option_setup_partial_root);
|
||||
|
||||
if (e.GetSelection() == 1)
|
||||
palerain_flags |= palerain_option_setup_rootful;
|
||||
else if (e.GetSelection() == 2)
|
||||
palerain_flags |= palerain_option_setup_partial_root;
|
||||
palerain_flags |= palerain_option_rootless;
|
||||
|
||||
setupBoot->SetValue(true);
|
||||
setupFakeFS->Enable(false);
|
||||
setupBindFS->Enable(false);
|
||||
});
|
||||
|
||||
auto* contentRow = new wxBoxSizer(wxHORIZONTAL);
|
||||
auto* leftColumn = new wxBoxSizer(wxVERTICAL);
|
||||
auto* rightColumn = new wxBoxSizer(wxVERTICAL);
|
||||
rootful->Bind(wxEVT_RADIOBUTTON,
|
||||
[setupFakeFS, setupBindFS](wxCommandEvent&)
|
||||
{
|
||||
palerain_flags &= ~(palerain_option_rootless |
|
||||
palerain_option_rootful);
|
||||
|
||||
leftColumn->Add(rootType, 0, wxALL | wxEXPAND, 5);
|
||||
leftColumn->Add(setupMode, 0, wxALL | wxEXPAND, 5);
|
||||
palerain_flags |= palerain_option_rootful;
|
||||
|
||||
rightColumn->Add(optionSafemode, 0, wxALL, 5);
|
||||
rightColumn->Add(optionVerbose, 0, wxALL, 5);
|
||||
rightColumn->Add(optionRevert, 0, wxALL, 5);
|
||||
rightColumn->Add(optionDarkBlockchain, 0, wxALL, 5);
|
||||
rightColumn->AddStretchSpacer();
|
||||
setupFakeFS->Enable(true);
|
||||
setupBindFS->Enable(true);
|
||||
});
|
||||
|
||||
contentRow->Add(leftColumn, 1, wxEXPAND | wxRIGHT, 10);
|
||||
contentRow->Add(rightColumn, 1, wxEXPAND | wxLEFT, 10);
|
||||
setupBoot->Bind(wxEVT_RADIOBUTTON, [](wxCommandEvent&)
|
||||
{
|
||||
palerain_flags &= ~(palerain_option_setup_rootful |
|
||||
palerain_option_setup_partial_root);
|
||||
});
|
||||
|
||||
left->Add(contentRow, 1, wxEXPAND | wxLEFT | wxRIGHT, 10);
|
||||
left->Add(new wxStaticText(this, wxID_ANY, "Boot Arguments:"), 0, wxALL, 15);
|
||||
left->Add(bootArgs, 0, wxLEFT | wxRIGHT | wxEXPAND, 30);
|
||||
left->AddStretchSpacer();
|
||||
setupFakeFS->Bind(wxEVT_RADIOBUTTON, [&](wxCommandEvent&)
|
||||
{
|
||||
palerain_flags &= ~palerain_option_setup_partial_root;
|
||||
palerain_flags |= palerain_option_setup_rootful;
|
||||
});
|
||||
|
||||
setupBindFS->Bind(wxEVT_RADIOBUTTON, [&](wxCommandEvent&)
|
||||
{
|
||||
palerain_flags &= ~palerain_option_setup_rootful;
|
||||
palerain_flags |= palerain_option_setup_partial_root;
|
||||
});
|
||||
|
||||
//
|
||||
// General
|
||||
//
|
||||
auto* generalSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
auto* generalLeft = new wxBoxSizer(wxVERTICAL);
|
||||
auto* generalRight = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
generalLeft->Add(createTitle(generalPage, "Startup"), 0, wxBOTTOM, 3);
|
||||
|
||||
generalLeft->Add(optionSafemode, 0, wxTOP, 7);
|
||||
generalLeft->Add(optionVerbose, 0, wxTOP , 7);
|
||||
generalLeft->Add(optionRevert, 0, wxTOP, 7);
|
||||
generalLeft->Add(optionDarkBlockchain, 0, wxTOP, 7);
|
||||
|
||||
generalLeft->AddStretchSpacer();
|
||||
|
||||
generalRight->Add(createTitle(generalPage, "Jailbreak Type"), 0, wxBOTTOM, 3);
|
||||
|
||||
generalRight->Add(rootless, 0, wxTOP, 7);
|
||||
generalRight->Add(rootful, 0, wxTOP | wxBOTTOM, 5);
|
||||
|
||||
generalRight->Add(createTitle(generalPage, "Startup (Rootful)"), 0, wxTOP | wxBOTTOM, 3);
|
||||
|
||||
generalRight->Add(setupBoot, 0, wxTOP, 7);
|
||||
generalRight->Add(setupFakeFS, 0, wxTOP, 5);
|
||||
generalRight->Add(setupBindFS, 0, wxTOP, 5);
|
||||
|
||||
generalRight->AddStretchSpacer();
|
||||
|
||||
generalSizer->Add(generalLeft, 1, wxEXPAND | wxRIGHT | wxLEFT, 10);
|
||||
generalSizer->Add(generalRight, 1, wxEXPAND | wxLEFT, 10);
|
||||
|
||||
generalPage->SetSizer(generalSizer);
|
||||
|
||||
//
|
||||
// Advanced
|
||||
//
|
||||
auto* advancedOuterSizer = new wxBoxSizer(wxVERTICAL);
|
||||
auto* advancedSizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
advancedSizer->Add(createTitle(advancedPage, "Boot Arguments"), 0, wxBOTTOM, 3);
|
||||
|
||||
advancedSizer->Add(bootArgs, 0, wxTOP | wxBOTTOM | wxEXPAND, 7);
|
||||
|
||||
advancedSizer->Add(createTitle(advancedPage, "Advanced"), 0, wxTOP | wxBOTTOM, 3);
|
||||
|
||||
advancedSizer->Add(optionForceEnableSSV, 0, wxTOP | wxBOTTOM, 7);
|
||||
advancedSizer->Add(createDescription(advancedPage, "Forces the jailbreak to detect SSV as being required."), 0, wxLEFT | wxRIGHT, 20);
|
||||
|
||||
advancedOuterSizer->Add(advancedSizer, 1, wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, 10);
|
||||
|
||||
advancedPage->SetSizer(advancedOuterSizer);
|
||||
|
||||
notebook->AddPage(generalPage, "General", true);
|
||||
notebook->AddPage(advancedPage, "Advanced");
|
||||
|
||||
left->Add(notebook, 1, wxEXPAND | wxALL, 10);
|
||||
|
||||
//
|
||||
// Right side
|
||||
//
|
||||
auto* back = new wxButton(this, wxID_ANY, "Back");
|
||||
|
||||
right->Add(logo, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP | wxLEFT | wxRIGHT, 10);
|
||||
right->Add(logoText, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, 5);
|
||||
right->AddStretchSpacer();
|
||||
|
||||
Reference in new issue
Block a user