Skip to content

Commit

Permalink
Fix button offsets per screen type
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherHaws committed Nov 25, 2022
1 parent 9860333 commit a300611
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,22 @@ public static void initialize() {
}

private static void onScreenOpened(Screen screen) {
var offsetFromCenter = 0;
var xOffsetFromCenter = 0;
var yOffset = 0;

if (screen instanceof SignEditScreen) {
offsetFromCenter = 50;
xOffsetFromCenter += 50;
yOffset += 70;
} else if (screen instanceof BookEditScreen) {
offsetFromCenter = 70;
xOffsetFromCenter += 70;
yOffset += 20;
} else if (screen instanceof AnvilScreen anvilScreen) {
xOffsetFromCenter += 85;
yOffset += (screen.height / 2) - 80;
((AnvilScreenAccessor)anvilScreen).getNameField().setRenderTextProvider((abc, def) ->
Text.literal(abc).asOrderedText()
);

offsetFromCenter += 85;
} else {
// Not a supported screen.
return;
Expand All @@ -74,16 +78,16 @@ private static void onScreenOpened(Screen screen) {
var colorButtons = getFormatButtons(
screen,
colorFormattings,
screen.width / 2 - (120 + offsetFromCenter),
70,
(screen.width / 2) - (120 + xOffsetFromCenter),
yOffset,
4
);

var modifierButtons = getFormatButtons(
screen,
modifierFormattings,
screen.width / 2 + offsetFromCenter,
50,
(screen.width / 2) + (xOffsetFromCenter),
yOffset,
6
);

Expand Down

0 comments on commit a300611

Please sign in to comment.