Add resolution-based UI scaling; apply skin/music kit instantly on select
This commit is contained in:
@@ -46,8 +46,25 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto CAndromedaMenu::GetUIScale() -> float
|
||||||
|
{
|
||||||
|
float Scale = ImGui::GetIO().DisplaySize.y / 1080.f;
|
||||||
|
|
||||||
|
if ( Scale < 0.75f )
|
||||||
|
Scale = 0.75f;
|
||||||
|
|
||||||
|
if ( Scale > 2.0f )
|
||||||
|
Scale = 2.0f;
|
||||||
|
|
||||||
|
return Scale;
|
||||||
|
}
|
||||||
|
|
||||||
auto CAndromedaMenu::OnRenderMenu() -> void
|
auto CAndromedaMenu::OnRenderMenu() -> void
|
||||||
{
|
{
|
||||||
|
m_fUIScale = GetUIScale();
|
||||||
|
|
||||||
|
ImGui::GetIO().FontGlobalScale = m_fUIScale;
|
||||||
|
|
||||||
const float MenuAlpha = static_cast<float>( Settings::Menu::MenuAlpha ) / 255.f;
|
const float MenuAlpha = static_cast<float>( Settings::Menu::MenuAlpha ) / 255.f;
|
||||||
|
|
||||||
ImGui::PushStyleVar( ImGuiStyleVar_Alpha , MenuAlpha );
|
ImGui::PushStyleVar( ImGuiStyleVar_Alpha , MenuAlpha );
|
||||||
@@ -77,7 +94,7 @@ auto CAndromedaMenu::OnRenderMenu() -> void
|
|||||||
ImGui::PushStyleVar( ImGuiStyleVar_FrameRounding , 4.f );
|
ImGui::PushStyleVar( ImGuiStyleVar_FrameRounding , 4.f );
|
||||||
ImGui::PushStyleVar( ImGuiStyleVar_ItemSpacing , ImVec2( 8.f , 6.f ) );
|
ImGui::PushStyleVar( ImGuiStyleVar_ItemSpacing , ImVec2( 8.f , 6.f ) );
|
||||||
|
|
||||||
ImGui::SetNextWindowSize( ImVec2( 960 , 620 ) , ImGuiCond_FirstUseEver );
|
ImGui::SetNextWindowSize( ImVec2( 960.f * m_fUIScale , 620.f * m_fUIScale ) , ImGuiCond_FirstUseEver );
|
||||||
|
|
||||||
if ( ImGui::Begin( XorStr( "Evicted" ) , nullptr , ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar ) )
|
if ( ImGui::Begin( XorStr( "Evicted" ) , nullptr , ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar ) )
|
||||||
{
|
{
|
||||||
@@ -133,25 +150,27 @@ auto CAndromedaMenu::OnRenderMenu() -> void
|
|||||||
|
|
||||||
auto CAndromedaMenu::RenderSidebar() -> void
|
auto CAndromedaMenu::RenderSidebar() -> void
|
||||||
{
|
{
|
||||||
|
const float S = m_fUIScale;
|
||||||
|
|
||||||
const ImVec2 Avail = ImGui::GetContentRegionAvail();
|
const ImVec2 Avail = ImGui::GetContentRegionAvail();
|
||||||
|
|
||||||
ImDrawList* pDraw = ImGui::GetWindowDrawList();
|
ImDrawList* pDraw = ImGui::GetWindowDrawList();
|
||||||
|
|
||||||
const ImVec2 WinMin = ImGui::GetWindowPos();
|
const ImVec2 WinMin = ImGui::GetWindowPos();
|
||||||
const ImVec2 SidebarMax = WinMin + ImVec2( 210.f , Avail.y + 16.f );
|
const ImVec2 SidebarMax = WinMin + ImVec2( 210.f * S , Avail.y + 16.f );
|
||||||
|
|
||||||
pDraw->AddRectFilled( WinMin , SidebarMax , IM_COL32( 25 , 26 , 32 , 255 ) , 8.f );
|
pDraw->AddRectFilled( WinMin , SidebarMax , IM_COL32( 25 , 26 , 32 , 255 ) , 8.f );
|
||||||
|
|
||||||
if ( ImGui::BeginChild( "##Sidebar" , ImVec2( 210.f , Avail.y ) , false ) )
|
if ( ImGui::BeginChild( "##Sidebar" , ImVec2( 210.f * S , Avail.y ) , false ) )
|
||||||
{
|
{
|
||||||
const float HeaderHeight = 92.f;
|
const float HeaderHeight = 92.f * S;
|
||||||
const ImVec2 HeaderMin = ImGui::GetCursorScreenPos();
|
const ImVec2 HeaderMin = ImGui::GetCursorScreenPos();
|
||||||
const ImVec2 HeaderMax = HeaderMin + ImVec2( 210.f , HeaderHeight );
|
const ImVec2 HeaderMax = HeaderMin + ImVec2( 210.f * S , HeaderHeight );
|
||||||
|
|
||||||
pDraw->AddRectFilled( HeaderMin , HeaderMax , AccentU32( m_Accent ) , 8.f );
|
pDraw->AddRectFilled( HeaderMin , HeaderMax , AccentU32( m_Accent ) , 8.f );
|
||||||
|
|
||||||
pDraw->AddRectFilled( ImVec2( HeaderMax.x - 60.f , HeaderMin.y ) , HeaderMax , IM_COL32( 0 , 0 , 0 , 18 ) , 8.f );
|
pDraw->AddRectFilled( ImVec2( HeaderMax.x - 60.f * S , HeaderMin.y ) , HeaderMax , IM_COL32( 0 , 0 , 0 , 18 ) , 8.f );
|
||||||
pDraw->AddRectFilled( ImVec2( HeaderMin.x , HeaderMax.y - 22.f ) , HeaderMax , IM_COL32( 0 , 0 , 0 , 40 ) );
|
pDraw->AddRectFilled( ImVec2( HeaderMin.x , HeaderMax.y - 22.f * S ) , HeaderMax , IM_COL32( 0 , 0 , 0 , 40 ) );
|
||||||
|
|
||||||
ImFont* pIcon = GetAndromedaGUI()->GetIconFont();
|
ImFont* pIcon = GetAndromedaGUI()->GetIconFont();
|
||||||
ImFont* pBold = GetAndromedaGUI()->GetBoldSegoeFont();
|
ImFont* pBold = GetAndromedaGUI()->GetBoldSegoeFont();
|
||||||
@@ -160,40 +179,42 @@ auto CAndromedaMenu::RenderSidebar() -> void
|
|||||||
const char* szLogoText = "EVI CTED";
|
const char* szLogoText = "EVI CTED";
|
||||||
const char* szSubText = "ANDROMEDA";
|
const char* szSubText = "ANDROMEDA";
|
||||||
|
|
||||||
const float IconW = pIcon->CalcTextSizeA( 34.f , FLT_MAX , 0.f , szLogoIcon ).x;
|
const float IconW = pIcon->CalcTextSizeA( 34.f * S , FLT_MAX , 0.f , szLogoIcon ).x;
|
||||||
|
|
||||||
ImGui::SetCursorScreenPos( ImVec2( HeaderMin.x + 18.f , HeaderMin.y + 20.f ) );
|
ImGui::SetCursorScreenPos( ImVec2( HeaderMin.x + 18.f * S , HeaderMin.y + 20.f * S ) );
|
||||||
|
|
||||||
ImGui::PushFont( pIcon );
|
ImGui::PushFont( pIcon );
|
||||||
ImGui::TextColored( ImVec4( 1.f , 1.f , 1.f , 0.95f ) , "%s" , szLogoIcon );
|
ImGui::TextColored( ImVec4( 1.f , 1.f , 1.f , 0.95f ) , "%s" , szLogoIcon );
|
||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
|
|
||||||
ImGui::SameLine( 0.f , 10.f );
|
ImGui::SameLine( 0.f , 10.f * S );
|
||||||
|
|
||||||
ImGui::PushFont( pBold );
|
ImGui::PushFont( pBold );
|
||||||
ImGui::TextColored( ImVec4( 1.f , 1.f , 1.f , 1.f ) , "%s" , szLogoText );
|
ImGui::TextColored( ImVec4( 1.f , 1.f , 1.f , 1.f ) , "%s" , szLogoText );
|
||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
|
|
||||||
ImGui::SameLine( 0.f , 8.f );
|
ImGui::SameLine( 0.f , 8.f * S );
|
||||||
|
|
||||||
ImFont* pSeg = GetAndromedaGUI()->GetSegoeFont();
|
ImFont* pSeg = GetAndromedaGUI()->GetSegoeFont();
|
||||||
ImGui::PushFont( pSeg );
|
ImGui::PushFont( pSeg );
|
||||||
ImGui::TextColored( ImVec4( 1.f , 1.f , 1.f , 0.85f ) , "%s" , szSubText );
|
ImGui::TextColored( ImVec4( 1.f , 1.f , 1.f , 0.85f ) , "%s" , szSubText );
|
||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
|
|
||||||
ImGui::SetCursorScreenPos( ImVec2( HeaderMin.x + 18.f , HeaderMin.y + 52.f ) );
|
ImGui::SetCursorScreenPos( ImVec2( HeaderMin.x + 18.f * S , HeaderMin.y + 52.f * S ) );
|
||||||
|
|
||||||
ImGui::Dummy( ImVec2( 0.f , 34.f ) );
|
ImGui::Dummy( ImVec2( 0.f , 34.f * S ) );
|
||||||
|
|
||||||
ImGui::SetCursorPosX( 4.f );
|
ImGui::SetCursorPosX( 4.f * S );
|
||||||
|
|
||||||
TabButton( "I" , "Visuals" , TAB_VISUALS , ImVec2( 202.f , 40.f ) );
|
const ImVec2 TabSize( 202.f * S , 40.f * S );
|
||||||
TabButton( "P" , "Glow & Chams" , TAB_GLOW , ImVec2( 202.f , 40.f ) );
|
|
||||||
TabButton( "T" , "Skins" , TAB_SKINS , ImVec2( 202.f , 40.f ) );
|
|
||||||
TabButton( "N" , "Music Kit" , TAB_MUSIC , ImVec2( 202.f , 40.f ) );
|
|
||||||
TabButton( "S" , "Config" , TAB_CONFIG , ImVec2( 202.f , 40.f ) );
|
|
||||||
|
|
||||||
ImGui::SetCursorPosY( ImGui::GetCursorPosY() + 6.f );
|
TabButton( "I" , "Visuals" , TAB_VISUALS , TabSize );
|
||||||
|
TabButton( "P" , "Glow & Chams" , TAB_GLOW , TabSize );
|
||||||
|
TabButton( "T" , "Skins" , TAB_SKINS , TabSize );
|
||||||
|
TabButton( "N" , "Music Kit" , TAB_MUSIC , TabSize );
|
||||||
|
TabButton( "S" , "Config" , TAB_CONFIG , TabSize );
|
||||||
|
|
||||||
|
ImGui::SetCursorPosY( ImGui::GetCursorPosY() + 6.f * S );
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
@@ -237,13 +258,15 @@ auto CAndromedaMenu::TabButton( const char* szIcon , const char* szLabel , const
|
|||||||
ImFont* pIcon = GetAndromedaGUI()->GetIconFont();
|
ImFont* pIcon = GetAndromedaGUI()->GetIconFont();
|
||||||
ImFont* pText = GetAndromedaGUI()->GetDefaultFont();
|
ImFont* pText = GetAndromedaGUI()->GetDefaultFont();
|
||||||
|
|
||||||
const ImVec2 Icon( Pos.x + 14.f , Pos.y + ( Size.y - 26.f ) * 0.5f );
|
const float S = m_fUIScale;
|
||||||
|
|
||||||
pDraw->AddText( pIcon , 26.f , Icon , IM_COL32( 255 , 255 , 255 , (int)( TextColorOn * 255.f ) ) , szIcon );
|
const ImVec2 Icon( Pos.x + 14.f * S , Pos.y + ( Size.y - 26.f * S ) * 0.5f );
|
||||||
|
|
||||||
const float IconW = pIcon->CalcTextSizeA( 26.f , FLT_MAX , 0.f , szIcon ).x;
|
pDraw->AddText( pIcon , 26.f * S , Icon , IM_COL32( 255 , 255 , 255 , (int)( TextColorOn * 255.f ) ) , szIcon );
|
||||||
|
|
||||||
pDraw->AddText( pText , pText->FontSize , ImVec2( Icon.x + IconW + 12.f , Pos.y + ( Size.y - pText->FontSize ) * 0.5f ) , IM_COL32( 255 , 255 , 255 , (int)( TextColorOn * 255.f ) ) , szLabel );
|
const float IconW = pIcon->CalcTextSizeA( 26.f * S , FLT_MAX , 0.f , szIcon ).x;
|
||||||
|
|
||||||
|
pDraw->AddText( pText , pText->FontSize * S , ImVec2( Icon.x + IconW + 12.f * S , Pos.y + ( Size.y - pText->FontSize * S ) * 0.5f ) , IM_COL32( 255 , 255 , 255 , (int)( TextColorOn * 255.f ) ) , szLabel );
|
||||||
}
|
}
|
||||||
|
|
||||||
auto CAndromedaMenu::RenderVisualPanel() -> void
|
auto CAndromedaMenu::RenderVisualPanel() -> void
|
||||||
@@ -353,7 +376,7 @@ auto CAndromedaMenu::RenderSkinPanel() -> void
|
|||||||
if ( pManager->GetDumpedItems().empty() )
|
if ( pManager->GetDumpedItems().empty() )
|
||||||
pManager->ScanAllItems();
|
pManager->ScanAllItems();
|
||||||
|
|
||||||
ImGui::TextColored( ImVec4( 1.f , 1.f , 1.f , 0.4f ) , "%s" , "Select a weapon on the left, then a skin and press Apply." );
|
ImGui::TextColored( ImVec4( 1.f , 1.f , 1.f , 0.4f ) , "%s" , "Select a weapon on the left, then click a skin to apply it instantly." );
|
||||||
|
|
||||||
ImGui::NewLine();
|
ImGui::NewLine();
|
||||||
|
|
||||||
@@ -420,29 +443,19 @@ auto CAndromedaMenu::RenderSkinPanel() -> void
|
|||||||
ImGui::PushStyleColor( ImGuiCol_Header , Rarity );
|
ImGui::PushStyleColor( ImGuiCol_Header , Rarity );
|
||||||
|
|
||||||
if ( ImGui::Selectable( szLabel , bSel ) )
|
if ( ImGui::Selectable( szLabel , bSel ) )
|
||||||
|
{
|
||||||
m_iSelectedSkinIdx = static_cast<int>( j );
|
m_iSelectedSkinIdx = static_cast<int>( j );
|
||||||
|
|
||||||
|
pManager->SetWeaponSkin( Item.m_DefIdx , Skin.m_ID , true );
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::NewLine();
|
ImGui::NewLine();
|
||||||
|
|
||||||
const auto& ItemRef = Items[ m_iSelectedItemIdx ];
|
if ( ImGui::Button( "Remove" , ImVec2( 120.f * m_fUIScale , 28.f * m_fUIScale ) ) )
|
||||||
|
pManager->RemoveWeaponSkin( Item.m_DefIdx );
|
||||||
if ( ImGui::Button( "Apply Skin" , ImVec2( 120.f , 28.f ) ) )
|
|
||||||
{
|
|
||||||
if ( ItemRef.m_DumpedSkins.size() && m_iSelectedSkinIdx >= 0 )
|
|
||||||
{
|
|
||||||
const auto& Skin = ItemRef.m_DumpedSkins[ m_iSelectedSkinIdx ];
|
|
||||||
|
|
||||||
pManager->SetWeaponSkin( ItemRef.m_DefIdx , Skin.m_ID , true );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::SameLine();
|
|
||||||
|
|
||||||
if ( ImGui::Button( "Remove" , ImVec2( 120.f , 28.f ) ) )
|
|
||||||
pManager->RemoveWeaponSkin( ItemRef.m_DefIdx );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -461,7 +474,7 @@ auto CAndromedaMenu::RenderMusicPanel() -> void
|
|||||||
if ( pManager->GetDumpedItems().empty() )
|
if ( pManager->GetDumpedItems().empty() )
|
||||||
pManager->ScanAllItems();
|
pManager->ScanAllItems();
|
||||||
|
|
||||||
ImGui::TextColored( ImVec4( 1.f , 1.f , 1.f , 0.4f ) , "%s" , "Select a music kit and press Apply. Selecting a new kit replaces the previous one." );
|
ImGui::TextColored( ImVec4( 1.f , 1.f , 1.f , 0.4f ) , "%s" , "Click a music kit to apply it instantly. Selecting a new kit replaces the previous one." );
|
||||||
|
|
||||||
ImGui::NewLine();
|
ImGui::NewLine();
|
||||||
|
|
||||||
@@ -479,21 +492,17 @@ auto CAndromedaMenu::RenderMusicPanel() -> void
|
|||||||
const bool bSel = ( Skin.m_ID == pManager->GetMusicSelection() );
|
const bool bSel = ( Skin.m_ID == pManager->GetMusicSelection() );
|
||||||
|
|
||||||
if ( ImGui::Selectable( Skin.m_DisplayName.c_str() , bSel ) )
|
if ( ImGui::Selectable( Skin.m_DisplayName.c_str() , bSel ) )
|
||||||
|
{
|
||||||
m_iSelectedMusicIdx = Skin.m_ID;
|
m_iSelectedMusicIdx = Skin.m_ID;
|
||||||
|
|
||||||
|
pManager->SetMusicKit( Skin.m_ID , true );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::NewLine();
|
ImGui::NewLine();
|
||||||
|
|
||||||
if ( ImGui::Button( "Apply Music Kit" , ImVec2( 150.f , 28.f ) ) )
|
if ( ImGui::Button( "Reset" , ImVec2( 100.f * m_fUIScale , 28.f * m_fUIScale ) ) )
|
||||||
{
|
|
||||||
if ( m_iSelectedMusicIdx >= 0 )
|
|
||||||
pManager->SetMusicKit( m_iSelectedMusicIdx , true );
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::SameLine();
|
|
||||||
|
|
||||||
if ( ImGui::Button( "Reset" , ImVec2( 100.f , 28.f ) ) )
|
|
||||||
pManager->RemoveMusicKit();
|
pManager->RemoveMusicKit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -520,7 +529,7 @@ auto CAndromedaMenu::RenderConfigPanel() -> void
|
|||||||
|
|
||||||
ImGui::TextColored( ImVec4( 1.f , 1.f , 1.f , 0.4f ) , "%s" , "The skin changer now applies only the skins you configure per weapon." );
|
ImGui::TextColored( ImVec4( 1.f , 1.f , 1.f , 0.4f ) , "%s" , "The skin changer now applies only the skins you configure per weapon." );
|
||||||
|
|
||||||
if ( ImGui::Button( "Clear All Skins" , ImVec2( 150.f , 28.f ) ) )
|
if ( ImGui::Button( "Clear All Skins" , ImVec2( 150.f * m_fUIScale , 28.f * m_fUIScale ) ) )
|
||||||
GetInventoryItemsManager()->ClearAllSelections();
|
GetInventoryItemsManager()->ClearAllSelections();
|
||||||
|
|
||||||
EndPanel();
|
EndPanel();
|
||||||
@@ -540,8 +549,10 @@ auto CAndromedaMenu::BeginPanel( const char* szTitle ) -> void
|
|||||||
|
|
||||||
const float RightEdge = ImGui::GetWindowPos().x + ImGui::GetWindowContentRegionMax().x;
|
const float RightEdge = ImGui::GetWindowPos().x + ImGui::GetWindowContentRegionMax().x;
|
||||||
|
|
||||||
pDraw->AddRectFilled( Pos , ImVec2( Pos.x + 28.f , Pos.y + 2.f ) , AccentU32( m_Accent ) );
|
const float AccentW = 28.f * m_fUIScale;
|
||||||
pDraw->AddRectFilled( ImVec2( Pos.x + 28.f , Pos.y + 2.f ) , ImVec2( RightEdge , Pos.y + 2.f ) , IM_COL32( 255 , 255 , 255 , 18 ) );
|
|
||||||
|
pDraw->AddRectFilled( Pos , ImVec2( Pos.x + AccentW , Pos.y + 2.f ) , AccentU32( m_Accent ) );
|
||||||
|
pDraw->AddRectFilled( ImVec2( Pos.x + AccentW , Pos.y + 2.f ) , ImVec2( RightEdge , Pos.y + 2.f ) , IM_COL32( 255 , 255 , 255 , 18 ) );
|
||||||
|
|
||||||
ImGui::SetCursorPosY( ImGui::GetCursorPosY() + 12.f );
|
ImGui::SetCursorPosY( ImGui::GetCursorPosY() + 12.f );
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ private:
|
|||||||
int m_iSelectedSkinIdx = 0;
|
int m_iSelectedSkinIdx = 0;
|
||||||
int m_iSelectedMusicIdx = -1;
|
int m_iSelectedMusicIdx = -1;
|
||||||
|
|
||||||
|
float m_fUIScale = 1.0f;
|
||||||
|
|
||||||
|
private:
|
||||||
|
auto GetUIScale() -> float;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ImVec4 m_Accent = ImVec4( 0.78f , 0.18f , 0.29f , 1.00f );
|
ImVec4 m_Accent = ImVec4( 0.78f , 0.18f , 0.29f , 1.00f );
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user