Esempio n. 1
0
static void TestPDFUnion(skiatest::Reporter* reporter) {
    SkPDFUnion boolTrue = SkPDFUnion::Bool(true);
    ASSERT_EMIT_EQ(reporter, boolTrue, "true");

    SkPDFUnion boolFalse = SkPDFUnion::Bool(false);
    ASSERT_EMIT_EQ(reporter, boolFalse, "false");

    SkPDFUnion int42 = SkPDFUnion::Int(42);
    ASSERT_EMIT_EQ(reporter, int42, "42");

    SkPDFUnion realHalf = SkPDFUnion::Scalar(SK_ScalarHalf);
    ASSERT_EMIT_EQ(reporter, realHalf, "0.5");

    SkPDFUnion bigScalar = SkPDFUnion::Scalar(110999.75f);
#if !defined(SK_ALLOW_LARGE_PDF_SCALARS)
    ASSERT_EMIT_EQ(reporter, bigScalar, "111000");
#else
    ASSERT_EMIT_EQ(reporter, bigScalar, "110999.75");

    SkPDFUnion biggerScalar = SkPDFUnion::Scalar(50000000.1);
    ASSERT_EMIT_EQ(reporter, biggerScalar, "50000000");

    SkPDFUnion smallestScalar = SkPDFUnion::Scalar(1.0 / 65536);
    ASSERT_EMIT_EQ(reporter, smallestScalar, "0.00001526");
#endif

    SkPDFUnion stringSimple = SkPDFUnion::String("test ) string ( foo");
    ASSERT_EMIT_EQ(reporter, stringSimple, "(test \\) string \\( foo)");

    SkString stringComplexInput("\ttest ) string ( foo");
    SkPDFUnion stringComplex = SkPDFUnion::String(stringComplexInput);
    ASSERT_EMIT_EQ(reporter,
                   stringComplex,
                   "<0974657374202920737472696E67202820666F6F>");

    SkString nameInput("Test name\twith#tab");
    SkPDFUnion name = SkPDFUnion::Name(nameInput);
    ASSERT_EMIT_EQ(reporter, name, "/Test#20name#09with#23tab");

    SkString nameInput2("A#/%()<>[]{}B");
    SkPDFUnion name2 = SkPDFUnion::Name(nameInput2);
    ASSERT_EMIT_EQ(reporter, name2, "/A#23#2F#25#28#29#3C#3E#5B#5D#7B#7DB");

    SkPDFUnion name3 = SkPDFUnion::Name("SimpleNameWithOnlyPrintableASCII");
    ASSERT_EMIT_EQ(reporter, name3, "/SimpleNameWithOnlyPrintableASCII");

    // Test that we correctly handle characters with the high-bit set.
    SkString highBitString("\xDE\xAD" "be\xEF");
    SkPDFUnion highBitName = SkPDFUnion::Name(highBitString);
    ASSERT_EMIT_EQ(reporter, highBitName, "/#DE#ADbe#EF");
}
Esempio n. 2
0
int CThemes::Show()
{
	std::string file_name = "";

	CMenuWidget themes(menue_title, menue_icon, width);
	themes.setPreselected(selected);

	//intros
	themes.addIntroItems(menue_title != LOCALE_COLORTHEMEMENU_HEAD2 ? LOCALE_COLORTHEMEMENU_HEAD2 : NONEXISTANT_LOCALE);
	
	//set default theme
	themes.addItem(new CMenuForwarder(LOCALE_COLORTHEMEMENU_NEUTRINO_THEME, true, NULL, this, "theme_neutrino", CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED));

	readThemes(themes);

	CStringInputSMS nameInput(LOCALE_COLORTHEMEMENU_NAME, &file_name, 30, false, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789- ");
	CMenuForwarder *m1 = new CMenuForwarder(LOCALE_COLORTHEMEMENU_SAVE, true , NULL, &nameInput);

	// Don't show SAVE if UserDir does'nt exist
	if ( access(USERDIR, F_OK) != 0 ) { // check for existance
	// mkdir must be called for each subdir which does not exist 
	//	mkdir (USERDIR, S_IRUSR | S_IREAD | S_IWUSR | S_IWRITE | S_IXUSR | S_IEXEC) == 0) {
		if (system (((std::string)"mkdir -p " + USERDIR).c_str()) != 0) {
			printf("[neutrino theme] error creating %s\n", USERDIR);
		}
	}
	if (access(USERDIR, F_OK) == 0 ) {
		themes.addItem(GenericMenuSeparatorLine);
		themes.addItem(m1);
	} else {
		delete m1;
		printf("[neutrino theme] error accessing %s\n", USERDIR);
	}

	int res = themes.exec(NULL, "");
	selected = themes.getSelected();

	if (file_name.length() > 1) {
		saveFile((char*)((std::string)USERDIR + file_name + FILE_PREFIX).c_str());
	}

	if (hasThemeChanged) {
		if (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_COLORTHEMEMENU_QUESTION, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, menue_icon.c_str()) != CMessageBox::mbrYes)
			rememberOldTheme( false );
		else
			hasThemeChanged = false;
	}

	return res;
}
Esempio n. 3
0
int CThemes::Show()
{
	move_userDir();

	std::string file_name = "";

	CMenuWidget themes (LOCALE_COLORMENU_MENUCOLORS, NEUTRINO_ICON_SETTINGS, width);
	
	themes.addIntroItems(LOCALE_COLORTHEMEMENU_HEAD2);
	
	//set default theme
	themes.addItem(new CMenuForwarder(LOCALE_COLORTHEMEMENU_NEUTRINO_THEME, true, NULL, this, "theme_neutrino", CRCInput::RC_red));
	
	readThemes(themes);

	CKeyboardInput nameInput(LOCALE_COLORTHEMEMENU_NAME, &file_name);
	CMenuForwarder *m1 = new CMenuForwarder(LOCALE_COLORTHEMEMENU_SAVE, true , NULL, &nameInput, NULL, CRCInput::RC_green);

	if (CFileHelpers::createDir(THEMESDIR_VAR) && errno != EEXIST) {
		printf("[neutrino theme] error creating %s\n", THEMESDIR_VAR);

	}
	if (access(THEMESDIR_VAR, F_OK) == 0 ) {
		themes.addItem(GenericMenuSeparatorLine);
		themes.addItem(m1);
	} else {
		delete m1;
		printf("[neutrino theme] error accessing %s\n", THEMESDIR_VAR);
	}

	int res = themes.exec(NULL, "");

	if (!file_name.empty()) {
		saveFile(((std::string)THEMESDIR_VAR + "/" + file_name + FILE_PREFIX).c_str());
	}

	if (hasThemeChanged) {
		if (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_COLORTHEMEMENU_QUESTION, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_SETTINGS) != CMessageBox::mbrYes)
			rememberOldTheme( false );
		else
			hasThemeChanged = false;
	}
	return res;
}
Esempio n. 4
0
static void TestPDFUnion(skiatest::Reporter* reporter) {
    SkPDFUnion boolTrue = SkPDFUnion::Bool(true);
    assert_emit_eq(reporter, boolTrue, "true");

    SkPDFUnion boolFalse = SkPDFUnion::Bool(false);
    assert_emit_eq(reporter, boolFalse, "false");

    SkPDFUnion int42 = SkPDFUnion::Int(42);
    assert_emit_eq(reporter, int42, "42");

    assert_emit_eq_number(reporter, SK_ScalarHalf);
    assert_emit_eq_number(reporter, 110999.75f);  // bigScalar
    assert_emit_eq_number(reporter, 50000000.1f);  // biggerScalar
    assert_emit_eq_number(reporter, 1.0f / 65536);  // smallScalar

    SkPDFUnion stringSimple = SkPDFUnion::String("test ) string ( foo");
    assert_emit_eq(reporter, stringSimple, "(test \\) string \\( foo)");

    SkString stringComplexInput("\ttest ) string ( foo");
    SkPDFUnion stringComplex = SkPDFUnion::String(stringComplexInput);
    assert_emit_eq(reporter, stringComplex, "(\\011test \\) string \\( foo)");

    SkString binaryStringInput("\1\2\3\4\5\6\7\10\11\12\13\14\15\16\17\20");
    SkPDFUnion binaryString = SkPDFUnion::String(binaryStringInput);
    assert_emit_eq(reporter, binaryString, "<0102030405060708090A0B0C0D0E0F10>");

    SkString nameInput("Test name\twith#tab");
    SkPDFUnion name = SkPDFUnion::Name(nameInput);
    assert_emit_eq(reporter, name, "/Test#20name#09with#23tab");

    SkString nameInput2("A#/%()<>[]{}B");
    SkPDFUnion name2 = SkPDFUnion::Name(nameInput2);
    assert_emit_eq(reporter, name2, "/A#23#2F#25#28#29#3C#3E#5B#5D#7B#7DB");

    SkPDFUnion name3 = SkPDFUnion::Name("SimpleNameWithOnlyPrintableASCII");
    assert_emit_eq(reporter, name3, "/SimpleNameWithOnlyPrintableASCII");

    // Test that we correctly handle characters with the high-bit set.
    SkString highBitString("\xDE\xAD" "be\xEF");
    SkPDFUnion highBitName = SkPDFUnion::Name(highBitString);
    assert_emit_eq(reporter, highBitName, "/#DE#ADbe#EF");
}
Esempio n. 5
0
int CThemes::Show()
{
	std::string file_name = "";

	CMenuWidget themes (LOCALE_COLORMENU_MENUCOLORS, NEUTRINO_ICON_SETTINGS, width);
	
	themes.addIntroItems(LOCALE_COLORTHEMEMENU_HEAD2);
	
	//set default theme
	themes.addItem(new CMenuForwarder(LOCALE_COLORTHEMEMENU_NEUTRINO_THEME, true, NULL, this, "theme_neutrino", CRCInput::RC_red));
	
	readThemes(themes);

	CStringInputSMS nameInput(LOCALE_COLORTHEMEMENU_NAME, &file_name, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789- ");
	CMenuForwarder *m1 = new CMenuForwarder(LOCALE_COLORTHEMEMENU_SAVE, true , NULL, &nameInput, NULL, CRCInput::RC_green);

	if (mkdirhier(USERDIR) && errno != EEXIST) {
		printf("[neutrino theme] error creating %s\n", USERDIR);
	}
	if (access(USERDIR, F_OK) == 0 ) {
		themes.addItem(GenericMenuSeparatorLine);
		themes.addItem(m1);
	} else {
		delete m1;
		printf("[neutrino theme] error accessing %s\n", USERDIR);
	}

	int res = themes.exec(NULL, "");

	if (file_name.length() > 1) {
		saveFile((char*)((std::string)USERDIR + file_name + FILE_PREFIX).c_str());
	}

	if (hasThemeChanged) {
		if (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_COLORTHEMEMENU_QUESTION, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_SETTINGS) != CMessageBox::mbrYes)
			rememberOldTheme( false );
		else
			hasThemeChanged = false;
	}
	return res;
}
Esempio n. 6
0
int CThemes::Show()
{
	dprintf(DEBUG_NORMAL, "CThemes::Show:\n");

	std::string file_name = "";

	CMenuWidget themes(LOCALE_COLORMENU_MENUCOLORS, NEUTRINO_ICON_SETTINGS, width);
	
	//set default theme
	themes.addItem(new CMenuForwarder(LOCALE_COLORTHEMEMENU_DEFAULT_THEME, true, NULL, this, "theme_default" ));
	
	readThemes(themes);

	CStringInputSMS nameInput(LOCALE_COLORTHEMEMENU_NAME, &file_name);
	CMenuForwarder * m1 = new CMenuForwarder(LOCALE_COLORTHEMEMENU_SAVE, true , NULL, &nameInput, NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED);

	// Don't show SAVE if UserDir does'nt exist
	if ( access(USERDIR, F_OK) != 0 ) 
	{ 
		// check for existance
		// mkdir must be called for each subdir which does not exist 
		// mkdir (USERDIR, S_IRUSR | S_IREAD | S_IWUSR | S_IWRITE | S_IXUSR | S_IEXEC) == 0) {
		
		if (system (((std::string)"mkdir -p " + USERDIR).c_str()) != 0) 
		{
			printf("[neutrino theme] error creating %s\n", USERDIR);
		}
	}
	
	if (access(USERDIR, F_OK) == 0 ) 
	{
		themes.addItem(new CMenuSeparator(CMenuSeparator::LINE));
		themes.addItem(m1);
	} 
	else 
	{
		delete m1;
		printf("[neutrino theme] error accessing %s\n", USERDIR);
	}

	int res = themes.exec(NULL, "");

	if (file_name.length() > 1) 
	{
		saveFile((char*)((std::string)USERDIR + file_name + FILE_PREFIX).c_str());
	}

	if (hasThemeChanged) 
	{
		if (MessageBox(LOCALE_MESSAGEBOX_INFO, LOCALE_COLORTHEMEMENU_QUESTION, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_SETTINGS) != CMessageBox::mbrYes)
		{
			rememberOldTheme( false );
		}
		else
		{	
			CNeutrinoApp::getInstance()->exec(NULL, "savesettings");
			hasThemeChanged = false;
		}
	}
	
	return res;
}
Esempio n. 7
0
void
Player::customize()
{
    m_characterName = "";
    CallbackOverlay nameInput(3,30, "What is your name?", &m_characterName, &drawNameInput, &handleNameInput);
    //nameInput.main(m_level);
    std::vector<ListDefinition>raceList;
    raceList.push_back(ListDefinition(LIST_ENTRY,'a',"Human"));
    raceList.push_back(ListDefinition(LIST_ENTRY,'b',"Vedalken"));
    raceList.push_back(ListDefinition(LIST_ENTRY,'c',"Leonin"));
    raceList.push_back(ListDefinition(LIST_ENTRY,'d',"Viashino"));
    raceList.push_back(ListDefinition(LIST_ENTRY,'r',"Random"));
    ListOverlay raceOverlay(5, 30, "Select starting race", false, false, raceList);
    raceOverlay.main(m_level);
    for(unsigned int i=0; i<raceOverlay.m_definition.size(); i++) {
        ListDefinition &def = raceOverlay.m_definition[i];
        if(def.m_selected) {
            switch(i) {
            case 0:
                m_race=PLAYER_HUMAN;
                break;
            case 1:
                m_race=PLAYER_VEDALKEN;
                break;
            case 2:
                m_race=PLAYER_LEONIN;
                break;
            case 3:
                m_race=PLAYER_VIASHINO;
                break;
            case 4:
                boost::random::uniform_int_distribution<> raceDist(0,3);
                m_race = raceDist(RAND);
                break;
            }
        }
    }
    pickUp(m_level->m_actorFactory.getActor("Short Sword",m_level));
    pickUp(m_level->m_actorFactory.getActor("Minor Mana Potion",m_level));
    pickUp(m_level->m_actorFactory.getActor("Short Bow",m_level));
    Actor *arrow = m_level->m_actorFactory.getActor("Arrow",m_level);
    arrow->m_amount = 20;
    pickUp(arrow);
    m_weapon = 0;
    m_quiver = 3;
    int manaPoints = generateAttributes();
    calculateBonuses();
    calculateHp();
    calculateAc();
    TCODConsole::root->clear();
    increaseMana(manaPoints);
    drawNewCard(0,true);
    drawNewCard(1);
    drawNewCard(2);
    m_level->m_playerGenerated = true;
    std::string msg = "Welcome ";
    /*msg += m_characterName;
    msg += " the ";*/
    msg += m_raceName;
    m_level->m_messages->showMessage(msg, MESSAGE_WARNING);
    m_level->m_messages->showMessage("You enter the dungeons of Svogthos in search of the Orb of Knowledge", MESSAGE_WARNING);
}