void UIWidgetText::UpdatePosition() { MAKEHASH( m_Archetype ); MAKEHASH( m_Name ); STATICHASH( DisplayWidth ); const float DisplayWidth = ConfigManager::GetFloat( sDisplayWidth ); const float ParentWidth = m_OriginParent ? m_OriginParent->GetWidth() : DisplayWidth; const float ParentX = m_OriginParent ? Ceiling( m_OriginParent->GetX() ) : 0.0f; STATICHASH( DisplayHeight ); const float DisplayHeight = ConfigManager::GetFloat( sDisplayHeight ); const float ParentHeight = m_OriginParent ? m_OriginParent->GetHeight() : DisplayHeight; const float ParentY = m_OriginParent ? Ceiling( m_OriginParent->GetY() ) : 0.0f; STATICHASH( PixelX ); STATICHASH( PixelOffsetX ); STATICHASH( ScreenX ); float X = ConfigManager::GetArchetypeFloat( sPixelOffsetX, sm_Archetype, 0.0f, sm_Name ) + Pick( ConfigManager::GetArchetypeFloat( sPixelX, sm_Archetype, 0.0f, sm_Name ), ParentWidth * ConfigManager::GetArchetypeFloat( sScreenX, sm_Archetype, 0.0f, sm_Name ) ); STATICHASH( PixelY ); STATICHASH( PixelOffsetY ); STATICHASH( ScreenY ); float Y = ConfigManager::GetArchetypeFloat( sPixelOffsetY, sm_Archetype, 0.0f, sm_Name ) + Pick( ConfigManager::GetArchetypeFloat( sPixelY, sm_Archetype, 0.0f, sm_Name ), ParentHeight * ConfigManager::GetArchetypeFloat( sScreenY, sm_Archetype, 0.0f, sm_Name ) ); // Get dimensions so we can do different origins Array<STypesetGlyph> UnusedTypesetting; Vector2 Dimensions; Array<unicode_t> CodePoints; GetString().UTF8ToUnicode( CodePoints ); m_Font->Arrange( CodePoints, SRect( 0.0f, 0.0f, m_WrapWidth, 0.0f ), UnusedTypesetting, Dimensions ); AdjustDimensionsToParent( X, Y, Dimensions.x, Dimensions.y, ParentX, ParentY, ParentWidth, ParentHeight ); GetPositionFromOrigin( X, Y, Dimensions.x, Dimensions.y ); STATICHASH( ClampToPixelGrid ); m_ClampToPixelGrid = ConfigManager::GetArchetypeBool( sClampToPixelGrid, sm_Archetype, true, sm_Name ); if( m_ClampToPixelGrid ) { // Add 0.5 to compensate for font UVs being on half pixel intervals. m_TopLeft.x = Round( m_TopLeft.x ) + 0.5f; m_TopLeft.y = Round( m_TopLeft.y ) + 0.5f; } // Offset to properly align on pixel grid. const float PixelGridOffset = GetPixelGridOffset(); m_TopLeft.x -= PixelGridOffset; m_TopLeft.y -= PixelGridOffset; }
void FinalDestination::Initialize() { name = "finaldestination"; width = 512; height = 256; topdeath = -320; leftdeath = -192; rightdeath = 704; bottomdeath = 256; minhorizscroll = -128; maxhorizscroll = 384; minvertscroll = -192; maxvertscroll = 64; spawnx.push_back(160); spawnx.push_back(288); spawnx.push_back(96); spawnx.push_back(352); spawny.push_back(4); spawny.push_back(4); spawny.push_back(4); spawny.push_back(4); floors.push_back(Floor(64, 132, 384, 0, false)); walls.push_back(Wall(96, 132, 116, "left")); walls.push_back(Wall(416, 132, 116, "right")); walls.push_back(Wall(65, 132, 1, "left")); walls.push_back(Wall(447, 132, 1, "right")); ceilings.push_back(Ceiling(64, 132, 384)); ledges.push_back(Ledge(64, 132, "left")); ledges.push_back(Ledge(448, 132, "right")); songnames.push_back("Final Destination"); songnames.push_back("Final Destination"); songartists.push_back("Super Smash Bros. Brawl"); songartists.push_back("Super Smash Bros. Melee"); songs.push_back("SSBDS_Files/music/stages/finaldestination1.mp3"); songs.push_back("SSBDS_Files/music/stages/finaldestination2.mp3"); } // initializes all the variables for final destination
Ceiling Projectile::checkCeilingCollision(int deltax, int deltay) { for(int n = 0; n < (int)((mystage -> getCeilings()).size()); n++) { if(y+deltay >= mystage -> getCeilings()[n].y && y+deltay+dy < mystage -> getCeilings()[n].y && x+deltax+dx > mystage -> getCeilings()[n].x && x+deltax+dx < mystage -> getCeilings()[n].x + mystage -> getCeilings()[n].length) { return mystage -> getCeilings()[n]; } } return Ceiling(0, 0, 0); }
void CastleSiege::Initialize() { name = "castlesiege"; width = 512; height = 384; topdeath = -320; bottomdeath = 384; leftdeath = -128; rightdeath = 576; minhorizscroll = -64; maxhorizscroll = 256; minvertscroll = -192; maxvertscroll = 64; spawnx.push_back(160); spawnx.push_back(288); spawnx.push_back(96); spawnx.push_back(352); spawny.push_back(88); spawny.push_back(88); spawny.push_back(88); spawny.push_back(88); floors.push_back(Floor(40, 216, 161, 0, false)); floors.push_back(Floor(202, 216, 98, 25, false)); floors[0].rightneighbor = 1; floors[1].leftneighbor = 0; floors[1].rightneighbor = 2; floors.push_back(Floor(300, 191, 150, 0, false)); floors[2].leftneighbor = 1; floors.push_back(Floor(84, 160, 110, 0, true)); floors.push_back(Floor(302, 142, 104, 0, true)); ledges.push_back(Ledge(40, 216, "left")); ledges.push_back(Ledge(450, 191, "right")); walls.push_back(Wall(41, 216, 40, "left")); walls.push_back(Wall(449, 191, 40, "right")); ceilings.push_back(Ceiling(40, 256, 100)); ceilings.push_back(Ceiling(349, 231, 100)); walls.push_back(Wall(55, 256, 200, "left")); walls.push_back(Wall(435, 231, 200, "right")); songnames.push_back("Ike's Theme"); songnames.push_back("Victory is Near"); songartists.push_back("Fire Emblem 10: Radiant Dawn"); songartists.push_back("Fire Emblem 9: Path of Radiance"); songs.push_back("SSBDS_Files/music/stages/castlesiege1.mp3"); songs.push_back("SSBDS_Files/music/stages/castlesiege2.mp3"); } // initializes Castle Siege
void PokemonStadium::Initialize() { name = "pokemonstadium"; width = 512; height = 256; topdeath = -320; bottomdeath = 256; leftdeath = -192; rightdeath = 704; minhorizscroll = -128; maxhorizscroll = 384; minvertscroll = -192; maxvertscroll = 64; spawnx.push_back(160); spawnx.push_back(288); spawnx.push_back(96); spawnx.push_back(352); spawny.push_back(26); spawny.push_back(26); spawny.push_back(26); spawny.push_back(26); floors.push_back(Floor(42, 154, 428, 0, false)); floors.push_back(Floor(128, 110, 62, 0, true)); floors.push_back(Floor(324, 110, 62, 0, true)); walls.push_back(Wall(43, 154, 102, "left")); walls.push_back(Wall(469, 154, 102, "right")); ceilings.push_back(Ceiling(42, 216, 428)); ledges.push_back(Ledge(42, 154, "left")); ledges.push_back(Ledge(470, 154, "right")); songnames.push_back("Pokemon Gym / Evolution"); songnames.push_back("Battle Theme"); songnames.push_back("Lugia's Song"); songartists.push_back("Pokemon Red/Blue/Yellow"); songartists.push_back("Pokemon Gold/Silver/Crystal"); songartists.push_back("Pokemon 2000"); songs.push_back("SSBDS_Files/music/stages/pokemonstadium1.mp3"); songs.push_back("SSBDS_Files/music/stages/pokemonstadium2.mp3"); songs.push_back("SSBDS_Files/music/stages/pokemonstadium3.mp3"); } // initializes the pokemon stadium stage
void UIWidgetImage::InitializeFromDefinition( const SimpleString& DefinitionName ) { UIWidget::InitializeFromDefinition( DefinitionName ); MAKEHASH( DefinitionName ); MAKEHASH( m_Archetype ); STATICHASH( DisplayWidth ); const float DisplayWidth = ConfigManager::GetFloat( sDisplayWidth ); const float ParentWidth = m_OriginParent ? m_OriginParent->GetWidth() : DisplayWidth; const float ParentX = m_OriginParent ? Ceiling( m_OriginParent->GetX() ) : 0.0f; STATICHASH( DisplayHeight ); const float DisplayHeight = ConfigManager::GetFloat( sDisplayHeight ); const float ParentHeight = m_OriginParent ? m_OriginParent->GetHeight() : DisplayHeight; const float ParentY = m_OriginParent ? Ceiling( m_OriginParent->GetY() ) : 0.0f; STATICHASH( PixelX ); STATICHASH( ScreenX ); float X = Pick( ConfigManager::GetArchetypeFloat( sPixelX, sm_Archetype, 0.0f, sDefinitionName ), ParentWidth * ConfigManager::GetArchetypeFloat( sScreenX, sm_Archetype, 0.0f, sDefinitionName ) ); STATICHASH( PixelY ); STATICHASH( ScreenY ); float Y = Pick( ConfigManager::GetArchetypeFloat( sPixelY, sm_Archetype, 0.0f, sDefinitionName ), ParentHeight * ConfigManager::GetArchetypeFloat( sScreenY, sm_Archetype, 0.0f, sDefinitionName ) ); STATICHASH( PixelWidth ); STATICHASH( ScreenWidth ); float Width = Pick( ConfigManager::GetArchetypeFloat( sPixelWidth, sm_Archetype, 0.0f, sDefinitionName ), ParentWidth * ConfigManager::GetArchetypeFloat( sScreenWidth, sm_Archetype, 0.0f, sDefinitionName ) ); STATICHASH( PixelHeight ); STATICHASH( ScreenHeight ); float Height = Pick( ConfigManager::GetArchetypeFloat( sPixelHeight, sm_Archetype, 0.0f, sDefinitionName ), ParentHeight * ConfigManager::GetArchetypeFloat( sScreenHeight, sm_Archetype, 0.0f, sDefinitionName ) ); // Adjust for desired aspect ratio if one dimension is not given // (This is used to size images using ScreenWidth or ScreenHeight // properly regardless of screen aspect ratio. STATICHASH( AspectRatio ); const float AspectRatio = ConfigManager::GetArchetypeFloat( sAspectRatio, sm_Archetype, 1.0f, sDefinitionName ); if( Width == 0.0f ) { Width = Height * AspectRatio; } else if( Height == 0.0f ) { Height = Width / AspectRatio; } // Offset relative to resolved image dimensions if specified STATICHASH( ImageX ); X = Pick( X, ConfigManager::GetArchetypeFloat( sImageX, sm_Archetype, 0.0f, sDefinitionName ) * Width ); STATICHASH( ImageY ); Y = Pick( Y, ConfigManager::GetArchetypeFloat( sImageY, sm_Archetype, 0.0f, sDefinitionName ) * Height ); AdjustDimensionsToParent( X, Y, Width, Height, ParentX, ParentY, ParentWidth, ParentHeight ); GetPositionFromOrigin( X, Y, Width, Height ); STATICHASH( ClampToPixelGrid ); if( ConfigManager::GetArchetypeBool( sClampToPixelGrid, sm_Archetype, true, sDefinitionName ) ) { m_TopLeft.x = Round( m_TopLeft.x ); m_TopLeft.y = Round( m_TopLeft.y ); } // Offset to properly align on pixel grid. const float PixelGridOffset = GetPixelGridOffset(); m_TopLeft.x -= PixelGridOffset; m_TopLeft.y -= PixelGridOffset; // If LoadImage is false, we're expecting to dynamically set the texture in code somewhere STATICHASH( LoadImage ); if( ConfigManager::GetArchetypeBool( sLoadImage, sm_Archetype, true, sDefinitionName ) ) { STATICHASH( Image ); SetTexture( ConfigManager::GetArchetypeString( sImage, sm_Archetype, DEFAULT_TEXTURE, sDefinitionName ) ); } m_Dimensions = Vector2( Width, Height ); STATICHASH( Calibration ); m_Calibration = ConfigManager::GetArchetypeBool( sCalibration, sm_Archetype, false, sDefinitionName ); STATICHASH( MaterialOverride ); const SimpleString DefaultMaterial( "Material_HUD" ); m_Material = ConfigManager::GetArchetypeString( sMaterialOverride, sm_Archetype, DefaultMaterial.CStr(), sDefinitionName ); UpdateRender(); }
void UIWidgetFrame::InitializeFromDefinition( const SimpleString& DefinitionName ) { UIWidget::InitializeFromDefinition( DefinitionName ); MAKEHASH( DefinitionName ); MAKEHASH( m_Archetype ); STATICHASH( DisplayWidth ); const float DisplayWidth = ConfigManager::GetFloat( sDisplayWidth ); const float ParentWidth = m_OriginParent ? m_OriginParent->GetWidth() : DisplayWidth; const float ParentX = m_OriginParent ? Ceiling( m_OriginParent->GetX() ) : 0.0f; STATICHASH( DisplayHeight ); const float DisplayHeight = ConfigManager::GetFloat( sDisplayHeight ); const float ParentHeight = m_OriginParent ? m_OriginParent->GetHeight() : DisplayHeight; const float ParentY = m_OriginParent ? Ceiling( m_OriginParent->GetY() ) : 0.0f; // "Screen" values are now relative to parent, which may or may not be screen dimensions. STATICHASH( PixelX ); STATICHASH( ScreenX ); float X = Pick( ConfigManager::GetArchetypeFloat( sPixelX, sm_Archetype, 0.0f, sDefinitionName ), ParentWidth * ConfigManager::GetArchetypeFloat( sScreenX, sm_Archetype, 0.0f, sDefinitionName ) ); STATICHASH( PixelY ); STATICHASH( ScreenY ); float Y = Pick( ConfigManager::GetArchetypeFloat( sPixelY, sm_Archetype, 0.0f, sDefinitionName ), ParentHeight * ConfigManager::GetArchetypeFloat( sScreenY, sm_Archetype, 0.0f, sDefinitionName ) ); STATICHASH( PixelWidth ); STATICHASH( ScreenWidth ); float Width = Pick( ConfigManager::GetArchetypeFloat( sPixelWidth, sm_Archetype, 0.0f, sDefinitionName ), ParentWidth * ConfigManager::GetArchetypeFloat( sScreenWidth, sm_Archetype, 0.0f, sDefinitionName ) ); STATICHASH( PixelHeight ); STATICHASH( ScreenHeight ); float Height = Pick( ConfigManager::GetArchetypeFloat( sPixelHeight, sm_Archetype, 0.0f, sDefinitionName ), ParentHeight * ConfigManager::GetArchetypeFloat( sScreenHeight, sm_Archetype, 0.0f, sDefinitionName ) ); STATICHASH( PixelBorder ); m_Border = ConfigManager::GetArchetypeFloat( sPixelBorder, sm_Archetype, 0.0f, sDefinitionName ); // Adjust for desired aspect ratio if one dimension is not given // (This is used to size images using ScreenWidth or ScreenHeight // properly regardless of screen aspect ratio. STATICHASH( AspectRatio ); const float AspectRatio = ConfigManager::GetArchetypeFloat( sAspectRatio, sm_Archetype, 1.0f, sDefinitionName ); if( Width == 0.0f ) { Width = Height * AspectRatio; } else if( Height == 0.0f ) { Height = Width / AspectRatio; } AdjustDimensionsToParent( X, Y, Width, Height, ParentX, ParentY, ParentWidth, ParentHeight ); GetPositionFromOrigin( X, Y, Width, Height ); ASSERT( Width > m_Border * 2.0f ); ASSERT( Height > m_Border * 2.0f ); STATICHASH( ClampToPixelGrid ); if( ConfigManager::GetArchetypeBool( sClampToPixelGrid, sm_Archetype, true, sDefinitionName ) ) { m_TopLeft.x = Round( m_TopLeft.x ); m_TopLeft.y = Round( m_TopLeft.y ); } // Offset to properly align on pixel grid. const float PixelGridOffset = GetPixelGridOffset(); m_TopLeft.x -= PixelGridOffset; m_TopLeft.y -= PixelGridOffset; STATICHASH( Image ); const char* const Filename = ConfigManager::GetArchetypeString( sImage, sm_Archetype, DEFAULT_TEXTURE, sDefinitionName ); m_Texture = m_UIManager->GetRenderer()->GetTextureManager()->GetTexture( Filename, TextureManager::ETL_Permanent ); m_Dimensions = Vector2( Width, Height ); STATICHASH( MaterialOverride ); const SimpleString DefaultMaterial( "Material_HUD" ); m_Material = ConfigManager::GetArchetypeString( sMaterialOverride, sm_Archetype, DefaultMaterial.CStr(), sDefinitionName ); UpdateRender(); }