int main(int argc, char * argv[]) { unsigned int width = 1024; unsigned int height = 768; bool fullscreen = false; BCIInterface * bciinterface = new BCIInterface(width, height); FontManager fm; FPSCounter fps_c(fm.GetDefaultFont()); UDPReceiver * receiver = new UDPReceiver(2222); TrainingInterpreter * interpreter = new TrainingInterpreter(width, height); bciinterface->SetCommandReceiver(receiver); bciinterface->SetCommandInterpreter(interpreter); bciinterface->AddObject(new SSVEPStimulus(6, 60, (float)width/2, 100, 200,200, 255, 0, 0, 255)); bciinterface->AddObject(new SSVEPStimulus(8, 60, (float)width-100, (float)height/2, 200, 200, 255, 0, 0, 255)); bciinterface->AddObject(new SSVEPStimulus(10, 60, (float)width/2, (float)height-100, 200, 200, 255, 0, 0, 255)); bciinterface->AddObject(new SSVEPStimulus(9, 60, 100, (float)height/2,200, 200, 255, 0, 0, 255)); bciinterface->AddObject(new SSVEPStimulus(14, 60, (float)width/2, (float)height/2, 200, 200, 255, 0, 0, 255)); bciinterface->AddNonOwnedObject(&fps_c); int cmd = -1; bciinterface->DisplayLoop(fullscreen); delete bciinterface; delete interpreter; delete receiver; return 0; }
void DisplayProfile(sf::RenderWindow * renderWindow, CProfileIterator * iter, int x, int & y) { if (!renderWindow) return; FontManager * fontManager = FontManager::Get(); y += 15; while ( !iter->Is_Done() ) { sf::Text text("", *fontManager->GetFont("")); text.setCharacterSize(12); ostringstream texte; if ( CProfileManager::Get_Frame_Count_Since_Reset() != 0 ) texte << fixed << iter->Get_Current_Name() << " Calls/Frame:" << iter->Get_Current_Total_Calls()/CProfileManager::Get_Frame_Count_Since_Reset() << " Time/Frame:" << iter->Get_Current_Total_Time()/CProfileManager::Get_Frame_Count_Since_Reset() << " %Time/Parent " << iter->Get_Current_Total_Time()/iter->Get_Current_Parent_Total_Time()*100.0f; text.setString(texte.str()); text.setPosition(x,y); renderWindow->draw(text); //Childs CProfileIterator * childIter = CProfileManager::Get_Iterator(); *childIter = *iter; childIter->Enter_Child(0); DisplayProfile(renderWindow, childIter, x+15, y); CProfileManager::Release_Iterator(childIter); y += 15; iter->Next(); } }
static int gear_start_app(struct engine* engine) { monoWrapper::loadMonoModules(); monoWrapper::reInitMono(); if(monoWrapper::mono_engine_test_function_for_mono()!=200) { LOGE("monoWrapper::mono_engine_test_function_for_mono expected to return 200"); } else { LOGI("monoWrapper::mono_engine_test_function_for_mono returned 200"); } printf("hello hello"); monoWrapper::mono_engine_init(1); monoWrapper::mono_engine_init_for_mono_android(); monoWrapper::mono_engine_resize(monoWrapper::mono_engine_getWorld(0), 0, 0, engine->width, engine->height, 10.0f, 100000.0f); HWShaderManager* hwmanager = engine_getHWShaderManager(); hwmanager->Init(); g_cFontManager.init(); g_cFontManager.setRenderer(monoWrapper::mono_engine_getWorld(0)->getRenderer()); g_pFontPtr=g_cFontManager.loadFont("//storage//emulated//0//gear//fonts//arial_iphone10_84.ecf"); monoWrapper::mono_game_start(); return 0; }
void CGameOverState::Render( void ) { CSGD_Direct3D* pD3D = CSGD_Direct3D::GetInstance(); FontManager* pFont = CGame::GetInstance()->GetFont(); pD3D->Clear(WHITE); if(m_bWin) { if(m_nLevel_Finished == 4) { CSGD_TextureManager::GetInstance()->Draw(m_nWindBGid, 0, 0); pFont->Draw( ARNOVA , FINAL_LEVEL_WIN, 55, 250, 1.3f, 1.3f, WHITE); } else { CSGD_TextureManager::GetInstance()->Draw(m_nWindBGid, 0, 0); pFont->Draw( ARNOVA , GAME_WIN, 55, 250, 1.3f, 1.3f, WHITE); } } else { CSGD_TextureManager::GetInstance()->Draw(m_nLoseBGid, 0,0); pFont->Draw( ARNOVA , GAME_LOSE, 240, 100, 1.5f,1.5f, WHITE); } pFont->Draw( ARNOVA , STATE_EXIT, 55, 500); CSGD_TextureManager::GetInstance()->Draw(m_nCursorImg, m_nCursorX, m_nCursorY); }
void TestFontManager() { FontManager fm; fm.LoadLib("../../Data/Test/calibri.ttf"); fm.ChangeFontSize(64); auto quads = fm.AcquireText("FuckYou"); quads.Count(); }
// PopulateMenu void FontValueView::_PolulateMenu(BMenu* menu, BHandler* target, const char* markedFamily, const char* markedStyle) { if (!menu) return; FontManager* manager = FontManager::Default(); if (!manager->Lock()) return; BMenu* fontMenu = NULL; font_family family; font_style style; int32 count = manager->CountFontFiles(); for (int32 i = 0; i < count; i++) { if (!manager->GetFontAt(i, family, style)) break; BMessage* message = new BMessage(MSG_FONT_CHANGED); message->AddString("font family", family); message->AddString("font style", style); FontMenuItem* item = new FontMenuItem(style, family, style, message); item->SetTarget(target); bool markStyle = false; if (!fontMenu || (fontMenu->Name() && strcmp(fontMenu->Name(), family) != 0)) { // create new entry fontMenu = new BMenu(family); fontMenu->AddItem(item); menu->AddItem(fontMenu); // mark the menu if necessary if (markedFamily && strcmp(markedFamily, family) == 0) { if (BMenuItem* superItem = fontMenu->Superitem()) superItem->SetMarked(true); markStyle = true; } } else { // reuse old entry fontMenu->AddItem(item); } // mark the item if necessary if (markStyle && markedStyle && strcmp(markedStyle, style) == 0) item->SetMarked(true); } manager->Unlock(); }
void Sprite::drawStrings(const FontManager::TextList &strings, const FontManager &fontManager, int x, int y, uint32 color) { for (FontManager::TextList::const_iterator it = strings.begin(); it != strings.end(); ++it) { fontManager.drawText(_surfaceTrueColor, *it, x, y, color); y += fontManager.getFontHeight(); } updateTransparencyMap(); }
Label::Label(const std::string& text, sf::Color color, unsigned int size, FontManager& fontManager) : mText(text, fontManager.get(FontID::Main), size) { mText.setColor(color); sf::FloatRect bounds = mText.getGlobalBounds(); mText.setOrigin(bounds.width/2, bounds.height/2); }
void HUD::init(const sf::Texture &healthBar, const sf::Texture &healthBarBackground, const std::vector<Entity*> *players, FontManager &fontManager, int mode) { scoreText.setFont(*fontManager.getResource("Config/Content/Fonts/calibri.ttf")); scoreText.setPosition(20,40); scoreText.setColor(sf::Color::Black); this->mode = mode; for(unsigned int i = 0; i < players->size(); i++) { Player *playerPtr = dynamic_cast<Player*>(players->at(i)) ; if(playerPtr != NULL) { this->players.push_back(playerPtr); healthRecs.push_back(HealthBars(sf::RectangleShape(sf::Vector2f((float)healthBar.getSize().x, (float)healthBar.getSize().y)), sf::RectangleShape(sf::Vector2f((float)healthBarBackground.getSize().x, (float)healthBarBackground.getSize().y)))); healthRecs.at(i).healthBar.setTexture(&healthBar); healthRecs.at(i).healthBarBackground.setTexture(&healthBarBackground); //hardcoded healthRecs.at(i).healthBar.setPosition(15, 15); healthRecs.at(i).healthBarBackground.setPosition(10, 10); /*healthRecs.push_back(sf::RectangleShape(this->players->at(i)->getPlayerBars().health.getSize())); healthRecs.at(i).setTexture(this->players->at(i)->getPlayerBars().health.getTexture()); healthRecs.at(i).setTextureRect(this->players->at(i)->getPlayerBars().health.getTextureRect());*/ } } pClock.restart(); }
BasicButton::BasicButton(string text, int fontSize, Vector position, int width, int height) : m_text(text), m_width(width), m_height(height), m_selected(false), m_enabled(false), m_activated(true), m_position(position) { // create text surface FontManager fontManager; string font = "res/tahoma.ttf"; m_pTextSurface = fontManager.getTextSurface(font, m_text, fontSize); // check dimensions of font surface to make sure they do not overflow the button size VideoManager* pVideoManager = Locator::videoManager; int fontWidth = pVideoManager->getSurfaceWidth(m_pTextSurface); int fontHeight = pVideoManager->getSurfaceHeight(m_pTextSurface); if(fontWidth > m_width || fontHeight > m_height){ Locator::logger->log("font exceeds button size", Logger::CWARNING); } }
void GUI_Element::ApplyTextStyle(){ FontManager* fonts = m_owner->GetManager()->GetContext()->m_fontManager; const GUI_Style& CurrentStyle = m_style[m_state]; if (CurrentStyle.m_textFont != ""){ m_visual.m_text.setFont(*fonts->GetResource(CurrentStyle.m_textFont)); m_visual.m_text.setColor(CurrentStyle.m_textColor); m_visual.m_text.setCharacterSize(CurrentStyle.m_textSize); if (CurrentStyle.m_textCenterOrigin){ sf::FloatRect rect = m_visual.m_text.getLocalBounds(); m_visual.m_text.setOrigin(rect.left + rect.width / 2.0f, rect.top + rect.height / 2.0f); } else { m_visual.m_text.setOrigin(0.f, 0.f); } } m_visual.m_text.setPosition(m_position + CurrentStyle.m_textPadding); }
BOOL ATMFontMan::CacheNamedFont(String_64* pFontName) { CDC Screen; // and create a new one if (Screen.CreateIC(TEXT("DISPLAY"), 0, 0, 0)) { FontManager* pFontMan = GetApplication()->GetFontManager(); ERROR2IF(pFontMan == NULL,FALSE,"NULL FontManager ptr"); pFontMan->ClearTempFont(); EnumFontFamilies(Screen.m_hDC, NULL, (FONTENUMPROC) ATMFontMan_CallBackCacheNamedFont, (LPARAM)pFontName); Screen.DeleteDC(); return pFontMan->TempFontValid(); } return FALSE; }
INT32 APIENTRY ATMFontMan_CallBackValidateFont( ENUMLOGFONT FAR* lpelf, // address of logical-font data NEWTEXTMETRIC FAR* lpntm, // address of physical-font data INT32 FontType, // type of font LPARAM lParam // address of application-defined data ) { UNREFERENCED_PARAMETER (lpntm); if (FontType & DEVICE_FONTTYPE) { String_64 FontName(lpelf->elfLogFont.lfFaceName); FontManager* pFontMan = GetApplication()->GetFontManager(); pFontMan->ValidateItem(FC_ATM, &FontName, lpelf); } return TRUE; }
void CPopUp_SPGain::Render() { CCamera* Game_Camera = CCamera::GetInstance(); FontManager* pFont = CGame::GetInstance()->GetFont(); CSGD_TextureManager* pTM = CSGD_TextureManager::GetInstance(); int x = int(GetPosX() - Game_Camera->GetPosX()); int y = int(GetPosY() - Game_Camera->GetPosY()); CPopUp::Render(); AnimationManager::GetInstance()->Render( (float)(x + 75), (float)(y + 101), CEntity::IsFlipped(), *GetAnimInfo(), m_dwRenderColor); pFont->Draw( CHINESE_TAKEAWAY, L"Attack the enemy \n to build your special meter", x+48, y+44, 0.4f, 0.4f, BLACK ); }
void TextShape::OnInit() { FontManager* fontmanager = GetEntity()->GetKernel()->GetLayer(Layer::s_LayerManager)->GetRootEntity()->GetComponent<FontManager>(); m_font = fontmanager->Get(m_fontType); assert(m_font); // push good texture to material GLRender* render = GetEntity()->GetComponent<GLRender>(); assert(render); // helper because a font texture does not exists on the disk Material* material = static_cast<Material*>(GetEntity()->GetComponentByType(render->m_materialType)); assert(material); material->SetMainTexture(m_font->m_texture); SetText(m_text); m_isDirty = true; }
TextEffect::TextEffect(const string &text, const Vector2D &position, float life, float rotationSpeed, float rotation) : LifeEffect(life) { this->text = text; this->position = position; MathManager *mathManager = MathManager::getInstance(); this->rotationSpeed = mathManager->randBool() ? rotationSpeed : -rotationSpeed; this->rotation = rotation; FontManager *fontManager = FontManager::getInstance(); font = fontManager->getFont("effect"); if(!font) font = fontManager->getFont("regular"); if(!font) LogManager::getInstance()->error("No font for text effect."); width = font->getStringWidth(text); }
INT32 APIENTRY ATMFontMan_CallBackCacheNamedFont( ENUMLOGFONT FAR* lpelf, // address of logical-font data NEWTEXTMETRIC FAR* lpntm, // address of physical-font data INT32 FontType, // type of font LPARAM lParam // address of application-defined data ) { UNREFERENCED_PARAMETER (lpntm); if (FontType & DEVICE_FONTTYPE) { String_64 FontName(lpelf->elfLogFont.lfFaceName); if (lParam==NULL || (_tcsncicmp(FontName, *((String_64 * )lParam), 64) == 0)) { FontManager* pFontMan = GetApplication()->GetFontManager(); pFontMan->SetTempFont(FC_ATM, &FontName, lpelf); return FALSE; } } return TRUE; }
bool HeadsUpDisplay::DisplayCameraAndControlInfo(const FontManager& fontmanager_ref, const EntitySet& entityset_ref, const KernelSettings kernelsettings_ref) const { //display entity number in lower half of HUD stringstream ss1; string s1,s2; ss1 << entityset_ref.GetControlTargetID(); ss1 >> s1; s2 = "Entity Control: " + s1; fontmanager_ref.RenderText(s2.c_str(),10,kernelsettings_ref.iAppHeight-10,kernelsettings_ref); //display entity number in lower half of HUD stringstream ss2; s1 = ""; s2 = ""; //display camera source in lower half of HUD ss2 << entityset_ref.GetCameraTargetID(); ss2 >> s1; s2 = "Camera Source: " + s1; fontmanager_ref.RenderText(s2.c_str(),10,kernelsettings_ref.iAppHeight-25,kernelsettings_ref); stringstream ss3; s1 = ""; s2 = ""; //display hyperfactor of control entity ss3 << entityset_ref.GetControlTargetRef()->fHVS[0]; // ss3 << MathManipulations::SizVEC(entityset_ref.GetControlTargetRef()->vSVS[3]); ss3 >> s1; s2 = "HyperFactor: " + s1; fontmanager_ref.RenderText(s2.c_str(),200,kernelsettings_ref.iAppHeight-25,kernelsettings_ref); // fontmanager_ref.RenderText(s2.c_str(),200,kernelsettings_ref.iAppHeight-25,kernelsettings_ref); //Redner User Info fontmanager_ref.RenderText("Martin Goulet - Copyright 2005", 770,15,kernelsettings_ref); fontmanager_ref.RenderText("*****@*****.**", 825,30,kernelsettings_ref); return true; }
bool FPSCounter::RenderFPS(const Timer& timer_ref, const FontManager& fontmanager_ref, const KernelSettings& kernelsettings_ref) const { glPushMatrix(); //get actual favlue to display char* output = this->GetFPS(timer_ref); //call to fontmanager to render FPS text fontmanager_ref.RenderText(output, 2, 12, kernelsettings_ref); glPopMatrix(); return true; }
VirtualFont::VirtualFont(FontManager &fontManager, const Properties &properties) : properties(properties), middleLineFactor(0), layoutCache(fontManager.layoutCache), itemizer(fontManager.itemizer), indices(fontManager.getIndices(properties.slotCapacity)), began(0), hasClip(false), sequence(nullptr) { assert(properties.baseSize > 0); assert(properties.slotCapacity > 0); assert(!(properties.useAnisotropy && !properties.useMipmap)); // ANISOTROPY DOESN'T MAKE SENSE WITHOUT MIPMAPS // --- if (gl::isExtensionAvailable("GL_EXT_texture_filter_anisotropic")) { if (properties.useAnisotropy) { glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &anisotropy); } else { anisotropy = 1; } } else { anisotropy = 0; } // --- setSize(properties.baseSize); setColor(0, 0, 0, 1); }
void GameInfo::Display( int x, int y ) { CSGD_Direct3D* pD3D = CSGD_Direct3D::GetInstance(); FontManager* pFont = CGame::GetInstance()->GetFont(); CSGD_TextureManager* pTM = CSGD_TextureManager::GetInstance(); pTM->Draw( m_nMenuArtid, x, y); TOSTRINGSTREAM wss; wss.str(L""); wss << "Stage 0" << m_nLevel; pFont->Draw( CHINESE_TAKEAWAY , wss.str().c_str(), x + 43, y+36, 0.5f,0.5f); wss.str(L""); wss << "EXP: " << m_nExpPts; pFont->Draw( CHINESE_TAKEAWAY , wss.str().c_str(), x + 201, y+36, 0.5f,0.5f); wss.str(L""); wss << m_nFireSpl; pFont->Draw( CHINESE_TAKEAWAY , wss.str().c_str(), x + 83, y + 78, 0.5f,0.5f); wss.str(L""); wss << m_nWindSpl; pFont->Draw( CHINESE_TAKEAWAY , wss.str().c_str(), x + 160, y + 78, 0.5f,0.5f); wss.str(L""); wss << m_nIceSpl; pFont->Draw( CHINESE_TAKEAWAY , wss.str().c_str(), x + 237, y + 78, 0.5f,0.5f); wss.str(L""); wss << m_nEarthSpl; pFont->Draw( CHINESE_TAKEAWAY , wss.str().c_str(), x + 304, y + 78,0.5f,0.5f); }
int _main_(int _argc, char** _argv) { Args args(_argc, _argv); uint32_t width = 1280; uint32_t height = 720; uint32_t debug = BGFX_DEBUG_TEXT; uint32_t reset = BGFX_RESET_VSYNC; bgfx::init(args.m_type, args.m_pciId); bgfx::reset(width, height, reset); // Enable debug text. bgfx::setDebug(debug); // Set view 0 clear state. bgfx::setViewClear(0 , BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH , 0x303030ff , 1.0f , 0 ); // Init the text rendering system. FontManager* fontManager = new FontManager(512); TextBufferManager* textBufferManager = new TextBufferManager(fontManager); // Load some TTF files. const char* fontFilePath[7] = { "font/droidsans.ttf", "font/chp-fire.ttf", "font/bleeding_cowboys.ttf", "font/mias_scribblings.ttf", "font/ruritania.ttf", "font/signika-regular.ttf", "font/five_minutes.otf", }; const uint32_t numFonts = BX_COUNTOF(fontFilePath); TrueTypeHandle fontFiles[numFonts]; FontHandle fonts[numFonts]; for (uint32_t ii = 0; ii < numFonts; ++ii) { // Instantiate a usable font. fontFiles[ii] = loadTtf(fontManager, fontFilePath[ii]); fonts[ii] = fontManager->createFontByPixelSize(fontFiles[ii], 0, 32); // Preload glyphs and blit them to atlas. fontManager->preloadGlyph(fonts[ii], L"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ. \n"); // You can unload the truetype files at this stage, but in that // case, the set of glyph's will be limited to the set of preloaded // glyph. fontManager->destroyTtf(fontFiles[ii]); } TrueTypeHandle fontAwesomeTtf = loadTtf(fontManager, "font/fontawesome-webfont.ttf"); // This font doesn't have any preloaded glyph's but the truetype file // is loaded so glyph will be generated as needed. FontHandle fontAwesome72 = fontManager->createFontByPixelSize(fontAwesomeTtf, 0, 72); TrueTypeHandle visitorTtf = loadTtf(fontManager, "font/visitor1.ttf"); // This font doesn't have any preloaded glyph's but the truetype file // is loaded so glyph will be generated as needed. FontHandle visitor10 = fontManager->createFontByPixelSize(visitorTtf, 0, 10); //create a static text buffer compatible with alpha font //a static text buffer content cannot be modified after its first submit. TextBufferHandle staticText = textBufferManager->createTextBuffer(FONT_TYPE_ALPHA, BufferType::Static); // The pen position represent the top left of the box of the first line // of text. textBufferManager->setPenPosition(staticText, 24.0f, 100.0f); for (uint32_t ii = 0; ii < numFonts; ++ii) { // Add some text to the buffer. // The position of the pen is adjusted when there is an endline. textBufferManager->appendText(staticText, fonts[ii], L"The quick brown fox jumps over the lazy dog\n"); } // Now write some styled text. // Setup style colors. textBufferManager->setBackgroundColor(staticText, 0x551111ff); textBufferManager->setUnderlineColor(staticText, 0xff2222ff); textBufferManager->setOverlineColor(staticText, 0x2222ffff); textBufferManager->setStrikeThroughColor(staticText, 0x22ff22ff); // Background. textBufferManager->setStyle(staticText, STYLE_BACKGROUND); textBufferManager->appendText(staticText, fonts[0], L"The quick "); // Strike-through. textBufferManager->setStyle(staticText, STYLE_STRIKE_THROUGH); textBufferManager->appendText(staticText, fonts[0], L"brown fox "); // Overline. textBufferManager->setStyle(staticText, STYLE_OVERLINE); textBufferManager->appendText(staticText, fonts[0], L"jumps over "); // Underline. textBufferManager->setStyle(staticText, STYLE_UNDERLINE); textBufferManager->appendText(staticText, fonts[0], L"the lazy "); // Background + strike-through. textBufferManager->setStyle(staticText, STYLE_BACKGROUND | STYLE_STRIKE_THROUGH); textBufferManager->appendText(staticText, fonts[0], L"dog\n"); textBufferManager->setStyle(staticText, STYLE_NORMAL); textBufferManager->appendText(staticText, fontAwesome72, L"\xf011 \xf02e \xf061 \xf087 \xf0d9 \xf099 \xf05c \xf021 \xf113\n"); // Create a transient buffer for real-time data. TextBufferHandle transientText = textBufferManager->createTextBuffer(FONT_TYPE_ALPHA, BufferType::Transient); while (!entry::processEvents(width, height, debug, reset) ) { // This dummy draw call is here to make sure that view 0 is cleared // if no other draw calls are submitted to view 0. bgfx::touch(0); int64_t now = bx::getHPCounter(); static int64_t last = now; const int64_t frameTime = now - last; last = now; const double freq = double(bx::getHPFrequency() ); const double toMs = 1000.0 / freq; // Use debug font to print information about this example. bgfx::dbgTextClear(); bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/10-font"); bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Use the font system to display text and styled text."); bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs); // Use transient text to display debug information. wchar_t fpsText[64]; bx::swnprintf(fpsText, BX_COUNTOF(fpsText), L"Frame: % 7.3f[ms]", double(frameTime) * toMs); textBufferManager->clearTextBuffer(transientText); textBufferManager->setPenPosition(transientText, width - 150.0f, 10.0f); textBufferManager->appendText(transientText, visitor10, L"Transient\n"); textBufferManager->appendText(transientText, visitor10, L"text buffer\n"); textBufferManager->appendText(transientText, visitor10, fpsText); float at[3] = { 0, 0, 0.0f }; float eye[3] = { 0, 0, -1.0f }; float view[16]; bx::mtxLookAt(view, eye, at); const float centering = 0.5f; // Setup a top-left ortho matrix for screen space drawing. const bgfx::HMD* hmd = bgfx::getHMD(); if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING) ) { float proj[16]; bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f); static float time = 0.0f; time += 0.05f; const float dist = 10.0f; const float offset0 = -proj[8] + (hmd->eye[0].viewOffset[0] / dist * proj[0]); const float offset1 = -proj[8] + (hmd->eye[1].viewOffset[0] / dist * proj[0]); float ortho[2][16]; const float offsetx = width/2.0f; bx::mtxOrtho(ortho[0], centering, offsetx + centering, height + centering, centering, -1.0f, 1.0f, offset0); bx::mtxOrtho(ortho[1], centering, offsetx + centering, height + centering, centering, -1.0f, 1.0f, offset1); bgfx::setViewTransform(0, view, ortho[0], BGFX_VIEW_STEREO, ortho[1]); bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height); } else { float ortho[16]; bx::mtxOrtho(ortho, centering, width + centering, height + centering, centering, -1.0f, 1.0f); bgfx::setViewTransform(0, view, ortho); bgfx::setViewRect(0, 0, 0, width, height); } // Submit the debug text. textBufferManager->submitTextBuffer(transientText, 0); // Submit the static text. textBufferManager->submitTextBuffer(staticText, 0); // Advance to next frame. Rendering thread will be kicked to // process submitted rendering primitives. bgfx::frame(); } fontManager->destroyTtf(fontAwesomeTtf); fontManager->destroyTtf(visitorTtf); // Destroy the fonts. fontManager->destroyFont(fontAwesome72); fontManager->destroyFont(visitor10); for (uint32_t ii = 0; ii < numFonts; ++ii) { fontManager->destroyFont(fonts[ii]); } textBufferManager->destroyTextBuffer(staticText); textBufferManager->destroyTextBuffer(transientText); delete textBufferManager; delete fontManager; // Shutdown bgfx. bgfx::shutdown(); return 0; }
int main(int argc, char *argv[]) { // #ifdef QT_DEBUG // debugStreamFile.open(QFile::WriteOnly | QFile::Truncate); // #endif //FIXME qInstallMsgHandler( debugOutput ); spDebugConsole = 0; Q_INIT_RESOURCE(mudlet_alpha); QApplication app(argc, argv); app.setOrganizationName("Mudlet"); app.setApplicationName("Mudlet"); app.setApplicationVersion(APP_VERSION); QPixmap pixmap(":/Mudlet_splashscreen_main.png"); QSplashScreen splash(pixmap); QString startupMessage; if( QByteArray( APP_BUILD ).isEmpty() ) startupMessage = QString("Mudlet\n(Release version: ") % APP_VERSION % QString(")\n\n"); else startupMessage = QString("Mudlet\n(Development version: ") % APP_VERSION % APP_BUILD % QString(")\n\n"); // Following is suggested by GPL documentation startupMessage.append("Copyright " % QChar(169) % "2014 Heiko K" % QChar(246) % "hn\n\n"); startupMessage.append("Mudlet comes with\nABSOLUTELY NO WARRANTY\n\n"); startupMessage.append("This is free software, and you are welcome to\n"); startupMessage.append("redistribute it under certain conditions;\nselect the 'About' item for details.\n\nLoading profiles..."); splash.show(); splash.showMessage(startupMessage, Qt::AlignHCenter); app.processEvents(); //qt_ntfs_permission_lookup++; // turn permission checking on on NTFS file systems QTime t; t.start(); while( t.elapsed() < 1000 ) ; // Do nothing here for a second QString directory = QDir::homePath()+"/.config/mudlet"; QDir dir; if( ! dir.exists( directory ) ) { dir.mkpath( directory ); } // QFile file_doc(":/mudlet_documentation.html"); // QFile file_doc_old; // file_doc_old.setFileName( directory+"/mudlet_documentation.html" ); // if( file_doc_old.exists() ) // { //NOTE: B. von Roeder found out that the removal of old versions may *sometimes* fail on windows 7 due permission issues // if( ! file_doc_old.setPermissions( QFile::WriteOwner | QFile::ReadOwner | QFile::ReadUser | QFile::WriteUser | QFile::ReadOther | QFile::WriteOther ) ) // { // cout << "[ERROR] could not set file permissions of the old version of the manual" << endl; // gSysErrors << "[ERROR] could not set file permissions of the old version of the manual"; // } // string old_man_path = directory.toLatin1().data(); // old_man_path += "/mudlet_documentation.html"; // bool ok=file_doc_old.remove(); // if( ok ) // { // cout << "[INFO] deleted old version of the manual: " << old_man_path << endl; // } // else // { // cout << "[ERROR] could not remove old version of the manual: " << old_man_path << endl; // QString _m = "[ERROR] could not remove old version of the manual: "; // _m.append( old_man_path.c_str() ); // gSysErrors << _m; // } // } // else // { // gSysErrors << "[INFO] no old version of the manual found"; // } // if( file_doc.copy( directory+"/mudlet_documentation.html" ) ) // { // cout << "[OK] successfully copied new version of the manual" << endl; // QString _m = "[INFO] local manual: "; // _m.append( directory ); // gSysErrors << _m; // } // else // { // cout << "[ERROR] copy of new version of the manual failed" << endl; // gSysErrors << "[ERROR] copy of new version of the manual failed"; // } // QFile file_lua(":/LuaGlobal.lua"); // QFile file_lua_old( directory+"/LuaGlobal.lua" ); // if( ! file_lua_old.setPermissions( QFile::WriteOwner | QFile::ReadOwner | QFile::ReadUser | QFile::WriteUser | QFile::ReadOther | QFile::WriteOther ) ) // { // cout << "[ERROR] failed to set file permissions for the old version of LuaGlobal.lua" << endl; // gSysErrors << "[ERROR] failed to set file permissions for the old version of LuaGlobal.lua"; // } // else // { // cout << "[OK] successfully set file permissions for the old version of LuaGlobal.lua" << endl; // } // if( file_lua_old.remove() ) // { // cout << "[OK] old LuaGlobal.lua removed successfully" << endl; // gSysErrors << "[INFO] old LuaGlobal.lua removed successfully"; // } // else // { // cout << "[ERROR] failed to remove the old version of LuaGlobal.lua" << endl; // gSysErrors << "[ERROR] failed to remove the old version of LuaGlobal.lua"; // } // if( file_lua.copy( directory+"/LuaGlobal.lua" ) ) // { // cout << "[OK] new version of LuaGlobal.lua copied successfully" << endl; // gSysErrors << "[INFO] LuaGlobal.lua restored successfully"; // QFile file_lua_new(directory+"/LuaGlobal.lua"); // if( ! file_lua_new.setPermissions( QFile::WriteOwner | QFile::ReadOwner | QFile::ReadUser | QFile::WriteUser | QFile::ReadOther | QFile::WriteOther ) ) // { // cout << "[ERROR] failed to set file permissions for the new version of LuaGlobal.lua" << endl; // gSysErrors << "[ERROR] failed to set file permissions for the new version of LuaGlobal.lua"; // } // else // { // cout << "[OK] successfully set file permissions for the new version of LuaGlobal.lua" << endl; // } // } // QFile file_db(":/db.lua"); // QFile file_db_old( directory+"/db.lua" ); // if( ! file_db_old.setPermissions( QFile::WriteOwner | QFile::ReadOwner | QFile::ReadUser | QFile::WriteUser | QFile::ReadOther | QFile::WriteOther ) ) // { // cout << "[ERROR] failed to set file permissions for the old version of db.lua" << endl; // gSysErrors << "[ERROR] failed to set file permissions for the old version of db.lua"; // } // else // { // cout << "[OK] successfully set file permissions for the old version of db.lua" << endl; // } // if( file_db_old.remove() ) // { // cout << "[OK] old db.lua removed successfully" << endl; // gSysErrors << "[INFO] old db.lua removed successfully"; // } // else // { // cout << "[ERROR] failed to remove the old version of db.lua" << endl; // gSysErrors << "[ERROR] failed to remove the old version of db.lua"; // } // if( file_db.copy( directory+"/db.lua" ) ) // { // cout << "[OK] new version of db.lua copied successfully" << endl; // gSysErrors << "[INFO] db.lua restored successfully"; // QFile file_db_new(directory+"/db.lua"); // if( ! file_db_new.setPermissions( QFile::WriteOwner | QFile::ReadOwner | QFile::ReadUser | QFile::WriteUser | QFile::ReadOther | QFile::WriteOther ) ) // { // cout << "[ERROR] failed to set file permissions for the new version of db.lua" << endl; // gSysErrors << "[ERROR] failed to set file permissions for the new version of db.lua"; // } // else // { // cout << "[OK] successfully set file permissions for the new version of db.lua" << endl; // } // } startupMessage.append(" Done.\nLoading font files..."); splash.showMessage(startupMessage, Qt::AlignHCenter); app.processEvents(); t.restart(); while( t.elapsed() < 1000 ) ; // Do nothing here for a second QFile file_f1(":/fonts/ttf-bitstream-vera-1.10/COPYRIGHT.TXT"); file_f1.copy( directory+"/COPYRIGHT.TXT" ); QFile file_f2(":/fonts/ttf-bitstream-vera-1.10/RELEASENOTES.TXT"); file_f2.copy( directory+"/RELEASENOTES.TXT" ); QFile file_f3(":/fonts/ttf-bitstream-vera-1.10/VeraMoIt.ttf"); file_f3.copy( directory+"/VeraMoIt.ttf" ); QFile file_f4(":/fonts/ttf-bitstream-vera-1.10/local.conf"); file_f4.copy( directory+"/local.conf" ); QFile file_f5(":/fonts/ttf-bitstream-vera-1.10/VeraMoBd.ttf"); file_f5.copy( directory+"/VeraMoBd.ttf" ); QFile file_f6(":/fonts/ttf-bitstream-vera-1.10/VeraMoBd.ttf"); file_f6.copy( directory+"/VeraMoBd.ttf" ); QFile file_f7(":/fonts/ttf-bitstream-vera-1.10/README.TXT"); file_f7.copy( directory+"/README.TXT" ); QFile file_f8(":/fonts/ttf-bitstream-vera-1.10/VeraMoBI.ttf"); file_f8.copy( directory+"/VeraMoBI.ttf" ); QFile file_f9(":/fonts/ttf-bitstream-vera-1.10/VeraMono.ttf"); file_f9.copy( directory+"/VeraMono.ttf" ); /*QFile file_f(":/fonts/ttf-bitstream-vera-1.10/"); file_f.copy( directory+"/" ); QFile file_f(":/fonts/ttf-bitstream-vera-1.10/"); file_f.copy( directory+"/" ); QFile file_f(":/fonts/ttf-bitstream-vera-1.10/"); file_f.copy( directory+"/" ); */ startupMessage.append(" Done.\nAll data has been loaded successfully.\nStarting...\n\n\nHave fun!"); splash.showMessage(startupMessage, Qt::AlignHCenter); app.processEvents(); t.restart(); while( t.elapsed() < 1000 ) ; // Do nothing here for a second splash.finish( mudlet::self() ); // This seems to be the point at which instance of mudlet is created!!! mudlet::debugMode = false; HostManager::self(); FontManager fm; fm.addFonts(); QString home = QDir::homePath()+"/.config/mudlet"; QString homeLink = QDir::homePath()+"/mudlet-data"; QFile::link(home, homeLink); mudlet::self()->show(); app.exec(); }
int _main_(int /*_argc*/, char** /*_argv*/) { uint32_t width = 1280; uint32_t height = 720; uint32_t debug = BGFX_DEBUG_TEXT; uint32_t reset = BGFX_RESET_VSYNC; bgfx::init(); bgfx::reset(width, height, reset); // Enable debug text. bgfx::setDebug(debug); // Set view 0 clear state. bgfx::setViewClear(0 , BGFX_CLEAR_COLOR_BIT | BGFX_CLEAR_DEPTH_BIT , 0x303030ff , 1.0f , 0 ); // Init the text rendering system. FontManager* fontManager = new FontManager(512); TextBufferManager* textBufferManager = new TextBufferManager(fontManager); // Load some TTF files. const char* fontNames[7] = { "font/droidsans.ttf", "font/chp-fire.ttf", "font/bleeding_cowboys.ttf", "font/mias_scribblings.ttf", "font/ruritania.ttf", "font/signika-regular.ttf", "font/five_minutes.otf" }; const uint32_t fontCount = countof(fontNames); TrueTypeHandle fontFiles[fontCount]; FontHandle fonts[fontCount]; for (uint32_t ii = 0; ii < fontCount; ++ii) { // Instantiate a usable font. fontFiles[ii] = loadTtf(fontManager, fontNames[ii]); fonts[ii] = fontManager->createFontByPixelSize(fontFiles[ii], 0, 32); // Preload glyphs and blit them to atlas. fontManager->preloadGlyph(fonts[ii], L"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ. \n"); // You can unload the truetype files at this stage, but in that // case, the set of glyph's will be limited to the set of preloaded // glyph. fontManager->destroyTtf(fontFiles[ii]); } TrueTypeHandle console_tt = loadTtf(fontManager, "font/visitor1.ttf"); // This font doesn't have any preloaded glyph's but the truetype file // is loaded so glyph will be generated as needed. FontHandle consola_16 = fontManager->createFontByPixelSize(console_tt, 0, 10); //create a static text buffer compatible with alpha font //a static text buffer content cannot be modified after its first submit. TextBufferHandle staticText = textBufferManager->createTextBuffer(FONT_TYPE_ALPHA, BufferType::Static); // The pen position represent the top left of the box of the first line // of text. textBufferManager->setPenPosition(staticText, 24.0f, 100.0f); for (uint32_t ii = 0; ii < fontCount; ++ii) { // Add some text to the buffer. // The position of the pen is adjusted when there is an endline. textBufferManager->appendText(staticText, fonts[ii], L"The quick brown fox jumps over the lazy dog\n"); } // Now write some styled text. // Setup style colors. textBufferManager->setBackgroundColor(staticText, 0x551111FF); textBufferManager->setUnderlineColor(staticText, 0xFF2222FF); textBufferManager->setOverlineColor(staticText, 0x2222FFFF); textBufferManager->setStrikeThroughColor(staticText, 0x22FF22FF); // Background. textBufferManager->setStyle(staticText, STYLE_BACKGROUND); textBufferManager->appendText(staticText, fonts[0], L"The quick "); // Strike-through. textBufferManager->setStyle(staticText, STYLE_STRIKE_THROUGH); textBufferManager->appendText(staticText, fonts[0], L"brown fox "); // Overline. textBufferManager->setStyle(staticText, STYLE_OVERLINE); textBufferManager->appendText(staticText, fonts[0], L"jumps over "); // Underline. textBufferManager->setStyle(staticText, STYLE_UNDERLINE); textBufferManager->appendText(staticText, fonts[0], L"the lazy "); // Background + strike-through. textBufferManager->setStyle(staticText, STYLE_BACKGROUND | STYLE_STRIKE_THROUGH); textBufferManager->appendText(staticText, fonts[0], L"dog\n"); // Create a transient buffer for real-time data. TextBufferHandle transientText = textBufferManager->createTextBuffer(FONT_TYPE_ALPHA, BufferType::Transient); while (!processEvents(width, height, debug, reset) ) { // Set view 0 default viewport. bgfx::setViewRect(0, 0, 0, width, height); // This dummy draw call is here to make sure that view 0 is cleared // if no other draw calls are submitted to view 0. bgfx::submit(0); int64_t now = bx::getHPCounter(); static int64_t last = now; const int64_t frameTime = now - last; last = now; const double freq = double(bx::getHPFrequency() ); const double toMs = 1000.0 / freq; // Use transient text to display debug information. wchar_t fpsText[64]; bx::swnprintf(fpsText, countof(fpsText), L"Frame: % 7.3f[ms]", double(frameTime) * toMs); textBufferManager->clearTextBuffer(transientText); textBufferManager->setPenPosition(transientText, 20.0, 4.0f); textBufferManager->appendText(transientText, consola_16, L"bgfx/examples/10-font\n"); textBufferManager->appendText(transientText, consola_16, L"Description: Use the font system to display text and styled text.\n"); textBufferManager->appendText(transientText, consola_16, fpsText); float at[3] = { 0, 0, 0.0f }; float eye[3] = {0, 0, -1.0f }; float view[16]; float proj[16]; mtxLookAt(view, eye, at); // Setup a top-left ortho matrix for screen space drawing. float centering = 0.5f; mtxOrtho(proj, centering, width + centering, height + centering, centering, -1.0f, 1.0f); // Set view and projection matrix for view 0. bgfx::setViewTransform(0, view, proj); // Submit the debug text. textBufferManager->submitTextBuffer(transientText, 0); // Submit the static text. textBufferManager->submitTextBuffer(staticText, 0); // Advance to next frame. Rendering thread will be kicked to // process submitted rendering primitives. bgfx::frame(); } fontManager->destroyTtf(console_tt); // Destroy the fonts. fontManager->destroyFont(consola_16); for (uint32_t ii = 0; ii < fontCount; ++ii) { fontManager->destroyFont(fonts[ii]); } textBufferManager->destroyTextBuffer(staticText); textBufferManager->destroyTextBuffer(transientText); delete textBufferManager; delete fontManager; // Shutdown bgfx. bgfx::shutdown(); return 0; }
/// ctor RootWindow(IWindowManager& windowManager, FontManager& fontManager) :m_windowManager(windowManager), m_spFont(fontManager.Create(FontTypeface::Normal, 16)) { }
void Weapon::DrawHUD( Screen3D& Screen, MeshManager& MM, FontManager& FM, Camera& Viewer ) { HitPlayer = false; Screen.Clear(true); // Set the matrices to the origin D3DXMATRIX matWorld; D3DXMatrixIdentity( &matWorld ); Screen.SetTransform( matWorld ); //Set render states ScreenPtr->D3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); ScreenPtr->D3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); ScreenPtr->D3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); ScreenPtr->D3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); ScreenPtr->D3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); ScreenPtr->D3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); ScreenPtr->D3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ); ScreenPtr->D3DDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE ); ScreenPtr->D3DDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT ); ScreenPtr->D3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); //Draw the weapon model WeaponFont = FM.GetFont("Lucida Console", 16); Screen.D3DDevice->SetRenderState( D3DRS_FOGENABLE, FALSE ); Matrix ViewMatrix = Viewer.GetLookAtMatrix( -10 ); Matrix WorldMatrix; Matrix DisplacementMat; Matrix DisplacementMat2; Matrix ScaleMatrix; Screen.SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); Screen.SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); Screen.SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); Screen.SetRenderState(D3DRS_ALPHATESTENABLE, FALSE ); Screen.SetRenderState(D3DRS_ZENABLE, FALSE ); RECT muzzleDim = { Screen.GetWidth()/2, Screen.GetHeight()/2-Screen.GetHeight()/5,Screen.GetWidth()/2+(Screen.GetHeight()/5)*2, Screen.GetHeight()/2+Screen.GetHeight()/5}; int fade = (int)(MuzzleFlashFade*255.0f); Screen.DrawSpriteRect( muzzleDim, MuzzleFlash, true, D3DCOLOR_RGBA( fade, fade, fade, fade ) ); Screen.SetRenderState(D3DRS_ZENABLE, TRUE ); Screen.SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW); //Screen.SetTextureMode( TMSphereMap); //Screen.SetTexture(GlossMap, 1); Matrix RMat; RMat.Rotate( Viewer.Yaw, Viewer.Pitch, Viewer.Roll); ScreenPtr->D3DDevice->MultiplyTransform( D3DTS_TEXTURE1, &RMat.Mat ); //draw if(!RightHanded) { //First, apply a -1 scale to the transform //matrix so that the gun draws on the opposite side //(since it's left handed). Also, change the //culling order so it doesn't draw inside out. Screen.SetRenderState( D3DRS_CULLMODE, D3DCULL_CW); DisplacementMat.Translate( 0.10f, 3.1f, -4.3f); ScaleMatrix.Scale( -1, 1, 1 ); D3DXMatrixMultiply(&DisplacementMat.Mat, &DisplacementMat.Mat, &ScaleMatrix.Mat); D3DXMatrixMultiply(&ViewMatrix.Mat, &ViewMatrix.Mat, &DisplacementMat.Mat); D3DXMatrixInverse(&WorldMatrix.Mat, NULL, &ViewMatrix.Mat); Screen.SetTransform(WorldMatrix); //Draw the mesh now and return the culling state //DisplayMesh.Draw( Screen ); Screen.SetRenderState(D3DRS_LIGHTING, FALSE ); MeshA.Draw( Screen, WorldMatrix ); Screen.SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW); D3DMATRIX OldState; Screen.D3DDevice->GetTransform( D3DTS_VIEW, &OldState); Matrix I; Screen.SetViewTransform(I); Smoke.MoveSpawn( -1.0f, -1.2f, 9.0f); Smoke.Draw( Screen, Viewer ); if(DualWeapons) { Smoke.MoveSpawn( 1.0f, -1.1f, 8.0f); Smoke.Draw( Screen, Viewer ); } Screen.D3DDevice->SetTransform( D3DTS_VIEW, &OldState); } else { DisplacementMat.Translate( -0.10f, 3.1f, -4.3f); D3DXMatrixMultiply(&ViewMatrix.Mat, &ViewMatrix.Mat, &DisplacementMat.Mat); D3DXMatrixInverse(&WorldMatrix.Mat, NULL, &ViewMatrix.Mat); Screen.SetTransform(WorldMatrix); //Draw the weapon Screen.D3DDevice->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_NONE ); MeshA.Draw( Screen, WorldMatrix ); Screen.D3DDevice->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR ); Matrix I; Screen.SetViewTransform(I); Smoke.MoveSpawn( 1.0f, -1.1f, 8.0f); Smoke.Draw( Screen, Viewer ); if(DualWeapons) { Smoke.MoveSpawn( -1.0f, -1.1f, 8.0f); Smoke.Draw( Screen, Viewer ); } } //Show the ammo information by the weapon Screen.D3DDevice->SetRenderState( D3DRS_FOGENABLE, FALSE ); ScreenPtr->D3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT); ScreenPtr->D3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT); ScreenPtr->D3DDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE); Screen.SetRenderState(D3DRS_ZENABLE, FALSE ); if(ShowAmmoAmount) { TextureHandle hAmmoBox = Screen.GetTextureHandle( "..\\base\\art\\UI\\icons\\ammobox.bmp", "..\\base\\art\\UI\\icons\\ammobox_a.bmp"); Screen.DrawSprite( Screen.GetWidth() - 145.0f, (Real)Screen.GetHeight() - 40.0f, Screen.TM.GetTexture( hAmmoBox )); WeaponFont->Draw(Screen, Screen.GetWidth() - 105.0f, (Real)Screen.GetHeight() - 32.0f, false, D3DCOLOR_RGBA(255, 255, 255, 255), "%d", ClipAmmo); WeaponFont->Draw(Screen, Screen.GetWidth() - 60.0f, (Real)Screen.GetHeight() - 32.0f, false, D3DCOLOR_RGBA(255, 0, 0, 255), "%d", Ammo); } Screen.TM.SetTextureMode( TMNormal, 0, true); //draw the aimer if(ShowAmmoAmount) { Texture* AimerPtr = Screen.TM.GetTexture( Aimer ); Screen.SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); Screen.SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); Screen.SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); Screen.SetRenderState(D3DRS_ALPHATESTENABLE, FALSE ); RECT Dimensions; Dimensions.left = Screen.GetWidth() /2 - (AimerPtr->GetWidth()/2); Dimensions.top = Screen.GetHeight()/2 - (AimerPtr->GetHeight()/2); Dimensions.right = Screen.GetWidth() /2 + AimerPtr->GetWidth()/2-1; Dimensions.bottom = Screen.GetHeight()/2 + AimerPtr->GetHeight()/2-1; if(AimerPtr) Screen.DrawSprite(Screen.GetWidth()/2 - (AimerPtr->GetWidth()/2), Screen.GetHeight()/2 - (AimerPtr->GetHeight()/2), AimerPtr); } ScreenPtr->D3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); ScreenPtr->D3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); ScreenPtr->D3DDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR); Screen.SetRenderState(D3DRS_ZENABLE, TRUE ); Screen.SetRenderState( D3DRS_FOGENABLE, TRUE ); }
int _main_(int /*_argc*/, char** /*_argv*/) { uint32_t width = 1280; uint32_t height = 720; uint32_t debug = BGFX_DEBUG_TEXT; uint32_t reset = BGFX_RESET_VSYNC; bgfx::init(); bgfx::reset(width, height, reset); // Enable debug text. bgfx::setDebug(debug); // Set view 0 clear state. bgfx::setViewClear(0 , BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH , 0x303030ff , 1.0f , 0 ); // Imgui. imguiCreate(); char* bigText = loadText( "text/sherlock_holmes_a_scandal_in_bohemia_arthur_conan_doyle.txt"); // Init the text rendering system. FontManager* fontManager = new FontManager(512); TextBufferManager* textBufferManager = new TextBufferManager(fontManager); TrueTypeHandle font = loadTtf(fontManager, "font/special_elite.ttf"); // Create a distance field font. FontHandle fontSdf = fontManager->createFontByPixelSize(font, 0, 48, FONT_TYPE_DISTANCE); // Create a scaled down version of the same font (without adding anything to the atlas). FontHandle fontScaled = fontManager->createScaledFontToPixelSize(fontSdf, 14); TextLineMetrics metrics(fontManager->getFontInfo(fontScaled) ); uint32_t lineCount = metrics.getLineCount(bigText); float visibleLineCount = 20.0f; const char* textBegin = 0; const char* textEnd = 0; metrics.getSubText(bigText, 0, (uint32_t)visibleLineCount, textBegin, textEnd); TextBufferHandle scrollableBuffer = textBufferManager->createTextBuffer(FONT_TYPE_DISTANCE, BufferType::Transient); textBufferManager->setTextColor(scrollableBuffer, 0xFFFFFFFF); textBufferManager->appendText(scrollableBuffer, fontScaled, textBegin, textEnd); entry::MouseState mouseState; int32_t scrollArea = 0; const int32_t guiPanelWidth = 250; const int32_t guiPanelHeight = 200; float textScroll = 0.0f; float textRotation = 0.0f; float textScale = 1.0f; float textSize = 14.0f; while (!entry::processEvents(width, height, debug, reset, &mouseState) ) { imguiBeginFrame(mouseState.m_mx , mouseState.m_my , (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) , mouseState.m_mz , width , height ); imguiBeginScrollArea("Text Area" , width - guiPanelWidth - 10 , 10 , guiPanelWidth , guiPanelHeight , &scrollArea ); imguiSeparatorLine(); bool recomputeVisibleText = false; recomputeVisibleText |= imguiSlider("Number of lines", visibleLineCount, 1.0f, 177.0f , 1.0f); if (imguiSlider("Font size", textSize, 6.0f, 64.0f , 1.0f) ) { fontManager->destroyFont(fontScaled); fontScaled = fontManager->createScaledFontToPixelSize(fontSdf, (uint32_t) textSize); metrics = TextLineMetrics(fontManager->getFontInfo(fontScaled) ); recomputeVisibleText = true; } recomputeVisibleText |= imguiSlider("Scroll", textScroll, 0.0f, (lineCount-visibleLineCount) , 1.0f); imguiSlider("Rotate", textRotation, 0.0f, bx::pi*2.0f , 0.1f); recomputeVisibleText |= imguiSlider("Scale", textScale, 0.1f, 10.0f , 0.1f); if (recomputeVisibleText) { textBufferManager->clearTextBuffer(scrollableBuffer); metrics.getSubText(bigText,(uint32_t)textScroll, (uint32_t)(textScroll+visibleLineCount), textBegin, textEnd); textBufferManager->appendText(scrollableBuffer, fontScaled, textBegin, textEnd); } imguiEndScrollArea(); imguiEndFrame(); // Set view 0 default viewport. bgfx::setViewRect(0, 0, 0, width, height); // This dummy draw call is here to make sure that view 0 is cleared // if no other draw calls are submitted to view 0. bgfx::submit(0); int64_t now = bx::getHPCounter(); static int64_t last = now; const int64_t frameTime = now - last; last = now; const double freq = double(bx::getHPFrequency() ); const double toMs = 1000.0 / freq; // Use debug font to print32_t information about this example. bgfx::dbgTextClear(); bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/11-fontsdf"); bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Use a single distance field font to render text of various size."); bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime) * toMs); float at[3] = { 0, 0, 0.0f }; float eye[3] = {0, 0, -1.0f }; float view[16]; bx::mtxLookAt(view, eye, at); const float centering = 0.5f; // Setup a top-left ortho matrix for screen space drawing. const bgfx::HMD* hmd = bgfx::getHMD(); if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING) ) { float proj[16]; bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f); static float time = 0.0f; time += 0.05f; const float dist = 10.0f; const float offset0 = -proj[8] + (hmd->eye[0].viewOffset[0] / dist * proj[0]); const float offset1 = -proj[8] + (hmd->eye[1].viewOffset[0] / dist * proj[0]); float ortho[2][16]; const float viewOffset = width/4.0f; const float viewWidth = width/2.0f; bx::mtxOrtho(ortho[0], centering + viewOffset, centering + viewOffset + viewWidth, height + centering, centering, -1.0f, 1.0f, offset0); bx::mtxOrtho(ortho[1], centering + viewOffset, centering + viewOffset + viewWidth, height + centering, centering, -1.0f, 1.0f, offset1); bgfx::setViewTransform(0, view, ortho[0], BGFX_VIEW_STEREO, ortho[1]); bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height); } else { float ortho[16]; bx::mtxOrtho(ortho, centering, width + centering, height + centering, centering, -1.0f, 1.0f); bgfx::setViewTransform(0, view, ortho); bgfx::setViewRect(0, 0, 0, width, height); } //very crude approximation :( float textAreaWidth = 0.5f * 66.0f * fontManager->getFontInfo(fontScaled).maxAdvanceWidth; float textRotMat[16]; float textCenterMat[16]; float textScaleMat[16]; float screenCenterMat[16]; bx::mtxRotateZ(textRotMat, textRotation); bx::mtxTranslate(textCenterMat, -(textAreaWidth * 0.5f), (-visibleLineCount)*metrics.getLineHeight()*0.5f, 0); bx::mtxScale(textScaleMat, textScale, textScale, 1.0f); bx::mtxTranslate(screenCenterMat, ( (width) * 0.5f), ( (height) * 0.5f), 0); //first translate to text center, then scale, then rotate float tmpMat[16]; bx::mtxMul(tmpMat, textCenterMat, textRotMat); float tmpMat2[16]; bx::mtxMul(tmpMat2, tmpMat, textScaleMat); float tmpMat3[16]; bx::mtxMul(tmpMat3, tmpMat2, screenCenterMat); // Set model matrix for rendering. bgfx::setTransform(tmpMat3); // Draw your text. textBufferManager->submitTextBuffer(scrollableBuffer, 0); // Advance to next frame. Rendering thread will be kicked to // process submitted rendering primitives. bgfx::frame(); } imguiDestroy(); free(bigText); fontManager->destroyTtf(font); // Destroy the fonts. fontManager->destroyFont(fontSdf); fontManager->destroyFont(fontScaled); textBufferManager->destroyTextBuffer(scrollableBuffer); delete textBufferManager; delete fontManager; // Shutdown bgfx. bgfx::shutdown(); return 0; }
int main(int argc, char *argv[]) { debugStreamFile.open(QFile::WriteOnly | QFile::Truncate); spDebugConsole = 0; qInstallMsgHandler( debugOutput ); Q_INIT_RESOURCE(mudlet_alpha); QApplication app(argc, argv); app.setApplicationName("Mudlet"); QPixmap pixmap(":/Mudlet_splashscreen_main"); QSplashScreen splash(pixmap); splash.show(); splash.showMessage("Loading profiles ..."); app.processEvents(); //qt_ntfs_permission_lookup++; // turn permission checking on on NTFS file systems QString directory = QDir::homePath()+"/.config/mudlet"; QDir dir; if( ! dir.exists( directory ) ) { dir.mkpath( directory ); } // QFile file_doc(":/mudlet_documentation.html"); // QFile file_doc_old; // file_doc_old.setFileName( directory+"/mudlet_documentation.html" ); // if( file_doc_old.exists() ) // { //NOTE: B. von Roeder found out that the removal of old versions may *sometimes* fail on windows 7 due permission issues // if( ! file_doc_old.setPermissions( QFile::WriteOwner | QFile::ReadOwner | QFile::ReadUser | QFile::WriteUser | QFile::ReadOther | QFile::WriteOther ) ) // { // cout << "[ERROR] could not set file permissions of the old version of the manual" << endl; // gSysErrors << "[ERROR] could not set file permissions of the old version of the manual"; // } // string old_man_path = directory.toLatin1().data(); // old_man_path += "/mudlet_documentation.html"; // bool ok=file_doc_old.remove(); // if( ok ) // { // cout << "[INFO] deleted old version of the manual: " << old_man_path << endl; // } // else // { // cout << "[ERROR] could not remove old version of the manual: " << old_man_path << endl; // QString _m = "[ERROR] could not remove old version of the manual: "; // _m.append( old_man_path.c_str() ); // gSysErrors << _m; // } // } // else // { // gSysErrors << "[INFO] no old version of the manual found"; // } // if( file_doc.copy( directory+"/mudlet_documentation.html" ) ) // { // cout << "[OK] successfully copied new version of the manual" << endl; // QString _m = "[INFO] local manual: "; // _m.append( directory ); // gSysErrors << _m; // } // else // { // cout << "[ERROR] copy of new version of the manual failed" << endl; // gSysErrors << "[ERROR] copy of new version of the manual failed"; // } // QFile file_lua(":/LuaGlobal.lua"); // QFile file_lua_old( directory+"/LuaGlobal.lua" ); // if( ! file_lua_old.setPermissions( QFile::WriteOwner | QFile::ReadOwner | QFile::ReadUser | QFile::WriteUser | QFile::ReadOther | QFile::WriteOther ) ) // { // cout << "[ERROR] failed to set file permissions for the old version of LuaGlobal.lua" << endl; // gSysErrors << "[ERROR] failed to set file permissions for the old version of LuaGlobal.lua"; // } // else // { // cout << "[OK] successfully set file permissions for the old version of LuaGlobal.lua" << endl; // } // if( file_lua_old.remove() ) // { // cout << "[OK] old LuaGlobal.lua removed successfully" << endl; // gSysErrors << "[INFO] old LuaGlobal.lua removed successfully"; // } // else // { // cout << "[ERROR] failed to remove the old version of LuaGlobal.lua" << endl; // gSysErrors << "[ERROR] failed to remove the old version of LuaGlobal.lua"; // } // if( file_lua.copy( directory+"/LuaGlobal.lua" ) ) // { // cout << "[OK] new version of LuaGlobal.lua copied successfully" << endl; // gSysErrors << "[INFO] LuaGlobal.lua restored successfully"; // QFile file_lua_new(directory+"/LuaGlobal.lua"); // if( ! file_lua_new.setPermissions( QFile::WriteOwner | QFile::ReadOwner | QFile::ReadUser | QFile::WriteUser | QFile::ReadOther | QFile::WriteOther ) ) // { // cout << "[ERROR] failed to set file permissions for the new version of LuaGlobal.lua" << endl; // gSysErrors << "[ERROR] failed to set file permissions for the new version of LuaGlobal.lua"; // } // else // { // cout << "[OK] successfully set file permissions for the new version of LuaGlobal.lua" << endl; // } // } // QFile file_db(":/db.lua"); // QFile file_db_old( directory+"/db.lua" ); // if( ! file_db_old.setPermissions( QFile::WriteOwner | QFile::ReadOwner | QFile::ReadUser | QFile::WriteUser | QFile::ReadOther | QFile::WriteOther ) ) // { // cout << "[ERROR] failed to set file permissions for the old version of db.lua" << endl; // gSysErrors << "[ERROR] failed to set file permissions for the old version of db.lua"; // } // else // { // cout << "[OK] successfully set file permissions for the old version of db.lua" << endl; // } // if( file_db_old.remove() ) // { // cout << "[OK] old db.lua removed successfully" << endl; // gSysErrors << "[INFO] old db.lua removed successfully"; // } // else // { // cout << "[ERROR] failed to remove the old version of db.lua" << endl; // gSysErrors << "[ERROR] failed to remove the old version of db.lua"; // } // if( file_db.copy( directory+"/db.lua" ) ) // { // cout << "[OK] new version of db.lua copied successfully" << endl; // gSysErrors << "[INFO] db.lua restored successfully"; // QFile file_db_new(directory+"/db.lua"); // if( ! file_db_new.setPermissions( QFile::WriteOwner | QFile::ReadOwner | QFile::ReadUser | QFile::WriteUser | QFile::ReadOther | QFile::WriteOther ) ) // { // cout << "[ERROR] failed to set file permissions for the new version of db.lua" << endl; // gSysErrors << "[ERROR] failed to set file permissions for the new version of db.lua"; // } // else // { // cout << "[OK] successfully set file permissions for the new version of db.lua" << endl; // } // } QFile file_f1(":/fonts/ttf-bitstream-vera-1.10/COPYRIGHT.TXT"); file_f1.copy( directory+"/COPYRIGHT.TXT" ); QFile file_f2(":/fonts/ttf-bitstream-vera-1.10/RELEASENOTES.TXT"); file_f2.copy( directory+"/RELEASENOTES.TXT" ); QFile file_f3(":/fonts/ttf-bitstream-vera-1.10/VeraMoIt.ttf"); file_f3.copy( directory+"/VeraMoIt.ttf" ); QFile file_f4(":/fonts/ttf-bitstream-vera-1.10/local.conf"); file_f4.copy( directory+"/local.conf" ); QFile file_f5(":/fonts/ttf-bitstream-vera-1.10/VeraMoBd.ttf"); file_f5.copy( directory+"/VeraMoBd.ttf" ); QFile file_f6(":/fonts/ttf-bitstream-vera-1.10/VeraMoBd.ttf"); file_f6.copy( directory+"/VeraMoBd.ttf" ); QFile file_f7(":/fonts/ttf-bitstream-vera-1.10/README.TXT"); file_f7.copy( directory+"/README.TXT" ); QFile file_f8(":/fonts/ttf-bitstream-vera-1.10/VeraMoBI.ttf"); file_f8.copy( directory+"/VeraMoBI.ttf" ); QFile file_f9(":/fonts/ttf-bitstream-vera-1.10/VeraMono.ttf"); file_f9.copy( directory+"/VeraMono.ttf" ); /*QFile file_f(":/fonts/ttf-bitstream-vera-1.10/"); file_f.copy( directory+"/" ); QFile file_f(":/fonts/ttf-bitstream-vera-1.10/"); file_f.copy( directory+"/" ); QFile file_f(":/fonts/ttf-bitstream-vera-1.10/"); file_f.copy( directory+"/" ); */ splash.showMessage("All data has been loaded successfully.\n\nHave fun!"); QTime t; t.start(); while( t.elapsed() < 1500 ); splash.finish( mudlet::self() ); mudlet::debugMode = false; HostManager::self(); FontManager fm; fm.addFonts(); mudlet::self()->show(); app.exec(); }
bool Console::RenderConsole(const KernelSettings& kernelsettings_ref, const TextureSet& textureset_ref, const FontManager& fontmanager_ref, const Timer& timer_ref) const { //selection of projection matrix glMatrixMode(GL_PROJECTION); //push/save current projection matrix glPushMatrix(); //reset our new/current copy glLoadIdentity(); //setup orthogonal projection (parallel) glOrtho(0.0f, kernelsettings_ref.iAppWidth, kernelsettings_ref.iAppHeight, 0.0f, -1.0f, 1.0f); //select modelview glMatrixMode(GL_MODELVIEW); //save matrix glPushMatrix(); //reset it glLoadIdentity(); //save attribs glPushAttrib(GL_ALL_ATTRIB_BITS); //enable alpha glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); //set color glColor4f(kernelsettings_ref.consolesettings[0], kernelsettings_ref.consolesettings[1], kernelsettings_ref.consolesettings[2], kernelsettings_ref.consolesettings[3]); //bind console texture glBindTexture(GL_TEXTURE_2D, textureset_ref.GetTextureIndices()[0]); glEnable(GL_TEXTURE_2D); //draw triangle strip consisting console glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0, 1.0); glVertex2f(0, /*0*/55); glTexCoord2f(0.0, 0.0); glVertex2f(0, kernelsettings_ref.iAppHeight/2); glTexCoord2f(2.0, 1.0); glVertex2f( kernelsettings_ref.iAppWidth, /*0*/55); glTexCoord2f(2.0, 0.0); glVertex2f( (kernelsettings_ref.iAppWidth), kernelsettings_ref.iAppHeight/2); glEnd(); //draw bottom frame (black bottom line) glColor4f(0.0, 0.0, 0.0, 0.5); glRectf( 0,kernelsettings_ref.iAppHeight/2, kernelsettings_ref.iAppWidth, kernelsettings_ref.iAppHeight/2+5); //RENDERING MESSAGE LIST fontmanager_ref.RenderText("->", 0, (kernelsettings_ref.iAppHeight/2), kernelsettings_ref); fontmanager_ref.RenderText(this->GetCurrentMessage().c_str(), 25, (kernelsettings_ref.iAppHeight/2), kernelsettings_ref); for (int i = 0; i < this->GetMessageList().size(); i++) { int iFontSize = kernelsettings_ref.iFontSize; fontmanager_ref.RenderText(this->GetMessageList().at(i).c_str(), 0, (kernelsettings_ref.iAppHeight/2) - ( (i+1) * iFontSize), kernelsettings_ref); if (i > 8) break; //break so messages dont go beyond console delimiters } //disable textures glDisable(GL_TEXTURE_2D); //disable blend glDisable(GL_BLEND); //pop attribs glPopAttrib(); //select and pop old projection matrix back glMatrixMode(GL_PROJECTION); glPopMatrix(); //select and pop old modelview matrix glMatrixMode(GL_MODELVIEW); glPopMatrix(); return true; }
int main(int argc, char* argv[]) { #if defined(_MSC_VER) && defined(_DEBUG) // Enable leak detection for MSVC debug builds. { // Check for a debugger and prompt if one is not attached. while (!IsDebuggerPresent() && IDYES == MessageBox(0, "You are starting debug mudlet without a debugger attached. If you wish to attach one and verify that it worked, click yes. To continue without a debugger, click no.", "Mudlet Debug", MB_ICONINFORMATION | MB_YESNO | MB_DEFBUTTON2)) ; // _CRTDBG_ALLOC_MEM_DF: Enable heap debugging. // _CRTDBG_LEAK_CHECK_DF: Check for leaks at program exit. _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); // Create a log file for writing leaks. HANDLE hLogFile = CreateFile("stderr.txt", GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_WARN, hLogFile); // Set this to break on the allocation number shown in the debug output above. // _crtBreakAlloc = 0; pcre_malloc = pcre_malloc_dbg; pcre_free = pcre_free_dbg; pcre_stack_malloc = pcre_malloc_dbg; pcre_stack_free = pcre_free_dbg; } #endif // _MSC_VER && _DEBUG spDebugConsole = 0; unsigned int startupAction = 0; Q_INIT_RESOURCE(mudlet_alpha); QScopedPointer<QCoreApplication> initApp(createApplication(argc, argv, startupAction)); QApplication* app = qobject_cast<QApplication*>(initApp.data()); // Non-GUI actions --help and --version as suggested by GNU coding standards, // section 4.7: http://www.gnu.org/prep/standards/standards.html#Command_002dLine-Interfaces if (app == 0) { if (startupAction & 2) { // Do "version" action - wording and format is quite tightly specified by the coding standards std::cout << APP_TARGET << " " << APP_VERSION << APP_BUILD << std::endl; std::cout << "Qt libraries " << QT_VERSION_STR << "(compilation) " << qVersion() << "(runtime)" << std::endl; std::cout << "Copyright (C) 2008-" << std::string(__DATE__).substr(7, 4) << " Mudlet devs." << std::endl; std::cout << "Licence GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>" << std::endl; std::cout << "This is free software: you are free to change and redistribute it." << std::endl; std::cout << "There is NO WARRANTY, to the extent permitted by law." << std::endl; } if (startupAction & 1) { // Do "help" action - std::cout << "Usage: " << std::string(APP_TARGET) << "[OPTION...]" << std::endl; #if defined(Q_OS_WIN32) std::cout << " /h, /help displays this message." << std::endl; std::cout << " /v, /version displays version information." << std::endl; std::cout << " /q, /quiet no splash screen on startup." << std::endl; #define OPT_PREFIX '/' #else std::cout << " -h, --help displays this message." << std::endl; std::cout << " -v, --version displays version information." << std::endl; std::cout << " -q, --quiet no splash screen on startup." << std::endl; #define OPT_PREFIX '-' #endif std::cout << "There are other inherited options that arise from the Qt Libraries which" << std::endl; std::cout << "are not likely to be useful for normal use of this application:" << std::endl; // From documentation and from http://qt-project.org/doc/qt-5/qapplication.html: std::cout << " " << OPT_PREFIX << "dograb ignore any implicit or explicit -nograb." << std::endl; std::cout << " " << OPT_PREFIX << "dograb wins over " << OPT_PREFIX << "nograb even when" << std::endl; std::cout << " " << OPT_PREFIX << "nograb is last on the command line." << std::endl; std::cout << " " << OPT_PREFIX << "nograb the application should never grab the mouse or the" << std::endl; #if defined(Q_OS_LINUX) std::cout << " keyboard. This option is set by default when Mudlet is" << std::endl; std::cout << " running in the gdb debugger under Linux." << std::endl; #else std::cout << " keyboard." << std::endl; #endif std::cout << " " << OPT_PREFIX << "reverse sets the application's layout direction to" << std::endl; std::cout << " right to left." << std::endl; std::cout << " " << OPT_PREFIX << "style= style sets the application GUI style. Possible values depend" << std::endl; std::cout << " on your system configuration. If Qt was compiled with" << std::endl; std::cout << " additional styles or has additional styles as plugins" << std::endl; std::cout << " these will be available to the -style command line" << std::endl; std::cout << " option. You can also set the style for all Qt" << std::endl; std::cout << " applications by setting the QT_STYLE_OVERRIDE environment" << std::endl; std::cout << " variable." << std::endl; std::cout << " " << OPT_PREFIX << "style style is the same as listed above." << std::endl; std::cout << " " << OPT_PREFIX << "stylesheet= stylesheet" << std::endl; std::cout << " sets the application styleSheet." << std::endl; std::cout << " The value must be a path to a file that contains the" << std::endl; std::cout << " Style Sheet. Note: Relative URLs in the Style Sheet" << std::endl; std::cout << " file are relative to the Style Sheet file's path." << std::endl; std::cout << " " << OPT_PREFIX << "stylesheet stylesheet" << std::endl; std::cout << " is the same as listed above." << std::endl; #if defined(Q_OS_UNIX) std::cout << " " << OPT_PREFIX << "sync runs Mudlet in X synchronous mode. Synchronous mode" << std::endl; std::cout << " forces the X server to perform each X client request" << std::endl; std::cout << " immediately and not use buffer optimization. It makes" << std::endl; std::cout << " the program easier to debug and often much slower. The" << std::endl; std::cout << " -sync option is only valid for the X11 version of Qt." << std::endl; #endif std::cout << " " << OPT_PREFIX << "widgetcount prints debug message at the end about number of widgets" << std::endl; std::cout << " left undestroyed and maximum number of widgets existing" << std::endl; std::cout << " at the same time." << std::endl; std::cout << " " << OPT_PREFIX << "qmljsdebugger=1234[,block]" << std::endl; std::cout << " activates the QML/JS debugger with a specified port." << std::endl; std::cout << " The number is the port value and block is optional" << std::endl; std::cout << " and will make the application wait until a debugger" << std::endl; std::cout << " connects to it." << std::endl; std::cout << std::endl; std::cout << "Report bugs to: <https://github.com/Mudlet/Mudlet/issues>" << std::endl; std::cout << "pkg home page: <http://www.mudlet.org/>" << std::endl; } return 0; } // Turn the cursor into the waiting one during startup, so something shows // activity even if the quiet, no splashscreen startup has been used app->setOverrideCursor(QCursor(Qt::WaitCursor)); app->setOrganizationName("Mudlet"); app->setApplicationName("Mudlet"); app->setApplicationVersion(APP_VERSION); bool show_splash = !(startupAction & 4); // Not --quiet. QImage splashImage(":/Mudlet_splashscreen_main.png"); if (show_splash) { QPainter painter(&splashImage); unsigned fontSize = 16; QString sourceVersionText = QString("Version: " APP_VERSION APP_BUILD); bool isWithinSpace = false; while (!isWithinSpace) { QFont font("DejaVu Serif", fontSize, QFont::Bold | QFont::Serif | QFont::PreferMatch | QFont::PreferAntialias); QTextLayout versionTextLayout(sourceVersionText, font, painter.device()); versionTextLayout.beginLayout(); // Start work in this text item QTextLine versionTextline = versionTextLayout.createLine(); // First draw (one line from) the text we have put in on the layout to // see how wide it is..., assuming accutally that it will only take one // line of text versionTextline.setLineWidth(280); //Splashscreen bitmap is (now) 320x360 - hopefully entire line will all fit into 280 versionTextline.setPosition(QPointF(0, 0)); // Only pretend, so we can see how much space it will take QTextLine dummy = versionTextLayout.createLine(); if (!dummy.isValid()) { // No second line so have got all text in first so can do it isWithinSpace = true; qreal versionTextWidth = versionTextline.naturalTextWidth(); // This is the ACTUAL width of the created text versionTextline.setPosition(QPointF((320 - versionTextWidth) / 2.0, 270)); // And now we can place it centred horizontally versionTextLayout.endLayout(); // end the layout process and paint it out painter.setPen(QColor(176, 64, 0, 255)); // #b04000 versionTextLayout.draw(&painter, QPointF(0, 0)); } else { // Too big - text has spilled over onto a second line - so try again fontSize--; versionTextLayout.clearLayout(); versionTextLayout.endLayout(); } } // Repeat for other text, but we know it will fit at given size QString sourceCopyrightText = QChar(169) % QString(" Mudlet makers 2008-") % QString(__DATE__).mid(7); QFont font("DejaVu Serif", 16, QFont::Bold | QFont::Serif | QFont::PreferMatch | QFont::PreferAntialias); QTextLayout copyrightTextLayout(sourceCopyrightText, font, painter.device()); copyrightTextLayout.beginLayout(); QTextLine copyrightTextline = copyrightTextLayout.createLine(); copyrightTextline.setLineWidth(280); copyrightTextline.setPosition(QPointF(1, 1)); qreal copyrightTextWidth = copyrightTextline.naturalTextWidth(); copyrightTextline.setPosition(QPointF((320 - copyrightTextWidth) / 2.0, 340)); copyrightTextLayout.endLayout(); painter.setPen(QColor(112, 16, 0, 255)); // #701000 copyrightTextLayout.draw(&painter, QPointF(0, 0)); } QPixmap pixmap = QPixmap::fromImage(splashImage); QSplashScreen splash(pixmap); if (show_splash) { splash.show(); } app->processEvents(); QString splash_message; if (show_splash) { splash_message.append("\n\nMudlet comes with\n" "ABSOLUTELY NO WARRANTY!\n" "This is free software, and you are\n" "welcome to redistribute it under\n" "certain conditions; select the\n" "'About' item for details.\n\n"); splash_message.append("Locating profiles... "); splash.showMessage(splash_message, Qt::AlignHCenter | Qt::AlignTop); app->processEvents(); } QString directory = QDir::homePath() + "/.config/mudlet"; QDir dir; if (!dir.exists(directory)) { dir.mkpath(directory); } if (show_splash) { splash_message.append("Done.\n\nLoading font files... "); splash.showMessage(splash_message, Qt::AlignHCenter | Qt::AlignTop); app->processEvents(); } if (!QFile::exists(directory + "/COPYRIGHT.TXT")) { QFile file_f1(":/fonts/ttf-bitstream-vera-1.10/COPYRIGHT.TXT"); file_f1.copy(directory + "/COPYRIGHT.TXT"); } if (!QFile::exists(directory + "/RELEASENOTES.TXT")) { QFile file_f2(":/fonts/ttf-bitstream-vera-1.10/RELEASENOTES.TXT"); file_f2.copy(directory + "/RELEASENOTES.TXT"); } if (!QFile::exists(directory + "/VeraMoIt.ttf")) { QFile file_f3(":/fonts/ttf-bitstream-vera-1.10/VeraMoIt.ttf"); file_f3.copy(directory + "/VeraMoIt.ttf"); } if (!QFile::exists(directory + "/local.conf")) { QFile file_f4(":/fonts/ttf-bitstream-vera-1.10/local.conf"); file_f4.copy(directory + "/local.conf"); } if (!QFile::exists(directory + "/VeraMoBd.ttf")) { QFile file_f5(":/fonts/ttf-bitstream-vera-1.10/VeraMoBd.ttf"); file_f5.copy(directory + "/VeraMoBd.ttf"); } if (!QFile::exists(directory + "/VeraMoBd.ttf")) { QFile file_f6(":/fonts/ttf-bitstream-vera-1.10/VeraMoBd.ttf"); file_f6.copy(directory + "/VeraMoBd.ttf"); } if (!QFile::exists(directory + "/README.TXT")) { QFile file_f7(":/fonts/ttf-bitstream-vera-1.10/README.TXT"); file_f7.copy(directory + "/README.TXT"); } if (!QFile::exists(directory + "/VeraMoBI.ttf")) { QFile file_f8(":/fonts/ttf-bitstream-vera-1.10/VeraMoBI.ttf"); file_f8.copy(directory + "/VeraMoBI.ttf"); } if (!QFile::exists(directory + "/VeraMono.ttf")) { QFile file_f9(":/fonts/ttf-bitstream-vera-1.10/VeraMono.ttf"); file_f9.copy(directory + "/VeraMono.ttf"); } if (show_splash) { splash_message.append("Done.\n\n" "All data has been loaded successfully.\n\n" "Starting... Have fun!\n\n"); splash.showMessage(splash_message, Qt::AlignHCenter | Qt::AlignTop); app->processEvents(); } mudlet::debugMode = false; FontManager fm; fm.addFonts(); QString home = QDir::homePath() + "/.config/mudlet"; QString homeLink = QDir::homePath() + "/mudlet-data"; QFile::link(home, homeLink); mudlet::start(); mudlet::self()->show(); if (show_splash) { splash.finish(mudlet::self()); } app->restoreOverrideCursor(); // NOTE: Must restore cursor - BEWARE DEBUGGERS if you terminate application // without doing/reaching this restore - it can be quite hard to accurately // click something in a parent process to the application when you are stuck // with some OS's choice of wait cursor - you might wish to temparily disable // the earlier setOverrideCursor() line and this one. return app->exec(); }