Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
qaqFei committed Oct 25, 2024
1 parent 2577851 commit 93e3bf9
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 157 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/ppr-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: PhigrosPlayer Auto Build

on:
push:
branches: [ "main" ]

jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- name: py3.12
uses: actions/setup-python@v3
with:
python-version: 3.12

- name: build
run: |
cd src
python tool-compile.py -y --zip
- name: upload
uses: actions/upload-artifact@v4
with:
path: ${{ github.workspace }}/compile_result.zip
30 changes: 15 additions & 15 deletions src/phicore.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ def draw_ui(

root.run_js_code(
f"ctx.drawUIText(\
'{root.process_code_string_syntax_tostring(score)}',\
'{root.string2cstring(score)}',\
{w * 0.988 + scoreUI_dx},\
{h * (58 / 1080) + scoreUI_dy},\
{scoreUI_rotate},\
Expand All @@ -733,7 +733,7 @@ def draw_ui(
if rtacc:
root.run_js_code(
f"ctx.drawUIText(\
'{root.process_code_string_syntax_tostring(acc)}',\
'{root.string2cstring(acc)}',\
{w * 0.988 + scoreUI_dx},\
{h * (58 / 1080) + (w + h) / 145 / 0.75 * 1.5 + scoreUI_dy},\
{scoreUI_rotate},\
Expand All @@ -749,7 +749,7 @@ def draw_ui(
if combo_state:
root.run_js_code(
f"ctx.drawUIText(\
'{root.process_code_string_syntax_tostring(f"{combo}")}',\
'{root.string2cstring(f"{combo}")}',\
{w / 2 + combonumberUI_dx},\
{h * 0.05 + combonumberUI_dy},\
{combonumberUI_rotate},\
Expand All @@ -764,7 +764,7 @@ def draw_ui(

root.run_js_code(
f"ctx.drawUIText(\
'{root.process_code_string_syntax_tostring(combotips)}',\
'{root.string2cstring(combotips)}',\
{w / 2 + comboUI_dx},\
{h * 0.095 + comboUI_dy},\
{comboUI_rotate},\
Expand Down Expand Up @@ -794,7 +794,7 @@ def draw_ui(

root.run_js_code(
f"ctx.drawUIText(\
'{root.process_code_string_syntax_tostring(chart_information["Name"])}',\
'{root.string2cstring(chart_information["Name"])}',\
{w * 0.0125 + nameUI_dx},\
{h * 0.976 - (w + h) / 125 / 0.75 / 2 + nameUI_dy},\
{nameUI_rotate},\
Expand All @@ -809,7 +809,7 @@ def draw_ui(

root.run_js_code(
f"ctx.drawUIText(\
'{root.process_code_string_syntax_tostring(chart_information["Level"])}',\
'{root.string2cstring(chart_information["Level"])}',\
{w * 0.9875 + levelUI_dx},\
{h * 0.976 - (w + h) / 125 / 0.75 / 2 + levelUI_dy},\
{levelUI_rotate},\
Expand Down Expand Up @@ -1366,7 +1366,7 @@ def GetFrameRenderTask_Rpe(now_t:float, clear: bool = True, rjc: bool = True):
Task(
root.run_js_code,
f"ctx.drawRotateText(\
'{root.process_code_string_syntax_tostring(lineText)}',\
'{root.string2cstring(lineText)}',\
{linePos[0]},\
{linePos[1]},\
{lineRotate},\
Expand Down Expand Up @@ -1949,19 +1949,19 @@ def Begin_Animation(clear: bool = True, fcb: typing.Callable[[], typing.Any] = l
animation_time = 4.5

chart_name_text = chart_information["Name"]
chart_name_text_width_1px = root.run_js_code(f"ctx.font='50px PhigrosFont'; ctx.measureText({root.process_code_string_syntax_tocode(chart_name_text)}).width;") / 50
chart_name_text_width_1px = root.run_js_code(f"ctx.font='50px PhigrosFont'; ctx.measureText({root.string2sctring_hqm(chart_name_text)}).width;") / 50
chart_level_number = Get_LevelNumber()
chart_level_number_width_1px = root.run_js_code(f"ctx.font='50px PhigrosFont'; ctx.measureText({root.process_code_string_syntax_tocode(chart_level_number) if len(chart_level_number) >= 2 else "'00'"}).width;") / 50
chart_level_number_width_1px = root.run_js_code(f"ctx.font='50px PhigrosFont'; ctx.measureText({root.string2sctring_hqm(chart_level_number) if len(chart_level_number) >= 2 else "'00'"}).width;") / 50
if len(chart_level_number) == 1:
chart_level_number_width_1px /= 1.35
chart_level_text = Get_LevelText()
chart_level_text_width_1px = root.run_js_code(f"ctx.font='50px PhigrosFont'; ctx.measureText({root.process_code_string_syntax_tocode(chart_level_text) if len(chart_level_text) >= 2 else "'00'"}).width;") / 50
chart_level_text_width_1px = root.run_js_code(f"ctx.font='50px PhigrosFont'; ctx.measureText({root.string2sctring_hqm(chart_level_text) if len(chart_level_text) >= 2 else "'00'"}).width;") / 50
chart_artist_text = chart_information["Artist"]
chart_artist_text_width_1px = root.run_js_code(f"ctx.font='50px PhigrosFont'; ctx.measureText({root.process_code_string_syntax_tocode(chart_artist_text)}).width;") / 50
chart_artist_text_width_1px = root.run_js_code(f"ctx.font='50px PhigrosFont'; ctx.measureText({root.string2sctring_hqm(chart_artist_text)}).width;") / 50
chart_charter_text = chart_information["Charter"]
chart_charter_text_width_1px = root.run_js_code(f"ctx.font='50px PhigrosFont'; ctx.measureText({root.process_code_string_syntax_tocode(chart_charter_text)}).width;") / 50
chart_charter_text_width_1px = root.run_js_code(f"ctx.font='50px PhigrosFont'; ctx.measureText({root.string2sctring_hqm(chart_charter_text)}).width;") / 50
chart_illustrator_text = chart_information["Illustrator"]
chart_illustrator_text_width_1px = root.run_js_code(f"ctx.font='50px PhigrosFont'; ctx.measureText({root.process_code_string_syntax_tocode(chart_illustrator_text)}).width;") / 50
chart_illustrator_text_width_1px = root.run_js_code(f"ctx.font='50px PhigrosFont'; ctx.measureText({root.string2sctring_hqm(chart_illustrator_text)}).width;") / 50
tip = phi_tips.get_tip()
tip_font_size = w * 0.020833 / 1.25
infoframe_x = w * 0.095
Expand Down Expand Up @@ -2053,9 +2053,9 @@ def initFinishAnimation():
MaxCombo = chart_obj.note_num if not noautoplay else PhigrosPlayManagerObject.getMaxCombo()
AccString = f"{(Acc * 100):.2f}%"
ChartNameString = chart_information["Name"]
ChartNameStringFontSize = w * im_size * 0.65 / (root.run_js_code(f"ctx.font='50px PhigrosFont'; ctx.measureText({root.process_code_string_syntax_tocode(ChartNameString)}).width;") / 50)
ChartNameStringFontSize = w * im_size * 0.65 / (root.run_js_code(f"ctx.font='50px PhigrosFont'; ctx.measureText({root.string2sctring_hqm(ChartNameString)}).width;") / 50)
ChartLevelString = chart_information["Level"]
ChartLevelStringFontSize = w * im_size * 0.25 / (root.run_js_code(f"ctx.font='50px PhigrosFont'; ctx.measureText({root.process_code_string_syntax_tocode(ChartLevelString)}).width;") / 50)
ChartLevelStringFontSize = w * im_size * 0.25 / (root.run_js_code(f"ctx.font='50px PhigrosFont'; ctx.measureText({root.string2sctring_hqm(ChartLevelString)}).width;") / 50)
if ChartNameStringFontSize > w * 0.0275:
ChartNameStringFontSize = w * 0.0275
if ChartLevelStringFontSize > w * 0.0275 * 0.5:
Expand Down
14 changes: 7 additions & 7 deletions src/phigame_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def getBarWidth(self):
st = self.aSTime
et = self.aSTime + self.atime
p = (time.time() - st) / (et - st)
p = tool_funcs.fixOutofRangeP(p)
p = tool_funcs.fixorp(p)
p = self._ease_slow(p)
return p * (ev - sv) + sv

Expand All @@ -212,7 +212,7 @@ def getLabelWidth(self):
st = self.aSTime
et = self.aSTime + self.atime
p = (time.time() - st) / (et - st)
p = tool_funcs.fixOutofRangeP(p)
p = tool_funcs.fixorp(p)
p = self._ease_fast(p)
return p * (ev - sv) + sv

Expand All @@ -224,7 +224,7 @@ def getLabelX(self):
st = self.aSTime
et = self.aSTime + self.atime
p = (time.time() - st) / (et - st)
p = tool_funcs.fixOutofRangeP(p)
p = tool_funcs.fixorp(p)
p = self._ease_slow(p)
return p * (ev - sv) + sv

Expand All @@ -243,7 +243,7 @@ def getTextColor(self, t: int):
st = self.aSTime
et = self.aSTime + self.atime
p = (time.time() - st) / (et - st)
p = tool_funcs.fixOutofRangeP(p)
p = tool_funcs.fixorp(p)

# 这里奇怪的算法: 为了视觉上好看和还原一点
absv = abs(self.aFrom - self.aTo) if self.aFrom != self.aTo else 1.0
Expand All @@ -265,7 +265,7 @@ def getTextScale(self, t: int):
st = self.aSTime
et = self.aSTime + self.atime
p = (time.time() - st) / (et - st)
p = tool_funcs.fixOutofRangeP(p)
p = tool_funcs.fixorp(p)
p = self._ease_slow(p)

return tool_funcs.linear_interpolation(p, 0.0, 1.0, 1.175, 1.0) if self.aFrom == t else tool_funcs.linear_interpolation(p, 0.0, 1.0, 1.0, 1.175)
Expand All @@ -278,7 +278,7 @@ def getShadowRect(self):
st = self.aSTime
et = self.aSTime + self.atime
p = (time.time() - st) / (et - st)
p = tool_funcs.fixOutofRangeP(p)
p = tool_funcs.fixorp(p)
p = self._ease_slow(p)
return (
p * (ev[0] - sv[0]) + sv[0],
Expand Down Expand Up @@ -308,7 +308,7 @@ def render(
st = self.aSTime
et = self.aSTime + self.atime
p = (time.time() - st) / (et - st) if self.aSTime != float("-inf") else 1.0
p = tool_funcs.fixOutofRangeP(p)
p = tool_funcs.fixorp(p)
p = self._ease_slow(p)

drawPlaySettingDx = self.getSettingDx(shadowRectLeft, w, const.PHIGROS_SETTING_STATE.PLAY)
Expand Down
File renamed without changes.
File renamed without changes
27 changes: 24 additions & 3 deletions src/tool-compile.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from threading import Thread
from os import system
from os import system, mkdir
from os.path import isfile
from sys import argv
from shutil import copy, copytree

system("cls")

if input("Sure? (y/n) ").lower() not in ("yes", "y"):
raise SystemExit
if "-y" not in argv:
if input("Sure? (y/n) ").lower() not in ("yes", "y"):
raise SystemExit

def compile(file:str, hideconsole:bool):
system(f"{pyi_makespec} \"{file}\" -i icon.ico {"-w" if hideconsole and not debug else ""}")
Expand All @@ -23,6 +26,13 @@ def compile(file:str, hideconsole:bool):
("gui_launcher.py", False),
("phigros.py", False)
]
res_files = [
"_internal",
"web_canvas.html",
"7z.exe", "7z.dll",
"ecwv_installer.exe",
"resources", "shaders"
]
extend = open("_compile_pyiextend.py", "r", encoding="utf-8").read()

system("python -m venv compile_venv")
Expand All @@ -49,5 +59,16 @@ def compile(file:str, hideconsole:bool):
system("rmdir .\\compile_venv /s /q")
system("rmdir .\\build /s /q")
system("rmdir .\\dist /s /q")

if "--zip" in argv:
_copy = lambda src, tar: copy(src, tar) if isfile(src) else copytree(src, f"{tar}\\{src}")
try: mkdir(".\\compile_result")
except FileExistsError: pass
for i, _ in compile_files:
_copy(i.replace(".py", ".exe"), ".\\compile_result")
for i in res_files:
_copy(i, ".\\compile_result")
system("7z a compile_result.zip .\\compile_result\\*")

print("\nCompile complete!")
system("pause")
2 changes: 1 addition & 1 deletion src/tool_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def compute_intersection(x0, y0, x1, y1, x2, y2, x3, y3):
c2 = x3 * y2 - x2 * y3
return (b2 * c1 - b1 * c2) / (a1 * b2 - a2 * b1), (a1 * c2 - a2 * c1) / (a1 * b2 - a2 * b1)

def fixOutofRangeP(p: float):
def fixorp(p: float):
return max(0.0, min(1.0, p))

def PhigrosChapterNameAlphaValueTransfrom(p: float):
Expand Down
60 changes: 1 addition & 59 deletions src/web_canvas.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@
background-color: black;
}

.ppr-start {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 2;
opacity: 0.0;
-webkit-user-drag: none;
}

.main-canvas {
z-index: 1;
left: 0;
Expand Down Expand Up @@ -80,7 +69,7 @@
ctx = canvas_ele.getContext("2d", {willReadFrequently: true, alpha: false});
dialog_canvas_ctx = dialog_canvas_ele.getContext("2d");
gl = glcanvas.getContext("webgl");
JavaScript_WaitToExecute_CodeArray = new Array();
jscodes = new Array();
resize_task = false;
lfdaot_render_fcount = 0;
render_range_more = false;
Expand Down Expand Up @@ -139,53 +128,6 @@
// ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
}

function process_jswteca() {
for(var i=0;i<JavaScript_WaitToExecute_CodeArray.length;i++){
eval(JavaScript_WaitToExecute_CodeArray[i]);
}
JavaScript_WaitToExecute_CodeArray = new Array();
}

function change_color_block_opacity(opacity) {
color_block_img_ele.style.opacity = opacity; // color_block_img_ele define in python code.
}

function ease_out(x) {
return Math.sqrt(1 - Math.pow(x - 1, 2));
}

function show_in_animation(first_call = true,start_time = 0.0) {
if (!first_call){
process = (new Date().getTime() / 1000 - start_time) / 1.25;
ease_number = ease_out(process);
if (process > 1.0) {
change_color_block_opacity(1.0);
return;
}
change_color_block_opacity(ease_number);
setTimeout(() => show_in_animation(false,start_time),1000 / 60);
}
else{
show_in_animation(false,new Date().getTime() / 1000);
}
}

function show_out_animation(first_call = true,start_time = 0.0) {
if (!first_call){
process = (new Date().getTime() / 1000 - start_time) / 1.25;
ease_number = ease_out(process);
if (process > 1.0) {
change_color_block_opacity(0.0);
return;
}
change_color_block_opacity(1.0 - ease_number);
setTimeout(() => show_out_animation(false,start_time),1000 / 60);
}
else{
show_out_animation(false,new Date().getTime() / 1000);
}
}

function loadFont(family, url) {
var font = new FontFace(family, `url(${url})`);
font.load().then((rfont) => {
Expand Down
Loading

0 comments on commit 93e3bf9

Please sign in to comment.