コード例 #1
0
void IND_TTF_FontManager::doDrawText(const std::string& strFontName,const std::wstring& s, float x, float y,
									  uint32_t clrFont,bool bFlipX, bool bFlipY, float fZRotate, byte btTrans, 
									  bool bKerning, bool bUnderl) {
	IND_TTF_Font *pFont = getFontByName(strFontName);
	if(pFont)
		pFont->drawText(s,x,y,clrFont, bFlipX,bFlipY,fZRotate,btTrans,bKerning,bUnderl);
}
コード例 #2
0
/**
 * TODO:describtion
 *
 * @param strFontName				Name of the font.
 * @param sx                        TODO: describtion
 * @param sy                        TODO: describtion
 */
void IND_TTF_FontManager::setFontScale(const std::string& strFontName, float sx, float sy) {
	IND_TTF_Font *pFont = getFontByName(strFontName);
	if(pFont) {
		pFont->setXScale(sx);
		pFont->setYScale(sy);
	}
}
コード例 #3
0
/**
 * TODO:describtion
 *
 * @param strFontName				Name of the font.
 * @param hsx                       TODO: describtion
 * @param hsy                       TODO: describtion
 */
void IND_TTF_FontManager::setFontHotSpot(const std::string& strFontName, float hsx, float hsy) {
	IND_TTF_Font *pFont = getFontByName(strFontName);
	if(pFont) {
		pFont->setXHotspot(hsx);
		pFont->setYHotspot(hsy);
	}
}
コード例 #4
0
/**
 * TODO:describtion
 *
 * @param strFontName				Name of the font.
 * @param s                         TODO: describtion
 */
bool IND_TTF_FontManager::CacheFontString(const std::string& strFontName, const std::wstring& s) {
	IND_TTF_Font *pFont = getFontByName(strFontName);
	if(pFont)
		return pFont->buildStringCache(s);

	return false;
}
コード例 #5
0
ファイル: fontman.cpp プロジェクト: Grimfan33/residual
const Font *FontManager::getFontByUsage(FontUsage usage) const {
	switch (usage) {
	case kConsoleFont:
		return g_consolefont;
	case kGUIFont:
		return g_sysfont;
	case kBigGUIFont:
		return g_sysfont_big;
	case kLocalizedFont:
	{
		// First try to find a kBigGUIFont
		Common::String fontName = getLocalizedFontNameByUsage(kBigGUIFont);
		if (!fontName.empty()) {
			const Font *font = getFontByName(fontName);
			if (font)
				return font;
		}
		// Try kGUIFont
		fontName = getLocalizedFontNameByUsage(kGUIFont);
		if (!fontName.empty()) {
			const Font *font = getFontByName(fontName);
			if (font)
				return font;
		}
#ifdef USE_TRANSLATION
		// Accept any other font that has the charset in its name
		for (Common::HashMap<Common::String, const Font *>::const_iterator it = _fontMap.begin() ; it != _fontMap.end() ; ++it) {
			if (it->_key.contains(TransMan.getCurrentCharset()))
				return it->_value;
		}
#endif
		// Fallback: return a non localized kGUIFont.
		// Maybe we should return a null pointer instead?
		return g_sysfont;
	}
	}

	return 0;
}
コード例 #6
0
int IND_TTF_FontManager::doDrawTextEx(const std::string& strFontName,const std::wstring& sText,
									float fLeft, float fTop, float fRight, float fBottom, 
									uint32_t nFormat, uint32_t clrFont, uint32_t clrBorder, uint32_t clrBack,
									byte btBorderTrans, byte btBackTrans, bool bFlipX, bool bFlipY, 
									float fZRotate, byte btTrans, bool bKerning, bool bUnderl) {
	IND_TTF_Font *pFont = getFontByName(strFontName);
	if(pFont)
		pFont->drawTextEx(	sText, fLeft, fTop, fRight, fBottom, nFormat, clrFont, clrBorder,
							clrBack,btBorderTrans, btBackTrans,
							bFlipX,bFlipY,fZRotate,btTrans,bKerning,bUnderl);

	return 0;
}
コード例 #7
0
ファイル: GuiService.cpp プロジェクト: Faianca/hikari
    GuiService::GuiService(const Json::Value & config, const std::weak_ptr<ImageCache> & imageCache, sf::RenderTarget & renderTarget)
        : Service()
        , renderTarget(renderTarget)
        , gui(new gcn::Gui())
        , graphics(new gcn::SFMLGraphics(renderTarget))
        , input(new gcn::SFMLInput())
        , imageLoader(nullptr)
        , rootWidget(new gcn::Container())
        , rootContainer(new gcn::Container())
        , hudContainer(new gcn::Container())
        , fontImageMap()
        , fontMap()
    {
        // Set up the global image loader (a proxy to the image caching service)
        imageLoader.reset(new gui::HikariImageLoader(imageCache));
        gcn::Image::setImageLoader(imageLoader.get());

        buildFontMap(config["gui"]["fonts"]);

        if(auto globalFont = getFontByName(DEFAULT_FONT_NAME)) {
            gcn::Widget::setGlobalFont(globalFont.get());
        }

        // Set up the GUI's inputs/outputs
        gui->setInput(input.get());
        gui->setGraphics(graphics.get());
        gui->setTop(rootWidget.get());

        // Base the root containers size off the size of the render target
        unsigned int windowWidth = renderTarget.getSize().x;
        unsigned int windowHeight = renderTarget.getSize().y;

        // The root widget is an internal container for the other "layers" of widgets.
        rootWidget->setSize(windowWidth, windowHeight);
        rootWidget->setX(0);
        rootWidget->setY(0);
        rootWidget->setBaseColor(gcn::Color(0, 0, 0, 0));

        // This is where game state widgets go (almost everything)
        rootContainer->setSize(windowWidth, windowHeight);
        rootContainer->setX(0);
        rootContainer->setY(0);
        rootContainer->setBaseColor(gcn::Color(0, 0, 0, 0));

        // This is where overlaying widgets go (fps counter, console, etc.)
        hudContainer->setSize(windowWidth, windowHeight);
        hudContainer->setX(0);
        hudContainer->setY(0);
        hudContainer->setBaseColor(gcn::Color(0, 0, 0, 0));

        // The HUD container is always the "front"-most widget.
        rootWidget->add(rootContainer.get());
        rootWidget->add(hudContainer.get());

        // Set up key mappings
        // TODO: Get actual key mappings
        gui::InputHelper::setMappedButtonForKey(gcn::Key::Up, Input::BUTTON_UP);
        gui::InputHelper::setMappedButtonForKey(gcn::Key::Right, Input::BUTTON_RIGHT);
        gui::InputHelper::setMappedButtonForKey(gcn::Key::Down, Input::BUTTON_DOWN);
        gui::InputHelper::setMappedButtonForKey(gcn::Key::Left, Input::BUTTON_LEFT);
        gui::InputHelper::setMappedButtonForKey('A', /* gcn::Key::A */ Input::BUTTON_SHOOT);
        gui::InputHelper::setMappedButtonForKey('S', /* gcn::Key::S */ Input::BUTTON_JUMP);
        gui::InputHelper::setMappedButtonForKey(gcn::Key::Enter, Input::BUTTON_START);
        gui::InputHelper::setMappedButtonForKey(gcn::Key::RightShift, Input::BUTTON_SELECT);
        gui::InputHelper::setMappedButtonForKey(gcn::Key::Escape, Input::BUTTON_CANCEL);
    }
コード例 #8
0
/**
 * TODO:describtion
 *
 * @param strFontName				Name of the font.
 * @param ba                        TODO: describtion
 */
void IND_TTF_FontManager::setFontAutoCache(const std::string& strFontName, bool ba) {
	IND_TTF_Font *pFont = getFontByName(strFontName);
	if(pFont)
		pFont->setAutoCache(ba);
}
コード例 #9
0
/**
 * Returns true if the font is allready added to the manager.
 *
 * @param strName					Name of the font.
 */
bool IND_TTF_FontManager::isFontLoaded(const std::string& strName) {
	return getFontByName(strName) != NULL;
}