|
本帖最后由 jy02785317 于 2010-8-18 11:11 编辑
避开广告
避开广告
避开广告
避开广告
避开广告
避开广告
避开广告
避开广告
避开广告
避开广告
避开广告
避开广告
避开广告- function SelectThing(thing,thingnum) --显示物品菜单
- local xnum=CC.MenuThingXnum;
- local ynum=CC.MenuThingYnum;
- local w=CC.ThingPicWidth*xnum+(xnum-1)*CC.ThingGapIn+2*CC.ThingGapOut; --总体宽度
- local h=CC.ThingPicHeight*ynum+(ynum-1)*CC.ThingGapIn+2*CC.ThingGapOut; --物品栏高度
- local dx=(CC.ScreenW-w)/2;
- local dy=(CC.ScreenH-h-2*(CC.ThingFontSize+2*CC.MenuBorderPixel+5))/2-50;
- local y1_1,y1_2,y2_1,y2_2,y3_1,y3_2; --名称,说明和图片的Y坐标
- local cur_line=0;
- local cur_x=0;
- local cur_y=0;
- local cur_thing=-1;
- while true do
- Cls();
- y1_1=dy;
- y1_2=y1_1+CC.ThingFontSize+2*CC.MenuBorderPixel;
- DrawBox(dx,y1_1,dx+w,y1_2,C_WHITE);
- y2_1=y1_2+5
- y2_2=y2_1+CC.ThingFontSize+2*CC.MenuBorderPixel
- DrawBox(dx,y2_1,dx+w,y2_2,C_WHITE);
- y3_1=y2_2+5;
- y3_2=y3_1+h;
- DrawBox(dx,y3_1,dx+w,y3_2,C_WHITE);
- for y=0,ynum-1 do
- for x=0,xnum-1 do
- local id=y*xnum+x+xnum*cur_line --当前待选择物品
- local boxcolor;
- if x==cur_x and y==cur_y then
- boxcolor=C_WHITE;
- if thing[id]>=0 then
- cur_thing=thing[id];
- local str=JY.Thing[thing[id]]["名称"];
- if JY.Thing[thing[id]]["类型"]==1 or JY.Thing[thing[id]]["类型"]==2 then
- if JY.Thing[thing[id]]["使用人"] >=0 then
- str=str .. "(" .. JY.Person[JY.Thing[thing[id]]["使用人"]]["姓名"] .. ")";
- end
- end
- str=string.format("%s X %d",str,thingnum[id]);
- local str2=JY.Thing[thing[id]]["物品说明"];
- DrawString(dx+CC.ThingGapOut,y1_1+CC.MenuBorderPixel,str,C_GOLD,CC.ThingFontSize);
- DrawString(dx+CC.ThingGapOut,y2_1+CC.MenuBorderPixel,str2,C_ORANGE,CC.ThingFontSize);
- local myfont=math.modf(CC.ThingFontSize*0.7)--20
- local mx,my=dx+4*myfont,y3_2+2--130,365
- local myflag=0
- local myThing=JY.Thing[thing[id]]
- local function drawitem(ss,str,news)
- local mys
- if str==nil then
- mys=ss
- elseif myThing[ss]~=0 then
- if news==nil then
- if myflag==0 then
- mys=string.format(str..':%+d',myThing[ss])
- elseif myflag==1 then
- mys=string.format(str..':%d',myThing[ss])
- end
- else
- if myThing[ss]<0 then
- return
- end
- mys=string.format(str..':%s',news[myThing[ss]])
- end
- else
- return
- end
- local mylen=myfont*string.len(mys)/2+12
- if mx+mylen>CC.ScreenW-dx then
- my=my+myfont+10
- mx=dx+4*myfont
- end
- DrawStrBox(mx,my,mys,C_GOLD,myfont)
- mx=mx+mylen
- end
- if myThing['练出武功']>0 then
- local kfname='习得:'..JY.Wugong[myThing['练出武功']]['名称']
- DrawStrBox(mx,my,kfname,C_GOLD,myfont)
- mx=mx+myfont*string.len(kfname)/2+12
- end
- if myThing['类型']>0 then
- drawitem('加生命','生命')
- drawitem('加生命最大值','生命最值')
- drawitem('加中毒解毒','中毒')
- drawitem('加体力','体力')
- if myThing['改变内力性质']==2 then
- drawitem('内力门路阴阳合一')
- end
- drawitem('加内力','内力')
- drawitem('加内力最大值','内力最值')
- drawitem('加攻击力','攻击')
- drawitem('加轻功','轻功')
- drawitem('加防御力','防御')
- drawitem('加医疗能力','医疗')
- drawitem('加用毒能力','用毒')
- drawitem('加解毒能力','解毒')
- drawitem('加抗毒能力','抗毒')
- drawitem('加拳掌功夫','拳掌')
- drawitem('加御剑能力','御剑')
- drawitem('加耍刀技巧','耍刀')
- drawitem('加特殊兵器','特殊')
- drawitem('加暗器技巧','暗器')
- drawitem('加武学常识','武常')
- drawitem('加品德','品德')
- drawitem('加攻击次数','左右',{[0]='否','是'})
- drawitem('加攻击带毒','带毒')
- if mx~=dx or my~=y3_2+2 then
- DrawStrBox(dx,y3_2+2,' 效果:',C_RED,myfont)
- end
- end
- if myThing['类型']==1 or myThing['类型']==2 then
- if mx~=dx then
- mx=dx+4*myfont
- my=my+myfont+10
- end
- myflag=1
- local my2=my
- if myThing['仅修炼人物']>-1 then
- --drawitem('仅修炼人物','仅限',{[myThing['仅修炼人物']]=JY.Person[myThing['仅修炼人物']]['姓名']})
- drawitem('仅限:'..JY.Person[myThing['仅修炼人物']]['姓名'])
- end
- drawitem('需内力性质','阴阳',{[0]='阴','阳','不限'})
- drawitem('需内力','内力')
- drawitem('需攻击力','攻击')
- drawitem('需轻功','轻功')
- drawitem('需用毒能力','用毒')
- drawitem('需医疗能力','医疗')
- drawitem('需解毒能力','解毒')
- drawitem('需拳掌功夫','拳掌')
- drawitem('需御剑能力','御剑')
- drawitem('需耍刀技巧','耍刀')
- drawitem('需特殊兵器','特殊')
- drawitem('需暗器技巧','暗器')
- drawitem('需资质','资质')
- drawitem('需经验','修炼经验')
- if mx~=dx or my~=my2 then
- DrawStrBox(dx,my2,' 需求:',C_RED,myfont)
- end
- end
- else
- cur_thing=-1;
- end
- else
- boxcolor=C_BLACK;
- end
- local boxx=dx+CC.ThingGapOut+x*(CC.ThingPicWidth+CC.ThingGapIn);
- local boxy=y3_1+CC.ThingGapOut+y*(CC.ThingPicHeight+CC.ThingGapIn);
- lib.DrawRect(boxx,boxy,boxx+CC.ThingPicWidth+1,boxy+CC.ThingPicHeight+1,boxcolor);
- if thing[id]>=0 then
- if CC.LoadThingPic==1 then
- lib.PicLoadCache(2,thing[id]*2,boxx+1,boxy+1,1);
- else
- lib.PicLoadCache(0,(thing[id]+CC.StartThingPic)*2,boxx+1,boxy+1,1);
- end
- end
- end
- end
- ShowScreen();
- local keypress=WaitKey();
- lib.Delay(100);
- if keypress==VK_ESCAPE then
- cur_thing=-1;
- break;
- elseif keypress==VK_RETURN or keypress==VK_SPACE then
- break;
- elseif keypress==VK_UP then
- if cur_y == 0 then
- if cur_line > 0 then
- cur_line = cur_line - 1;
- end
- else
- cur_y = cur_y - 1;
- end
- elseif keypress==VK_DOWN then
- if cur_y ==ynum-1 then
- if cur_line < (math.modf(200/xnum)-ynum) then
- cur_line = cur_line + 1;
- end
- else
- cur_y = cur_y + 1;
- end
- elseif keypress==VK_LEFT then
- if cur_x > 0 then
- cur_x=cur_x-1;
- else
- cur_x=xnum-1;
- end
- elseif keypress==VK_RIGHT then
- if cur_x ==xnum-1 then
- cur_x=0;
- else
- cur_x=cur_x+1;
- end
- end
- end
- Cls();
- return cur_thing;
- end
复制代码 选择到物品时,显示物品的使用效果和需求,在各种分辨率下均可正常显示
下面是图
|
|