Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to rotate text with LUA engine + draw_text for vertical games? #7475

Open
buffis opened this issue Nov 14, 2020 · 5 comments
Open

No way to rotate text with LUA engine + draw_text for vertical games? #7475

buffis opened this issue Nov 14, 2020 · 5 comments
Labels

Comments

@buffis
Copy link
Contributor

buffis commented Nov 14, 2020

See screenshot:
https://i.imgur.com/69IIczu.png

The draw_text API doesn't seem to have any support for rotating the text.

Tested with rom bbakraidja

cracyc referenced this issue Dec 8, 2020
* Modernised and cleaned up Lua bindings for input classes.
* Exposed the input_sequence_poller class to Lua and updated the
  autofire and cheat plugins to use it, rather than continuing to
  pretend it's part of the input manager.
* Exposed more of the natural keyboard manager, including the ability
  to enable/disable individual keyboard and keypad devices like you
  can from the keyboard mode menu.
* Exposed a few more things on ioport_port and input_device.

-plugins/cheat: Fixed menu item not updating visually when disabling a
 cheat with UI Left.

-plugins/cheatfind: Fixed not finding the first screen after screen
 enumerator was exposed as an object rather than using a table.

-bwidow.cpp, pacman.cpp: Minor cleanup to recent changes.
@angelosa
Copy link
Member

angelosa commented Feb 7, 2021

fwiw it's not "vertical" games only, it's really anything that doesn't have ROT0 as screen orientation, example splatterj (ROT180):

0000x

emu.pause()
s = manager.machine.screens[":screen"]
s:draw_text(40, 40, "Hey I am upside down")

@h0tw1r3
Copy link
Contributor

h0tw1r3 commented Oct 3, 2021

Would it make sense if these functions drew on the ui layer instead of the "screen"? Then presumably the rotation becomes a non issue.

@cuavas
Copy link
Member

cuavas commented Oct 3, 2021

Allowing Lua to draw to the UI container is not as simple as you might hope.

cuavas added a commit that referenced this issue Nov 1, 2021
frontend: Made it so you can press UI On Screen Display to hide the
Analog Controls menu and see the response to your inputs without the
risk of changing settings, and see more axes at once and scroll them for
systems with very large number of axes.  Also ensure the axis being
configured is visible when the menu is visible, and made the menu behave
a bit more like the system input assignments menu (including
previous/next group navigation).

frontend: Allow Lua to draw to the UI container - this addresses the
main complaint in #7475.  Note that drawing to the UI container will
draw over any UI elements, including menus.  Plugins can check
menu_active to avoid drawing over menus.  Also removed some unnecessary
use of sol::overload.

frontend: Improved info/image box navigation on the system/softwre
selection menus, and cleaned up some leftover code that came from the
copy/pasted event handling functions.

frontend: Fixed sliders menu not handling Alt+Shift as intended (thanks
Coverity).  Fixed a couple of harmless Coverity errors, too.

emu/inpttype.ipp: Made the default assignment for Save State recognise
right shift.

plugins: Added next/previous group navigation to input macro edit menu.

docs: Added basic description of the system and software selection
menus, and corrected a couple of errors in the Lua reference.
@cuavas
Copy link
Member

cuavas commented Nov 1, 2021

@h0tw1r3 this has been at least partially addressed by 8ab63e2. It’s now possible to draw to render containers directly (see Lua reference for render container). This allows you to draw text “right way up” when the emulated screen is rotated. Note that render container coordinates are normalised (0,0)-(1,1) for the window/screen area, which may not correspond directly to the screen area due to aspect ratio differences or layouts. There’s still no way to explicitly draw rotated text.

Here’s a quick and dirty example that works at the console:

ui_ctnr = manager.machine.render.ui_container
lineheight = manager.ui.line_height
function overlay()
   ui_ctnr:draw_text('center', 1 - (2 * lineheight), 'hello\nfrom Lua', 0xffffffff, 0x66666666)
end
emu.register_frame_done(overlay, "frame")

Using this with Super-X (superx – a vertical screen game):
image

Note that anything from Lua drawn to the UI container will draw over UI elements, including menus. You can check menu_active to avoid drawing over menus if you like.

@h0tw1r3
Copy link
Contributor

h0tw1r3 commented Nov 2, 2021

Confirmed. Works as described.

For others reading this, the UI is not included in a :snapshot or :video_recording (which my use case requires).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants