BOOL LLFloaterPreference::postBuild()
{
	requires<LLButton>("About...");
	requires<LLButton>("OK");
	requires<LLButton>("Cancel");
	requires<LLButton>("Apply");
	requires<LLTabContainer>("pref core");

	if (!checkRequirements())
	{
		return FALSE;
	}

	mAboutBtn = getChild<LLButton>("About...");
	mAboutBtn->setClickedCallback(onClickAbout, this);
	
	mApplyBtn = getChild<LLButton>("Apply");
	mApplyBtn->setClickedCallback(onBtnApply, this);
		
	mCancelBtn = getChild<LLButton>("Cancel");
	mCancelBtn->setClickedCallback(onBtnCancel, this);

	mOKBtn = getChild<LLButton>("OK");
	mOKBtn->setClickedCallback(onBtnOK, this);
			
	mPreferenceCore = new LLPreferenceCore(
		getChild<LLTabContainer>("pref core"),
		getChild<LLButton>("OK")
		);
	
	sInstance = this;

	return TRUE;
}
BOOL LLFloaterNewIM::postBuild()
{
	requires<LLButton>("start_btn");
	requires<LLButton>("close_btn");
	requires<LLNameListCtrl>("user_list");

	if (checkRequirements())
	{
		childSetAction("start_btn", &LLFloaterNewIM::onStart, this);
		childSetAction("close_btn", &LLFloaterNewIM::onClickClose, this);
		mSelectionList = getChild<LLNameListCtrl>("user_list");
		if (mSelectionList)
		{
			mSelectionList->setDoubleClickCallback(&LLFloaterNewIM::onStart);
			mSelectionList->setCallbackUserData(this);
		}
		else
		{
			llwarns << "LLUICtrlFactory::getNameListByName() returned NULL for 'user_list'" << llendl;
		}
		sOnlineDescriptor = getString("online_descriptor");
		setDefaultBtn("start_btn");
		return TRUE;
	}	

	return FALSE;
}
//Return the file counter. -1 on error
int ShellUnpacker::openCompressedFile()
{
	if(!checkRequirements())
		return -2; //Return check requirements error;

	return urarlib_list((void*) _fileName.c_str(), (ArchiveList_struct*) &_unRARList);
}
 void TriggerAltimeter::blockUntilActive(ExecutionState* state)
 {
     DataModelLogger* RUNLOG = state->getLogger();
     SensorHandler* sensor = SensorHandler::setupSensor(SENSOR_TYPE_ALTIMETER, state,
             isValueTrue(getParameter("HIGH_PRECISION", state)));
     if (!sensor)
         throw ExecutionAbortedException();
     sensor_event_t* event;
     std::vector<std::string>* values;
     for (;;) {
         // Check if we are still running
         if (!state->isRunning())
             throw ExecutionAbortedException();
         // Retrieve event with values
         event = sensor->retrieveEvent();
         // Check if event was successfully retrieved
         if (NULL == event)
             continue;
         // Check returned values
         values = new std::vector<std::string>();
         RUNLOG->debug(SSTR("Retrieved: ALT=" << event->altitude_s.altitude));
         values->push_back(/*ALTITUDE*/SSTR(event->altitude_s.altitude));
         delete event;
         if (checkRequirements(state, values))
             break;
     }
     delete sensor;
 }
Exemple #5
0
void GatherInfoTask::onComplete()
{
	if (getItemHandle()->getItemInfo()->isDownloadable())
		checkRequirements();
	else
		getItemHandle()->getInternal()->completeStage(true);
}
Exemple #6
0
BOOL LLFloaterNewIM::postBuild()
{
	requires("start_btn", WIDGET_TYPE_BUTTON);
	requires("close_btn", WIDGET_TYPE_BUTTON);
	requires("user_list", WIDGET_TYPE_NAME_LIST);
	requires("online_descriptor", WIDGET_TYPE_TEXT_BOX);
	requires("name_format", WIDGET_TYPE_TEXT_BOX);

	if (checkRequirements())
	{
		childSetAction("start_btn", &LLFloaterNewIM::onStart, this);
		childSetAction("close_btn", &LLFloaterNewIM::onClickClose, this);
		mSelectionList = LLViewerUICtrlFactory::getNameListByName(this, "user_list");
		if (mSelectionList)
		{
			mSelectionList->setDoubleClickCallback(&LLFloaterNewIM::onStart);
			mSelectionList->setCallbackUserData(this);
		}
		else
		{
			llwarns << "LLViewerUICtrlFactory::getNameListByName() returned NULL for 'user_list'" << llendl;
		}
		sOnlineDescriptor = childGetValue("online_descriptor").asString();
		sNameFormat = childGetValue("name_format").asString();
		setDefaultBtn("start_btn");
		return TRUE;
	}	

	return FALSE;
}
Exemple #7
0
bool GatherInfoTask::checkNullBranch(UserCore::Item::BranchInfoI* branchInfo)
{
	if (branchInfo)
		return true;

	if (!getUserCore()->getItemManager()->isKnownBranch(getMcfBranch(), getItemId()))
		throw gcException(ERR_BADITEM, "Branch is invalid or user doesnt have permissions to install branch.");

	if (!m_bFirstTime || HasAnyFlags(m_uiFlags, GI_FLAG_TEST))
		throw gcException(ERR_UNSUPPORTEDPLATFORM, 1, "This branch is not supported on this platform");

	m_bFirstTime = false;
	bool res = false;

	if (!m_bCanceled && m_pGIHH)
		res = m_pGIHH->showPlatformError();

	if (!res)
	{
		completeStage();
	}
	else
	{
		m_uiMcfBranch = MCFBranch::BranchFromInt(0);
		checkRequirements();
	}

	return false;
}
Exemple #8
0
BOOL LLPrefsIMImpl::postBuild()
{
	requires("online_visibility");
	requires("send_im_to_email");
	if (!checkRequirements())
	{
		return FALSE;
	}

	childSetLabelArg("send_im_to_email", "[EMAIL]", getString("log_in_to_change"));

	// Don't enable this until we get personal data
	childDisable("include_im_in_chat_console");
	childDisable("include_im_in_chat_history");
	childDisable("show_timestamps_check");
	childDisable("friends_online_notify_checkbox");
	
	childDisable("online_visibility");
	childDisable("send_im_to_email");
	childDisable("log_instant_messages");
	childDisable("log_chat");
	childDisable("log_show_history");
	childDisable("log_path_button");
	childDisable("busy_response");
	childDisable("log_instant_messages_timestamp");
	childDisable("log_chat_timestamp");
	childDisable("log_chat_IM");
	childDisable("log_date_timestamp");
	childDisable("logfile_name_datestamp");

	childSetText("busy_response", getString("log_in_to_change"));

	childSetValue("include_im_in_chat_console", gSavedSettings.getBOOL("IMInChatConsole"));
	childSetValue("include_im_in_chat_history", gSavedSettings.getBOOL("IMInChatHistory"));
	childSetValue("show_timestamps_check", gSavedSettings.getBOOL("IMShowTimestamps"));
	childSetValue("friends_online_notify_checkbox", gSavedSettings.getBOOL("ChatOnlineNotification"));

	childSetText("chat_logs_location", gSavedPerAccountSettings.getString("InstantMessageLogPath"));
	childSetValue("log_instant_messages", gSavedPerAccountSettings.getBOOL("LogInstantMessages")); 
	childSetValue("log_chat", gSavedPerAccountSettings.getBOOL("LogChat")); 
	childSetValue("log_show_history", gSavedPerAccountSettings.getBOOL("LogShowHistory"));
	childSetValue("log_instant_messages_timestamp", gSavedPerAccountSettings.getBOOL("IMLogTimestamp"));
	childSetValue("log_chat_timestamp", gSavedPerAccountSettings.getBOOL("LogChatTimestamp"));
	childSetValue("log_chat_IM", gSavedPerAccountSettings.getBOOL("LogChatIM"));
	childSetValue("log_date_timestamp", gSavedPerAccountSettings.getBOOL("LogTimestampDate"));
	childSetValue("logfile_name_datestamp", gSavedPerAccountSettings.getBOOL("LogFileNamewithDate"));

	childSetCommitCallback("log_chat",onCommitLogging,this);
	childSetCommitCallback("log_instant_messages",onCommitLogging,this);
	
	return TRUE;
}
Exemple #9
0
/**
 * Check if we can unlock power.
 */
bool MenuPowers::checkUnlock(int pci) {
	// If we didn't find power in power_menu, than it has no requirements
	if (pci == -1) return true;

	if (!checkCellVisible(pci)) return false;

	// If we already have a power, don't try to unlock it
	if (checkUnlocked(pci)) return false;

	// Check base requirements
	if (checkRequirements(pci)) return true;
	return false;
}
 bool TriggerAltimeter::isActive(ExecutionState* state)
 {
     DataModelLogger* RUNLOG = state->getLogger();
     std::vector<std::string>* values = new std::vector<std::string>();
     errno = EOK;
     SensorHandler* sensor = SensorHandler::setupSensor(SENSOR_TYPE_ALTIMETER, state);
     if (!sensor)
         return false;
     sensor_event_t* event = sensor->retrieveEvent();
     delete sensor;
     if (NULL == event)
         return false;
     RUNLOG->debug(SSTR("Retrieved: ALT=" << event->altitude_s.altitude));
     values->push_back(/*ALTITUDE*/SSTR(event->altitude_s.altitude));
     delete event;
     return checkRequirements(state, values);
 }
Exemple #11
0
BOOL LLPrefsIMImpl::postBuild()
{
	requires("online_visibility");
	requires("send_im_to_email");
	if (!checkRequirements())
	{
		return FALSE;
	}

	mGotPersonalInfo = false;
	mOriginalIMViaEmail = false;
	mOriginalHideOnlineStatus = true;
	childSetLabelArg("send_im_to_email", "[EMAIL]", childGetText("log_in_to_change"));

	// Don't enable this until we get personal data
	childDisable("online_visibility");
	childDisable("send_im_to_email");
	childDisable("log_instant_messages");
	childDisable("log_chat");
	childDisable("log_show_history");
	childDisable("log_path_button");
	childDisable("busy_response");
	childDisable("log_instant_messages_timestamp");
	childDisable("log_chat_timestamp");
	childDisable("log_chat_IM");
	childDisable("log_date_timestamp");

	childSetText("busy_response", childGetText("log_in_to_change"));
	
	refresh(); 

	childSetText("log_path_string", mLogPath);
	childSetValue("log_instant_messages", mLogInstantMessages); 
	childSetValue("log_chat", mLogChat); 
	childSetValue("log_show_history", mLogShowHistory);
	childSetValue("log_instant_messages_timestamp", mIMLogTimestamp);
	childSetValue("log_chat_timestamp", mLogChatTimestamp);
	childSetValue("log_chat_IM", mLogIMChat);
	childSetValue("log_date_timestamp",mLogTimestampDate);
	childSetAction("log_path_button", onClickLogPath, this);
	childSetCommitCallback("log_chat",onCommitLogging,this);
	childSetCommitCallback("log_instant_messages",onCommitLogging,this);
	
	return TRUE;
}
bool MenuPowers::checkUnlocked(int pci) {
	// If we didn't find power in power_menu, than it has no requirements
	if (pci == -1) return true;

	if (!checkCellVisible(pci)) return false;

	// If power_id is saved into vector, it's unlocked anyway
	// check power_cell_unlocked and stats->powers_list
	for (size_t i=0; i<power_cell_unlocked.size(); ++i) {
		if (power_cell_unlocked[i].id == power_cell_all[pci].id)
			return true;
	}
	if (std::find(stats->powers_list.begin(), stats->powers_list.end(), power_cell_all[pci].id) != stats->powers_list.end()) return true;

	// Check the rest requirements
	if (checkRequirements(pci) && !power_cell_all[pci].requires_point) return true;
	return false;
}
Exemple #13
0
BOOL LLPanelInput::postBuild()
{
	requires("Mouse Sensitivity", WIDGET_TYPE_SLIDER_BAR);
	requires("invert mouse", WIDGET_TYPE_CHECKBOX);
	requires("automatic fly", WIDGET_TYPE_CHECKBOX);
	requires("dynamic camera", WIDGET_TYPE_SLIDER);
	requires("edit camera movement", WIDGET_TYPE_CHECKBOX);
	requires("appearance camera movement", WIDGET_TYPE_CHECKBOX);
	
	if (!checkRequirements())
	{
		return FALSE;
	}	

	refresh();

	return TRUE;
}
Exemple #14
0
BOOL LLPanelLCD::postBuild()
{
	requires<LLRadioGroup>("LCDDestination");
	requires<LLCheckBoxCtrl>("DisplayLinden");
	requires<LLCheckBoxCtrl>("DisplayDebug");
	requires<LLCheckBoxCtrl>("DisplayDebugConsole");
	requires<LLCheckBoxCtrl>("DisplayRegion");
	requires<LLCheckBoxCtrl>("DisplayChat");
	requires<LLCheckBoxCtrl>("DisplayIM");

	if (!checkRequirements())
	{
		return FALSE;
	}	

	refresh();

	return TRUE;
}
BOOL HippoPanelGridsImpl::postBuild()
{
	requires<LLComboBox>("grid_selector");
	requires<LLComboBox>("platform");
	requires<LLLineEditor>("gridname");
	requires<LLLineEditor>("loginuri");
	requires<LLLineEditor>("loginpage");
	requires<LLLineEditor>("helperuri");
	requires<LLLineEditor>("website");
	requires<LLLineEditor>("support");
	requires<LLLineEditor>("register");
	requires<LLLineEditor>("password");
	requires<LLLineEditor>("search");
	requires<LLButton>("btn_delete");
	requires<LLButton>("btn_add");
	requires<LLButton>("btn_copy");
	requires<LLButton>("btn_default");
	requires<LLButton>("btn_gridinfo");
	requires<LLButton>("btn_help_render_compat");
	if (!checkRequirements()) return false;
	
	LLComboBox *platform = getChild<LLComboBox>("platform");
	platform->removeall();
	for (int p=HippoGridInfo::PLATFORM_OTHER; p<HippoGridInfo::PLATFORM_LAST; p++)
		platform->add(HippoGridInfo::getPlatformString(static_cast<HippoGridInfo::Platform>(p)));
	
	childSetAction("btn_delete", onClickDelete, this);
	childSetAction("btn_add", onClickAdd, this);
	childSetAction("btn_copy", onClickCopy, this);
	childSetAction("btn_default", onClickDefault, this);
	childSetAction("btn_gridinfo", onClickGridInfo, this);
	childSetAction("btn_help_render_compat", onClickHelpRenderCompat, this);
	childSetAction("btn_advanced", onClickAdvanced, this);
	
	childSetCommitCallback("grid_selector", onSelectGrid, this);
	childSetCommitCallback("platform", onSelectPlatform, this);
	
	// !!!### 	server_choice_combo->setFocusLostCallback(onServerComboLostFocus);
	
	reset();
	return true;
}
BOOL LLFloaterPreference::postBuild()
{
	requires<LLButton>("About...");
	requires<LLButton>("OK");
	requires<LLButton>("Cancel");
	requires<LLButton>("Apply");
	requires<LLTabContainer>("pref core");

	if (!checkRequirements())
	{
		return FALSE;
	}

	mAboutBtn = getChild<LLButton>("About...");
	mAboutBtn->setClickedCallback(onClickAbout, this);
	
	mApplyBtn = getChild<LLButton>("Apply");
	mApplyBtn->setClickedCallback(onBtnApply, this);
		
	mCancelBtn = getChild<LLButton>("Cancel");
	mCancelBtn->setClickedCallback(onBtnCancel, this);

	mOKBtn = getChild<LLButton>("OK");
	mOKBtn->setClickedCallback(onBtnOK, this);
			
	// avoid race condition, where mPreferenceCore is non-null, but not fully created
	LLPreferenceCore *pcore = new LLPreferenceCore(
		getChild<LLTabContainer>("pref core"),
		getChild<LLButton>("OK")
		);
	mPreferenceCore = pcore;
	
	sInstance = this;

	return TRUE;
}
Exemple #17
0
// virtual
BOOL LLFloaterIMPanel::postBuild() 
{
	requires<LLLineEditor>("chat_editor");
	requires<LLTextEditor>("im_history");

	if (checkRequirements())
	{
		setTitle(mLogLabel);
		if (mSessionType == P2P_SESSION && LLVoiceClient::getInstance()->isParticipantAvatar(mSessionUUID))
			LLAvatarNameCache::get(mOtherParticipantUUID, boost::bind(&LLFloaterIMPanel::onAvatarNameLookup, this, _2));

		mInputEditor = getChild<LLLineEditor>("chat_editor");
		mInputEditor->setAutoreplaceCallback(boost::bind(&LLAutoReplace::autoreplaceCallback, LLAutoReplace::getInstance(), _1, _2, _3, _4, _5));
		mInputEditor->setFocusReceivedCallback( boost::bind(&LLFloaterIMPanel::onInputEditorFocusReceived, this) );
		mFocusLostSignal = mInputEditor->setFocusLostCallback(boost::bind(&LLFloaterIMPanel::setTyping, this, false));
		mInputEditor->setKeystrokeCallback( boost::bind(&LLFloaterIMPanel::onInputEditorKeystroke, this, _1) );
		mInputEditor->setCommitCallback( boost::bind(&LLFloaterIMPanel::onSendMsg,this) );
		mInputEditor->setCommitOnFocusLost( FALSE );
		mInputEditor->setRevertOnEsc( FALSE );
		mInputEditor->setReplaceNewlinesWithSpaces( FALSE );
		mInputEditor->setPassDelete( TRUE );

		if (LLComboBox* flyout = findChild<LLComboBox>("instant_message_flyout"))
		{
			flyout->setCommitCallback(boost::bind(&LLFloaterIMPanel::onFlyoutCommit, this, flyout, _2));
			addDynamics(flyout);
		}
		if (LLUICtrl* ctrl = findChild<LLUICtrl>("tp_btn"))
			ctrl->setCommitCallback(boost::bind(static_cast<void(*)(const LLUUID&)>(LLAvatarActions::offerTeleport), mOtherParticipantUUID));
		if (LLUICtrl* ctrl = findChild<LLUICtrl>("pay_btn"))
			ctrl->setCommitCallback(boost::bind(LLAvatarActions::pay, mOtherParticipantUUID));
		if (LLButton* btn = findChild<LLButton>("group_info_btn"))
			btn->setCommitCallback(boost::bind(LLGroupActions::show, mSessionUUID));
		if (LLUICtrl* ctrl = findChild<LLUICtrl>("history_btn"))
			ctrl->setCommitCallback(boost::bind(&LLFloaterIMPanel::onClickHistory, this));

		getChild<LLButton>("start_call_btn")->setCommitCallback(boost::bind(&LLIMMgr::startCall, gIMMgr, boost::ref(mSessionUUID), LLVoiceChannel::OUTGOING_CALL));
		getChild<LLButton>("end_call_btn")->setCommitCallback(boost::bind(&LLIMMgr::endCall, gIMMgr, boost::ref(mSessionUUID)));
		getChild<LLButton>("send_btn")->setCommitCallback(boost::bind(&LLFloaterIMPanel::onSendMsg,this));
		if (LLButton* btn = findChild<LLButton>("toggle_active_speakers_btn"))
			btn->setCommitCallback(boost::bind(&LLFloaterIMPanel::onClickToggleActiveSpeakers, this, _2));

		mHistoryEditor = getChild<LLViewerTextEditor>("im_history");
		mHistoryEditor->setParseHTML(TRUE);
		mHistoryEditor->setParseHighlights(TRUE);

		sTitleString = getString("title_string");
		sTypingStartString = getString("typing_start_string");
		sSessionStartString = getString("session_start_string");

		if (mSpeakerPanel)
		{
			mSpeakerPanel->refreshSpeakers();
		}

		if (mSessionType == P2P_SESSION)
		{
			getChild<LLUICtrl>("mute_btn")->setCommitCallback(boost::bind(&LLFloaterIMPanel::onClickMuteVoice, this));
			getChild<LLUICtrl>("speaker_volume")->setCommitCallback(boost::bind(&LLVoiceClient::setUserVolume, LLVoiceClient::getInstance(), mOtherParticipantUUID, _2));
		}

		setDefaultBtn("send_btn");

		mVolumeSlider.connect(this,"speaker_volume");
		mEndCallBtn.connect(this,"end_call_btn");
		mStartCallBtn.connect(this,"start_call_btn");
		mSendBtn.connect(this,"send_btn");
		mMuteBtn.connect(this,"mute_btn");

		return TRUE;
	}

	return FALSE;
}
void MenuPowers::logic() {
	for (size_t i=0; i<power_cell_unlocked.size(); i++) {
		if (static_cast<size_t>(power_cell_unlocked[i].id) < powers->powers.size() && powers->powers[power_cell_unlocked[i].id].passive) {
			bool unlocked_power = std::find(stats->powers_list.begin(), stats->powers_list.end(), power_cell_unlocked[i].id) != stats->powers_list.end();
			std::vector<int>::iterator it = std::find(stats->powers_passive.begin(), stats->powers_passive.end(), power_cell_unlocked[i].id);

			int cell_index = getCellByPowerIndex(power_cell_unlocked[i].id, power_cell_all);
			if (it != stats->powers_passive.end()) {
				if (!checkRequirements(cell_index) && power_cell_unlocked[i].passive_on) {
					stats->powers_passive.erase(it);
					stats->effects.removeEffectPassive(power_cell_unlocked[i].id);
					power_cell[i].passive_on = false;
					stats->refresh_stats = true;
				}
			}
			else if (((checkRequirements(cell_index) && !power_cell_unlocked[i].requires_point) || unlocked_power) && !power_cell_unlocked[i].passive_on) {
				stats->powers_passive.push_back(power_cell_unlocked[i].id);
				power_cell_unlocked[i].passive_on = true;
				// for passives without special triggers, we need to trigger them here
				if (stats->effects.triggered_others)
					powers->activateSinglePassive(stats, power_cell_unlocked[i].id);
			}
		}
	}

	for (size_t i=0; i<power_cell.size(); i++) {
		//upgrade buttons logic
		if (upgradeButtons[i] != NULL) {
			upgradeButtons[i]->enabled = false;
			// enable button only if current level is unlocked and next level can be unlocked
			if (checkUpgrade(static_cast<int>(i))) {
				upgradeButtons[i]->enabled = true;
			}
			if ((!tab_control || power_cell[i].tab == tab_control->getActiveTab()) && upgradeButtons[i]->checkClick()) {
				upgradePower(static_cast<int>(i));
			}
		}
	}

	points_left = (stats->level * stats->power_points_per_level) - getPointsUsed();
	if (points_left > 0) {
		newPowerNotification = true;
	}

	if (!visible) return;

	tablist.logic();
	if (!tabs.empty()) {
		for (size_t i=0; i<tabs.size(); i++) {
			if (tab_control->getActiveTab() == static_cast<int>(i)) {
				tablist.setNextTabList(&tablist_pow[i]);
			}
			tablist_pow[i].logic();
		}
	}

	if (closeButton->checkClick()) {
		visible = false;
		snd->play(sfx_close);
	}

	if (tab_control) {
		// make shure keyboard navigation leads us to correct tab
		for (size_t i=0; i<slots.size(); i++) {
			if (power_cell[i].tab == tab_control->getActiveTab())
				continue;

			if (slots[i] && slots[i]->in_focus)
				slots[i]->defocus();
		}

		tab_control->logic();
	}
}
Action *ContextMenuActionProvider::addAction(Action *action, QMenu *menu, const QModelIndex &index, ItemActiveStates requiredActiveState)
{
    return addAction(action, menu, checkRequirements(index, requiredActiveState));
}
int main(int argc, const char * argv[])
{
    
#ifdef DEBUG
    cout << "DEBUG!!! DEBUG !!! DEBUG !!!" << endl;
    cout << "WORKING TREE: " << DEBUG_CHDIR << endl;
    if(!fileExists(DEBUG_CHDIR)){
        cout << "Error: Working Tree not found!!" << endl;
        exit(0);
    }
    chdir(DEBUG_CHDIR);
#endif
    
    if(argc == 2 && string(argv[1]) == string("-h")){
        cout << "Usage: " << argv[0] << "[" << threadsToRun << "] [benchmarkNr] ["<< positiveSentiments <<"] [" << negativeSentiments << "] [" << shufPath << "]" << endl;
        cout << "       1. Nr. of Threads to start" << endl;
        cout << "       2. BenchmakrNr: 0 for new, (TIMESTAMP) for resuming..." << endl;
        cout << "       3. Argument: Path to positive Sentiments File" << endl;
        cout << "       4. Argument: Path to negative Sentiments File" << endl;
        cout << "       5. Argument: Path to (g)shuf binary" << endl;
        exit(0);
    }
    
    std::string benchmarkNr(to_string(std::time(0)));
    
    if(argc >= 2){
        threadsToRun = atoi(argv[1]);
    }
    
    if(argc >= 3 && std::strcmp(argv[2], "0") != 0){
        benchmarkNr = string(argv[2]);
    }
    if(argc >= 4){
        positiveSentiments = string(argv[3]);
    }
    if(argc >= 5){
        negativeSentiments = string(argv[4]);
    }
    if(argc >= 6){
        shufPath = string(argv[5]);
    }
    
    if (!checkRequirements()){
        cout << "Usage: " << argv[0] << " ["<< positiveSentiments <<"] [" << negativeSentiments << "] [" << shufPath << "]" << endl;
        exit(0);
    }
    
    
    std::array<std::string, 3> t = {"url","user","mchar"};
    std::vector<std::string> transformers = getTransformCombinations(t, 1);
    transformers.push_back(string("id"));
    std::array<std::string, 4> featureSelectors = {"aes","ae","a","as"};
    std::array<std::string, 2> classifiers = {"bayes","svm"};
    std::array<int, 3> cutOffs = {2, 3, 4};
    std::array<string, 3> negativeFiles;
    std::array<string, 3> positiveFiles;
    
    int i = 0;
    for(auto& cutOff : cutOffs){
        negativeFiles[i] = generateSentimenFile(negativeSentiments, cutOff, benchmarkNr);
        positiveFiles[i] = generateSentimenFile(positiveSentiments, cutOff, benchmarkNr);
        i++;
    }
    
    std::vector<ClassifierConfiguration*> baseConfigurations;
    
    for(auto& transformer : transformers) {
        for(auto& featureSelector : featureSelectors){
            for(auto& classifier : classifiers){
                for(auto& cutOff : cutOffs){
                    //std::cout << "python classifier -f " << featureSelector << " -r " << transformer << " -t " << classifier << " -c " << cutOff << "\n";
                    
                    ClassifierConfiguration *cc = new ClassifierConfiguration(transformer, featureSelector, classifier, 0+cutOff, benchmarkNr);
                    cc->positivesFile = positiveFiles[cutOff-2]; // -2 weil der cutoff mit 2 beginnt
                    cc->negativesFile = negativeFiles[cutOff-2];
                    //baseConfigurations[bc++] = cc;
                    baseConfigurations.push_back(cc);
                }
            }
        }
    }
    
    std::cout << "Pickles to create: " << baseConfigurations.size()  << endl;
    
    for(auto bc : baseConfigurations){
        while (running_threads >= threadsToRun) {
            sleep(1);
        }
        bc->start();
    }
    
    while(running_threads > 0){
        sleep(1);
    }
    
    return 0;
}
Exemple #21
0
void MenuPowers::logic() {
	setUnlockedPowers();

	for (size_t i=0; i<power_cell_unlocked.size(); i++) {
		if (static_cast<size_t>(power_cell_unlocked[i].id) < powers->powers.size() && powers->powers[power_cell_unlocked[i].id].passive) {
			bool unlocked_power = std::find(stats->powers_list.begin(), stats->powers_list.end(), power_cell_unlocked[i].id) != stats->powers_list.end();
			std::vector<int>::iterator it = std::find(stats->powers_passive.begin(), stats->powers_passive.end(), power_cell_unlocked[i].id);

			int cell_index = getCellByPowerIndex(power_cell_unlocked[i].id, power_cell_all);
			bool is_current_upgrade_max = (getCellByPowerIndex(power_cell_unlocked[i].id, power_cell) != -1);

			if (it != stats->powers_passive.end()) {
				if (!is_current_upgrade_max || (!checkRequirements(cell_index) && power_cell_unlocked[i].passive_on)) {
					// passive power is activated, but does not meet requirements, so remove it
					stats->powers_passive.erase(it);
					stats->effects.removeEffectPassive(power_cell_unlocked[i].id);
					power_cell[i].passive_on = false;
					stats->refresh_stats = true;
				}
			}
			else if (is_current_upgrade_max && ((checkRequirements(cell_index) && !power_cell_unlocked[i].requires_point) || unlocked_power) && !power_cell_unlocked[i].passive_on) {
				// passive power has not been activated, so activate it here
				stats->powers_passive.push_back(power_cell_unlocked[i].id);
				power_cell_unlocked[i].passive_on = true;
				// for passives without special triggers, we need to trigger them here
				if (stats->effects.triggered_others)
					powers->activateSinglePassive(stats, power_cell_unlocked[i].id);
			}
		}
	}

	for (size_t i=0; i<power_cell.size(); i++) {
		//upgrade buttons logic
		if (upgradeButtons[i] != NULL) {
			upgradeButtons[i]->enabled = false;
			// enable button only if current level is unlocked and next level can be unlocked
			if (checkUpgrade(static_cast<int>(i))) {
				upgradeButtons[i]->enabled = true;
			}
			if ((!tab_control || power_cell[i].tab == tab_control->getActiveTab()) && upgradeButtons[i]->checkClick()) {
				upgradePower(static_cast<int>(i));
			}

			// automatically apply upgrades when requires_point = false
			if (upgradeButtons[i]->enabled) {
				int next_index;
				int prev_index = -1;
				while ((next_index = getNextLevelCell(static_cast<int>(i))) != -1) {
					if (prev_index == next_index) {
						// this should never happen, but if it ever does, it would be an infinite loop
						break;
					}

					if (!power_cell_upgrade[next_index].requires_point && checkUpgrade(static_cast<int>(i))) {
						upgradePower(static_cast<int>(i), true);
					}
					else {
						break;
					}

					prev_index = next_index;
				}
			}
		}
	}

	points_left = (stats->level * stats->power_points_per_level) - getPointsUsed();
	if (points_left > 0) {
		newPowerNotification = true;
	}

	if (!visible) return;

	tablist.logic();
	if (!tabs.empty()) {
		for (size_t i=0; i<tabs.size(); i++) {
			if (tab_control && tab_control->getActiveTab() == static_cast<int>(i)) {
				tablist.setNextTabList(&tablist_pow[i]);
			}
			tablist_pow[i].logic();
		}
	}

	if (closeButton->checkClick()) {
		visible = false;
		snd->play(sfx_close);
	}

	if (tab_control) {
		// make shure keyboard navigation leads us to correct tab
		for (size_t i=0; i<slots.size(); i++) {
			if (power_cell[i].tab == tab_control->getActiveTab())
				continue;

			if (slots[i] && slots[i]->in_focus)
				slots[i]->defocus();
		}

		tab_control->logic();
	}
}
Exemple #22
0
 /**
  * QuadTree Constructor.
  *
  * @param width    Width of a field that might be represented in a QuadTree. Also specifies a
  *                 height because field must be rectangular. Width must be a power of 2.
  * @param startX   Starting point of represented field in x-axis.
  * @param startY   Starting point of represented field in y-axis.
  * @param capacity Maximum capacity of a single tree node. Specifies how much elements (at most)
  *                 can be stored in one node. An exception are nodes at the maximum level of the
  *                 tree which shall store all remaining elements inserted into QuadTree (because
  *                 QuadTree doesn't have a limit to maximum number of stored elements).
  */
 QuadTree(size_t width, int startX, int startY, size_t capacity)
     : width(width), startX(startX), startY(startY), nodeCapacity(capacity),
     tr(startX, startY, width, width)
 {
     checkRequirements();
 }
Exemple #23
0
 /**
  * QuadTree Constructor.
  * Parameters startX, startY and nodeCapacity are set to 0.
  *
  *  @see QuadTree(size_t width, int startX, int startY, capacity)
  */
 explicit QuadTree(size_t width)
     : width(width), startX(0), startY(0), nodeCapacity(0),
     tr(startX, startY, width, width)
 {
     checkRequirements();
 }