81025 Commits

Author SHA1 Message Date
Tommy
d3448ef7e9 Clarify and correct mouse input location calculations
The portion of the window that the game canvas covers is now what is
returned by video::input_area(). This is in display coordinates, which
may not match draw coordinates or output coordinates.

sdl/input.cpp was changed to query and account for input_area when the
mouse location is polled. This removes the input dimension caching that
was previously being done.

All other uses of input_area() are probably erroneous, as SDL events are
automatically converted to draw-space by SDL. It is only needed when
polling the mouse location directly, which returns it in display
coordinates relative to the window.
2022-07-24 22:06:33 +12:00
Tommy
b9b8f78206 video: Tidy up handling of draw size, output size, and logical offset
This ensures sveral things:
 * the game display's offscreen render buffers are used correctly
 * custom render targets will report the correct draw area
 * they will also report the correct clipping region and viewport
 * converting draw space coordinates to output coordinates will
   return the correct coordinates on the full render target.

Not much of this is currently used, but it will be necessary to get
correct for source clipping regions and possibly input conversion.
These are both on the TODO list to clean up.
2022-07-24 22:06:33 +12:00
Tommy
bef85a51a4 video: Clarify draw_area() -> game_canvas() in almost all cases
Theoretically the drawing area may change if we are rendering to
texture. However the vast majority of cases wanted the game canvas
size independent of whatever the current render target may be.

A function game_canvas_size() was also added returning a point,
and this was used to simplify things where appropriate.
2022-07-24 22:06:33 +12:00
Tommy
68f86eba10 video: Clarify headless and unit test checks and interfaces
* faked() has been renamed headless() to better express its meaning
  - it is true when there is no window or renderer at all
* internal usage of the window pointer has been clarified
  - a window should always exist, unless in headless mode
* non_interactive() has been removed in favour of headless()
  - they are logically identical
* some nomenclature internal to video:: was clarified
  - fake_interactive_ -> testing_
  - fake_size -> test_resolution_
  - init_fake_window() -> init_test_window()
  - make_fake() -> init_fake()
  - update_framebuffer_fake() -> update_test_framebuffer()
* any_fake() was replaced with testing() to check if running tests
* make_test_fake() was removed in favour of set_resolution()
  - the only other use was for init which can be done... in init()

There are now two clear non-standard modes: headless() and testing().

Headless mode has no window or renderer, and hardware rendering
should never be attempted.

Testing mode has a window and renderer, but there are not currently
any tests which use them. Rendering functions may be skipped.
2022-07-24 22:06:33 +12:00
Tommy
8c9519456c video: Rearrange, and make init_window() internal to init() 2022-07-24 22:06:33 +12:00
Tommy
6775be5913 Call SDL_Quit at exit, not some other strange place 2022-07-24 22:06:33 +12:00
Tommy
5c575548fd display: Correctly update for changed pixel scale 2022-07-24 22:06:33 +12:00
Tommy
0548f5a490 display: Apply several small fixes and replacements
* don't apply a delay while calculating fps count - this is redundant
* remove dirty_ flag - it can be replaced by queueing a redraw
* rename redraw_everything to queue_rerender for clarity
* remove some unnecessary redundant actions when queueing rerenders
* make draw() private and stop everything from calling it
  - calling it manually is no longer necessary, and now harmful.
2022-07-24 22:06:33 +12:00
Tommy
bef3d1092c display: General tidyup
This should just be shifting things around with no change to execution.
2022-07-24 22:06:33 +12:00
Tommy
0c096ff917 draw_manager: Add invalidate_all() to invalidate the entire screen
Updated usage everywhere appropriate.
2022-07-24 22:06:33 +12:00
Tommy
a18eef1c5e Immediately update the UI when pixel scale changes in preferences
* the dialog now raises a resize event in this case
* raise_resize_event() now activates linked handlers immediately,
  in stead of waiting until the next event pump.
2022-07-24 22:06:33 +12:00
Tommy
7877158b69 video: remove and refactor unnecessary and poor interfaces
* removed clear_screen() - not necessary to do
* removed delay() - inappropriately used, and should not be here anyway
* expose render_screen only to draw_manager - nothing else should do it
* remove read_texture - unused
* split window_has_flags into individual queries:
  - window_is_visible()
  - window_has_focus()
  - window_has_mouse_focus()
* tidied window mode setting code
* removed setup_completed() and has_window() - always true as used
* cleaned video.hpp includes
* deexposed some internal video functions
  - update_framebuffer -> update_buffers(false)
  - make_fake -> unused externally
2022-07-24 22:06:33 +12:00
Tommy
29c82e308a CVideo: Remove CVideo singleton, replacing with "video" interface
The only real change is that in stead of passing around CVideo
pointers and calling things via CVideo::get_singleton().foo()
one simply does not pass around pointers, and calls video::foo().
2022-07-24 22:06:33 +12:00
Tommy
8fed797861 Rework DRAW events
* removed DRAW_ALL_EVENT - it is not the correct way to draw everything
* made debug_clock a TLD, in stead of hooking DRAW events
* tidied draw event handling, also removing some incorrect usage
2022-07-24 22:06:33 +12:00
Tommy
ad48f7782b Greatly simplify event code relating to resizing
There are still some things doing things in bad places.
They will be fixed.
2022-07-24 22:06:33 +12:00
Tommy
99be6c52a4 CVideo: begin refactoring
* marked many functions for refactor
* removed some unused functions
* moved help tooltip functions out to floating_label.*pp
* streamlined help string tracking
* removed flip_locker - it is no longer useful
* removed update_locker - it is no longer useful
2022-07-24 22:06:33 +12:00
Tommy
86570f6cc4 sdl/utils: Properly report empty result when masking a null texture 2022-07-24 22:03:34 +12:00
Tommy
d007ec64af Handle non-hex-sized images when cropping to hex
Images that are not 72x72 are centered and cropped before masking.

Fixes #6118.
2022-07-24 22:03:34 +12:00
doofus-01
e8d451bbd5
1.17 dwarf sprite cleanup (#6902)
* fill semitransparent pixels

* sprite palette cleanup
2022-07-23 21:30:49 -07:00
doofus-01
346e74697f
1.17 drake sprite cleanup (#6901)
* fill semitransparent pixels

* drake sprite palette cleanup
2022-07-23 18:33:14 -07:00
Nils Kneuper
d9663c6fe5 updated Finnish translation 2022-07-23 12:46:45 +02:00
Nils Kneuper
f6f81c78dd updated British English translation 2022-07-23 12:46:01 +02:00
Nils Kneuper
fb021524af updated Arabic translation 2022-07-23 12:44:57 +02:00
Tommy
0b97284f07 Correctly invalidate the previous frame when displaying leadership
Fixes #3996.

I applied the fix by jostephd. The fix looks good, and works.
2022-07-23 15:24:53 +12:00
loonycyborg
720094361d
servers: avoid exception on write error 2022-07-22 18:23:27 +03:00
loonycyborg
b346b3911b
Remove dead code 2022-07-22 18:14:54 +03:00
Tommy
28f2637a06 display: simplify map screenshot procedure 2022-07-22 15:07:59 +12:00
Tommy
49e75f0e89 Fix hex invalidation code for animations when zoomed
It did not match the actual animation placement... the code was both
duplicated and wrong. I guess one part got updated and the other part
didn't.

It still needs to be deduplicated...
2022-07-22 15:07:59 +12:00
Tommy
f6763be08b top_level_drawable: Implement copy and move constructors 2022-07-22 15:07:59 +12:00
Tommy
afd6baa7cf Hardware unit HP/XP bars
This was the last critical hardware acceleration task.
Pretty much everything should be acceptably accelerated now.
2022-07-22 15:07:59 +12:00
Tommy
a4ebf83be3 Remove screen size code from MP lobby prefs dialog callback
It seems to be unnecessary, and left over from before GUI2 migration.
2022-07-22 15:07:59 +12:00
Tommy
9362698f1a font/sdl_ttf_compat: allow pango_render_text to not clip the text
This is used by widgets/button to determine the ideal button size.
2022-07-22 15:07:59 +12:00
Tommy
8295c55d1f GUI1: Remove TODOs from widgets/button as it appears to work fine 2022-07-22 15:07:59 +12:00
Tommy
fa3315b520 GUI1: Remove CVideo from widget constructor 2022-07-22 15:07:59 +12:00
Tommy
1fea22a51d events::sdl_handler: Make handle_window_event optional
Very little actually uses this.
2022-07-22 15:07:59 +12:00
Tommy
6a2ea6ed3e display: Slightly optimize movement defense % text drawing 2022-07-22 15:07:59 +12:00
Tommy
3bf2339c07 display: Stop using surfaces for tod_hex_mask
ToD mask fade is probably better now, but needs testing as it isn't
used in mainline.
2022-07-22 15:07:59 +12:00
Tommy
3835f9580b Fix some poor indentation, and tidy some TODOs 2022-07-22 15:07:59 +12:00
Discontinuum
6991fcf5a8 Fix the description of concealment
It affects all villages, water villages included
2022-07-21 18:21:15 +02:00
Tommy
157c8d066a display: Improve terrain code text background performance
Appropriately blits a single-pixel texture using recently added
features, in stead of creating a new surface and texture each time.
2022-07-21 12:16:04 +12:00
Tommy
482bc22f80 Fix the --render-image commandline option
It now implies (and is not denied by) --nogui.
2022-07-21 12:16:04 +12:00
Tommy
0c381e74f0 sdl/texture: Properly set blend mode on textures created from surface 2022-07-21 12:16:04 +12:00
Tommy
0692c4958d sdl/point: Add elementwise multiplication and division operators 2022-07-21 12:16:04 +12:00
Tommy
d58829e129 sdl/rect: Add pos() and size() returning points {x,y} and {w,h} 2022-07-21 12:16:04 +12:00
Tommy
2da7515722 sdl/window: add set_logical_size(point)
Also changed get_logical_size to return point not SDL_Point.
2022-07-21 12:16:04 +12:00
Tommy
eae182ba80 draw_manager: Make TLD removal more robust
TLDs can now be deregistered or raised during TLD iteration.

Also removed an explicit deregister of the loading screen, which
appears to no longer be necessary.
2022-07-21 12:16:04 +12:00
Tommy
8633120f08 Add update() function to top_level_drawable, run before layout()
This is mostly good for updating things that may change layout,
such as motion animations. However it can be useful for other things.
2022-07-21 12:16:04 +12:00
Tommy
5e54f2eca3 draw_manager: Just raise TLD on redundant reregistration 2022-07-21 12:16:04 +12:00
Tommy
afa2abb667 display: Allow using chained setters to manage blit helpers
For example `drawing_buffer_add(...).set_alpha(128).set_hflip(true);`
2022-07-21 12:16:04 +12:00
Tommy
3b12a5043f sdl/rect: Add shift(point) to shift a rect to a relative position 2022-07-21 12:16:04 +12:00