コード例 #1
0
ファイル: Commands_TextInput.cpp プロジェクト: nh2/obse
bool TextInputMenu::IsCurrentLineEmpty(UInt32 fromPos) const
{
	if (FindLineEnd(fromPos) - FindLineStart(fromPos) == 1)
		return true;
	else
		return false;
}
コード例 #2
0
ファイル: Commands_TextInput.cpp プロジェクト: nh2/obse
//returns -1 if code not handled, otherwise returns new insertion pos
UInt32 TextInputJournal::ResolveControlCode(UInt8 controlCode, UInt32 insertPos)
{
	if (IsFull())
		return -1;

	UInt32 newPos = insertPos;

	switch (controlCode)
	{
	case DIK_RETURN: //line break
		newPos = InsertText(insertPos, kTagStrings[kHTMLTag_BR].c_str());
		break;
	case DIK_UP:	//move to end of previous line
		newPos = FindLineStart(insertPos);
		if (newPos > GetMinPos())
			newPos = SeekPosition(newPos, true, true);

		break;
	case DIK_DOWN:	//move to start of next line
		newPos = FindLineEnd(insertPos);
		if (newPos <= GetMaxPos())
			newPos = SeekPosition(newPos, false, true);

		break;
	case DIK_C:		//align center
		newPos = SetLineStartingTag(insertPos, kHTMLTag_DIV_Center);
		break;
	case DIK_L:		//align left
		newPos = SetLineStartingTag(insertPos, kHTMLTag_DIV_Left);
		break;
	case DIK_R:		//align right
		newPos = SetLineStartingTag(insertPos, kHTMLTag_DIV_Right);
		break;
	case DIK_1:
	case DIK_2:
	case DIK_3:
	case DIK_4:
	case DIK_5:		//Change font
		{
			char fontNum = controlCode - DIK_1 + '1';
			m_inputText[12] = fontNum;
			break;
		}
	default:
		newPos = -1;
	}

	return newPos;
}
コード例 #3
0
//we begin at the begin of a line
static ptagLevel InitALevel(int *i) 
{
	ptagLevel pLevel;
	int j = *i;
	int iLineBegin = 0;
	int iLineEnd = 0;
	int iRow = 0;
	int iCol = 0;
	char a;
	int *pInt;
	int k;
	int b;

	assert (LineType(j) == LINE_TYPE_LEVEL_BEGIN); 

	//first decide how many line rows
	iLineBegin = j;
	while(1) {
		//we are now at the begin of the line
		
		a = (char)level_data_level[j];
		while (a != 0x0a) {
			if (a == '#')
				iLineEnd = j;
			a = (char)level_data_level[++j];
		}
		
		if (iLineEnd == 0) //There are no '#'s in this line.
			break;

		if (iLineEnd -iLineBegin + 1 > iCol)
			iCol = iLineEnd - iLineBegin + 1;

		iRow ++; 
		j++; 
		iLineEnd = 0;
		iLineBegin = j;
	}


	//Init a structure
	pLevel = (ptagLevel)calloc(1, sizeof(Level));
	pLevel->row = iRow;
	pLevel->col = iCol;
	pLevel->data = (int *)calloc(iRow*iCol, sizeof(int));
	pInt = pLevel->data;
	
	//set value to pLevel->data	
	j = *i;

	for(iRow = 0; iRow < pLevel->row; iRow++)
	{
		iLineEnd = FindLineEnd(j);
		for(k = 0; k <= iLineEnd; k++) 
		{
			b = level_data_level[j++];
			switch (b) {
			case '@':
				pLevel->manx = k;
				pLevel->many = iRow;	
				pInt[iRow*iCol+k] = B_MAN;
				break;
			case '$':
				pInt[iRow*iCol+k] = B_OBJECT;
				break;
			case '.':
				pInt[iRow*iCol+k] = B_GOAL;
				break;
			case '*':
				pInt[iRow*iCol+k] = B_TREASURE;
				break;
			case '+':
				pLevel->manx = k;
				pLevel->many = iRow;	
				pInt[iRow*iCol+k] = B_SAVEMAN;
				break;
			case '#':
				pInt[iRow*iCol+k] = B_STONE;
				break;
			default:
				pInt[iRow*iCol+k] = B_NOTHING;
			}
		}
		for ( ; k < iCol; k++)
			pInt[iRow*iCol+k] = B_NOTHING;
		GotoNextLine(&j);
	}
	
	*i = j;
	return pLevel;
}