Skip to content

Commit c728387

Browse files
committed
re-add random username buttons and changed Target and Source options to 8 in CMakeLists
1 parent 6a05fec commit c728387

5 files changed

Lines changed: 50 additions & 2 deletions

File tree

launcher/ui/dialogs/ChooseOfflineNameDialog.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <QPushButton>
2222
#include <QRegularExpression>
23+
#include <QRandomGenerator>
2324

2425
#include "ui_ChooseOfflineNameDialog.h"
2526

@@ -73,3 +74,32 @@ void ChooseOfflineNameDialog::on_allowInvalidUsernames_checkStateChanged(const Q
7374
ui->usernameTextBox->setValidator(checkState == Qt::Checked ? nullptr : m_usernameValidator);
7475
updateAcceptAllowed(getUsername());
7576
}
77+
78+
void ChooseOfflineNameDialog::on_randomCharUser_clicked()
79+
{
80+
const QString possibleCharacters("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
81+
const int randomStringLength = 14;
82+
QString randomString;
83+
for(int i=0; i<randomStringLength; ++i)
84+
{
85+
int index = QRandomGenerator::global()->generate() % possibleCharacters.length();
86+
QChar nextChar = possibleCharacters.at(index);
87+
randomString.append(nextChar);
88+
}
89+
ui->usernameTextBox->setText(randomString);
90+
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
91+
}
92+
93+
void ChooseOfflineNameDialog::on_randomFullUser_clicked()
94+
{
95+
//todo: maybe make this words configurable and not hardcoded, smh.
96+
QList<QString> PossibleUsernameHalves = {"Cookie", "Clicker", "Licker", "Lenny", "Super", "Sakupen", "Sonic", "Geometry", "Mining", "Chicken", "Sculpted", "Random", "Painted", "Fainted", "MadeIn", "Chinese", "Bing", "Hell", "Circles", "Wave", "Dash", "Crafting", "Smelting", "Jockey", "Vase", "Heaven", "Pudding", "Chilling"};
97+
int UsernameArrayLength = PossibleUsernameHalves.count();
98+
//int indexPossibleHalf = QRandomGenerator::global()->bounded(22);
99+
int indexFirstPossibleHalf = QRandomGenerator::global()->bounded(UsernameArrayLength);
100+
int indexSecondPossibleHalf = QRandomGenerator::global()->bounded(UsernameArrayLength);
101+
QString GeneratedUsername = PossibleUsernameHalves[indexFirstPossibleHalf] + PossibleUsernameHalves[indexSecondPossibleHalf];
102+
ui->usernameTextBox->setText(GeneratedUsername);
103+
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
104+
}
105+

launcher/ui/dialogs/ChooseOfflineNameDialog.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ class ChooseOfflineNameDialog final : public QDialog {
4444
void on_usernameTextBox_textEdited(const QString& newText) const;
4545
void on_allowInvalidUsernames_checkStateChanged(Qt::CheckState checkState) const;
4646

47+
private slots:
48+
void on_randomCharUser_clicked();
49+
void on_randomFullUser_clicked();
50+
4751
private:
4852
Ui::ChooseOfflineNameDialog* ui;
4953
QRegularExpressionValidator* m_usernameValidator;

launcher/ui/dialogs/ChooseOfflineNameDialog.ui

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@
4747
</property>
4848
</widget>
4949
</item>
50+
<item>
51+
<widget class="QPushButton" name="randomCharUser">
52+
<property name="text">
53+
<string>Random Characters</string>
54+
</property>
55+
</widget>
56+
</item>
57+
<item>
58+
<widget class="QPushButton" name="randomFullUser">
59+
<property name="text">
60+
<string>Random Username</string>
61+
</property>
62+
</widget>
63+
</item>
5064
<item>
5165
<widget class="QDialogButtonBox" name="buttonBox">
5266
<property name="standardButtons">

libraries/javacheck/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ find_package(Java 1.7 REQUIRED COMPONENTS Development)
44

55
include(UseJava)
66
set(CMAKE_JAVA_JAR_ENTRY_POINT JavaCheck)
7-
set(CMAKE_JAVA_COMPILE_FLAGS -target 7 -source 7 -Xlint:deprecation -Xlint:unchecked)
7+
set(CMAKE_JAVA_COMPILE_FLAGS -target 8 -source 8 -Xlint:deprecation -Xlint:unchecked)
88

99
set(SRC
1010
JavaCheck.java

libraries/launcher/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ find_package(Java 1.7 REQUIRED COMPONENTS Development)
44

55
include(UseJava)
66
set(CMAKE_JAVA_JAR_ENTRY_POINT org.prismlauncher.EntryPoint)
7-
set(CMAKE_JAVA_COMPILE_FLAGS -target 7 -source 7)
7+
set(CMAKE_JAVA_COMPILE_FLAGS -target 8 -source 8)
88

99
set(SRC
1010
org/prismlauncher/EntryPoint.java

0 commit comments

Comments
 (0)