Exemple #1
0
void Label::OnDraw()
{
	int normalColor = MakeInt(r, g, b);
	int maxComponent = (r > g ? (r > b ? r : b) : (g > b ? g : b));
	int shadowColor = 0;

	if (maxComponent < 200)
		//shadowColor = (normalColor & 0x7f7f7f) << 1;
		shadowColor = MakeInt(176, 176, 182);
	else
		shadowColor = (normalColor & 0xfefefe) >> 1;

	font->DrawString(this->x + 2, this->y, this->text, D2D1::ColorF(shadowColor, 1.0F));
	font->DrawString(this->x, this->y + 2, this->text, D2D1::ColorF(shadowColor, 1.0F));
	font->DrawString(this->x + 2, this->y + 2, this->text, D2D1::ColorF(shadowColor, 1.0F));
	font->DrawString(this->x, this->y, this->text, D2D1::ColorF(normalColor, 1.0F));
}
Exemple #2
0
//.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtOpt::ParseEnum -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
//
void  DtOpt::ParseEnum(const DtEnumOptPair* EnumPairs, wstring OptName)
{
    while (EnumPairs->m_Name != L"")
    {
        if (EnumPairs->m_Name == m_StrValue)
        {
            MakeInt(EnumPairs->m_Value);
            return;
        }
        EnumPairs++;
    }
    throw DtOptException(L"Invalid argument for command line option: -%ls",
                                                                         OptName.c_str());
}
Exemple #3
0
int 
CPictFile::SumPictInit ( 
	int pictwidth, 
	int pictheight, 
	int numchars, 
	int numcols, 
	int colsinch, 
	int fontpoints, 
	int fontxsize, 
	int fontysize, 
	int fontdescent, 
	int fontbold, 
	char *fontname, 
	const char *outname, 
	int addwidth, 
	int addheight, 
	int addascent
) {

	int	i;
	int tlX, tlY, brX, brY;
	char StrFormat[8];
	char StrFormat2[16];

	
	m_dev_xsize = (int)((double)fontpoints*(double)fontxsize/(double)(fontysize)) + 2 + addwidth;
	m_dev_ysize = fontpoints + addheight;
		
	m_fontdescent = (int)(m_dev_ysize * (double)fontdescent / (double)fontysize + 0.5) + addascent;

	m_xpos = m_dev_xsize / 2;
	m_ypos = m_dev_ysize + (m_dev_ysize / 2);

		// { 0,0 is top left corner, and we increase *ypos to go down the page}
/*			{as the size of the unit cell gets larger, the shift of the
			character to place it nicely in the "box" changes; I haven't worked
			out a nice formula that gives integer values that work for any
			number of points}
*/

	if ( ( m_OutFile = fopen( outname, "w+b" ) ) == NULL ) return 0;

/*
{Calculate here the TopLeft and BottomRight corners of the PICT, based on the size of the
 image and the page dimensions entered above: changing these to reflect, e.g. US Letter
 paper will result in a changed 'window' in which the program will draw the PICT. Note that
 BOXSHADE allows both PICT and EPSF to be *wider* than the defined page (i.e. it doesn't 
check for user errors over what will fit), but it does split the output into separate files of one 
'page-full' (or less)}
*/

	tlX = 0;
	tlY = 0;

	int sumpix = 72 / colsinch;
	if ( sumpix == 0 ) sumpix = 1;

	brY = tlY + (pictheight / fontysize) * m_dev_ysize;
	brX = tlX + numchars * m_dev_xsize + numcols * sumpix + m_dev_xsize;
	
	StrFormat[0] = tlY / 256;
	StrFormat[1] = tlY % 256;
	StrFormat[2] = tlX / 256;
	StrFormat[3] = tlX % 256;
	StrFormat[4] = brY / 256;
	StrFormat[5] = brY % 256;
	StrFormat[6] = brX / 256;
	StrFormat[7] = brX % 256;
   
	for ( i = 0; i < 16; ++i ) StrFormat2[i] = 0;
	/* {yes, I know I'm being lazy!} */
	// hres
	StrFormat2[0] = tlX / 256;
	StrFormat2[1] = tlX % 256;

	// vres
	StrFormat2[4] = tlY / 256;
	StrFormat2[5] = tlY % 256;
                                  
	// srcrect top
	StrFormat2[8] = brX / 256;
	StrFormat2[9] = brX % 256;
	// srcrect left

	// srcrect bottom
	StrFormat2[12] = brY / 256;
	StrFormat2[13] = brY % 256;
	// srcrect right
		
	// version int 2
	// res int 2    
		
	// hres, fixed 4
	// vres  .. fixed 4
	// srcrect  .. top, left, bottom, right ints .. 8
		
	// reserved long  4
        
		// Represent a version 2 picture fixed point bounding box   

/*
{I have to write a header of 512 bytes plus 2 bytes for the PICT size field, 
which fortunately is never read.}
*/

	for ( i = 0; i < 514; ++i )  putc(0, m_OutFile );
			
/*	{now we write the various header opcodes and size for the file} */
			
	for ( i = 0; i < 8; ++i ) putc( StrFormat[i], m_OutFile );
	for ( i = 0; i < 10; ++i ) putc( StrHeaderOp[i], m_OutFile );
	for ( i = 0; i < 16; ++i ) putc( StrFormat2[i], m_OutFile );
	for ( i = 0; i < 4; ++i ) putc( 0, m_OutFile );

	// Now ..

	for ( i = 0; i < 6; ++i ) putc( StrHiLiteClip[i], m_OutFile );
	for ( i = 0; i < 8; ++i ) putc( StrFormat[i], m_OutFile );
		
	// Do Op 44, SetFontName?
	MakeInt ( 44 );
	int length = strlen(fontname) + 3;
	MakeInt ( length );
	MakeInt ( 22 );		// FontID
	putc ( length = strlen(fontname), m_OutFile );
	for ( i = 0; i < length; ++i ) putc( fontname[i], m_OutFile );
		
	// SetFontId op
	for ( i = 0; i < 4; ++i ) putc( StrSetFont[i], m_OutFile );
		
	MakeInt( 4 ); // Text Face ( Word ) 
		
	if ( fontbold ) {
		MakeInt(256);
	} else {
		MakeInt(0);
	}
		
	MakeInt(13); // Text Size points
	MakeInt(fontpoints); // Text Size points
		
	return 1;
}
Exemple #4
0
Type* Type::Read(Buffer *buf)
{
  uint32_t kind = 0;
  uint32_t width = 0;
  uint32_t count = 0;
  bool sign = false;
  bool varargs = false;
  String *name = NULL;
  Type *target_type = NULL;
  TypeCSU *csu_type = NULL;
  Vector<Type*> argument_types;

  Try(ReadOpenTag(buf, TAG_Type));
  while (!ReadCloseTag(buf, TAG_Type)) {
    switch (PeekOpenTag(buf)) {
    case TAG_Kind: {
      Try(!kind);
      Try(ReadTagUInt32(buf, TAG_Kind, &kind));
      break;
    }
    case TAG_Width: {
      Try(ReadTagUInt32(buf, TAG_Width, &width));
      break;
    }
    case TAG_Sign: {
      Try(ReadTagEmpty(buf, TAG_Sign));
      sign = true;
      break;
    }
    case TAG_Name: {
      Try(!name);
      Try(kind == YK_CSU);
      name = String::ReadWithTag(buf, TAG_Name);
      break;
    }
    case TAG_Type: {
      Try(!target_type);
      Try(kind == YK_Pointer || kind == YK_Array || kind == YK_Function);
      target_type = Type::Read(buf);
      break;
    }
    case TAG_Count: {
      Try(kind == YK_Array);
      Try(ReadTagUInt32(buf, TAG_Count, &count));
      break;
    }
    case TAG_TypeFunctionCSU: {
      Try(!csu_type);
      Try(ReadOpenTag(buf, TAG_TypeFunctionCSU));
      csu_type = Type::Read(buf)->AsCSU();
      Try(ReadCloseTag(buf, TAG_TypeFunctionCSU));
      break;
    }
    case TAG_TypeFunctionVarArgs: {
      Try(kind == YK_Function);
      Try(ReadTagEmpty(buf, TAG_TypeFunctionVarArgs));
      varargs = true;
      break;
    }
    case TAG_TypeFunctionArguments: {
      Try(kind == YK_Function);
      Try(argument_types.Empty());
      Try(ReadOpenTag(buf, TAG_TypeFunctionArguments));
      while (!ReadCloseTag(buf, TAG_TypeFunctionArguments)) {
        Type *ntype = Type::Read(buf);
        argument_types.PushBack(ntype);
      }
      break;
    }
    default:
      Try(false);
    }
  }

  switch ((TypeKind)kind) {
  case YK_Error:
    return MakeError();
  case YK_Void:
    return MakeVoid();
  case YK_Int:
    return MakeInt(width, sign);
  case YK_Float:
    return MakeFloat(width);
  case YK_Pointer:
    Try(target_type);
    return MakePointer(target_type, width);
  case YK_Array:
    Try(target_type);
    return MakeArray(target_type, count);
  case YK_CSU:
    Try(name);
    return MakeCSU(name);
  case YK_Function:
    Try(target_type);
    return MakeFunction(target_type, csu_type, varargs, argument_types);
  default:
    Try(false);
  }
}
  Ccall(_stratego_t_5);
  Ccall(_stratego_y_5);
  Ccall(_stratego_e_6);
  Ccall(_stratego_f_6);
  Ccall(_stratego_h_6);
  Ccall(_stratego_i_6);
  Ccall(_stratego_u_5);
  Ccall(_stratego_w_5);
ENDPROC

PROC(_stratego_s_5)
  _ST_printnl();
ENDPROC

PROC(_stratego_t_5)
  Tset(App2("TCons",MakeInt(0),App2("TCons",MakeInt(0),App0("TNil"))));
ENDPROC

PROC(_stratego_u_5)
  TestFunTop(a_0);
  TravInit();
  OneNextSon();
  Tdupl();
  Epushd(0,1);
  MoveTop(0,1);
  NotNULLd(0,1);
  Tset(App2("TCons",App0("stderr"),App2("TCons",App2("Cons",ATmakeString("successes: "),App2("Cons",Egetd(0,1),App0("Nil"))),App0("TNil"))));
  Ccall(_stratego_s_5);
  Epopd(0,1);
  Tpop();
  OneNextSon();
Exemple #6
0
void SetVariable()
{
    sPlayerName = xi_refCharacter.name;

    nPlayerMoney = sti(xi_refCharacter.Money);
    nCurrentExperience = sti(xi_refCharacter.Experience);
    nNextExperience = CalculateExperienceFromRank(sti(xi_refCharacter.rank)+1);
    nFreeSkillPoints = sti(xi_refCharacter.Skill.FreeSkill);
	int nFreeAbilities = 0;
	if( CheckAttribute(xi_refCharacter,"perks.FreePoints") )
		nFreeAbilities = sti(xi_refCharacter.perks.FreePoints);

    nLeadership = sti(xi_refCharacter.Skill.Leadership);
    nFencing = sti(xi_refCharacter.Skill.Fencing);
    nSailing = sti(xi_refCharacter.Skill.Sailing);
    nAccuracy = sti(xi_refCharacter.Skill.Accuracy);
    nCannons = sti(xi_refCharacter.Skill.Cannons);
    nGrappling = sti(xi_refCharacter.Skill.Grappling);
    nRepair = sti(xi_refCharacter.Skill.Repair);
    nDefence = sti(xi_refCharacter.Skill.Defence);
    nCommerce = sti(xi_refCharacter.Skill.Commerce);
    nSneak = sti(xi_refCharacter.Skill.Sneak);

    GameInterface.StatusLine.EXP.Max = nNextExperience;
    GameInterface.StatusLine.EXP.Min = CalculateExperienceFromRank(sti(xi_refCharacter.rank));
    GameInterface.StatusLine.EXP.Value = nCurrentExperience;

    GameInterface.strings.CurrentExperience = nCurrentExperience;
    GameInterface.strings.NextExperience = nNextExperience;
    GameInterface.strings.Money = MakeMoneyShow(nPlayerMoney,MONEY_SIGN,MONEY_DELIVER);
    GameInterface.strings.CharacterName = xi_refCharacter.name+" "+xi_refCharacter.lastname;
    GameInterface.strings.Reputation = XI_ConvertString(GetReputationName(sti(xi_refCharacter.reputation)));
	GameInterface.strings.FreeAbilitiesPoints = nFreeAbilities;
    GameInterface.strings.FreeSkillPoints = nFreeSkillPoints;
    GameInterface.strings.Rank = xi_refCharacter.rank;
	GameInterface.strings.MaxHP = MakeInt(LAi_GetCharacterHP(xi_refCharacter)) + "/" + MakeInt(LAi_GetCharacterMaxHP(xi_refCharacter));

	SetSkillShow("SkillLeadership",nLeadership);
	SetSkillShow("SkillFencing",nFencing);
	SetSkillShow("SkillSailing",nSailing);
	SetSkillShow("SkillAccuracy",nAccuracy);
	SetSkillShow("SkillCannons",nCannons);
	SetSkillShow("SkillGrappling",nGrappling);
	SetSkillShow("SkillRepair",nRepair);
	SetSkillShow("SkillDefence",nDefence);
	SetSkillShow("SkillCommerce",nCommerce);
	SetSkillShow("SkillSneak",nSneak);

	SetNewPicture("FACEPICT", "interfaces\portraits\256\face_" + xi_refCharacter.FaceId + ".tga");
	if( xi_refCharacter.id == xi_refMainChar.id ) {
		SetNewPicture("TYPEPICT", "");
	} else {
		switch( FindFellowtravellers(xi_refMainChar,xi_refCharacter) )
		{
		case FELLOWTRAVEL_COMPANION:
			SetNewPicture("TYPEPICT", "interfaces\IsCompanion.tga");
		break;
		case FELLOWTRAVEL_OFFICER:
			SetNewPicture("TYPEPICT", "");
			//SetNewPicture("TYPEPICT", "interfaces\IsOfficer.tga");
		break;
		}
	}

	SendMessage(&GameInterface,"lsl",MSG_INTERFACE_MSG_TO_NODE,"exp",0);
	oldIndex = -1;
}
Exemple #7
0
  MOVE(g_0,ATmakeAFun("F",2,0));
ENDPROC

PROCDECL(_stratego_main);
PROCDECL(_stratego_i_0);
PROCDECL(_stratego_j_0);
PROCDECL(_stratego_k_0);

PROC(_stratego_main)
  Tset(App2("F",App0("B"),App2("G",App0("A"),App0("C"))));
  Ccall(_stratego_i_0);
  Tset(App2("F",App0("B"),App2("G",App0("C"),App0("A"))));
  Ccall(_stratego_i_0);
  Tset(App2("F",App0("D"),App2("G",App0("D"),App0("A"))));
  Ccall(_stratego_i_0);
  Tset(App2("G",MakeInt(1),ATmakeString("a")));
  Ccall(_stratego_i_0);
ENDPROC

PROC(_stratego_i_0)
  Epushd(0,5);
  Ccall(_stratego_j_0);
  MoveTop(0,3);
  goto p_0;
  p_0 :
  TestFunFC(g_0,&&f_0,Egetd(0,3));
  MoveArg(0,4,0,3,0);
  MoveArg(0,5,0,3,1);
  goto q_0;
  q_0 :
  TestFunFC(h_0,&&fail,Egetd(0,5));
Exemple #8
0
char Misc::MakeChar(char c1, char c2)
{
   return (MakeInt(c1) << 4) | MakeInt(c2);
}
bool SetFen(ChessPosition * board, string fen)
{
	InitializeBoard(board);
	ASSERT(fen.length() > 10);

	vector<string> tokens;
	Tokenize(fen, tokens, " ");
	int index = 0;
	int col = 0;
	int row = 0;

	do {
		switch (tokens[0][index]) {
		case 'K': SetPiece(board, WK, MakeSquare(row, col));	col++; break;
		case 'Q': SetPiece(board, WQ, MakeSquare(row, col));	col++; break;
		case 'R': SetPiece(board, WR, MakeSquare(row, col));	col++; break;
		case 'B': SetPiece(board, WB, MakeSquare(row, col));	col++; break;
		case 'N': SetPiece(board, WN, MakeSquare(row, col));	col++; break;
		case 'P': SetPiece(board, WP, MakeSquare(row, col));	col++; break;
		case 'k': SetPiece(board, BK, MakeSquare(row, col));	col++; break;
		case 'q': SetPiece(board, BQ, MakeSquare(row, col));	col++; break;
		case 'r': SetPiece(board, BR, MakeSquare(row, col));	col++; break;
		case 'b': SetPiece(board, BB, MakeSquare(row, col));	col++; break;
		case 'n': SetPiece(board, BN, MakeSquare(row, col));	col++; break;
		case 'p': SetPiece(board, BP, MakeSquare(row, col));	col++; break;
		case '/': row++; col = 0; break;
		case '1': col += 1; break;
		case '2': col += 2; break;
		case '3': col += 3; break;
		case '4': col += 4; break;
		case '5': col += 5; break;
		case '6': col += 6; break;
		case '7': col += 7; break;
		case '8': col += 8; break;
		};
		index++;
	} while (index < tokens[0].length());

	if (tokens[1] == "w") 
		board->sideToMove = WHITE;
	else
	{
		HASH_SIDE();
		board->sideToMove = BLACK;
	}
		


	index = 0;
	do {
		switch (tokens[2][index]) {
		case 'K': board->castlingprivileges |= WHITESHORT;  break;
		case 'Q': board->castlingprivileges |= WHITELONG;  break;
		case 'k': board->castlingprivileges |= BLACKSHORT;  break;
		case 'q': board->castlingprivileges |= BLACKLONG;  break;
		}
		index++;
	} while (index < tokens[2].length());
	HASH_CASTLE();

	//en passant quare
	if (tokens[3] == "-")
		board->enpassantsquare = INVALID;
	else{
		board->enpassantsquare = MakeSquareFromString(tokens[3]);
		HASH_EP(board->enpassantsquare, board->sideToMove)
	}
		

	// 50 move rule counter
	if (tokens[4] == "-")
		board->fiftymoverule = 0;
	else
		board->fiftymoverule = MakeInt(tokens[5]);
	
	//move number
	board->Movenum = MakeInt(tokens[5]);
	HASH_MOVENUM();

	ASSERT(isBoardOK(board));
	return true;
}