Skip to content

Commit 76be48e

Browse files
author
Not-A-Normal-Robot
committed
anticheat, add grade point counter
1 parent ec078d6 commit 76be48e

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

parts/scenes/main.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ local verName=("%s %s %s"):format(SYSTEM,VERSION.string,VERSION.name)
66
local tipLength=760
77
local tip=gc.newText(getFont(30),"")
88
local scrollX--Tip scroll position
9+
local visibleModes
910

1011
local widgetX0={
1112
-10,-10,-10,-10,
@@ -43,6 +44,18 @@ end)
4344
function scene.sceneInit()
4445
BG.set()
4546

47+
visibleModes={}--1=unlocked, 2=locked but visible
48+
for name,M in next,MODES do
49+
if RANKS[name]and M.x then
50+
visibleModes[name]=1
51+
if M.unlock then
52+
for i=1,#M.unlock do
53+
visibleModes[M.unlock[i]]=visibleModes[M.unlock[i]]or 2
54+
end
55+
end
56+
end
57+
end
58+
4659
--Set tip
4760
tip:set(text.getTip())
4861
scrollX=tipLength
@@ -59,6 +72,7 @@ function scene.sceneInit()
5972
end
6073

6174
function scene.resize()
75+
if not visibleModes[STAT.lastPlay] then STAT.lastPlay='sprint_10l' end
6276
local qpModeName=text.modes[STAT.lastPlay]and text.modes[STAT.lastPlay][1]or"["..STAT.lastPlay.."]"
6377
scene.widgetList[2]:setObject((CHALLENGE==1 or CHALLENGE==8 or CHALLENGE==9) and text.WidgetText.main.reset or text.WidgetText.main.qplay..qpModeName)
6478
scene.widgetList[3]:setObject(CHALLENGE~=0 and text.WidgetText.main.chal or text.WidgetText.main.online)

parts/scenes/mode.lua

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,19 @@ local mapCam={
2525
}
2626
local visibleModes
2727
local touchDist
28+
local totalGrade
29+
local maxGrade
2830

2931
local scene={}
3032

3133
function scene.sceneInit()
34+
totalGrade,maxGrade=0,0
3235
BG.set()
3336
mapCam.zoomK=SCN.prev=='main'and 5 or 1
3437
visibleModes={}--1=unlocked, 2=locked but visible
3538
for name,M in next,MODES do
39+
maxGrade=maxGrade+(M.getRank and 5 or 0)
40+
totalGrade=(RANKS[name] and RANKS[name]>0) and totalGrade+RANKS[name] or totalGrade
3641
if RANKS[name]and M.x then
3742
visibleModes[name]=1
3843
if M.unlock then
@@ -229,6 +234,35 @@ local function _drawModeShape(M,S,drawType)
229234
end
230235
end
231236
function scene.draw()
237+
if CHALLENGE~=0 then
238+
setFont(50)
239+
local percentage=string.format("%.1f", 100*totalGrade/maxGrade).."%, "
240+
local rank=math.min(math.floor(8*totalGrade/maxGrade)+1,8)
241+
local colors={
242+
{.7,.7,.7}, --F [0.00% - 12.5%]
243+
{.63,.52,.65}, --D [12.5% - 25.0%]
244+
{.45,.24,.56}, --C [25.0% - 37.5%]
245+
{.2,.4,.6}, --B [37.5% - 50.0%]
246+
{.6,.85,.65}, --A [50.0% - 62.5%]
247+
{.85,.8,.3}, --S [62.5% - 75.0%]
248+
{.85,.5,.4}, --U [75.0% - 87.5%]
249+
{.85,.3,.8} --X [87.5% - 100%]
250+
}
251+
local letters={
252+
CHAR.icon.rankF,
253+
CHAR.icon.rankD,
254+
CHAR.icon.rankC,
255+
CHAR.icon.rankB,
256+
CHAR.icon.rankA,
257+
CHAR.icon.rankS,
258+
CHAR.icon.rankU,
259+
CHAR.icon.rankX
260+
}
261+
gc_setColor(colors[rank])
262+
local text="[C"..CHALLENGE.."] "..totalGrade.."/"..maxGrade.." ("..percentage..letters[rank]..(totalGrade==maxGrade and "+" or "")..")"
263+
mStr(text,360,20)
264+
end
265+
gc_setColor(1,1,1,1)
232266
local _
233267
gc_push('transform')
234268
gc_translate(640,360)

0 commit comments

Comments
 (0)