@@ -49,18 +49,27 @@ void Window::Draw() {
4949 int count = static_cast <int >(notifications.size ());
5050 int inverseIndex = -(count - 1 - index);
5151
52+ if (index != 0 ) {
53+ auto it = notificationHeights.find (notification.id );
54+ if (it != notificationHeights.end ()) {
55+ basePosition.y -= it->second + padding;
56+ } else {
57+ basePosition.y -= (notification.isAchievement ? 100 .0f : 60 .0f ) + padding;
58+ }
59+ }
60+
5261 if (notification.isAchievement ) {
5362 // Enhanced layout for achievements
5463 DrawEnhancedNotification (notification, basePosition, position, padding, index);
5564 } else {
5665 // Original simple layout for regular notifications
57- DrawRegularNotification (notification, basePosition, inverseIndex, position, padding, vp);
66+ DrawRegularNotification (notification, basePosition, inverseIndex, position, padding, vp, index );
5867 }
5968 }
6069}
6170
6271void Window::DrawRegularNotification (const Options& notification, ImVec2 basePosition, int inverseIndex, int position,
63- float padding, ImGuiViewport* vp) {
72+ float padding, ImGuiViewport* vp, int index ) {
6473 ImGui::PushStyleColor (ImGuiCol_WindowBg, ImVec4 (0 , 0 , 0 , CVarGetFloat (" gNotifications.BgOpacity" , 0 .5f )));
6574 ImGui::PushStyleColor (ImGuiCol_Border, ImVec4 (0 , 0 , 0 , 0 ));
6675 ImGui::PushStyleVar (ImGuiStyleVar_WindowRounding, 4 .0f );
@@ -85,21 +94,20 @@ void Window::DrawRegularNotification(const Options& notification, ImVec2 basePos
8594
8695 ImVec2 currentWinSize = ImGui::GetWindowSize ();
8796 ImVec2 notificationPos;
97+
8898 switch (position) {
8999 case 0 : // Top Left
90- notificationPos = ImVec2 (basePosition.x , basePosition.y + ((currentWinSize. y + padding) * inverseIndex) );
100+ notificationPos = ImVec2 (basePosition.x , basePosition.y );
91101 break ;
92102 case 1 : // Top Right
93- notificationPos = ImVec2 (basePosition.x - currentWinSize.x ,
94- basePosition.y + ((currentWinSize.y + padding) * inverseIndex));
103+ notificationPos = ImVec2 (basePosition.x - currentWinSize.x , basePosition.y );
95104 break ;
96105 case 2 : // Bottom Left
97- notificationPos =
98- ImVec2 (basePosition.x , basePosition.y - ((currentWinSize.y + padding) * (inverseIndex + 1 )));
106+ notificationPos = ImVec2 (basePosition.x , basePosition.y - currentWinSize.y );
99107 break ;
100108 case 3 : // Bottom Right
101- notificationPos = ImVec2 (basePosition. x - currentWinSize. x ,
102- basePosition.y - (( currentWinSize.y + padding) * (inverseIndex + 1 )) );
109+ notificationPos =
110+ ImVec2 (basePosition. x - currentWinSize. x , basePosition.y - currentWinSize.y );
103111 break ;
104112 }
105113
@@ -122,6 +130,9 @@ void Window::DrawRegularNotification(const Options& notification, ImVec2 basePos
122130 ImGui::TextColored (notification.suffixColor , " %s" , notification.suffix .c_str ());
123131 }
124132
133+ // Store actual height in cache for future positioning calculations
134+ notificationHeights[notification.id ] = currentWinSize.y ;
135+
125136 ImGui::End ();
126137 ImGui::PopStyleVar (4 );
127138 ImGui::PopStyleColor (2 );
@@ -225,65 +236,30 @@ void Window::DrawEnhancedNotification(const Options& notification, ImVec2 basePo
225236 }
226237
227238 // Get actual window size after content layout
228- ImVec2 actualWinSize = ImGui::GetWindowSize ();
229-
230- // Calculate position using accumulated heights from cache
231- float accumulatedHeight = 0 .0f ;
232- if (position == 0 || position == 1 ) {
233- // Top positions: accumulate heights of notifications before this one
234- for (int i = 0 ; i < index; ++i) {
235- if (notifications[i].isAchievement ) {
236- auto it = notificationHeights.find (notifications[i].id );
237- if (it != notificationHeights.end ()) {
238- accumulatedHeight += it->second + padding;
239- } else {
240- // Fallback estimate if height not yet cached
241- accumulatedHeight += 100 .0f + padding;
242- }
243- } else {
244- // Regular notifications use smaller estimate
245- accumulatedHeight += 50 .0f + padding;
246- }
247- }
248- } else {
249- // Bottom positions: accumulate heights of notifications after this one
250- for (int i = index + 1 ; i < static_cast <int >(notifications.size ()); ++i) {
251- if (notifications[i].isAchievement ) {
252- auto it = notificationHeights.find (notifications[i].id );
253- if (it != notificationHeights.end ()) {
254- accumulatedHeight += it->second + padding;
255- } else {
256- // Fallback estimate if height not yet cached
257- accumulatedHeight += 100 .0f + padding;
258- }
259- } else {
260- // Regular notifications use smaller estimate
261- accumulatedHeight += 50 .0f + padding;
262- }
263- }
264- }
239+ ImVec2 currentWinSize = ImGui::GetWindowSize ();
265240
266241 ImVec2 notificationPos;
242+
267243 switch (position) {
268244 case 0 : // Top Left
269- notificationPos = ImVec2 (basePosition.x , basePosition.y + accumulatedHeight );
245+ notificationPos = ImVec2 (basePosition.x , basePosition.y );
270246 break ;
271247 case 1 : // Top Right
272- notificationPos = ImVec2 (basePosition.x - enhancedWidth , basePosition.y + accumulatedHeight );
248+ notificationPos = ImVec2 (basePosition.x - currentWinSize. x , basePosition.y );
273249 break ;
274250 case 2 : // Bottom Left
275- notificationPos = ImVec2 (basePosition.x , basePosition.y - actualWinSize. y - accumulatedHeight );
251+ notificationPos = ImVec2 (basePosition.x , basePosition.y - currentWinSize. y );
276252 break ;
277253 case 3 : // Bottom Right
278254 notificationPos =
279- ImVec2 (basePosition.x - enhancedWidth , basePosition.y - actualWinSize. y - accumulatedHeight );
255+ ImVec2 (basePosition.x - currentWinSize. x , basePosition.y - currentWinSize. y );
280256 break ;
281257 }
282258
283259 ImGui::SetWindowPos (notificationPos);
284260
285261 // Store actual height in cache for future positioning calculations
286- notificationHeights[notification.id ] = actualWinSize .y ;
262+ notificationHeights[notification.id ] = currentWinSize .y ;
287263
288264 ImGui::End ();
289265
0 commit comments