Пример #1
0
void GLWdock::draw(GLwindowState &ws, double t){
	typedef Entity::Dockable Dockable;
	int ix;
	if(!docker)
		return;
	GLWrect cr = clientRect();
	glColor4ub(255,255,255,255);
	glwpos2d(cr.x0, cr.y0 + 1 * getFontHeight());
	glwprintf("Resource Units: %.0lf", docker->e->getRU());
	glColor4ub(255,255,0,255);
	int fonth = getFontHeight();
	int iy = 0;

	if(!docker)
		return;
	glColor4ub(255,255,255,255);
	glwpos2d(cr.x0, cr.y0 + (2 + iy++) * fonth);
	glwprintf("Cool: %lg", docker->baycool);
	glwpos2d(cr.x0, cr.y0 + (2 + iy++) * fonth);
	glwprintf("Remain docked: %s", docker->remainDocked ? "Yes" : "No");
	glwpos2d(cr.x0, cr.y0 + (2 + iy++) * fonth);
	glwprintf("Grouping: %s", grouping ? "Yes" : "No");
	glwpos2d(cr.x0, cr.y0 + (2 + iy++) * fonth);
	glwprintf("Docked:");
	glColor4ub(255,255,255,255);

	int mx = ws.mx - cr.x0, my = ws.my - cr.y0;
	/* Mouse cursor highlights */
	if(!modal && 0 < mx && mx < width && (iy - 2 <= my / fonth && my / fonth <= iy - 1 || (1 + iy) * fonth < my)){
		glColor4ub(0,0,255,127);
		glRecti(cr.x0, cr.y0 + (my / fonth) * fonth, cr.x1, cr.y0 + (my / fonth + 1) * fonth);
		glColor4ub(255,255,255,255);
	}

	if(grouping){
		std::map<cpplib::dstring, int> map;

		for(WarField::EntityList::iterator it = docker->el.begin(); it != docker->el.end(); it++) if(*it){
			Entity *e = (*it)->toDockable();
			if(e)
				map[e->dispname()]++;
		}
		for(std::map<cpplib::dstring, int>::iterator it = map.begin(); it != map.end(); it++){
			glwpos2d(cr.x0, cr.y0 + (2 + iy++) * fonth);
			glwprintf("%d X %s", it->second, (const char*)it->first);
		}
	}
	else{
		for(WarField::EntityList::iterator it = docker->el.begin(); it != docker->el.end(); it++) if(*it){
			Entity *e = (*it)->toDockable();
			if(!e)
				continue;
			if(height < (2 + iy) * fonth)
				return;
			glwpos2d(cr.x0, cr.y0 + (2 + iy++) * fonth);
			glwprintf("%d X %s %lg m^3", 1, e->dispname(), e->getHitRadius() * e->getHitRadius() * e->getHitRadius());
		}
	}
}
Пример #2
0
void CharsetRendererClassic::printChar(int chr, bool ignoreCharsetMask) {
	int width, height, origWidth, origHeight;
	int offsX, offsY;
	VirtScreen *vs;
	const byte *charPtr;
	bool is2byte = (chr >= 256 && _vm->_useCJKMode);

	assertRange(1, _curId, _vm->_numCharsets - 1, "charset");

	if ((vs = _vm->findVirtScreen(_top)) == NULL && (vs = _vm->findVirtScreen(_top + getFontHeight())) == NULL)
		return;

	if (chr == '@')
		return;

	translateColor();

	_vm->_charsetColorMap[1] = _color;

#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
	processTownsCharsetColors(_bytesPerPixel);
	bool noSjis = false;

	if (_vm->_game.platform == Common::kPlatformFMTowns && _vm->_useCJKMode) {
		if ((chr & 0x00ff) == 0x00fd) {
			chr >>= 8;
			noSjis = true;
		}
	}
Пример #3
0
static void splash_scene() {
	uint32_t highscore;
	char highnick[20];

	char key = 0;
	while(key == 0) {
		getInputWaitRelease();

		int dy = getFontHeight();
		int s1x = DoString(0, 0, "r0ket");
		s1x = (RESX-s1x)/2;
		int s2x = DoString(0, 0, "JUMP!");
		s2x = (RESX-s2x)/2;

		lcdFill(0);
		
		DoString(s1x, 3*dy, "r0ket");
		DoString(s2x, 4*dy, "JUMP!");
		DoString(0, 7*dy, "by webholics");

		highscore = highscore_get(highnick);

		int s3x = DoInt(0, 0, highscore);
		DoChar(s3x, 0, 'm');
		DoString (0, dy, highnick);

		lcdDisplay();

		key = getInputWaitTimeout(1000);
	}
}
Пример #4
0
void Font::drawString(Surface *dst, const Common::String &str,
                      int x, int y, int with_color, int spacing, bool markDirty) const {
    assert(dst != NULL);
    assert(x >= 0);
    assert(y >= 0);

    uint widest = getStringWidth(str, spacing);

    int curx = x + (widest - getLineWidth(str, 0, spacing)) / 2;
    int cury = y;

    for (uint i = 0; i < str.size(); ++i) {

        // If we encounter the '|' char (newline and end of string marker),
        // skip it and go to the start of the next line
        if (str[i] == '|') {
            cury += getFontHeight();
            curx = x + (widest - getLineWidth(str, i+1, spacing) - 1) / 2;
            continue;
        }

        // Break early if there's no more space on the screen
        if (curx >= dst->w - 1 || cury >= dst->h - 1) {
            break;
        }

        drawChar(dst, str[i], curx, cury, with_color);
        curx += getCharWidth(str[i]) + spacing;
    }

    if (markDirty) {
        Common::Rect r(x, y, x + widest, y + getStringHeight(str));
        dst->markDirtyRect(r);
    }
}
Пример #5
0
void drawUsage(double usage)
{
	int lineHeight = getFontHeight();
	int y1 = lcdGetCrsrY();
	int y2 = y1 + lineHeight;
	static const int frameSize = 1;
	BYTE color_frame = 0x00;

	// Colors: green - yellow - red
	static const BYTE colors[] = {
		0x1C, 0x3C, 0x5C, 0x7C, 0x9C, 0xBC, 0xDC, 0xFC,
		0xF8, 0xF4, 0xF0, 0xEC, 0xE8, 0xE4, 0xE0
	};

	drawRectFill(0, y1+frameSize, frameSize, lineHeight-2*frameSize, color_frame);
	drawRectFill(0, y1, 3*frameSize, frameSize, color_frame);
	drawRectFill(0, y2-frameSize, 3*frameSize, frameSize, color_frame);

	drawRectFill(RESX-frameSize, y1+frameSize, frameSize, lineHeight-2*frameSize, color_frame);
	drawRectFill(RESX-3*frameSize, y1, 3*frameSize, frameSize, color_frame);
	drawRectFill(RESX-3*frameSize, y2-frameSize, 3*frameSize, frameSize, color_frame);

	int lines = (RESX - 2*frameSize - 1) * usage + 0.5;
	for(int i = 0; i < lines; ++i)
		drawVLine(frameSize + i, y1 + frameSize, y2 - frameSize - 1, colors[(int)((double)i / (RESX-2*frameSize) * sizeof(colors) + 0.5)]);

	lcdNl();
}
Пример #6
0
	void Text::display() {
		auto tp = _position;

		auto font = _batcher->getFont();

		auto fontHeight = font->getFontHeight();
		auto start = font->getFontStart();
		auto length = font->getFontLength();

		auto glyphs = font->getFontGlyphs();
		if(!_used) {
			_index = _batcher->addString();
		}

		for(int i = 0; _text[i] != 0; i++) {
			char c = _text[i];
			if(_text[i] == '\n') {
				tp.y += fontHeight * _scaling.y;
				tp.x = _position.x;
			} else {
				// Check for correct glyph
				auto gi = c - start;
				if(gi < 0 || gi >= length)
					gi = length;
				glm::vec4 destRect(tp, glyphs[gi].size * _scaling);
				//Add the character to the font batcher
				_batcher->add(destRect, glyphs[gi].uvRect, _depth, _tint, _index);
				tp.x += glyphs[gi].size.x * _scaling.x;
			}
		}
	}
	float GetTextHeight(std::string text, Vector widheimult)
	{
		static bool force_highquality = true;
		static bool use_bit = force_highquality||XMLSupport::parse_bool(vs_config->getVariable ("graphics","high_quality_font","false"));
		static float font_point = XMLSupport::parse_float (vs_config->getVariable ("graphics","font_point","16"));
		return use_bit ? getFontHeight() : (font_point * 2 / g_game.y_resolution);
	}
Пример #8
0
void ThemeEngine::drawRadiobutton(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state) {
	if (!ready())
		return;

	Common::Rect r2 = r;
	DrawData dd = kDDRadiobuttonDefault;

	if (checked)
		dd = kDDRadiobuttonSelected;

	if (state == kStateDisabled)
		dd = kDDRadiobuttonDisabled;

	const int checkBoxSize = MIN((int)r.height(), getFontHeight());

	r2.bottom = r2.top + checkBoxSize;
	r2.right = r2.left + checkBoxSize;

	queueDD(dd, r2);

	r2.left = r2.right + checkBoxSize;
	r2.right = r.right;

	queueDDText(getTextData(dd), getTextColor(dd), r2, str, false, false, _widgets[kDDRadiobuttonDefault]->_textAlignH, _widgets[dd]->_textAlignV);
}
Пример #9
0
static void batteryLevel(void)
{
    int dy = 0;
    int dx = 0;
    int32_t voltage = 0;
    float purcentage = 0;
    uint8_t color = 0x00;

    setExtFont("normal");
    dy = RESY - getFontHeight();
    dx = DoString(dx, dy, "Bat");

    if (batteryCharging()) {
        dx = DoString(dx, dy, "(+)");
    }
    dx = DoString(dx, dy, ":");

    voltage = batteryGetVoltage();
    purcentage = (voltage - (float)BAT_MIN) / ((float)BAT_MAX - BAT_MIN) * 100.0;

    if (purcentage >= 50) {
        color = RGB(0, 7, 0);
    }
    else if (purcentage >= 10) {
        color = RGB(7, 7, 0);
    }
    else {
        color = RGB(7, 0, 0);
    }
    setTextColor(GLOBAL(nickbg), color);
    dx = DoString(dx, dy, IntToStr(purcentage, 3, F_LONG));
    DoString(dx, dy, "%");
    resetColor();
}
Пример #10
0
static bool gameover_scene() {
	int dy = getFontHeight();
	int s1x = DoString(0, 0, "GAME OVER!");
	s1x = (RESX-s1x)/2;
	int s2x = DoString(0, 0, "HIGHTSCORE!");
	s2x = (RESX-s2x)/2;

	char key = 0;
	while(key != BTN_UP && key != BTN_DOWN) {
		lcdClear();

		if(highscore_set(game.scroll_pos / 15, GLOBAL(nickname)))
			DoString (s2x, dy, "HIGHSCORE!");
		else
			DoString(s1x, dy, "GAME OVER!");

		int x = DoInt(0, 3*dy, game.scroll_pos / 15);
		DoChar(x, 3*dy, 'm');

		DoString(0, 5*dy, "UP to play");
		DoString(0, 6*dy, "DOWN to quit");

		lcdDisplay();

		key = getInputWaitTimeout(5000);
	}

	return !(key==BTN_DOWN);
}
Пример #11
0
//------------------------------------------------------------------------------
// Outline Font functions
// FtglOutlineFont::outputText() -- FTGLOutlineFont output routines
//------------------------------------------------------------------------------
void FtglOutlineFont::outputText(const double x, const double y, const char* txt, const int n, const bool vf, const bool)
{
    // Make sure we have characters to print
    if (n <= 0) return;


    // Make sure we have a loaded font
    if (isNotLoaded()) {
        loadFont();
        if (isNotLoaded()) throw new ExpInvalidFont();
    }

    // Prepare the output text
    char cbuf[MSG_BUF_LEN];
    int nn = xferChars(cbuf,MSG_BUF_LEN,txt,n);
    if (nn <= 0) return;

    // Output the text
    FTGLOutlineFont* ftgl1 = static_cast<FTGLOutlineFont*>(FTGL());
    if (ftgl1 != nullptr) {
        glPushMatrix();
        glTranslated(x, y, 0.0);
        glScalef(static_cast<GLfloat>(getFontWidth()), static_cast<GLfloat>(getFontHeight()), 1.0f);
        if (vf) {
            // Vertical text
            GLdouble dy = getLineSpacing();
            if (getFontHeight() != 0.0) dy = getLineSpacing() / getFontHeight();
            char cc[2];
            cc[1] = '\0';
            for (int i = 0; i < nn; i++) {
                cc[0] = cbuf[i];
                ftgl1->Render(cc);
                glTranslated(0.0, -dy, 0.0);
            }
        }
        else {
            // Normal text
            ftgl1->Render(cbuf);
        }
        glPopMatrix();
    }
    else {
        if (isMessageEnabled(MSG_ERROR)) {
            std::cerr << "FtglOutlineFont::outputText() - no outline font available" << std::endl;
        }
    }
}
Пример #12
0
TextAdder::TextAdder(const size_t wSpace, const size_t hSpace, const CvScalar color, const double scale):
  wSpace_(wSpace),
  hSpace_(hSpace),
  scale_(scale),
  font_( cvFont(scale_) ),
  color_(color),
  fontHeight_( getFontHeight() )
{ }
Пример #13
0
static int getAdjustedTextY(Font font, int wantedY) {
  if (wantedY < 0) return 0;
  const int fontHeight = (int) getFontHeight(font);
  if (fontHeight + wantedY >= COM_SIZE) {
    return COM_SIZE - fontHeight;
  }
  return wantedY;
}
Пример #14
0
void CALabel::updateImage()
{
    
    CAImage *tex = new CAImage();

    float fontHeight = getFontHeight(m_nfontName.c_str(), m_nfontSize);
    

    unsigned int linenumber = (int)this->getBounds().size.height/fontHeight;
    CCSize size = CCSizeZero;
    if ((m_nNumberOfLine <= linenumber && m_nNumberOfLine != 0))
    {
        size = CCSizeMake(this->getBounds().size.width, fontHeight*m_nNumberOfLine);
    }
    else
    {
        
        size = this->getBounds().size;
        
    }

    tex->initWithString(m_nText.c_str(),
                        m_nfontName.c_str(),
                        m_nfontSize* CC_CONTENT_SCALE_FACTOR(),
                        size,
                        m_nTextAlignment,
                        m_nVerticalTextAlignmet);
    
    m_cLabelSize = tex->getContentSize();
    
    CCRect rect = CCRectZero;
    rect.size.width = this->getBounds().size.width;
    rect.size.height = tex->getContentSize().height;
    float width = MIN(this->getBounds().size.width,tex->getContentSize().width);
    rect.size.width = width;
    
    this->setImage(tex);
    
    switch (m_nVerticalTextAlignmet)
    {
        case CAVerticalTextAlignmentTop:
            pTextHeight =0;
            break;
        case CAVerticalTextAlignmentCenter:
            pTextHeight =(this->getBounds().size.height-rect.size.height)/2;
            break;
        case CAVerticalTextAlignmentBottom:
            pTextHeight =this->getBounds().size.height - rect.size.height;
            break;
        default:
            break;
    }
    
    this->setImageRect(rect);
    tex->release();

    return ;
}
Пример #15
0
void board_menu_draw(board_t* b)
{
  setTextColor(0, 0xff);
  setIntFont(&Font_7x8);

  const int lineh = getFontHeight();

  lcdSetCrsr(0, 0);
  lcdPrintln("0xb number game");
  lcdPrintln("Push < > ^ v");
  lcdPrintln("Add same blocks");
  lcdPrint("Try to reach '");
  setTextColor(colors[N_COLORS-1].bg, colors[N_COLORS-1].fg);
  lcdPrint("b");
  setTextColor(0, 0xff);
  lcdPrintln("'!");
  lcdNl();

  for (uint i = 0; i < menu_N; i ++) {
    if (i == b->menu_item)
      lcdPrint(">> ");
    else
      lcdPrint("   ");
    lcdPrint(menu_str[i]);

    switch (i) {
      case 3:
        // width
        lcdPrint(" = ");
        lcdPrint(IntToStr(b->w, 2, 0));
        break;
      case 4:
        // height
        lcdPrint(" = ");
        lcdPrint(IntToStr(b->h, 2, 0));
      default:
        break;
    }
    lcdNl();
  }

  if (b->menu_item == 2) {
    lcdPrintln(font_list[b->font]);
    if (b->font == FONT_NONE) {
      uint w = RESX / N_COLORS;
      for (uint8_t i = 0; i < N_COLORS; i++) {
        const color_t* col = colors + i;
        setTextColor(col->bg, col->fg);
        DoRect(i*w, 120, w, 10);
      }
    }
    else {
      setExtFont(font_list[b->font]);
      lcdPrint("789ab");
    }
  }
}
Пример #16
0
void printHeader()
{
	int lineHeight = getFontHeight();
	BYTE color = 0x00;

	lcdMoveCrsr(3, 2);
	lcdPrintln("System Information");
	lcdMoveCrsr(0, -2);
	drawHLine(lineHeight+3, 0, RESX-1, color);
	lcdNl();
}
Пример #17
0
static void
initStrings(ModeInfo * mi)
{
	imagestruct *ip = &ims[MI_SCREEN(mi)];
	char *p, *p2, *p3, buf[BUFSIZ];
	int height, w, i, j;

	p = strncpy(buf, message, BUFSIZ);
	while (strlen(p) > 0) {
		p2 = p + strlen(p) - 1;
		if (*p2 == '\n')
			*p2 = 0;
		else
			break;
	}
	for (height = 0; p && height < MAXLINES; height++) {
		if (!(p2 = (char *) strchr(p, '\n')) ||
				!p2[1]) {
			p2 = p + strlen(p);
		}
		/* p2 now points to the first '\n' */
		*p2 = 0;
		for (w = 0; w < p2 - p; w++) {
			p3 = p + w;
			if (*p3 == '\t') /* this should be improved */
				*p3 = ' ';
		}
		(void) strncpy(ip->strnew[height], p,
			MAXWIDTH - 1);
		ip->strnew[height][MAXWIDTH - 1] = '\0';
		if (p == p2)
			break;
		p = p2 + 1;
	}
	ip->lines = height;
	j = 0;
	for (i = 0; i < ip->lines; i++) {
		if (ip->strnew[i] && *(ip->strnew[i])) {
			ip->textWidth[i] = getTextWidth(ip->strnew[i]) +
				getTextWidth((char *) "I");
			/* add a little more to give some border room */
			if (ip->textWidth[i] > ip->textWidth[j]) {
				j = i;
			}
		}
		ip->pixw = ip->textWidth[j];
	}
	for (i = 0; i < ip->lines; i++) {
		ip->textStart[i] = (ip->pixw - ip->textWidth[i]) / 2;
	}
	ip->text_height = getFontHeight(mode_font);
	ip->pixh = ip->lines * ip->text_height;
}
Пример #18
0
static void modeMessageInit(DisplayInternalInfo& displayInternalInfo, const void* param) {
  HT1632Class& HT1632 = displayInternalInfo.ht1632;

  if (param != nullptr) {
    snprintf(modeMessageData.msg, sizeof(modeMessageData.msg), "%s", (const char*) param);
  } else if (modeMessageData.modeMsgsIndex >= (ModeMsgsIndex) 0 && modeMessageData.modeMsgsIndex < modeMsgsIndexLast) {
    strncpy(modeMessageData.msg, modeMessageMsgs[modeMessageData.modeMsgsIndex], sizeof(modeMessageData.msg));
  }

  // runtime
  modeMessageData.wd = HT1632.getTextWidth(modeMessageData.msg,
					   getFontWidth(modeMessageData.font),
					   getFontHeight(modeMessageData.font));
}
Пример #19
0
/**
 * @brief Calculate the height of a string by counting the number of '|' chars (which
 *        are used as newline characters and end-of-string markers)
 *
 * @param str       String to draw
 * @param spacing   Space to leave between individual characters. Defaults to 0.
 *
 * @return The calculated height of the string
 */
uint Font::getStringHeight(const Common::String &str) const {
    uint len = str.size();
    int separators = 0;

    for (uint i = 0; i < len; ++i) {
        // All strings in the data files should end with '|' but not all do.
        // This is why we check whether we are at the last char too.
        if (str[i] == '|' || i == len - 1) {
            ++separators;
        }
    }

    return separators * getFontHeight();
}
Пример #20
0
void simpleNickname(void) {
    int dx=0;
	int dy=0;
    static uint32_t ctr=0;
	ctr++;

	setExtFont(GLOBAL(nickfont));
	dx=DoString(0,0,GLOBAL(nickname));
    dx=(RESX-dx)/2;
    if(dx<0)
        dx=0;
    dy=(RESY-getFontHeight())/2;

	lcdClear();
	DoString(dx,dy,GLOBAL(nickname));
	lcdDisplay();

    getInputWait();
    return;
}
Пример #21
0
static void dataLove(void)
{
    int dx = 50;
    int dy = 0;
    static int blue = 0;
    static int inc = 1;

    setTextColor(GLOBAL(nickbg), RGB(7, blue, 3));
    if (blue >= 7) {
        inc = -1;
    }
    else if (blue <= 0) {
        inc = 1;
    }
    blue += inc;
    setExtFont(GLOBAL(nickfont));
    dy= (RESY - getFontHeight()) / 3 * 2;
    DoString(dx, dy, "<3");
    resetColor();
}
UINodeServerSelector::UINodeServerSelector (IFrontend *frontend, int rows) :
		Super(frontend, 1, rows)
{
	_headlineFont = getFont(HUGE_FONT);
	_headlineHeight = _headlineFont->getCharHeight();
	setBackgroundColor(backgroundColor);
	setSize(0.8f, 0.6f);
	setScrollingEnabled(true);
	setPageVisible(false);
	setAlignment(NODE_ALIGN_CENTER | NODE_ALIGN_MIDDLE);
	setId("server-selector");
	setFont(HUGE_FONT);
	setRowHeight(getFontHeight() / static_cast<float>(_frontend->getHeight()));
	_mouseWheelScrollAmount = _rowHeight * _frontend->getHeight() * 5;
	Vector4Set(colorWhite, _fontColor);
	reset();
	setRowSpacing(2);
	_entryOffsetY = _headlineHeight;
	_colWidth = _size.x;
	setAutoColsRows();
}
Пример #23
0
void ram(void) {
    int dx=0;
	int dy=0;
    static uint32_t ctr=0;
	ctr++;

	setExtFont(GLOBAL(nickfont));
	dx=DoString(0,0,GLOBAL(nickname));
    dx=(RESX-dx)/2;
    if(dx<0)
        dx=0;
    dy=(RESY-getFontHeight())/2;

	lcdClear();
	DoString(dx,dy,GLOBAL(nickname));
	lcdRefresh();

    while(getInputRaw()==BTN_NONE){
        delayms_queue_plus(10,0);
    };
    return;
}
Пример #24
0
void simpleNickname(void) {
    int dx=0;
	int dy=0;
    static uint32_t ctr=0;
	ctr++;

	setExtFont(GLOBAL(nickfont));
	dx=DoString(0,0,GLOBAL(nickname));
    dx=(RESX-dx)/2;
    if(dx<0)
        dx=0;
    dy=(RESY-getFontHeight())/3;

    lcdFill(GLOBAL(nickbg));
    setTextColor(GLOBAL(nickbg),GLOBAL(nickfg));
	DoString(dx,dy,GLOBAL(nickname));
    dataLove();
    batteryLevel();
	lcdDisplay();

    getInputWaitTimeout(300);
    return;
}
Пример #25
0
static void drawBackgroundMessages(DisplayInternalInfo& displayInternalInfo) {
  HT1632Class& HT1632 = displayInternalInfo.ht1632;
  int boardId, i, j;
  for (i=0; i < BACKGROUND_MESSAGE_COUNT; ++i) {
    if (backgroundMessage[i].enabled == false) continue;
    if (willAnimate(&backgroundMessage[i].animation) == false) continue;
    for (j=0; j < BUFFER_SECONDARY; ++j) {
      switch (backgroundMessage[i].displayColor) {
        case displayColorGreen: boardId = 0; break;
        case displayColorRed: boardId = 1; break;
        case displayColorYellow:  // fall thru...
        default: boardId = j; break;
      }
      HT1632.drawTarget(BUFFER_BOARD(boardId+1));
      HT1632.drawText(backgroundMessage[i].msg, backgroundMessage[i].x, backgroundMessage[i].y,
		      getFontData(backgroundMessage[i].font),
		      getFontWidth(backgroundMessage[i].font),
		      getFontHeight(backgroundMessage[i].font),
		      getFontGlyphStep(backgroundMessage[i].font));
      if (backgroundMessage[i].displayColor != displayColorYellow) break;
    }
  }
}
Пример #26
0
static void mainloop(void)
{
    int dx=0;
	int dy=0;
    
	setExtFont(GLOBAL(nickfont));
	dx=DoString(0,0,GLOBAL(nickname));
    dx=(RESX-dx)/2;
    if(dx<0)
        dx=0;
    dy=(RESY-getFontHeight())/2;

	lcdClear();
    lcdSetPixel(1,1,1);
	DoString(dx,dy,GLOBAL(nickname));
    lcdRefresh();

    lk_ticks = 0;
    lk_button_mode = 0x00;
    lk_ls0 = 0x00;
    lk_ls1 = 0x00;
    lk_ls2 = 0x00;
    lk_ls3 = 0x00;
    lk_in0 = 0x00;
    lk_in1 = 0x00;
    lk_ticks = 0x0000;
    lk_piezo_toggle = 0x00;

    while(getInputRaw()==BTN_NONE){
        tick_lilakit();
        melody_play();
        //delayms_queue(10);    //XXX: this hangs the badge.
        delayms(10);
    }
    return;
}
Пример #27
0
int main(int argc, char *argv[])
{
    QScopedPointer<QApplication> app(createApplication(argc, argv));

#ifdef Q_OS_SYMBIAN
    // Translation for NFC Status messages
    QString locale = QLocale::system().name();

    QTranslator translator;
    translator.load(QString("nfcinteractor_") + locale);
    app->installTranslator(&translator);

    QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
#endif

    // Create a variable that stores the platform, to customize the
    // screen appearance in QML accordingly.
#if defined(Q_OS_SYMBIAN)
    int platformId = 0;
#elif defined(MEEGO_EDITION_HARMATTAN)
    int platformId = 1;
#elif defined(QT_SIMULATOR)
    int platformId = 2;
#else
    int platformId = 3;
#endif


    // Register the Nfc interaction classes to the QML environment
    qmlRegisterType<NfcInfo>("Nfc", 1, 0, "NfcInfo");
    qmlRegisterType<NfcRecordModel>("Nfc", 1, 0, "NfcRecordModel");
    qmlRegisterType<NfcRecordItem>("Nfc", 1, 0, "NfcRecordItem");
    qmlRegisterUncreatableType<NfcTypes>("com.nfcinfo.types", 1, 0,
                                                 "NfcTypes", "This exports NfcTypes enums to QML");

    // Setup QML Viewer
    QmlApplicationViewer viewer;
    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    viewer.rootContext()->setContextProperty("platform", platformId);

    // On MeeGo, only allow activating SNEP if compiled with the library support
    // (not permitted otherwise).
    bool useSnep = true;
#if defined(MEEGO_EDITION_HARMATTAN) && !defined(USE_SNEP)
    useSnep = false;
#endif
    viewer.rootContext()->setContextProperty("allowSnep", QVariant(useSnep));

    AppSettings* settings = new AppSettings();  // Ownership will be transferred to NfcInfo*
    viewer.rootContext()->setContextProperty("settings", settings);

    // Symbian has style constants defined in platformStyle, MeeGo has a
    // different system.
    // To minimize QML code differences between both versions, define
    // a customPlatformStyle here, used by both versions.
    // (Unfortunately it's not possible to use the original
    // "platformStyle" on Symbian and set a "platformStyle" on MeeGo,
    // because the Window already has platformStyle property, which
    // would have preference over setting a context property from here)
    QScopedPointer<QDeclarativePropertyMap> platformStyle(new QDeclarativePropertyMap());
    platformStyle->insert("paddingSmall", QVariant(4));
    platformStyle->insert("paddingMedium", QVariant(8));
    platformStyle->insert("paddingLarge", QVariant(12));
    platformStyle->insert("fontSizeSmall", QVariant(18));
    platformStyle->insert("colorNormalLight", QVariant(QColor(255, 255, 255)));
    platformStyle->insert("colorNormalMid", QVariant(QColor(153, 153, 153)));
#if defined(MEEGO_EDITION_HARMATTAN)
    qDebug() << "MeeGo UI platform style";
    platformStyle->insert("fontFamilyRegular", QVariant(QString("Nokia Pure Text")));
    platformStyle->insert("fontSizeMedium", QVariant(22));
    platformStyle->insert("fontHeightMedium", QVariant(getFontHeight(QString("Nokia Pure Text"), 22)));
    platformStyle->insert("fontSizeLarge", QVariant(26));
#else
    qDebug() << "Symbian UI platform style";
    platformStyle->insert("fontFamilyRegular", QVariant(QFont().defaultFamily()));
    platformStyle->insert("fontSizeMedium", QVariant(20));
    platformStyle->insert("fontHeightMedium", QVariant(getFontHeight(QFont().defaultFamily(), 20)));
    platformStyle->insert("fontSizeLarge", QVariant(22));
#endif
    viewer.rootContext()->setContextProperty("customPlatformStyle", platformStyle.data());

    // Register the image provider class to QML
    TagImageCache *tagImageCache = new TagImageCache();
    viewer.engine()->addImageProvider(QLatin1String("nfcimageprovider"), tagImageCache);

#ifdef USE_IAP
    // In App Purchasing
    qDebug() << "Using IAP";
    viewer.rootContext()->setContextProperty("useIap", QVariant(true));
    #if defined(Q_OS_SYMBIAN)
        // In App Purchasing APIs on Symbian
        QScopedPointer<IapManager> iapManager(new IapManager());
        // Add the known items to the list
        // Also retrieves if the user has already purchased the items
        // from the internal DB, to prevent the need to go online
        // every time.
        iapManager->addIapProduct(IAP_ID_ADV_TAGS);
        iapManager->addIapProduct(IAP_ID_REMOVE_ADS);
        iapManager->addIapProduct(IAP_ID_UNLIMITED);
        viewer.rootContext()->setContextProperty("iapManager", iapManager.data());
        viewer.rootContext()->setContextProperty("iapIdAdvTags", QVariant(IAP_ID_ADV_TAGS));
        viewer.rootContext()->setContextProperty("iapIdRemoveAds", QVariant(IAP_ID_REMOVE_ADS));
        viewer.rootContext()->setContextProperty("iapIdUnlimited", QVariant(IAP_ID_UNLIMITED));
    #else
        // Unlimited version on Harmattan
        // No IAP APIs available -> separate product on Nokia Store
    #endif
#else
    viewer.rootContext()->setContextProperty("useIap", QVariant(false));
#endif

#ifdef IAP_TEST_MODE
    qDebug() << "IAP Test Mode";
    viewer.rootContext()->setContextProperty("iapTestMode", QVariant(true));
#else
    viewer.rootContext()->setContextProperty("iapTestMode", QVariant(false));
#endif

#ifdef USE_IAA
    // In App Advertising
    qDebug() << "Using IAA";
    #if defined(Q_OS_SYMBIAN) && defined(USE_IAP)
        // Define the pointer here; creating it in the if would instantly
        // destroy it again after the if ends, but we obviously need to
        // keep the instance alive till the app exits.
        // Use a scoped pointer so that we only need to create the instance
        // when the user hasn't purchased the remove ads upgrade, to speed
        // up app startup time if he has.
        //QScopedPointer<AdInterface> adI;
        // Symbian & using IAP - only start the ad interface if the user
        // didn't already purchase the remove ads upgrade
        if (!iapManager->isProductPurchased(IAP_ID_REMOVE_ADS)) {
            // IAA Upgrade not purchased - use IAA
            //AdInterface adI;
            //adI.reset(new AdInterface());
            //viewer.rootContext()->setContextProperty("adInterface", adI.data());
            inneractivePlugin::initializeEngine(viewer.engine());
            viewer.rootContext()->setContextProperty("useIaa", QVariant(true));
        } else {
            // IAA Upgrade purchased - don't use IAA
            viewer.rootContext()->setContextProperty("useIaa", QVariant(false));
        }
    #else
        // [Symbian and no IAP] or Harmattan
        //QScopedPointer<AdInterface> adI(new AdInterface());
        //viewer.rootContext()->setContextProperty("adInterface", adI.data());
        inneractivePlugin::initializeEngine(viewer.engine());
        viewer.rootContext()->setContextProperty("useIaa", QVariant(true));
    #endif
#else
    // IAA not activated
    viewer.rootContext()->setContextProperty("useIaa", QVariant(false));
#endif

    QScopedPointer<NfcInfo> nfcInfo(new NfcInfo());
    // Give the ndef manager a pointer to our declarative view,
    // so that it can raise the app to the foreground when an
    // autostart tag is touched and the app is already running.
    nfcInfo->setDeclarativeView(viewer);
    nfcInfo->setAppSettings(settings);
    nfcInfo->setImageCache(tagImageCache);
    // Pass the record model back to the QML
    // Could be easier to just make the model a property?
    viewer.rootContext()->setContextProperty("recordModel", nfcInfo->recordModel());
#ifdef USE_IAP
#ifdef Q_OS_SYMBIAN
    // Symbian: set unlimited tags according to whether it has been purchased already
    nfcInfo->setUnlimitedAdvancedMsgs(iapManager->isProductPurchased(IAP_ID_ADV_TAGS) || iapManager->isProductPurchased(IAP_ID_UNLIMITED));
#else
    // Harmattan: set unlimited tags according to whether IAP is enabled in the .pro file.
    // (if it is enabled, limit tag writing. If USE_IAP isn't set, use unlimited tag writing)
    nfcInfo->setUnlimitedAdvancedMsgs(false);
#endif
#endif

    // Make the nfcPeerToPeer class known in the QML world
    viewer.rootContext()->setContextProperty("nfcInfo", nfcInfo.data());

    // Finally, load the main QML file to the viewer.
    viewer.setMainQmlFile(QLatin1String("qml/main.qml"));

    viewer.showExpanded();

    //nfcInfo->initAndStartNfcAsync();

//#ifdef Q_OS_SYMBIAN
//    // Prevent screensaver from kicking in on Symbian
//    QSystemScreenSaver *screensaver = new QSystemScreenSaver ( &viewer );
//    screensaver->setScreenSaverInhibit();
//#endif

    return app->exec();
}
Пример #28
0
int lcdGetVisibleLines(void){
    return (RESY/getFontHeight()); // subtract title line
}
Пример #29
0
//------------------------------------------------------------------------------
// Halo Font functions
// FtglHaloFont::outputText() -- FtglHaloFont output routines
//------------------------------------------------------------------------------
void FtglHaloFont::outputText(const double x, const double y, const char* txt, const int n, const bool vf, const bool rf)
{
    GLfloat ocolor[4];
    glGetFloatv(GL_CURRENT_COLOR, ocolor);

    // Make sure we have characters to print
    if (n <= 0) return;

    // Make sure we have a loaded font
    if (isNotLoaded()) {
        loadFont();
        if (isNotLoaded()) throw new ExpInvalidFont();
    }

    // Prepare the output text
    char cbuf[MSG_BUF_LEN];
    int nn = xferChars(cbuf,MSG_BUF_LEN,txt,n);
    if (nn <= 0) return;

    if (haloColor != nullptr) Graphic::lcColor3(haloColor->red(), haloColor->green(), haloColor->blue());
    // default to black if we have no color specified
    else glColor3f(0,0,0);

    // now render the outline font over it!
    if (!rf) {
        if (outline != nullptr) {
            glPushMatrix();
            glTranslated(x, y, -0.01f);
            // get our current linewidth
            GLfloat lw = 0;
            glGetFloatv(GL_LINE_WIDTH, &lw);
            glLineWidth(linewidth);
            glScalef(static_cast<GLfloat>(getFontWidth()), static_cast<GLfloat>(getFontHeight()), 1.0f);
            if (vf) {
                // Vertical text
                GLdouble dy = getLineSpacing();
                if (getFontHeight() != 0.0) dy = getLineSpacing() / getFontHeight();
                char cc[2];
                cc[1] = '\0';
                for (int i = 0; i < nn; i++) {
                    cc[0] = cbuf[i];
                    outline->Render(cc);
                    glTranslated(0.0, -dy, 0.0);
                }
            }
            else {
                // Normal text
                outline->Render(cbuf);
            }
            glLineWidth(lw);
            glPopMatrix();
        }
        else {
              if (isMessageEnabled(MSG_ERROR)) {
                  std::cerr << "FtglHaloFont::outputText() - no outline font available" << std::endl;
              }
        }
    }

    glColor4fv(ocolor);

    // output the text
    FTGLPolygonFont* ftgl1 = static_cast<FTGLPolygonFont*>(FTGL());
    if (ftgl1 != nullptr) {
        glPushMatrix();
        glTranslated(x, y, 0.0);
        glScalef(static_cast<GLfloat>(getFontWidth()), static_cast<GLfloat>(getFontHeight()), 1.0f);
        if (vf) {
            // Vertical text
            GLdouble dy = getLineSpacing();
            if (getFontHeight() != 0.0) dy = getLineSpacing() / getFontHeight();
            char cc[2];
            cc[1] = '\0';
            for (int i = 0; i < nn; i++) {
                cc[0] = cbuf[i];
                ftgl1->Render(cc);
                glTranslated(0.0, -dy, 0.0);
            }
        }
        else {
            // Normal text
            ftgl1->Render(cbuf);
        }
        glPopMatrix();
    }
    else {
        if (isMessageEnabled(MSG_ERROR)) {
            std::cerr << "FtglPolygonFont::outputText() - no Polygon font available" << std::endl;
        }
    }
}
Пример #30
0
int TextPlane::Draw(const string & newText, int offset,bool startlower, bool force_highquality, bool automatte)
{
  int retval=1;
  bool drawbg = (bgcol.a!=0);
  static unsigned int * display_lists=CreateLists ();
	// some stuff to draw the text stuff
  string::const_iterator text_it = newText.begin();
  static bool use_bit = force_highquality||XMLSupport::parse_bool(vs_config->getVariable ("graphics","high_quality_font","false"));
  static float font_point = XMLSupport::parse_float (vs_config->getVariable ("graphics","font_point","16"));
  static bool font_antialias = XMLSupport::parse_bool (vs_config->getVariable ("graphics","font_antialias","true"));
  void * fnt = getFont();
  static float std_wid=glutStrokeWidth (GLUT_STROKE_ROMAN,'W');
  myFontMetrics.i=font_point*std_wid/(119.05+33.33);
  if (use_bit)
	  myFontMetrics.i=glutBitmapWidth(fnt,'W');
  myFontMetrics.j=font_point;
  myFontMetrics.i/=.5*g_game.x_resolution;
  myFontMetrics.j/=.5*g_game.y_resolution;
  float tmp,row, col;
  float origcol,origrow;
  GetPos (row,col);
  GetPos(row,origcol);
  float rowheight=use_bit?getFontHeight():myFontMetrics.j;
  myFontMetrics.j=rowheight;
  
	  
  if (startlower) {
      row -= rowheight;

  }
  GFXPushBlendMode();
  glLineWidth (1);
  if (!use_bit&&font_antialias) {
    GFXBlendMode (SRCALPHA,INVSRCALPHA);
	if(gl_options.smooth_lines)
	{
		glEnable(GL_LINE_SMOOTH);
	}
  }else {
	GFXBlendMode (SRCALPHA,INVSRCALPHA);
	if(gl_options.smooth_lines)
	{
		glDisable(GL_LINE_SMOOTH);
	}
  }
  GFXColorf(this->col);

  GFXDisable (DEPTHTEST);
  GFXDisable (CULLFACE);

  GFXDisable (LIGHTING);

  GFXDisable (TEXTURE0);
  GFXDisable (TEXTURE1);

  glPushMatrix();
  glLoadIdentity();
  if (!automatte&&drawbg) {
	GFXColorf(this->bgcol);
	DrawSquare(col,this->myDims.i,row-rowheight*.25,row+rowheight);
  }
  GFXColorf(this->col);

  int entercount=0;
  for (;entercount<offset&&text_it!=newText.end();text_it++) {
    if (*text_it=='\n')
      entercount++;
  }
  glTranslatef(col,row,0);  
  //  glRasterPos2f (g_game.x_resolution*(1-(col+1)/2),g_game.y_resolution*(row+1)/2);
  glRasterPos2f (0,0);
  float scalex=1;
  float scaley=1;
  int potentialincrease=0;
  if (!use_bit) {
    int numplayers=1;
    if (_Universe) // _Universe can be NULL during bootstrap.
      numplayers = (_Universe->numPlayers()>3?_Universe->numPlayers()/2:
                    _Universe->numPlayers());
    scalex=numplayers*myFontMetrics.i/std_wid;
    scaley=myFontMetrics.j/(119.05+33.33);
  }
  glScalef (scalex,scaley,1);
  bool firstThroughLoop=true;
  GFXColor currentCol (this->col);
  while(text_it != newText.end() && (firstThroughLoop||row>myDims.j-rowheight*.25)) {
    unsigned char myc = *text_it;
    if (myc=='_') {
      myc = ' ';
    }
    float shadowlen = 0;
    if(myc=='\t') {
      shadowlen=glutBitmapWidth(fnt,' ')*5./(.5*g_game.x_resolution);
    } else {
      if (use_bit) {
        shadowlen = glutBitmapWidth (fnt,myc)/(float)(.5*g_game.x_resolution); // need to use myc -- could have transformed '_' to ' '
      } else {
        shadowlen = myFontMetrics.i*glutStrokeWidth(GLUT_STROKE_ROMAN,myc)/std_wid;
      }
    }
    
    if (*text_it=='#') {
      if (newText.end()-text_it>6) {
	float r,g,b;
	r = TwoCharToFloat (*(text_it+1),*(text_it+2));
	g = TwoCharToFloat (*(text_it+3),*(text_it+4));
	b = TwoCharToFloat (*(text_it+5),*(text_it+6));
	if (r==0&&g==0&&b==0) {
		currentCol = this->col;
	}else {
		currentCol = GFXColor(r, g, b, this->col.a);
	}
	GFXColorf(currentCol);
        static bool setRasterPos= XMLSupport::parse_bool(vs_config->getVariable("graphics","set_raster_text_color","true"));
        if (use_bit&&setRasterPos)
          glRasterPos2f(col-origcol,0);
	text_it = text_it+6;
      } else {
        break;
      }
      text_it++;
      continue;
    }else if(*text_it>=32) {//always true
	  if(automatte){
		GFXColorf(this->bgcol);
		DrawSquare(col-origcol,col-origcol+shadowlen/scalex,-rowheight*.25/scaley,rowheight*.75/scaley);
		GFXColorf(currentCol);
	  }
      //glutStrokeCharacter (GLUT_STROKE_ROMAN,*text_it);
      retval+=potentialincrease;
      potentialincrease=0;
      int lists = display_lists[myc+(isInside()?128:0)];
      if (lists) {
	    GFXCallList(lists);
	  }else{
		 if (use_bit){
	        glutBitmapCharacter (fnt,myc);
		  }
		 else{
           glutStrokeCharacter (GLUT_STROKE_ROMAN,myc);
		 }
      }
	}
    if(*text_it=='\t') {
	  if(automatte){
		GFXColorf(this->bgcol);
		DrawSquare(col-origcol,col-origcol+shadowlen*5/(.5*g_game.x_resolution),-rowheight*.25/scaley,rowheight*.75/scaley);
		GFXColorf(currentCol);
	  }
      col+=shadowlen;
      glutBitmapCharacter (fnt,' ');
      glutBitmapCharacter (fnt,' ');
      glutBitmapCharacter (fnt,' ');
      glutBitmapCharacter (fnt,' ');
      glutBitmapCharacter (fnt,' ');
    } else {
      col+=shadowlen;
    }
    if(doNewLine(text_it,newText.end(),col,myDims.i, myFontMetrics.i,row-rowheight<=myDims.j)){
      GetPos (tmp,col);
      firstThroughLoop=false;
      row -= rowheight;
      glPopMatrix();
      glPushMatrix ();
      glLoadIdentity();
	  if (!automatte&&drawbg) {
		GFXColorf(this->bgcol);
		DrawSquare(col,this->myDims.i,row-rowheight*.25,row+rowheight*.75);
	  }
      if (*text_it=='\n') {
	    currentCol = this->col;
      }
	  GFXColorf(currentCol);
      glTranslatef (col,row,0);
      glScalef(scalex,scaley,1);
      glRasterPos2f(0,0);
      potentialincrease++;
	}
    text_it++;
  }
  if(gl_options.smooth_lines)
  {
	  glDisable(GL_LINE_SMOOTH);
  }
  glPopMatrix();

  
  GFXPopBlendMode();
  GFXColorf(this->col);
  return retval;
}