PC Shell interface

Started by BAD_AL, July 15, 2020, 12:19:05 PM

Previous topic - Next topic
July 15, 2020, 12:19:05 PM Last Edit: July 15, 2020, 02:41:33 PM by BAD_AL
I've always preferred the Console interface (up,down,left,right,a,b) to the PC's forced mouse and keyboard use.
I feel it's just faster to use the buttons(up,down,left,right,accept,back).

Also, with the possibility of playing the game under a WindowsXP Virtual Machines or Wine on various mobile platforms, I think it would be good to have a console style interface option on the PC version of the game.

Looking into the feasibility of this led me to discover the following functions on the shell screens:
[spoiler]
   Input_Accept = function(this) ...
   Input_Back = function(this)  ...
   Input_GeneralLeft = function(this,bFromAI) ...
   Input_GeneralRight = function(this,bFromAI) ...
   Input_GeneralUp = function(this,bFromAI) ...
   Input_GeneralDown = function(this,bFromAI) ...
[/spoiler]
These functions receive (and process) the events from the Up, down,left,right,accept,back buttons.
The screen where I spend the most (annoying) time moving the mouse around is the character select screen ( ingame.lvl 'ifs_charselect.lua').
But there's a problem. Looking at the source code we get the following message/comment:
[spoiler]
ifs_charselect1 = NewIFShellScreen {
   nologo = 1,
   bDimBackdrop = 1,
   -- Actual contents are created in ifs_charselect_fnBuildScreen

   -- Note: for now, the exe is handling all the inputs/events, so this
   -- screen has no Enter/Exit/Update/Input handlers.
It does have an
   -- Input_Back handler to override the base class's default functionality
   -- (go to previous screen)

   Input_Back = function(this)
   end,
   Input_GeneralLeft = function(this,bFromAI)
   end,
   Input_GeneralRight = function(this,bFromAI)
   end,
   Input_GeneralUp = function(this,bFromAI)
   end,
   Input_GeneralDown = function(this,bFromAI)
   end,
}
[/spoiler]
Which makes it sound like for this screen, we cannot process the up,down,left,right,b buttons in the lua code.

When putting print statements in these functions, I never saw output and got kinda bummed.
Anyone else try this with success on this screen? (hoping I just messed something up in my testing)
Is there more to the puzzle that someone else is aware of?

In the PC version, ifs_charselect is not used. It uses ifs_pc_spawnselect which ties into hard coded exe stuff. Lots of people have messed with ifs_pc_spawnselect over time and all anyone has accomplished is changing the sizes and locations of things.
Never let a person named AnthonyBF2 touch your BF2.

Ok, that explains why I didn't see anything print out :)

I switched to print out stuff in the input functions on 'ifs_pc_spawnselect' and am able to see print output now :)
I'm trying to print out what 'this' is in the context of those functions in order to get at the buttons on the screen but have only been able to print out a partial for some reason.
Here's the screen info I was able to extract:
[spoiler]
{
   cancelSound = "shell_menu_cancel",
   fnPostError = "function: 061D40A8",
   Input_GeneralDown = "function: 061D7138",
   HandleMouse = "function: 061D41B0",
   enterSound = "",
   Leave = "function: 061D4180",
   acceptSound = "shell_menu_accept",
   BotInfo = {
     type = "container",
     inert = "1",
     y = "0",
     x = "0",
     cp = "userdata: 07D87AC0",
     ScreenRelativeX = "1",
     ScreenRelativeY = "1"
   },
   Input_GeneralUp = "function: 061D7120",
   exitSound = "shell_menu_exit",
   Input_Back = "function: 061D70D8",
   errorSound = "shell_menu_error",
   nextFlashyTime = "17.252716064453",
   nologo = "1",
   type = "screen",
   Info = {
     SlotWindow6 = {
      titleBarElement = {
        startdelay = "0",
        type = "text",
        flashy = "1",
        cp = "userdata: 07D87D10"
      },
      onTexture = "btn_on_pieces",
      skin = {
        cp = "userdata: 07D88140",
        type = "border",
        ZPos = "135"
      },
      x = "100.80000305176",
      buttonHeightPad = "1",
      type = "buttonwindow",
      InfoText = {
        startdelay = "0",
        cp = "userdata: 07D8ャ・qテ{
[/spoiler]
Looks like the string somehow got corrupted at the end.
Perhaps someone has a better 'print_table' function?
I'm using this one (which returns a big string):
[spoiler]
-- from http://lua-users.org/wiki/TableSerialization
function table_print (tt, indent, done)
  done = done or {}
  indent = indent or 0
  if type(tt) == "table" then
    local sb = {}
    for key, value in pairs (tt) do
      table.insert(sb, string.rep (" ", indent)) -- indent it
      if type (value) == "table" and not done [value] then
        done [value] = true
        table.insert(sb, key .. " = {\n");
        table.insert(sb, table_print (value, indent + 2, done))
        table.insert(sb, string.rep (" ", indent)) -- indent it
        table.insert(sb, "}\n");
      elseif "number" == type(key) then
        table.insert(sb, string.format("\"%s\"\n", tostring(value)))
      else
        table.insert(sb, string.format(
            "%s = \"%s\"\n", tostring (key), tostring(value)))
       end
    end
    return table.concat(sb)
  else
    return tt .. "\n"
  end
end

function to_string( tbl )
    if  "nil"       == type( tbl ) then
        return tostring(nil)
    elseif  "table" == type( tbl ) then
        return table_print(tbl)
    elseif  "string" == type( tbl ) then
        return tbl
    else
        return tostring(tbl)
    end
end
[/spoiler]