摘要:Dim x = GetScreenXDim y = GetScreenYDim t = DateTime.Format("%H:%M:%S",time)Traceprint tfile.Write "/sdcard/pictures/点名/config.txt
大家好,我是郭立员~,本文所讲内容仅供学习参考,请勿非法使用。
前言
写了个点名的脚本,并没有全部完成,写到添加名单的时候,发现悬浮窗的点击事件中再次套用点击事件时不太好用,也就懒得继续写了。
看看效果
功能上没啥介绍的就是悬浮窗各种显示、按钮点击事件啥的,直接上代码:
测试设备雷电模拟器,分辨率 720*1280
Dim x = GetScreenXDim y = GetScreenYDim t = DateTime.Format("%H:%M:%S",time)Traceprint tfile.Write "/sdcard/pictures/点名/config.txt", "关闭"Call FW.NewFWindow("浮窗名1", 0, 0, x, y)Call FW.SetPicture("浮窗名1", "/sdcard/pictures/点名/bg.jpg")Call FW.AddTextView("浮窗名1", "时间", t, x*0.4, x*0.9, 500, 200)Call FW.SetTextColor("时间","FFFFFF")Call FW.SetTextSize("时间", 20)Call FW.AddImageView("浮窗名1", "设置", "/sdcard/pictures/点名/设置.png", x * 0.85, x * 0.1, x * 0.1, x * 0.1)Call FW.SetOnClick("设置", 添加名单)Call FW.AddImageView("浮窗名1", "头像", "/sdcard/pictures/点名/头像/1.png", x * 0.5-150, x * 0.5-200, 300, 300)Call FW.AddTextView("浮窗名1", "姓名", "姓名", x * 0.5-80, x * 0.65, 500, 200)Call FW.SetTextSize("姓名", 40)Call FW.SetTextColor("姓名", "FFFFFF")Call FW.NewFWindow("浮窗名2", 0, x, x, y-x)Call FW.SetSmoothing("浮窗名2", 20)Call FW.AddButton("浮窗名2", "按钮", "开始点名", x * 0.05, x * 0.4, x * 0.9, x * 0.12)Call FW.SetBackColor("按钮","d28800")Call FW.SetTextColor("按钮", "FFFFFF")Call FW.SetOnClick("按钮", 点名)Call FW.NewFWindow("浮窗名3", x * 0.05, x * 1.05 , x * 0.43, x * 0.25)Call FW.SetBackColor("浮窗名3", "EEEEEE")Call FW.SetSmoothing("浮窗名3", 20)Call FW.AddTextView("浮窗名3", "总数", "0", x * 0.19, x * 0.05, 500, 200)Call FW.SetTextColor("总数", "d28800")Call FW.SetTextSize("总数", 20)Call FW.AddTextView("浮窗名3", "全部人数", "全部人数", x * 0.13, x * 0.13, 500, 200)Call FW.SetTextColor("全部人数", "AAAAAA")Call FW.NewFWindow("浮窗名4", x * 0.52, x * 1.05 , x * 0.43, x * 0.25)Call FW.SetBackColor("浮窗名4", "EEEEEE")Call FW.SetSmoothing("浮窗名4", 30)Call FW.AddTextView("浮窗名4", "次数", "0", x * 0.19, x * 0.05, 500, 200)Call FW.SetTextColor("次数", "5c52ff")Call FW.SetTextSize("次数", 20)Call FW.AddTextView("浮窗名4", "被抽到", "抽到次数", x * 0.13, x * 0.13, 500, 200)Call FW.SetTextColor("被抽到", "AAAAAA")Call FW.Show("浮窗名1")Call FW.Show("浮窗名2")Call FW.Show("浮窗名3")Call FW.Show("浮窗名4")Call FW.Show("头像")If Dir.Exist("/sdcard/pictures/点名/名单.txt") = 0 Then Dialog.MsgBox("首次使用点击右上角设置\n添加点名的名单",0)End IfDoDelay 20Dim rndNumDim getNum = 0FW.SetTextView( "时间", DateTime.Format("%H:%M:%S",time), x*0.4, x*0.9, 500, 200)Dim arr = file.readlines("/sdcard/pictures/点名/名单.txt")Dim num = len(arr) Call FW.SetTextView("总数", num, x * 0.19, x * 0.05, 500, 200)Dim 开关 = file.read("/sdcard/pictures/点名/config.txt")Dim rndPicIf 开关 = "开始" Then rndPic = int(4*rnd+1)rndNum = arr[int(num*rnd+1)]If UTF8.Len(rndNum) = 2 Then Call FW.SetTextView("姓名", rndNum, x * 0.5 - 80, x * 0.65, 500, 200)Else Call FW.SetTextView("姓名", rndNum, x * 0.45 - 80, x * 0.65, 500, 200)End IfCall FW.SetImageView("头像", "/sdcard/pictures/点名/头像/"&rndPic&".png", x * 0.5-150, x * 0.5-200, 300, 300)ElseIf 开关 = "关闭" ThenIf len(cstr(rndPic)) = 4 Then rndPic = 1End IfDim 结果 = file.read("/sdcard/pictures/点名/结果.txt")If UTF8.Len(结果) = 2 Then Call FW.SetTextView("姓名", 结果, x * 0.5 - 80, x * 0.65, 500, 200)Else Call FW.SetTextView("姓名", 结果, x * 0.45 - 80, x * 0.65, 500, 200)End IfCall FW.SetImageView("头像", "/sdcard/pictures/点名/头像/" & rndPic & ".png", x * 0.5 - 150, x * 0.5 - 200, 300, 300)Dim 次数 = file.read("/sdcard/pictures/点名/次数.txt")Dim tb_ci = Encode.JsonToTable(次数)getNum = tb_ci[结果]Call FW.SetTextView("次数", getNum, x * 0.19, x * 0.05, 500, 200)End IfLoopFunction 添加名单Dim x = GetScreenXDim y = GetScreenYShowMessage "添加名单"Call FW.NewFWindow("名单设置", 0, 0, x, y)Call FW.AddButton("名单设置", "查看", "查看", x*0.11, 150, x*0.18, x*0.18)Call FW.AddButton("名单设置", "添加", "添加", x*0.3, 150, x * 0.18, x*0.18)Call FW.AddButton("名单设置", "替换", "替换", x*0.49, 150, x * 0.18, x*0.18)Call FW.AddButton("名单设置", "清空", "清空", x*0.68, 150, x*0.18, x*0.18)Call FW.SetBackColor("查看", "d28800")Call FW.SetBackColor("添加", "d28800")Call FW.SetBackColor("替换", "d28800")Call FW.SetBackColor("清空", "d28800")Call FW.SetTextColor("查看", "FFFFFF")Call FW.SetTextColor("添加", "FFFFFF")Call FW.SetTextColor("替换", "FFFFFF")Call FW.SetTextColor("清空", "FFFFFF")Call FW.AddTextView("名单设置", "名单列表", "点击查看按钮显示全部名单!", x*0.11, 200+x*0.18, x*0.89, x)Call FW.SetOnClick("查看",查看名单)Call FW.Show("名单设置")End FunctionFunction 点名Dim x = GetScreenXdim ret = FW.GetValue("按钮")If ret["Text"] = "开始点名" Then TracePrint "开始点名"Call FW.SetButton("按钮", "停止点名", x * 0.05, x * 0.4, x * 0.9, x * 0.12)Call FW.SetBackColor("按钮", "5c52ff")file.Write "/sdcard/pictures/点名/config.txt", "开始"End IfIf ret["Text"] = "停止点名" Then TracePrint "停止点名"Call FW.SetButton("按钮", "开始点名", x * 0.05, x * 0.4, x * 0.9, x * 0.12)Call FW.SetBackColor("按钮", "d28800")file.Write "/sdcard/pictures/点名/config.txt", "关闭"Dim arr = file.readlines("/sdcard/pictures/点名/名单.txt")Dim 点名结果 = arr[int(len(arr) *rnd+1)]file.Write "/sdcard/pictures/点名/结果.txt", 点名结果Dim 次数 = file.read("/sdcard/pictures/点名/次数.txt")Dim tb_ci = Encode.JsonToTable(次数)tb_ci[点名结果] = tb_ci[点名结果] +1file.Write("/sdcard/pictures/点名/次数.txt", encode.tabletojson(tb_ci)) End IfEnd FunctionFunction 查看名单TracePrint "待开发"FW.SetTextView("名单列表", "无名单", x*0.11, 200+x*0.18, x*0.89, x)End Function=正文完=
来源:鱼雯小
免责声明:本站系转载,并不代表本网赞同其观点和对其真实性负责。如涉及作品内容、版权和其它问题,请在30日内与本站联系,我们将在第一时间删除内容!