Problem Problem lighting buttons with "oapi.blt" .

johnnymanly

Donator
Donator
Joined
Mar 17, 2008
Messages
179
Reaction score
116
Points
43
Location
Southwest Pennsylginia
Website
sites.google.com
I'm hoping to use a lighted button effect for NAVMODE and RCSMODE in a simple VC. I've got NAVMODE working fine with this code:
Code:
function redraw_panel_navmode(surf)

  for i = NAVMODE.KILLROT, NAVMODE.HOLDALT - 1 do
    if vi:get_navmode(i) then
      oapi.blt(surf, tex4, (6-i)*85.3, 0, (6-i)*85.3, 0, 85.3, 64)
    end
  end

end
A lighter image is copied over a darker one when the buttons are pressed.

I tried the same thing with RCSMODE using:
Code:
function redraw_panel_rcsmode(surf)

  for i = RCSMODE.ROT, RCSMODE.LIN do
    if vi:get_rcsmode(i) then
      oapi.blt(surf, tex6, (2-i)*64, 0, (2-i)*64, 0, 64, 64)
    end
  end

end
The source image is copied over the target but it's always there. No matter what mode it's in or if it's off, it looks like the buttons are always lit up.
What am I doing wrong?:unsure:
Screenshot_20250223_173443.png
 
I got the effect I wanted using sketchpad:
Code:
function redraw_panel_rcsmode(surf)

  local pSkp = oapi.get_sketchpad(surf)
  local pOld = pSkp:set_font(rfont)
  pSkp:set_textcolor(_RGB(97,160,80))
  pSkp:set_textalign(SKP.CENTER, SKP.BASELINE)
  pSkp:set_backgroundcolor(0, 0, 0)
  pSkp:set_backgroundmode(SKP.OPAQUE)

  if vi:get_rcsmode() == 0 then
    pSkp:text(32, 44, "LIN", 3)
    pSkp:text(96, 44, "ROT", 3)
  elseif vi:get_rcsmode() == 1 then
    pSkp:text(32, 44, "LIN", 3)
  else
    pSkp:text(96, 44, "ROT", 3)
  end

  oapi.release_sketchpad(pSkp)

end
RCS is not meant to be turned off in this context but if you turn it off with the keyboard both lights go out.
 
Back
Top