本文整理汇总了C++中BitmapText类的典型用法代码示例。如果您正苦于以下问题:C++ BitmapText类的具体用法?C++ BitmapText怎么用?C++ BitmapText使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BitmapText类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SpellSlot
void Spellbook::calculateSpellSlots() {
float yOffset = GUIConstants::TOP + SPELL_OFFSET;
float xOffset = GUIConstants::LEFT + GUIConstants::TEXT_OFFSET / 2.f + SpellSlot::ICON_OFFSET;
for (auto& it : m_core->getData().spellsLearned) {
for (auto& it2 : it.second) {
SpellSlot slot = SpellSlot(it2);
slot.setPosition(sf::Vector2f(xOffset, yOffset));
BitmapText text;
text.setCharacterSize(GUIConstants::CHARACTER_SIZE_M);
text.setColor(COLOR_WHITE);
text.setString(g_textProvider->getText(EnumNames::getSpellIDName(it2)));
text.setPosition(sf::Vector2f(xOffset + SpellSlot::ICON_SIZE + SpellSlot::ICON_OFFSET + MARGIN, yOffset));
BitmapText textDesc;
textDesc.setCharacterSize(GUIConstants::CHARACTER_SIZE_S);
textDesc.setColor(COLOR_LIGHT_GREY);
textDesc.setString(g_textProvider->getCroppedText(
EnumNames::getSpellIDName(it2) + "Desc", GUIConstants::CHARACTER_SIZE_S,
static_cast<int>(WIDTH - (SpellSlot::SIZE + 4 * MARGIN))));
textDesc.setPosition(sf::Vector2f(xOffset + SpellSlot::ICON_SIZE + SpellSlot::ICON_OFFSET + MARGIN, yOffset + GUIConstants::CHARACTER_SIZE_M + 4.f));
std::pair<BitmapText, BitmapText> texts = std::pair<BitmapText, BitmapText>(text, textDesc);
m_typeMap.at(it.first)->push_back(std::pair<SpellSlot, std::pair<BitmapText, BitmapText>>(slot, texts));
yOffset += SpellSlot::SIZE + MARGIN;
}
yOffset = GUIConstants::TOP + SPELL_OFFSET;
}
}
示例2: ScreenAttract
ScreenMusicScroll::ScreenMusicScroll( CString sClassName ) : ScreenAttract( sClassName )
{
vector<Song*> arraySongs;
SONGMAN->GetSongs( arraySongs );
SongUtil::SortSongPointerArrayByTitle( arraySongs );
unsigned i;
for( i=0; i < arraySongs.size(); i++ )
{
BitmapText *bt = new BitmapText;
m_textLines.push_back(bt);
Song* pSong = arraySongs[i];
bt->LoadFromFont( THEME->GetPathToF("ScreenMusicScroll titles") );
bt->SetText( pSong->GetFullDisplayTitle(), pSong->GetFullTranslitTitle() );
bt->SetDiffuse( SONGMAN->GetSongColor(pSong) );
bt->SetZoom( TEXT_ZOOM );
this->AddChild( bt );
}
// for( i=0; i<min(NUM_CREDIT_LINES, MAX_CREDIT_LINES); i++ )
// {
// m_textLines[m_iNumLines].LoadFromFont( THEME->GetPathToF("ScreenMusicScroll titles") );
// m_textLines[m_iNumLines].SetText( CREDIT_LINES[i] );
// m_textLines[m_iNumLines].SetZoom( TEXT_ZOOM );
//
// m_iNumLines++;
// }
for( i=0; i<m_textLines.size(); i++ )
{
m_textLines[i]->SetXY( CENTER_X, SCREEN_BOTTOM + 40 );
m_textLines[i]->BeginTweening( SCROLL_DELAY * i );
m_textLines[i]->BeginTweening( 2.0f*SCROLL_SPEED );
m_textLines[i]->SetXY( CENTER_X, SCREEN_TOP - 40 );
}
this->MoveToTail( &m_In ); // put it in the back so it covers up the stuff we just added
this->MoveToTail( &m_Out ); // put it in the back so it covers up the stuff we just added
this->ClearMessageQueue( SM_BeginFadingOut ); // ignore ScreenAttract's SecsToShow
this->PostScreenMessage( SM_BeginFadingOut, 0.2f * i + 3.0f );
SOUND->PlayOnceFromDir( ANNOUNCER->GetPathTo("music scroll") );
}
示例3:
WndBag::WndBag(Bag* bag, Listener* listener, Mode mode, const std::string& title)
{
this->listener = listener;
this->mode = mode;
this->title = title;
lastMode = mode;
lastBag = bag;
nCols = PixelDungeon::landscape() ? COLS_L : COLS_P;
nRows = (Belongings::BACKPACK_SIZE + 4 + 1) / nCols + ((Belongings::BACKPACK_SIZE + 4 + 1) % nCols > 0 ? 1 : 0);
int slotsWidth = SLOT_SIZE * nCols + SLOT_MARGIN * (nCols - 1);
int slotsHeight = SLOT_SIZE * nRows + SLOT_MARGIN * (nRows - 1);
BitmapText* txtTitle = PixelScene::createText(title.size() > 0 ? title : bag->Name(), 9);
txtTitle->hardlight(TITLE_COLOR);
txtTitle->measure();
txtTitle->x = (int)(slotsWidth - txtTitle->Width()) / 2;
txtTitle->y = (int)(TITLE_HEIGHT - txtTitle->Height()) / 2;
Group::add(txtTitle);
placeItems(bag);
resize(slotsWidth, slotsHeight + TITLE_HEIGHT);
Belongings* stuff = Dungeon::hero->belongings;
//Bag[] bags = {
// stuff.backpack,
// stuff.getItem(SeedPouch.class),
// stuff.getItem(ScrollHolder.class),
// stuff.getItem(WandHolster.class),
// stuff.getItem(Keyring.class) };
//
//for (Bag b : bags) {
// if (b != null) {
// BagTab tab = new BagTab(b);
// tab.setSize(TAB_WIDTH, tabHeight());
// add(tab);
//
// tab.select(b == bag);
// }
//}
}
示例4: ClearChoices
void LinkedOptionsMenu::SetChoices( const CStringArray &asChoices )
{
ClearChoices();
for( unsigned i = 0; i < asChoices.size(); i++ )
{
CString ch = asChoices[i];
BitmapText *bt = new BitmapText;
m_Rows.push_back( bt );
bt->LoadFromFont( THEME->GetPathF( m_sName, "menutext" ) );
bt->SetName( "Row" );
bt->SetXY( ROW_OFFSET_X, ROW_OFFSET_Y + (ROW_SPACING_Y * (float)(i % ROWS_PER_PAGE)) );
bt->SetText( ch );
m_Frame.AddChild( bt );
ON_COMMAND( *bt );
}
// show first page of choices
for( unsigned i = 0; i < asChoices.size() && i < (unsigned)ROWS_PER_PAGE; i++ )
{
m_Rows[i]->PlayCommand("TweenOn");
}
m_iCurPage = 0;
if ( asChoices.size() > (unsigned)ROWS_PER_PAGE )
{
m_sprIndicatorDown.PlayCommand("TweenOn");
m_bIndTweenedOn[1] = true;
}
if ( m_Rows.size() > 0 )
{
if ( m_bFocus ) m_Cursor.PlayCommand( "TweenOn" );
m_Cursor.SetXY( CURSOR_OFFSET_X + m_Rows[0]->GetX(), m_Rows[0]->GetY() );
m_Cursor.SetBarWidth( floor(m_Rows[0]->GetZoomedWidth()) );
m_iCurrentSelection = 0;
}
else
{
m_iCurrentSelection = -1;
m_Cursor.PlayCommand( "TweenOff" );
if ( m_bFocus )
SCREENMAN->PostMessageToTopScreen( m_smChangeMenu, 0.0f );
}
}
示例5: LOAD_ALL_COMMANDS
// begin ScreenTextEntryVisual
void ScreenTextEntryVisual::Init()
{
ROW_START_X.Load( m_sName, "RowStartX" );
ROW_START_Y.Load( m_sName, "RowStartY" );
ROW_END_X.Load( m_sName, "RowEndX" );
ROW_END_Y.Load( m_sName, "RowEndY" );
ScreenTextEntry::Init();
m_sprCursor.Load( THEME->GetPathG(m_sName,"cursor") );
m_sprCursor->SetName( "Cursor" );
LOAD_ALL_COMMANDS( m_sprCursor );
this->AddChild( m_sprCursor );
// Init keyboard
{
BitmapText text;
text.LoadFromFont( THEME->GetPathF(m_sName,"keyboard") );
text.SetName( "Keys" );
ActorUtil::LoadAllCommands( text, m_sName );
text.PlayCommand( "Init" );
FOREACH_KeyboardRow( r )
{
for( int x=0; x<KEYS_PER_ROW; ++x )
{
BitmapText *&pbt = m_ptextKeys[r][x];
pbt = text.Copy();
this->AddChild( pbt );
RString s = g_szKeys[r][x];
if( !s.empty() && r == KEYBOARD_ROW_SPECIAL )
s = THEME->GetString( m_sName, s );
pbt->SetText( s );
}
}
}
m_sndChange.Load( THEME->GetPathS(m_sName,"change"), true );
}
示例6: calculateModifierSlots
void Spellbook::calculateModifierSlots() {
float yOffset = GUIConstants::TOP + SPELL_OFFSET;
float xOffset = GUIConstants::LEFT + 2 * GUIConstants::TEXT_OFFSET;
float modifierXOffset = 213.f;
float textYOffset = SpellSlot::ICON_SIZE / 2.f - GUIConstants::CHARACTER_SIZE_S / 2.f;
for (auto& it : m_core->getData().modfiersLearned) {
BitmapText text;
text.setCharacterSize(GUIConstants::CHARACTER_SIZE_S);
text.setColor(COLOR_WHITE);
text.setPosition(sf::Vector2f(xOffset, yOffset + textYOffset));
text.setString(g_textProvider->getText(EnumNames::getSpellModifierTypeName(it.first)));
m_modifierTexts.push_back(text);
for (int i = 0; i < it.second; i++) {
SpellModifier modifier;
modifier.level = i + 1;
modifier.type = it.first;
ModifierSlot slot(modifier);
slot.setPosition(sf::Vector2f(modifierXOffset + (i * (ModifierSlot::SIZE + MARGIN)), yOffset));
m_modifierSlots.push_back(slot);
}
yOffset += ModifierSlot::SIZE + 6.f;
}
}
示例7: BitmapText
void Game::showFPSText(sf::RenderTarget& target, float frameTimeSeconds) {
sf::View oldView = target.getView();
target.setView(target.getDefaultView());
m_fpsList.push_back(frameTimeSeconds);
if (static_cast<int>(m_fpsList.size()) > FPS_AVERAGE_NR) {
m_fpsList.pop_front();
}
// calc average
float sum = 0.f;
for (float f : m_fpsList) {
sum += f;
}
int fps = static_cast<int>(1.f / (sum / FPS_AVERAGE_NR));
BitmapText fpsText = BitmapText(
"FPS: " + std::to_string(fps));
fpsText.setColor(COLOR_BAD);
fpsText.setPosition(sf::Vector2f(1050.f, 10.f));
fpsText.setCharacterSize(16);
target.draw(fpsText);
target.setView(oldView);
}
示例8: calculateModifierSlots
void Spellbook::calculateModifierSlots()
{
float yOffset = GUIConstants::TOP + GUIConstants::TEXT_OFFSET + 2 * GUIConstants::CHARACTER_SIZE_M + 2 * MARGIN + 2 * BUTTON_SIZE.y;
float xOffset = GUIConstants::LEFT + GUIConstants::TEXT_OFFSET;
int maxY = 4;
int y = 1;
for (auto& it : m_core->getData().modfiersLearned)
{
BitmapText text;
text.setCharacterSize(GUIConstants::CHARACTER_SIZE_M);
text.setColor(CENDRIC_COLOR_WHITE);
text.setPosition(sf::Vector2f(xOffset, yOffset));
text.setString(g_textProvider->getText(EnumNames::getSpellModifierTypeName(it.first)));
m_modifierTexts.push_back(text);
yOffset += GUIConstants::CHARACTER_SIZE_M * 2;
for (int i = 0; i < it.second; i++)
{
SpellModifier modifier;
modifier.level = i + 1;
modifier.type = it.first;
ModifierSlot slot(modifier);
slot.setPosition(sf::Vector2f(xOffset + (i * (ModifierSlot::SIDE_LENGTH + MARGIN)), yOffset));
m_modifierSlots.push_back(slot);
}
if (y >= maxY)
{
yOffset = GUIConstants::TOP + GUIConstants::TEXT_OFFSET + 2 * GUIConstants::CHARACTER_SIZE_M + 2 * MARGIN + 2 * BUTTON_SIZE.y;
xOffset = GUIConstants::LEFT + WIDTH - (3 * ModifierSlot::SIDE_LENGTH + 2 * MARGIN + GUIConstants::TEXT_OFFSET);
y = 0;
}
else
{
y++;
yOffset += GUIConstants::CHARACTER_SIZE_M + ModifierSlot::SIDE_LENGTH;
}
}
}
示例9: LoadExit
void OptionRow::LoadExit()
{
m_RowType = OptionRow::ROW_EXIT;
m_RowDef.name = EXIT_NAME;
m_RowDef.choices.push_back( "" );
BitmapText *bt = new BitmapText;
m_textItems.push_back( bt );
bt->LoadFromFont( THEME->GetPathF(m_sType,"item") );
CString sText = "Exit";
PrepareItemText( sText );
bt->SetText( sText );
bt->RunCommands( ITEMS_ON_COMMAND );
bt->SetShadowLength( 0 );
bt->SetX( ITEMS_LONG_ROW_SHARED_X );
m_Frame.AddChild( bt );
FOREACH_PlayerNumber( p )
m_OptionIcons[p].SetHidden( true );
m_sprBullet.SetHidden( true );
m_textTitle.SetHidden( true );
}
示例10: ScreenAttract
ScreenUnlock::ScreenUnlock( CString sClassName ) : ScreenAttract( sClassName )
{
LOG->Trace("ScreenUnlock::ScreenUnlock()");
unsigned NumUnlocks = NUM_UNLOCKS;
if (UNLOCKMAN->m_SongEntries.size() < NumUnlocks)
NumUnlocks = UNLOCKMAN->m_SongEntries.size();
if (!PREFSMAN->m_bUseUnlockSystem || NumUnlocks == 0)
{
this->HandleScreenMessage( SM_GoToNextScreen );
return;
}
PointsUntilNextUnlock.LoadFromFont( THEME->GetPathToF("Common normal") );
PointsUntilNextUnlock.SetHorizAlign( Actor::align_left );
unsigned i;
CString IconCommand = ICON_COMMAND;
for(i=1; i <= NumUnlocks; i++)
{
// get pertaining UnlockEntry
CString SongTitle = DISPLAYED_SONG(i);
if (USE_UNLOCKS_DAT == 1)
if ((unsigned)i <= UNLOCKMAN->m_SongEntries.size() )
SongTitle = UNLOCKMAN->m_SongEntries[i-1].m_sSongName;
LOG->Trace("UnlockScreen: Searching for %s", SongTitle.c_str());
const UnlockEntry *pSong = UNLOCKMAN->FindLockEntry( SongTitle );
if( pSong == NULL)
{
LOG->Trace("Can't find song %s", SongTitle.c_str());
continue;
}
Sprite* entry = new Sprite;
// new unlock graphic
entry->Load( THEME->GetPathToG(ssprintf("ScreenUnlock %d icon", i)) );
// set graphic location
entry->SetName( ssprintf("Unlock%d",i) );
SET_XY( *entry );
entry->Command(IconCommand);
Unlocks.push_back(entry);
if ( !pSong->IsLocked() )
this->AddChild(Unlocks[Unlocks.size() - 1]);
}
// scrolling text
if (UNLOCK_TEXT_SCROLL != 0)
{
float ScrollingTextX = UNLOCK_TEXT_SCROLL_X;
float ScrollingTextStartY = UNLOCK_TEXT_SCROLL_START_Y;
float ScrollingTextEndY = UNLOCK_TEXT_SCROLL_END_Y;
float ScrollingTextZoom = UNLOCK_TEXT_SCROLL_ZOOM;
float ScrollingTextRows = UNLOCK_TEXT_SCROLL_ROWS;
float MaxWidth = UNLOCK_TEXT_SCROLL_MAX_WIDTH;
float SecondsToScroll = TIME_TO_DISPLAY;
if (SecondsToScroll > 2) SecondsToScroll--;
float SECS_PER_CYCLE = 0;
if (UNLOCK_TEXT_SCROLL != 3)
SECS_PER_CYCLE = (float)SecondsToScroll/(ScrollingTextRows + NumUnlocks);
else
SECS_PER_CYCLE = (float)SecondsToScroll/(ScrollingTextRows * 3 + NumUnlocks + 4);
for(i = 1; i <= NumUnlocks; i++)
{
CString DisplayedSong = DISPLAYED_SONG(i);
if (USE_UNLOCKS_DAT == 1)
if ((unsigned)i <= UNLOCKMAN->m_SongEntries.size() )
DisplayedSong = UNLOCKMAN->m_SongEntries[i-1].m_sSongName;
DisplayedSong.MakeUpper();
const UnlockEntry *pSong = UNLOCKMAN->FindLockEntry(DisplayedSong);
if ( pSong == NULL ) // no such song
continue;
BitmapText* text = new BitmapText;
text->LoadFromFont( THEME->GetPathToF("ScreenUnlock text") );
text->SetHorizAlign( Actor::align_left );
text->SetZoom(ScrollingTextZoom);
if (pSong && pSong->m_pSong != NULL)
{
CString title = pSong->m_pSong->GetDisplayMainTitle();
CString subtitle = pSong->m_pSong->GetDisplaySubTitle();
if( subtitle != "" )
title = title + "\n" + subtitle;
text->SetMaxWidth( MaxWidth );
text->SetText( title );
}
//.........这里部分代码省略.........
示例11: ScreenAttract
ScreenCredits::ScreenCredits( CString sName ) : ScreenAttract( sName )
{
vector<Song*> arraySongs;
SONGMAN->GetSongs( arraySongs );
SongUtil::SortSongPointerArrayByTitle( arraySongs );
// FIXME: Redo this screen with a BGA
CString sBackgroundsTransformFunction = ssprintf(
"function(self,offset,itemIndex,numItems) "
" self:x(%f*offset); "
" self:y(%f*offset); "
"end",
(float)BACKGROUNDS_SPACING_X,
(float)BACKGROUNDS_SPACING_Y );
m_ScrollerBackgrounds.SetName( "Backgrounds" );
m_ScrollerBackgrounds.Load3(
BACKGROUNDS_SCROLL_SECONDS_PER_ITEM,
4,
false,
sBackgroundsTransformFunction,
false );
SET_XY( m_ScrollerBackgrounds );
this->AddChild( &m_ScrollerBackgrounds );
m_ScrollerFrames.SetName( "Backgrounds" );
m_ScrollerFrames.Load3(
BACKGROUNDS_SCROLL_SECONDS_PER_ITEM,
4,
false,
sBackgroundsTransformFunction,
false );
SET_XY( m_ScrollerFrames );
this->AddChild( &m_ScrollerFrames );
float fTime = 0;
{
for( int i=0; i<NUM_BACKGROUNDS; i++ )
{
Song* pSong = NULL;
for( int j=0; j<50; j++ )
{
pSong = arraySongs[ rand()%arraySongs.size() ];
if( pSong->HasBackground() )
break;
}
Sprite* pBackground = new Sprite;
pBackground->LoadBG( pSong->HasBackground() ? pSong->GetBackgroundPath() : THEME->GetPathG("Common","fallback background") );
pBackground->ScaleToClipped( BACKGROUNDS_WIDTH, BACKGROUNDS_HEIGHT );
m_ScrollerBackgrounds.AddChild( pBackground );
Sprite* pFrame = new Sprite;
pFrame->Load( THEME->GetPathG("ScreenCredits","background frame") );
m_ScrollerFrames.AddChild( pFrame );
}
float fFirst = -2;
float fLast = NUM_BACKGROUNDS+2;
m_ScrollerBackgrounds.SetCurrentAndDestinationItem( fFirst );
m_ScrollerBackgrounds.SetDestinationItem( fLast );
m_ScrollerFrames.SetCurrentAndDestinationItem( fFirst );
m_ScrollerFrames.SetDestinationItem( fLast );
fTime = max( fTime, BACKGROUNDS_SCROLL_SECONDS_PER_ITEM*(fLast-fFirst) );
}
CString sTextsTransformFunction = ssprintf(
"function(self,offset,itemIndex,numItems) "
" self:x(%f*offset); "
" self:y(%f*offset); "
"end",
(float)TEXTS_SPACING_X,
(float)TEXTS_SPACING_Y );
m_ScrollerTexts.SetName( "Texts" );
m_ScrollerTexts.Load3(
TEXTS_SCROLL_SECONDS_PER_ITEM,
40,
false,
sTextsTransformFunction,
false );
SET_XY( m_ScrollerTexts );
this->AddChild( &m_ScrollerTexts );
{
for( unsigned i=0; i<ARRAYLEN(CREDIT_LINES); i++ )
{
BitmapText* pText = new BitmapText;
pText->LoadFromFont( THEME->GetPathF("ScreenCredits","titles") );
pText->SetText( CREDIT_LINES[i].text );
switch( CREDIT_LINES[i].colorIndex )
{
case 1: pText->SetDiffuse( TEXTS_COLOR_INTRO ); break;
case 2: pText->SetDiffuse( TEXTS_COLOR_HEADER ); break;
case 0: pText->SetDiffuse( TEXTS_COLOR_NORMAL ); break;
default: ASSERT(0);
}
pText->SetZoom( TEXTS_ZOOM );
m_ScrollerTexts.AddChild( pText );
//.........这里部分代码省略.........
示例12: DeviceInput
void ScreenDebugOverlay::Init()
{
Screen::Init();
// Init debug mappings
// TODO: Arch-specific?
{
g_Mappings.Clear();
g_Mappings.holdForDebug1 = DeviceInput(DEVICE_KEYBOARD, KEY_F3);
g_Mappings.holdForDebug2.MakeInvalid();
g_Mappings.holdForSlow = DeviceInput(DEVICE_KEYBOARD, KEY_ACCENT);
g_Mappings.holdForFast = DeviceInput(DEVICE_KEYBOARD, KEY_TAB);
/* TODO: Find a better way of indicating which option is which here.
* Maybe we should take a page from ScreenEdit's menus and make
* RowDefs()? */
int i=0;
g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F8);
g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F7);
g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F6);
i=0;
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C1);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C2);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C3);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C4);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C5);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C6);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C7);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C8);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C9);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C0);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cq);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cw);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ce);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cr);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ct);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cy);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cu);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ci);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Co);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cp);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_UP);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_DOWN);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_BACK);
g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F5)] = 0;
g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F6)] = 1;
g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F7)] = 2;
g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F8)] = 3;
}
map<RString,int> iNextDebugButton;
int iNextGameplayButton = 0;
FOREACH( IDebugLine*, *g_pvpSubscribers, p )
{
RString sPageName = (*p)->GetPageName();
DeviceInput di;
switch( (*p)->GetType() )
{
case IDebugLine::all_screens:
di = g_Mappings.debugButton[iNextDebugButton[sPageName]++];
break;
case IDebugLine::gameplay_only:
di = g_Mappings.gameplayButton[iNextGameplayButton++];
break;
}
(*p)->m_Button = di;
if( find(m_asPages.begin(), m_asPages.end(), sPageName) == m_asPages.end() )
m_asPages.push_back( sPageName );
}
m_iCurrentPage = 0;
m_bForcedHidden = false;
m_Quad.StretchTo( RectF( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) );
m_Quad.SetDiffuse( BACKGROUND_COLOR );
this->AddChild( &m_Quad );
// if you're going to add user commands, make sure to have the overrides
// set after parsing the metrics. -aj
m_textHeader.SetName( "HeaderText" );
m_textHeader.LoadFromFont( THEME->GetPathF("ScreenDebugOverlay", "header") );
LOAD_ALL_COMMANDS_AND_SET_XY_AND_ON_COMMAND( m_textHeader );
m_textHeader.SetText( DEBUG_MENU );
this->AddChild( &m_textHeader );
FOREACH_CONST( RString, m_asPages, s )
{
int iPage = s - m_asPages.begin();
DeviceInput di;
bool b = GetKeyFromMap( g_Mappings.pageButton, iPage, di );
ASSERT( b );
RString sButton = INPUTMAN->GetDeviceSpecificInputString( di );
BitmapText *p = new BitmapText;
//.........这里部分代码省略.........
示例13: switch
//.........这里部分代码省略.........
}
m_textNames[l].SetDiffuse( STEPS_TYPE_COLOR(pts.colorIndex) );
m_textPoints[l].SetDiffuse( STEPS_TYPE_COLOR(pts.colorIndex) );
m_textTime[l].SetDiffuse( STEPS_TYPE_COLOR(pts.colorIndex) );
m_textScores[l].SetDiffuse( STEPS_TYPE_COLOR(pts.colorIndex) );
if( bRecentHighScore )
{
m_textNames[l].SetEffectGlowBlink(0.1f);
m_textScores[l].SetEffectGlowBlink(0.1f);
}
else
{
m_textNames[l].SetEffectNone();
m_textScores[l].SetEffectNone();
}
}
}
return SECONDS_PER_PAGE;
case PAGE_TYPE_ALL_STEPS:
{
m_textStepsType.SetText( GameManager::StepsTypeToThemedString(pts.nt) );
for( unsigned s=0; s<m_vpStepsScoreRowItem.size(); s++ )
{
StepsScoreRowItem *pStepsScoreRowItem = m_vpStepsScoreRowItem[s];
const Song* pSong = pStepsScoreRowItem->m_pSong;
pStepsScoreRowItem->m_textSongTitle.SetText( pSong->GetFullDisplayTitle() );
for( vector<Difficulty>::iterator dc_iter = m_vDiffsToShow.begin(); dc_iter != m_vDiffsToShow.end(); dc_iter++ )
{
const Steps* pSteps = pSong->GetStepsByDifficulty( pts.nt, *dc_iter, false );
BitmapText* pTextStepsScore = &pStepsScoreRowItem->m_textStepsScore[*dc_iter];
if( pSteps == NULL )
{
pTextStepsScore->SetHidden( true );
}
else
{
HighScoreList &hsl = PROFILEMAN->GetMachineProfile()->GetStepsHighScoreList(pSong,pSteps);
HighScore hs = hsl.GetTopScore();
bool bRecentHighScore = false;
if( !hsl.vHighScores.empty() )
{
hs = hsl.GetTopScore();
const CString *psName = &hsl.GetTopScore().sName;
bRecentHighScore = find( GAMESTATE->m_vpsNamesThatWereFilled.begin(), GAMESTATE->m_vpsNamesThatWereFilled.end(), psName ) != GAMESTATE->m_vpsNamesThatWereFilled.end();
}
else
{
hs.sName = NO_SCORE_NAME;
}
CString s;
s = hs.GetDisplayName() + "\n";
s += ssprintf( "%0*.*f%%", PERCENT_TOTAL_SIZE, PERCENT_DECIMAL_PLACES, hs.fPercentDP*100 );
pTextStepsScore->SetText( s );
}
}
}
}
return m_ListScoreRowItems.GetSecondsForCompleteScrollThrough();
case PAGE_TYPE_ALL_COURSES:
{
示例14: FOREACH_PlayerNumber
void OptionRow::AfterImportOptions()
{
// Make all selections the same if bOneChoiceForAllPlayers
// Hack: we only import active players, so if only player 2 is imported,
// we need to copy p2 to p1, not p1 to p2.
if( m_RowDef.bOneChoiceForAllPlayers )
{
PlayerNumber pnCopyFrom = GAMESTATE->m_MasterPlayerNumber;
if( GAMESTATE->m_MasterPlayerNumber == PLAYER_INVALID )
pnCopyFrom = PLAYER_1;
FOREACH_PlayerNumber( p )
m_vbSelected[p] = m_vbSelected[pnCopyFrom];
}
FOREACH_PlayerNumber( p )
{
switch( m_RowDef.selectType )
{
case SELECT_ONE:
{
/* Make sure the row actually has a selection. */
bool bHasASelection = false;
for( unsigned i=0; i<m_vbSelected[p].size(); i++ )
{
if( m_vbSelected[p][i] )
bHasASelection = true;
}
if( !bHasASelection && !m_vbSelected[p].empty() )
m_vbSelected[p][0] = true;
m_iChoiceInRowWithFocus[p] = GetOneSelection(p, true); // focus on the selection we just set
}
break;
case SELECT_MULTIPLE:
case SELECT_NONE:
m_iChoiceInRowWithFocus[p] = 0;
break;
default:
ASSERT(0);
}
}
// init row icons
FOREACH_HumanPlayer( p )
{
LoadOptionIcon( p, "" );
}
// If the items will go off the edge of the screen, then re-init with the "long row" style.
{
BitmapText bt;
bt.LoadFromFont( THEME->GetPathF(m_sType,"item") );
bt.RunCommands( ITEMS_ON_COMMAND );
float fX = ITEMS_START_X;
for( unsigned c=0; c<m_RowDef.choices.size(); c++ )
{
CString sText = m_RowDef.choices[c];
PrepareItemText( sText );
bt.SetText( sText );
fX += bt.GetZoomedWidth();
if( c != m_RowDef.choices.size()-1 )
fX += ITEMS_GAP_X;
if( fX > ITEMS_END_X )
{
m_RowDef.layoutType = LAYOUT_SHOW_ONE_IN_ROW;
break;
}
}
}
//
// load m_textItems
//
switch( m_RowDef.layoutType )
{
case LAYOUT_SHOW_ONE_IN_ROW:
// init text
FOREACH_HumanPlayer( p )
{
BitmapText *bt = new BitmapText;
m_textItems.push_back( bt );
const int iChoiceInRowWithFocus = m_iChoiceInRowWithFocus[p];
bt->LoadFromFont( THEME->GetPathF(m_sType,"item") );
CString sText = (iChoiceInRowWithFocus==-1) ? "" : m_RowDef.choices[iChoiceInRowWithFocus];
// ugly hack for Speed mods --infamouspat
PrepareItemText( sText );
bt->SetText( sText );
bt->RunCommands( ITEMS_ON_COMMAND );
bt->SetShadowLength( 0 );
//.........这里部分代码省略.........
示例15: ScreenAttract
ScreenCredits::ScreenCredits( CString sName ) : ScreenAttract( sName )
{
vector<Song*> arraySongs;
SONGMAN->GetSongs( arraySongs );
SongUtil::SortSongPointerArrayByTitle( arraySongs );
// FIXME: Redo this screen with a BGA
m_ScrollerBackgrounds.SetName( "Backgrounds" );
m_ScrollerBackgrounds.Load(
BACKGROUNDS_SCROLL_SECONDS_PER_ITEM,
4,
RageVector3(0, 0, 0),
RageVector3(0, 0, 0),
RageVector3(BACKGROUNDS_SPACING_X, BACKGROUNDS_SPACING_Y, 0),
RageVector3(0, 0, 0) );
SET_XY( m_ScrollerBackgrounds );
this->AddChild( &m_ScrollerBackgrounds );
m_ScrollerFrames.SetName( "Backgrounds" );
m_ScrollerFrames.Load(
BACKGROUNDS_SCROLL_SECONDS_PER_ITEM,
4,
RageVector3(0, 0, 0),
RageVector3(0, 0, 0),
RageVector3(BACKGROUNDS_SPACING_X, BACKGROUNDS_SPACING_Y, 0),
RageVector3(0, 0, 0) );
SET_XY( m_ScrollerFrames );
this->AddChild( &m_ScrollerFrames );
float fTime = 0;
{
for( int i=0; i<NUM_BACKGROUNDS; i++ )
{
Song* pSong = NULL;
for( int j=0; j<50; j++ )
{
pSong = arraySongs[ rand()%arraySongs.size() ];
if( pSong->HasBackground() )
break;
}
Sprite* pBackground = new Sprite;
pBackground->LoadBG( pSong->HasBackground() ? pSong->GetBackgroundPath() : THEME->GetPathToG("Common fallback background") );
pBackground->ScaleToClipped( BACKGROUNDS_WIDTH, BACKGROUNDS_HEIGHT );
m_ScrollerBackgrounds.AddChild( pBackground );
Sprite* pFrame = new Sprite;
pFrame->Load( THEME->GetPathToG("ScreenCredits background frame") );
m_ScrollerFrames.AddChild( pFrame );
}
const int iFirst = -2, iLast = NUM_BACKGROUNDS+2;
m_ScrollerBackgrounds.SetCurrentAndDestinationItem( iFirst );
m_ScrollerBackgrounds.SetDestinationItem( iLast );
m_ScrollerFrames.SetCurrentAndDestinationItem( iFirst );
m_ScrollerFrames.SetDestinationItem( iLast );
fTime = max( fTime, BACKGROUNDS_SCROLL_SECONDS_PER_ITEM*(iLast-iFirst) );
}
m_ScrollerTexts.SetName( "Texts" );
m_ScrollerTexts.Load(
TEXTS_SCROLL_SECONDS_PER_ITEM,
40,
RageVector3(0, 0, 0),
RageVector3(0, 0, 0),
RageVector3(TEXTS_SPACING_X, TEXTS_SPACING_Y, 0),
RageVector3(0, 0, 0) );
SET_XY( m_ScrollerTexts );
this->AddChild( &m_ScrollerTexts );
{
for( unsigned i=0; i<ARRAYSIZE(CREDIT_LINES); i++ )
{
BitmapText* pText = new BitmapText;
pText->LoadFromFont( THEME->GetPathToF("ScreenCredits titles") );
pText->SetText( CREDIT_LINES[i].text );
switch( CREDIT_LINES[i].colorIndex )
{
case 1: pText->SetDiffuse( TEXTS_COLOR_INTRO ); break;
case 2: pText->SetDiffuse( TEXTS_COLOR_HEADER ); break;
case 0: pText->SetDiffuse( TEXTS_COLOR_NORMAL ); break;
default: ASSERT(0);
}
pText->SetZoom( TEXTS_ZOOM );
m_ScrollerTexts.AddChild( pText );
}
const int iFirst = -10, iLast = ARRAYSIZE(CREDIT_LINES)+10;
m_ScrollerTexts.SetCurrentAndDestinationItem( iFirst );
m_ScrollerTexts.SetDestinationItem( iLast );
fTime = max( fTime, TEXTS_SCROLL_SECONDS_PER_ITEM*(iLast-iFirst) );
}
m_Overlay.LoadFromAniDir( THEME->GetPathToB("ScreenCredits overlay") );
this->AddChild( &m_Overlay );
this->MoveToTail( &m_In ); // put it in the back so it covers up the stuff we just added
this->MoveToTail( &m_Out ); // put it in the back so it covers up the stuff we just added
//.........这里部分代码省略.........