71544 Commits

Author SHA1 Message Date
Charles Dang
ed27b67f1e Port floating textbox/command console to GUI2
The old floating textbox was extremely entwined with the controller_base, play_controller, and menu_handler
classes. controller_base::have_keyboard_focus essentially controlled whether some events were executed based
on whether the floating textbox was open or not. Additionally, those events weren't even reached if a UI dialog
was open at all.

The new design features a singleton console class that can be called from anywhere, not just the game. I've also
decoupled the execution object from play_controller. The relevant functions in menu_handler are now passed to
the console as callbacks.

To work around map events such as clicking not being available if the console was open, I removed the exclusionary
is-in-dialog check from controller_base::handle_event and instead exit early out certain types of events using
controller_base::have_keyboard_focus. As mentioned in the accompanying comment, this isn't the best solution, but
it will do for now.

The new console also isn't fully feature-comparable with the old GUI1 one. The following are still missing:
* The checkbox, for use when sending messages.
* Tab completion.
* A crash occurs when existing the app if a game was exited with the console open.

I'm leaving the old floating_textbox code around for now for reference.
2018-03-19 01:22:18 +11:00
Charles Dang
770664d1f3 Added a getter for a static pango_text object
The reason I added this was so I can refactor some temporary pango_text objects out of the display class.
styled_widget doesn't use this for reasons explained in the comment.
2018-03-19 01:22:16 +11:00
Charles Dang
2dca404a63 Split texture caches into linear and NN scaled versions
With textures, you can't change render scale quality once they've been created. To rectify this, I've
made the texture caches a map of caches, sorted by scale quality. This should result in no performance
overhead, since an image is simply added to the appropriate quality cache on creation instead of in
a single cache. If a different version of a texture is needed it will be loaded later.

By default, load_texture will return images using nearest neighbor scaling. GUI2 always fetches images
using linear scaling. This is consistent with the old software rendering method. Plus, we don't have
any way (as of now) to specify the render quality on a per-image basis.
2018-03-19 01:22:14 +11:00
Charles Dang
6c04ae29b9 GUI2/Window: removed empty undraw() function
This was emptied earlier in my refactor when window unrendering was removed. I simply hadn't
removed the function yet.
2018-03-19 01:22:13 +11:00
Charles Dang
3154ab419f Restored alpha handling of unit frames
Still need to figure out the blending effects or submerge alpha.
2018-03-19 01:22:12 +11:00
Charles Dang
c406a2067f Refactored halo code to bring it in line with new drawing methods
This basically rips out all the unrendering and invalidation code. Neither is needed anymore.
Instead, we can have a simple, clean, "just draw the managed halos" interface.

Note there's an issue unrelated to this where halos aren't removed when a unit is killed with
the debug kill menu command.
2018-03-19 01:22:10 +11:00
Charles Dang
f7de368551 Added some inline wrappers for SDL_SetTexture* functions 2018-03-19 01:22:09 +11:00
Charles Dang
ca44435550 SDL/Window: removed pixel format member and promoted renderer info wholly to class member
The pixel format member was really rather useless, since SDL_RenderInfo returns an array of supported
formats and only the first one was being saved.
2018-03-19 01:22:08 +11:00
Charles Dang
855345291b GUI2: removed some unnecessary calls to canvas::set_is_dirty
The one in Outro was unnecessary since set_variable already calls set_is_dirty.
The one in the Story Viewer was there to deal with some background redraw issues which no longer appear
with the new drawing methods.
2018-03-19 01:22:06 +11:00
Charles Dang
8396b535c8 GUI2/Window: draw background image first instead of last
Originally was going to do this as workaround for the background tiling over the borders,
but I fixed the root cause of that instead. Still, this just makes more sense.
2018-03-19 01:22:05 +11:00
Charles Dang
c8f36d2758 GUI2/Canvas: set clip rect when tiling images
This fixes an issue where images could be tiled outside their desired size area.
2018-03-19 01:22:04 +11:00
Charles Dang
af861f7292 Allowed IPFs to work again when using the texture cache
See create_texture_from_sub_file doc comment for more info.
2018-03-19 01:22:03 +11:00
Charles Dang
8a82d43855 Some initial code (disabled for now) for setting up an OGL context
In the interests of getting this all done faster, I've decided to postpone work on the OGL implementation for now
and focus on the SDL_Renderer version. This contains some basic code (include-guarded) for setting up an OGL context
for the main SDL window.
2018-03-19 01:22:01 +11:00
Charles Dang
61dcb43ee6 GUI2/Canvas: refactor surface use out of image rendering
The only real reason to keep using a surface was in order to have resize mode manipulations. I've now added
texture-only handling methods (the tiling one was borrowed from display.cpp's draw_background function).
2018-03-19 01:21:12 +11:00
Charles Dang
01d78cbb7f Trim ToD images to hex 2018-03-19 01:21:11 +11:00
Charles Dang
1cb496d966 Extended implementation of the texture cache
Instead of always loading a surface at the same time, textures are now loaded directly from disk if applicable.
Instead, surfaces are only loaded if applicable to apply some effect that cannot as of now be done with texture
manipulation since we dont have shader support yet.

In that vein, I've also added two new texture caches, one for masked-to-hex images and one for ToD colored images.
2018-03-19 01:21:10 +11:00
Charles Dang
250bb0b3af GUI2/Canvas: fixed mirrored images being flipped on the wrong axis. 2018-03-19 01:21:08 +11:00
Charles Dang
d748cbcd23 Units: fixed bad HP/XP bars fill rect offset 2018-03-19 01:21:07 +11:00
Charles Dang
37bcade3a1 Removed most call to raise_draw_event
These don't seem necessary anymore since draw handling happens per-frame and doesn't rely
on calling derived class's draw() member.
2018-03-19 01:21:06 +11:00
Charles Dang
d427bf1e65 Enabled more stuff drawing
Hex overlay, map items, fog/shroud transitions.
2018-03-19 01:21:05 +11:00
Charles Dang
643ebe221f Got a bunch more components drawing
Reachmaps, attack indicators, shroud/fog (incomplete).
2018-03-19 01:21:04 +11:00
Charles Dang
66f2d3f49c Video: removed unused arguments from make_test_fake 2018-03-19 01:21:03 +11:00
Charles Dang
e205e42d44 Video: (almost) completely removed framebuffer surface
Again, useless since there's no more window surface with accelerated rendering.
getSurface() remains since it's still used in quite a lot of places. Will removed ASAP.
2018-03-19 01:21:01 +11:00
Charles Dang
ea395c1fb5 Removed draw() calls into the display class
Not needed anymore since per-frame drawing is handled within said class.
2018-03-19 01:17:07 +11:00
Charles Dang
42894f6ac3 Another huge chunk of progress 2018-03-19 01:17:05 +11:00
Charles Dang
d614c71786 Uint: fixed bad bar alpha on unit mouseover 2018-03-19 01:16:30 +11:00
Charles Dang
b8a03da847 Fixed play_controller not joining current event context
Was broken when I moved the GUI2 drawing trigger code to global scope probably.
2018-03-19 01:16:29 +11:00
Charles Dang
ba9a0f7550 GUI2/Canvas: made use of CVideo::render_copy 2018-03-19 01:16:28 +11:00
Charles Dang
6fbc2491ea Video: expand render_copy to take flip arguments
Still needs to handle rotation.
2018-03-19 01:16:24 +11:00
Charles Dang
6fdf1bcc88 Draw units under bars/orbs/etc 2018-03-19 01:16:03 +11:00
Charles Dang
c52a2a1b75 GUI2: moved event handling into main context
Not sure why I need to call join() in connect() instead of the ctor, though.
2018-03-19 01:16:02 +11:00
Charles Dang
d2087a14c4 Initial refactor for main-screen accelerated rendering 2018-03-19 01:16:01 +11:00
Charles Dang
8dc661db40 Decoupled drawing buffer code from display class 2018-03-19 01:14:02 +11:00
Charles Dang
e30a2aa520 Added static prototype for GUI2 in-game theme 2018-03-19 01:14:00 +11:00
Charles Dang
758ad0bf23 GUI2/Miniap: draw any provided canvas data before the minimap 2018-03-19 01:13:59 +11:00
Charles Dang
441ec38adf Moved GUI2's per-frame drawing trigger to global scope
This is derived from work originally done by @aginor (48bcb277d4). I cherry-picked that commit and made a few alterations.
2018-03-19 01:13:58 +11:00
Charles Dang
eaac01c9a2 Enabled drawing of minimap in-game 2018-03-19 01:13:56 +11:00
Charles Dang
e7d1c970bc GUI2/Canvas: disable surface manip w/ accelerated rendering for stretch resize mode
RenderCopy handles that automatically.
2018-03-19 01:13:55 +11:00
Charles Dang
2d39d19af9 Texture: converted internal handling to use a shared_ptr
This allows multiple texture objects to refer to the same texture without destroying them prematurely.
This is different from the SDL_Surface wrapper's implementation since surfaces have their own internal
refcounting system; textures do not.
2018-03-19 01:13:54 +11:00
Charles Dang
3e2046b5d8 Added a texture cache
Note this probably doesn't work properly yet since I haven't properly implemented shared management
of textures in their wrapper class.
2018-03-19 01:13:53 +11:00
Charles Dang
da7917955b Use get_renderer() over *get_window()
This doesn't appear to have been an issue in the rectangle drawing code at least, but it should guard
against possible segfaults in the future.
2018-03-19 01:13:52 +11:00
Charles Dang
4a0f8d9db0 CVideo: convert blit_surface to handle input as textures instead of blitting to framebuffer 2018-03-19 01:13:51 +11:00
Charles Dang
81a62bf49c Moved renderer RAII helpers to their own file and added ones for clip rect and viewport
Do note that setting an empty rect in render_raii_rect_setter_base is not the same as passing nullptr.
If an empty rect is passed to SDL_RenderGetClipRect, for example, you can end up with nothing drawing
since everything is being clipped.
2018-03-19 01:13:49 +11:00
Charles Dang
a710d6d457 GUI2/Minimap: quick fix to get the minimap drawing again 2018-03-19 01:13:48 +11:00
Charles Dang
56a793c086 Added SDL_Texture wrapper class and some utility functions 2018-03-19 01:13:47 +11:00
Charles Dang
5c430f6096 GUI2/Canvas: add error logging if canvas texture creation fails 2018-03-19 01:13:46 +11:00
Charles Dang
894e9b6b3e Small code simplification 2018-03-19 01:13:44 +11:00
Charles Dang
aa2f266e87 GUI2/Canvas: removed surface_lock objects
The canvas surface isn't even passed to these functions anymore so I have no idea how this built.
2018-03-19 01:13:43 +11:00
Charles Dang
94f9303bde Removed some debug output
[ci skip]
2018-03-19 01:13:42 +11:00
Charles Dang
48d072a02e GUI2: refactored viewport setting and re-added clip rect setting
It turns out I had removed the clip rect setting in error; it prevented items in, say, a listbox from drawing
outside the widget's boundaries. I've re-added that now.

I've also moved viewport setting to the same place. It turns out it didn't need to be set every canvas draw.
The only reason the old code was passing the blitting rect to the canvas was it was needed for the sdl_blit call.
Since I can now set the viewport independent of a canvas state, there's no longer a need to set the viewport in
the canvas.
2018-03-19 01:13:41 +11:00