Skip to content

Fix controller inventory background, remove stone background for MKB - #49

Open
leduythuccs wants to merge 5 commits into
mapron:mainfrom
leduythuccs:fix-controller-inventory-background
Open

leduythuccs wants to merge 5 commits into
mapron:mainfrom
leduythuccs:fix-controller-inventory-background

Conversation

@leduythuccs

@leduythuccs leduythuccs commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #46

Most of the hardcoded number is generated by claude code,

Controller layout

  • The inventory grid is centered with a (maxCols - cols) * cellWidth / 2 offset
  • The controller background is transparent, because the game draws the background behind that. That's why we need drawBlended to respect the transparent background

Remove stone background for MKB

  • Now use the stone area of controller/panel/mainpanelbg.sprite (plus its .lowend version)
  • drawScaled is needed because MKB panel is larger than the controller panel

Result

8x12 layout

image image

leduythuccs and others added 3 commits November 12, 2026 11:37
Controller inventory backgrounds are centered in the panel, so sprite
coordinates differ from panel coordinates. Offset the copied frames
accordingly, include their borders, and draw the belt frames.

The game draws its own panel behind the controller inventory, so keep
the expanded background transparent instead of filling it with stone,
which covered the top menu. Center the equipment, grid and belt row in
the panel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace background of MKB with controller mainpanelbg.sprite, scaled with panel size

const auto gridOffset = Point{ ((cellCountXmax - cellCountX) / 2) * cellWidth, ((cellCountYmax - cellCountY) / 2) * cellHeight };
const auto widgetsOffset = Point{ 100, 0 };
const auto gridOffset = Point{ (cellCountXmax - cellCountX) * cellWidth / 2, (cellCountYmax - cellCountY) * cellHeight / 2 };

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the old formula is off by half a cell if the different is odd number. Is it intended?

I fixed it so the grid center correctly

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I was trying to move grid in "discrete" steps, so for odd it does not jumping. it is not off, so yes it is intended. So we don't have half-cell distance from left-border when we have max-1 width, just padding on a right.

There is 0 reason to do so, though. Probably better with your suggestin.

Comment thread src/CoreLib/Image.cpp
}
}

void Bitmap::drawScaled(Rect destRect, const Bitmap& src, Rect srcRect)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is something we should avoid, all stuff in json have like "scale: 1.2" and stuff, so at least no rescaling, I wish we can remove blender later, but rescaled is suspicios

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha. Let me think of another way to fix it. Originally I use draw, then realized, for some reasons, the MKB panel is actually larger than the cropped controller panel.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

he MKB panel is actually larger than the cropped controller panel.
yeah, tile still should work. At worst we can resort and mirror and copy (flip image vertically) to not see horizontal tile repeat. but vertical tiling must be possible seamless with this texture.

} else {
Rect stoneRect = s_panelBgStoneRect;
stoneRect /= downscale;
bmp.drawScaled({ .topLeft = {}, .size = newSize }, desc.lowres ? panelBgLowend : panelBgHighre, stoneRect);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You stretching panelBg? that does no feel right... Especially with shittiest 2x2 linear interpolation AI did.
I think we can safely tile with background. It repeats itself if you look ar backround itself, it is periodic at least horizontally. (around 80% of width start repeating pattern).
so make a cut and the tileWith like it was with stone

if (bd.rect.size.width > 0) {
const int margin = desc.controller ? s_ctrlFrameMargin : 10; // extra borders
bd.rect.expand(margin);
bd.moveTo -= Point{ margin, margin };

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+= -margin, -margin
and remove -= overload please.

Maybe it's me but it is confusing to deal with -= (displacement) especialy when displacement can be negative (i was thinking removing += and add move/displace instead). as in mathematical sense you can't add two points, you can apply displacement vector to a point. current += already a dirty code for convenience.

(same for another -= you added)


const auto gridOffset = Point{ ((cellCountXmax - cellCountX) / 2) * cellWidth, ((cellCountYmax - cellCountY) / 2) * cellHeight };
const auto widgetsOffset = Point{ 100, 0 };
const auto gridOffset = Point{ (cellCountXmax - cellCountX) * cellWidth / 2, (cellCountYmax - cellCountY) * cellHeight / 2 };

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I was trying to move grid in "discrete" steps, so for odd it does not jumping. it is not off, so yes it is intended. So we don't have half-cell distance from left-border when we have max-1 width, just padding on a right.

There is 0 reason to do so, though. Probably better with your suggestin.

@mapron

mapron commented Nov 12, 2026

Copy link
Copy Markdown
Owner

I am adding you as collaborator, so it will be easier to patch (no need to fork, pull og commits its, just make MR any time and merge). won't grant you direct push to master :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wrong layout for controller when expanding inventory

2 participants