NarumiSTG_HyperSnowDrifter/script/ExRumia/ExRumia_Package_ReplaySelec...

341 lines
16 KiB
Plaintext
Raw Permalink Normal View History

2023-01-26 11:34:56 +00:00
<EFBFBD><EFBFBD>@Initialize
{
SetAutoDeleteObject(true);
LoadReplayList();
TBackground();
TReplaySelectScene();
SetScriptResult("");
}
@MainLoop
{
yield;
}
@Finalize
{
}
function DigitToCommaArray(num){ //Natashinitai
let srcStr = IntToString(num);
let res = [];
let nChar = 0;
for(let i = length(srcStr) - 1; i >= 0; i--){
res = [srcStr[i]] ~ res;
nChar++;
if(nChar % 3 == 0 && i > 0) res = "," ~ res;
}
return res;
}
function CreateTextObject(
float mx, my, size,
string text, font,
int colorTop, colorBottom,
int borderColor, borderWidth,
int renderPriority
){
let obj = ObjText_Create();
ObjText_SetText(obj, text);
ObjText_SetFontSize(obj, size);
ObjText_SetFontType(obj, font);
ObjText_SetFontColorTop(obj, colorTop);
ObjText_SetFontColorBottom(obj, colorBottom);
ObjText_SetFontBorderType(obj, BORDER_FULL);
ObjText_SetFontBorderColor(obj, borderColor);
ObjText_SetFontBorderWidth(obj, borderWidth);
Obj_SetRenderPriorityI(obj, renderPriority);
ObjRender_SetX(obj, mx);
ObjRender_SetY(obj, my);
return obj;
}
function <int> _Create2DImage(imgpath, int[] rectarray){
int imgname = ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(imgname, imgpath);
ObjSprite2D_SetSourceRect(imgname, rectarray);
ObjSprite2D_SetDestCenter(imgname);
//ObjRender_SetPosition(imgname, positionstart)
return imgname;
}
task TBackground()
{
//̀of
int image = _Create2DImage("script/game/PackageLib/Img.png", [0, 0, 1920, 1080]);
LoadTextureEx(image, true, true);
Obj_SetRenderPriorityI(image, 1);
ObjRender_SetAlpha(image, 0);
ObjSprite2D_SetDestRect(image, 0, 0, 1920, 1080);
//<00>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>eW[R
let objText = ObjText_Create();
ObjText_SetText(objText, "Paradise Records");
ObjText_SetFontType(objText, "Connecting Chain Handserif");
ObjText_SetFontSize(objText, 96);
ObjText_SetFontBold(objText, true);
ObjText_SetFontColorTop(objText, 128, 128, 255);
ObjText_SetFontColorBottom(objText, 64, 64, 255);
ObjText_SetFontBorderType(objText, BORDER_FULL);
ObjText_SetFontBorderColor(objText,255, 255, 255);
ObjText_SetFontBorderWidth(objText, 2);
Obj_SetRenderPriorityI(objText, 30);
ObjRender_SetX(objText, 32);
ObjRender_SetY(objText, 32);
let objWarning = CreateTextObject(
GetScreenWidth()/2, 11*GetScreenHeight()/12, [35, 40][GetCommonData("Language", 0)],
["Press X/Cancel to return to the menu.", "X/CANCEL:<00>0<EFBFBD>0<EFBFBD>0<EFBFBD>0k00^<5E>0"][GetCommonData("Language", 0)], "<00>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<08><>0<EFBFBD>0<EFBFBD>0<EFBFBD>0 <09> ver2 Bold",
0xFFFFFF, 0xFFFFFF,
0x5800BB, 35/10,
2
);
ObjText_SetHorizontalAlignment(objWarning, ALIGNMENT_CENTER);
}
//----------------------------------------------------
// <00>0<EFBFBD>0<EFBFBD>0<EFBFBD>0x<30><78>b
//----------------------------------------------------
task TReplaySelectScene
{
LoadReplayList();
let listValidReplayIndex = GetValidReplayIndices();
let cursorY = 0;
let page = 0;
let countMaxItem = length(listValidReplayIndex);
let countItemPerPage = 20;
let pageMax = trunc((countMaxItem - 1) / countItemPerPage);
pageMax = max(pageMax, 0);
let lastPageMaxCursorY = trunc(countMaxItem % countItemPerPage);
if(countMaxItem % countItemPerPage == 0)
{
lastPageMaxCursorY = countItemPerPage;
}
task TMenuItem(let itemY)
{
let objText = CreateTextObject(32, 120 + 50 * itemY, 25, "");
ObjText_SetFontBorderWidth(objText, 2);
let objSelect = CreateTextObject(32, 120 + 50 * itemY, 25, "");
ObjText_SetFontBorderWidth(objSelect, 2);
ObjRender_SetAlpha(objText, 150);
ObjRender_SetAlpha(objSelect, 120);
ObjRender_SetBlendType(objSelect, BLEND_ADD_ARGB);
let oldPage = -1;
loop
{
if(page != oldPage)
{
let text = "";
let indexList = page * countItemPerPage + itemY;
if(indexList < countMaxItem)
{
let indexReplay = listValidReplayIndex[indexList];
if(IsValidReplayIndex(indexReplay))
{
text = rtos("00", indexReplay) ~ " ";
text = text ~ vtos("-8s", GetReplayInfo(indexReplay, REPLAY_USER_NAME)) ~ " ";
text = text ~ GetReplayInfo(indexReplay, REPLAY_DATE_TIME) ~ " ";
text = text ~ DigitToCommaArray(trunc(GetReplayInfo(indexReplay, REPLAY_TOTAL_SCORE)/10)*10) ~ " ";
text = text ~ GetReplayInfo(indexReplay, REPLAY_PLAYER_NAME) ~ " ";
if(GetReplayUserData(indexReplay, "Difficulty") == "Novice"){
text = text ~ "Novice";
}
else if(GetReplayUserData(indexReplay, "Difficulty") == "Standard"){
text = text ~ "Standard";
}
else if(GetReplayUserData(indexReplay, "Difficulty") == "Extra"){
text = text ~ "Extra";
}
else{
text = text ~ "Standard";
}
}
}
ObjText_SetText(objText, text);
ObjText_SetText(objSelect, text);
oldPage = page;
}
if(page == pageMax && itemY >= lastPageMaxCursorY)
{
Obj_SetVisible(objText, false);
Obj_SetVisible(objSelect, false);
}
else
{
Obj_SetVisible(objText, true);
Obj_SetVisible(objSelect, itemY == cursorY);
}
yield;
}
Obj_Delete(objText);
Obj_Delete(objSelect);
}
ascent(let iItem in 0 .. countItemPerPage)
{
TMenuItem(iItem);
}
//<00>0<EFBFBD>0<EFBFBD>rKaL0<4C>0<EFBFBD>0<EFBFBD>0<EFBFBD>0U0<55>0<EFBFBD>0~0g0<67>__j
while(GetVirtualKeyState(VK_OK) != KEY_FREE){yield;}
//<00>0<EFBFBD>0<EFBFBD>Qt
let frameKeyHold = 0;//<00>0<EFBFBD>0<EFBFBD>bW0c0q0j0W0<57>0<EFBFBD>0<EFBFBD>0<EFBFBD>0pe
loop
{
//zl<7A>[
if(GetVirtualKeyState(VK_OK) == KEY_PULL)
{
let indexList = page * countItemPerPage + cursorY;
if(indexList < countMaxItem)
{
let indexReplay = listValidReplayIndex[indexList];
let pathReplay = GetReplayInfo(indexReplay, REPLAY_FILE_PATH);
SetScriptResult(indexReplay);
CloseScript(GetOwnScriptID());
break;
}
}
if(GetVirtualKeyState(VK_CANCEL) == KEY_PULL)
{
//<00>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
// XDDDDDDDDDD
SetScriptResult(99999999*69420);
CloseScript(GetOwnScriptID());
break;
}
//<00>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>y<EFBFBD>R
if(GetVirtualKeyState(VK_UP) == KEY_PUSH || GetVirtualKeyState(VK_UP) == KEY_HOLD)
{
frameKeyHold++;
if(GetVirtualKeyState(VK_UP) == KEY_PUSH ||
frameKeyHold == 20 ||
(frameKeyHold > 20 && (frameKeyHold % 5 == 0)))
{
cursorY--;
}
}
else if(GetVirtualKeyState(VK_DOWN) == KEY_PUSH || GetVirtualKeyState(VK_DOWN) == KEY_HOLD)
{
frameKeyHold++;
if(GetVirtualKeyState(VK_DOWN) == KEY_PUSH ||
frameKeyHold == 20 ||
(frameKeyHold > 20 && (frameKeyHold % 5 == 0)))
{
cursorY++;
}
}
else if(GetVirtualKeyState(VK_LEFT) == KEY_PUSH || GetVirtualKeyState(VK_LEFT) == KEY_HOLD)
{
frameKeyHold++;
if(GetVirtualKeyState(VK_LEFT) == KEY_PUSH ||
frameKeyHold == 20 ||
(frameKeyHold > 20 && (frameKeyHold % 5 == 0)))
{
page--;
}
}
else if(GetVirtualKeyState(VK_RIGHT) == KEY_PUSH || GetVirtualKeyState(VK_RIGHT) == KEY_HOLD)
{
frameKeyHold++;
if(GetVirtualKeyState(VK_RIGHT) == KEY_PUSH ||
frameKeyHold == 20 ||
(frameKeyHold > 20 && (frameKeyHold % 5 == 0)))
{
page++;
}
}
else
{
frameKeyHold = 0;
}
if(page < 0)
{
page = pageMax;
}
else if(page > pageMax)
{
page = 0;
}
if(page != pageMax)
{
if(cursorY < 0)
{
cursorY = countItemPerPage - 1;
}
else if(cursorY >= countItemPerPage)
{
cursorY = 0;
}
}
else
{
if(cursorY < 0)
{
cursorY = lastPageMaxCursorY - 1;
}
else if(cursorY >= lastPageMaxCursorY)
{
cursorY = 0;
}
}
yield;
}
}
//----------------------------------------------------
// <00>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
//----------------------------------------------------
function CreateTextObject(let mx, let my, let size, let text)
{
let obj = ObjText_Create();
ObjText_SetText(obj, text);
ObjText_SetFontType(obj, "Unispace");
ObjText_SetFontSize(obj, size);
ObjText_SetFontBold(obj, true);
ObjText_SetFontColorTop(obj, 0xBC55FF);
ObjText_SetFontColorBottom(obj, 0xECD0FF);
ObjText_SetFontBorderType(obj, BORDER_FULL);
ObjText_SetFontBorderColor(obj, 255, 255, 255);
ObjText_SetFontBorderWidth(obj, 2);
Obj_SetRenderPriorityI(obj, 40);
ObjRender_SetX(obj, mx);
ObjRender_SetY(obj, my);
return obj;
}