| 
 | 
 
 楼主 |
发表于 2019-8-6 14:38:57
|
显示全部楼层
 
 
 
以下是原码,论坛下的公版,我没修改过 
 
function draw_bagwindow() 
    if not flag_win_bag or flag_win_bag~=1 then 
       if win_bag then 
          WindowShow (win_bag, false) 
       end 
       return 
    end 
    if not Bag then 
       return 
    end 
    local _bag_ch = {} 
    local _bag_cn = {} 
    for k,v in pairs(Bag) do 
     if k~='ENCB' then 
        table.insert(_bag_ch,k) 
     end 
    end 
    for i=1,#_bag_ch do 
            table.insert(_bag_cn,Bag[_bag_ch[i]]["cnt"]) 
    end 
if win_bag_show == 0 then 
    WINDOW_HEIGHT = 30 
    WINDOW_WIDTH = 70 
else 
    WINDOW_HEIGHT = (math.ceil(#_bag_ch / 2) + 1)*15+40 
    WINDOW_WIDTH = 190 
end 
    -- Create the window 
--        WindowCreate (win_bag, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_POSITION, 4, 0x000010)  -- create window 
  WindowCreate (win_bag,  
                windowinfo_bag.window_left,  
                windowinfo_bag.window_top,  
                WINDOW_WIDTH,     
                WINDOW_HEIGHT,   
                windowinfo_bag.window_mode,  
                windowinfo_bag.window_flags,  
                0x000010)  
 
        movewindow.save_state (win_bag)           
    -- define the fonts 
        WindowFont (win_bag, "f1", FONT_NAME1, FONT_SIZE_12) 
        WindowFont (win_bag, "f2", FONT_NAME2, FONT_SIZE_11) 
        WindowFont (win_bag, "f3", FONT_NAME1, FONT_SIZE_12, true) 
        WindowFont (win_bag, "f4", FONT_NAME3, FONT_SIZE_11, true) 
        WindowFont (win_bag, "f5", FONT_NAME1, FONT_SIZE_11) 
 
    -- work out how high the font is 
        font_height = WindowFontInfo (win_bag, "f1", 1)   -- height of the font   
 
    -- draw the border of the whole box 
        WindowCircleOp (win_bag, miniwin.circle_round_rectangle, 0, 2, WINDOW_WIDTH-2, WINDOW_HEIGHT, 0xc0c0c0, 0, 1,0, 0, 9, 9)  
 
    -- ensure window visible 
    local head_width   = (WINDOW_WIDTH - WindowTextWidth (win_bag, "f1", "物品列表"))/2 
if win_bag_show == 0 then 
  WindowAddHotspot(win_bag, "bag",   
                   0, 0, 0, 0,  
                   "", -- mouseover (do nothing) 
                   "", -- cancelmouseover (do nothing) 
                   "", 
                   "", -- cancelmousedown (do nothing) 
                   "mouseup", -- mouseup (do nothing) 
                   "点击关闭开启",    -- hint text if they hover over it               
                   0, 0) 
 
    WindowText (win_bag, "f5",  
                "物品列表",   -- text 
                5, 9, 0, 0,        -- rectangle 
                ColourNameToRGB ("yellow"), -- colour 
                false)              -- not Unicode 
else 
  WindowLine (win_bag, 0, font_height + 15,WINDOW_WIDTH-2,font_height + 15,0xc0c0c0, 0,1) 
  movewindow.add_drag_handler (win_bag, 0, 0, 0, font_height + 15) 
  WindowAddHotspot(win_bag, "bag",   
                   0, font_height + 15, 0, 0,  
                   "", -- mouseover (do nothing) 
                   "", -- cancelmouseover (do nothing) 
                   "", 
                   "", -- cancelmousedown (do nothing) 
                   "mouseup", -- mouseup (do nothing) 
                   "点击关闭开启",    -- hint text if they hover over it               
                   0, 0) 
 
    WindowText (win_bag, "f5",  
                "物品列表",   -- text 
                head_width, 9, 0, 0,        -- rectangle 
                ColourNameToRGB ("yellow"), -- colour 
                false)              -- not Unicode 
 
   WindowText (win_bag, "f1",  
               "共"..#_bag_ch.."件物品",   -- text 
                5, 30, 0, 0,        -- rectangle 
                ColourNameToRGB ("white"), -- colour 
                false)              -- not Unicode 
  if Bag["ENCB"].value then 
   WindowText (win_bag, "f1",  
               "负重".. Bag["ENCB"].value .."%",   -- text 
                100, 30, 0, 0,        -- rectangle 
                ColourNameToRGB ("white"), -- colour 
                false)              -- not Unicode 
 
  end 
    for i = 1,#_bag_ch do 
            if _bag_ch[i] == "" or _bag_ch[i] == nil then 
                _bag_ch[i] = "数据丢失"  
            end 
            if _bag_ch[i] == "" or _bag_ch[i] == nil then 
                _basic[i] = "数据丢失" 
            end 
                 
        local txt2 = _bag_ch[i].." *".._bag_cn[i] 
        local _high = math.ceil(i/2)*15 + 30 
    if i/2 < math.ceil(i/2) then 
      WindowText (win_bag, "f1",  
                    txt2,   -- text 
                    5, _high, 0, 0,        -- rectangle 
                --  ColourNameToRGB (_colour), -- colour 
                                 ColourNameToRGB ("green"), -- colour 
                    false)              -- not Unicode 
    else 
      WindowText (win_bag, "f1",  
                    txt2,   -- text 
                    95+5, _high, 0, 0,        -- rectangle 
                --  ColourNameToRGB (_colour), -- colour 
                                 ColourNameToRGB ("green"), -- colour 
                    false)              -- not Unicode 
    end         
        end 
end 
if flag_win_bag and flag_win_bag==1 then 
           WindowShow (win_bag, true) 
else 
           WindowShow (win_bag, false) 
end 
end 
 |   
 
 
 
 |