From 40d77bc26506fef47a55fb1f5a01616cd96e6de2 Mon Sep 17 00:00:00 2001 From: Vladislav Laetansky Date: Mon, 28 Mar 2022 15:40:34 +0300 Subject: [PATCH] NOISSUE save custom offline player name --- launcher/Application.cpp | 3 +++ launcher/LaunchController.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 958c5e3d..0575f00a 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -680,6 +680,9 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) // Minecraft launch method m_settings->registerSetting("MCLaunchMethod", "LauncherPart"); + // Minecraft offline player name + m_settings->registerSetting("LastOfflinePlayerName", ""); + // Wrapper command for launch m_settings->registerSetting("WrapperCommand", ""); diff --git a/launcher/LaunchController.cpp b/launcher/LaunchController.cpp index 7750be1a..17e79545 100644 --- a/launcher/LaunchController.cpp +++ b/launcher/LaunchController.cpp @@ -125,13 +125,14 @@ void LaunchController::login() { if(!m_session->wants_online) { // we ask the user for a player name bool ok = false; - QString usedname = m_session->player_name; + QString lastOfflinePlayerName = APPLICATION->settings()->get("LastOfflinePlayerName").toString(); + QString usedname = lastOfflinePlayerName.isEmpty() ? m_session->player_name : lastOfflinePlayerName; QString name = QInputDialog::getText( m_parentWidget, tr("Player name"), tr("Choose your offline mode player name."), QLineEdit::Normal, - m_session->player_name, + usedname, &ok ); if (!ok) @@ -142,6 +143,7 @@ void LaunchController::login() { if (name.length()) { usedname = name; + APPLICATION->settings()->set("LastOfflinePlayerName", usedname); } m_session->MakeOffline(usedname); // offline flavored game from here :3