EDA_MSG_PANEL::EDA_MSG_PANEL( wxWindow* aParent, int aId, const wxPoint& aPosition, const wxSize& aSize ) : wxPanel( aParent, aId, aPosition, aSize ) { SetFont( wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ) ); SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) ); m_last_x = 0; m_fontSize = computeFontSize(); }
EDA_MSG_PANEL::EDA_MSG_PANEL( EDA_DRAW_FRAME* parent, int id, const wxPoint& pos, const wxSize& size ) : wxPanel( parent, id, pos, size ) { SetFont( wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ) ); SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) ); m_last_x = 0; m_fontSize = computeFontSize(); }
bool WindowProtocol::init(){ bool ret = false; //super init if(!Layer::init()) return ret; //Put blocker Layer* blocker = LayerColor::create(Color4B(0, 0, 0, 255*0.5), VisibleRect::getVisibleRect().size.width, VisibleRect::getVisibleRect().size.height); blocker->setAnchorPoint(Vec2::ZERO); blocker->setPosition(Vec2(VisibleRect::getVisibleRect().origin.x, VisibleRect::getVisibleRect().origin.y)); //Base window _baseWindow = Scale9Sprite::createWithSpriteFrameName("WindowBase.psd",BASE_WINDOW_INSET_RECT); _baseWindow->setContentSize(Size(850,490-10-10)); _baseWindow->setAnchorPoint(Vec2(0.0, 1.0)); _baseWindow->setPosition(Vec2(55, VisibleRect::getVisibleRect().size.height-60)); //Put base window _baseLayout = Layout::create(); CCASSERT(_baseLayout!=nullptr, "_baseLayout cannot be null."); _baseLayout->setLayoutType(Layout::Type::VERTICAL); _baseLayout->setContentSize(_baseWindow->getCapInsets().size); _baseLayout->setAnchorPoint(Vec2(0.0, 1.0)); _baseLayout->setPosition(Vec2(2,_baseWindow->getContentSize().height-2)); //PutLayout on sprite _baseWindow->addChild(_baseLayout,0); //---Title--- //Layout _titleLayout = Layout::create(); CCASSERT(_titleLayout!=nullptr, "_titleLayer cannot be null."); //_titleLayout->setAnchorPoint(Vec2(0.0, 1.0)); _titleLayout->setLayoutType(Layout::Type::HORIZONTAL); _titleLayout->setContentSize(Size(850-2*2, 55)); _titleLayout->setPosition(Vec2(_baseLayout->getContentSize().width/2, _baseLayout->getContentSize().height/2)); //set baseTitle as titleLayout background //No longer need title base image... _titleLayout->setBackGroundColorType(Layout::BackGroundColorType::SOLID); _titleLayout->setBackGroundColor(Color3B(200, 200, 169)); //Close Button LinearLayoutParameter* lpCloseButton = LinearLayoutParameter::create(); _closeButton = Button::create("MainUI_Windows_Close_Normal.png","MainUI_Windows_Close_Pressed.png","",TextureResType::PLIST); CCASSERT(_closeButton!=nullptr, "_closeButton cannot be null."); _closeButton->setPosition(Vec2(_titleLayout->getContentSize().width/2, _titleLayout->getContentSize().height/2)); lpCloseButton->setGravity(LinearLayoutParameter::LinearGravity::LEFT); lpCloseButton->setMargin(Margin(0, 0, 0, 0)); _closeButton->setLayoutParameter(lpCloseButton); if(_closeCallback!=nullptr) _closeButton->addTouchEventListener(_closeCallback); //Title text LinearLayoutParameter* lpTitleText = LinearLayoutParameter::create(); _titleText = Text::create(_titleString, "fonts/Apple_LiGothic_Medium.ttf", computeFontSize(42)); CCASSERT(_titleText!=nullptr, "_titletext cannot be null."); _titleText->setColor(Color3B(59,134,134)); _titleText->setPosition(Vec2(_titleLayout->getContentSize().width/2, _titleLayout->getContentSize().height/2)); lpTitleText->setGravity(LinearLayoutParameter::LinearGravity::CENTER_VERTICAL); lpTitleText->setMargin(Margin(_titleLayout->getContentSize().width/2-_titleText->getContentSize().width/2-_closeButton->getContentSize().width, 0, 0, 0)); _titleText->setLayoutParameter(lpTitleText); //Add component to title layout _titleLayout->addChild(_closeButton,1); _titleLayout->addChild(_titleText,2); //---add to base layout--- _baseLayout->addChild(_titleLayout); //setBlockerTouchDispatcher auto touchBlocker = EventListenerTouchOneByOne::create(); touchBlocker->setSwallowTouches(true); //lambda decide later touchBlocker->onTouchBegan= [](Touch* touch,Event* e){ return true; }; _eventDispatcher->addEventListenerWithSceneGraphPriority(touchBlocker, blocker); //addChild addChild(blocker,0); addChild(_baseWindow,1); ret = true; return ret; }
int EDA_MSG_PANEL::GetRequiredHeight() { // make space for two rows of text plus a number of pixels between them. return 2 * computeFontSize().y + 0; }
bool HUDLayer::init(HUD_ID status){ if (!BaseLayer::init()) return false; auto player = PlayerManager::getInstance()->getCurPlayer(); mm->setHUDBasePosition(getPosition()); mm->setStatus(status); Size winSize = CCDirector::getInstance()->getWinSize(); // Load the images of the buildings we'll have and draw them to the game HUD layer ResourceModel *rm = ResourceModel::getModel(); auto _moveableSprites = mm->getMovableSprites(); if (mm->getStatus() == ATTACK){ for (int i = 0; i < mm->BAR_ICON; ++i){ auto sprite = Sprite::create(rm->strTroop[i + 1]); float offsetFraction = ((float)(i + 1)) / (mm->BAR_ICON + 1); sprite->setPosition(Point(winSize.width*offsetFraction, 70)); TTFConfig ttfConfig("fonts/Silom.ttf",computeFontSize(20)); Label* count = Label::createWithTTF(ttfConfig, to_string(player->getPlayerOwnedArcher())); addChild(sprite, 1); _moveableSprites.pushBack(sprite); } // Draw the background of the game HUD CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGB565); auto _background = Sprite::create("UI/HUD.png"); _background->setScaleX(2); _background->setAnchorPoint(Point(0, 0)); CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_Default); addChild(_background, 0); mm->setBackground(_background); } mm->setMovableSprites(_moveableSprites); mm->setSelSprite(nullptr); //@var used to show message. TTFConfig config("fonts/Avenir.ttf", computeFontSize(8 * 4)); /* Label* lblcursorPos = Label::createWithTTF(config, "x:?? y:??", TextHAlignment::LEFT); lblcursorPos->setPosition(Vec2(VisibleRect::getVisibleRect().origin.x + 200, VisibleRect::getVisibleRect().size.height - 20)); addChild(lblcursorPos, -1); mm->setlblCursorPos(lblcursorPos); Label* lblTilePos = Label::createWithTTF(config, "row:?? col:??", TextHAlignment::LEFT); lblTilePos->setPosition(Vec2(VisibleRect::getVisibleRect().origin.x + 200, VisibleRect::getVisibleRect().size.height - 60)); addChild(lblTilePos, -1); mm->setlblTilePos(lblTilePos); Label* lblPlayerPos = Label::createWithTTF(config, "palyer uid=??", TextHAlignment::LEFT); lblPlayerPos->setPosition(Vec2(VisibleRect::getVisibleRect().origin.x + 200, VisibleRect::getVisibleRect().size.height - 100)); addChild(lblPlayerPos, -1); mm->setlblPlayerPos(lblPlayerPos); Label* lblResourcePos = Label::createWithTTF(config, "str = ??,\nmag = ??,\n food = ??,", TextHAlignment::LEFT); lblResourcePos->setPosition(Vec2(VisibleRect::getVisibleRect().origin.x + 800, VisibleRect::getVisibleRect().size.height - 60)); addChild(lblResourcePos, -1); mm->setlblResourcePos(lblResourcePos); */ Label* lblCountdownPos = Label::createWithTTF(config, "time remain: ??", TextHAlignment::LEFT); lblCountdownPos->setPosition(Vec2(VisibleRect::getVisibleRect().origin.x + 500, VisibleRect::getVisibleRect().size.height - 60)); addChild(lblCountdownPos, -1); mm->setlblCountdownPos(lblCountdownPos); //@var used to manage building range images. auto selGroups = Node::create(); addChild(selGroups, -50); mm->setSelGroups(selGroups); scheduleUpdate(); auto listener = EventListenerTouchOneByOne::create(); listener->setSwallowTouches(false); listener->onTouchBegan = CC_CALLBACK_2(HUDLayer::onTouchBegan, this); listener->onTouchMoved = CC_CALLBACK_2(HUDLayer::onTouchMoved, this); listener->onTouchEnded = CC_CALLBACK_2(HUDLayer::onTouchEnded, this); auto dispatcher = Director::getInstance()->getEventDispatcher(); dispatcher->addEventListenerWithSceneGraphPriority(listener, this); return true; }
void CoreData::load() { string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey); const string dir = data_path + "data/core"; Logger::getInstance().add("Core data"); Renderer &renderer= Renderer::getInstance(); //textures backgroundTexture= renderer.newTexture2D(rsGlobal); backgroundTexture->setMipmap(false); backgroundTexture->getPixmap()->load(dir+"/menu/textures/back.tga"); fireTexture= renderer.newTexture2D(rsGlobal); fireTexture->setFormat(Texture::fAlpha); fireTexture->getPixmap()->init(1); fireTexture->getPixmap()->load(dir+"/misc_textures/fire_particle.tga"); snowTexture= renderer.newTexture2D(rsGlobal); snowTexture->setMipmap(false); snowTexture->setFormat(Texture::fAlpha); snowTexture->getPixmap()->init(1); snowTexture->getPixmap()->load(dir+"/misc_textures/snow_particle.tga"); customTexture= renderer.newTexture2D(rsGlobal); customTexture->getPixmap()->load(dir+"/menu/textures/custom_texture.tga"); logoTexture= renderer.newTexture2D(rsGlobal); logoTexture->setMipmap(false); logoTexture->getPixmap()->load(dir+"/menu/textures/logo.tga"); logoTextureList.clear(); string logosPath= dir+"/menu/textures/logo*.*"; vector<string> logoFilenames; findAll(logosPath, logoFilenames); for(int i = 0; i < logoFilenames.size(); ++i) { string logo = logoFilenames[i]; if(strcmp("logo.tga",logo.c_str()) != 0) { Texture2D *logoTextureExtra= renderer.newTexture2D(rsGlobal); logoTextureExtra->setMipmap(true); logoTextureExtra->getPixmap()->load(dir+"/menu/textures/" + logo); logoTextureList.push_back(logoTextureExtra); } } waterSplashTexture= renderer.newTexture2D(rsGlobal); waterSplashTexture->setFormat(Texture::fAlpha); waterSplashTexture->getPixmap()->init(1); waterSplashTexture->getPixmap()->load(dir+"/misc_textures/water_splash.tga"); buttonSmallTexture= renderer.newTexture2D(rsGlobal); buttonSmallTexture->setForceCompressionDisabled(true); buttonSmallTexture->getPixmap()->load(dir+"/menu/textures/button_small.tga"); buttonBigTexture= renderer.newTexture2D(rsGlobal); buttonBigTexture->setForceCompressionDisabled(true); buttonBigTexture->getPixmap()->load(dir+"/menu/textures/button_big.tga"); horizontalLineTexture= renderer.newTexture2D(rsGlobal); horizontalLineTexture->setForceCompressionDisabled(true); horizontalLineTexture->getPixmap()->load(dir+"/menu/textures/line_horizontal.tga"); verticalLineTexture= renderer.newTexture2D(rsGlobal); verticalLineTexture->setForceCompressionDisabled(true); verticalLineTexture->getPixmap()->load(dir+"/menu/textures/line_vertical.tga"); checkBoxTexture= renderer.newTexture2D(rsGlobal); checkBoxTexture->setForceCompressionDisabled(true); checkBoxTexture->getPixmap()->load(dir+"/menu/textures/checkbox.tga"); checkedCheckBoxTexture= renderer.newTexture2D(rsGlobal); checkedCheckBoxTexture->setForceCompressionDisabled(true); checkedCheckBoxTexture->getPixmap()->load(dir+"/menu/textures/checkbox_checked.tga"); //display font Config &config= Config::getInstance(); string displayFontNamePrefix=config.getString("FontDisplayPrefix"); string displayFontNamePostfix=config.getString("FontDisplayPostfix"); int displayFontSize=computeFontSize(config.getInt("FontDisplayBaseSize")); string displayFontName=displayFontNamePrefix+intToStr(displayFontSize)+displayFontNamePostfix; displayFont= renderer.newFont(rsGlobal); displayFont->setType(displayFontName); displayFont->setSize(displayFontSize); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] displayFontName = [%s] displayFontSize = %d\n",__FILE__,__FUNCTION__,__LINE__,displayFontName.c_str(),displayFontSize); //menu fonts string displayFontNameSmallPrefix= config.getString("FontDisplayPrefix"); string displayFontNameSmallPostfix= config.getString("FontDisplayPostfix"); int displayFontNameSmallSize=computeFontSize(config.getInt("FontDisplaySmallBaseSize")); string displayFontNameSmall=displayFontNameSmallPrefix+intToStr(displayFontNameSmallSize)+displayFontNameSmallPostfix; displayFontSmall= renderer.newFont(rsGlobal); displayFontSmall->setType(displayFontNameSmall); displayFontSmall->setSize(displayFontNameSmallSize); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] displayFontSmallName = [%s] displayFontSmallNameSize = %d\n",__FILE__,__FUNCTION__,__LINE__,displayFontNameSmall.c_str(),displayFontNameSmallSize); string menuFontNameNormalPrefix= config.getString("FontMenuNormalPrefix"); string menuFontNameNormalPostfix= config.getString("FontMenuNormalPostfix"); int menuFontNameNormalSize=computeFontSize(config.getInt("FontMenuNormalBaseSize")); string menuFontNameNormal= menuFontNameNormalPrefix+intToStr(menuFontNameNormalSize)+menuFontNameNormalPostfix; menuFontNormal= renderer.newFont(rsGlobal); menuFontNormal->setType(menuFontNameNormal); menuFontNormal->setSize(menuFontNameNormalSize); menuFontNormal->setWidth(Font::wBold); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] menuFontNormalName = [%s] menuFontNormalNameSize = %d\n",__FILE__,__FUNCTION__,__LINE__,menuFontNameNormal.c_str(),menuFontNameNormalSize); string menuFontNameBigPrefix= config.getString("FontMenuBigPrefix"); string menuFontNameBigPostfix= config.getString("FontMenuBigPostfix"); int menuFontNameBigSize=computeFontSize(config.getInt("FontMenuBigBaseSize")); string menuFontNameBig= menuFontNameBigPrefix+intToStr(menuFontNameBigSize)+menuFontNameBigPostfix; menuFontBig= renderer.newFont(rsGlobal); menuFontBig->setType(menuFontNameBig); menuFontBig->setSize(menuFontNameBigSize); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] menuFontNameBig = [%s] menuFontNameBigSize = %d\n",__FILE__,__FUNCTION__,__LINE__,menuFontNameBig.c_str(),menuFontNameBigSize); string menuFontNameVeryBigPrefix= config.getString("FontMenuBigPrefix"); string menuFontNameVeryBigPostfix= config.getString("FontMenuBigPostfix"); int menuFontNameVeryBigSize=computeFontSize(config.getInt("FontMenuVeryBigBaseSize")); string menuFontNameVeryBig= menuFontNameVeryBigPrefix+intToStr(menuFontNameVeryBigSize)+menuFontNameVeryBigPostfix; menuFontVeryBig= renderer.newFont(rsGlobal); menuFontVeryBig->setType(menuFontNameVeryBig); menuFontVeryBig->setSize(menuFontNameVeryBigSize); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] menuFontNameVeryBig = [%s] menuFontNameVeryBigSize = %d\n",__FILE__,__FUNCTION__,__LINE__,menuFontNameVeryBig.c_str(),menuFontNameVeryBigSize); //console font string consoleFontNamePrefix= config.getString("FontConsolePrefix"); string consoleFontNamePostfix= config.getString("FontConsolePostfix"); int consoleFontNameSize=computeFontSize(config.getInt("FontConsoleBaseSize")); string consoleFontName= consoleFontNamePrefix+intToStr(consoleFontNameSize)+consoleFontNamePostfix; consoleFont= renderer.newFont(rsGlobal); consoleFont->setType(consoleFontName); consoleFont->setSize(consoleFontNameSize); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] consoleFontName = [%s] consoleFontNameSize = %d\n",__FILE__,__FUNCTION__,__LINE__,consoleFontName.c_str(),consoleFontNameSize); //sounds clickSoundA.load(dir+"/menu/sound/click_a.wav"); clickSoundB.load(dir+"/menu/sound/click_b.wav"); clickSoundC.load(dir+"/menu/sound/click_c.wav"); attentionSound.load(dir+"/menu/sound/attention.wav"); highlightSound.load(dir+"/menu/sound/highlight.wav"); introMusic.open(dir+"/menu/music/intro_music.ogg"); introMusic.setNext(&menuMusic); menuMusic.open(dir+"/menu/music/menu_music.ogg"); menuMusic.setNext(&menuMusic); waterSounds.resize(6); for(int i=0; i<6; ++i){ waterSounds[i]= new StaticSound(); waterSounds[i]->load(dir+"/water_sounds/water"+intToStr(i)+".wav"); } }