forkserf / forkserf

a continuation of "FreeSerf"

Home Page:https://forkserf.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

separate Viewport zoom from UI element zoom

zdechlak opened this issue · comments

forkserf.2023-01-19.20-29-05.mp4

That is actually the intended behavior from Freeserf. I have thought about making panelbar & popup zoom a separate control as I don't really like it either, but it seems that some people may prefer it. I will mark this as feature request.

Note that the cut-off-right-half-of-panel on the Options screen shown in your last frame is a known but, I need to create Issue tracker for at some point. This is due to the flip between Large and Normal popup window types

it would be great if it worked like in this project https://www.simpleguide.net/sg/serflings.jsf

join forces guys

The creator of Serflings is not willing to open source his project, unfortunately.

I looked into this briefly but it is not a simple fix. The GUI objects are all children to the Viewport game window and they all scale together. I need to break them apart to be drawn totally separately.

Looking at this further, it looks like the code is scaling the entire frame and not individual objects, and the core SDL2 library doesn't actually support zooming individual sprites. I am looking into the SDL_gfx supplemental library to see if is possible to scale the Viewport without scaling the entire frame, and then draw normal unscaled UI objects on top of it

looks like using RenderCopyEx to draw the zoomed/reduced current frame so far, after terrain and game objects drawn but before UI elements drawn, with a dsrect of the full game window size, then draw UI elements on top? Is it possible to call RenderCopy / RenderCopyEx multiple times per Frame? I would think so.. I suspect it is calling every single time it draws a sprite...

https://stackoverflow.com/questions/328500/proper-way-to-scale-an-sdl-surface-without-clipping

it maybe be simpler (or ultimately the same thing) to draw all non-UI sprites multiplied by zoom_factor (using RenderCopyEx?) and draw UI sprites normally. Only complication is trying to reclaim the performance benefit of not drawing anything that can't be seen, which the current implementation does (I'm pretty sure), though the perf hit might not be all that important...

this is mostly working now! it was difficult to separate the Viewport from the rest of the UI but it is now working and popup-dragging while zoom is now supported. Still need to tweak some things as the viewport jumps around when things resized/opened/closed, but the zoom part works well.

forkserf_new_zoom.mp4

fixing the jumpiness turned out to be easy, and I made it so popups that become off-screen due to resizing are simply moved back on-screen. This seems like it all works great now, but haven't playtested

done in v0.6.1