예제 #1
0
bool AnyProfileExists()
{
	for(int i=0;i<MAX_SAVE_SLOTS;i++)
		if (ProfileExists(i)) return true;
	
	return false;
}
예제 #2
0
파일: Helpers.cpp 프로젝트: ds-hwang/d2bs
bool SwitchToProfile(const char* profile)
{
	if(Vars.bUseProfileScript != TRUE || !ProfileExists(profile))
		return false;

	char file[_MAX_FNAME+_MAX_PATH] = "",
		 defaultStarter[_MAX_FNAME] = "",
		 defaultGame[_MAX_FNAME] = "",
		 scriptPath[_MAX_PATH] = "";
	sprintf_s(file, sizeof(file), "%sd2bs.ini", Vars.szPath);

	GetPrivateProfileString(profile, "ScriptPath", "scripts", scriptPath, _MAX_PATH, file);
	GetPrivateProfileString(profile, "DefaultGameScript", "", defaultGame, _MAX_FNAME, file);
	GetPrivateProfileString(profile, "DefaultStarterScript", "", defaultStarter, _MAX_FNAME, file);

	strcpy_s(Vars.szProfile, 256, profile);
	sprintf_s(Vars.szScriptPath, _MAX_PATH, "%s%s", Vars.szPath, scriptPath);
	if(strlen(defaultGame) > 0)
		strcpy_s(Vars.szDefault, _MAX_FNAME, defaultGame);
	if(strlen(defaultStarter) > 0)
		strcpy_s(Vars.szStarter, _MAX_FNAME, defaultStarter);

	Vars.bUseProfileScript = FALSE;
	Reload();
	return true;
}
예제 #3
0
void CVoxSQLite::AddProfile( const char* username, Profile& rProfile )
{
	if ( ProfileExists( username ) )
	{
		UpdateProfile( username, rProfile );
	}
	else
	{
		InsertProfile( username, rProfile );
	}
}
static bool GetProfileName(QWidget *parent, std::string &name,
		std::string &file, const char *title, const char *text,
		const char *oldName = nullptr)
{
	char path[512];
	int ret;

	for (;;) {
		bool success = NameDialog::AskForName(parent, title, text,
				name, QT_UTF8(oldName));
		if (!success) {
			return false;
		}
		if (name.empty()) {
			QMessageBox::information(parent,
					QTStr("NoNameEntered.Title"),
					QTStr("NoNameEntered.Text"));
			continue;
		}
		if (ProfileExists(name.c_str())) {
			QMessageBox::information(parent,
					QTStr("NameExists.Title"),
					QTStr("NameExists.Text"));
			continue;
		}
		break;
	}

	if (!GetFileSafeName(name.c_str(), file)) {
		blog(LOG_WARNING, "Failed to create safe file name for '%s'",
				name.c_str());
		return false;
	}

	ret = GetConfigPath(path, sizeof(path), "obs-studio/basic/profiles/");
	if (ret <= 0) {
		blog(LOG_WARNING, "Failed to get profiles config path");
		return false;
	}

	file.insert(0, path);

	if (!GetClosestUnusedFileName(file, nullptr)) {
		blog(LOG_WARNING, "Failed to get closest file name for %s",
				file.c_str());
		return false;
	}

	file.erase(0, ret);
	return true;
}
예제 #5
0
static void handle_input()
{
    bool button_pressed = false;
#ifdef CONFIG_USE_TAPS
    // tap controls
    {
        int cx = (Graphics::SCREEN_WIDTH / 2) - (sprites[SPR_MENU].w / 2) - 8;
        int cy = (Graphics::SCREEN_HEIGHT / 2) - 8;
        for(int i=0;i<sprites[SPR_MENU].nframes;i++)
        {
            RectI r = Sprites::get_sprite_rect(cx, cy, SPR_MENU, i);
            if (VJoy::ModeAware::wasTap(r))
            {
                if (title.cursel == i)
                {
                    button_pressed = true;
                    
                }
                else
                {
                    sound(SND_MENU_MOVE);
                    title.cursel = i;
                }
                
                break;
            }

            cy += (sprites[SPR_MENU].h + 18);
        }
    }
#endif
    
    // pad control
    {
        if (justpushed(DOWNKEY))
        {
            sound(SND_MENU_MOVE);
            if (++title.cursel >= sprites[SPR_MENU].nframes)
                title.cursel = 0;
        }
        else if (justpushed(UPKEY))
        {
            sound(SND_MENU_MOVE);
            if (--title.cursel < 0)
                title.cursel = sprites[SPR_MENU].nframes - 1;
        }
        
        button_pressed = button_pressed || buttonjustpushed();
	}
    
    
	if (button_pressed)
	{
		sound(SND_MENU_SELECT);
		int choice = title.cursel;
		
		// handle case where user selects Load but there is no savefile,
		// or the last_save_file is deleted.
		if (title.cursel == 1)
		{
			if (!ProfileExists(settings->last_save_slot))
			{
				bool foundslot = false;
				for(int i=0;i<MAX_SAVE_SLOTS;i++)
				{
					if (ProfileExists(i))
					{
						stat("Last save file %d missing. Defaulting to %d instead.", settings->last_save_slot, i);
						settings->last_save_slot = i;
						foundslot = true;
					}
				}
				
				// there are no save files. Start a new game instead.
				if (!foundslot)
				{
					stat("No save files found. Starting new game instead.");
					choice = 0;
				}
			}
		}
		
		if (choice == 1 && settings->multisave)
		{
			title.selchoice = 2;
			title.seldelay = SELECT_MENU_DELAY;
		}
		else
		{
			title.selchoice = choice;
			title.seldelay = SELECT_DELAY;
			music(0);
		}
	}
	
	run_konami_code();
}
예제 #6
0
파일: title.cpp 프로젝트: Rox64/NXEngine
static void handle_input()
{
	if (justpushed(DOWNKEY))
	{
		sound(SND_MENU_MOVE);
		if (++title.cursel >= sprites[SPR_MENU].nframes)
			title.cursel = 0;
	}
	else if (justpushed(UPKEY))
	{
		sound(SND_MENU_MOVE);
		if (--title.cursel < 0)
			title.cursel = sprites[SPR_MENU].nframes - 1;
	}
	
	if (buttonjustpushed())
	{
		sound(SND_MENU_SELECT);
		int choice = title.cursel;
		
		// handle case where user selects Load but there is no savefile,
		// or the last_save_file is deleted.
		if (title.cursel == 1)
		{
			if (!ProfileExists(settings->last_save_slot))
			{
				bool foundslot = false;
				for(int i=0;i<MAX_SAVE_SLOTS;i++)
				{
					if (ProfileExists(i))
					{
						stat("Last save file %d missing. Defaulting to %d instead.", settings->last_save_slot, i);
						settings->last_save_slot = i;
						foundslot = true;
					}
				}
				
				// there are no save files. Start a new game instead.
				if (!foundslot)
				{
					stat("No save files found. Starting new game instead.");
					choice = 0;
				}
			}
		}
		
		if (choice == 1 && settings->multisave)
		{
			title.selchoice = 2;
			title.seldelay = SELECT_MENU_DELAY;
		}
		else
		{
			title.selchoice = choice;
			title.seldelay = SELECT_DELAY;
			music(0);
		}
	}
	
	run_konami_code();
}