Exemple #1
0
void Controller::handlePut(Key& key, shared_ptr<Value> value,
        const Requirements& requirements) {
    Condition condition = prepareCondition(key, value->getSize(), requirements);
    {
        lock_guard<mutex> gurad(infoLock);
        info[key] = KeyInfo{make_unique<Requirements>(requirements),
            value->getSize()};
    }
    double estimatedCost;
    Choice* choice = decider->choose(condition, &estimatedCost);
    if (choice == nullptr) {
        throw NoChoiceAvailableException();
    }
    accountant->recordEstimate(estimatedCost);
    accountant->recordPut(choice->getId(), value->getSize());
    storeInto(key, value, *choice, requirements);
    choice_id old_choice_id = memory->remember(key, choice->getId());
    if (old_choice_id != 0) {
        auto it = choices.find(old_choice_id);
        assert(it != choices.end());
        Choice& old_choice = it->second;
        old_choice.getActor()->del(key, old_choice.getProfile());
    }
    estimator->notifyPut(key, requirements);
    if (enableStat) {
        stat->notifyPut(key);
    }
}
void DeveloperToolsScreen::CreateViews() {
	using namespace UI;
	root_ = new ScrollView(ORIENT_VERTICAL);

	I18NCategory *d = GetI18NCategory("Dialog");
	I18NCategory *de = GetI18NCategory("Developer");
	I18NCategory *gs = GetI18NCategory("Graphics");
	I18NCategory *a = GetI18NCategory("Audio");
	I18NCategory *s = GetI18NCategory("System");

	LinearLayout *list = root_->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(1.0f)));
	list->SetSpacing(0);
	list->Add(new ItemHeader(s->T("General")));
	list->Add(new Choice(de->T("System Information")))->OnClick.Handle(this, &DeveloperToolsScreen::OnSysInfo);
	list->Add(new CheckBox(&g_Config.bShowDeveloperMenu, de->T("Show Developer Menu")));

	Choice *cpuTests = new Choice(de->T("Run CPU Tests"));
	list->Add(cpuTests)->OnClick.Handle(this, &DeveloperToolsScreen::OnRunCPUTests);
#ifdef IOS
	const std::string testDirectory = g_Config.flash0Directory + "../";
#else
	const std::string testDirectory = g_Config.memCardDirectory;
#endif
	if (!File::Exists(testDirectory + "pspautotests/tests/")) {
		cpuTests->SetEnabled(false);
	}

	list->Add(new CheckBox(&g_Config.bEnableLogging, de->T("Enable Logging")))->OnClick.Handle(this, &DeveloperToolsScreen::OnLoggingChanged);
	list->Add(new Choice(de->T("Logging Channels")))->OnClick.Handle(this, &DeveloperToolsScreen::OnLogConfig);
	list->Add(new ItemHeader(de->T("Language")));
	list->Add(new Choice(de->T("Load language ini")))->OnClick.Handle(this, &DeveloperToolsScreen::OnLoadLanguageIni);
	list->Add(new Choice(de->T("Save language ini")))->OnClick.Handle(this, &DeveloperToolsScreen::OnSaveLanguageIni);
	list->Add(new Choice(d->T("Back")))->OnClick.Handle(this, &DeveloperToolsScreen::OnBack);
}
void ControlMapper::Refresh() {
	Clear();
	I18NCategory *c = GetI18NCategory("MappableControls");

	std::map<std::string, int> keyImages;
	keyImages["Circle"] = I_CIRCLE;
	keyImages["Cross"] = I_CROSS;
	keyImages["Square"] = I_SQUARE;
	keyImages["Triangle"] = I_TRIANGLE;
	keyImages["Start"] = I_START;
	keyImages["Select"] = I_SELECT;
	keyImages["L"] = I_L;
	keyImages["R"] = I_R;

	using namespace UI;

	LinearLayout *root = Add(new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));

	auto iter = keyImages.find(keyName_);
	// First, look among images.
	if (iter != keyImages.end()) {
		root->Add(new Choice(iter->second, new LinearLayoutParams(200, WRAP_CONTENT)))->OnClick.Handle(this, &ControlMapper::OnReplaceAll);
	} else {
		// No image? Let's translate.
		Choice *choice = new Choice(c->T(keyName_.c_str()), new LinearLayoutParams(200, WRAP_CONTENT));
		choice->SetCentered(true);
		root->Add(choice)->OnClick.Handle(this, &ControlMapper::OnReplaceAll);
	}

	LinearLayout *rightColumn = root->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(1.0f)));
	rightColumn->SetSpacing(2.0f);
	std::vector<KeyDef> mappings;
	KeyMap::KeyFromPspButton(pspKey_, &mappings);

	for (size_t i = 0; i < mappings.size(); i++) {
		std::string deviceName = GetDeviceName(mappings[i].deviceId);
		std::string keyName = KeyMap::GetKeyOrAxisName(mappings[i].keyCode);
		int image = -1;

		LinearLayout *row = rightColumn->Add(new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));

		Choice *c = row->Add(new Choice(deviceName + "." + keyName, new LinearLayoutParams(1.0f)));
		char tagbuf[16];
		sprintf(tagbuf, "%i", (int)i);
		c->SetTag(tagbuf);
		c->OnClick.Handle(this, &ControlMapper::OnReplace);

		Choice *d = row->Add(new Choice("X"));
		d->SetTag(tagbuf);
		d->OnClick.Handle(this, &ControlMapper::OnDelete);

		row->Add(new Choice("+"))->OnClick.Handle(this, &ControlMapper::OnAdd);
	}

	if (mappings.size() == 0) {
		// look like an empty line
		rightColumn->Add(new Choice("", new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT)))->OnClick.Handle(this, &ControlMapper::OnAdd);
	}
}
void FileManager::AddFileButton(const wstring info, const string picN, const string coverN, const string coverCN, const string clickedN, const float pX, const float pY, const float cX, const float cY, 
	unsigned int a, const float bX, const float bY,const unsigned int bW, const unsigned int bH)
{
	Choice button;
	button.Init(picN,coverN,coverCN,clickedN,pX,pY,cX,cY,a,bX,bY,bW,bH);
	button.SetInfo(info);
	fileButtons.push_back(button);
}
Exemple #5
0
void ShaderListScreen::ListShaders(DebugShaderType shaderType, UI::LinearLayout *view) {
	using namespace UI;
	std::vector<std::string> shaderIds_ = gpu->DebugGetShaderIDs(shaderType);
	for (auto id : shaderIds_) {
		Choice *choice = view->Add(new Choice(gpu->DebugGetShaderString(id, shaderType, SHADER_STRING_SHORT_DESC)));
		choice->SetTag(id);
		choice->OnClick.Handle(this, &ShaderListScreen::OnShaderClick);
	}
}
Exemple #6
0
void Controller::storeInto(Key& key, shared_ptr<Value> value,
        const Choice& choice, const Requirements& requirements) {
    Actor* actor = choice.getActor();
    Dbg() << "chose " << choice.desc() << " for this" << endl;
    if (requirements.metadata.empty()) {
        actor->put(key, value, choice.getProfile());
    } else {
        actor->put(key, value, choice.getProfile(), &requirements.metadata);
    }
}
void DeveloperToolsScreen::CreateViews() {
	using namespace UI;
	root_ = new ScrollView(ORIENT_VERTICAL);

	I18NCategory *d = GetI18NCategory("Dialog");
	I18NCategory *de = GetI18NCategory("Developer");
	I18NCategory *gs = GetI18NCategory("Graphics");
	I18NCategory *a = GetI18NCategory("Audio");
	I18NCategory *s = GetI18NCategory("System");

	LinearLayout *list = root_->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(1.0f)));
	list->SetSpacing(0);
	list->Add(new ItemHeader(s->T("General")));

#ifdef IOS
	if (!iosCanUseJit) {
		list->Add(new TextView(s->T("DynarecisJailed", "Dynarec (JIT) - (Not jailbroken - JIT not available)")));
	} else {
		auto jitCheckbox = new CheckBox(&g_Config.bJit, s->T("Dynarec", "Dynarec (JIT)"));
		jitCheckbox->SetEnabled(!PSP_IsInited());
		list->Add(jitCheckbox);
	}
#else
	auto jitCheckbox = new CheckBox(&g_Config.bJit, s->T("Dynarec", "Dynarec (JIT)"));
	jitCheckbox->SetEnabled(!PSP_IsInited());
	list->Add(jitCheckbox);
#endif

	list->Add(new Choice(de->T("System Information")))->OnClick.Handle(this, &DeveloperToolsScreen::OnSysInfo);
	list->Add(new CheckBox(&g_Config.bShowDeveloperMenu, de->T("Show Developer Menu")));
	list->Add(new CheckBox(&g_Config.bDumpDecryptedEboot, de->T("Dump Decrypted Eboot", "Dump Decrypted EBOOT.BIN (If Encrypted) When Booting Game")));

	Choice *cpuTests = new Choice(de->T("Run CPU Tests"));
	list->Add(cpuTests)->OnClick.Handle(this, &DeveloperToolsScreen::OnRunCPUTests);
#ifdef IOS
	const std::string testDirectory = g_Config.flash0Directory + "../";
#else
	const std::string testDirectory = g_Config.memCardDirectory;
#endif
	if (!File::Exists(testDirectory + "pspautotests/tests/")) {
		cpuTests->SetEnabled(false);
	}

	list->Add(new CheckBox(&g_Config.bEnableLogging, de->T("Enable Logging")))->OnClick.Handle(this, &DeveloperToolsScreen::OnLoggingChanged);
	list->Add(new Choice(de->T("Logging Channels")))->OnClick.Handle(this, &DeveloperToolsScreen::OnLogConfig);
	list->Add(new ItemHeader(de->T("Language")));
	list->Add(new Choice(de->T("Load language ini")))->OnClick.Handle(this, &DeveloperToolsScreen::OnLoadLanguageIni);
	list->Add(new Choice(de->T("Save language ini")))->OnClick.Handle(this, &DeveloperToolsScreen::OnSaveLanguageIni);
	list->Add(new ItemHeader(""));
	list->Add(new Choice(d->T("Back")))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
}
Exemple #8
0
void Controller::checkMigration(Key& key, const Choice& current,
        bool extraGet, shared_ptr<Value> valueGot) {
    Requirements requirements;
    size_t size;
    {
        lock_guard<mutex> guard(infoLock);
        if (info.count(key) == 0) return;
        requirements = *info[key].requirements.get();
        size = info[key].size;
    }
    Condition condition = prepareCondition(key, size, requirements);
    double estimatedCost;
    Choice* choice = decider->findBetter(condition, current, extraGet,
            &estimatedCost);
    if (choice != nullptr) {
        Dbg() << "migrating from " << current.desc() << " to " << choice->desc() << endl;
        shared_ptr<Value> value;
        Requirements migrateRequirements;
        if (extraGet) {
            value = current.getActor()->get(key, current.getProfile());
        } else {
            value = valueGot;
        }
        storeInto(key, value, *choice, requirements);
        choice_id old_id = memory->remember(key, choice->getId());
        deleteFrom(key, current);
        accountant->recordMigrate(current.getId(), choice->getId(), size,
                extraGet);
    }
}
//==== Create & Init Choice  ====//
void GroupLayout::AddChoice( Choice & choice, const char* label, int used_w )
{
    assert( m_Group && m_Screen );

    //==== Choice Button ====//
    VspButton* button = new VspButton( m_X, m_Y, m_ChoiceButtonWidth, m_StdHeight, label );
    button->box( FL_THIN_UP_BOX );
    button->labelfont( 1 );
    button->labelsize( 12 );
    button->labelcolor( FL_BLACK );
    button->copy_label( label );
    m_Group->add( button );
    AddX( m_ChoiceButtonWidth );

    //==== Choice Picker ====//
    int choice_w = FitWidth( m_ChoiceButtonWidth + used_w, m_SliderWidth );
    Fl_Choice* fl_choice = new Fl_Choice( m_X, m_Y, choice_w, m_StdHeight );
    fl_choice->down_box( FL_BORDER_BOX );
    fl_choice->textfont( 1 );
    fl_choice->textsize( 12 );
    fl_choice->textcolor( FL_DARK_BLUE );
    m_Group->add( fl_choice );
    AddX( choice_w );

    //==== Add Choice Text ===//
    vector< string > choice_vec = choice.GetItems();
    for ( int i = 0 ; i < ( int )choice_vec.size() ; i++ )
    {
        fl_choice->add( choice_vec[i].c_str() );
    }
    fl_choice->value( 0 );

    choice.Init( m_Screen, fl_choice, button );

    if( strcmp( label, "AUTO_UPDATE" ) == 0 || strcmp( label, "" ) == 0 )
    {
        choice.SetButtonNameUpdate( true );
    }

    AddY( m_StdHeight );
    NewLineX();

}
Exemple #10
0
 void
 Space::_trycommit(const Choice& c, unsigned int a) {
   if (a >= c.alternatives())
     throw SpaceIllegalAlternative("Space::commit");
   if (failed())
     return;
   if (Brancher* b = brancher(c._id)) {
     // There is a matching brancher
     if (b->commit(*this,c,a) == ES_FAILED)
       fail();
   }
 }
Exemple #11
0
shared_ptr<Value> Controller::handleGet(Key& key, const Requirements& requirements) {
    shared_ptr<Value> value;

    Requirements mutable_requirements = requirements;

    choice_id cid;
    if (memory->recall(key, &cid)) {
        auto cit = choices.find(cid);
        assert(cit != choices.end());
        Choice choice = cit->second;
        accountant->recordGet(cid);

        Actor* actor = choice.getActor();
        Dbg() << "choice " << choice.desc() << "handle this" << endl;
        if (requirements.prefer_url) {
            value = actor->get_url(key, requirements.expiration, choice.getProfile());
        }
        if (!value) {
            value = actor->get(key, choice.getProfile(), requirements.range, &mutable_requirements.metadata);
        }

        if (!value) {
            Err() << "cannot find " << key.toString() << " in choice " << choice.desc() << endl;
            for (auto& choice_pair : choices) {
                Choice& choice = choice_pair.second;
                if (choice.getActor()->get(key, choice.getProfile(), requirements.range, &mutable_requirements.metadata)) {
                    Err() << "found key in " << choice.desc() << "instead" << endl;
                    abort();
                }
            }
        }

        if (enableGetMigration) {
            bool extraGet = !value->hasUrl();
            checkMigration(key, choice, extraGet, value);
        }
    }

    estimator->notifyGet(key, mutable_requirements);
    if (enableStat) {
        stat->notifyGet(key);
    }

    return value;
}
void ControlMapper::Refresh() {
	Clear();

	using namespace UI;

	LinearLayout *root = Add(new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));
	
	root->Add(new Choice(keyName_, new LinearLayoutParams(200, WRAP_CONTENT)))->OnClick.Handle(this, &ControlMapper::OnReplaceAll);
	LinearLayout *rightColumn = root->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(1.0f)));
	rightColumn->SetSpacing(2.0f);
	std::vector<KeyDef> mappings;
	KeyMap::KeyFromPspButton(pspKey_, &mappings);

	for (size_t i = 0; i < mappings.size(); i++) {
		std::string deviceName = GetDeviceName(mappings[i].deviceId);
		std::string keyName = KeyMap::GetKeyOrAxisName(mappings[i].keyCode);
		int image = -1;

		LinearLayout *row = rightColumn->Add(new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));

		Choice *c = row->Add(new Choice(deviceName + "." + keyName, new LinearLayoutParams(1.0f)));
		char tagbuf[16];
		sprintf(tagbuf, "%i", (int)i);
		c->SetTag(tagbuf);
		c->OnClick.Handle(this, &ControlMapper::OnReplace);

		Choice *d = row->Add(new Choice("X"));
		d->SetTag(tagbuf);
		d->OnClick.Handle(this, &ControlMapper::OnDelete);

		row->Add(new Choice("+"))->OnClick.Handle(this, &ControlMapper::OnAdd);
	}

	if (mappings.size() == 0) {
		// look like an empty line
		rightColumn->Add(new Choice("", new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT)))->OnClick.Handle(this, &ControlMapper::OnAdd);
	}
}
Exemple #13
0
 void
 Space::print(const Choice& c, unsigned int a, std::ostream& o) const {
   if (a >= c.alternatives())
     throw SpaceIllegalAlternative("Space::print");
   if (failed())
     return;
   if (Brancher* b = const_cast<Space&>(*this).brancher(c._id)) {
     // There is a matching brancher
     b->print(*this,c,a,o);
   } else {
     // There is no matching brancher!
     throw SpaceNoBrancher("Space::print");
   }
 }
Exemple #14
0
 void
 Space::_commit(const Choice& c, unsigned int a) {
   if (a >= c.alternatives())
     throw SpaceIllegalAlternative();
   if (failed())
     return;
   /*
    * Due to weakly monotonic propagators the following scenario might
    * occur: a brancher has been committed with all its available
    * choices. Then, propagation determines less information
    * than before and the brancher now will create new choices.
    * Later, during recomputation, all of these choices
    * can be used together, possibly interleaved with 
    * choices for other branchers. That means all branchers
    * must be scanned to find the matching brancher for the choice.
    *
    * b_commit tries to optimize scanning as it is most likely that
    * recomputation does not generate new choices during recomputation
    * and hence b_commit is moved from newer to older branchers.
    */
   Brancher* b_old = b_commit;
   // Try whether we are lucky
   while (b_commit != Brancher::cast(&bl))
     if (c._id != b_commit->id())
       b_commit = Brancher::cast(b_commit->next());
     else
       goto found;
   if (b_commit == Brancher::cast(&bl)) {
     // We did not find the brancher, start at the beginning
     b_commit = Brancher::cast(bl.next());
     while (b_commit != b_old)
       if (c._id != b_commit->id())
         b_commit = Brancher::cast(b_commit->next());
       else
         goto found;
   }
   // There is no matching brancher!
   throw SpaceNoBrancher();
 found:
   // There is a matching brancher
   if (b_commit->commit(*this,c,a) == ES_FAILED)
     fail();
 }
void GameSettingsScreen::CreateViews() {
	GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true);

	cap60FPS_ = g_Config.iForceMaxEmulatedFPS == 60;
	showDebugStats_ = g_Config.bShowDebugStats;

	iAlternateSpeedPercent_ = 3;
	for (int i = 0; i < 8; i++) {
		if (g_Config.iFpsLimit <= alternateSpeedTable[i]) {
			iAlternateSpeedPercent_ = i;
			break;
		}
	}

	// Information in the top left.
	// Back button to the bottom left.
	// Scrolling action menu to the right.
	using namespace UI;

	I18NCategory *d = GetI18NCategory("Dialog");
	I18NCategory *gs = GetI18NCategory("Graphics");
	I18NCategory *c = GetI18NCategory("Controls");
	I18NCategory *a = GetI18NCategory("Audio");
	I18NCategory *s = GetI18NCategory("System");
	I18NCategory *ms = GetI18NCategory("MainSettings");
	I18NCategory *dev = GetI18NCategory("Developer");

	root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));

	ViewGroup *leftColumn = new AnchorLayout(new LinearLayoutParams(1.0f));
	root_->Add(leftColumn);

	root_->Add(new Choice(d->T("Back"), "", false, new AnchorLayoutParams(150, 64, 10, NONE, NONE, 10)))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);

	TabHolder *tabHolder = new TabHolder(ORIENT_VERTICAL, 200, new AnchorLayoutParams(10, 0, 10, 0, false));

	root_->Add(tabHolder);

	// TODO: These currently point to global settings, not game specific ones.

	// Graphics
	ViewGroup *graphicsSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
	LinearLayout *graphicsSettings = new LinearLayout(ORIENT_VERTICAL);
	graphicsSettings->SetSpacing(0);
	graphicsSettingsScroll->Add(graphicsSettings);
	tabHolder->AddTab(ms->T("Graphics"), graphicsSettingsScroll);

	graphicsSettings->Add(new ItemHeader(gs->T("Rendering Mode")));
	static const char *renderingMode[] = { "Non-Buffered Rendering", "Buffered Rendering", "Read Framebuffers To Memory (CPU)", "Read Framebuffers To Memory (GPU)"};
	graphicsSettings->Add(new PopupMultiChoice(&g_Config.iRenderingMode, gs->T("Mode"), renderingMode, 0, ARRAY_SIZE(renderingMode), gs, screenManager()))->OnChoice.Handle(this, &GameSettingsScreen::OnRenderingMode);


	graphicsSettings->Add(new ItemHeader(gs->T("Frame Rate Control")));
	static const char *frameSkip[] = {"Off", "1", "2", "3", "4", "5", "6", "7", "8"};
	graphicsSettings->Add(new PopupMultiChoice(&g_Config.iFrameSkip, gs->T("Frame Skipping"), frameSkip, 0, ARRAY_SIZE(frameSkip), gs, screenManager()));
	graphicsSettings->Add(new CheckBox(&g_Config.bAutoFrameSkip, gs->T("Auto FrameSkip")));
	graphicsSettings->Add(new CheckBox(&cap60FPS_, gs->T("Force max 60 FPS (helps GoW)")));
	static const char *customSpeed[] = {"Unlimited", "25%", "50%", "75%", "100%", "125%", "150%", "200%", "300%"};
	graphicsSettings->Add(new PopupMultiChoice(&iAlternateSpeedPercent_, gs->T("Alternative Speed"), customSpeed, 0, ARRAY_SIZE(customSpeed), gs, screenManager()));

	graphicsSettings->Add(new ItemHeader(gs->T("Features")));
	postProcChoice_ = graphicsSettings->Add(new Choice(gs->T("Postprocessing Shader")));
	postProcChoice_->OnClick.Handle(this, &GameSettingsScreen::OnPostProcShader);
	postProcChoice_->SetEnabled(g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);

#if defined(_WIN32) || defined(USING_QT_UI)
	graphicsSettings->Add(new CheckBox(&g_Config.bFullScreen, gs->T("FullScreen")))->OnClick.Handle(this, &GameSettingsScreen::OnFullscreenChange);
#endif
	graphicsSettings->Add(new CheckBox(&g_Config.bStretchToDisplay, gs->T("Stretch to Display")));
	// Small Display: To avoid overlapping touch controls on large tablets. Better control over this will be coming later.
	graphicsSettings->Add(new CheckBox(&g_Config.bSmallDisplay, gs->T("Small Display")));
	if (pixel_xres < pixel_yres * 1.3) // Smaller than 4:3
		graphicsSettings->Add(new CheckBox(&g_Config.bPartialStretch, gs->T("Partial Vertical Stretch")));
	graphicsSettings->Add(new CheckBox(&g_Config.bMipMap, gs->T("Mipmapping")));

	graphicsSettings->Add(new ItemHeader(gs->T("Performance")));

#ifndef USING_GLES2
	static const char *internalResolutions[] = {"Auto (1:1)", "1x PSP", "2x PSP", "3x PSP", "4x PSP", "5x PSP", "6x PSP", "7x PSP", "8x PSP", "9x PSP", "10x PSP" };
#else
	static const char *internalResolutions[] = {"Auto (1:1)", "1x PSP", "2x PSP", "3x PSP", "4x PSP", "5x PSP" };
#endif
	resolutionChoice_ = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iInternalResolution, gs->T("Rendering Resolution"), internalResolutions, 0, ARRAY_SIZE(internalResolutions), gs, screenManager()));
	resolutionChoice_->OnClick.Handle(this, &GameSettingsScreen::OnResolutionChange);
	resolutionChoice_->SetEnabled(g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
#ifdef _WIN32
	graphicsSettings->Add(new CheckBox(&g_Config.bVSync, gs->T("VSync")));
#endif
	graphicsSettings->Add(new CheckBox(&g_Config.bHardwareTransform, gs->T("Hardware Transform")));
	CheckBox *swSkin = graphicsSettings->Add(new CheckBox(&g_Config.bSoftwareSkinning, gs->T("Software Skinning")));
	CheckBox *vtxCache = graphicsSettings->Add(new CheckBox(&g_Config.bVertexCache, gs->T("Vertex Cache")));
	vtxCache->SetEnabledPtr((bool *)&g_Config.bHardwareTransform);
	graphicsSettings->Add(new CheckBox(&g_Config.bTextureBackoffCache, gs->T("Lazy texture caching", "Lazy texture caching (speedup)")));
	graphicsSettings->Add(new CheckBox(&g_Config.bTextureSecondaryCache, gs->T("Retain changed textures", "Retain changed textures (speedup, mem hog)")));

	// Seems solid, so we hide the setting.
	// CheckBox *vtxJit = graphicsSettings->Add(new CheckBox(&g_Config.bVertexDecoderJit, gs->T("Vertex Decoder JIT")));

	if (PSP_IsInited()) {
		swSkin->SetEnabled(false);
		// vtxJit->SetEnabled(false);
	}

	graphicsSettings->Add(new CheckBox(&g_Config.bLowQualitySplineBezier, gs->T("LowCurves", "Low quality spline/bezier curves")));

	// In case we're going to add few other antialiasing option like MSAA in the future.
	// graphicsSettings->Add(new CheckBox(&g_Config.bFXAA, gs->T("FXAA")));
	graphicsSettings->Add(new ItemHeader(gs->T("Texture Scaling")));
#ifndef USING_GLES2
	static const char *texScaleLevelsNPOT[] = {"Auto", "Off", "2x", "3x", "4x", "5x"};
	static const char *texScaleLevelsPOT[] = {"Auto", "Off", "2x", "4x"};
#else
	static const char *texScaleLevelsNPOT[] = {"Auto", "Off", "2x", "3x"};
	static const char *texScaleLevelsPOT[] = {"Auto", "Off", "2x"};
#endif

	static const char **texScaleLevels;
	static int numTexScaleLevels;
	if (gl_extensions.OES_texture_npot) {
		texScaleLevels = texScaleLevelsNPOT;
		numTexScaleLevels = ARRAY_SIZE(texScaleLevelsNPOT);
	} else {
		texScaleLevels = texScaleLevelsPOT;
		numTexScaleLevels = ARRAY_SIZE(texScaleLevelsPOT);
	}
	graphicsSettings->Add(new PopupMultiChoice(&g_Config.iTexScalingLevel, gs->T("Upscale Level"), texScaleLevels, 0, numTexScaleLevels, gs, screenManager()));
	static const char *texScaleAlgos[] = { "xBRZ", "Hybrid", "Bicubic", "Hybrid + Bicubic", };
	graphicsSettings->Add(new PopupMultiChoice(&g_Config.iTexScalingType, gs->T("Upscale Type"), texScaleAlgos, 0, ARRAY_SIZE(texScaleAlgos), gs, screenManager()));
	graphicsSettings->Add(new CheckBox(&g_Config.bTexDeposterize, gs->T("Deposterize")));
	graphicsSettings->Add(new ItemHeader(gs->T("Texture Filtering")));
	static const char *anisoLevels[] = { "Off", "2x", "4x", "8x", "16x" };
	graphicsSettings->Add(new PopupMultiChoice(&g_Config.iAnisotropyLevel, gs->T("Anisotropic Filtering"), anisoLevels, 0, ARRAY_SIZE(anisoLevels), gs, screenManager()));
	static const char *texFilters[] = { "Auto", "Nearest", "Linear", "Linear on FMV", };
	graphicsSettings->Add(new PopupMultiChoice(&g_Config.iTexFiltering, gs->T("Texture Filter"), texFilters, 1, ARRAY_SIZE(texFilters), gs, screenManager()));

	graphicsSettings->Add(new ItemHeader(gs->T("Hack Settings", "Hack Settings (these WILL cause glitches)")));
	graphicsSettings->Add(new CheckBox(&g_Config.bTimerHack, gs->T("Timer Hack")));
	// Maybe hide this on non-PVR?
	graphicsSettings->Add(new CheckBox(&g_Config.bDisableAlphaTest, gs->T("Disable Alpha Test (PowerVR speedup)")))->OnClick.Handle(this, &GameSettingsScreen::OnShaderChange);
	graphicsSettings->Add(new CheckBox(&g_Config.bDisableStencilTest, gs->T("Disable Stencil Test")));
	graphicsSettings->Add(new CheckBox(&g_Config.bAlwaysDepthWrite, gs->T("Always Depth Write")));
	CheckBox *prescale = graphicsSettings->Add(new CheckBox(&g_Config.bPrescaleUV, gs->T("Texture Coord Speedhack")));
	if (PSP_IsInited())
		prescale->SetEnabled(false);

	graphicsSettings->Add(new ItemHeader(gs->T("Overlay Information")));
	static const char *fpsChoices[] = {
		"None", "Speed", "FPS", "Both"
#ifdef BLACKBERRY
     , "Statistics"
#endif
	};
	graphicsSettings->Add(new PopupMultiChoice(&g_Config.iShowFPSCounter, gs->T("Show FPS Counter"), fpsChoices, 0, ARRAY_SIZE(fpsChoices), gs, screenManager()));
	graphicsSettings->Add(new CheckBox(&showDebugStats_, gs->T("Show Debug Statistics")));

	// Developer tools are not accessible ingame, so it goes here.
	graphicsSettings->Add(new ItemHeader(gs->T("Debugging")));
	Choice *dump = graphicsSettings->Add(new Choice(gs->T("Dump next frame to log")));
	dump->OnClick.Handle(this, &GameSettingsScreen::OnDumpNextFrameToLog);
	if (!PSP_IsInited())
		dump->SetEnabled(false);

	// We normally use software rendering to debug so put it in debugging.
	CheckBox *softwareGPU = graphicsSettings->Add(new CheckBox(&g_Config.bSoftwareRendering, gs->T("Software Rendering", "Software Rendering (experimental)"))); 
	if (PSP_IsInited())
		softwareGPU->SetEnabled(false);

	// Audio
	ViewGroup *audioSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
	LinearLayout *audioSettings = new LinearLayout(ORIENT_VERTICAL);
	audioSettings->SetSpacing(0);
	audioSettingsScroll->Add(audioSettings);
	tabHolder->AddTab(ms->T("Audio"), audioSettingsScroll);

	audioSettings->Add(new ItemHeader(ms->T("Audio")));

	PopupSliderChoice *sfxVol = audioSettings->Add(new PopupSliderChoice(&g_Config.iSFXVolume, 0, MAX_CONFIG_VOLUME, a->T("SFX volume"), screenManager()));
	sfxVol->SetEnabledPtr(&g_Config.bEnableSound);
	PopupSliderChoice *bgmVol = audioSettings->Add(new PopupSliderChoice(&g_Config.iBGMVolume, 0, MAX_CONFIG_VOLUME, a->T("BGM volume"), screenManager()));
	bgmVol->SetEnabledPtr(&g_Config.bEnableSound);

	audioSettings->Add(new CheckBox(&g_Config.bEnableSound, a->T("Enable Sound")));
	CheckBox *lowAudio = audioSettings->Add(new CheckBox(&g_Config.bLowLatencyAudio, a->T("Low latency audio")));
	lowAudio->SetEnabledPtr(&g_Config.bEnableSound);

	// Control
	ViewGroup *controlsSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
	LinearLayout *controlsSettings = new LinearLayout(ORIENT_VERTICAL);
	controlsSettings->SetSpacing(0);
	controlsSettingsScroll->Add(controlsSettings);
	tabHolder->AddTab(ms->T("Controls"), controlsSettingsScroll);
	controlsSettings->Add(new ItemHeader(ms->T("Controls")));
	controlsSettings->Add(new Choice(c->T("Control Mapping")))->OnClick.Handle(this, &GameSettingsScreen::OnControlMapping);

#if defined(USING_GLES2)
	controlsSettings->Add(new CheckBox(&g_Config.bHapticFeedback, c->T("HapticFeedback", "Haptic Feedback (vibration)")));
	static const char *tiltTypes[] = { "None (Disabled)", "Analog Stick", "D-PAD", "PSP Action Buttons"};
	controlsSettings->Add(new PopupMultiChoice(&g_Config.iTiltInputType, c->T("Tilt Input Type"), tiltTypes, 0, ARRAY_SIZE(tiltTypes), c, screenManager()))->OnClick.Handle(this, &GameSettingsScreen::OnTiltTypeChange);

	Choice *customizeTilt = controlsSettings->Add(new Choice(c->T("Customize tilt")));
	customizeTilt->OnClick.Handle(this, &GameSettingsScreen::OnTiltCuztomize);
	customizeTilt->SetEnabledPtr((bool *)&g_Config.iTiltInputType); //<- dirty int-to-bool cast
#endif
	controlsSettings->Add(new ItemHeader(c->T("OnScreen", "On-Screen Touch Controls")));
	controlsSettings->Add(new CheckBox(&g_Config.bShowTouchControls, c->T("OnScreen", "On-Screen Touch Controls")));
	layoutEditorChoice_ = controlsSettings->Add(new Choice(c->T("Custom layout...")));
	layoutEditorChoice_->OnClick.Handle(this, &GameSettingsScreen::OnTouchControlLayout);
	layoutEditorChoice_->SetEnabledPtr(&g_Config.bShowTouchControls);
	CheckBox *disableDiags = controlsSettings->Add(new CheckBox(&g_Config.bDisableDpadDiagonals, c->T("Disable D-Pad diagonals (4-way touch)")));
	disableDiags->SetEnabledPtr(&g_Config.bShowTouchControls);
	View *opacity = controlsSettings->Add(new PopupSliderChoice(&g_Config.iTouchButtonOpacity, 0, 100, c->T("Button Opacity"), screenManager()));
	opacity->SetEnabledPtr(&g_Config.bShowTouchControls);
	static const char *touchControlStyles[] = {"Classic", "Thin borders"};
	View *style = controlsSettings->Add(new PopupMultiChoice(&g_Config.iTouchButtonStyle, c->T("Button style"), touchControlStyles, 0, ARRAY_SIZE(touchControlStyles), c, screenManager()));
	style->SetEnabledPtr(&g_Config.bShowTouchControls);

#if defined(_WIN32) && !defined(USING_QT_UI)
	controlsSettings->Add(new ItemHeader(c->T("Keyboard", "Keyboard Control Settings")));
	controlsSettings->Add(new CheckBox(&g_Config.bIgnoreWindowsKey, c->T("Ignore Windows Key")));
#endif

	// System
	ViewGroup *systemSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
	LinearLayout *systemSettings = new LinearLayout(ORIENT_VERTICAL);
	systemSettings->SetSpacing(0);
	systemSettingsScroll->Add(systemSettings);
	tabHolder->AddTab(ms->T("System"), systemSettingsScroll);

	systemSettings->Add(new ItemHeader(s->T("UI Language")));
	systemSettings->Add(new Choice(dev->T("Language", "Language")))->OnClick.Handle(this, &GameSettingsScreen::OnLanguage);

	systemSettings->Add(new ItemHeader(s->T("Emulation")));
	systemSettings->Add(new CheckBox(&g_Config.bFastMemory, s->T("Fast Memory", "Fast Memory (Unstable)")));

	systemSettings->Add(new CheckBox(&g_Config.bSeparateCPUThread, s->T("Multithreaded (experimental)")))->SetEnabled(!PSP_IsInited());
	systemSettings->Add(new CheckBox(&g_Config.bSeparateIOThread, s->T("I/O on thread (experimental)")))->SetEnabled(!PSP_IsInited());
	systemSettings->Add(new PopupSliderChoice(&g_Config.iLockedCPUSpeed, 0, 1000, s->T("Change CPU Clock", "Change CPU Clock (0 = default) (unstable)"), screenManager()));
#ifndef USING_GLES2
	systemSettings->Add(new PopupSliderChoice(&g_Config.iRewindFlipFrequency, 0, 1800, s->T("Rewind Snapshot Frequency", "Rewind Snapshot Frequency (0 = off, mem hog)"), screenManager()));
#endif

	systemSettings->Add(new CheckBox(&g_Config.bAtomicAudioLocks, s->T("Atomic Audio locks (experimental)")))->SetEnabled(!PSP_IsInited());

	systemSettings->Add(new ItemHeader(s->T("Developer Tools")));
	systemSettings->Add(new Choice(s->T("Developer Tools")))->OnClick.Handle(this, &GameSettingsScreen::OnDeveloperTools);

	systemSettings->Add(new ItemHeader(s->T("General")));
	systemSettings->Add(new CheckBox(&g_Config.bCheckForNewVersion, s->T("VersionCheck", "Check for new versions of PPSSPP")));
	systemSettings->Add(new Choice(s->T("Clear Recent Games List")))->OnClick.Handle(this, &GameSettingsScreen::OnClearRecents);
	systemSettings->Add(new Choice(s->T("Restore Default Settings")))->OnClick.Handle(this, &GameSettingsScreen::OnRestoreDefaultSettings);
	systemSettings->Add(new CheckBox(&g_Config.bEnableAutoLoad, s->T("Auto Load Newest Savestate")));

	enableReports_ = Reporting::IsEnabled();
	enableReportsCheckbox_ = new CheckBox(&enableReports_, s->T("Enable Compatibility Server Reports"));
	enableReportsCheckbox_->SetEnabled(Reporting::IsSupported());
	systemSettings->Add(enableReportsCheckbox_);

	systemSettings->Add(new ItemHeader(s->T("Networking")));
	systemSettings->Add(new CheckBox(&g_Config.bEnableWlan, s->T("Enable networking", "Enable networking/wlan (beta)")));

//#ifndef ANDROID
	systemSettings->Add(new ItemHeader(s->T("Cheats", "Cheats (experimental, see forums)")));
	systemSettings->Add(new CheckBox(&g_Config.bEnableCheats, s->T("Enable Cheats")));
//#endif
	LinearLayout *list = root_->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(1.0f)));
	systemSettings->SetSpacing(0);

	systemSettings->Add(new ItemHeader(s->T("PSP Settings")));
	static const char *models[] = {"PSP-1000" , "PSP-2000/3000"};
	systemSettings->Add(new PopupMultiChoice(&g_Config.iPSPModel, s->T("PSP Model"), models, 0, ARRAY_SIZE(models), s, screenManager()));
	// TODO: Come up with a way to display a keyboard for mobile users,
	// so until then, this is Windows/Desktop only.
#if defined(_WIN32) || defined(USING_QT_UI)
	systemSettings->Add(new Choice(s->T("Change Nickname")))->OnClick.Handle(this, &GameSettingsScreen::OnChangeNickname);
#endif
#if defined(_WIN32) || (defined(USING_QT_UI) && !defined(USING_GLES2))
	// Screenshot functionality is not yet available on non-Windows/non-Qt
	systemSettings->Add(new CheckBox(&g_Config.bScreenshotsAsPNG, s->T("Screenshots as PNG")));
#endif
	systemSettings->Add(new CheckBox(&g_Config.bDayLightSavings, s->T("Day Light Saving")));
	static const char *dateFormat[] = { "YYYYMMDD", "MMDDYYYY", "DDMMYYYY"};
	systemSettings->Add(new PopupMultiChoice(&g_Config.iDateFormat, s->T("Date Format"), dateFormat, 1, 3, s, screenManager()));
	static const char *timeFormat[] = { "12HR", "24HR"};
	systemSettings->Add(new PopupMultiChoice(&g_Config.iTimeFormat, s->T("Time Format"), timeFormat, 1, 2, s, screenManager()));
	static const char *buttonPref[] = { "Use O to confirm", "Use X to confirm" };
	systemSettings->Add(new PopupMultiChoice(&g_Config.iButtonPreference, s->T("Confirmation Button"), buttonPref, 0, 2, s, screenManager()));
}
Exemple #16
0
void Spawner::runChoice(const Choice choice) {
  QProcess::startDetached(choice.id(), choice.params());
}
Exemple #17
0
void Spawner::openId(Choice choice) {
  _coordinator.openItem(QUrl(choice.id()));
}
void GameSettingsScreen::CreateViews() {
	GameInfo *info = g_gameInfoCache.GetInfo(NULL, gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE);

	cap60FPS_ = g_Config.iForceMaxEmulatedFPS == 60;

	iAlternateSpeedPercent_ = (g_Config.iFpsLimit * 100) / 60;

	bool vertical = UseVerticalLayout();

	// Information in the top left.
	// Back button to the bottom left.
	// Scrolling action menu to the right.
	using namespace UI;

	I18NCategory *d = GetI18NCategory("Dialog");
	I18NCategory *gs = GetI18NCategory("Graphics");
	I18NCategory *c = GetI18NCategory("Controls");
	I18NCategory *a = GetI18NCategory("Audio");
	I18NCategory *s = GetI18NCategory("System");
	I18NCategory *ms = GetI18NCategory("MainSettings");
	I18NCategory *dev = GetI18NCategory("Developer");

	if (vertical) {
		root_ = new LinearLayout(ORIENT_VERTICAL, new LayoutParams(FILL_PARENT, FILL_PARENT));
	} else {
		root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));
	}

	TabHolder *tabHolder;
	if (vertical) {
		tabHolder = new TabHolder(ORIENT_HORIZONTAL, 200, new LinearLayoutParams(1.0f));
		root_->Add(tabHolder);
		root_->Add(new Choice(d->T("Back"), "", false, new LinearLayoutParams(0.0f)))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
	} else {
		tabHolder = new TabHolder(ORIENT_VERTICAL, 200, new AnchorLayoutParams(10, 0, 10, 0, false));
		root_->Add(tabHolder);
		root_->Add(new Choice(d->T("Back"), "", false, new AnchorLayoutParams(150, 64, 10, NONE, NONE, 10)))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
	}
	root_->SetDefaultFocusView(tabHolder);

	// TODO: These currently point to global settings, not game specific ones.

	// Graphics
	ViewGroup *graphicsSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
	LinearLayout *graphicsSettings = new LinearLayout(ORIENT_VERTICAL);
	graphicsSettings->SetSpacing(0);
	graphicsSettingsScroll->Add(graphicsSettings);
	tabHolder->AddTab(ms->T("Graphics"), graphicsSettingsScroll);

	graphicsSettings->Add(new ItemHeader(gs->T("Rendering Mode")));
	static const char *renderingMode[] = { "Non-Buffered Rendering", "Buffered Rendering", "Read Framebuffers To Memory (CPU)", "Read Framebuffers To Memory (GPU)"};
	PopupMultiChoice *renderingModeChoice = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iRenderingMode, gs->T("Mode"), renderingMode, 0, ARRAY_SIZE(renderingMode), gs, screenManager()));
	renderingModeChoice->OnChoice.Handle(this, &GameSettingsScreen::OnRenderingMode);
	renderingModeChoice->SetDisabledPtr(&g_Config.bSoftwareRendering);

	CheckBox *blockTransfer = graphicsSettings->Add(new CheckBox(&g_Config.bBlockTransferGPU, gs->T("Simulate Block Transfer", "Simulate Block Transfer (unfinished)")));
	blockTransfer->SetDisabledPtr(&g_Config.bSoftwareRendering);

	graphicsSettings->Add(new ItemHeader(gs->T("Frame Rate Control")));
	static const char *frameSkip[] = {"Off", "1", "2", "3", "4", "5", "6", "7", "8"};
	graphicsSettings->Add(new PopupMultiChoice(&g_Config.iFrameSkip, gs->T("Frame Skipping"), frameSkip, 0, ARRAY_SIZE(frameSkip), gs, screenManager()));
	frameSkipAuto_ = graphicsSettings->Add(new CheckBox(&g_Config.bAutoFrameSkip, gs->T("Auto FrameSkip")));
	frameSkipAuto_->OnClick.Handle(this, &GameSettingsScreen::OnAutoFrameskip);
	graphicsSettings->Add(new CheckBox(&cap60FPS_, gs->T("Force max 60 FPS (helps GoW)")));

	graphicsSettings->Add(new PopupSliderChoice(&iAlternateSpeedPercent_, 0, 600, gs->T("Alternative Speed", "Alternative Speed (in %, 0 = unlimited)"), 5, screenManager()));

	graphicsSettings->Add(new ItemHeader(gs->T("Features")));
	I18NCategory *ps = GetI18NCategory("PostShaders");
	postProcChoice_ = graphicsSettings->Add(new ChoiceWithValueDisplay(&g_Config.sPostShaderName, gs->T("Postprocessing Shader"), ps));
	postProcChoice_->OnClick.Handle(this, &GameSettingsScreen::OnPostProcShader);
	postProcEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
	postProcChoice_->SetEnabledPtr(&postProcEnable_);

#if !defined(MOBILE_DEVICE)
	graphicsSettings->Add(new CheckBox(&g_Config.bFullScreen, gs->T("FullScreen")))->OnClick.Handle(this, &GameSettingsScreen::OnFullscreenChange);
#endif
	graphicsSettings->Add(new CheckBox(&g_Config.bStretchToDisplay, gs->T("Stretch to Display")));
	// Small Display: To avoid overlapping touch controls on large tablets. Better control over this will be coming later.
	graphicsSettings->Add(new CheckBox(&g_Config.bSmallDisplay, gs->T("Small Display")));
	if (pixel_xres < pixel_yres * 1.3) // Smaller than 4:3
		graphicsSettings->Add(new CheckBox(&g_Config.bPartialStretch, gs->T("Partial Vertical Stretch")));

#ifdef ANDROID
	// Hide Immersive Mode on pre-kitkat Android
	if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= 19) {
		graphicsSettings->Add(new CheckBox(&g_Config.bImmersiveMode, gs->T("Immersive Mode")))->OnClick.Handle(this, &GameSettingsScreen::OnImmersiveModeChange);
	}
#endif

	graphicsSettings->Add(new ItemHeader(gs->T("Performance")));
#ifndef MOBILE_DEVICE
	static const char *internalResolutions[] = {"Auto (1:1)", "1x PSP", "2x PSP", "3x PSP", "4x PSP", "5x PSP", "6x PSP", "7x PSP", "8x PSP", "9x PSP", "10x PSP" };
#else
	static const char *internalResolutions[] = {"Auto (1:1)", "1x PSP", "2x PSP", "3x PSP", "4x PSP", "5x PSP" };
#endif
	resolutionChoice_ = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iInternalResolution, gs->T("Rendering Resolution"), internalResolutions, 0, ARRAY_SIZE(internalResolutions), gs, screenManager()));
	resolutionChoice_->OnChoice.Handle(this, &GameSettingsScreen::OnResolutionChange);
	resolutionEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
	resolutionChoice_->SetEnabledPtr(&resolutionEnable_);

#ifdef ANDROID
	static const char *deviceResolutions[] = { "Native device resolution", "Auto (same as Rendering)", "1x PSP", "2x PSP", "3x PSP", "4x PSP", "5x PSP" };
	UI::PopupMultiChoice *hwscale = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iAndroidHwScale, gs->T("Display Resolution (HW scaler)"), deviceResolutions, 0, ARRAY_SIZE(deviceResolutions), gs, screenManager()));
	hwscale->OnChoice.Handle(this, &GameSettingsScreen::OnHwScaleChange);  // To refresh the display mode
#endif

#ifdef _WIN32
	graphicsSettings->Add(new CheckBox(&g_Config.bVSync, gs->T("VSync")));
#endif
	CheckBox *mipmapping = graphicsSettings->Add(new CheckBox(&g_Config.bMipMap, gs->T("Mipmapping")));
	mipmapping->SetDisabledPtr(&g_Config.bSoftwareRendering);

	CheckBox *hwTransform = graphicsSettings->Add(new CheckBox(&g_Config.bHardwareTransform, gs->T("Hardware Transform")));
	hwTransform->OnClick.Handle(this, &GameSettingsScreen::OnHardwareTransform);
	hwTransform->SetDisabledPtr(&g_Config.bSoftwareRendering);

	CheckBox *swSkin = graphicsSettings->Add(new CheckBox(&g_Config.bSoftwareSkinning, gs->T("Software Skinning")));
	swSkin->SetDisabledPtr(&g_Config.bSoftwareRendering);

	CheckBox *vtxCache = graphicsSettings->Add(new CheckBox(&g_Config.bVertexCache, gs->T("Vertex Cache")));
	vtxCacheEnable_ = !g_Config.bSoftwareRendering && g_Config.bHardwareTransform;
	vtxCache->SetEnabledPtr(&vtxCacheEnable_);

	CheckBox *texBackoff = graphicsSettings->Add(new CheckBox(&g_Config.bTextureBackoffCache, gs->T("Lazy texture caching", "Lazy texture caching (speedup)")));
	texBackoff->SetDisabledPtr(&g_Config.bSoftwareRendering);

	CheckBox *texSecondary_ = graphicsSettings->Add(new CheckBox(&g_Config.bTextureSecondaryCache, gs->T("Retain changed textures", "Retain changed textures (speedup, mem hog)")));
	texSecondary_->SetDisabledPtr(&g_Config.bSoftwareRendering);

	CheckBox *framebufferSlowEffects = graphicsSettings->Add(new CheckBox(&g_Config.bDisableSlowFramebufEffects, gs->T("Disable slower effects (speedup)")));
	framebufferSlowEffects->SetDisabledPtr(&g_Config.bSoftwareRendering);

	// Seems solid, so we hide the setting.
	// CheckBox *vtxJit = graphicsSettings->Add(new CheckBox(&g_Config.bVertexDecoderJit, gs->T("Vertex Decoder JIT")));

	// if (PSP_IsInited()) {
		// vtxJit->SetEnabled(false);
	// }

	static const char *quality[] = { "Low", "Medium", "High"};
	PopupMultiChoice *beziersChoice = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iSplineBezierQuality, gs->T("LowCurves", "Spline/Bezier curves quality"), quality, 0, ARRAY_SIZE(quality), gs, screenManager()));
	beziersChoice->SetDisabledPtr(&g_Config.bSoftwareRendering);
	
	// In case we're going to add few other antialiasing option like MSAA in the future.
	// graphicsSettings->Add(new CheckBox(&g_Config.bFXAA, gs->T("FXAA")));
	graphicsSettings->Add(new ItemHeader(gs->T("Texture Scaling")));
#ifndef MOBILE_DEVICE
	static const char *texScaleLevelsNPOT[] = {"Auto", "Off", "2x", "3x", "4x", "5x"};
	static const char *texScaleLevelsPOT[] = {"Auto", "Off", "2x", "4x"};
#else
	static const char *texScaleLevelsNPOT[] = {"Auto", "Off", "2x", "3x"};
	static const char *texScaleLevelsPOT[] = {"Auto", "Off", "2x"};
#endif

	static const char **texScaleLevels;
	static int numTexScaleLevels;
	if (gl_extensions.OES_texture_npot) {
		texScaleLevels = texScaleLevelsNPOT;
		numTexScaleLevels = ARRAY_SIZE(texScaleLevelsNPOT);
	} else {
		texScaleLevels = texScaleLevelsPOT;
		numTexScaleLevels = ARRAY_SIZE(texScaleLevelsPOT);
	}
	PopupMultiChoice *texScalingChoice = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iTexScalingLevel, gs->T("Upscale Level"), texScaleLevels, 0, numTexScaleLevels, gs, screenManager()));
	texScalingChoice->SetDisabledPtr(&g_Config.bSoftwareRendering);

	static const char *texScaleAlgos[] = { "xBRZ", "Hybrid", "Bicubic", "Hybrid + Bicubic", };
	PopupMultiChoice *texScalingType = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iTexScalingType, gs->T("Upscale Type"), texScaleAlgos, 0, ARRAY_SIZE(texScaleAlgos), gs, screenManager()));
	texScalingType->SetDisabledPtr(&g_Config.bSoftwareRendering);

	CheckBox *deposterize = graphicsSettings->Add(new CheckBox(&g_Config.bTexDeposterize, gs->T("Deposterize")));
	deposterize->SetDisabledPtr(&g_Config.bSoftwareRendering);

	graphicsSettings->Add(new ItemHeader(gs->T("Texture Filtering")));
	static const char *anisoLevels[] = { "Off", "2x", "4x", "8x", "16x" };
	PopupMultiChoice *anisoFiltering = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iAnisotropyLevel, gs->T("Anisotropic Filtering"), anisoLevels, 0, ARRAY_SIZE(anisoLevels), gs, screenManager()));
	anisoFiltering->SetDisabledPtr(&g_Config.bSoftwareRendering);

	static const char *texFilters[] = { "Auto", "Nearest", "Linear", "Linear on FMV", };
	PopupMultiChoice *texFilter = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iTexFiltering, gs->T("Texture Filter"), texFilters, 1, ARRAY_SIZE(texFilters), gs, screenManager()));
	texFilter->SetDisabledPtr(&g_Config.bSoftwareRendering);

	static const char *bufFilters[] = { "Linear", "Nearest", };
	PopupMultiChoice *bufFilter = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iBufFilter, gs->T("Screen Scaling Filter"), bufFilters, 1, ARRAY_SIZE(bufFilters), gs, screenManager()));
	bufFilter->SetDisabledPtr(&g_Config.bSoftwareRendering);

	graphicsSettings->Add(new ItemHeader(gs->T("Hack Settings", "Hack Settings (these WILL cause glitches)")));
	graphicsSettings->Add(new CheckBox(&g_Config.bTimerHack, gs->T("Timer Hack")));
	CheckBox *alphaHack = graphicsSettings->Add(new CheckBox(&g_Config.bDisableAlphaTest, gs->T("Disable Alpha Test (PowerVR speedup)")));
	alphaHack->OnClick.Handle(this, &GameSettingsScreen::OnShaderChange);
	alphaHack->SetDisabledPtr(&g_Config.bSoftwareRendering);

	CheckBox *stencilTest = graphicsSettings->Add(new CheckBox(&g_Config.bDisableStencilTest, gs->T("Disable Stencil Test")));
	stencilTest->SetDisabledPtr(&g_Config.bSoftwareRendering);

	CheckBox *depthWrite = graphicsSettings->Add(new CheckBox(&g_Config.bAlwaysDepthWrite, gs->T("Always Depth Write")));
	depthWrite->SetDisabledPtr(&g_Config.bSoftwareRendering);

	CheckBox *prescale = graphicsSettings->Add(new CheckBox(&g_Config.bPrescaleUV, gs->T("Texture Coord Speedhack")));
	prescale->SetDisabledPtr(&g_Config.bSoftwareRendering);

	graphicsSettings->Add(new ItemHeader(gs->T("Overlay Information")));
	static const char *fpsChoices[] = {
		"None", "Speed", "FPS", "Both"
#ifdef BLACKBERRY
     , "Statistics"
#endif
	};
	graphicsSettings->Add(new PopupMultiChoice(&g_Config.iShowFPSCounter, gs->T("Show FPS Counter"), fpsChoices, 0, ARRAY_SIZE(fpsChoices), gs, screenManager()));
	graphicsSettings->Add(new CheckBox(&g_Config.bShowDebugStats, gs->T("Show Debug Statistics")))->OnClick.Handle(this, &GameSettingsScreen::OnJitAffectingSetting);

	// Developer tools are not accessible ingame, so it goes here.
	graphicsSettings->Add(new ItemHeader(gs->T("Debugging")));
	Choice *dump = graphicsSettings->Add(new Choice(gs->T("Dump next frame to log")));
	dump->OnClick.Handle(this, &GameSettingsScreen::OnDumpNextFrameToLog);
	if (!PSP_IsInited())
		dump->SetEnabled(false);

	// We normally use software rendering to debug so put it in debugging.
	CheckBox *softwareGPU = graphicsSettings->Add(new CheckBox(&g_Config.bSoftwareRendering, gs->T("Software Rendering", "Software Rendering (experimental)")));
	softwareGPU->OnClick.Handle(this, &GameSettingsScreen::OnSoftwareRendering);
	if (PSP_IsInited())
		softwareGPU->SetEnabled(false);

	// Audio
	ViewGroup *audioSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
	LinearLayout *audioSettings = new LinearLayout(ORIENT_VERTICAL);
	audioSettings->SetSpacing(0);
	audioSettingsScroll->Add(audioSettings);
	tabHolder->AddTab(ms->T("Audio"), audioSettingsScroll);

	audioSettings->Add(new ItemHeader(ms->T("Audio")));

	audioSettings->Add(new CheckBox(&g_Config.bEnableSound, a->T("Enable Sound")));
	static const char *latency[] = { "Low", "Medium", "High" };
	PopupMultiChoice *lowAudio = audioSettings->Add(new PopupMultiChoice(&g_Config.iAudioLatency, a->T("Audio Latency"), latency, 0, ARRAY_SIZE(latency), gs, screenManager()));
	lowAudio->SetEnabledPtr(&g_Config.bEnableSound);

	audioSettings->Add(new ItemHeader(a->T("Audio hacks")));
	audioSettings->Add(new CheckBox(&g_Config.bSoundSpeedHack, a->T("Sound speed hack (DOA etc.)")));

	// Control
	ViewGroup *controlsSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
	LinearLayout *controlsSettings = new LinearLayout(ORIENT_VERTICAL);
	controlsSettings->SetSpacing(0);
	controlsSettingsScroll->Add(controlsSettings);
	tabHolder->AddTab(ms->T("Controls"), controlsSettingsScroll);
	controlsSettings->Add(new ItemHeader(ms->T("Controls")));
	controlsSettings->Add(new Choice(c->T("Control Mapping")))->OnClick.Handle(this, &GameSettingsScreen::OnControlMapping);

#if defined(MOBILE_DEVICE)
	controlsSettings->Add(new CheckBox(&g_Config.bHapticFeedback, c->T("HapticFeedback", "Haptic Feedback (vibration)")));
	static const char *tiltTypes[] = { "None (Disabled)", "Analog Stick", "D-PAD", "PSP Action Buttons"};
	controlsSettings->Add(new PopupMultiChoice(&g_Config.iTiltInputType, c->T("Tilt Input Type"), tiltTypes, 0, ARRAY_SIZE(tiltTypes), c, screenManager()))->OnClick.Handle(this, &GameSettingsScreen::OnTiltTypeChange);

	Choice *customizeTilt = controlsSettings->Add(new Choice(c->T("Customize tilt")));
	customizeTilt->OnClick.Handle(this, &GameSettingsScreen::OnTiltCuztomize);
	customizeTilt->SetEnabledPtr((bool *)&g_Config.iTiltInputType); //<- dirty int-to-bool cast
#endif
	controlsSettings->Add(new ItemHeader(c->T("OnScreen", "On-Screen Touch Controls")));
	controlsSettings->Add(new CheckBox(&g_Config.bShowTouchControls, c->T("OnScreen", "On-Screen Touch Controls")));
	layoutEditorChoice_ = controlsSettings->Add(new Choice(c->T("Custom layout...")));
	layoutEditorChoice_->OnClick.Handle(this, &GameSettingsScreen::OnTouchControlLayout);
	layoutEditorChoice_->SetEnabledPtr(&g_Config.bShowTouchControls);

	// On systems that aren't Symbian, iOS, and Maemo, offer to let the user see this button.
	// Some Windows touch devices don't have a back button or other button to call up the menu.
#if !defined(__SYMBIAN32__) && !defined(IOS) && !defined(MAEMO)
	CheckBox *enablePauseBtn = controlsSettings->Add(new CheckBox(&g_Config.bShowTouchPause, c->T("Show Touch Pause Menu Button")));

	// Don't allow the user to disable it once in-game, so they can't lock themselves out of the menu.
	if (!PSP_IsInited()) {
		enablePauseBtn->SetEnabledPtr(&g_Config.bShowTouchControls);
	} else {
		enablePauseBtn->SetEnabled(false);
	}
#endif

	CheckBox *disableDiags = controlsSettings->Add(new CheckBox(&g_Config.bDisableDpadDiagonals, c->T("Disable D-Pad diagonals (4-way touch)")));
	disableDiags->SetEnabledPtr(&g_Config.bShowTouchControls);
	View *opacity = controlsSettings->Add(new PopupSliderChoice(&g_Config.iTouchButtonOpacity, 0, 100, c->T("Button Opacity"), screenManager()));
	opacity->SetEnabledPtr(&g_Config.bShowTouchControls);
	static const char *touchControlStyles[] = {"Classic", "Thin borders"};
	View *style = controlsSettings->Add(new PopupMultiChoice(&g_Config.iTouchButtonStyle, c->T("Button style"), touchControlStyles, 0, ARRAY_SIZE(touchControlStyles), c, screenManager()));
	style->SetEnabledPtr(&g_Config.bShowTouchControls);

	controlsSettings->Add(new ItemHeader(c->T("Keyboard", "Keyboard Control Settings")));
#if defined(USING_WIN_UI)
	controlsSettings->Add(new CheckBox(&g_Config.bIgnoreWindowsKey, c->T("Ignore Windows Key")));
#endif // #if defined(USING_WIN_UI)
	controlsSettings->Add(new PopupSliderChoiceFloat(&g_Config.fAnalogLimiterDeadzone, 0.0f, 1.0f, c->T("Analog Limiter"), 0.10f, screenManager()));

	// System
	ViewGroup *systemSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
	LinearLayout *systemSettings = new LinearLayout(ORIENT_VERTICAL);
	systemSettings->SetSpacing(0);
	systemSettingsScroll->Add(systemSettings);
	tabHolder->AddTab(ms->T("System"), systemSettingsScroll);

	systemSettings->Add(new ItemHeader(s->T("UI Language")));
	systemSettings->Add(new Choice(dev->T("Language", "Language")))->OnClick.Handle(this, &GameSettingsScreen::OnLanguage);

	systemSettings->Add(new ItemHeader(s->T("Emulation")));
	systemSettings->Add(new CheckBox(&g_Config.bFastMemory, s->T("Fast Memory", "Fast Memory (Unstable)")))->OnClick.Handle(this, &GameSettingsScreen::OnJitAffectingSetting);

	systemSettings->Add(new CheckBox(&g_Config.bSeparateCPUThread, s->T("Multithreaded (experimental)")))->SetEnabled(!PSP_IsInited());
	systemSettings->Add(new CheckBox(&g_Config.bSeparateIOThread, s->T("I/O on thread (experimental)")))->SetEnabled(!PSP_IsInited());
	systemSettings->Add(new CheckBox(&g_Config.bForceLagSync, s->T("Force real clock sync (slower, less lag)")));
	systemSettings->Add(new PopupSliderChoice(&g_Config.iLockedCPUSpeed, 0, 1000, s->T("Change CPU Clock", "Change CPU Clock (0 = default) (unstable)"), screenManager()));
#ifndef MOBILE_DEVICE
	systemSettings->Add(new PopupSliderChoice(&g_Config.iRewindFlipFrequency, 0, 1800, s->T("Rewind Snapshot Frequency", "Rewind Snapshot Frequency (0 = off, mem hog)"), screenManager()));
#endif
	systemSettings->Add(new CheckBox(&g_Config.bSetRoundingMode, s->T("Respect FPU rounding (disable for old GEB saves)")))->OnClick.Handle(this, &GameSettingsScreen::OnJitAffectingSetting);

	systemSettings->Add(new CheckBox(&g_Config.bAtomicAudioLocks, s->T("Atomic Audio locks (experimental)")))->SetEnabled(!PSP_IsInited());
#if defined(USING_WIN_UI)
	systemSettings->Add(new CheckBox(&g_Config.bBypassOSKWithKeyboard, s->T("Enable Windows native keyboard", "Enable Windows native keyboard")));
#endif

	systemSettings->Add(new ItemHeader(s->T("Developer Tools")));
	systemSettings->Add(new Choice(s->T("Developer Tools")))->OnClick.Handle(this, &GameSettingsScreen::OnDeveloperTools);

	systemSettings->Add(new ItemHeader(s->T("General")));

#ifdef ANDROID
	static const char *screenRotation[] = {"Auto", "Landscape", "Portrait", "Landscape Reversed", "Portrait Reversed"};
	PopupMultiChoice *rot = systemSettings->Add(new PopupMultiChoice(&g_Config.iScreenRotation, c->T("Screen Rotation"), screenRotation, 0, ARRAY_SIZE(screenRotation), c, screenManager()));
	rot->OnChoice.Handle(this, &GameSettingsScreen::OnScreenRotation);
#endif

	systemSettings->Add(new CheckBox(&g_Config.bCheckForNewVersion, s->T("VersionCheck", "Check for new versions of PPSSPP")));
	if (g_Config.iMaxRecent > 0)
		systemSettings->Add(new Choice(s->T("Clear Recent Games List")))->OnClick.Handle(this, &GameSettingsScreen::OnClearRecents);
	systemSettings->Add(new Choice(s->T("Restore Default Settings")))->OnClick.Handle(this, &GameSettingsScreen::OnRestoreDefaultSettings);
	systemSettings->Add(new CheckBox(&g_Config.bEnableAutoLoad, s->T("Auto Load Newest Savestate")));

	enableReports_ = Reporting::IsEnabled();
	enableReportsCheckbox_ = new CheckBox(&enableReports_, s->T("Enable Compatibility Server Reports"));
	enableReportsCheckbox_->SetEnabled(Reporting::IsSupported());
	systemSettings->Add(enableReportsCheckbox_);

	systemSettings->Add(new ItemHeader(s->T("Networking")));
	systemSettings->Add(new CheckBox(&g_Config.bEnableWlan, s->T("Enable networking", "Enable networking/wlan (beta)")));

#ifdef _WIN32
	systemSettings->Add(new PopupTextInputChoice(&g_Config.proAdhocServer, s->T("Change proAdhocServer Address"), "", 255, screenManager()));
#else
	systemSettings->Add(new ChoiceWithValueDisplay(&g_Config.proAdhocServer, s->T("Change proAdhocServer Address"), nullptr))->OnClick.Handle(this, &GameSettingsScreen::OnChangeproAdhocServerAddress);
#endif

	systemSettings->Add(new ChoiceWithValueDisplay(&g_Config.sMACAddress, s->T("Change Mac Address"), nullptr))->OnClick.Handle(this, &GameSettingsScreen::OnChangeMacAddress);

//#ifndef ANDROID
	systemSettings->Add(new ItemHeader(s->T("Cheats", "Cheats (experimental, see forums)")));
	systemSettings->Add(new CheckBox(&g_Config.bEnableCheats, s->T("Enable Cheats")));
//#endif
	systemSettings->SetSpacing(0);

	systemSettings->Add(new ItemHeader(s->T("PSP Settings")));
	static const char *models[] = {"PSP-1000" , "PSP-2000/3000"};
	systemSettings->Add(new PopupMultiChoice(&g_Config.iPSPModel, s->T("PSP Model"), models, 0, ARRAY_SIZE(models), s, screenManager()));
	// TODO: Come up with a way to display a keyboard for mobile users,
	// so until then, this is Windows/Desktop only.
#if defined(_WIN32)  // TODO: Add all platforms where KEY_CHAR support is added
	systemSettings->Add(new PopupTextInputChoice(&g_Config.sNickName, s->T("Change Nickname"), "", 32, screenManager()));
#elif defined(USING_QT_UI)
	systemSettings->Add(new Choice(s->T("Change Nickname")))->OnClick.Handle(this, &GameSettingsScreen::OnChangeNickname);
#endif
#if defined(_WIN32) || (defined(USING_QT_UI) && !defined(MOBILE_DEVICE))
	// Screenshot functionality is not yet available on non-Windows/non-Qt
	systemSettings->Add(new CheckBox(&g_Config.bScreenshotsAsPNG, s->T("Screenshots as PNG")));
#endif
	systemSettings->Add(new CheckBox(&g_Config.bDayLightSavings, s->T("Day Light Saving")));
	static const char *dateFormat[] = { "YYYYMMDD", "MMDDYYYY", "DDMMYYYY"};
	systemSettings->Add(new PopupMultiChoice(&g_Config.iDateFormat, s->T("Date Format"), dateFormat, 1, 3, s, screenManager()));
	static const char *timeFormat[] = { "12HR", "24HR"};
	systemSettings->Add(new PopupMultiChoice(&g_Config.iTimeFormat, s->T("Time Format"), timeFormat, 1, 2, s, screenManager()));
	static const char *buttonPref[] = { "Use O to confirm", "Use X to confirm" };
	systemSettings->Add(new PopupMultiChoice(&g_Config.iButtonPreference, s->T("Confirmation Button"), buttonPref, 0, 2, s, screenManager()));
}
void TouchControlVisibilityScreen::CreateViews() {
	using namespace UI;

	root_ = new ScrollView(ORIENT_VERTICAL);
	LinearLayout *vert = root_->Add(new LinearLayout(ORIENT_VERTICAL, new LayoutParams(FILL_PARENT, FILL_PARENT)));
	vert->SetSpacing(0);

	LinearLayout *topBar = new LinearLayout(ORIENT_HORIZONTAL);
	I18NCategory *di = GetI18NCategory("Dialog");
	topBar->Add(new Choice(di->T("Back")))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
	topBar->Add(new Choice(di->T("Toggle All")))->OnClick.Handle(this, &TouchControlVisibilityScreen::OnToggleAll);

	vert->Add(topBar);
	I18NCategory *co = GetI18NCategory("Controls");
	vert->Add(new ItemHeader(co->T("Touch Control Visibility")));

	const int cellSize = 400;

	UI::GridLayoutSettings gridsettings(cellSize, 64, 5);
	gridsettings.fillCells = true;
	GridLayout *grid = vert->Add(new GridLayout(gridsettings, new LayoutParams(FILL_PARENT, WRAP_CONTENT)));

	std::map<std::string, int> keyImages;
	keyImages["Circle"] = I_CIRCLE;
	keyImages["Cross"] = I_CROSS;
	keyImages["Square"] = I_SQUARE;
	keyImages["Triangle"] = I_TRIANGLE;
	keyImages["Start"] = I_START;
	keyImages["Select"] = I_SELECT;
	keyImages["L"] = I_L;
	keyImages["R"] = I_R;
	keyImages["Combo0"] = I_1;
	keyImages["Combo1"] = I_2;
	keyImages["Combo2"] = I_3;
	keyImages["Combo3"] = I_4;
	keyImages["Combo4"] = I_5;

	keyToggles.clear();
	keyToggles["Circle"] = &g_Config.bShowTouchCircle;
	keyToggles["Cross"] = &g_Config.bShowTouchCross;
	keyToggles["Square"] = &g_Config.bShowTouchSquare;
	keyToggles["Triangle"] = &g_Config.bShowTouchTriangle;
	keyToggles["L"] = &g_Config.bShowTouchLTrigger;
	keyToggles["R"] = &g_Config.bShowTouchRTrigger;
	keyToggles["Start"] = &g_Config.bShowTouchStart;
	keyToggles["Select"] = &g_Config.bShowTouchSelect;
	keyToggles["Dpad"] = &g_Config.bShowTouchDpad;
	keyToggles["Analog Stick"] = &g_Config.bShowTouchAnalogStick;
	keyToggles["Unthrottle"] = &g_Config.bShowTouchUnthrottle;
	keyToggles["Combo0"] = &g_Config.bShowComboKey0;
	keyToggles["Combo1"] = &g_Config.bShowComboKey1;
	keyToggles["Combo2"] = &g_Config.bShowComboKey2;
	keyToggles["Combo3"] = &g_Config.bShowComboKey3;
	keyToggles["Combo4"] = &g_Config.bShowComboKey4;

	std::map<std::string, int>::iterator imageFinder;

	I18NCategory *mc = GetI18NCategory("MappableControls");

	for (auto i = keyToggles.begin(); i != keyToggles.end(); ++i) {
		LinearLayout *row = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
		row->SetSpacing(0);

		CheckBox *checkbox = new CheckBox(i->second, "", "", new LinearLayoutParams(50, WRAP_CONTENT));
		row->Add(checkbox);

		imageFinder = keyImages.find(i->first);
		Choice *choice;

		if (imageFinder != keyImages.end()) {
			choice = new Choice(keyImages[imageFinder->first], new LinearLayoutParams(1.0f));	
		} else {
			choice = new Choice(mc->T(i->first.c_str()), new LinearLayoutParams(1.0f));
		}

		ChoiceEventHandler *choiceEventHandler = new ChoiceEventHandler(checkbox);
		choice->OnClick.Handle(choiceEventHandler, &ChoiceEventHandler::onChoiceClick);

		choice->SetCentered(true);
		
		row->Add(choice);
		grid->Add(row);
	}
}
void GameSettingsScreen::CreateViews() {
	GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true);

	cap60FPS_ = g_Config.iForceMaxEmulatedFPS == 60;
	
	iAlternateSpeedPercent_ = 3;
	for (int i = 0; i < 8; i++) {
		if (g_Config.iFpsLimit <= alternateSpeedTable[i]) {
			iAlternateSpeedPercent_ = i;
			break;
		}
	}

	// Information in the top left.
	// Back button to the bottom left.
	// Scrolling action menu to the right.
	using namespace UI;

	I18NCategory *d = GetI18NCategory("Dialog");
	I18NCategory *gs = GetI18NCategory("Graphics");
	I18NCategory *c = GetI18NCategory("Controls");
	I18NCategory *a = GetI18NCategory("Audio");
	I18NCategory *s = GetI18NCategory("System");
	I18NCategory *ms = GetI18NCategory("MainSettings");
	I18NCategory *dev = GetI18NCategory("Developer");

	root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));

	ViewGroup *leftColumn = new AnchorLayout(new LinearLayoutParams(1.0f));
	root_->Add(leftColumn);

	root_->Add(new Choice(d->T("Back"), "", false, new AnchorLayoutParams(150, WRAP_CONTENT, 10, NONE, NONE, 10)))->OnClick.Handle(this, &GameSettingsScreen::OnBack);

	TabHolder *tabHolder = new TabHolder(ORIENT_VERTICAL, 200, new AnchorLayoutParams(10, 0, 10, 0, false));

	root_->Add(tabHolder);

	// TODO: These currently point to global settings, not game specific ones.

	// Graphics
	ViewGroup *graphicsSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
	LinearLayout *graphicsSettings = new LinearLayout(ORIENT_VERTICAL);
	graphicsSettings->SetSpacing(0);
	graphicsSettingsScroll->Add(graphicsSettings);
	tabHolder->AddTab(ms->T("Graphics"), graphicsSettingsScroll);

	graphicsSettings->Add(new ItemHeader(gs->T("Rendering Mode")));
	static const char *renderingMode[] = { "Non-Buffered Rendering", "Buffered Rendering", "Read Framebuffers To Memory (CPU)", "Read Framebuffers To Memory (GPU)"};
	graphicsSettings->Add(new PopupMultiChoice(&g_Config.iRenderingMode, gs->T("Mode"), renderingMode, 0, ARRAY_SIZE(renderingMode), gs, screenManager()))->OnChoice.Handle(this, &GameSettingsScreen::OnRenderingMode);

	graphicsSettings->Add(new ItemHeader(gs->T("Frame Rate Control")));
	static const char *frameSkip[] = {"Off", "Auto", "1", "2", "3", "4", "5", "6", "7", "8"};
	graphicsSettings->Add(new PopupMultiChoice(&g_Config.iFrameSkip, gs->T("Frame Skipping"), frameSkip, 0, ARRAY_SIZE(frameSkip), gs, screenManager()));
	static const char *fpsChoices[] = {"None", "Speed", "FPS", "Both"};

	graphicsSettings->Add(new CheckBox(&cap60FPS_, gs->T("Force max 60 FPS (helps GoW)")));
	static const char *customSpeed[] = {"Unlimited", "25%", "50%", "75%", "100%", "125%", "150%", "200%", "300%"};
	graphicsSettings->Add(new PopupMultiChoice(&iAlternateSpeedPercent_, gs->T("Alternative Speed"), customSpeed, 0, ARRAY_SIZE(customSpeed), gs, screenManager()));
	
	graphicsSettings->Add(new ItemHeader(gs->T("Features")));
	graphicsSettings->Add(new CheckBox(&g_Config.bHardwareTransform, gs->T("Hardware Transform")));
	graphicsSettings->Add(new CheckBox(&g_Config.bVertexCache, gs->T("Vertex Cache")));
	graphicsSettings->Add(new CheckBox(&g_Config.bLowQualitySplineBezier, gs->T("Low quality spline/bezier curves (speed)")));
	
	static const char *internalResolutions[] = {"Auto (1:1)", "1x PSP", "2x PSP", "3x PSP", "4x PSP", "5x PSP" };
	graphicsSettings->Add(new PopupMultiChoice(&g_Config.iInternalResolution, gs->T("Rendering Resolution"), internalResolutions, 0, ARRAY_SIZE(internalResolutions), gs, screenManager()))->OnClick.Handle(this, &GameSettingsScreen::OnResolutionChange);
	graphicsSettings->Add(new CheckBox(&g_Config.bStretchToDisplay, gs->T("Stretch to Display")));
#ifdef BLACKBERRY
	if (pixel_xres == pixel_yres)
		graphicsSettings->Add(new CheckBox(&g_Config.bPartialStretch, gs->T("Partial Vertical Stretch")));
#endif
	graphicsSettings->Add(new CheckBox(&g_Config.bMipMap, gs->T("Mipmapping")));
	// This setting is not really useful for anyone atm.
	// graphicsSettings->Add(new CheckBox(&g_Config.bTrueColor, gs->T("True Color")));
#ifdef _WIN32
	graphicsSettings->Add(new CheckBox(&g_Config.bVSync, gs->T("VSync")));
	graphicsSettings->Add(new CheckBox(&g_Config.bFullScreen, gs->T("FullScreen")));
#endif

	graphicsSettings->Add(new ItemHeader(gs->T("Overlay Information")));
	graphicsSettings->Add(new PopupMultiChoice(&g_Config.iShowFPSCounter, gs->T("Show FPS Counter"), fpsChoices, 0, ARRAY_SIZE(fpsChoices), gs, screenManager()));
	graphicsSettings->Add(new CheckBox(&g_Config.bShowDebugStats, gs->T("Show Debug Statistics")));
	
	graphicsSettings->Add(new ItemHeader(gs->T("Texture Scaling")));
#ifndef USING_GLES2
	static const char *texScaleLevels[] = {"Off", "2x", "3x","4x", "5x"};
#else
	static const char *texScaleLevels[] = {"Off", "2x", "3x"};
#endif
	graphicsSettings->Add(new PopupMultiChoice(&g_Config.iTexScalingLevel, gs->T("Upscale Level"), texScaleLevels, 1, ARRAY_SIZE(texScaleLevels), gs, screenManager()));
	static const char *texScaleAlgos[] = { "xBRZ", "Hybrid", "Bicubic", "Hybrid + Bicubic", };
	graphicsSettings->Add(new PopupMultiChoice(&g_Config.iTexScalingType, gs->T("Upscale Type"), texScaleAlgos, 0, ARRAY_SIZE(texScaleAlgos), gs, screenManager()));
	graphicsSettings->Add(new CheckBox(&g_Config.bTexDeposterize, gs->T("Deposterize")));
	graphicsSettings->Add(new ItemHeader(gs->T("Texture Filtering")));
	static const char *anisoLevels[] = { "Off", "2x", "4x", "8x", "16x" };
	graphicsSettings->Add(new PopupMultiChoice(&g_Config.iAnisotropyLevel, gs->T("Anisotropic Filtering"), anisoLevels, 0, ARRAY_SIZE(anisoLevels), gs, screenManager()));
	static const char *texFilters[] = { "Auto", "Nearest", "Linear", "Linear on FMV", };
	graphicsSettings->Add(new PopupMultiChoice(&g_Config.iTexFiltering, gs->T("Texture Filter"), texFilters, 1, ARRAY_SIZE(texFilters), gs, screenManager()));

	graphicsSettings->Add(new ItemHeader(gs->T("Hack Settings")));
	graphicsSettings->Add(new CheckBox(&g_Config.bDisableStencilTest, gs->T("Disable Stencil Test")));
	graphicsSettings->Add(new CheckBox(&g_Config.bAlwaysDepthWrite, gs->T("Always Depth Write")));

	// Developer tools are not accessible ingame, so it goes here
	graphicsSettings->Add(new ItemHeader(gs->T("Debugging")));
	Choice *dump = graphicsSettings->Add(new Choice(gs->T("Dump next frame to log")));
	dump->OnClick.Handle(this, &GameSettingsScreen::OnDumpNextFrameToLog);
	if (!PSP_IsInited())
		dump->SetEnabled(false);

	// Audio
	ViewGroup *audioSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
	LinearLayout *audioSettings = new LinearLayout(ORIENT_VERTICAL);
	audioSettings->SetSpacing(0);
	audioSettingsScroll->Add(audioSettings);
	tabHolder->AddTab(ms->T("Audio"), audioSettingsScroll);

	std::string atracString;
	atracString.assign(Atrac3plus_Decoder::IsInstalled() ? "Redownload Atrac3+ plugin" : "Download Atrac3+ plugin");
	audioSettings->Add(new ItemHeader(ms->T("Audio")));
	audioSettings->Add(new Choice(a->T(atracString.c_str())))->OnClick.Handle(this, &GameSettingsScreen::OnDownloadPlugin);

	audioSettings->Add(new PopupSliderChoice(&g_Config.iSFXVolume, 0, 8, a->T("SFX volume"), screenManager()));
	audioSettings->Add(new PopupSliderChoice(&g_Config.iBGMVolume, 0, 8, a->T("BGM volume"), screenManager()));
	 
	audioSettings->Add(new CheckBox(&g_Config.bEnableSound, a->T("Enable Sound")));
	audioSettings->Add(new CheckBox(&g_Config.bEnableAtrac3plus, a->T("Enable Atrac3+")));
	audioSettings->Add(new CheckBox(&g_Config.bLowLatencyAudio, a->T("Low latency audio")));

	// Control
	ViewGroup *controlsSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
	LinearLayout *controlsSettings = new LinearLayout(ORIENT_VERTICAL);
	controlsSettings->SetSpacing(0);
	controlsSettingsScroll->Add(controlsSettings);
	tabHolder->AddTab(ms->T("Controls"), controlsSettingsScroll);
	controlsSettings->Add(new ItemHeader(ms->T("Controls")));
	controlsSettings->Add(new Choice(c->T("Control Mapping")))->OnClick.Handle(this, &GameSettingsScreen::OnControlMapping);
	controlsSettings->Add(new CheckBox(&g_Config.bAccelerometerToAnalogHoriz, c->T("Tilt", "Tilt to Analog (horizontal)")));
	controlsSettings->Add(new PopupSliderChoice(&g_Config.iTiltSensitivity, 10, 200, c->T("Tilt Sensitivity"), screenManager()));
	controlsSettings->Add(new ItemHeader(c->T("OnScreen", "On-Screen Touch Controls")));
	controlsSettings->Add(new CheckBox(&g_Config.bShowTouchControls, c->T("OnScreen", "On-Screen Touch Controls")));
	controlsSettings->Add(new PopupSliderChoice(&g_Config.iTouchButtonOpacity, 0, 100, c->T("Button Opacity"), screenManager()));
	controlsSettings->Add(new PopupSliderChoiceFloat(&g_Config.fButtonScale, 0.80, 2.0, c->T("Button Scaling"), screenManager()));
	controlsSettings->Add(new CheckBox(&g_Config.bShowAnalogStick, c->T("Show Left Analog Stick")));
	
	// System
	ViewGroup *systemSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
	LinearLayout *systemSettings = new LinearLayout(ORIENT_VERTICAL);
	systemSettings->SetSpacing(0);
	systemSettingsScroll->Add(systemSettings);
	tabHolder->AddTab(ms->T("System"), systemSettingsScroll);

	systemSettings->Add(new ItemHeader(s->T("Emulation")));
	systemSettings->Add(new CheckBox(&g_Config.bFastMemory, s->T("Fast Memory", "Fast Memory (Unstable)")));

#ifdef IOS
	if (isJailed) {
		systemSettings->Add(new TextView(s->T("DynarecisJailed", "Dynarec (JIT) - (Not jailbroken - JIT not available)")));
	} else {
		systemSettings->Add(new CheckBox(&g_Config.bJit, s->T("Dynarec", "Dynarec (JIT)")));
	}
#else
	systemSettings->Add(new CheckBox(&g_Config.bJit, s->T("Dynarec", "Dynarec (JIT)")));
#endif

#ifndef __SYMBIAN32__
	systemSettings->Add(new CheckBox(&g_Config.bSeparateCPUThread, s->T("Multithreaded (experimental)")))->SetEnabled(!PSP_IsInited());
	systemSettings->Add(new CheckBox(&g_Config.bSeparateIOThread, s->T("I/O on thread (experimental)")))->SetEnabled(!PSP_IsInited());
#endif
	systemSettings->Add(new PopupSliderChoice(&g_Config.iLockedCPUSpeed, 0, 1000, s->T("Change CPU Clock", "Change CPU Clock (0 = default)"), screenManager()));

	enableReports_ = Reporting::IsEnabled();
//#ifndef ANDROID 
	systemSettings->Add(new ItemHeader(s->T("Cheats", "Cheats (experimental, see forums)")));
	systemSettings->Add(new CheckBox(&g_Config.bEnableCheats, s->T("Enable Cheats")));
//#endif
	LinearLayout *list = root_->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(1.0f)));
	systemSettings->SetSpacing(0);
	systemSettings->Add(new ItemHeader(s->T("General")));
	systemSettings->Add(new Choice(dev->T("Language", "Language")))->OnClick.Handle(this, &GameSettingsScreen::OnLanguage);
	systemSettings->Add(new Choice(s->T("Developer Tools")))->OnClick.Handle(this, &GameSettingsScreen::OnDeveloperTools);
#ifdef _WIN32
	// Screenshot functionality is not yet available on non-Windows
	systemSettings->Add(new CheckBox(&g_Config.bScreenshotsAsPNG, s->T("Screenshots as PNG")));
#endif

	// TODO: Come up with a way to display a keyboard for mobile users,
	// so until then, this is Windows/Desktop only.
#ifdef _WIN32
	systemSettings->Add(new Choice(s->T("Change Nickname")))->OnClick.Handle(this, &GameSettingsScreen::OnChangeNickname);
#endif
	systemSettings->Add(new Choice(s->T("Clear Recent Games List")))->OnClick.Handle(this, &GameSettingsScreen::OnClearRecents);
	enableReportsCheckbox_ = new CheckBox(&enableReports_, s->T("Enable Compatibility Server Reports"));
	enableReportsCheckbox_->SetEnabled(Reporting::IsSupported());
	systemSettings->Add(enableReportsCheckbox_);


	systemSettings->Add(new ItemHeader(s->T("PSP Settings")));
	systemSettings->Add(new CheckBox(&g_Config.bDayLightSavings, s->T("Day Light Saving")));
	static const char *dateFormat[] = { "YYYYMMDD", "MMDDYYYY", "DDMMYYYY"};
	systemSettings->Add(new PopupMultiChoice(&g_Config.iDateFormat, s->T("Date Format"), dateFormat, 1, 3, s, screenManager()));
	static const char *timeFormat[] = { "12HR", "24HR"};
	systemSettings->Add(new PopupMultiChoice(&g_Config.iTimeFormat, s->T("Time Format"), timeFormat, 1, 2, s, screenManager()));
	static const char *buttonPref[] = { "Use O to confirm", "Use X to confirm" };
	systemSettings->Add(new PopupMultiChoice(&g_Config.iButtonPreference, s->T("Confirmation Button"), buttonPref, 0, 2, s, screenManager()));
}
/** Choose which Card to play, using different algorithms.
 *
 * This function chooses which card to play, using different
 * levels of complexity.
 * The main concepts are of the algorithms are:
 * - BASE:        play lowest card
 * - FINAL RUSH:  play highest card
 * - SAVE:        do not play
 *
 * Every option generated by an algorithms has a level, based on:
 * - value of the Card object
 * - count of the Card object
 * - level of the Card object
 * - Cards in the Deck
 * - algorithm relevance
 *
 * This method is declared as static so that it can be used
 * in every situation (e.g.: advice to user)
 *
 * @param state         state of current game
 * @param hand          player's Deck
 * @param brainLevel    player's cleverness
 *                      HUMAN: player is the user
 *                      ...
 *                      AI_MAX: player is AI with full capability
 * @return copy of the Card chosen, NULL if he decided not to play
 */
Card *Role::chooseCard(gameState_t *state,Deck *hand,int brainLevel)
{
    int algorithmLevel;
    Choice possibilities;
    Choice *cards;
    Card *chosen,*max1,*max2,*tmp;
    bool first=false;

    if(state->winning==NULL)
        first=true;

    if(state==NULL)
    {
        cerr <<"Error: argument \"state\" can't be NULL\n";
        return NULL;
    }

    if(!first && (state->winning->getValue()==2  ||  (state->winning->getValue()==1 && state->aces==0)) )
        return NULL;  //se non si può superare
    else{
        if(brainLevel==HUMAN)
        {
            cards=selectCard(state,hand,FOUR_CARDS);
            if(!cards) return NULL;
            chosen=cards->popCard();
            delete cards;
            while(chosen->isPlayable(state->winning)==false)
            {
                msg_rejectCard();
                msg_printState(state);
                cards=selectCard(state,hand,FOUR_CARDS);
                if(!cards) return NULL;
                chosen=cards->popCard();
                delete cards;
            }
            return chosen;
        }else{
            // in base al loro livello BRAIN, i giocatori hanno più o meno opzioni
            // fra le quali scegliere. Ogni opzione è data da un algoritmo, che
            // può essere più o meno vantaggioso in base alla situazione delle carte.

            //____________________________ALGORITMO:"Base"____________________________
            //gioco le carte di valore più basso possibile
            chosen=hand->getFirstPlayable(state->winning);

            if(chosen != NULL)
            {
                //...............calcolo del livello dell'opzione.............
                algorithmLevel = 10;   //livello di base dell'algoritmo

                switch(chosen->getCount() - (first? 1 : state->winning->getCount()))   //se aumento il numero (es. da coppia a tris)
                {
                    case 0: algorithmLevel += 5;    break;   //buona
                    case 1: algorithmLevel -= 2;    break;
                    case 2: algorithmLevel -= 5;    break;
                    case 3: algorithmLevel -= 10;   break;   //molto svantaggiosa
                }

                if(chosen == hand->getLast())   //se la carta è alta
                {
                    if(state->n < 4)  algorithmLevel -= 5;   //se sono alle prime giocate è svantaggioso
                    if(state->n < 2)  algorithmLevel -= 5;   //giocare subito una carta alta!
                }
                //............................................................

                possibilities.addOption(new Card(chosen),algorithmLevel);   //mi salvo l'opzione nella lista
            }else
                return NULL;   //non può giocare nulla, deve per forza passare
            //_________________________________________________________________________

            //____________________________ALGORITMO:"Base++"____________________________
            //gioco le carte di livello più basso possibile

            if(brainLevel > 1)
            {
                chosen=hand->getLowerPlayable(state->winning,state);   //parto dalla carta più bassa giocabile, trovata prima

                //...............calcolo del livello dell'opzione.............
                algorithmLevel = 16;   //livello di base dell'algoritmo

                switch(chosen->getCount() - (first? 1 : state->winning->getCount()))   //se aumento il numero (es. da coppia a tris)
                {
                    case 0: algorithmLevel += 5;  break;   //buona
                    case 1: algorithmLevel -= 2;  break;
                    case 2: algorithmLevel -= 5;  break;
                    case 3: algorithmLevel -= 10;  break;   //molto svantaggiosa
                }

                if(chosen == hand->getLast())   //se la carta è alta
                {
                    if(state->n < 4)  algorithmLevel -= 5;   //se sono alle prime giocate è svantaggioso
                    if(state->n < 2)  algorithmLevel -= 5;   //      giocare subito una carta alta!
                }
                //............................................................

                possibilities.addOption(new Card(chosen),algorithmLevel);   //mi salvo l'opzione nella lista
            }
            //_________________________________________________________________________

            //____________________________ALGORITMO:"Final Rush"____________________________
            //se ho una carta bassa, e una che prende sicuramente, gioco prima la seconda

            if(brainLevel > 1)
            {
                if(hand->getTotGroups()==2  &&  hand->getFirst()==hand->getFirstPlayable(state->winning))   //se ci sono carte di 2 valori
                {
                    chosen=hand->getLast();   //passo alla più alta

                    if(chosen->getValue()==2)   //se è un 2
                    {
                        if(!chosen->isPlayable(state->winning))
                            chosen=NULL;
                    }else{
                        //se è un asso            e    i 2 sono finiti
                        if(chosen->getValue()==1  &&  state->twos==0)
                            if(!chosen->isPlayable(state->winning))
                                chosen=NULL;
                    }

                    if(chosen!=NULL)   //se le condizioni sono soddisfatte
                    {
                        //...............calcolo del livello dell'opzione.............
                        algorithmLevel = 40;   //livello di base dell'algoritmo
                        //............................................................
                        possibilities.addOption(new Card(chosen),algorithmLevel);   //mi salvo l'opzione nella lista
                    }
                }
            }
            //_________________________________________________________________________

            //____________________________ALGORITMO:"Final Rush++"____________________________
            //se ho solo una carta di livello basso, gioco prima le alte

            if(brainLevel > 2)
            {
                if(hand->countCheapCards()<2)   //se c'è al massimo una carta bassa
                {
                    chosen=hand->getFirstPlayable(state->winning);
                    while(chosen)
                    {
                        if(chosen->getLevel() >= TWO_LEV)   //se la carta è alta
                        {
                            if(chosen->isPlayable(state->winning))   //se posso giocarla
                            {
                                //...............calcolo del livello dell'opzione.............
                                algorithmLevel = 30;   //livello di base dell'algoritmo
                                //............................................................
                                possibilities.addOption(new Card(chosen),algorithmLevel);   //mi salvo l'opzione nella lista
                                chosen=NULL;
                            }
                        }
                        if(chosen)
                            chosen=hand->getNext();
                    }
                }
            }
            //_________________________________________________________________________


            //____________________________ALGORITMO:"Save Last"____________________________
            //se posso giocare solo la mia carta più alta e ho ancora tante carte, passo

            if(brainLevel > 2)
            {
                if(hand->getFirstPlayable(state->winning) == hand->getLast())   //se posso giocare solo la mia carta più alta
                {
                    if(hand->countCheapCards()>3)   //se ho ancora tante carte
                    {
                        //...............calcolo del livello dell'opzione.............
                        algorithmLevel = 20 + hand->getTotGroups();   //più carte mi restano, più conviene passare
                        //............................................................
                        possibilities.addOption(NULL,algorithmLevel);   //mi salvo l'opzione nella lista
                    }
                }
            }
            //_________________________________________________________________________



            //____________________________ALGORITMO:"Save More"____________________________

            if(brainLevel > 2)
            {

                //__________________________Save Pre____________________________
                //se posso giocare solo la seconda carta più alta, passo

                hand->getFirstPlayable(state->winning);
                if(hand->getNext() == hand->getLast())   //se dovrei giocare la penultima carta più alta
                {
                    if(hand->countCheapCards()>4)   //se ho ancora tante carte
                    {
                        //...............calcolo del livello dell'opzione.............
                        algorithmLevel = 15 + hand->getTotGroups();   //più carte mi restano, più conviene passare
                        //............................................................
                        possibilities.addOption(NULL,algorithmLevel);   //mi salvo l'opzione nella lista
                    }
                }


                max1=hand->getFirst();
                max2=hand->getFirst();

                for(tmp=hand->getNext(); tmp!=NULL; tmp=hand->getNext())
                {
                    if(tmp->getLevel() >= max1->getLevel())   //se il livello è più alto del massimo
                    {
                        max2=max1;   //faccio scalare il secondo massimo
                        max1=tmp;
                    }else{
                        if(tmp->getLevel() >= max2->getLevel())   //se il livello è più alto del secondo massimo
                            max2=tmp;
                    }
                }

                //__________________________Save Last++____________________________
                //se posso giocare solo la carta di livello più alto, passo
                if(hand->getFirstPlayable(state->winning)==max1)   //se dovrei giocare la carta di livello più alto
                {
                    if(hand->countCheapCards()>3)   //se ho ancora tante carte
                    {
                        //...............calcolo del livello dell'opzione.............
                        algorithmLevel = 18 + hand->getTotGroups();   //più carte mi restano, più conviene passare
                        //............................................................
                        possibilities.addOption(NULL,algorithmLevel);   //mi salvo l'opzione nella lista
                    }
                }else{

                    //__________________________Save Pre++____________________________
                    //se posso giocare solo la seconda carta di livello più alto, passo
                    if(hand->getFirstPlayable(state->winning)==max2)   //se dovrei giocare la seconda carta di livello più alto
                    {
                        if(hand->countCheapCards()>4)   //se ho ancora tante carte
                        {
                            //...............calcolo del livello dell'opzione.............
                            algorithmLevel = 15 + hand->getTotGroups();   //più carte mi restano, più conviene passare
                            //............................................................
                            possibilities.addOption(NULL,algorithmLevel);   //mi salvo l'opzione nella lista
                        }
                    }
                }

                //__________________________Save Last3____________________________
                //se giocherei la carta più alta o di livello più alto, passo
                if(possibilities.getBest()==max1  ||  possibilities.getBest()==hand->getLast())   //se dovrei giocare la carta di livello più alto
                {
                    if(hand->countCheapCards()>2)   //se ho ancora carte
                    {
                        //...............calcolo del livello dell'opzione.............
                        algorithmLevel = 20 + hand->getTotGroups();   //livello più basso di final rush
                        //............................................................
                        possibilities.addOption(NULL,algorithmLevel);   //mi salvo l'opzione nella lista
                    }
                }





            }


            /*
            cout <<"\nQuesto è il mazzo:\n";
            hand->print(true);
            cout <<"\nQueste sono le possibilità:\n";
            possibilities.print(true);
            //*/

            chosen=possibilities.getBest();

            /*
            if(chosen)
                cout <<"\nQuesta è la carta scelta: " <<chosen->getShortName() <<endl;
            else
                cout <<"\nPassa\n";
            //*/

            possibilities.reset();
            if(chosen)
            {
                if(state->winning  &&  chosen->getCount()>state->winning->getCount()
                    && ((chosen->getValue()==2) || (chosen->getValue()==1 && state->twos==0)))
                {
                    Card *tmp=new Card(chosen);
                    chosen=tmp->divide(state->winning->getCount());
                    delete tmp;
                }
                return new Card(chosen);
            }
            else
                return NULL;
        }
    }
}
Exemple #22
0
void TocManager::activate(Choice c) {
  qDebug() << c.id();
  _coordinator.openItem("runcible-view-pdf", QUrl(c.id()));
}
Exemple #23
0
void Controller::deleteFrom(Key& key, const Choice& choice) {
    Actor* actor = choice.getActor();
    actor->del(key, choice.getProfile());
}
Exemple #24
0
string Controller::handleDist() {
    stringstream ss;
    const map<Key, choice_id>& mem = memory->dump();
    double tcost = 0;
    if (enableStat) Info() << "======== Cost Report ========" << endl;
    try {
        memory->lockIt();
        for (auto& it : mem) {
            string key = it.first.toString();
            choice_id choice_id = it.second;
            Choice& choice = choices.find(choice_id)->second;

            if (!(info.count(key) == 1)) {
                continue;
            }
            size_t size;
            Requirements requirements;
            {
                lock_guard<mutex> guard(infoLock);
                requirements = *info[key].requirements.get();
                size = info[key].size;
            }

            ss << key << " " << size << " " << choice.desc();

            if (enableStat) {
                double cost = 0;
                long get, put;
                stat->getInfo(key, get, put);

                Condition condition;
                condition.size = size;
                condition.durabilityRequired = requirements.durabilityRequired;
                condition.latencyRequired = requirements.latencyRequired;
                condition.bandwidthRequired = requirements.bandwidthRequired;
                condition.getRequests = get;
                condition.putRequests = put;
                condition.timeSpan = 86400 * 30;
                Choice *bestChoice = decider->choose(condition, &cost);
                if (bestChoice == nullptr) {
                    Err() << "can't find optimal place?" << endl;
                } else {
                    tcost += cost;
                }
                ss << " " << get << " " << put << " " << bestChoice->desc();
            }
            ss << endl;
        }
        if (enableStat) {
            for (const auto& it : getChoices()) {
                double myCost = 0;
                double realMyCost = 0;
                const Choice& myChoice = it.second;
                for (auto& it : mem) {
                    string key = it.first.toString();
                    choice_id choice_id = it.second;
                    Choice& choice = choices.find(choice_id)->second;

                    if (!(info.count(key) == 1)) {
                        continue;
                    }

                    size_t size;
                    {
                        lock_guard<mutex> guard(infoLock);
                        size = info[key].size;
                    }

                    long get, put;
                    stat->getInfo(key, get, put);

                    double cost = myChoice.calcCost(get, put, size);
                    myCost += cost;
                    if (choice_id == myChoice.getId()) realMyCost += cost;
                }
                Info() << myChoice.getName() << " SOLO: " << myCost / 1000 << " nano$"
                    << "  COST: " << realMyCost / 1000 << " nano$" << endl;
            }
        }
        memory->unlockIt();
        if (enableStat) {
            Info() << "Optimal total cost: " << tcost / 1000 << " nano$" << endl;
        }
    } catch (...) {
        Err() << "got exception in handleDist" << endl;
        memory->unlockIt();
    }
    return ss.str();
}
Exemple #25
0
bool operator<(Choice a, Choice b) {
    return a.title().compare(b.title(), Qt::CaseInsensitive) < 0;
}