//TODO: maxEngery, Backpacksize, curentMoney int displayStore(SDL_Surface *screen, dataStore *data, menuDataStore *menuData) { menuData->buttons[ITEM_BUTTON].disabled=!(data->player.candystash + data->player.bp.currentVolume>=data->player.cutSpeed*1000); menuData->buttons[BACKPACK_BUTTON].disabled=!(data->player.candystash + data->player.bp.currentVolume>=data->player.bp.maxVolume*3); menuData->buttons[VIEW_BUTTON].disabled=!(data->player.candystash + data->player.bp.currentVolume>=data->player.vision*1000); menuData->buttons[ ENERGY_BUTTON ].disabled=!(data->player.candystash + data->player.bp.currentVolume>=data->player.maxEnergy); sprintf(menuData->buttons[ ITEM_BUTTON ].name,"Tool Upgrade %.0f",data->player.cutSpeed*1000); sprintf(menuData->buttons[ BACKPACK_BUTTON ].name,"Backpack Upgrade %d",data->player.bp.maxVolume*3); sprintf(menuData->buttons[ VIEW_BUTTON ].name,"View Upgrade %d",data->player.vision*1000); sprintf(menuData->buttons[ ENERGY_BUTTON ].name,"Energy Upgrade %d",data->player.maxEnergy); /*Background */ // int width = 400, height = 350; // SDL_Rect background = {screen->clip_rect.w/2-width/2,screen->clip_rect.h/2-height/2,width,height}; SDL_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0x00, 0x00, 0x00 )); int i; for(i=0;i<3;i+=2){ /*Draw Text */ char text[50]; sprintf(text,"%d CANDY",(data->player.candystash+data->player.bp.currentVolume)); SDL_Surface *message; TTF_Font *font = theFont(25); SDL_Color textColor = { 255*i, 255*i, 255*i,0}; if (!(message = TTF_RenderText_Blended( font, text, textColor ))) { printf("%s\n",TTF_GetError()); return 1; } TTF_CloseFont(font); SDL_Rect textRect = {300-i,22-i,0,0}; if(0!=SDL_BlitSurface( message, NULL, screen, &textRect)) { printf("%s\n",SDL_GetError()); return 1; } SDL_FreeSurface(message); } /*Buttons*/ int buttonID; for (buttonID = 0; buttonID<STOREBUTTONCOUNT; buttonID++) { drawButtonWithState(screen, &menuData->buttons[buttonID],1); } SDL_Flip(screen); return 0; }
void TTimeTextView::Init() { m_IsLocked = false; SetTextRect(Bounds()); SetAlignment(B_ALIGN_CENTER); // Set up max number of character SetMaxBytes(11); // Set font and color BFont theFont(be_plain_font); theFont.SetSize(10); SetViewColor(kWhite); SetFontAndColor(&theFont, B_FONT_ALL, &kBlack); // Set up time rects. We divide the area up into four areas // for hour, minutes, seconds and frames float numberWidth; float spaceWidth; BRect bounds = Bounds(); numberWidth = StringWidth("00"); spaceWidth = StringWidth(":"); m_HoursRect.left = bounds.left; m_HoursRect.top = bounds.top; m_HoursRect.right = m_HoursRect.left + numberWidth; m_HoursRect.bottom = bounds.bottom; m_MinutesRect.left = m_HoursRect.right + spaceWidth; m_MinutesRect.top = bounds.top; m_MinutesRect.right = m_MinutesRect.left + numberWidth; m_MinutesRect.bottom = bounds.bottom; m_SecondsRect.left = m_MinutesRect.right + spaceWidth; m_SecondsRect.top = bounds.top; m_SecondsRect.right = m_SecondsRect.left + numberWidth; m_SecondsRect.bottom = bounds.bottom; m_FramesRect.left = m_SecondsRect.right + spaceWidth; m_FramesRect.top = bounds.top; m_FramesRect.right = bounds.right; m_FramesRect.bottom = bounds.bottom; // Select first cell //Select(0,2); //ScrollToSelection(); m_CurrentCell = 1; }
void CScintillaConsoleDlg::qtInitialize() { struct SScintillaColors { int iItem; COLORREF rgb; }; const COLORREF blueGrey=RGB(128,128,255); _scintillaObject->setTabWidth(4); sendEditor(QsciScintillaBase::SCI_USEPOPUP,0); // no popup! sendEditor(QsciScintillaBase::SCI_SETREADONLY,1); int fontSize=8; std::string theFont("Courier"); // since Scintilla 2.7.2 and Qt5.1.1, "Courier New" gives strange artifacts (with Mac and Linux)! #ifdef MAC_VREP fontSize=12; // bigger fonts here #endif if (App::userSettings->auxConsoleFontSize!=-1) fontSize=App::userSettings->auxConsoleFontSize; if (App::userSettings->auxConsoleFont.length()!=0) theFont=App::userSettings->auxConsoleFont; _setAStyle(QsciScintillaBase::STYLE_DEFAULT,RGB(int(info->_textColor[0]*255.0f),int(info->_textColor[1]*255.0f),int(info->_textColor[2]*255.0f)),RGB(int(info->_backgroundColor[0]*255.0f),int(info->_backgroundColor[1]*255.0f),int(info->_backgroundColor[2]*255.0f)),fontSize,theFont.c_str()); // set global default style if (info->_mode&2) sendEditor(QsciScintillaBase::SCI_SETWRAPMODE,QsciScintillaBase::SC_WRAP_WORD); else sendEditor(QsciScintillaBase::SCI_SETWRAPMODE,QsciScintillaBase::SC_WRAP_NONE); _scintillaObject->SendScintilla(QsciScintillaBase::SCI_STYLECLEARALL); // set all styles _scintillaObject->SendScintilla(QsciScintillaBase::SCI_SETSELBACK,1,blueGrey); // selection color move(info->_initialPosition[0],info->_initialPosition[1]); resize(info->_initialSize[0],info->_initialSize[1]); setWindowTitle(info->_title.c_str()); _initialized=true; }
ItemMsgBox::ItemMsgBox(Opened_By openedBy, QString text, bool isFriendly, QString label, QString title, QWidget *parent) : QDialog(parent), ui(new Ui::ItemMsgBox) { QFontDatabase::addApplicationFont(":/PressStart2P.ttf"); whoOpened = openedBy; currentText = text; ui->setupUi(this); ui->checkFriendly->setChecked(isFriendly); if(whoOpened != NPC) ui->checkFriendly->hide(); if(!label.isEmpty()) ui->NotesLabel->setText(label); if(!title.isEmpty()) this->setWindowTitle(title); //#ifdef Q_OS_MACX // QFont theFont("Press Start 2P", 11); //#else // QFont theFont("Press Start 2P", 11); //#endif QFont theFont("Press Start 2P"); theFont.setPixelSize(8); ui->msgTextBox->setFont(theFont); ui->msgTextBox->clear(); QFontMetrics meter(ui->msgTextBox->font()); int w_width = meter.size(Qt::TextSingleLine, "XXXXXXXXXXXXXXXXXXXXXXXXXXX").width(); int scrW = ui->msgTextBox->style()->pixelMetric(QStyle::PM_ScrollBarExtent); ui->msgTextBox->setMaximumWidth(w_width+scrW+12); ui->msgTextBox->setMinimumWidth(w_width+scrW+12); ui->msgTextBox->appendPlainText(currentText); updateGeometry(); }
int displayAbout(SDL_Surface *screen, dataStore *data) { int done, mouseX, mouseY; SDL_Event event; SDL_Color textColor = { 255, 255, 255,0}; SDL_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0x00, 0x00, 0x00 )); myButton button; button.rect.x = screen->clip_rect.w/2-BUTTONWIDTH/2; button.rect.y = screen->clip_rect.h-BUTTONHEIGHT-100; button.rect.w = BUTTONWIDTH; button.rect.h = BUTTONHEIGHT; button.name="Back"; drawButton(screen, &button); TTF_Font *font = theFont(20); char aboutText[10][100] = {"Hedgewood is a game written by:"," - toco"," - tk"," - JTR"," "," we hope you enjoy it."," ","Thanks to:"," - friend of tk for the grapics"," - our great tutor Arne"}; if (!(renderMultiLineText(font, 150, 100, &aboutText[0],10, textColor,screen))) printf("%s\n",TTF_GetError()); SDL_Flip(screen); TTF_CloseFont(font); // SDL_FreeSurface(message); unsigned int startTime, stopTime, diffTime; unsigned int innerStartTime, innerStopTime; done = 0; while ( !done ) { startTime = SDL_GetTicks(); /* Check for events */ while ( SDL_PollEvent(&event) ) { innerStartTime = SDL_GetTicks(); switch (event.type) { case SDL_MOUSEMOTION: break; case SDL_MOUSEBUTTONUP: SDL_GetMouseState(&mouseX,&mouseY); if (isButtonClicked(&button, mouseX, mouseY)) { done = 1; } #if (DEBUG==1) printf("Cusor-Position x: %d y: %d\n",mouseX,mouseY); #endif break; case SDL_KEYDOWN: /* Any keypress quits the app... */ switch( event.key.keysym.sym ) { case SDLK_f: break; case SDLK_0: printf ("Music off\n"); Mix_HaltMusic(); Mix_HaltChannel(-1); data->soundEnabled=0; break; case SDLK_m: printf ("Music on /Pause\n"); if( Mix_PlayingMusic() == 0 ) Mix_PlayMusic( data->ingamemusic, -1); if( Mix_PausedMusic() == 1 ) Mix_ResumeMusic(); else Mix_PauseMusic(); break; case SDLK_ESCAPE: case SDLK_q: done = 1; quitSDL(data); break; default: break; } break; /* case SDL_QUIT: done = 1; break; */ default: break; } innerStopTime = SDL_GetTicks(); diffTime=(innerStopTime-innerStartTime); //25 Frames per second (40 Milliseconds per frame) if (MS_FRAMETIME>diffTime) SDL_Delay(MS_FRAMETIME-diffTime); } stopTime = SDL_GetTicks(); diffTime = (stopTime-startTime); //25 Frames per second (40 Milliseconds per frame) if (MS_FRAMETIME>diffTime) SDL_Delay(MS_FRAMETIME-diffTime); } return 0; }
/** * Wenn die Schrift fertig verwendet wurde muss TTF_CloseFont(font); aufgerufen werden! * @return gibt eine initialisierte TTF_Font zurück mit der Größe für Buttons */ TTF_Font *buttonFont() { return theFont(28); /*requires TTF_CloseFont(font); after use*/ }
void KDChartHiLoPainter::specificPaintData( QPainter* painter, const QRect& ourClipRect, KDChartTableDataBase* data, KDChartDataRegionList* /*regions*/, const KDChartAxisParams* axisPara, bool /*bNormalMode*/, uint /*chart*/, double logWidth, double areaWidthP1000, double logHeight, double axisYOffset, double /*minColumnValue*/, double /*maxColumnValue*/, double /*columnValueDistance*/, uint chartDatasetStart, uint chartDatasetEnd, uint datasetStart, uint datasetEnd ) { double areaHeightP1000 = logHeight / 1000.0; double averageValueP1000 = ( areaWidthP1000 + areaHeightP1000 ) / 2.0; int datasetNum=abs(static_cast<int>(chartDatasetEnd-chartDatasetStart))+1; painter->setPen( params()->outlineDataColor() ); // Number of values: If -1, use all values, otherwise use the // specified number of values. int numValues = 0; if ( params()->numValues() != -1 ) numValues = params()->numValues(); else numValues = data->usedCols(); // We need to make sure that we have a certain number of // cells in the dataset(s), depending on the sub type to display. if( (numValues < 2) || ((params()->hiLoChartSubType() == KDChartParams::HiLoClose) && (numValues < 3)) || ((params()->hiLoChartSubType() == KDChartParams::HiLoOpenClose) && (numValues < 4)) ){ qDebug( "\nNot enough data to display a High/Low Chart!\n" ); qDebug( "type requiring" ); qDebug( "---- ---------" ); qDebug( "High/Low 2 data cells per series" ); qDebug( "High/Low/Close 3 data cells per series" ); qDebug( "High/Low/open/Close 4 data cells per series\n" ); return; // PENDING(kalle) Throw exception? } double pixelsPerUnit = 0.0; if( 0.0 != axisPara->trueAxisHigh() - axisPara->trueAxisLow() ) pixelsPerUnit = logHeight / (axisPara->trueAxisHigh() - axisPara->trueAxisLow()); else pixelsPerUnit = logHeight / 10; // Distance between the individual "stocks" double pointDist = logWidth / (double)datasetNum; // compute the position of the 0 axis double zeroXAxisI = axisPara->axisZeroLineStartY() - _dataRect.y(); const int nLineWidth = params()->lineWidth(); // Loop over the datasets, draw one "stock" line for each series. for ( uint dataset = chartDatasetStart; dataset <= chartDatasetEnd; ++dataset ) { // The first and the second col are always high and low; we sort them // accordingly. QVariant valueA; QVariant valueB; if( dataset >= datasetStart && dataset <= datasetEnd && data->cellCoord( dataset, 0, valueA, 1 ) && data->cellCoord( dataset, 1, valueB, 1 ) && QVariant::Double == valueA.type() && QVariant::Double == valueB.type() ){ const double cellValue1 = valueA.toDouble(); const double cellValue2 = valueB.toDouble(); const double lowValue = QMIN( cellValue1, cellValue2 ); const double highValue = QMAX( cellValue1, cellValue2 ); const double lowDrawValue = lowValue * pixelsPerUnit; const double highDrawValue = highValue * pixelsPerUnit; painter->setPen( QPen( params()->dataColor( dataset ), nLineWidth ) ); // draw line from low to high int xpos = static_cast<int>( pointDist * ( (double)(dataset-chartDatasetStart) + 0.5 ) ); int lowYPos = static_cast<int>( zeroXAxisI - lowDrawValue ); int highYPos = static_cast<int>( zeroXAxisI - highDrawValue ); painter->drawLine( xpos, lowYPos, xpos, highYPos ); // Find out how long open/close lines need to be in case we // need them. We make them 1/10 of the space available for one // "stock". int openCloseTickLength = static_cast<int>( pointDist * 0.1 ); // we need these here because we might need to consider these // later when drawing the low and high labels bool hasOpen = false, hasClose = false; double openValue = 0.0, openDrawValue = 0.0, closeValue = 0.0, closeDrawValue = 0.0; // if we have an open/close chart, show the open value if( params()->hiLoChartSubType() == KDChartParams::HiLoOpenClose ) { // Only do this if there is a value in the third col. if( data->cellCoord( dataset, 2, valueA, 1 ) && QVariant::Double == valueA.type() ) { hasOpen = true; openValue = valueA.toDouble(); openDrawValue = openValue * pixelsPerUnit; painter->drawLine( xpos - openCloseTickLength, static_cast<int>( zeroXAxisI - openDrawValue ), xpos, static_cast<int>( zeroXAxisI - openDrawValue ) ); } } // If we have an open/close chart or a close chart, show the // close value, but only if there is a value in the // corresponding column (2 for HiLoClose, 3 for // HiLoOpenClose). if( ( params()->hiLoChartSubType() == KDChartParams::HiLoClose && data->cellCoord( dataset, 2, valueA, 1 ) && QVariant::Double == valueA.type() ) || ( params()->hiLoChartSubType() == KDChartParams::HiLoOpenClose && data->cellCoord( dataset, 3, valueB, 1 ) && QVariant::Double == valueB.type() ) ) { hasClose = true; closeValue = ( params()->hiLoChartSubType() == KDChartParams::HiLoClose ) ? valueA.toDouble() : valueB.toDouble(); closeDrawValue = closeValue * pixelsPerUnit; painter->drawLine( xpos, static_cast<int>( zeroXAxisI - closeDrawValue ), xpos + openCloseTickLength, static_cast<int>( zeroXAxisI - closeDrawValue ) ); } // Draw the low value, if requested. if( params()->hiLoChartPrintLowValues() ) { // PENDING(kalle) Number formatting? QFont theFont( params()->hiLoChartLowValuesFont() ); if ( params()->hiLoChartLowValuesUseFontRelSize() ) { int nTxtHeight = static_cast < int > ( params()->hiLoChartLowValuesFontRelSize() * averageValueP1000 ); theFont.setPointSizeFloat( nTxtHeight ); } KDChartTextPiece lowText( painter, QString::number( lowValue ), theFont ); int width = lowText.width(); int height = lowText.height(); // Check whether there is enough space below the data display int valX = 0, valY = 0; //qDebug("\nzeroXAxisI %f lowDrawValue %f height %i logHeight %f _dataRect.y() %i axisYOffset %f",zeroXAxisI,highDrawValue,height,logHeight,_dataRect.y(),axisYOffset); //qDebug("zeroXAxisI - lowDrawValue + height %f < axisYOffset + logHeight %f", //zeroXAxisI - lowDrawValue + height, axisYOffset+logHeight); if( zeroXAxisI - lowDrawValue + height < axisYOffset+logHeight ) { // enough space valX = xpos - ( width / 2 ); valY = (int)lowDrawValue - lowText.fontLeading(); } else { // not enough space - move to left if( !hasOpen || height < openDrawValue ) { // Either there is no open value or it is high enough // that we can put the low value to the left. valX = xpos - width - nLineWidth; valY = static_cast<int>(zeroXAxisI) - lowYPos + height/2 + nLineWidth/2; }// else ; // no way to draw it (really?) } lowText.draw( painter, valX, static_cast<int>( zeroXAxisI - valY ), ourClipRect, params()->hiLoChartLowValuesColor() ); } // Draw the high value, if requested. if( params()->hiLoChartPrintHighValues() ) { // PENDING(kalle) Number formatting? QFont theFont( params()->hiLoChartHighValuesFont() ); if ( params()->hiLoChartHighValuesUseFontRelSize() ) { int nTxtHeight = static_cast < int > ( params()->hiLoChartHighValuesFontRelSize() * averageValueP1000 ); theFont.setPointSizeFloat( nTxtHeight ); } KDChartTextPiece highText( painter, QString::number( highValue ), theFont ); int width = highText.width(); int height = highText.height(); // Check whether there is enough space above the data display int valX = 0, valY = 0; if( zeroXAxisI - highDrawValue - height > axisYOffset ) { // enough space valX = xpos - ( width / 2 ); valY = (int)highDrawValue + highText.fontLeading() + height; } else { // not enough space - move to right if( !hasClose || height < ( _dataRect.height() - closeDrawValue ) ) { // Either there is no close value or it is low enough // that we can put the high value to the right. valX = xpos + nLineWidth; valY = static_cast<int>(zeroXAxisI) - highYPos + height/2 - nLineWidth/2; } //else ; // no way to draw it (really?) } highText.draw( painter, valX, static_cast<int>( zeroXAxisI - valY ), ourClipRect, params()->hiLoChartHighValuesColor() ); } // Draw the open value, if requested. if( params()->hiLoChartPrintOpenValues() && params()->hiLoChartSubType() == KDChartParams::HiLoOpenClose ) { // PENDING(kalle) Number formatting? QFont theFont( params()->hiLoChartOpenValuesFont() ); if ( params()->hiLoChartOpenValuesUseFontRelSize() ) { int nTxtHeight = static_cast < int > ( params()->hiLoChartOpenValuesFontRelSize() * averageValueP1000 ); theFont.setPointSizeFloat( nTxtHeight ); } KDChartTextPiece openText( painter, QString::number( openValue ), theFont ); int width = openText.width(); int height = openText.height(); // We can pretty safely assume that there is always enough // space to the left and right of the data display. int valX = 0, valY = 0; valX = xpos - openCloseTickLength - width; valY = (int)openDrawValue + ( height / 2 ); openText.draw( painter, valX, static_cast<int>( zeroXAxisI - valY ), ourClipRect, params()->hiLoChartOpenValuesColor() ); } // Draw the close value, if requested. if( params()->hiLoChartPrintCloseValues() && ( params()->hiLoChartSubType() == KDChartParams::HiLoOpenClose || params()->hiLoChartSubType() == KDChartParams::HiLoClose ) ) { // PENDING(kalle) Number formatting? QFont theFont( params()->hiLoChartCloseValuesFont() ); if ( params()->hiLoChartCloseValuesUseFontRelSize() ) { int nTxtHeight = static_cast < int > ( params()->hiLoChartCloseValuesFontRelSize() * averageValueP1000 ); theFont.setPointSizeFloat( nTxtHeight ); } KDChartTextPiece closeText( painter, QString::number( closeValue ), theFont ); //int width = closeText.width(); int height = closeText.height(); // We can pretty safely assume that there is always enough // space to the left and right of the data display. int valX = 0, valY = 0; valX = xpos + openCloseTickLength; valY = (int)closeDrawValue + ( height / 2 ); closeText.draw( painter, valX, static_cast<int>( zeroXAxisI - valY ), ourClipRect, params()->hiLoChartCloseValuesColor() ); } } else continue; // we cannot display this value } }
int displayPopup(SDL_Surface *screen, dataStore __attribute__((unused)) *data, menuDataStore *menuData) { /*Background */ int width = POPUP_WIDTH+2, height = POPUP_HEIGHT+2; SDL_Rect background = {screen->clip_rect.w/2-width/2,screen->clip_rect.h/2-height/2,width,height}; SDL_FillRect( screen, &background, SDL_MapRGB( screen->format, 0xFF, 0xFF, 0xFF )); background.x+=1; background.y+=1; background.w-=2; background.h-=2; SDL_FillRect( screen, &background, SDL_MapRGB( screen->format, 0x00, 0x00, 0x00 )); /*Draw Text */ SDL_Surface *message; TTF_Font *font = theFont(24); SDL_Color textColor = { 255, 255, 255,0}; //SDL_Color textColor = { 0, 0, 0, 0}; if (!(message = TTF_RenderText_Blended( font, menuData->text, textColor ))) { printf("%s\n",TTF_GetError()); return 1; } SDL_Rect textRect = {background.x+20,background.y+10,0,0}; if(0!=SDL_BlitSurface( message, NULL, screen, &textRect)) { printf("%s\n",SDL_GetError()); return 1; } /*DrawTextField*/