Skip to content

Commit edeb6d5

Browse files
committed
partial
1 parent 8e5c325 commit edeb6d5

4 files changed

Lines changed: 62 additions & 37 deletions

File tree

scripts/semantic_review.py

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,63 @@ def detect_collisions(buttons, elements):
1515

1616
# 1. Check if Text overflows its likely container (Button or Panel)
1717
for t in text_elements:
18+
tb = t['Bounds']
19+
# Skip empty text
20+
if tb['Width'] == 0 or tb['Height'] == 0: continue
21+
1822
found_container = False
19-
# Check buttons first
23+
potential_overflow = None
24+
25+
# Check buttons
2026
for b in buttons:
21-
if is_contained(t['Bounds'], b['Bounds']):
22-
found_container = True
23-
break
24-
# If it overlaps but isn't contained, it might be an overflow
25-
if (t['Bounds']['X'] < b['Bounds']['X'] + b['Bounds']['Width'] and
26-
t['Bounds']['X'] + t['Bounds']['Width'] > b['Bounds']['X'] and
27-
t['Bounds']['Y'] < b['Bounds']['Y'] + b['Bounds']['Height'] and
28-
t['Bounds']['Y'] + t['Bounds']['Height'] > b['Bounds']['Y']):
29-
# It overlaps! Is it too large?
30-
if t['Bounds']['Width'] > b['Bounds']['Width'] or t['Bounds']['Height'] > b['Bounds']['Height']:
31-
collisions.append(f"Text '{t['Text']}' overflows Button '{b.get('Text', 'Unknown')}'")
32-
found_container = True # We consider this its container even if it overflows
33-
break
27+
bb = b['Bounds']
28+
# If they overlap at all
29+
if (tb['X'] < bb['X'] + bb['Width'] and
30+
tb['X'] + tb['Width'] > bb['X'] and
31+
tb['Y'] < bb['Y'] + bb['Height'] and
32+
tb['Y'] + tb['Height'] > bb['Y']):
33+
34+
if is_contained(tb, bb):
35+
found_container = True
36+
break
37+
else:
38+
# Overlaps but not contained -> potential overflow
39+
potential_overflow = f"Text '{t['Text']}' overflows Button '{b.get('Text', 'Unknown')}'"
40+
found_container = True # Mark as found so we don't treat as floating
41+
break
3442

3543
if not found_container:
3644
# Check panels
45+
# We want the SMALLEST panel that contains it or overlaps it most
46+
candidate_panels = []
3747
for p in panels:
38-
if is_contained(t['Bounds'], p['Bounds']):
39-
found_container = True
40-
break
41-
if (t['Bounds']['X'] < p['Bounds']['X'] + p['Bounds']['Width'] and
42-
t['Bounds']['X'] + t['Bounds']['Width'] > p['Bounds']['X'] and
43-
t['Bounds']['Y'] < p['Bounds']['Y'] + p['Bounds']['Height'] and
44-
t['Bounds']['Y'] + t['Bounds']['Height'] > p['Bounds']['Y']):
45-
if t['Bounds']['Width'] > p['Bounds']['Width'] or t['Bounds']['Height'] > p['Bounds']['Height']:
46-
collisions.append(f"Text '{t['Text']}' overflows Panel")
47-
found_container = True
48-
break
48+
pb = p['Bounds']
49+
if (tb['X'] < pb['X'] + pb['Width'] and
50+
tb['X'] + tb['Width'] > pb['X'] and
51+
tb['Y'] < pb['Y'] + pb['Height'] and
52+
tb['Y'] + tb['Height'] > pb['Y']):
53+
candidate_panels.append(p)
54+
55+
if candidate_panels:
56+
# Sort by area ascending to find the most specific container
57+
candidate_panels.sort(key=lambda x: x['Bounds']['Width'] * x['Bounds']['Height'])
58+
p = candidate_panels[0]
59+
if not is_contained(tb, p['Bounds']):
60+
potential_overflow = f"Text '{t['Text']}' overflows Panel"
61+
found_container = True
62+
63+
if potential_overflow:
64+
collisions.append(potential_overflow)
4965

5066
# If still no container found, it might be floating text
5167
# Check if it overlaps with any button it shouldn't be in
52-
if not found_container:
68+
elif not found_container:
5369
for b in buttons:
54-
if (t['Bounds']['X'] < b['Bounds']['X'] + b['Bounds']['Width'] and
55-
t['Bounds']['X'] + t['Bounds']['Width'] > b['Bounds']['X'] and
56-
t['Bounds']['Y'] < b['Bounds']['Y'] + b['Bounds']['Height'] and
57-
t['Bounds']['Y'] + t['Bounds']['Height'] > b['Bounds']['Y']):
70+
bb = b['Bounds']
71+
if (tb['X'] < bb['X'] + bb['Width'] and
72+
tb['X'] + tb['Width'] > bb['X'] and
73+
tb['Y'] < bb['Y'] + bb['Height'] and
74+
tb['Y'] + tb['Height'] > bb['Y']):
5875
collisions.append(f"Floating Text '{t['Text']}' overlaps with Button '{b.get('Text', 'Unknown')}'")
5976

6077
# 2. Check for Button-Button collisions (unrelated to text)

scripts/update_screenshots.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040
"discovery:fire_unlocked",
4141
"discovery:earth_unlocked",
4242
"tab:Spire",
43+
"hover:Fire",
44+
"click",
45+
"hover:Earth",
46+
"click",
4347
"screenshot:mixing_table"
4448
]
4549
}

src/IncriElemental.Desktop/UI/LogSystem.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public void AddToLog(string message)
2424

2525
public void Draw(SpriteBatch spriteBatch, SpriteFont? font, Texture2D pixel, VisualManager visuals)
2626
{
27+
// Register the log background area as a panel for overflow auditing
28+
visuals.DrawPanel(spriteBatch, pixel, new Rectangle(5, 50, 200, UiLayout.Height - 60), Color.Transparent, 0f);
29+
2730
if (font != null)
2831
{
2932
visuals.DrawString(spriteBatch, font, "LOG", new Vector2(20, 55), Color.Gray * 0.5f);

src/IncriElemental.Desktop/UI/MixingTableSystem.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void Draw(SpriteBatch spriteBatch, GameEngine engine, SpriteFont font, Te
4848
drawRect.X += (int)shake;
4949
}
5050

51-
spriteBatch.Draw(pixel, drawRect, Color.DarkSlateGray * 0.5f);
51+
visuals.DrawPanel(spriteBatch, pixel, drawRect, Color.DarkSlateGray * 0.5f, 0.5f);
5252

5353
var borderColor = Color.Gold;
5454
if (_successPulse > 0) borderColor = Color.White * _successPulse;
@@ -57,25 +57,26 @@ public void Draw(SpriteBatch spriteBatch, GameEngine engine, SpriteFont font, Te
5757
spriteBatch.Draw(pixel, new Rectangle(drawRect.X, drawRect.Bottom - 2, drawRect.Width, 2), borderColor);
5858

5959
var title = "ALCHEMICAL VESSEL";
60-
spriteBatch.DrawString(font, title, new Vector2(drawRect.Center.X - font.MeasureString(title).X / 2, drawRect.Y - 30), Color.Gold);
60+
visuals.DrawString(spriteBatch, font, title, new Vector2(drawRect.Center.X - font.MeasureString(title).X / 2, drawRect.Y - 30), Color.Gold);
6161

62-
var y = drawRect.Y + 20;
62+
var y = (float)drawRect.Y + 20;
6363
if (!_currentIngredients.Any())
6464
{
6565
var msg = "(Empty - Add elements below)";
66-
spriteBatch.DrawString(font, msg, new Vector2(drawRect.Center.X - font.MeasureString(msg).X * 0.4f / 2, y), Color.Gray, 0f, Vector2.Zero, 0.8f, SpriteEffects.None, 0f);
66+
visuals.DrawString(spriteBatch, font, msg, new Vector2(drawRect.Center.X - font.MeasureString(msg).X * 0.8f / 2, y), Color.Gray, 0.8f);
6767
}
6868
else
6969
{
7070
foreach (var kvp in _currentIngredients)
7171
{
7272
var line = $"{kvp.Key}: {kvp.Value}";
73-
spriteBatch.DrawString(font, line, new Vector2(drawRect.X + 20, y), visuals.GetColor(kvp.Key), 0f, Vector2.Zero, 0.8f, SpriteEffects.None, 0f);
73+
var lineSize = font.MeasureString(line) * 0.8f;
74+
visuals.DrawString(spriteBatch, font, line, new Vector2(drawRect.Center.X - lineSize.X / 2, y), visuals.GetColor(kvp.Key), 0.8f);
7475
y += 25;
7576
}
7677

7778
var prompt = "CLICK VESSEL TO MIX";
78-
spriteBatch.DrawString(font, prompt, new Vector2(drawRect.Center.X - font.MeasureString(prompt).X * 0.8f / 2, drawRect.Bottom - 30), Color.White * 0.8f, 0f, Vector2.Zero, 0.8f, SpriteEffects.None, 0f);
79+
visuals.DrawString(spriteBatch, font, prompt, new Vector2(drawRect.Center.X - font.MeasureString(prompt).X * 0.8f / 2, drawRect.Bottom - 30), Color.White * 0.8f, 0.8f);
7980
}
8081

8182
// Ingredient Buttons
@@ -91,7 +92,7 @@ public void Draw(SpriteBatch spriteBatch, GameEngine engine, SpriteFont font, Te
9192
var rect = new Rectangle(curX, btnY, 60, 30);
9293
var hover = rect.Contains(mousePos);
9394
spriteBatch.Draw(pixel, rect, visuals.GetColor(type) * (hover ? 0.6f : 0.3f));
94-
spriteBatch.DrawString(font, type.ToString()[..1], new Vector2(rect.Center.X - 5, rect.Center.Y - 10), Color.White);
95+
visuals.DrawString(spriteBatch, font, type.ToString()[..1], new Vector2(rect.Center.X - 5, rect.Center.Y - 10), Color.White);
9596

9697
curX += 70;
9798
}

0 commit comments

Comments
 (0)