MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / login

Method login

launcher/LaunchController.cpp:149–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147
148
149void LaunchController::login() {
150 decideAccount();
151
152 // if no account is selected, we bail
153 if (!m_accountToUse)
154 {
155 emitFailed(tr("No account selected for launch."));
156 return;
157 }
158
159 // we loop until the user succeeds in logging in or gives up
160 bool tryagain = true;
161 unsigned int tries = 0;
162
163 while (tryagain)
164 {
165 if (tries > 0 && tries % 3 == 0) {
166 auto result = QMessageBox::question(
167 m_parentWidget,
168 tr("Continue launch?"),
169 tr("It looks like we couldn't launch after %1 tries. Do you want to continue trying?")
170 .arg(tries)
171 );
172
173 if (result == QMessageBox::No) {
174 emitAborted();
175 return;
176 }
177 }
178 tries++;
179 m_session = std::make_shared<AuthSession>();
180 m_session->wants_online = m_online;
181 m_session->demo = m_demo;
182 m_accountToUse->fillSession(m_session);
183
184 // Launch immediately in true offline mode
185 if(m_accountToUse->isOffline()) {
186 launchInstance();
187 return;
188 }
189
190 switch(m_accountToUse->accountState()) {
191 case AccountState::Offline: {
192 m_session->wants_online = false;
193 [[fallthrough]];
194 }
195 case AccountState::Online: {
196 if(!m_session->wants_online) {
197 // we ask the user for a player name
198 bool ok = false;
199
200 QString message = tr("Choose your offline mode player name.");
201 if(m_session->demo) {
202 message = tr("Choose your demo mode player name.");
203 }
204
205 QString lastOfflinePlayerName = APPLICATION->settings()->get("LastOfflinePlayerName").toString();
206 QString usedname = lastOfflinePlayerName.isEmpty() ? m_session->player_name : lastOfflinePlayerName;

Callers

nothing calls this directly

Calls 15

fillSessionMethod · 0.80
isOfflineMethod · 0.80
accountStateMethod · 0.80
isEmptyMethod · 0.80
lengthMethod · 0.80
MakeOfflineMethod · 0.80
ownsMinecraftMethod · 0.80
hasProfileMethod · 0.80
MakeDemoMethod · 0.80
setSkipButtonMethod · 0.80
currentTaskMethod · 0.80
execWithTaskMethod · 0.80

Tested by

no test coverage detected