void ImportSampleDialog::DrawView() {

    SetWindow(LIST_WIDTH,LIST_SIZE+3) ;

    GUITextProperties props ;

// Draw title

//	char title[40] ;

    SetColor(CD_NORMAL) ;

//	sprintf(title,"Sample Import from %s",currentPath_.GetName()) ;
//	w_.DrawString(title,pos,props) ;

// Draw samples

    int x=1 ;
    int y=1 ;

    if (currentSample_<topIndex_) {
        topIndex_=currentSample_ ;
    } ;
    if (currentSample_>=topIndex_+LIST_SIZE) {
        topIndex_=currentSample_ ;
    } ;

    IteratorPtr<Path> it(sampleList_.GetIterator()) ;
    int count=0 ;
    char buffer[256] ;
    for(it->Begin(); !it->IsDone(); it->Next()) {
        if ((count>=topIndex_)&&(count<topIndex_+LIST_SIZE)) {
            Path &current=it->CurrentItem() ;
            const std::string p=current.GetName() ;

            if (count==currentSample_) {
                SetColor(CD_HILITE2) ;
                props.invert_=true ;
            } else {
                SetColor(CD_NORMAL) ;
                props.invert_=false ;
            }
            if (!current.IsDirectory()) {
                strcpy(buffer,p.c_str()) ;
            } else {
                buffer[0]='[' ;
                strcpy(buffer+1,p.c_str()) ;
                strcat(buffer,"]") ;
            }
            buffer[LIST_WIDTH-1]=0 ;
            DrawString(x,y,buffer,props) ;
            y+=1 ;
        }
        count++ ;
    } ;

    y=LIST_SIZE+2 ;
    int offset=LIST_WIDTH/4 ;

    SetColor(CD_NORMAL) ;

    for (int i=0; i<3; i++) {
        const char *text=buttonText[i] ;
        x=offset*(i+1)-strlen(text)/2 ;
        props.invert_=(i==selected_)?true:false ;
        DrawString(x,y,text,props) ;
    }
} ;
void    plDynamicTextMsg::DrawString( int16_t x, int16_t y, const char *text )
{
    wchar_t *wString = hsStringToWString(text);
    DrawString(x,y,wString);
    delete [] wString;
}
Exemple #3
0
void
BTextControl::Draw(BRect updateRect)
{
	bool enabled = IsEnabled();
	bool active = fText->IsFocus() && Window()->IsActive();

	BRect rect = fText->Frame();
	rect.InsetBy(-2, -2);

	if (be_control_look != NULL) {
		rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
		uint32 flags = 0;
		if (!enabled)
			flags |= BControlLook::B_DISABLED;
		if (active)
			flags |= BControlLook::B_FOCUSED;
		be_control_look->DrawTextControlBorder(this, rect, updateRect, base,
			flags);

		rect = Bounds();
		rect.right = fDivider - kLabelInputSpacing;
//		rect.right = fText->Frame().left - 2;
//		rect.right -= 3;//be_control_look->DefaultLabelSpacing();
		be_control_look->DrawLabel(this, Label(), rect, updateRect,
			base, flags, BAlignment(fLabelAlign, B_ALIGN_MIDDLE));

		return;
	}

	// outer bevel

	rgb_color noTint = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color lighten1 = tint_color(noTint, B_LIGHTEN_1_TINT);
	rgb_color lighten2 = tint_color(noTint, B_LIGHTEN_2_TINT);
	rgb_color lightenMax = tint_color(noTint, B_LIGHTEN_MAX_TINT);
	rgb_color darken1 = tint_color(noTint, B_DARKEN_1_TINT);
	rgb_color darken2 = tint_color(noTint, B_DARKEN_2_TINT);
	rgb_color darken4 = tint_color(noTint, B_DARKEN_4_TINT);
	rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);

	if (enabled)
		SetHighColor(darken1);
	else
		SetHighColor(noTint);

	StrokeLine(rect.LeftBottom(), rect.LeftTop());
	StrokeLine(rect.RightTop());

	if (enabled)
		SetHighColor(lighten2);
	else
		SetHighColor(lighten1);

	StrokeLine(BPoint(rect.left + 1.0f, rect.bottom), rect.RightBottom());
	StrokeLine(BPoint(rect.right, rect.top + 1.0f), rect.RightBottom());

	// inner bevel

	rect.InsetBy(1.0f, 1.0f);

	if (active) {
		SetHighColor(navigationColor);
		StrokeRect(rect);
	} else {
		if (enabled)
			SetHighColor(darken4);
		else
			SetHighColor(darken2);

		StrokeLine(rect.LeftTop(), rect.LeftBottom());
		StrokeLine(rect.LeftTop(), rect.RightTop());

		SetHighColor(noTint);
		StrokeLine(BPoint(rect.left + 1.0f, rect.bottom), rect.RightBottom());
		StrokeLine(BPoint(rect.right, rect.top + 1.0f));
	}

	// label

	if (Label()) {
		_ValidateLayoutData();
		font_height& fontHeight = fLayoutData->font_info;

		float y = Bounds().top + (Bounds().Height() + 1 - fontHeight.ascent
			- fontHeight.descent) / 2 + fontHeight.ascent;
		float x;

		float labelWidth = StringWidth(Label());
		switch (fLabelAlign) {
			case B_ALIGN_RIGHT:
				x = fDivider - labelWidth - kLabelInputSpacing;
				break;

			case B_ALIGN_CENTER:
				x = fDivider - labelWidth / 2.0;
				break;

			default:
				x = 0.0;
				break;
		}

		BRect labelArea(x, Bounds().top, x + labelWidth, Bounds().bottom);
		if (x < fDivider && updateRect.Intersects(labelArea)) {
			labelArea.right = fText->Frame().left - kLabelInputSpacing;

			BRegion clipRegion(labelArea);
			ConstrainClippingRegion(&clipRegion);
			SetHighColor(IsEnabled() ? ui_color(B_CONTROL_TEXT_COLOR)
				: tint_color(noTint, B_DISABLED_LABEL_TINT));
			DrawString(Label(), BPoint(x, y));
		}
	}
}
Exemple #4
0
void TextInput::Draw( Rect area )
{
   FillRect( Bounds(), 0x888888 );
   DrawRect( Bounds(), 0x999999 );
   DrawString( 2,2, m_text, 0 );
}
Exemple #5
0
/**
 * Draw the details for the given vehicle at the given position
 *
 * @param v     current vehicle
 * @param left  The left most coordinate to draw
 * @param right The right most coordinate to draw
 * @param y     The y coordinate
 * @param vscroll_pos Position of scrollbar
 * @param vscroll_cap Number of lines currently displayed
 * @param det_tab Selected details tab
 */
void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_pos, uint16 vscroll_cap, TrainDetailsWindowTabs det_tab)
{
	/* get rid of awkward offset */
	y -= WD_MATRIX_TOP;

	int sprite_height = ScaleGUITrad(GetVehicleHeight(VEH_TRAIN));
	int line_height = max(sprite_height, WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM);
	int sprite_y_offset = line_height / 2;
	int text_y_offset = (line_height - FONT_HEIGHT_NORMAL) / 2;

	/* draw the first 3 details tabs */
	if (det_tab != TDW_TAB_TOTALS) {
		bool rtl = _current_text_dir == TD_RTL;
		Direction dir = rtl ? DIR_E : DIR_W;
		int x = rtl ? right : left;
		for (; v != NULL && vscroll_pos > -vscroll_cap; v = v->GetNextVehicle()) {
			GetCargoSummaryOfArticulatedVehicle(v, &_cargo_summary);

			/* Draw sprites */
			uint dx = 0;
			int px = x;
			const Train *u = v;
			do {
				Point offset;
				int width = u->GetDisplayImageWidth(&offset);
				if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) {
					int pitch = 0;
					const Engine *e = Engine::Get(v->engine_type);
					if (e->GetGRF() != NULL) {
						pitch = ScaleGUITrad(e->GetGRF()->traininfo_vehicle_pitch);
					}
					PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
					VehicleSpriteSeq seq;
					u->GetImage(dir, EIT_IN_DETAILS, &seq);
					seq.Draw(px + (rtl ? -offset.x : offset.x), y - line_height * vscroll_pos + sprite_y_offset + pitch, pal, v->vehstatus & VS_CRASHED);
				}
				px += rtl ? -width : width;
				dx += width;
				u = u->Next();
			} while (u != NULL && u->IsArticulatedPart());

			bool separate_sprite_row = (dx > (uint)ScaleGUITrad(TRAIN_DETAILS_MAX_INDENT));
			if (separate_sprite_row) {
				vscroll_pos--;
				dx = 0;
			}

			uint num_lines = max(1u, _cargo_summary.Length());
			for (uint i = 0; i < num_lines; i++) {
				int sprite_width = max<int>(dx, ScaleGUITrad(TRAIN_DETAILS_MIN_INDENT)) + 3;
				int data_left  = left + (rtl ? 0 : sprite_width);
				int data_right = right - (rtl ? sprite_width : 0);
				if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) {
					int py = y - line_height * vscroll_pos + text_y_offset;
					if (i > 0 || separate_sprite_row) {
						if (vscroll_pos != 0) GfxFillRect(left, py - WD_MATRIX_TOP - 1, right, py - WD_MATRIX_TOP, _colour_gradient[COLOUR_GREY][5]);
					}
					switch (det_tab) {
						case TDW_TAB_CARGO:
							if (i < _cargo_summary.Length()) {
								TrainDetailsCargoTab(&_cargo_summary[i], data_left, data_right, py);
							} else {
								DrawString(data_left, data_right, py, STR_QUANTITY_N_A, TC_LIGHT_BLUE);
							}
							break;

						case TDW_TAB_INFO:
							if (i == 0) TrainDetailsInfoTab(v, data_left, data_right, py);
							break;

						case TDW_TAB_CAPACITY:
							if (i < _cargo_summary.Length()) {
								TrainDetailsCapacityTab(&_cargo_summary[i], data_left, data_right, py);
							} else {
								SetDParam(0, STR_EMPTY);
								DrawString(data_left, data_right, py, STR_VEHICLE_INFO_NO_CAPACITY);
							}
							break;

						default: NOT_REACHED();
					}
				}
				vscroll_pos--;
			}
		}
	} else {
		CargoArray act_cargo;
		CargoArray max_cargo;
		Money feeder_share = 0;

		for (const Vehicle *u = v; u != NULL; u = u->Next()) {
			act_cargo[u->cargo_type] += u->cargo.StoredCount();
			max_cargo[u->cargo_type] += u->cargo_cap;
			feeder_share             += u->cargo.FeederShare();
		}

		/* draw total cargo tab */
		DrawString(left, right, y + text_y_offset, STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY_TEXT);
		y += line_height;

		for (CargoID i = 0; i < NUM_CARGO; i++) {
			if (max_cargo[i] > 0 && --vscroll_pos < 0 && vscroll_pos > -vscroll_cap) {
				SetDParam(0, i);            // {CARGO} #1
				SetDParam(1, act_cargo[i]); // {CARGO} #2
				SetDParam(2, i);            // {SHORTCARGO} #1
				SetDParam(3, max_cargo[i]); // {SHORTCARGO} #2
				SetDParam(4, _settings_game.vehicle.freight_trains);
				DrawString(left, right, y + text_y_offset, FreightWagonMult(i) > 1 ? STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY_MULT : STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY);
				y += line_height;
			}
		}
		SetDParam(0, feeder_share);
		DrawString(left, right, y + text_y_offset, STR_VEHICLE_INFO_FEEDER_CARGO_VALUE);
	}
}
Exemple #6
0
int _jGetString(char *dest, char *start, int maxlen, GS_TYPE type)
{
	/*
	 * Returns 1 if OK; 0 if rejected or quit.
	 */

	int y;
	event e;
	int i;
	int startx;
   int key;

   curpos = 0;
	HideCursor();
	startx = QueryX();
	y = QueryY();

	lrects = malloc(maxlen * sizeof(rect));
	for (i = 0; i < maxlen; i++)
	{
		rect R;

		R.Xmin = startx + i * StringWidthX;
		R.Xmax = R.Xmin + StringWidthX - 1;
		R.Ymax = y;
		R.Ymin = R.Ymax - FontHeight + 1;
		lrects[i] = R;
	}


	tbuf = malloc(maxlen + 1);
	memset(tbuf, ' ', maxlen);
	tbuf[maxlen] = 0;

	i = 0;
	if (start)
	{
		for (i = 0; i < maxlen && start[i]; i++)
			tbuf[i] = start[i];
	}
	curpos = min(i, maxlen - 1);



	TextAlign(alignLeft, alignBottom);

	DrawString(tbuf);

	/* Now highlight somebody */
	InvertRect(&lrects[curpos]);


	while (1)
	{
      key = 0;

		KeyEvent(true, &e);
      if (e.ASCII && e.ASCII != 0xe0)
         key = e.ASCII;
      else if (e.ScanCode != 0xff)
         key = e.ScanCode << 8;

      



		if (key)
		{
			if (key == 0x0d || key == 0x1b)
				break;

			if (key == 0x08)	/* backspace */
            backspace(maxlen);
         else if (key == 0x15)      /* control U */
         {
            while(curpos)
               backspace(maxlen);
         }
			else
			{
				int acceptable = 0;

				if (type == GS_ANYTHING)
					acceptable = isprint(key);
				else if (type == GS_INTEGER)
					acceptable = isdigit(key) || key == '-';
				else if (type == GS_UNSIGNED)
					acceptable = isdigit(key);
				else if (type == GS_FLOAT)
					acceptable = isdigit(key) || key == '.' || key == '-' || key == 'E' || key == 'e';

				if (acceptable)
				{
					InvertRect(&lrects[curpos]);
					MoveTo(lrects[curpos].Xmin, lrects[curpos].Ymax);
					DrawChar(key);
					tbuf[curpos] = key;

					if (curpos < maxlen - 1)
						curpos++;

					InvertRect(&lrects[curpos]);
				}
			}

		}
		else
		{
			int button = (e.State & 0x700) >> 8;

			if (button == swRight)
			{
				key = 0x1b;
				break;
			}
		}
	}
	if (key != 0x1b)
		strcpy(dest, tbuf);

	ShowCursor();
	free(lrects);
	free(tbuf);
	return (key != 0x1b);
}
Exemple #7
0
void SO_Display()
{
	// kolor tła - zawartośæ bufora koloru
	glClearColor(1.0, 1.0, 1.0, 1.0);

	// czyszczenie bufora koloru i bufora głębokości
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// wybór macierzy modelowania
	glMatrixMode(GL_MODELVIEW);

	// macierz modelowania = macierz jednostkowa
	glLoadIdentity();

	// przesunięcie układu współrzędnych sześcianu do środka bryły odcinania
	glTranslatef(0, 0, -(near + far) / 2);

	// obroty sześcianu
	glRotatef(rotatex, 1.0, 0, 0);
	glRotatef(rotatey, 0, 1.0, 0);

	// włączenie oświetlenia
	glEnable(GL_LIGHTING);

	// parametry globalnego światła otaczającego
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient_light);

	// włączenie obsługi właściwości materiałów
	glEnable(GL_COLOR_MATERIAL);

	// właściwości materiału określone przez kolor wierzchołków
	glColorMaterial(GL_FRONT, GL_AMBIENT);

	// włączenie testu bufora głębokości
	glEnable(GL_DEPTH_TEST);

	glBegin(GL_TRIANGLES);
	glColor3fv(Red);
	glVertex3f(0.0, 0.0, -0.5);
	glVertex3f(0.5, 0.0, 0.5);
	glVertex3f(-0.5, 0.0, 0.5);

	glColor3fv(Cyan);
	glVertex3f(0.0, 0.8, 0.0);
	glVertex3f(-0.5, 0.0, 0.5);
	glVertex3f(0.5, 0.0, 0.5);

	glColor3fv(Yellow);
	glVertex3f(0.0, 0.8, 0.0);
	glVertex3f(0.0, 0.0, -0.5);
	glVertex3f(-0.5, 0.0, 0.5);

	glColor3fv(Blue);
	glVertex3f(0.0, 0.8, 0.0);
	glVertex3f(0.5, 0.0, 0.5);
	glVertex3f(0.0, 0.0, -0.5);

	glEnd();


	// wyłączenie oświetlenia
	glDisable(GL_LIGHTING);

	// wyłączenie obsługi właściwości materiałów
	glDisable(GL_COLOR_MATERIAL);

	// wyświetlenie składowych globalnego światła otaczającego
	char string[100];
	GLfloat rgba[4];
	glColor3fv(Black);

	// pobranie wartości składowych światła otaczającego
	// (oczywiście wartości te odpowiadają tablicy ambient_light)
	glGetFloatv(GL_LIGHT_MODEL_AMBIENT, rgba);
	sprintf(string, "AMBIENT: R=%f G=%f B=%f A=%f", rgba[0], rgba[1], rgba[2], rgba[3]);

	// trzeba odpowiednio przekształciæ układ współrzędnych
	// aby napis znajdował się na samej "górze" bryły obcinania
	glLoadIdentity();
	glTranslatef(0, 0, -near);

	// narysowanie napisu
	DrawString((float)left, (float)bottom, string);


	// skierowanie poleceñ do wykonania
	glFlush();

	// zamiana buforów koloru
	glutSwapBuffers();
}
Exemple #8
0
void
PackageColumn::DrawField(BField* field, BRect rect, BView* parent)
{
    BBitmapStringField* bitmapField
        = dynamic_cast<BBitmapStringField*>(field);
    BStringField* stringField = dynamic_cast<BStringField*>(field);
    RatingField* ratingField = dynamic_cast<RatingField*>(field);

    if (bitmapField != NULL) {
        const BBitmap* bitmap = bitmapField->Bitmap();

        // figure out the placement
        float x = 0.0;
        BRect r = bitmap ? bitmap->Bounds() : BRect(0, 0, 15, 15);
        float y = rect.top + ((rect.Height() - r.Height()) / 2);
        float width = 0.0;

        switch (Alignment()) {
        default:
        case B_ALIGN_LEFT:
        case B_ALIGN_CENTER:
            x = rect.left + sTextMargin;
            width = rect.right - (x + r.Width()) - (2 * sTextMargin);
            r.Set(x + r.Width(), rect.top, rect.right - width, rect.bottom);
            break;

        case B_ALIGN_RIGHT:
            x = rect.right - sTextMargin - r.Width();
            width = (x - rect.left - (2 * sTextMargin));
            r.Set(rect.left, rect.top, rect.left + width, rect.bottom);
            break;
        }

        if (width != bitmapField->Width()) {
            BString truncatedString(bitmapField->String());
            parent->TruncateString(&truncatedString, fTruncateMode, width + 2);
            bitmapField->SetClippedString(truncatedString.String());
            bitmapField->SetWidth(width);
        }

        // draw the bitmap
        if (bitmap != NULL) {
            parent->SetDrawingMode(B_OP_ALPHA);
            parent->DrawBitmap(bitmap, BPoint(x, y));
            parent->SetDrawingMode(B_OP_OVER);
        }

        // draw the string
        DrawString(bitmapField->ClippedString(), parent, r);

    } else if (stringField != NULL) {

        float width = rect.Width() - (2 * sTextMargin);

        if (width != stringField->Width()) {
            BString truncatedString(stringField->String());

            parent->TruncateString(&truncatedString, fTruncateMode, width + 2);
            stringField->SetClippedString(truncatedString.String());
            stringField->SetWidth(width);
        }

        DrawString(stringField->ClippedString(), parent, rect);

    } else if (ratingField != NULL) {

        const float kDefaultTextMargin = 8;

        float width = rect.Width() - (2 * kDefaultTextMargin);

        BString string = "★★★★★";
        float stringWidth = parent->StringWidth(string);
        bool drawOverlay = true;

        if (width < stringWidth) {
            string.SetToFormat("%.1f", ratingField->Rating());
            drawOverlay = false;
            stringWidth = parent->StringWidth(string);
        }

        switch (Alignment()) {
        default:
        case B_ALIGN_LEFT:
            rect.left += kDefaultTextMargin;
            break;
        case B_ALIGN_CENTER:
            rect.left = rect.left + (width - stringWidth) / 2.0f;
            break;

        case B_ALIGN_RIGHT:
            rect.left = rect.right - (stringWidth + kDefaultTextMargin);
            break;
        }

        rect.left = floorf(rect.left);
        rect.right = rect.left + stringWidth;

        if (drawOverlay)
            parent->SetHighColor(0, 170, 255);

        font_height	fontHeight;
        parent->GetFontHeight(&fontHeight);
        float y = rect.top + (rect.Height()
                              - (fontHeight.ascent + fontHeight.descent)) / 2
                  + fontHeight.ascent;

        parent->DrawString(string, BPoint(rect.left, y));

        if (drawOverlay) {
            rect.left = ceilf(rect.left
                              + (ratingField->Rating() / 5.0f) * rect.Width());

            rgb_color color = parent->LowColor();
            color.alpha = 190;
            parent->SetHighColor(color);

            parent->SetDrawingMode(B_OP_ALPHA);
            parent->FillRect(rect, B_SOLID_HIGH);

        }
    }
}
void UIFont::DrawString(float x, float y, int32 align, const tchar *string, const uint32 color)
{
	DrawString(x, y, align, string, color, 0.0f, 1.0f, 1.0f);
}
Exemple #10
0
int InstallData(char* drive){
	FIL firmfile;
	char* progressbar = "[       ]";
	char* progress = progressbar+1;
	print("%s", progressbar);  ConsolePrevLine();
	
	//Create the workdir
	sprintf(tmpstr, "%s:%s", drive, DATAFOLDER);
	f_mkdir(tmpstr);
	f_chmod(tmpstr, AM_HID, AM_HID);
	
	//Read firmware data
	if(f_open(&firmfile, "firmware.bin", FA_READ | FA_OPEN_EXISTING) == FR_OK){
		//... We'll see
	}else return CONF_NOFIRMBIN;
	*progress++ = '.'; DrawString(BOT_SCREEN, progressbar, 130, 50, ConsoleGetTextColor(), ConsoleGetBackgroundColor());
	
	//Create patched native_firm
	f_read(&firmfile, WORKBUF, NAT_SIZE, &tmpu32);
	u8* n_firm = decryptFirmTitle(WORKBUF, NAT_SIZE, 0x00000002);
	u8* n_firm_patch = GetFilePack("nat_patch.bin");
	applyPatch(n_firm, n_firm_patch);
	u8 keyx[16] = {0};
	if(GetSystemVersion() < 3){
		FileOpen(&tempfile, KEYFILENAME, 0);
		FileRead(&tempfile, &keyx[0], 16, 0);
		FileClose(&tempfile);
	}
	*progress++ = '.'; DrawString(BOT_SCREEN, progressbar, 130, 50, ConsoleGetTextColor(), ConsoleGetBackgroundColor());
	for(int i = 0; i < NAT_SIZE; i+=0x4){
		if(!strcmp((char*)n_firm + i, "Shit")){
			if(1){
				memcpy((char*)n_firm + i, rxmode_emu_label, 4);
			}else{
				memcpy((char*)n_firm + i, rxmode_sys_label , 4);
			}
		}
		if(!strcmp((char*)n_firm + i, "InsertKeyXHere!") && keyx[0] != 0){
			memcpy(n_firm + i, keyx, 16);
		}
		if(*((unsigned int*)(n_firm + i)) == 0xAAAABBBB){
			*((unsigned int*)(n_firm + i)) = (checkEmuNAND() / 0x200) - 1;
		}
	}
	*progress++ = '.'; DrawString(BOT_SCREEN, progressbar, 130, 50, ConsoleGetTextColor(), ConsoleGetBackgroundColor());
	sprintf(tmpstr, "%s:%s/0004013800000002.bin", drive, DATAFOLDER);
	if(FileOpen(&tempfile, tmpstr, 1)){
		FileWrite(&tempfile, n_firm, NAT_SIZE, 0);
		FileClose(&tempfile);
		//FileCopy("0004013800000002.bin", tmpstr);
	}else return CONF_ERRNFIRM;
	*progress++ = '.'; DrawString(BOT_SCREEN, progressbar, 130, 50, ConsoleGetTextColor(), ConsoleGetBackgroundColor());
	
	//Create AGB patched firmware
	f_read(&firmfile, WORKBUF, AGB_SIZE, &tmpu32);
	u8* a_firm = decryptFirmTitle(WORKBUF, AGB_SIZE, 0x00000202);
	u8* a_firm_patch = GetFilePack("agb_patch.bin");
	if(a_firm){
		applyPatch(a_firm, a_firm_patch);
		sprintf(tmpstr, "%s:%s/0004013800000202.bin", drive, DATAFOLDER);
		if(FileOpen(&tempfile, tmpstr, 1)){
			FileWrite(&tempfile, a_firm, AGB_SIZE, 0);
			FileClose(&tempfile);
		}else return CONF_ERRNFIRM;
		*progress++ = '.';
	}else{	
		//If we cannot decrypt it from firmware.bin becouse of titlekey messed up, it probably means that AGB has been modified in some way.
		//So we read it from his installed ncch...
		FindApp(0x00040138, 0x00000202, 1);
		char* path = getContentAppPath();
		FileOpen(&tempfile, path, 0);
		FileRead(&tempfile, WORKBUF, AGB_SIZE, 0);
		FileClose(&tempfile);
		a_firm = decryptFirmTitleNcch(WORKBUF, AGB_SIZE);
		if(a_firm){
			applyPatch(a_firm, a_firm_patch);
			sprintf(tmpstr, "%s:%s/0004013800000202.bin", drive, DATAFOLDER);
			if(FileOpen(&tempfile, tmpstr, 1)){
				FileWrite(&tempfile, a_firm, AGB_SIZE, 0);
				FileClose(&tempfile);
			}else return CONF_ERRNFIRM;
			*progress++ = '.';
		}else{
			*progress++ = 'x'; //If we get here, then we'll play without AGB, lol
		}
	}
	DrawString(BOT_SCREEN, progressbar, 130, 50, ConsoleGetTextColor(), ConsoleGetBackgroundColor());
	
	//Create TWL patched firmware
	f_read(&firmfile, WORKBUF, TWL_SIZE, &tmpu32);
	u8* t_firm = decryptFirmTitle(WORKBUF, TWL_SIZE, 0x00000102);
	u8* t_firm_patch = GetFilePack("twl_patch.bin");
	if(t_firm){
		applyPatch(t_firm, t_firm_patch);
		sprintf(tmpstr, "%s:%s/0004013800000102.bin", drive, DATAFOLDER);
		if(FileOpen(&tempfile, tmpstr, 1)){
			FileWrite(&tempfile, t_firm, TWL_SIZE, 0);
			FileClose(&tempfile);
			//FileCopy("0004013800000102.bin", tmpstr);
		}else return CONF_ERRNFIRM;
		*progress++ = '.'; 
	}else{
		*progress++ = 'x'; 
	}
	DrawString(BOT_SCREEN, progressbar, 130, 50, ConsoleGetTextColor(), ConsoleGetBackgroundColor());
	
	sprintf(tmpstr, "%s:%s/data.bin", drive, DATAFOLDER);
	if(FileOpen(&tempfile, tmpstr, 1)){
		FileWrite(&tempfile, __DATE__, 12, 0);
		FileWrite(&tempfile, __TIME__, 9, 12);
		FileClose(&tempfile);
	}else return CONF_CANTOPENFILE;
	*progress++ = '.'; DrawString(BOT_SCREEN, progressbar, 130, 50, ConsoleGetTextColor(), ConsoleGetBackgroundColor());
	
	f_close(&firmfile);
	return 0;
}
Exemple #11
0
void
ShowAdditionsWin(void)
{
	Str255		next, back;
	Str255		compDescTitle;
	StringPtr	selCompMsg;
	Handle		listBoxRect;
	Rect 		dataBounds, listBoxFrame, viewRect;
	short		reserr;
	int			totalRows = 0, i, instChoice;
	Point		cSize;
	Boolean		bCellSelected;
	GrafPtr		oldPort;
	GetPort(&oldPort);
		
	SetPort(gWPtr);
	
	gCurrWin = kAdditionsID; 
	/* gControls->aw = (CompWin *) NewPtrClear(sizeof(CompWin)); */
	
	GetResourcedString(next, rInstList, sNextBtn);
	GetResourcedString(back, rInstList, sBackBtn);

	// get controls
	listBoxRect = Get1Resource('RECT', rCompListBox);
	reserr = ResError(); 
	if (reserr == noErr && listBoxRect != NULL)
	{
		HLock((Handle)listBoxRect);
		SetRect(&gControls->aw->compListBox, 	((Rect*)*listBoxRect)->left,
												((Rect*)*listBoxRect)->top,
												((Rect*)*listBoxRect)->right,
												((Rect*)*listBoxRect)->bottom);
		HUnlock((Handle)listBoxRect);
	}
	else
	{
		ErrorHandler(reserr, nil);
		return;
	}
	gControls->aw->compDescBox = NULL;
	gControls->aw->compDescBox = GetNewControl(rCompDescBox, gWPtr);
	if (!gControls->aw->compDescBox)
	{
		ErrorHandler(eMem, nil);
		return;
	}

	gControls->aw->compListBox.right -= kScrollBarWidth;
	instChoice = gControls->opt->instChoice-1;
	for (i=0; i<kMaxComponents; i++)
	{
		if (totalRows >= gControls->cfg->numComps)
			break;
		if (!gControls->cfg->comp[i].invisible && gControls->cfg->comp[i].additional &&
			(gControls->cfg->st[instChoice].comp[i] == kInSetupType))
			totalRows++;
	}
		
	SetRect(&dataBounds, 0, 0, 1, totalRows);
	SetPt( &cSize, 0, 0);
	gControls->aw->compList = LNew((const Rect*)&gControls->aw->compListBox, (const Rect*)&dataBounds,
									cSize, rCheckboxLDEF, gWPtr, true, false, false, true);
	(*gControls->aw->compList)->selFlags = lExtendDrag + lUseSense + lDoVAutoscroll;
	
	HLock((Handle)gControls->aw->compDescBox);
	SetRect(&viewRect, (*gControls->aw->compDescBox)->contrlRect.left,
					   (*gControls->aw->compDescBox)->contrlRect.top,
					   (*gControls->aw->compDescBox)->contrlRect.right,
					   (*gControls->aw->compDescBox)->contrlRect.bottom);
	HUnlock((Handle)gControls->aw->compDescBox);
	viewRect.top += kInterWidgetPad;
	SetRect(&viewRect, viewRect.left + kTxtRectPad,
						viewRect.top + kTxtRectPad,
						viewRect.right - kTxtRectPad,
						viewRect.bottom - kTxtRectPad);
	TextFont(applFont);
	TextSize(9);
	gControls->aw->compDescTxt = TENew(&viewRect, &viewRect);
	TextFont(systemFont);
	TextSize(12);
	
	// populate controls
	bCellSelected = AddPopulateCompInfo();
	
	// show controls
	GetResourcedString(compDescTitle, rInstList, sCompDescTitle);
	SetControlTitle(gControls->aw->compDescBox, compDescTitle);
	
	MoveTo( gControls->aw->compListBox.left, gControls->aw->compListBox.top - kInterWidgetPad);
	HLock(gControls->cfg->selCompMsg);
	selCompMsg = CToPascal(*gControls->cfg->selAddMsg);
	if (selCompMsg)
		DrawString( selCompMsg );
	HUnlock(gControls->cfg->selCompMsg);
	SetRect(&listBoxFrame, gControls->aw->compListBox.left, 
						 --gControls->aw->compListBox.top,
						   gControls->aw->compListBox.right + kScrollBarWidth,
						 ++gControls->aw->compListBox.bottom);
	FrameRect(&listBoxFrame);
	ShowNavButtons( back, next );
	if (bCellSelected)
		AddSetOptInfo(true);
	else
		DrawDiskSpaceMsgs( gControls->opt->vRefNum );

	// default highlight first row
	AddInitRowHighlight(0);

#if 0	    
	RGBColor backColorOld;
    Rect adjustedRect, *clRect = &gControls->aw->compListBox;
    SetRect(&adjustedRect, clRect->left, clRect->top+1, clRect->right, clRect->bottom-1);
    GetBackColor(&backColorOld);
    BackColor(whiteColor);
    EraseRect(&adjustedRect);
    RGBBackColor(&backColorOld);
#endif
    
	SetPort(oldPort);
}
/*=============================================================================================*\
|	Draw																						|
+-----------------------------------------------------------------------------------------------+
|	Effet: Redessiner une partie de la view.													|
|	Entre: 																						|
|		BRect frame: Rectagle qui a besoin d'etre redessine.									|
\*=============================================================================================*/
void ShrinkView::Draw(BRect updateRect)
{
	BPoint pPointList[8];		//Utilise pour dessiner les polygone.
	rgb_color color = {0,0,0,0};
	rgb_color colorHigh = {0,0,0,0};
	
	SetDrawingMode(B_OP_COPY);
	if(m_pBmp)
	{
		uint32 * uiBits = (uint32*)m_pBmp->Bits();
		uint32 uiColor = uiBits[141];
		uint32 uiColorHigh = uiBits[289];
		
		color.red = ( uiColor & 0xFF0000) / 0x10000;
		color.green = (uiColor & 0xFF00) / 0x100;
		color.blue = (uiColor & 0xFF) ;
		colorHigh.red = ( uiColorHigh & 0xFF0000) / 0x10000;
		colorHigh.green = (uiColorHigh & 0xFF00) / 0x100;
		colorHigh.blue = (uiColorHigh & 0xFF) ;
			
	}

	//if(updateRect.left < 10)
	{
		if(m_pBmp)
		{
			DrawBitmap(m_pBmp, BRect(140,15,147,15), BRect(Bounds().Width() - 7, 16, Bounds().Width(), Bounds().Height() - 7));				 
		}

	}
	//if(updateRect.right > Bounds().Width()-10)
	{
		if(m_pBmp)
		{
			DrawBitmap(m_pBmp, BRect(140,14,147,14), BRect(0, 16, 7, Bounds().Height() - 7));

		}
	}
	
	
	//Dessiner l'etiquette si necessaire.
	if(updateRect.top < 16 && updateRect.right >= 16)
	{
		
		if(m_pBmp)
		{
			
			if(m_bShrink && m_bMouseOver)
			{
				DrawBitmap(m_pBmp, BRect(80,0,95,15), BRect(Bounds().Width() - 15,0,Bounds().Width(),15));
				DrawBitmap(m_pBmp, BRect(137,0,137,15), BRect(16, 0, Bounds().Width() - 15, 15)); 
			}
			else if(m_bShrink)
			{
				DrawBitmap(m_pBmp, BRect(64,0,79,15), BRect(Bounds().Width() - 15,0,Bounds().Width(),15));
				DrawBitmap(m_pBmp, BRect(136,0,136,15), BRect(16, 0, Bounds().Width() - 15, 15)); 
			}
			else if(m_bMouseOver)
			{
				DrawBitmap(m_pBmp, BRect(112,0,127,15), BRect(Bounds().Width() - 15,0,Bounds().Width(),15));
				DrawBitmap(m_pBmp, BRect(139,0,139,15), BRect(16, 0, Bounds().Width() - 15, 15)); 
			}
			else
			{
				DrawBitmap(m_pBmp, BRect(96,0,111,15), BRect(Bounds().Width() - 15,0,Bounds().Width(),15));
				DrawBitmap(m_pBmp, BRect(138,0,138,15), BRect(16, 0, Bounds().Width() - 15 , 15)); 
			}
			SetFont(be_bold_font);
					
			if(m_bMouseOver)
			{
				SetHighColor(colorHigh);
			}
			else
			{
				SetHighColor(color);
			}	
			SetDrawingMode(B_OP_OVER);
			DrawString(m_pzLabel, BPoint(18,12), NULL);	
			SetDrawingMode(B_OP_COPY);	
		}
		else
		{
			if(m_bShrink)
			{
				DrawDegrader(BRect(16,0,Bounds().Width(),4), 255, 192);
				DrawDegrader(BRect(16,11,Bounds().Width(),15), 192, 128);
			
				//Remplir le milieu de l'etiquette en gris
				SetHighColor(192, 192, 192, 0);
				FillRect(BRect(16, 5, Bounds().Width(), 10));
			}
			else	//Degrader du blanc au gris
			{
				DrawDegrader(BRect(16,0,Bounds().Width(),15), 255, 192);
			}
			SetFont(be_bold_font);
			SetHighColor(0, 0, 0, 0);
			SetDrawingMode(B_OP_OVER);
			DrawString(m_pzLabel, BPoint(18,12), NULL);
		}
	}
		
	//Redessiner le boutton si nessesaire.
	if(updateRect.left < 16 && updateRect.top < 16)
	{
		if(m_pBmp)
		{
			if(m_bShrink && m_bMouseOver)
			{
				DrawBitmap(m_pBmp, BRect(16,0,31,15), BRect(0,0,15,15));
			}
			else if(m_bShrink)
			{
				DrawBitmap(m_pBmp, BRect(0,0,15,15), BRect(0,0,15,15));
			}
			else if(m_bMouseOver)
			{
				DrawBitmap(m_pBmp, BRect(48,0,63,15), BRect(0,0,15,15));
			}
			else
			{
				DrawBitmap(m_pBmp, BRect(32,0,47,15), BRect(0,0,15,15));
			}
		
		}
		else
		{
			//Redessiner le degrader
			if(m_bShrink)
			{
				DrawDegrader(BRect(0, 0, 16, 4), 255, 192);
				DrawDegrader(BRect(0, 11, 16, 15), 192, 128);
			
				//Remplir le milieu de l'etiquette en gris
				SetHighColor(192, 192, 192, 0);
				FillRect(BRect(0, 5, 15, 10));
			}
			else	//Degrader du blanc au gris
			{
				DrawDegrader(BRect(0,0,15,15), 255, 192);
			}
		
			//Dessiner le Boutton si le curseur est au dessus du triangle.
			if( m_bMouseOver)
			{	
			SetHighColor(64, 64, 64, 0);
				pPointList[0] = BPoint(1,3);
				pPointList[1] = BPoint(3,1);
				pPointList[2] = BPoint(12,1);
				pPointList[3] = BPoint(14,3);
				pPointList[4] = BPoint(14,12);
				pPointList[5] = BPoint(12,14);
				pPointList[6] = BPoint(3,14);
				pPointList[7] = BPoint(1,12);
				StrokePolygon(pPointList, 8, true,  B_SOLID_HIGH);	
		
				SetHighColor(255, 255, 255, 0);
				pPointList[0] = BPoint(2,12);
				pPointList[1] = BPoint(2,3);
				pPointList[2] = BPoint(3,2);
				pPointList[3] = BPoint(12,2);
				StrokePolygon(pPointList, 4, false,  B_SOLID_HIGH);	
		
				SetHighColor(192, 192, 192, 0);
				pPointList[0] = BPoint(3,3);
				pPointList[1] = BPoint(12,3);
				pPointList[2] = BPoint(12,12);
				pPointList[3] = BPoint(3,12);
				FillPolygon(pPointList, 4,  B_SOLID_HIGH);	
		
				SetHighColor(128, 128, 128, 0);
				pPointList[0] = BPoint(13,3);
				pPointList[1] = BPoint(13,12);
				pPointList[2] = BPoint(12,13);
				pPointList[3] = BPoint(3,13);
				StrokePolygon(pPointList, 4, false,  B_SOLID_HIGH);	
			}
	
			//Dessiner le triangle vers la droite.
			// La View est reduite.
			if(m_bShrink)
			{
			SetHighColor(0, 0, 0, 256);
				pPointList[0] = BPoint(9,7);
				pPointList[1] = BPoint(6,4);
				pPointList[2] = BPoint(6,11);
				pPointList[3] = BPoint(9,8);
				FillPolygon(pPointList, 4, B_SOLID_HIGH);
			}
			//Dessiner le triangle vers le bas.
			// La View est agrandi.
			else
			{
				SetHighColor(0, 0, 0, 256);
				pPointList[0] = BPoint(7,9);
				pPointList[1] = BPoint(4,6);
				pPointList[2] = BPoint(11,6);
				pPointList[3] = BPoint(8,9);
				FillPolygon(pPointList, 4, B_SOLID_HIGH);
			}
		}
	}
	
	//Redessiner le degrader du bas si necessaire
	if(!m_bShrink && updateRect.bottom > Bounds().Height() - 8)
	{
		if(m_pBmp)
		{
			DrawBitmap(m_pBmp, BRect(128,0,135,7), BRect(0,Bounds().Height()-7,7,Bounds().Height()));
			DrawBitmap(m_pBmp, BRect(128,8,135,15), BRect(Bounds().Width() - 7,Bounds().Height()-7,Bounds().Width(),Bounds().Height()));
			DrawBitmap(m_pBmp, BRect(140,0,140,7), BRect(8, Bounds().Height()-7, Bounds().Width() - 7, Bounds().Height())); 
		}
		else
		{
			DrawDegrader(BRect(0,Bounds().bottom - 8,Bounds().Width(),Bounds().bottom), 192, 128);
		}
	} 
}//End of Draw.
Exemple #13
0
void Draw_Stage5(){ //ステージ5の描画に関する関数
	DrawString(0, 30, "ステージ5です。", WHITE);
	DrawBox(320, 120, 380, 180, PINK, true);
	DrawBox(520, 320, 580, 380, PINK, true);
	DrawBox(600, 0, 640, 70, PINK, true);
}
Exemple #14
0
void Label::OnPaint()
{
	SetColor(color.r, color.g, color.b);
	DrawString(this->text, this->X, this->Y);
}
void MyApp::DrawHelp()
{
	int lineStart(LINE_START);
	int lineStep(LINE_STEP);

	//! 显示地图信息
	DrawString(0, lineStart, CLR_WHITE, "-------Help Info-------");
	lineStart += lineStep;

	DrawString(0, lineStart, CLR_WHITE, "ShowHelpInfo: H");
	lineStart += lineStep;
	DrawString(0, lineStart, CLR_WHITE, "ResetSpaceRect: Home");
	lineStart += lineStep;
	DrawString(0, lineStart, CLR_WHITE, "Quit: ESC");
	lineStart += lineStep;
	DrawString(0, lineStart, CLR_WHITE, "ShowConfigValue: C");
	lineStart += lineStep;
	DrawString(0, lineStart, CLR_WHITE, "SetSingleMode: S");
	lineStart += lineStep;
	DrawString(0, lineStart, CLR_WHITE, "ChangeNextSpace: N");
	lineStart += lineStep;
	DrawString(0, lineStart, CLR_WHITE, "ShowEntityProp: P");
	lineStart += lineStep;
	DrawString(0, lineStart, CLR_WHITE, "ShowEntityID: I");
	lineStart += lineStep;
	DrawString(0, lineStart, CLR_WHITE, "ShowRobotID: R");
	lineStart += lineStep;
	DrawString(0, lineStart, CLR_WHITE, "ShowEntityPos: Z");
	lineStart += lineStep;

	DrawString(0, lineStart, CLR_WHITE, "-------Cmd Info-------");
	lineStart += lineStep;

	int w,h;
	GetWindowSize(w,h);
	int infoHeight = h-lineStart-LINE_BOTTOM;
	if(infoHeight < lineStep)
		return;

	const FvRobotCfg::Items& kItems = FvRobotCfg::Instance().GetItems();
	if(kItems.empty())
		return;

	int iItemsPerPage = infoHeight / lineStep;
	int iPages = (kItems.size() + iItemsPerPage-1) / iItemsPerPage;
	if(m_iInfoPage4Help >= iPages)
		m_iInfoPage4Help = iPages-1;

	int iStart = m_iInfoPage4Help*iItemsPerPage;
	int i = iStart;
	for(; i<iStart+iItemsPerPage && i<(int)kItems.size(); ++i)
	{
		DrawString(0, lineStart, CLR_WHITE, kItems[i].GetCmdStr().c_str());
		lineStart += lineStep;
	}

	if(m_iInfoPage4Help==0 && m_iInfoPage4Help<iPages-1)
	{
		DrawString(0, lineStart, CLR_WHITE, "-------Press Page Down-------");
		lineStart += lineStep;
	}
	else if(0<m_iInfoPage4Help && m_iInfoPage4Help<iPages-1)
	{
		DrawString(0, lineStart, CLR_WHITE, "-------Press Page UP/Down-------");
		lineStart += lineStep;
	}
	else if(0<m_iInfoPage4Help && m_iInfoPage4Help==iPages-1)
	{
		DrawString(0, lineStart, CLR_WHITE, "-------Press Page UP-------");
		lineStart += lineStep;
	}
}
void
BButton::Draw(BRect updateRect)
{
	if (be_control_look != NULL) {
		BRect rect(Bounds());
		rgb_color background = LowColor();
		rgb_color base = background;
		uint32 flags = be_control_look->Flags(this);
		if (IsDefault())
			flags |= BControlLook::B_DEFAULT_BUTTON;
		be_control_look->DrawButtonFrame(this, rect, updateRect,
			base, background, flags);
		be_control_look->DrawButtonBackground(this, rect, updateRect,
			base, flags);

		// always leave some room around the label
		rect.InsetBy(3.0, 3.0);
		be_control_look->DrawLabel(this, Label(), rect, updateRect,
			base, flags, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));
		return;
	}

	font_height fh;
	GetFontHeight(&fh);

	const BRect bounds = Bounds();
	BRect rect = bounds;

	const bool enabled = IsEnabled();
	const bool pushed = Value() == B_CONTROL_ON;
	// Default indicator
	if (IsDefault())
		rect = _DrawDefault(rect, enabled);

	BRect fillArea = rect;
	fillArea.InsetBy(3.0, 3.0);

	BString text = Label();

#if 1
	// Label truncation
	BFont font;
	GetFont(&font);
	font.TruncateString(&text, B_TRUNCATE_END, fillArea.Width() - 4);
#endif

	// Label position
	const float stringWidth = StringWidth(text.String());
	const float x = (rect.right - stringWidth) / 2.0;
	const float labelY = bounds.top
		+ ((bounds.Height() - fh.ascent - fh.descent) / 2.0)
		+ fh.ascent + 1.0;
	const float focusLineY = labelY + fh.descent;

	/* speed trick:
	   if the focus changes but the button is not pressed then we can
	   redraw only the focus line,
	   if the focus changes and the button is pressed invert the internal rect
	   this block takes care of all the focus changes
	*/
	if (IsFocusChanging()) {
		if (pushed) {
			rect.InsetBy(2.0, 2.0);
			InvertRect(rect);
		} else {
			_DrawFocusLine(x, focusLineY, stringWidth, IsFocus()
				&& Window()->IsActive());
		}

		return;
	}

	// colors
	rgb_color panelBgColor = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color buttonBgColor = tint_color(panelBgColor, B_LIGHTEN_1_TINT);
	rgb_color lightColor;
	rgb_color maxLightColor;

	rgb_color dark1BorderColor;
	rgb_color dark2BorderColor;

	rgb_color bevelColor1;
	rgb_color bevelColor2;
	rgb_color bevelColorRBCorner;

	rgb_color borderBevelShadow;
	rgb_color borderBevelLight;

	if (enabled) {
		lightColor = tint_color(panelBgColor, B_LIGHTEN_2_TINT);
		maxLightColor = tint_color(panelBgColor, B_LIGHTEN_MAX_TINT);

		dark1BorderColor = tint_color(panelBgColor, B_DARKEN_3_TINT);
		dark2BorderColor = tint_color(panelBgColor, B_DARKEN_4_TINT);

		bevelColor1 = tint_color(panelBgColor, B_DARKEN_2_TINT);
		bevelColor2 = panelBgColor;

		if (IsDefault()) {
			borderBevelShadow = tint_color(dark1BorderColor,
				(B_NO_TINT + B_DARKEN_1_TINT) / 2);
			borderBevelLight = tint_color(dark1BorderColor, B_LIGHTEN_1_TINT);

			borderBevelLight.red = (borderBevelLight.red + panelBgColor.red)
				/ 2;
			borderBevelLight.green = (borderBevelLight.green
				+ panelBgColor.green) / 2;
			borderBevelLight.blue = (borderBevelLight.blue
				+ panelBgColor.blue) / 2;

			dark1BorderColor = tint_color(dark1BorderColor, B_DARKEN_3_TINT);
			dark2BorderColor = tint_color(dark1BorderColor, B_DARKEN_4_TINT);

			bevelColorRBCorner = borderBevelShadow;
		} else {
			borderBevelShadow = tint_color(panelBgColor,
				(B_NO_TINT + B_DARKEN_1_TINT) / 2);
			borderBevelLight = buttonBgColor;

			bevelColorRBCorner = dark1BorderColor;
		}
	} else {
		lightColor = tint_color(panelBgColor, B_LIGHTEN_2_TINT);
		maxLightColor = tint_color(panelBgColor, B_LIGHTEN_1_TINT);

		dark1BorderColor = tint_color(panelBgColor, B_DARKEN_1_TINT);
		dark2BorderColor = tint_color(panelBgColor, B_DARKEN_2_TINT);

		bevelColor1 = panelBgColor;
		bevelColor2 = buttonBgColor;

		if (IsDefault()) {
			borderBevelShadow = dark1BorderColor;
			borderBevelLight = panelBgColor;
			dark1BorderColor = tint_color(dark1BorderColor, B_DARKEN_1_TINT);
			dark2BorderColor = tint_color(dark1BorderColor, 1.16);

		} else {
			borderBevelShadow = panelBgColor;
			borderBevelLight = panelBgColor;
		}

		bevelColorRBCorner = tint_color(panelBgColor, 1.08);;
	}

	// fill the button area
	SetHighColor(buttonBgColor);
	FillRect(fillArea);

	BeginLineArray(22);
	// bevel around external border
	AddLine(BPoint(rect.left, rect.bottom),
			BPoint(rect.left, rect.top), borderBevelShadow);
	AddLine(BPoint(rect.left + 1, rect.top),
			BPoint(rect.right, rect.top), borderBevelShadow);

	AddLine(BPoint(rect.right, rect.top + 1),
			BPoint(rect.right, rect.bottom), borderBevelLight);
	AddLine(BPoint(rect.left + 1, rect.bottom),
			BPoint(rect.right - 1, rect.bottom), borderBevelLight);

	rect.InsetBy(1.0, 1.0);

	// external border
	AddLine(BPoint(rect.left, rect.bottom),
			BPoint(rect.left, rect.top), dark1BorderColor);
	AddLine(BPoint(rect.left + 1, rect.top),
			BPoint(rect.right, rect.top), dark1BorderColor);
	AddLine(BPoint(rect.right, rect.top + 1),
			BPoint(rect.right, rect.bottom), dark2BorderColor);
	AddLine(BPoint(rect.right - 1, rect.bottom),
			BPoint(rect.left + 1, rect.bottom), dark2BorderColor);

	rect.InsetBy(1.0, 1.0);

	// Light
	AddLine(BPoint(rect.left, rect.top),
			BPoint(rect.left, rect.top), buttonBgColor);
	AddLine(BPoint(rect.left, rect.top + 1),
			BPoint(rect.left, rect.bottom - 1), lightColor);
	AddLine(BPoint(rect.left, rect.bottom),
			BPoint(rect.left, rect.bottom), bevelColor2);
	AddLine(BPoint(rect.left + 1, rect.top),
			BPoint(rect.right - 1, rect.top), lightColor);
	AddLine(BPoint(rect.right, rect.top),
			BPoint(rect.right, rect.top), bevelColor2);
	// Shadow
	AddLine(BPoint(rect.left + 1, rect.bottom),
			BPoint(rect.right - 1, rect.bottom), bevelColor1);
	AddLine(BPoint(rect.right, rect.bottom),
			BPoint(rect.right, rect.bottom), bevelColorRBCorner);
	AddLine(BPoint(rect.right, rect.bottom - 1),
			BPoint(rect.right, rect.top + 1), bevelColor1);

	rect.InsetBy(1.0, 1.0);

	// Light
	AddLine(BPoint(rect.left, rect.top),
			BPoint(rect.left, rect.bottom - 1), maxLightColor);
	AddLine(BPoint(rect.left, rect.bottom),
			BPoint(rect.left, rect.bottom), buttonBgColor);
	AddLine(BPoint(rect.left + 1, rect.top),
			BPoint(rect.right - 1, rect.top), maxLightColor);
	AddLine(BPoint(rect.right, rect.top),
			BPoint(rect.right, rect.top), buttonBgColor);
	// Shadow
	AddLine(BPoint(rect.left + 1, rect.bottom),
			BPoint(rect.right, rect.bottom), bevelColor2);
	AddLine(BPoint(rect.right, rect.bottom - 1),
			BPoint(rect.right, rect.top + 1), bevelColor2);

	rect.InsetBy(1.0,1.0);

	EndLineArray();

	// Invert if clicked
	if (enabled && pushed) {
		rect.InsetBy(-2.0, -2.0);
		InvertRect(rect);
	}

	// Label color
	if (enabled) {
		if (pushed) {
			SetHighColor(maxLightColor);
			SetLowColor(255 - buttonBgColor.red,
						255 - buttonBgColor.green,
						255 - buttonBgColor.blue);
		} else {
			SetHighColor(ui_color(B_CONTROL_TEXT_COLOR));
			SetLowColor(buttonBgColor);
		}
	} else {
		SetHighColor(tint_color(panelBgColor, B_DISABLED_LABEL_TINT));
		SetLowColor(buttonBgColor);
	}

	// Draw the label
	DrawString(text.String(), BPoint(x, labelY));

	// Focus line
	if (enabled && IsFocus() && Window()->IsActive() && !pushed)
		_DrawFocusLine(x, focusLineY, stringWidth, true);
}
Exemple #17
0
/*
================
SCR_ExecuteLayoutString 

================
*/
void SCR_ExecuteLayoutString (char *s)
{
	int		x, y;
	int		value;
	char	*token;
	int		width;
	int		index;
	clientinfo_t	*ci;

	if (cls.state != ca_active || !cl.refresh_prepped)
		return;

	if (!s[0])
		return;

	x = 0;
	y = 0;
	width = 3;

	while (s)
	{
		token = COM_Parse (&s);
		if (!strcmp(token, "xl"))
		{
			token = COM_Parse (&s);
			x = atoi(token);
			continue;
		}
		if (!strcmp(token, "xr"))
		{
			token = COM_Parse (&s);
			x = viddef.width + atoi(token);
			continue;
		}
		if (!strcmp(token, "xv"))
		{
			token = COM_Parse (&s);
			x = viddef.width/2 - 160 + atoi(token);
			continue;
		}

		if (!strcmp(token, "yt"))
		{
			token = COM_Parse (&s);
			y = atoi(token);
			continue;
		}
		if (!strcmp(token, "yb"))
		{
			token = COM_Parse (&s);
			y = viddef.height + atoi(token);
			continue;
		}
		if (!strcmp(token, "yv"))
		{
			token = COM_Parse (&s);
			y = viddef.height/2 - 120 + atoi(token);
			continue;
		}

		if (!strcmp(token, "pic"))
		{	// draw a pic from a stat number
			token = COM_Parse (&s);
			value = cl.frame.playerstate.stats[atoi(token)];
			if (value >= MAX_IMAGES)
				Com_Error (ERR_DROP, "Pic >= MAX_IMAGES");
			if (cl.configstrings[CS_IMAGES+value])
			{
				SCR_AddDirtyPoint (x, y);
				SCR_AddDirtyPoint (x+23, y+23);
				re.DrawPic (x, y, cl.configstrings[CS_IMAGES+value]);
			}
			continue;
		}

		if (!strcmp(token, "client"))
		{	// draw a deathmatch client block
			int		score, ping, time;

			token = COM_Parse (&s);
			x = viddef.width/2 - 160 + atoi(token);
			token = COM_Parse (&s);
			y = viddef.height/2 - 120 + atoi(token);
			SCR_AddDirtyPoint (x, y);
			SCR_AddDirtyPoint (x+159, y+31);

			token = COM_Parse (&s);
			value = atoi(token);
			if (value >= MAX_CLIENTS || value < 0)
				Com_Error (ERR_DROP, "client >= MAX_CLIENTS");
			ci = &cl.clientinfo[value];

			token = COM_Parse (&s);
			score = atoi(token);

			token = COM_Parse (&s);
			ping = atoi(token);

			token = COM_Parse (&s);
			time = atoi(token);

			DrawAltString (x+32, y, ci->name);
			DrawString (x+32, y+8,  "Score: ");
			DrawAltString (x+32+7*8, y+8,  va("%i", score));
			DrawString (x+32, y+16, va("Ping:  %i", ping));
			DrawString (x+32, y+24, va("Time:  %i", time));

			if (!ci->icon)
				ci = &cl.baseclientinfo;
			re.DrawPic (x, y, ci->iconname);
			continue;
		}

		if (!strcmp(token, "ctf"))
		{	// draw a ctf client block
			int		score, ping;
			char	block[80];

			token = COM_Parse (&s);
			x = viddef.width/2 - 160 + atoi(token);
			token = COM_Parse (&s);
			y = viddef.height/2 - 120 + atoi(token);
			SCR_AddDirtyPoint (x, y);
			SCR_AddDirtyPoint (x+159, y+31);

			token = COM_Parse (&s);
			value = atoi(token);
			if (value >= MAX_CLIENTS || value < 0)
				Com_Error (ERR_DROP, "client >= MAX_CLIENTS");
			ci = &cl.clientinfo[value];

			token = COM_Parse (&s);
			score = atoi(token);

			token = COM_Parse (&s);
			ping = atoi(token);
			if (ping > 999)
				ping = 999;

			sprintf(block, "%3d %3d %-12.12s", score, ping, ci->name);

			if (value == cl.playernum)
				DrawAltString (x, y, block);
			else
				DrawString (x, y, block);
			continue;
		}

		if (!strcmp(token, "picn"))
		{	// draw a pic from a name
			token = COM_Parse (&s);
			SCR_AddDirtyPoint (x, y);
			SCR_AddDirtyPoint (x+23, y+23);
			re.DrawPic (x, y, token);
			continue;
		}

		if (!strcmp(token, "num"))
		{	// draw a number
			token = COM_Parse (&s);
			width = atoi(token);
			token = COM_Parse (&s);
			value = cl.frame.playerstate.stats[atoi(token)];
			SCR_DrawField (x, y, 0, width, value);
			continue;
		}

		if (!strcmp(token, "hnum"))
		{	// health number
			int		color;

			width = 3;
			value = cl.frame.playerstate.stats[STAT_HEALTH];
			if (value > 25)
				color = 0;	// green
			else if (value > 0)
				color = (cl.frame.serverframe>>2) & 1;		// flash
			else
				color = 1;

			if (cl.frame.playerstate.stats[STAT_FLASHES] & 1)
				re.DrawPic (x, y, "field_3");

			SCR_DrawField (x, y, color, width, value);
			continue;
		}
NS_IMETHODIMP
nsThebesRenderingContext::DrawString(const nsString& aString, nscoord aX, nscoord aY,
                                     PRInt32 aFontID, const nscoord* aSpacing)
{
    return DrawString(aString.get(), aString.Length(), aX, aY, aFontID, aSpacing);
}
Exemple #19
0
void Reflektor_Display()
{
	// kolor tła - zawartośæ bufora koloru
	glClearColor(1.0, 1.0, 1.0, 1.0);

	// czyszczenie bufora koloru i bufora głêbokości
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// wybór macierzy modelowania
	glMatrixMode(GL_MODELVIEW);

	// macierz modelowania = macierz jednostkowa
	glLoadIdentity();

	// włączenie testu bufora głêbokości
	glEnable(GL_DEPTH_TEST);

	// włączenie oświetlenia
	glEnable(GL_LIGHTING);

	// włączenie światła GL_LIGHT0
	glEnable(GL_LIGHT0);

	// włączenie automatycznej normalizacji wektorów normalnych
	glEnable(GL_NORMALIZE);

	// przesuniêcie układu współrzêdnych obiektu do środka bryły odcinania
	glTranslatef(0, 0, -(near + far) / 2);

	// obroty obiektu
	glRotatef(rotatex, 1.0, 0, 0);
	glRotatef(rotatey, 0, 1.0, 0);

	// skalowanie obiektu - klawisze "+" i "-"
	glScalef(scale, scale, scale);

	// właściwości materiału
	glMaterialfv(GL_FRONT, GL_AMBIENT, ambient);
	glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse);
	glMaterialfv(GL_FRONT, GL_SPECULAR, specular);
	glMaterialf(GL_FRONT, GL_SHININESS, shininess);

	// kąt odciêcia reflektora
	glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, spot_cutoff);

	// wykładnik tłumienia kątowego reflektora
	glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, spot_exponent);

	// stały współczynnik tłumienia światła,
	glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, constant_attenuation);

	// liniowy współczynnik tłumienia światła
	glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, linear_attenuation);

	// kwadratowy współczynnik tłumienia światła
	glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, quadratic_attenuation);

	// zmiana położenia źródła światła jest wykonywana niezależnie
	// od obrotów obiektu, stąd odłożenie na stos macierzy modelowania
	glPushMatrix();

	// macierz modelowania = macierz jednostkowa
	glLoadIdentity();

	// przesuniêcie układu współrzêdnych źródła światła do środka bryły odcinania
	glTranslatef(0, 0, -(near + far) / 2);

	// obroty położenia źródła światła - klawisze kursora
	glRotatef(light_rotatexx, 1.0, 0, 0);
	glRotatef(light_rotateyy, 0, 1.0, 0);

	// przesuniêcie źródła światła
	glTranslatef(light_position[0], light_position[1], light_position[2]);

	// ustalenie pozycji źródła światła
	glLightfv(GL_LIGHT0, GL_POSITION, light_position);

	// ustalenie kierunku reflektora
	glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, spot_direction);

	// odłożenie na stos zmiennych stanu związanych z oświetleniem sceny
	glPushAttrib(GL_LIGHTING_BIT);

	// wyłacznie źródła światła GL_LIGHT0
	glDisable(GL_LIGHT0);

	// materiał imitujący świecenie kuli na czerwono
	glMaterialfv(GL_FRONT, GL_EMISSION, Red);

	// narysowanie kuli położonej w początku źródła światła
	glutSolidSphere(0.1, 30, 20);

	// przywrócenie zmiennych stanu związanych z oświetleniem sceny
	glPopAttrib();

	// przywrócenie pierwotnej macierzy modelowania
	glPopMatrix();

	glBegin(GL_TRIANGLES);
	glVertex3f(0.0, 0.0, -0.5);
	glVertex3f(0.5, 0.0, 0.5);
	glVertex3f(-0.5, 0.0, 0.5);

	glVertex3f(0.0, 0.8, 0.0);
	glVertex3f(-0.5, 0.0, 0.5);
	glVertex3f(0.5, 0.0, 0.5);

	glVertex3f(0.0, 0.8, 0.0);
	glVertex3f(0.0, 0.0, -0.5);
	glVertex3f(-0.5, 0.0, 0.5);

	glVertex3f(0.0, 0.8, 0.0);
	glVertex3f(0.0, 0.0, 0.5);
	glVertex3f(0.0, 0.0, -0.5);

	glEnd();

	// informacje o wartościach modyfikowanych
	// parametrów źródła światała GL_LIGHT0
	char string[200];
	GLfloat vec[4];
	glColor3fv(Black);

	// trzeba odpowiednio przekształciæ układ współrzędnych
	// aby napis znajdował się na samej "górze" bryły obcinania
	glLoadIdentity();
	glTranslatef(0, 0, -near);


	// kierunek źródła światła
	glGetLightfv(GL_LIGHT0, GL_POSITION, vec);
	sprintf(string, "GL_POSITION = (%f,%f,%f,%f)", vec[0], vec[1], vec[2], vec[3]);
	DrawString((float)left, (float)bottom, string);

	glGetLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, vec);
	sprintf(string, "GL_SPOT_DIRECTION = (%f,%f,%f)", vec[0], vec[1], vec[2]);

	// kąt odciêcia reflektora
	glGetLightfv(GL_LIGHT0, GL_SPOT_CUTOFF, vec);
	sprintf(string, "GL_SPOT_CUTOFF = %f", vec[0]);
	DrawString(2, 30, string);

	// wykładnik tłumienia kątowego reflektora
	glGetLightfv(GL_LIGHT0, GL_SPOT_EXPONENT, vec);
	sprintf(string, "GL_SPOT_EXPONENT = %f", vec[0]);
	DrawString(2, 44, string);

	// stały współczynnik tłumienia światła,
	glGetLightfv(GL_LIGHT0, GL_CONSTANT_ATTENUATION, vec);
	sprintf(string, "GL_CONSTANT_ATTENUATION = %f", vec[0]);
	DrawString(2, 58, string);

	// liniowy współczynnik tłumienia światła
	glGetLightfv(GL_LIGHT0, GL_LINEAR_ATTENUATION, vec);
	sprintf(string, "GL_LINEAR_ATTENUATION = %f", vec[0]);
	DrawString(2, 72, string);

	// kwadratowy współczynnik tłumienia światła
	glGetLightfv(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, vec);
	sprintf(string, "GL_QUADRATIC_ATTENUATION = %f", vec[0]);
	DrawString(2, 86, string);

	// skierowanie poleceñ do wykonania
	glFlush();

	// zamiana buforów koloru
	glutSwapBuffers();
}
Exemple #20
0
void BSizeColumn::DrawField(BField* _field, BRect rect, BView* parent)
{
	char		str[256];
	float		width = rect.Width() - (2 * kTEXT_MARGIN);
	BFont		font;
	BString		string;
	off_t		size = ((BSizeField*)_field)->Size();

	parent->GetFont(&font);
	if (size < kKB_SIZE)
	{
		sprintf(str, "%Ld bytes", size);
		if (font.StringWidth(str) > width)
			sprintf(str, "%Ld B", size);
	}
	else
	{
		const char*	suffix;
		float 		float_value;
		if (size >= kTB_SIZE)
		{
			suffix = "TB";
			float_value = (float)size / kTB_SIZE;
		}
		else if (size >= kGB_SIZE)
		{
			suffix = "GB";
			float_value = (float)size / kGB_SIZE;
		}
		else if (size >= kMB_SIZE)
		{
			suffix = "MB";
			float_value = (float)size / kMB_SIZE;
		}
		else
		{
			suffix = "KB";
			float_value = (float)size / kKB_SIZE;
		}

		for (int32 index = 0; ; index++)
		{
			if (!kSIZE_FORMATS[index])
				break;

			sprintf(str, kSIZE_FORMATS[index], float_value, suffix);
			// strip off an insignificant zero so we don't get readings
			// such as 1.00
			char *period = 0;
			char *tmp (NULL);
			for (tmp = str; *tmp; tmp++)
			{
				if (*tmp == '.')
					period = tmp;
			}
			if (period && period[1] && period[2] == '0')
				// move the rest of the string over the insignificant zero
				for (tmp = &period[2]; *tmp; tmp++)
					*tmp = tmp[1];
			if (font.StringWidth(str) <= width)
				break;
		}
	}


	string = str;
	parent->TruncateString(&string, B_TRUNCATE_MIDDLE, width + 2);
	DrawString(string.String(), parent, rect);
}
Exemple #21
0
// DrawString
BRect
Painter::DrawString(const char* utf8String, const escapement_delta* delta)
{
	// TODO: to be moved elsewhere
	return DrawString(utf8String, strlen(utf8String), fPenLocation, delta);
}
void
GameView::Draw(BRect rect)
{
	SetDrawingMode(B_OP_ALPHA);
	
	// Draw slots
	BPoint deckPoints[]={ BPoint(-80,4),BPoint(-80,116),BPoint(0,116),
		BPoint(0,4)};
	BPolygon* deck;
	
	for (int i=0;i<8;i++) {
		if (i==4) {
			for (int j=0;j<4;j++) {
				deckPoints[j].x+=80+4;
			}
		}
		for (int j=0;j<4;j++) {
			deckPoints[j].x+=80+4;
		}
		deck=new BPolygon(deckPoints,4);
		
		StrokePolygon(deck);
		
		if (board[i]!=NULL) {
			DrawBitmap(board[i]->img,deck->Frame());
		}
	}
	// Draw cards
	short row=0;
	short stack=0;
	
	for (short i=8;i<200;i++) {
		BBitmap* img=NULL;
		if (board[i]!=NULL) {
			img=board[i]->img;
		}
		BPoint pt(85*(stack+1),40*(row+4));
		DrawBitmapAsync(img,pt);
		row++;
		if (row==26) {
			row=0;
			stack++;
		}
	}
	Sync();
	
	// Draw Points
	
	BString movesText="";
	movesText << moves;
	
	BFont bigFont;
	bigFont.SetFace(B_BOLD_FACE);
	bigFont.SetSize(18);
	
	BFont smallFont;
	smallFont.SetSize(12);
	
	SetHighColor(255,255,255);

	SetFont(&bigFont);
	DrawString(movesText, BPoint((width+10 - bigFont.StringWidth(movesText)) / 2, height-15));

	SetFont(&smallFont);
	DrawString("Moves", BPoint((width+10   - smallFont.StringWidth("Moves")) / 2, height));
}
void
MemoryView::Draw(BRect rect)
{
	rect = Bounds();

	float divider = (fTargetAddressSize + 1) * fCharWidth;
	StrokeLine(BPoint(divider, rect.top),
				BPoint(divider, rect.bottom));

	if (fTargetBlock == NULL)
		return;

	uint32 hexBlockSize = (1 << fHexMode) + 1;
	uint32 blockByteSize = hexBlockSize / 2;
	if (fHexMode != HexModeNone && fTextMode != TextModeNone) {
		divider += (fHexBlocksPerLine * hexBlockSize + 1) * fCharWidth;
		StrokeLine(BPoint(divider, rect.top),
					BPoint(divider, rect.bottom));
	}

	char buffer[32];
	char textbuffer[512];

	int32 startLine = int32(rect.top / fLineHeight);
	const char* currentAddress = (const char*)(fTargetBlock->Data()
		+ fHexBlocksPerLine * blockByteSize * startLine);
	const char* maxAddress = (const char*)(fTargetBlock->Data()
		+ fTargetBlock->Size());
	const char* targetAddress = (const char *)fTargetBlock->Data()
		+ fTargetAddress - fTargetBlock->BaseAddress();
	BPoint drawPoint(1.0, (startLine + 1) * fLineHeight);
	int32 currentBlocksPerLine = fHexBlocksPerLine;
	int32 currentCharsPerLine = fTextCharsPerLine;
	rgb_color addressColor = tint_color(HighColor(), B_LIGHTEN_1_TINT);
	rgb_color dataColor = HighColor();
	font_height fh;
	GetFontHeight(&fh);
	target_addr_t lineAddress = fTargetBlock->BaseAddress() + startLine
		* currentCharsPerLine;
	for (; currentAddress < maxAddress && drawPoint.y < rect.bottom
		+ fLineHeight; drawPoint.y += fLineHeight) {
		drawPoint.x = 1.0;
		snprintf(buffer, sizeof(buffer), "%0*" B_PRIx64,
			(int)fTargetAddressSize, lineAddress);
		PushState();
		SetHighColor(tint_color(HighColor(), B_LIGHTEN_1_TINT));
		DrawString(buffer, drawPoint);
		drawPoint.x += fCharWidth * (fTargetAddressSize + 2);
		PopState();

		if (fHexMode != HexModeNone) {
			if (currentAddress + (currentBlocksPerLine * blockByteSize)
				> maxAddress) {
				currentCharsPerLine = maxAddress - currentAddress;
				currentBlocksPerLine = currentCharsPerLine
					/ blockByteSize;
			}

			for (int32 j = 0; j < currentBlocksPerLine; j++) {
				const char* blockAddress = currentAddress + (j
					* blockByteSize);
				_GetNextHexBlock(buffer,
					std::min((size_t)hexBlockSize, sizeof(buffer)),
					blockAddress);
				DrawString(buffer, drawPoint);
				if (targetAddress >= blockAddress && targetAddress <
					blockAddress + blockByteSize) {
					PushState();
					SetHighColor(B_TRANSPARENT_COLOR);
					SetDrawingMode(B_OP_INVERT);
					FillRect(BRect(drawPoint.x, drawPoint.y - fh.ascent,
						drawPoint.x + (hexBlockSize - 1) * fCharWidth,
						drawPoint.y + fh.descent));
					PopState();
				}

				drawPoint.x += fCharWidth * hexBlockSize;
			}

			if (currentBlocksPerLine < fHexBlocksPerLine)
				drawPoint.x += fCharWidth * hexBlockSize
					* (fHexBlocksPerLine - currentBlocksPerLine);
		}
		if (fTextMode != TextModeNone) {
			drawPoint.x += fCharWidth;
			for (int32 j = 0; j < currentCharsPerLine; j++) {
				// filter non-printable characters
				textbuffer[j] = currentAddress[j] > 32 ? currentAddress[j]
					: '.';
			}
			textbuffer[fTextCharsPerLine] = '\0';
			DrawString(textbuffer, drawPoint);
			if (targetAddress >= currentAddress && targetAddress
				< currentAddress + currentCharsPerLine) {
				PushState();
				SetHighColor(B_TRANSPARENT_COLOR);
				SetDrawingMode(B_OP_INVERT);
				uint32 blockAddress = uint32(targetAddress - currentAddress);
				if (fHexMode != HexModeNone)
					blockAddress &= ~(blockByteSize - 1);
				float startX = drawPoint.x + fCharWidth * blockAddress;
				float endX = startX;
				if (fHexMode != HexModeNone)
					endX += fCharWidth * ((hexBlockSize - 1) / 2);
				else
					endX += fCharWidth;
				FillRect(BRect(startX, drawPoint.y - fh.ascent, endX,
					drawPoint.y + fh.descent));
				PopState();
			}
		}
		if (currentBlocksPerLine > 0) {
			currentAddress += currentBlocksPerLine * blockByteSize;
			lineAddress += currentBlocksPerLine * blockByteSize;
		} else {
			currentAddress += fTextCharsPerLine;
			lineAddress += fTextCharsPerLine;
		}
	}
}
Exemple #24
0
int main()
{
	eosFrameBuffer fb;
	if(eosFrameBuffer_Open(&fb)) {
		return 0;
	}

	CFrameBuffer bf = CreateFrameBuffer(1366, 768);

	struct timeval start, end;
 
    	long mtime, seconds, useconds;    
 
    	gettimeofday(&start, NULL);
 
	
	// Draw background rectangle.
	CRect bg_rect = CreateRect(100, 100, 200, 200);
	CColor bg_color = CreateColor(240, 0, 0);
	DrawRectangle(&bf, &bg_rect, &bg_color);

	// Draw rectangle contour.
	//CColor contour_color = CreateColor(0, 0, 0);
	//DrawRectangleContour(&bf, &bg_rect, &contour_color);

	// Draw diagonal line.
	//CPoint p0 = CPoint_Create(0, 499);
	//CPoint p1 = CPoint_Create(499, 0);
	//CColor p_color = CreateColor(255, 255, 0);
	//DrawLine(&bf, &p0, &p1, &p_color);

	// Draw char.
	CFont font = CreateFont("resources/test.myfont");
	//CPoint char_pos = CPoint_Create(300, 100);
	//CColor char_color = CreateColor(255, 255, 255);
	//DrawChar(&bf, &font, 'P', &char_pos, &char_color);

	// Draw text.
	CPoint str_pos = CPoint_Create(100, 200);
	CColor str_color = CreateColor(180, 180, 180);
	DrawString(&bf, &font, "Monster Truck", &str_pos, &str_color);

	// Draw text.
	CPoint str2_pos = CPoint_Create(100, 220);
	CColor str2_color = CreateColor(10, 180, 180);
	DrawString(&bf, &font, "Monster Truck", &str2_pos, &str2_color);

	// Get text width.
	//CString mst_str = CString_Create("Monster Truck");
	//printf("Monster Truck width : %d\n", GetStringXSize(&font, &mst_str));

	// Draw image resize.
	CImage image = CreateImageFromBitmap("resources/umbrella2.bmp");
	CPoint img_pos = CPoint_Create(300, 51);
	CSize img_size = CreateSize(500, 500);
	DrawImageResize(&bf, &image, &img_pos, &img_size);	

	eosFrameBuffer_Draw(&fb);
	eosFrameBuffer_DrawBackBuffer(&fb, &bf);
    	
	gettimeofday(&end, NULL);
    	seconds  = end.tv_sec  - start.tv_sec;
    	useconds = end.tv_usec - start.tv_usec;
    	mtime = seconds + useconds;
   	printf("Elapsed time: %d ms\n", mtime / 1000);

	gettimeofday(&start, NULL);
	
	DrawRectangle(&bf, &bg_rect, &bg_color);
	DrawString(&bf, &font, "Monster Truck", &str_pos, &str_color);
	DrawString(&bf, &font, "Monster Truck", &str2_pos, &str2_color);
	DrawImageResize(&bf, &image, &img_pos, &img_size);
	eosFrameBuffer_DrawBackBuffer(&fb, &bf);

	gettimeofday(&end, NULL);
	seconds  = end.tv_sec  - start.tv_sec;
        useconds = end.tv_usec - start.tv_usec;
        mtime = seconds + useconds;
        printf("Elapsed time: %d ms\n", mtime / 1000);

	eosFrameBuffer_Close(&fb);
	//printf("FIX:\n");
	//printf("FB len         : %d\n", m_FixInfo.smem_len);
	//printf("FB type        : %d\n", m_FixInfo.type);
	//printf("FB type aux    : %d\n", m_FixInfo.type_aux);
	//printf("FB visual      : %d\n", m_FixInfo.visual);
	//printf("FB xpanstep    : %d\n", m_FixInfo.xpanstep);
	//printf("FB ypanstep    : %d\n", m_FixInfo.ypanstep);
	//printf("FB ywrapstep   : %d\n", m_FixInfo.ywrapstep);
	//printf("FB line_length : %d\n", m_FixInfo.line_length);

	//printf("VAR:\n");
	//printf("Res            : %d %d\n", m_VarInfo.xres, m_VarInfo.yres);
	//printf("Res virtual    : %d %d\n", m_VarInfo.xres_virtual, m_VarInfo.yres_virtual);
	//printf("Offset         : %d %d\n", m_VarInfo.xoffset, m_VarInfo.yoffset);
	//printf("bits_per_pixel : %d\n", m_VarInfo.bits_per_pixel);
	//printf("grayscale      : %d\n", m_VarInfo.grayscale);
	return 0;
}
Exemple #25
0
void GameRoad::draw(void)
{
    SPRITE *sp;
    int c = 0;
    if(cond == RO_INI) {
        return;
    }
    if(del_block.ok > 0) {
        SetDrawBlendMode( DX_BLENDMODE_INVSRC, 128);
    }

    // 背景
    sp = &spd[RO_SP_BG];
    DrawGraph(sp->x, sp->y, sp->num, TRUE);

    // 落ちるブロック描画
    sp = &spd[cols[block.col]+block.type];

    if(block.ok == 1) {
        DrawGraph(block.x, roady[block.k], sp->num, TRUE);
    }

    // 現在埋まっているブロックを描画
    for(int i=0; i<RO_Y_CNT; i++) {
        for(int j=0; j<RO_X_CNT; j++) {
            int n = roads[i][j] & ~0xf0;
            int co = roads[i][j]>>4;
            if(n!=0) {
                sp = &spd[cols[co]+(n-1)];
                DrawGraph(roadx[j], roady[i], sp->num, TRUE);
            }
        }
    }


    if(cond == RO_GAMEOVER) {

        // ゲームオーバー
        SetDrawBright( 255 , 255 , 255 );
        for(int i=RO_SP_LOSE1; i<=RO_SP_LOSE4; i++) {
            sp = &spd[i];
            DrawGraph(sp->x, sp->y, sp->num, TRUE);
        }
        SetDrawBright( alpha , alpha , alpha );

        alpha -= 8;
        if(alpha < 128) {
            alpha = 128;
        }

        return;
    }

    // いち
    sp = &spd[RO_SP_ICHI];
    DrawGraph(sp->x, sp->y, ichi_num[sp->pat][sp->num], TRUE);

    sp = &spd[RO_SP_FB];
    DrawGraph(sp->x, sp->y, sp->num, TRUE);

    RO_LEVEL *lv = &levels[now_level];	// 現在レベル

    // 失敗ブロック描画
    if(del_block.ok > 0) {
        del_block.ok -= 8;
        SetDrawBlendMode( DX_BLENDMODE_NOBLEND , 0);
    }

    if(del_block.ok <= 0) {
        del_block.ok = 0;
    }
    else {
        int n = del_block.type;
        sp = &spd[cols[del_block.col] + n];
        SetDrawBlendMode( DX_BLENDMODE_ALPHA,  del_block.ok );	//ブレンドモード
        DrawRotaGraph( del_block.x, roady[del_block.k], 1.0,  0.0, sp->num, TRUE );

        // エフェクト描画
        if(del_block.ok > 184) {
            sp = &spd[RO_SP_NG1];
        }
        else {
            sp = &spd[RO_SP_NG2];
        }
        DrawGraph(sp->x, sp->y, sp->num, TRUE);

        SetDrawBlendMode( DX_BLENDMODE_NOBLEND,  0 );		//ブレンドモードをオフ
    }

    if(efe_ok > 0) {
        int e = efe_ok / 8;
        if( e > 4 ) {
            efe_ok = 0;
            return;
        }

        sp = &spd[RO_SP_OK1+e];
        DrawGraph(sp->x, sp->y, sp->num, TRUE);
        efe_ok++;
    }

    if(cond == RO_GAME_S) {
        if(stage == 0) {
            sp = &spd[RO_SP_T1];
        }
        else {
            sp = &spd[RO_SP_T2];
        }

        shine(sp);

        SetDrawBlendMode( DX_BLENDMODE_ALPHA,  sp->pat);
        DrawGraph(sp->x, sp->y, sp->num, TRUE);
        SetDrawBlendMode( DX_BLENDMODE_NOBLEND,  0 );

    }
#ifdef _DEBUG
    // クリア描画
    if(cond == RO_CLEAR) {
        if(stage == 0) {
            SetFontSize(24);
            DrawFormatString( 420 , 8 , GetColor( 0 , 0 , 0 ), "Ichi can walk! (←/↓/↑/→)");
            SetFontSize(20);
            DrawFormatString( 100, 48, GetColor(0, 0, 0),
                              "Let's cross to the opposite shore. Or let's fall from a bridge. " );
            DrawFormatString( 100, 76, GetColor(0, 0, 0),
                              "対岸へ渡りましょう。無理なら橋から落ちましょう。" );
        }
    } else if(stage == 0) {
        DrawString(100, 48+8, "↑/↓:Panel up down", GetColor(0, 0, 0));
        DrawString(100, 76+8, "←/→:Panel speed up or down", GetColor(0, 0, 0));
        DrawString(100, 104+8,"Enter-key:panel is rotated.", GetColor(0, 0, 0));
        DrawString(100, 132+8, "Let's connect a portion without a frame and construct a bridge. ", GetColor(0, 0, 0));
        DrawString(100, 160+8, "流れる音のパネルを、左岸か他のパネルにつなげて道を作りましょう。", GetColor(0, 0, 0));
        DrawString(100, 188+8, "枠の無い面でのみ、つなげられます。", GetColor(0, 0, 0));
    }

#else
    DrawFormatString( 0 , 0 , GetColor( 255, 255, 255 ) , "level:%d",now_level);
#endif
    DrawFormatString( 12 ,  32, GetColor(255 , 255 , 255 ) , "time:%d miss:%d",time, miss);
    DrawFormatString( 12 ,  56, GetColor(255 , 0, 0), "red:%d",  get_rgb[0]);
    DrawFormatString( 12 ,  80, GetColor(0 , 255, 0),"green:%d", get_rgb[1]);
    DrawFormatString( 12 , 104, GetColor(0 , 0, 255),"blue:%d",  get_rgb[2]);
    return;
}
void MyApp::DrawGlobalMode()
{
	FvRobotMainApp::SpaceList& kSpaceList = FvRobotMainApp::pInstance()->GetSpaceList();
	FvRobotMainApp::SpaceEntityList& kSpaceEntityList = FvRobotMainApp::pInstance()->GetSpaceEntityList();

	int lineStart(LINE_START);
	int lineStep(LINE_STEP);

	//! 显示地图信息
	DrawString(0, lineStart, CLR_WHITE, "-------Global Mode-------");
	lineStart += lineStep;
	DrawString(0, lineStart, CLR_WHITE, "ShowHelpInfo: H");
	lineStart += lineStep;
	if(1)
	{
		int iCtrlers(0), iOthers(0);
		if(kSpaceEntityList.size())
		{
			FvRobotMainApp::SpaceEntity* pkSpaceEntity(NULL);
			if(m_iSpaceIdx >= (int)kSpaceEntityList.size())
			{
				m_bResetWindow4Space = true;
				m_iSpaceIdx = m_iSpaceIdx % kSpaceEntityList.size();
			}
			DrawString(0, lineStart, CLR_WHITE, "Spaces:%d,Idx:%d", kSpaceEntityList.size(), m_iSpaceIdx);
			lineStart += lineStep;
			int idx(0);
			FvRobotMainApp::SpaceEntityList::iterator itrB = kSpaceEntityList.begin();
			FvRobotMainApp::SpaceEntityList::iterator itrE = kSpaceEntityList.end();
			while(itrB != itrE)
			{
				if(idx == m_iSpaceIdx)
				{
					pkSpaceEntity = &(*itrB);
					break;
				}
				++itrB;
				++idx;
			}
			DrawString(0, lineStart, CLR_WHITE, "id:%d, type:%d", pkSpaceEntity->m_iSpaceID, pkSpaceEntity->m_uiSpaceType);
			lineStart += lineStep;

			//! 显示Space
			{
				const FvRobotMainApp::SpaceInfo* pkSpaceInfo = FvRobotMainApp::Instance().FindSpaceInfo(pkSpaceEntity->m_uiSpaceType);
				FV_ASSERT(pkSpaceInfo);
				if(m_bResetWindow4Space)
				{
					m_bResetWindow4Space = false;
					SetWindowFit2Rect(pkSpaceInfo->kSpaceRect);
				}

				for(int i=0; i<(int)pkSpaceInfo->kCells.size(); ++i)
				{
					DrawRect(pkSpaceInfo->kCells[i], CLR_YELLOW);
				}
				DrawRect(pkSpaceInfo->kSpaceRect, CLR_YELLOW);
			}

			//! 显示实体
			if(1)
			{
				FvRobotMainApp::Entities& kEntityMap = pkSpaceEntity->m_kEntities;
				//! 显示实体数量
				DrawString(0, lineStart, CLR_WHITE, "Entities:%d", kEntityMap.size());
				lineStart += lineStep;
				FvRobotMainApp::Entities::iterator itrB = kEntityMap.begin();
				FvRobotMainApp::Entities::iterator itrE = kEntityMap.end();
				while(itrB != itrE)
				{
					FvEntity* pkEntity = itrB->second;
					p2Clr clr;
					const FvVector3& p3 = pkEntity->GetPos();
					FvVector2 p2(p3.x, p3.y);
					int x,y;
					char charID[32] = {0};
					char robotID[32] = {0};
					char charPos[64] = {0};
					bool bConvertPos(false);
					if(m_bShowEntityID)
					{
						bConvertPos = true;
						sprintf(charID, "%d", pkEntity->GetEntityID());
					}
					if(m_bShowRobotID)
					{
						bConvertPos = true;
						sprintf(robotID, "%d", pkEntity->GetRobotID());
					}
					if(m_bShowEntityPos)
					{
						bConvertPos = true;
						sprintf(charPos, "%.2f,%.2f,%.2f", p3.x, p3.y, p3.z);
					}
					if(bConvertPos)
					{
						ConvertWorldToScreen(p2, x, y);
					}

					if(pkEntity->IsCtrler())//! ctrler
					{
						++iCtrlers;
						clr = CLR_RED;
						DrawPoint(p3, clr);
						if(m_bShowEntityID)
						{
							DrawString(x, y, clr, charID);
						}
						if(m_bShowRobotID)
						{
							DrawString(x, y-lineStep, clr, robotID);
						}
						if(m_bShowEntityPos)
						{
							DrawString(x, y+lineStep, clr, charPos);
						}
					}
					else//! others
					{
						++iOthers;
						clr = CLR_BLUE;
						DrawPoint(p3, clr);
						if(m_bShowEntityID)
						{
							DrawString(x, y, clr, charID);
						}
						if(m_bShowEntityPos)
						{
							DrawString(x, y+lineStep, clr, charPos);
						}
					}

					//! 显示非Ctrler实体的属性,测试Lod
					if(m_bShowEntityProp)
					{
/**
						FvEntity* pkOther = pkEntity;
						DrawString(0, lineStart, CLR_WHITE, "-------------");
						lineStart += lineStep;
						DrawString(0, lineStart, CLR_WHITE, "Entity:%d", pkOther->GetEntityID());
						lineStart += lineStep;
						const FvEntityDescription* pkEntityDes = pkOther->GetEntityDes();
						FvUInt32 cnt = pkEntityDes->PropertyCount();
						for(FvUInt32 i=0; i<cnt; ++i)
						{
							FvDataDescription* pkDataDes = pkEntityDes->Property(i);
							FvObjPtr spObj = pkOther->FindProperty(i);
							if(!spObj)
								continue;
							switch(spObj->RTTI())
							{
							case FVOBJ_RTTI_INT8:
								{
									FvInt8 v = FVOBJ_GETVAL(spObj, FvObjInt8);
									DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v);
								}
								break;
							case FVOBJ_RTTI_UINT8:
								{
									FvUInt8 v = FVOBJ_GETVAL(spObj, FvObjUInt8);
									DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v);
								}
								break;
							case FVOBJ_RTTI_INT16:
								{
									FvInt16 v = FVOBJ_GETVAL(spObj, FvObjInt16);
									DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v);
								}
								break;
							case FVOBJ_RTTI_UINT16:
								{
									FvUInt16 v = FVOBJ_GETVAL(spObj, FvObjUInt16);
									DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v);
								}
								break;
							case FVOBJ_RTTI_INT32:
								{
									FvInt32 v = FVOBJ_GETVAL(spObj, FvObjInt32);
									DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v);
								}
								break;
							case FVOBJ_RTTI_UINT32:
								{
									FvUInt32 v = FVOBJ_GETVAL(spObj, FvObjUInt32);
									DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v);
								}
								break;
							case FVOBJ_RTTI_INT64:
								{
									FvInt64 v = FVOBJ_GETVAL(spObj, FvObjInt64);
									DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%I64d", pkDataDes->Name().c_str(), v);
								}
								break;
							case FVOBJ_RTTI_UINT64:
								{
									FvUInt64 v = FVOBJ_GETVAL(spObj, FvObjUInt64);
									DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%I64u", pkDataDes->Name().c_str(), v);
								}
								break;
							case FVOBJ_RTTI_FLOAT:
								{
									float v = FVOBJ_GETVAL(spObj, FvObjFloat);
									DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%f", pkDataDes->Name().c_str(), v);
								}
								break;
							case FVOBJ_RTTI_DOUBLE:
								{
									double v = FVOBJ_GETVAL(spObj, FvObjDouble);
									DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%f", pkDataDes->Name().c_str(), v);
								}
								break;
							case FVOBJ_RTTI_STRING:
								{
									FvString v = FVOBJ_GETVAL(spObj, FvObjString);
									DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%s", pkDataDes->Name().c_str(), v.c_str());
								}
								break;
							case FVOBJ_RTTI_MAILBOX:
								{
									FVOBJ_CONVERT_P(spObj, FvObjMailBox, pMB);
									DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%s", pkDataDes->Name().c_str(), pMB->c_str());
								}
								break;
							default:
								{
									DrawString(0, lineStart, CLR_WHITE, "PropName:%s", pkDataDes->Name().c_str());
								}
								break;
							}
							lineStart += lineStep;
						}
**/
					}

					++itrB;
				}
			}

			DrawString(0, lineStart, CLR_WHITE, "Ctrler:%d, Others:%d", iCtrlers, iOthers);
			lineStart += lineStep;
		}
		else
		{
			DrawString(0, lineStart, CLR_WHITE, "Spaces:%d,Idx:%d", 0, 0);
			lineStart += lineStep;
			DrawString(0, lineStart, CLR_WHITE, "Entities:%d", 0);
			lineStart += lineStep;
			DrawString(0, lineStart, CLR_WHITE, "Ctrler:%d, Others:%d", 0, 0);
			lineStart += lineStep;
		}
	}
}
Exemple #27
0
int InstallData(char* drive){
	static const FirmInfo agb_info = { 0x8B800, 0x4CE00, 0x08006800, 0xD600, 0xE200, 0x08020000};
	static const FirmInfo twl_info = { 0x153600, 0x4D200, 0x08006800, 0xD600, 0xE200, 0x08020000};
	FIL firmfile;
	unsigned int progressWidth, progressX;
	wchar_t progressbar[8] = {0,};
	wchar_t *progress = progressbar;
	int i;

	progressWidth = getMpInfo() == MPINFO_CTR ? 7 : 3;
	progressX = (BOT_SCREEN_WIDTH - progressWidth * FONT_WIDTH) / 2;

	for (i = 0; i < progressWidth; i++)
		wcscat(progressbar, strings[STR_PROGRESS]);
	print(L"%ls", progressbar);
	ConsolePrevLine();

	//Create the workdir
	sprintf(tmpstr, "%s:%s", drive, DATAFOLDER);
	f_mkdir(tmpstr);

	//Read firmware data
	if (f_open(&firmfile, "firmware.bin", FA_READ | FA_OPEN_EXISTING) != FR_OK) return CONF_NOFIRMBIN;
	wcsncpy(progress, strings[STR_PROGRESS_OK], wcslen(strings[STR_PROGRESS_OK]));
	progress += wcslen(strings[STR_PROGRESS_OK]);
	DrawString(BOT_SCREEN, progressbar, progressX, 50, ConsoleGetTextColor(), ConsoleGetBackgroundColor());

	//Create decrypted native_firm
	f_read(&firmfile, WORKBUF, NAT_SIZE, &tmpu32);
	uint8_t* n_firm = decryptFirmTitle(WORKBUF, NAT_SIZE, 0x00000002, 1);
	wcsncpy(progress, strings[STR_PROGRESS_OK], wcslen(strings[STR_PROGRESS_OK]));
	progress += wcslen(strings[STR_PROGRESS_OK]);
	DrawString(BOT_SCREEN, progressbar, progressX, 50, ConsoleGetTextColor(), ConsoleGetBackgroundColor());

	getFirmPath(tmpstr, getMpInfo() == MPINFO_KTR ?
		TID_KTR_NATIVE_FIRM : TID_CTR_NATIVE_FIRM);
	if(FileOpen(&tempfile, tmpstr, 1)){
		FileWrite(&tempfile, n_firm, NAT_SIZE, 0);
		FileClose(&tempfile);
	}else {
		f_close(&firmfile);
		return CONF_ERRNFIRM;
	}
	wcsncpy(progress, strings[STR_PROGRESS_OK], wcslen(strings[STR_PROGRESS_OK]));
	progress += wcslen(strings[STR_PROGRESS_OK]);
	DrawString(BOT_SCREEN, progressbar, progressX, 50, ConsoleGetTextColor(), ConsoleGetBackgroundColor());

	if (getMpInfo() != MPINFO_CTR)
		goto end;

	//Create AGB patched firmware
	f_read(&firmfile, WORKBUF, AGB_SIZE, &tmpu32);
	uint8_t* a_firm = decryptFirmTitle(WORKBUF, AGB_SIZE, 0x00000202, 1);
	if (!a_firm && checkEmuNAND())
	{
		/* Try to get the Title Key from the EmuNAND */
		a_firm = decryptFirmTitle(WORKBUF, AGB_SIZE, 0x00000202, 2);
		if (!a_firm) {
			/* If we cannot decrypt it from firmware.bin because of titlekey messed up,
			it probably means that AGB has been modified in some way. */
			//So we read it from his installed ncch...
			FindApp(0x00040138, 0x00000202, 1);
			char* path = getContentAppPath();
			if (!FileOpen(&tempfile, path, 0) && checkEmuNAND())
			{
				/* Try with EmuNAND */
				FindApp(0x00040138, 0x00000202, 2);
				path = getContentAppPath();
				if (!FileOpen(&tempfile, path, 0))
				{
					f_close(&firmfile);
					return CONF_ERRNFIRM;
				}
			}

			FileRead(&tempfile, WORKBUF, AGB_SIZE, 0);
			FileClose(&tempfile);
			a_firm = decryptFirmTitleNcch(WORKBUF, AGB_SIZE);
		}
	}

	if (a_firm) {
		if (applyPatch(a_firm, "/rxTools/system/patches/ctr/agb_firm.elf", &agb_info))
			return CONF_ERRPATCH;

		getFirmPath(tmpstr, TID_CTR_TWL_FIRM);
		if(FileOpen(&tempfile, tmpstr, 1)){
			FileWrite(&tempfile, a_firm, AGB_SIZE, 0);
			FileClose(&tempfile);
		}else {
			f_close(&firmfile);
			return CONF_ERRNFIRM;
		}
		wcsncpy(progress, strings[STR_PROGRESS_OK], wcslen(strings[STR_PROGRESS_OK]));
		progress += wcslen(strings[STR_PROGRESS_OK]);
	} else {
		wcsncpy(progress, strings[STR_PROGRESS_FAIL], wcslen(strings[STR_PROGRESS_FAIL]));
		progress += wcslen(strings[STR_PROGRESS_FAIL]); //If we get here, then we'll play without AGB, lol
	}

	DrawString(BOT_SCREEN, progressbar, progressX, 50, ConsoleGetTextColor(), ConsoleGetBackgroundColor());

	//Create TWL patched firmware
	f_read(&firmfile, WORKBUF, TWL_SIZE, &tmpu32);
	uint8_t* t_firm = decryptFirmTitle(WORKBUF, TWL_SIZE, 0x00000102, 1);
	if(t_firm){
		if (applyPatch(t_firm, "/rxTools/system/patches/ctr/twl_firm.elf", &twl_info))
			return CONF_ERRPATCH;

		getFirmPath(tmpstr, TID_CTR_TWL_FIRM);
		if(FileOpen(&tempfile, tmpstr, 1)){
			FileWrite(&tempfile, t_firm, TWL_SIZE, 0);
			FileClose(&tempfile);
			//FileCopy("0004013800000102.bin", tmpstr);
		}else {
			f_close(&firmfile);
			return CONF_ERRNFIRM;
		}
		wcsncpy(progress, strings[STR_PROGRESS_OK], wcslen(strings[STR_PROGRESS_OK]));
		progress += wcslen(strings[STR_PROGRESS_OK]);
	}else{
		wcsncpy(progress, strings[STR_PROGRESS_FAIL], wcslen(strings[STR_PROGRESS_FAIL]));
		progress += wcslen(strings[STR_PROGRESS_FAIL]);
	}
	DrawString(BOT_SCREEN, progressbar, progressX, 50, ConsoleGetTextColor(), ConsoleGetBackgroundColor());

	sprintf(tmpstr, "%s:%s/data.bin", drive, DATAFOLDER);
	if(FileOpen(&tempfile, tmpstr, 1)){
		FileWrite(&tempfile, __DATE__, 12, 0);
		FileWrite(&tempfile, __TIME__, 9, 12);
		FileClose(&tempfile);
	}else {
		f_close(&firmfile);
		return CONF_CANTOPENFILE;
	}
	wcsncpy(progress, strings[STR_PROGRESS_OK], wcslen(strings[STR_PROGRESS_OK]));
	progress += wcslen(strings[STR_PROGRESS_OK]);
	DrawString(BOT_SCREEN, progressbar, progressX, 50, ConsoleGetTextColor(), ConsoleGetBackgroundColor());

end:
	f_close(&firmfile);
	return 0;
}
void MyApp::DrawSingleMode()
{
	FvRobotClientAppPtr spApp = FvRobotMainApp::Instance().GetRobotInSingleMode();

	int lineStart(LINE_START);
	int lineStep(LINE_STEP);

	//! 显示地图信息
	DrawString(0, lineStart, CLR_WHITE, "-------Single Mode-------");
	lineStart += lineStep;
	DrawString(0, lineStart, CLR_WHITE, "ShowHelpInfo: H");
	lineStart += lineStep;
	if(!spApp)
	{
		DrawString(0, lineStart, CLR_WHITE, "Err: No Selected Robot");
		lineStart += lineStep;
		return;
	}
	if(1)
	{
		DrawString(0, lineStart, CLR_WHITE, "ServerTime:%.1f", spApp->GetServerConnection()->ServerTime());
		lineStart += lineStep;

		DrawString(0, lineStart, CLR_WHITE, "ServerToDScaling:%.2f,ServerToD:%.2f", spApp->GetToDScaling(), spApp->GetToD());
		lineStart += lineStep;

		DrawString(0, lineStart, CLR_WHITE, "SpaceID:%d, Type:%d, RobotID:%d", spApp->SpaceID(), spApp->SpaceType(), spApp->RobotID());
		lineStart += lineStep;

		//! 显示Space
		const FvRobotMainApp::SpaceInfo* pkSpaceInfo = FvRobotMainApp::Instance().FindSpaceInfo(spApp->SpaceType());
		if(!pkSpaceInfo)
		{
			DrawString(0, lineStart, CLR_WHITE, "Err:No Space Info");
			lineStart += lineStep;
			return;
		}
		else
		{
			if(m_bResetWindow4Space)
			{
				m_bResetWindow4Space = false;
				SetWindowFit2Rect(pkSpaceInfo->kSpaceRect);
			}

			for(int i=0; i<(int)pkSpaceInfo->kCells.size(); ++i)
			{
				DrawRect(pkSpaceInfo->kCells[i], CLR_YELLOW);
			}
			DrawRect(pkSpaceInfo->kSpaceRect, CLR_YELLOW);
		}

		//! 显示实体
		if(1)
		{
			const FvRobotClientApp::EntityMap& kEntityMap = spApp->GetEntityMap();
			//! 显示实体数量
			DrawString(0, lineStart, CLR_WHITE, "Entities:%d", kEntityMap.size());
			lineStart += lineStep;
			FvRobotClientApp::EntityMap::const_iterator itrB = kEntityMap.begin();
			FvRobotClientApp::EntityMap::const_iterator itrE = kEntityMap.end();
			while(itrB != itrE)
			{
				FvEntity* pkEntity = itrB->second;
				p2Clr clr;
				const FvVector3& p3 = pkEntity->GetPos();
				FvVector2 p2(p3.x, p3.y);
				int x,y;
				char charID[32] = {0};
				char robotID[32] = {0};
				char charPos[64] = {0};
				bool bConvertPos(false);
				if(m_bShowEntityID)
				{
					bConvertPos = true;
					sprintf(charID, "%d", pkEntity->GetEntityID());
				}
				if(m_bShowRobotID)
				{
					bConvertPos = true;
					sprintf(robotID, "%d", pkEntity->GetRobotID());
				}
				if(m_bShowEntityPos)
				{
					bConvertPos = true;
					sprintf(charPos, "%.2f,%.2f,%.2f", p3.x, p3.y, p3.z);
				}
				if(bConvertPos)
				{
					ConvertWorldToScreen(p2, x, y);
				}

				if(pkEntity->IsCtrler())//! ctrler
				{
					clr = CLR_RED;
					DrawPoint(p3, clr);
					if(m_bShowEntityID)
					{
						DrawString(x, y, clr, charID);
					}
					if(m_bShowRobotID)
					{
						DrawString(x, y-lineStep, clr, robotID);
					}
					if(m_bShowEntityPos)
					{
						DrawString(x, y+lineStep, clr, charPos);
					}
				}
				else//! others
				{
					clr = CLR_BLUE;
					DrawPoint(p3, clr);
					if(m_bShowEntityID)
					{
						DrawString(x, y, clr, charID);
					}
					if(m_bShowEntityPos)
					{
						DrawString(x, y+lineStep, clr, charPos);
					}
				}

				//! 显示非Ctrler实体的属性,测试Lod
				if(m_bShowEntityProp)
				{
/**
					FvEntity* pkOther = pkEntity;
					DrawString(0, lineStart, CLR_WHITE, "-------------");
					lineStart += lineStep;
					DrawString(0, lineStart, CLR_WHITE, "Entity:%d", pkOther->GetEntityID());
					lineStart += lineStep;
					const FvEntityDescription* pkEntityDes = pkOther->GetEntityDes();
					FvUInt32 cnt = pkEntityDes->PropertyCount();
					for(FvUInt32 i=0; i<cnt; ++i)
					{
						FvDataDescription* pkDataDes = pkEntityDes->Property(i);
						FvObjPtr spObj = pkOther->FindProperty(i);
						if(!spObj)
							continue;
						switch(spObj->RTTI())
						{
						case FVOBJ_RTTI_INT8:
							{
								FvInt8 v = FVOBJ_GETVAL(spObj, FvObjInt8);
								DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v);
							}
							break;
						case FVOBJ_RTTI_UINT8:
							{
								FvUInt8 v = FVOBJ_GETVAL(spObj, FvObjUInt8);
								DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v);
							}
							break;
						case FVOBJ_RTTI_INT16:
							{
								FvInt16 v = FVOBJ_GETVAL(spObj, FvObjInt16);
								DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v);
							}
							break;
						case FVOBJ_RTTI_UINT16:
							{
								FvUInt16 v = FVOBJ_GETVAL(spObj, FvObjUInt16);
								DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v);
							}
							break;
						case FVOBJ_RTTI_INT32:
							{
								FvInt32 v = FVOBJ_GETVAL(spObj, FvObjInt32);
								DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v);
							}
							break;
						case FVOBJ_RTTI_UINT32:
							{
								FvUInt32 v = FVOBJ_GETVAL(spObj, FvObjUInt32);
								DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v);
							}
							break;
						case FVOBJ_RTTI_INT64:
							{
								FvInt64 v = FVOBJ_GETVAL(spObj, FvObjInt64);
								DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%I64d", pkDataDes->Name().c_str(), v);
							}
							break;
						case FVOBJ_RTTI_UINT64:
							{
								FvUInt64 v = FVOBJ_GETVAL(spObj, FvObjUInt64);
								DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%I64u", pkDataDes->Name().c_str(), v);
							}
							break;
						case FVOBJ_RTTI_FLOAT:
							{
								float v = FVOBJ_GETVAL(spObj, FvObjFloat);
								DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%f", pkDataDes->Name().c_str(), v);
							}
							break;
						case FVOBJ_RTTI_DOUBLE:
							{
								double v = FVOBJ_GETVAL(spObj, FvObjDouble);
								DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%f", pkDataDes->Name().c_str(), v);
							}
							break;
						case FVOBJ_RTTI_STRING:
							{
								FvString v = FVOBJ_GETVAL(spObj, FvObjString);
								DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%s", pkDataDes->Name().c_str(), v.c_str());
							}
							break;
						case FVOBJ_RTTI_MAILBOX:
							{
								FVOBJ_CONVERT_P(spObj, FvObjMailBox, pMB);
								DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%s", pkDataDes->Name().c_str(), pMB->c_str());
							}
							break;
						default:
							{
								DrawString(0, lineStart, CLR_WHITE, "PropName:%s", pkDataDes->Name().c_str());
							}
							break;
						}
						lineStart += lineStep;
					}
**/
				}

				++itrB;
			}
		}
	}
}
Exemple #29
0
void TermView::Draw(BRect updateRect)
{
	VTermRect updatedChars = PixelsToGlyphs(updateRect);
	
	VTermPos pos;
	font_height height;
	GetFontHeight(&height);

	int availableRows, availableCols;
	vterm_get_size(fTerm, &availableRows, &availableCols);

	for (pos.row = updatedChars.start_row; pos.row <= updatedChars.end_row;
			pos.row++) {
		float x = updatedChars.start_col * fFontWidth + kBorderSpacing;
		float y = pos.row * fFontHeight + height.ascent + kBorderSpacing + 1;
		MovePenTo(x, y);

		for (pos.col = updatedChars.start_col;
				pos.col <= updatedChars.end_col;) {
			VTermScreenCell cell;

			if (pos.col < 0 || pos.row < 0 || pos.col >= availableCols 
					|| pos.row >= availableRows) {

				// All cells outside the used terminal area are drawn with the
				// same background color as the top-left one.
				VTermPos firstPos;
				firstPos.row = 0;
				firstPos.col = 0;
				vterm_screen_get_cell(fTermScreen, firstPos, &cell);
				cell.chars[0] = 0;
				cell.width = 1;
			} else
				vterm_screen_get_cell(fTermScreen, pos, &cell);

			rgb_color foreground, background;
			foreground.red = cell.fg.red;
			foreground.green = cell.fg.green;
			foreground.blue = cell.fg.blue;
			foreground.alpha = 255;
			background.red = cell.bg.red;
			background.green = cell.bg.green;
			background.blue = cell.bg.blue;
			background.alpha = 255;

			if(cell.attrs.reverse) {
				SetLowColor(foreground);
				SetViewColor(foreground);
				SetHighColor(background);
			} else {
				SetLowColor(background);
				SetViewColor(background);
				SetHighColor(foreground);
			}

			BPoint penLocation = PenLocation();
			FillRect(BRect(penLocation.x, penLocation.y - height.ascent,
				penLocation.x + cell.width * fFontWidth, penLocation.y + 1),
				B_SOLID_LOW);

			if (cell.chars[0] == 0) {
				DrawString(" ");
				pos.col ++;
			} else {
				char buffer[VTERM_MAX_CHARS_PER_CELL];
				wcstombs(buffer, (wchar_t*)cell.chars,
						VTERM_MAX_CHARS_PER_CELL);

				DrawString(buffer);
				pos.col += cell.width;
			}
		}
	}
}
void DropDownListStringItem::Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const
{
	DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, this->String(), sel ? TC_WHITE : TC_BLACK);
}