/* called by the C++ code to render */ extern "C" void device_render (int* pixels, const int width, const int height, const float time, const Vec3f& vx, const Vec3f& vy, const Vec3f& vz, const Vec3f& p) { /* move instances */ float t = 0.7f*time; g_instance0->local2world.p = mul(2.0f,Vec3f(+cos(t),0.0f,+sin(t))); g_instance1->local2world.p = mul(2.0f,Vec3f(-cos(t),0.0f,-sin(t))); g_instance2->local2world.p = mul(2.0f,Vec3f(-sin(t),0.0f,+cos(t))); g_instance3->local2world.p = mul(2.0f,Vec3f(+sin(t),0.0f,-cos(t))); updateInstance(g_scene,g_instance0); updateInstance(g_scene,g_instance1); updateInstance(g_scene,g_instance2); updateInstance(g_scene,g_instance3); rtcCommit (g_scene); /* render all pixels */ const int numTilesX = (width +TILE_SIZE_X-1)/TILE_SIZE_X; const int numTilesY = (height+TILE_SIZE_Y-1)/TILE_SIZE_Y; launch_renderTile(numTilesX*numTilesY,pixels,width,height,time,vx,vy,vz,p,numTilesX,numTilesY); rtcDebug(); }
void CreateComplexObjectAction::_onEnd(const Point& pt, bool canceled) { if (!canceled && updateInstance(pt)) { assert(mObject); // Permanent it to final scene mObject->setName(getSceneManipulator()->getSceneInfo()->generateAutoName(mObject)); getSceneManipulator()->addObject(mObject); } mObject.reset(); }
void Small::setVariable(int type, int no, QCString value, int position) { switch(type){ case INSTANCE: updateInstance(no,value); break; case PROFILE: updateProfile(no,value); break; case CONTEXT: updateContext(no,value, position); break; } }
void CreateObjectAction::_onEnd(const Point& pt, bool canceled) { if (!canceled && updateInstance(pt)) { assert(mObject); // Permanent it to final scene mObject->setName(getSceneManipulator()->getSceneInfo()->generateAutoName(mObject)); getSceneManipulator()->addObject(mObject); } if (mRangeSphereNode) { mRangeSphereNode->setVisible(false); } mObject.reset(); }
void MainWindow::doLaunch(bool online, BaseProfilerFactory *profiler) { if (!m_selectedInstance) return; // Find an account to use. std::shared_ptr<MojangAccountList> accounts = MMC->accounts(); MojangAccountPtr account = accounts->activeAccount(); if (accounts->count() <= 0) { // Tell the user they need to log in at least one account in order to play. auto reply = CustomMessageBox::selectable( this, tr("No Accounts"), tr("In order to play Minecraft, you must have at least one Mojang or Minecraft " "account logged in to MultiMC." "Would you like to open the account manager to add an account now?"), QMessageBox::Information, QMessageBox::Yes | QMessageBox::No)->exec(); if (reply == QMessageBox::Yes) { // Open the account manager. on_actionManageAccounts_triggered(); } } else if (account.get() == nullptr) { // If no default account is set, ask the user which one to use. AccountSelectDialog selectDialog(tr("Which account would you like to use?"), AccountSelectDialog::GlobalDefaultCheckbox, this); selectDialog.exec(); // Launch the instance with the selected account. account = selectDialog.selectedAccount(); // If the user said to use the account as default, do that. if (selectDialog.useAsGlobalDefault() && account.get() != nullptr) accounts->setActiveAccount(account->username()); } // if no account is selected, we bail if (!account.get()) return; // we try empty password first :) QString password; // we loop until the user succeeds in logging in or gives up bool tryagain = true; // the failure. the default failure. QString failReason = tr("Your account is currently not logged in. Please enter " "your password to log in again."); while (tryagain) { AuthSessionPtr session(new AuthSession()); session->wants_online = online; auto task = account->login(session, password); if (task) { // We'll need to validate the access token to make sure the account // is still logged in. ProgressDialog progDialog(this); if (online) progDialog.setSkipButton(true, tr("Play Offline")); progDialog.exec(task.get()); if (!task->successful()) { failReason = task->failReason(); } } switch (session->status) { case AuthSession::Undetermined: { QLOG_ERROR() << "Received undetermined session status during login. Bye."; tryagain = false; break; } case AuthSession::RequiresPassword: { EditAccountDialog passDialog(failReason, this, EditAccountDialog::PasswordField); if (passDialog.exec() == QDialog::Accepted) { password = passDialog.password(); } else { tryagain = false; } break; } case AuthSession::PlayableOffline: { // we ask the user for a player name bool ok = false; QString usedname = session->player_name; QString name = QInputDialog::getText(this, tr("Player name"), tr("Choose your offline mode player name."), QLineEdit::Normal, session->player_name, &ok); if (!ok) { tryagain = false; break; } if (name.length()) { usedname = name; } session->MakeOffline(usedname); // offline flavored game from here :3 } case AuthSession::PlayableOnline: { // update first if the server actually responded if (session->auth_server_online) { updateInstance(m_selectedInstance, session, profiler); } else { launchInstance(m_selectedInstance, session, profiler); } tryagain = false; } } } }
void CreateComplexObjectAction::_onBegin(const Point& pt) { updateInstance(pt); }
void MainWindow::doLaunch() { if (!m_selectedInstance) return; // Find an account to use. std::shared_ptr<MojangAccountList> accounts = MMC->accounts(); MojangAccountPtr account = accounts->activeAccount(); if (accounts->count() <= 0) { // Tell the user they need to log in at least one account in order to play. auto reply = CustomMessageBox::selectable( this, tr("No Accounts"), tr("In order to play Minecraft, you must have at least one Mojang or Minecraft " "account logged in to MultiMC." "Would you like to open the account manager to add an account now?"), QMessageBox::Information, QMessageBox::Yes | QMessageBox::No)->exec(); if (reply == QMessageBox::Yes) { // Open the account manager. on_actionManageAccounts_triggered(); } } else if (account.get() == nullptr) { // If no default account is set, ask the user which one to use. AccountSelectDialog selectDialog(tr("Which account would you like to use?"), AccountSelectDialog::GlobalDefaultCheckbox, this); selectDialog.exec(); // Launch the instance with the selected account. account = selectDialog.selectedAccount(); // If the user said to use the account as default, do that. if (selectDialog.useAsGlobalDefault() && account.get() != nullptr) accounts->setActiveAccount(account->username()); } // if no account is selected, we bail if (!account.get()) return; QString failReason = tr("Your account is currently not logged in. Please enter " "your password to log in again."); // do the login. if the account has an access token, try to refresh it first. if (account->accountStatus() != NotVerified) { // We'll need to validate the access token to make sure the account is still logged in. ProgressDialog progDialog(this); progDialog.setSkipButton(true, tr("Play Offline")); auto task = account->login(); progDialog.exec(task.get()); auto status = account->accountStatus(); if (status != NotVerified) { updateInstance(m_selectedInstance, account); } else { if (!task->successful()) { failReason = task->failReason(); } if (loginWithPassword(account, failReason)) updateInstance(m_selectedInstance, account); } // in any case, revert from online to verified. account->downgrade(); } else { if (loginWithPassword(account, failReason)) { updateInstance(m_selectedInstance, account); account->downgrade(); } // in any case, revert from online to verified. account->downgrade(); } }
void CreateObjectAction::_onDrag(const Point& pt) { updateInstance(pt); }
Sqf::Value Database::fetchCharacterDetails(int characterID) { try { Poco::Data::Statement stmt((*activeSession)); stmt << "select s.`worldspace`, s.`medical`, s.`zombie_kills`, s.`headshots`, s.`survivor_kills`, s.`state`, s.`class`, p.`ranger`, p.`outlaw`, p.`hunter`, p.`nomad`, p.`survivalist`, p.`engineer`, p.`undead`, p.`total_survivor_kills`, p.`clan` " << "from `survivor` s join `profile` p on s.`unique_id` = p.`unique_id` where s.`id` = ?", use(characterID), now; Sqf::Parameters retVal; Poco::Data::Statement updateInstance((*activeSession)); updateInstance << "update `survivor` set `lastserver` = ?, `activeserver` = ? where `id` = ?", use(serverID), use(serverID), use(characterID); updateInstance.executeAsync(); Poco::Data::RecordSet rs(stmt); if (rs.rowCount() > 0 && rs.columnCount() >= 1) { Sqf::Value worldSpace = Sqf::Parameters(); //empty worldspace Sqf::Value medical = Sqf::Parameters(); //script will fill this in if empty Sqf::Value stats = lexical_cast<Sqf::Value>("[0,0,0]"); //killsZ, headZ, killsH Sqf::Value currentState = Sqf::Parameters(); //empty state (aiming, etc) int myClass = 0; int ranger = 0; int outlaw = 0; int hunter = 0; int nomad = 0; int survivalist = 0; int engineer = 0; int undead = 0; int humanKills = 0; string clan = "0"; //Get Worldspace try { string ws = rs[0].convert<std::string>(); worldSpace = lexical_cast<Sqf::Value>(ws); } catch (boost::bad_lexical_cast) { console->log("Invalid Worldspace for Character: " + characterID); } //Get Medical try { string med = rs[1].convert<std::string>(); medical = lexical_cast<Sqf::Value>(med); } catch (boost::bad_lexical_cast) { console->log("Invalid Medical for Character: " + characterID); } //Get Stats try { Sqf::Parameters& statsArr = boost::get<Sqf::Parameters>(stats); int i; i = rs[2].convert<int>(); statsArr[0] = i; i = rs[3].convert<int>(); statsArr[1] = i; i = rs[4].convert<int>(); statsArr[2] = i; } catch (boost::bad_lexical_cast) { console->log("Invalid Stats for Character: " + characterID); } //Get Current State try { string state = rs[5].convert<std::string>(); currentState = lexical_cast<Sqf::Value>(state); } catch (boost::bad_lexical_cast) { console->log("Invalid State for Character: " + characterID); } myClass = rs[6].convert<int>(); ranger = rs[7].convert<int>(); outlaw = rs[8].convert<int>(); hunter = rs[9].convert<int>(); nomad = rs[10].convert<int>(); survivalist = rs[11].convert<int>(); engineer = rs[12].convert<int>(); undead = rs[13].convert<int>(); humanKills = rs[14].convert<int>(); clan = rs[15].convert<string>(); retVal.push_back(string("PASS")); retVal.push_back(medical); retVal.push_back(stats); retVal.push_back(currentState); retVal.push_back(worldSpace); retVal.push_back(myClass); retVal.push_back(ranger); retVal.push_back(outlaw); retVal.push_back(hunter); retVal.push_back(nomad); retVal.push_back(survivalist); retVal.push_back(engineer); retVal.push_back(undead); retVal.push_back(clan); //Wait for Async Update Player Model / Instance to finish updateInstance.wait(); } else { retVal.push_back(string("ERROR")); } return retVal; } catch (Poco::Exception const& ex) { Sqf::Parameters retVal; retVal.push_back(string("ERROR")); console->log(ex.what()); return retVal; } catch (boost::bad_lexical_cast const& ex) { Sqf::Parameters retVal; retVal.push_back(string("ERROR")); console->log(ex.what()); return retVal; } catch (boost::bad_get const& ex) { Sqf::Parameters retVal; retVal.push_back(string("ERROR")); console->log(ex.what()); return retVal; } catch (std::exception const& ex) { Sqf::Parameters retVal; retVal.push_back(string("ERROR")); console->log(ex.what()); return retVal; } };