<commit_before>package.path = package.path 
--  .. ";/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs/?.lua"
--  .. ";/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs/?/?.lua"

.. ";C:\\Program Files (x86)\\ZeroBraneStudio\\lualibs\\?.lua"
.. ";C:\\Program Files (x86)\\ZeroBraneStudio\\lualibs\\?\\?.lua"

package.cpath = package.cpath 
--  .. ";/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/?.dylib"
--  .. ";/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/socket/?.dylib"

.. ";C:\\Program Files (x86)\\ZeroBraneStudio\\bin\\clibs53\\?.dll"
.. ";C:\\Program Files (x86)\\ZeroBraneStudio\\bin\\clibs53\\socket\\?.dll"

require('mobdebug').start()

print("main");

--UI stuff
if(ui ~= nil) then

  ui.UP     = 0
  ui.RIGHT  = 1
  ui.DOWN   = 2
  ui.LEFT   = 3
  ui.OK     = 4
  ui.CANCEL = 5
  ui.ESC    = 6

  ui.windows = {};
  ui.addWindow = function(x, y, w, h)

    local newWindow = {x=x, y=y, w=w, h=h}
    newWindow.margins = {x=12, y=0}
    newWindow.menuItems = {}
    newWindow.currMenuItem = 1    

    newWindow.addMenuItem = function(text, callback)

      local newMenuItem = {text=text, callback=callback}

      table.insert(newWindow.menuItems, newMenuItem)
      return newMenuItem
    end


    table.insert(ui.windows, newWindow)
    return newWindow

  end

  ui.update = function(button)

    if #ui.windows == 0 then

      if button == ui.ESC then

        ui.openMenu()
        return true

      end

    else
      local topWindowIndex = #ui.windows;
      local topWindow = ui.windows[topWindowIndex]

      if button == ui.UP then
        topWindow.currMenuItem = math.max(1, topWindow.currMenuItem - 1) 

      elseif button == ui.RIGHT then

      elseif button == ui.DOWN then
        topWindow.currMenuItem = math.min(#topWindow.menuItems, topWindow.currMenuItem + 1) 

      elseif button == ui.LEFT then

      elseif button == ui.OK then
        if topWindow.menuItems[topWindow.currMenuItem].callback ~= nil then
          topWindow.menuItems[topWindow.currMenuItem].callback()
        end

      elseif button == ui.CANCEL then
        table.remove(ui.windows, topWindowIndex)

      elseif button == ui.ESC then

        ui.closeMenu()

      end

      return true
    end

    return false
  end

  ui.render = function()

    for i, window in ipairs(ui.windows) do
      ui.renderWindow(window.x, window.y, window.w, window.h)

      for i, menuItem in ipairs(window.menuItems) do

        local x = window.x + window.margins.x
        local y = window.y + window.margins.x

        if (window.currMenuItem == i) then
          ui.renderMenuItem('-' .. menuItem.text, x, y +((i-1)* 8));
        else
          ui.renderMenuItem(menuItem.text, x, y +((i-1)* 8));
        end


      end

    end

  end

  ui.openMenu = function()

    local win2 = ui.addWindow(16, 16, 8, 8)

    win2.addMenuItem("equip", function() 


        local win3 = ui.addWindow(20, 20, 8, 8)

        win3.addMenuItem("LOL", function() print('show equip menu') end)
        win3.addMenuItem("LOL2", function() print('show equip menu') end)
        win3.addMenuItem("LOL3", function() print('show equip menu') end)


      end
    )
    win2.addMenuItem("status", function() print('show equip menu') end)
    win2.addMenuItem("close", function() ui.closeMenu() end)

  end

  ui.closeMenu = function()
    print('close menu')  
    ui.windows = {}
  end



end




print('main - ok');<commit_msg>ザ☆ぼんおどり<commit_after>package.path = package.path 
--  .. ";/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs/?.lua"
--  .. ";/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs/?/?.lua"

.. ";C:\\Program Files (x86)\\ZeroBraneStudio\\lualibs\\?.lua"
.. ";C:\\Program Files (x86)\\ZeroBraneStudio\\lualibs\\?\\?.lua"

package.cpath = package.cpath 
--  .. ";/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/?.dylib"
--  .. ";/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/socket/?.dylib"

.. ";C:\\Program Files (x86)\\ZeroBraneStudio\\bin\\clibs53\\?.dll"
.. ";C:\\Program Files (x86)\\ZeroBraneStudio\\bin\\clibs53\\socket\\?.dll"

require('mobdebug').start()

print("main");


--************************
--Window
--************************
Window = {}
Window.__index = Window

function Window.new(x, y, w, h)
  local win = {}
  setmetatable(win, Window)
  win.x = x 
  win.y = y 
  win.w = w 
  win.h = h 
  win.margins = {x=12, y=0}
  win.menuItems = {}
  win.currMenuItem = 1  

  return win
end

function Window:addMenuItem(newMenuItem)

  --local newMenuItem = {text=text, callback=callback}

  table.insert(self.menuItems, newMenuItem)
  --return newMenuItem
end

function Window:render()

  ui.renderWindow(self.x, self.y, self.w, self.h)

  for i, menuItem in ipairs(self.menuItems) do

    local x = self.x + self.margins.x
    local y = self.y + self.margins.x

    if (self.currMenuItem == i) then
      ui.renderMenuItem('-' .. menuItem.text, x, y +((i-1)* 8));
    else
      ui.renderMenuItem(menuItem.text, x, y +((i-1)* 8));
    end


  end

end

--************************
--MenuItem
--************************
MenuItem = {}
MenuItem.__index = MenuItem

function MenuItem.new(text, callback)
  local menuItem = {}
  setmetatable(menuItem, MenuItem)
  menuItem.text = text
  menuItem.callback = callback  

  return menuItem
end



--UI stuff
if(ui ~= nil) then

  ui.UP     = 0
  ui.RIGHT  = 1
  ui.DOWN   = 2
  ui.LEFT   = 3
  ui.OK     = 4
  ui.CANCEL = 5
  ui.ESC    = 6

  ui.windows = {};
  ui.addWindow = function(newWindow)

    table.insert(ui.windows, newWindow)

  end

  ui.update = function(button)

    if #ui.windows == 0 then

      if button == ui.ESC then

        ui.openMenu()
        return true

      end

    else
      local topWindowIndex = #ui.windows;
      local topWindow = ui.windows[topWindowIndex]

      if button == ui.UP then
        topWindow.currMenuItem = math.max(1, topWindow.currMenuItem - 1) 

      elseif button == ui.RIGHT then

      elseif button == ui.DOWN then
        topWindow.currMenuItem = math.min(#topWindow.menuItems, topWindow.currMenuItem + 1) 

      elseif button == ui.LEFT then

      elseif button == ui.OK then
        if topWindow.menuItems[topWindow.currMenuItem].callback ~= nil then
          topWindow.menuItems[topWindow.currMenuItem].callback()
        end

      elseif button == ui.CANCEL then
        table.remove(ui.windows, topWindowIndex)

      elseif button == ui.ESC then

        ui.closeMenu()

      end

      return true
    end

    return false
  end

  ui.render = function()

    for i, window in ipairs(ui.windows) do

      window:render()

    end

  end

  ui.openMenu = function()

    local win = Window.new(16, 16, 8, 8)

    local menuItem1 = MenuItem.new("equip", function() 

        local win = Window.new(32, 32, 8, 8)

        local menuItem1 = MenuItem.new("lol1", function() print('show equip menu') end)
        local menuItem2 = MenuItem.new("lol2", function() print('show equip menu') end)
        local menuItem3 = MenuItem.new("lol3", function() print('show equip menu') end)

        win:addMenuItem(menuItem1)
        win:addMenuItem(menuItem2)
        win:addMenuItem(menuItem3)

        ui.addWindow(win)

      end
    )
    local menuItem2 = MenuItem.new("status", function() print('show equip menu') end)
    local menuItem3 = MenuItem.new("save", function() print('show save menu') end)
    local menuItem4 = MenuItem.new("quit", function() print('show quit menu') end)


    win:addMenuItem(menuItem1)
    win:addMenuItem(menuItem2)
    win:addMenuItem(menuItem3)
    win:addMenuItem(menuItem4)


    ui.addWindow(win)

  end

  ui.closeMenu = function()
    print('close menu')  
    ui.windows = {}
  end



end




print('main - ok');
{'fraction_non_alphanumeric': 0.1529936305732484, 'fraction_numerical': 0.015414012738853504, 'mean_word_length': 2.643155452436195, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4090287', 'n_tokens_mistral': 2829, 'n_tokens_neox': 2617, 'n_words': 564}