calref / cboe

Classic Blades of Exile
http://spiderwebforums.ipbhost.com/index.php?/forum/12-blades-of-exile/
Other
168 stars 41 forks source link

Information icons in shop not clickable #247

Closed x-qq closed 4 years ago

x-qq commented 4 years ago

The following icons are not clickable.

clickable

Additionally, clicking around the icons and scrolling that UI seems to eventually produce temporary weird-looking glitches.

x-qq commented 4 years ago

So what happens here is this:

1) Event catching rectangles are defined in coordinates relative to the main game window 2) Elements of the shop window (item names, prices, icons etc) are drawn into shop's own rendering target, based partially on the coordinates of the above event catching rectangles. 3) So far this is consistent, because both event rectangles and positions of the shop elements inside the rendering target are based at (0,0) 4) Contents of the rendering target are drawn with an offset inside the main window. This creates the current bug, because the event catching rectangles no longer match the actual icon positions.

https://github.com/calref/cboe/blob/master/src/game/boe.newgraph.cpp#L807

void refresh_shopping() {
    rectangle from_rect(talk_gworld);
    rectangle to_rect = from_rect;
    to_rect.offset(19,7);             <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    rect_draw_some_item(talk_gworld.getTexture(),from_rect,mainPtr,to_rect);
    shop_sbar->draw();
}

Here is how it looks with event rectangles overlaid on top of the shop UI:

pix

Without the offset, shop window is drawn at (0,0) base and event rects exactly match the icons, but the downside is that rest of the UI is broken:

nooffset

Additionally, clicks in the shop window for some unknown reason have their coordinates adjusted by (-5, -5), which added to confusion. https://github.com/calref/cboe/blob/master/src/game/boe.dlgutil.cpp#L673

    p.x -= 5;
    p.y -= 5;