• Print

Author Topic: ULib.Menu -- What to do?  (Read 12 times)

0 Members and 1 Guest are viewing this topic.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
ULib.Menu -- What to do?
« on: October 08, 2006, 09:02:00 pm »
I must say, I'm not proud of the code for ULib.Menu. I feel that it's lacking in code clarity as well as efficiency... I'm tempted to completely recode it.

The bug spbogie found is not the only one in there... here's some other ones (not as big, at least, but still problems)

BUG 1: This code block
[lua]   local next_page = offset + pageopts + 1
   if page == 1 then next_page = next_page + 1 end
   if self.options[ next_page ] then -- If there's a next page
      page_options[ pageopts + 2 ] = { text=self.skin.next, id=ULib.ID_NEXT }
   elseif page > 1 and self.options[ offset + pageopts + 1 ] then --TODO: What was this for? It never gets called.
      page_options[ pageopts + 2 ] = page_options[ pageopts + 1 ] -- Switch places so it looks smooth
      page_options[ pageopts + 1 ] = self.options[ offset + pageopts + 1 ]
   end[/lua]
As you can see, the elseif statement is never called because the if statement is called first. I think I was using this to display an extra option on the last page, and the code got mangled somehow.

BUG 2: The timeout for the playeroptions hook is reset when the player chooses an invalid option, but it's reset to the original value. It's possible that the menu could fade and the user's number keys would still be hooked.

BUG 3: The callback function is not called on a timeout. This is easy enough to fix with a timer, but important to free resources.

BUG 4: The spbogie-discovered bug discussed here


Experiencing God's grace one day at a time.

  • Print