void AdvancedWidget::createControls() {
	style::margins marginSmall(0, 0, 0, st::settingsSmallSkip);
	style::margins marginLarge(0, 0, 0, st::settingsLargeSkip);

	style::margins marginLocalStorage = [&] {
#ifndef TDESKTOP_DISABLE_NETWORK_PROXY
		return marginSmall;
#else // !TDESKTOP_DISABLE_NETWORK_PROXY
		return marginLarge;
#endif // TDESKTOP_DISABLE_NETWORK_PROXY
	}();
	if (self()) {
		createChildRow(_manageLocalStorage, marginLocalStorage, lang(lng_settings_manage_local_storage), SLOT(onManageLocalStorage()));
	}

#ifndef TDESKTOP_DISABLE_NETWORK_PROXY
	createChildRow(_connectionType, marginLarge, lang(lng_connection_type), lang(lng_connection_auto_connecting), LabeledLink::Type::Primary, SLOT(onConnectionType()));
	connectionTypeUpdated();
#endif // !TDESKTOP_DISABLE_NETWORK_PROXY

	if (self()) {
		createChildRow(_askQuestion, marginSmall, lang(lng_settings_ask_question), SLOT(onAskQuestion()));
	} else {
		style::margins slidedPadding(0, marginLarge.bottom() / 2, 0, marginLarge.bottom() - (marginLarge.bottom() / 2));
		createChildRow(_useDefaultTheme, marginLarge, slidedPadding, lang(lng_settings_bg_use_default), SLOT(onUseDefaultTheme()));
		if (!Window::Theme::SuggestThemeReset()) {
			_useDefaultTheme->hide(anim::type::instant);
		}
		createChildRow(_toggleNightTheme, marginLarge, getNightThemeToggleText(), SLOT(onToggleNightTheme()));
	}
	createChildRow(_telegramFAQ, marginLarge, lang(lng_settings_faq), SLOT(onTelegramFAQ()));
	if (self()) {
		style::margins marginLogout(0, 0, 0, 2 * st::settingsLargeSkip);
		createChildRow(_logOut, marginLogout, lang(lng_settings_logout), SLOT(onLogOut()));
	}
}
Exemplo n.º 2
0
void Game::processNetworkEvents()
{
    sf::Lock guard(_clientsMutex);
    for(auto it = _clients.begin(); it != _clients.end();++it)
    {
        book::Client* client = *it;
        book::packet::NetworkEvent* msg;
        while(client and client->pollEvent(msg))
        {
            switch(msg->type())
            {
                case book::FuncIds::IdDisconnected :
                {
                    it = _clients.erase(it);
                    --it;
                    delete client;
                    client = nullptr;
                }break;
                case book::FuncIds::IdLogOut :
                {
                    it = _clients.erase(it);
                    --it;
                    client->getTeam()->remove(client);

                    onLogOut(client);
                    client = nullptr;
                }break;
                case book::FuncIds::IdRequestCreateEntity :
                {
                    book::packet::RequestCreateEntity* event = static_cast<book::packet::RequestCreateEntity*>(msg);

                    sf::Lock gameGuard(_teamMutex);
                    short int entityType = event->getType();
                    int gold = client->getTeam()->getGold();
                    sf::Vector2i coord = event->getCoord();


                    for(book::EntityType::Info& info : book::EntityType::informations)
                    {
                        if(info.makeAs == entityType
                           and gold >= info.cost
                           and _byCoords[coord].size() == 0)
                        {
                            book::MakeAs makeAs = book::getMakeAs(info.makeAs);
                            if(makeAs != nullptr)
                            {
                                createEntity(coord,client->getTeam(),makeAs);
                                client->getTeam()->addGold(-info.cost);
                            }
                        }
                    }
                }break;
                case book::FuncIds::IdRequestDestroyEntity :
                {
                    book::packet::RequestDestroyEntity* event = static_cast<book::packet::RequestDestroyEntity*>(msg);
                    unsigned int id = event->getId();

                    if(entities.isValid(id))
                    {
                        sf::Lock gameGuard(_teamMutex);
                        CompTeam::Handle team = entities.getComponent<CompTeam>(id);
                        if(team.isValid())
                        {
                            if(team->_team->id() == client->getTeam()->id())
                            {
                                destroyEntity(id);
                            }
                        }
                    }
                }break;
                default : break;
            }
        }
    }
}