scigraphics::textStyle scigraphics::legend::updateLegendRectangle( painter &Painter, const graphCollection &Graphics ) { if ( getRectangle() == InitLegendRectangle ) setRectangle( createInitialRectangle(Painter) ); std::list<std::string> Legends = legendsList(Graphics); if ( Legends.empty() ) { setRectangle( getRectangle().leftUp(), getRectangle().leftUp() ); return getLegendTextStyle(); } textStyle Style = getLegendTextStyle(); legendSize LegendSizes; while ( true ) { LegendSizes = sizesForLegendRectangle( Painter, Style, Graphics ); if ( Style.getFontSize() <= minFontSize() ) break; if ( LegendSizes.height() < Painter.height() ) break; if ( Style.getFontSize() <= minFontSize() ) break; Style.setFontSize( Style.getFontSize() - 1 ); } setRectangleFromLegendSize( Painter, LegendSizes ); return Style; }
/*---------------------------------------------------------------------*//** フレーム制御 **//*---------------------------------------------------------------------*/ void HeaderPanel::exec(ExecRes* res, const ExecCtx* ec) { Panel::exec(res, ec); GameExecCtx* gec = (GameExecCtx*)ec; TouchPanel* ui = gec->getTouchPanel(); // 子パネル制御 PointF32 ptTouch(S32_MIN, S32_MIN); PointF32 ptClick(S32_MIN, S32_MIN); bool isTouch = !ui->isReacted() ? ui->getTouchPosition(&ptTouch) : false; bool isClick = !ui->isReacted() ? ui->isTapRelease(&ptClick, 0L) : false; ///ui->isClickRelease(&ptClick) for(int i = 0; i < NUM_BTN; i++) { if(_pnlBtn[i] == 0) { continue; } if(isClick) { if(_pnlBtn[i]->hit(&ptClick, true)) { switch(i) { case BTN_LEFT: _res.setFlags(Res::F_CLICK_L, true); Game::getGame()->getSoundManager()->playUiSe(GameSoundDef::SE_OK, false); break; case BTN_RIGHT: _res.setFlags(Res::F_CLICK_R, true); Game::getGame()->getSoundManager()->playUiSe(GameSoundDef::SE_OK, false); break; case BTN_FUNC: _res.setFlags(Res::F_CLICK_F, true); Game::getGame()->getSoundManager()->playUiSe(GameSoundDef::SE_OK, false); break; } ui->setReacted(true); } } else { _pnlBtn[i]->hit(&ptTouch, isTouch); } _pnlBtn[i]->exec(res, ec); } // ボディのタップ判定 if(!ui->isReacted() && isClick) { if(getRectangle()->isPointIn(&ptClick)) { _res.setFlags(Res::F_CLICK_BODY, true); } } if(!ui->isReacted() && isTouch) { if(getRectangle()->isPointIn(&ptTouch)) { _res.setFlags(Res::F_TOUCH_BODY, true); } } }
void BoundingBoxExtractor::gotComment(const char *value) { QString data(value); if (data.indexOf("%BoundingBox:") == -1) return; getRectangle(value, m_llx, m_lly, m_urx, m_ury); }
void texSelector::setRectColor(string name, ofFloatColor color){ textureRect* target = getRectangle(name); target->col[0].set(color); target->col[1].set(color); target->col[2].set(color); target->col[3].set(color); refleshVertexPointer(); }
void scigraphics::legend::drawAllLegends( painter &Painter, const graphCollection &Graphics, const textStyle &Style ) { wcoord y = getRectangle().up() - interTextVerticalDistance(Style); for ( graphCollection::const_reverse_iterator Graph = Graphics.rbegin(); Graph != Graphics.rend(); ++Graph ) { if ( shouldDrawGraphLegend( *Graph ) ) { wcoord LegendHeight = drawGraphLegend( Painter, y, *Graph, Style ); y -= LegendHeight + interTextVerticalDistance(Style); } } }
void scigraphics::legend::draw( painter &Painter, const graphCollection &Graphics ) { if ( ! isVisible() ) return; if ( ! shouldDrawLegend(Graphics) ) return; const textStyle CurrTextStyle = updateLegendRectangle( Painter, Graphics ); if ( getRectangle().width() <= 1 ) return; drawBackground( Painter ); drawAllLegends( Painter, Graphics, CurrTextStyle ); }
scigraphics::wcoord scigraphics::legend::drawGraphLegend( painter &Painter, wcoord y, const graph &Graph, const textStyle &Style ) { const wcoord TextHeight = Painter.textHeight( Graph.legend(), Style ); const wcoord XForExample = getRectangle().left() + textHorizontalIndent(); const wcoord ExampleWidth = Graph.legendExampleWidth(); const wcoord GraphLegendHeight = std::max( Graph.legendExampleHeight(), TextHeight ); Graph.drawLegendExample( Painter, wrectangle( wpoint( XForExample, y-GraphLegendHeight ), wpoint(XForExample+ExampleWidth,y) ) ); const wcoord XForText = XForExample + ExampleWidth + textHorizontalIndent(); Painter.drawTextW( Graph.legend(), wpoint( XForText, y-GraphLegendHeight/2 ), painter::HLeft|painter::VCenter, Style ); return GraphLegendHeight; }
void scigraphics::legend::setRectangleFromLegendSize( painter &Painter, const legendSize &LegendSize ) { wpoint LeftUp = getRectangle().leftUp(); wpoint RightDown( LeftUp.x() + LegendSize.width(), LeftUp.y() - LegendSize.height() ); wrectangle LegendRectangle( LeftUp, RightDown ); if ( LegendRectangle.width() < Painter.plotWidth() ) while ( LegendRectangle.right() > Painter.plotWidth() ) LegendRectangle.moveX( -1 ); if ( LegendRectangle.height() < Painter.plotHeight() ) while ( LegendRectangle.down() < 0 ) LegendRectangle.moveY( +1 ); setRectangle( LegendRectangle ); }
bool VpeMain::reallyClose() { WRect rect; show( WWinStateShowNormal ); if( _quitAnyways || okToQuit() ) { startWait(); clearProject(); stopWait(); // write out .INI file stuff char buff[_MAX_PATH]; _ini.write( IDE_INI_IDENTIFIER, IDE_INI_EDITOR, (char*)_editor.gets() ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_EDITOR_ISDLL, _editorIsDll ? "1" : "0" ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_EDITOR_PARMS, _editorParms.gets() ); for( int i=0; i<_oldProjects.count(); i++ ) { itoa( i+1, buff, 10 ); _ini.write( IDE_INI_IDENTIFIER, buff, (const char*)*((WFileName*)_oldProjects[i]) ); } _ini.write( IDE_INI_IDENTIFIER, IDE_INI_TOOLBAR, _toolBarActive ? "1" : "0" ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_STATWND, (_statusBar != NULL) ? "1" : "0" ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_AUTOREFRESH, _autoRefresh ? "1" : "0" ); getRectangle( rect ); itoa( rect.w(), buff, 10 ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_WIDTH, buff ); itoa( rect.h(), buff, 10 ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_HEIGHT, buff ); itoa( rect.x(), buff, 10 ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_X, buff ); itoa( rect.y(), buff, 10 ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_Y, buff ); if( _otherhelp != NULL ) { delete _otherhelp; _otherhelp = NULL; } delete _help; _help = NULL; return( true ); } return( false ); }
std::list<Tile*> Tilemap::getRectangle( const TilePos& pos, const Size& size, const bool corners /*= true */ ) { return getRectangle( pos, pos + TilePos( size.getWidth(), size.getHeight()), corners ); }
bool LastingEffects::tick(Creature* c, LastingEffect effect) { PROFILE_BLOCK("LastingEffects::tick"); switch (effect) { case LastingEffect::BLEEDING: c->getBody().bleed(c, 0.03); c->secondPerson(PlayerMessage("You are bleeding.", MessagePriority::HIGH)); c->thirdPerson(PlayerMessage(c->getName().the() + " is bleeding.", MessagePriority::HIGH)); if (c->getBody().getHealth() <= 0) { c->you(MsgType::DIE_OF, "bleeding"); c->dieWithLastAttacker(); return true; } break; case LastingEffect::REGENERATION: c->getBody().heal(c, 0.03); break; case LastingEffect::ON_FIRE: c->getPosition().fireDamage(0.1); break; case LastingEffect::POISON: c->getBody().bleed(c, 0.03); c->secondPerson(PlayerMessage("You suffer from poisoning.", MessagePriority::HIGH)); c->thirdPerson(PlayerMessage(c->getName().the() + " suffers from poisoning.", MessagePriority::HIGH)); if (c->getBody().getHealth() <= 0) { c->you(MsgType::DIE_OF, "poisoning"); c->dieWithLastAttacker(); return true; } break; case LastingEffect::WARNING: { const int radius = 5; bool isDanger = false; bool isBigDanger = false; auto position = c->getPosition(); for (Position v : position.getRectangle(Rectangle(-radius, -radius, radius + 1, radius + 1))) { for (auto f : v.getFurniture()) if (f->emitsWarning(c)) { if (v.dist8(position).value_or(2) <= 1) isBigDanger = true; else isDanger = true; } if (Creature* enemy = v.getCreature()) { if (!c->canSee(enemy) && c->isEnemy(enemy)) { int diff = enemy->getAttr(AttrType::DAMAGE) - c->getAttr(AttrType::DEFENSE); if (diff > 5) isBigDanger = true; else if (diff > 0) isDanger = true; } } } if (isBigDanger) c->privateMessage(PlayerMessage("You sense big danger!", MessagePriority::HIGH)); else if (isDanger) c->privateMessage(PlayerMessage("You sense danger!", MessagePriority::HIGH)); break; } case LastingEffect::SUNLIGHT_VULNERABLE: if (c->getPosition().sunlightBurns()) { c->you(MsgType::ARE, "burnt by the sun"); if (Random.roll(10)) { c->you(MsgType::YOUR, "body crumbles to dust"); c->dieWithReason("killed by sunlight", Creature::DropType::ONLY_INVENTORY); return true; } } break; case LastingEffect::ENTERTAINER: if (!c->isAffected(LastingEffect::SLEEP) && Random.roll(50)) { auto others = c->getVisibleCreatures().filter([](const Creature* c) { return c->getBody().hasBrain() && c->getBody().isHumanoid(); }); if (others.empty()) break; string jokeText = "a joke"; optional<LastingEffect> hatedGroup; for (auto effect : getHateEffects()) if (c->isAffected(effect) || (c->getAttributes().getHatedByEffect() != effect && Random.roll(10 * getHateEffects().size()))) { hatedGroup = effect; break; } if (hatedGroup) jokeText.append(" about "_s + getHatedGroupName(*hatedGroup)); c->verb("crack", "cracks", jokeText); for (auto other : others) if (other != c && !other->isAffected(LastingEffect::SLEEP)) { if (hatedGroup && hatedGroup == other->getAttributes().getHatedByEffect()) { other->addMorale(-0.05); other->you(MsgType::ARE, "offended"); } else { other->verb("laugh", "laughs"); other->addMorale(0.01); } } } break; case LastingEffect::BAD_BREATH: for (auto pos : c->getPosition().getRectangle(Rectangle::centered(7))) if (auto other = pos.getCreature()) other->addMorale(-0.002); break; case LastingEffect::DISAPPEAR_DURING_DAY: if (c->getGame()->getSunlightInfo().getState() == SunlightState::DAY) c->dieNoReason(Creature::DropType::ONLY_INVENTORY); break; default: break; } return false; }
Rectangle *Surface::getRectangle(void) { return getRectangle(0, 0); }
//-------------------------------------------------------------- void LayerTransform::setHeight(float h) { this->size.y = h; ofRectangle rect = getRectangle(); ofNotifyEvent(sizeChangeEvent,rect,this); }
//-------------------------------------------------------------- void LayerTransform::setWidth(float w) { this->size.x = w; onSetSize(); ofRectangle rect = getRectangle(); ofNotifyEvent(sizeChangeEvent,rect,this); }
//-------------------------------------------------------------- void LayerTransform::setSize(float w, float h) { this->size.set(w, h, 0); onSetSize(); ofRectangle rect = getRectangle(); ofNotifyEvent(sizeChangeEvent,rect,this); }