Ejemplo n.º 1
0
GUI_ListBox::~GUI_ListBox(void)
{
	cState()->ClearEntries();
	hilights.clear();
	selected = -1;
	delete scrollbar;
}
Ejemplo n.º 2
0
bool CGhostPlayer::validateGhostFile(const c8 *sFile, c8 *sPlayer, c8 *sLevel, u32 *iSteps) {
  bool bRet=true;
  u32 iSize=0;
  c8 sBuffer[0xFF];
  CSerializer cData;
  *iSteps=0;

  printf("open %s\n",sFile);

  IFileSystem *pFs=m_pDevice->getFileSystem();
  IReadFile *f=pFs->createAndOpenFile(path(sFile));

  f->read(&iSize,sizeof(u32));
  f->read(sBuffer,iSize);

  cData.setBuffer(sBuffer,iSize);

  CGhostHeader cHead(&cData);
  if (!strcmp(cHead.getIdent(),"StuntMarbleRacersGhostFile")) {
    strcpy(sPlayer,cHead.getPlayer());
    strcpy(sLevel ,cHead.getLevel ());
    while (f->getPos()<f->getSize()) {
      f->read(&iSize,sizeof(u32));
      bRet=bRet && iSize==24;
      f->read(sBuffer,iSize);
      cData.setBuffer(sBuffer,iSize);
      CGhostState cState(&cData);
      (*iSteps)++;
    }
  }

  f->drop();
  return bRet && !strcmp(cHead.getIdent(),"StuntMarbleRacersGhostFile");
}
Ejemplo n.º 3
0
bool GUI_ListBox::ProcessMe(GUI_MOUSE_EVENT _event, int _x, int _y)
{
	auto s = cState();
	if (_event == LBDOWN &&
		_x > rect.left && _x < rect.right - scrlBarWidth &&
		_y > rect.top && _y < rect.bottom)
	//click is in listbox area
	{
		int sel = (_y - (rect.top + style->MarginTop())) / (font->GetfHeight() + lineSpace) + scrollbar->GetScrollPos();
		if (sel >= 0 && sel < int(s->entries.size()))
		{
			selected = sel;			
			if (s->GetSelectBox())
			//if this listBox allows for multiselection
			{
				bool wasSelected = false;
				for (UINT i = 0; i < hilights.size(); ++i)
				{
					if (hilights[i] == sel)
					{	
						hilights.erase(hilights.begin() + i);
						wasSelected = true;
					}
				}
				if (!wasSelected)
					hilights.push_back(sel);
			}
			return true;
		}
	}
	return false;
}
Ejemplo n.º 4
0
void GUI_ListBox::AddElement(string element, bool hilight)
//adds a new element to the list, and marks it either selected or not
{
	auto s = cState();
	s->AddEntry(element);
	if (s->GetSelectBox() && hilight) hilights.push_back(s->entries.size() - 1);
	scrollbar->SetScrollRange(s->entries.size() - nLines);
}
Ejemplo n.º 5
0
void GUI_ListBox::SetSelected(int _selected)
{
	if (_selected >= 0 && _selected < int(cState()->entries.size()))
	{
		selected = _selected;
	}
	else selected = -1;
}
Ejemplo n.º 6
0
int GUI_ListBox::GetSelected()
{
	if (selected >= int(cState()->entries.size()))
	{
		return -1;
	}
	return selected;
}
Ejemplo n.º 7
0
bool GUI_ListBox::IsHighlight(UINT index)
{
	auto s = cState();
	if (!s->GetSelectBox() || index > s->entries.size()) return false;

	for (UINT i = 0; i < hilights.size(); ++i)
	{
		if (hilights[i] == index) return true;
	}

	return false;
}
Ejemplo n.º 8
0
std::string GUI_ListBox::GetSelectedText()
{
	//	sprintf(outVar, "%s", entries[selected].data());
	if (selected != -1)
	{
		return cState()->entries[selected];
	}
	else
	{
		return "";
	}
}
Ejemplo n.º 9
0
GUI_ListBox::GUI_ListBox(RECT _mRect, int _id, GUI_ElementStyle *_style, bool _selectBox, bool _noSelect)
	: GUI_BaseElement(_mRect, _id, _style)
{
	swapState(new GUI_ListBoxState(this));
	//calculating how many lines the ListBox can display and max length of line
	style = _style;
	lineSpace = 2;
	nLines = (height - style->MarginBottom() - style->MarginTop()) / (font->GetfHeight() + lineSpace);
	//default justification is left
	listJustification = T_LEFT;
	//line position
	selected = 2;

	auto s = cState();
	s->SetSelectBox(_selectBox);
	s->SetnoSelect(_noSelect);
	createScrollbar();
	src = GUI_Looks::GetResource(this);
}
Ejemplo n.º 10
0
void main(int argc, char* argv[]) {
	int syms, strength;
	arrays::Array<SYM> input( argv[1], syms, strength );

	char dir[255];
	sprintf(dir, "%d-%d-%d-%d.tmp", input.getHeight(), input.getWidth(), syms, strength );
			
	coverage::state cState(input, syms, strength);

	printf("Completed analysis.\nWriting cached data to disk.\n");
	cState.flush();
	printf("Finished cache data write.\n\n");

	for ( int i = 0; i < input.getHeight(); i++ ) {
		printf("Row: %d; Count: %d\n", i+1, cState.getRowCount(i));
	}

	printf("\n%d elements of %d are flexible\n", cState.getFlexibleCount(), input.getHeight() * input.getWidth() );

}
Ejemplo n.º 11
0
void GUI_ListBox::Draw(SURFHANDLE surf, RECT &drawablerect, int xoffset, int yoffset)
{

	BLITDATA blitdata;
	calculateBlitData(xoffset + rect.left, yoffset + rect.top, drawablerect, blitdata);

	//width or height == 0 indicates that the element is completely outside its
	//parents rect, so no need to draw.
	if (blitdata.width > 0 && blitdata.height > 0)
	{
		//draw background and frame
		oapiBlt(surf, src, &blitdata.tgtrect, &blitdata.srcrect, SURF_PREDEF_CK);
	}

	//find printable rect (
	RECT printableRect = _R(rect.left + xoffset + style->MarginLeft(), rect.top + yoffset + style->MarginTop(), rect.right + xoffset - scrlBarWidth - style->MarginLeft(), rect.bottom + yoffset - style->MarginBottom());

	//draw entries

	SetSelected(selected);
	int posInDrawList = 0;						//notes the position in the currently visible list as opposed to the entire list


	auto s = cState();

	for (UINT i = scrollbar->GetScrollPos(); i < s->entries.size() && int(i) < scrollbar->GetScrollPos() + nLines; ++i, ++posInDrawList)
	{
		int tgty = printableRect.top + (posInDrawList * (font->GetfHeight() + lineSpace));	
		
		if (!s->noSelect && !s->selectBox && selected == i || s->selectBox && IsHighlight(i)) 
		{
			font->Print(surf, s->entries[i], printableRect.left, tgty, printableRect, true, listJustification);
		}
		else
		{
			font->Print(surf, s->entries[i], printableRect.left, tgty, printableRect, false, listJustification);
		}
	}

}
Ejemplo n.º 12
0
static void vTraceUp(APG_TRACE_CTX* spCtx, APG_OPCODE* spOp, apg_uint uiId, apg_uint uiOffset, apg_uint uiPhraseLen){
	APG_PARSER_CTX* spParserCtx = spCtx->spParserCtx;
	char caPrtBuf[APG_DISPLAY_MAX_LINE + sizeof(PRINTBUF) + 1];
	void* vpPrtBuf = NULL;
	apg_uint uiIsTruncated = APG_FALSE;
	char caIndentBuf[APG_DISPLAY_MAX_LINE];
	char caScratchBuf[2*APG_DISPLAY_MAX_LINE];
	apg_uint uiAChars, uiPrintChars;
	int uiState;
	const apg_achar* acpPhrase;
	apg_uint* uipOtherRecord;
	uipOtherRecord = (apg_uint*)vpVecPop(spCtx->vpVecRecordStack);
	TASSERT(uipOtherRecord);
	if(uiDoTrace(spCtx, spOp, uiId)){
		vpPrtBuf = vpStrBufInit(&caPrtBuf[0], sizeof(caPrtBuf));
		while(APG_TRUE && vpPrtBuf){
	spCtx->uiTreeDepth--;
			acpPhrase = spCtx->spParserCtx->acpInputString + uiOffset;
			if(uiPhraseLen == APG_UNDEFINED){uiState = NOMATCH;}
			else if(uiPhraseLen == 0){uiState = EMPTY;}
			else{uiState = MATCH;}
			sprintf(&caScratchBuf[0], "%5lu:%5lu:%3lu:%c:",
					(unsigned long int)spCtx->uiRecordNumber, (unsigned long int)*uipOtherRecord, (unsigned long int)spCtx->uiTreeDepth, cState(uiState));
			uiStrBufCat(vpPrtBuf, &caScratchBuf[0]);
			if(uiStrBufIsTruncated(vpPrtBuf)){uiIsTruncated = APG_TRUE;break;}
			uiIndent(spCtx->uiTreeDepth, caIndentBuf, sizeof(caIndentBuf));
			uiStrBufCat(vpPrtBuf, &caIndentBuf[0]);
			if(uiStrBufIsTruncated(vpPrtBuf)){uiIsTruncated = APG_TRUE;break;}
			switch(uiId){
			case P_RNM:
				vTraceOpRnm(vpPrtBuf, spOp->sUnion.sRnm.spRule->cpRuleName);
				break;
			case P_UDT:
				vTraceOpUdt(vpPrtBuf, spOp->sUnion.sUdt.spUdt->cpUdtName);
				break;
			case P_REP:
				vTraceOpRep(vpPrtBuf, spOp->sUnion.sRep.uiMin, spOp->sUnion.sRep.uiMax);
				break;
			case P_ALT:
				vTraceOpAlt(vpPrtBuf, spOp->sUnion.sAlt.uiChildCount);
				break;
			case P_CAT:
				vTraceOpCat(vpPrtBuf, spOp->sUnion.sCat.uiChildCount);
				break;
			case P_AND:
				vTraceOpAnd(vpPrtBuf);
				break;
			case P_NOT:
				vTraceOpNot(vpPrtBuf);
				break;
			case P_TRG:
				vTraceOpTrg(vpPrtBuf, (apg_uint)spOp->sUnion.sTrg.acMin, (apg_uint)spOp->sUnion.sTrg.acMax);
				break;
			case P_TBS:
				vTraceOpTbs(vpPrtBuf, spOp->sUnion.sTbs.acpStrTbl, spOp->sUnion.sTbs.uiStrLen);
				break;
			case P_TLS:
				vTraceOpTls(vpPrtBuf, spOp->sUnion.sTls.acpStrTbl, spOp->sUnion.sTls.uiStrLen);
				break;
			default:
				TASSERT(APG_FALSE);
				break;
			}
			if(uiStrBufIsTruncated(vpPrtBuf)){uiIsTruncated = APG_TRUE;break;}
			if(uiPhraseLen == APG_UNDEFINED){
				uiPrintChars = uiStrBufCat(vpPrtBuf, ": :");
			} else{
				sprintf(&caScratchBuf[0], ":%lu:", (unsigned long int)uiPhraseLen);
				uiPrintChars = uiStrBufCat(vpPrtBuf, &caScratchBuf[0]);
				uiAChars = uiACharToString(&caScratchBuf[0], sizeof(caScratchBuf), acpPhrase, uiPhraseLen);
				uiPrintChars = uiStrBufCat(vpPrtBuf, &caScratchBuf[0]);
				if(uiAChars < uiPhraseLen){uiIsTruncated = APG_TRUE;break;}
				if(uiStrBufIsTruncated(vpPrtBuf)){uiIsTruncated = APG_TRUE;break;}
			}
			break;
		}
		fprintf(spOut, "%s", cpStrBufString(vpPrtBuf));
		if(uiIsTruncated){fprintf(spOut, "...");}
		fprintf(spOut, "\n");
	}
	spCtx->uiRecordNumber++;
}
Ejemplo n.º 13
0
static void vTraceDown(APG_TRACE_CTX* spCtx, APG_OPCODE* spOp, apg_uint uiId, apg_uint uiOffset){
	APG_PARSER_CTX* spParserCtx = spCtx->spParserCtx;
	char caPrtBuf[APG_DISPLAY_MAX_LINE + sizeof(PRINTBUF) + 1];
	void* vpPrtBuf = NULL;
	apg_uint uiIsTruncated = APG_FALSE;
	char caIndentBuf[APG_DISPLAY_MAX_LINE];
	char caScratchBuf[2*APG_DISPLAY_MAX_LINE];
	apg_uint uiAChars, uiPrintChars;
	void* vpTest;
	const apg_achar* acpPhrase;
	apg_uint uiPhraseLen;
	vpTest = vpVecPush(spCtx->vpVecRecordStack, (void*)&spCtx->uiRecordNumber);
	TASSERT(vpTest);
	if(uiDoTrace(spCtx, spOp, uiId)){
		vpPrtBuf = vpStrBufInit(&caPrtBuf[0], sizeof(caPrtBuf));
		while(APG_TRUE && vpPrtBuf){
			acpPhrase = spCtx->spParserCtx->acpInputString + uiOffset;
			uiPhraseLen = (uiOffset < spCtx->spParserCtx->uiInputStringLen) ? spCtx->spParserCtx->uiInputStringLen - uiOffset : 0;
			sprintf(&caScratchBuf[0], "%5lu:-----:%3lu:%c:", (unsigned long int)spCtx->uiRecordNumber, (unsigned long int)spCtx->uiTreeDepth, cState(PRE_PARSE));
			uiStrBufCat(vpPrtBuf, &caScratchBuf[0]);
			if(uiStrBufIsTruncated(vpPrtBuf)){uiIsTruncated = APG_TRUE;break;}
			uiIndent(spCtx->uiTreeDepth, caIndentBuf, sizeof(caIndentBuf));
			uiStrBufCat(vpPrtBuf, &caIndentBuf[0]);
			if(uiStrBufIsTruncated(vpPrtBuf)){uiIsTruncated = APG_TRUE;break;}
			switch(uiId){
			case P_RNM:
				vTraceOpRnm(vpPrtBuf, spOp->sUnion.sRnm.spRule->cpRuleName);
				break;
			case P_UDT:
				vTraceOpUdt(vpPrtBuf, spOp->sUnion.sUdt.spUdt->cpUdtName);
				break;
			case P_REP:
				vTraceOpRep(vpPrtBuf, spOp->sUnion.sRep.uiMin, spOp->sUnion.sRep.uiMax);
				break;
			case P_ALT:
				vTraceOpAlt(vpPrtBuf, spOp->sUnion.sAlt.uiChildCount);
				break;
			case P_CAT:
				vTraceOpCat(vpPrtBuf, spOp->sUnion.sCat.uiChildCount);
				break;
			case P_AND:
				vTraceOpAnd(vpPrtBuf);
				break;
			case P_NOT:
				vTraceOpNot(vpPrtBuf);
				break;
			case P_TRG:
				vTraceOpTrg(vpPrtBuf, (apg_uint)spOp->sUnion.sTrg.acMin, (apg_uint)spOp->sUnion.sTrg.acMax);
				break;
			case P_TBS:
				vTraceOpTbs(vpPrtBuf, spOp->sUnion.sTbs.acpStrTbl, spOp->sUnion.sTbs.uiStrLen);
				break;
			case P_TLS:
				vTraceOpTls(vpPrtBuf, spOp->sUnion.sTls.acpStrTbl, spOp->sUnion.sTls.uiStrLen);
				break;
			default:
				TASSERT(APG_FALSE);
				break;
			}
			uiPrintChars = uiStrBufCat(vpPrtBuf, ": :");
			if(uiStrBufIsTruncated(vpPrtBuf)){uiIsTruncated = APG_TRUE;break;}
			uiAChars = uiACharToString(&caScratchBuf[0], sizeof(caScratchBuf), acpPhrase, uiPhraseLen);
			uiPrintChars = uiStrBufCat(vpPrtBuf, &caScratchBuf[0]);
			if(uiAChars < uiPhraseLen){uiIsTruncated = APG_TRUE;break;}
			if(uiStrBufIsTruncated(vpPrtBuf)){uiIsTruncated = APG_TRUE;break;}
	spCtx->uiTreeDepth++;
			break;
		}
		fprintf(spOut, "%s", cpStrBufString(vpPrtBuf));
		if(uiIsTruncated){fprintf(spOut, "...");}
		fprintf(spOut, "\n");
	}
	spCtx->uiRecordNumber++;
}
Ejemplo n.º 14
0
int GUI_ListBox::NumEntries()
{
	return cState()->entries.size();
}
Ejemplo n.º 15
0
void GUI_ListBox::clear()
{
	cState()->ClearEntries();
	hilights.clear();
}