Cirno2022/script/default_system/Default_ReplaySaveScene.txt

394 lines
18 KiB
Plaintext
Raw Permalink Normal View History

<EFBFBD><EFBFBD>//<00>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>OX[<5B>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
@Initialize
{
SetAutoDeleteObject(true);
LoadReplayList();
TBackground();
TReplayIndexSelection();
}
@MainLoop
{
yield;
}
@Finalize
{
}
let MENU_INDEX_SELECTION = 1;
let MENU_NAME_ENTRY = 2;
let menuMode = MENU_INDEX_SELECTION;
function CreateTextObject(let mx, let my, let size, let text)
{
let obj = ObjText_Create();
ObjText_SetText(obj, text);
ObjText_SetFontSize(obj, size);
ObjText_SetFontBold(obj, true);
ObjText_SetFontColorTop(obj, 128, 128, 255);
ObjText_SetFontColorBottom(obj, 64, 64, 255);
ObjText_SetFontBorderType(obj, BORDER_FULL);
ObjText_SetFontBorderColor(obj,255, 255, 255);
ObjText_SetFontBorderWidth(obj, 2);
Obj_SetRenderPriorityI(obj, 10);
ObjRender_SetX(obj, mx);
ObjRender_SetY(obj, my);
return obj;
}
task TBackground
{
let target = GetTransitionRenderTargetName();
let obj = ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(obj, target);
Obj_SetRenderPriority(obj, 0.1);
ObjSprite2D_SetSourceRect(obj, 0, 0, 640, 480);
ObjSprite2D_SetDestCenter(obj);
ObjRender_SetPosition(obj, 320, 240, 0);
ObjRender_SetAlpha(obj, 64);
}
task TReplayIndexSelection()
{
let cursorY = 0;
let page = 0;
let countMaxItem = REPLAY_INDEX_DIGIT_MAX - REPLAY_INDEX_DIGIT_MIN + 1;
let countItemPerPage = 10;
let pageMax = trunc((countMaxItem - 1) / countItemPerPage);
pageMax = max(pageMax, 1);
let lastPageMaxCursorY = trunc(countMaxItem / countItemPerPage);
task TMenuItem(let itemY)
{
let objText = CreateTextObject(64, 64 + 30 * itemY, 18, "");
let objSelect = CreateTextObject(64, 64 + 30 * itemY, 18, "");
ObjRender_SetBlendType(objSelect, BLEND_ADD_RGB);
let oldPage = -1;
while(menuMode == MENU_INDEX_SELECTION)
{
if(page != oldPage)
{
let index = page * countItemPerPage + itemY + 1;
let text = rtos("00", index) ~ " ";
if(IsValidReplayIndex(index))
{
text = text ~ vtos("-8s", GetReplayInfo(index, REPLAY_USER_NAME)) ~ " ";
text = text ~ GetReplayInfo(index, REPLAY_DATE_TIME) ~ " ";
text = text ~ rtos("000000000000", GetReplayInfo(index, REPLAY_TOTAL_SCORE)) ~ " ";
}
else
{
text = text ~ "No Data";
}
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
while(menuMode == MENU_INDEX_SELECTION)
{
//zl<7A>[
if(GetVirtualKeyState(VK_OK) == KEY_PULL)
{
menuMode = MENU_NAME_ENTRY;
let index = page * countItemPerPage + cursorY + 1;
TNameEntry(index);
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 % 10 == 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 % 10 == 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 % 10 == 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 % 10 == 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;
}
}
task TNameEntry(let replayIndex)
{
let strTextIn =
[
["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P"],
["Q","R","S","T","U","V","W","X","Y","Z",".",",",":",";","_","@"],
["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p"],
["q","r","s","t","u","v","w","x","y","z","+","-","/","*","=","%"],
["0","1","2","3","4","5","6","7","8","9","0","!","?","'","\"","$"],
["(",")","{","}","[","]","<",">","&","#","|","~","^"," "," ","B}"]
];
let strTextView =
[
["!<21>",""<22>","#<23>","$<24>","%<25>","&<26>","'<27>","(<28>",")<29>","*<2A>","+<2B>",",<2C>","-<2D>",".<2E>","/<2F>","0<>"],
["1<>","2<>","3<>","4<>","5<>","6<>","7<>","8<>","9<>",":<3A>","<0E>"," <0C>","<1A>","<1B>","?<3F>"," <20>"],
["A<>","B<>","C<>","D<>","E<>","F<>","G<>","H<>","I<>","J<>","K<>","L<>","M<>","N<>","O<>","P<>"],
["Q<>","R<>","S<>","T<>","U<>","V<>","W<>","X<>","Y<>","Z<>"," <0B>"," <0A>","<0F>","
<EFBFBD>","<1D>","<05>"],
["<10>","<11>","<12>","<13>","<14>","<15>","<16>","<17>","<18>","<19>","<10>","<01>","<1F>"," "," ","<04>"],
["<08>"," <09>","[<5B>","]<5D>",";<3B>","=<3D>","<1C>","<1E>","<06>","<03>","\<5C>","^<5E>","><3E>"," "," ","B}<7D>N"]
];
let cursorX = 0;
let cursorY = 0;
let maxCursorX = length(strTextIn[0]);
let maxCursorY = length(strTextIn);
task TMenuItem(let itemX, let itemY)
{
let objText = CreateTextObject(120 + itemX * 24, 200 + itemY * 24, 22, strTextView[itemY][itemX]);
let objSelect = CreateTextObject(120 + itemX * 24, 200 + itemY * 24, 22, strTextView[itemY][itemX]);
ObjRender_SetBlendType(objSelect, BLEND_ADD_RGB);
while(menuMode == MENU_NAME_ENTRY)
{
Obj_SetVisible(objSelect, itemX == cursorX && itemY == cursorY);
yield;
}
Obj_Delete(objText);
Obj_Delete(objSelect);
}
ascent(let iY in 0..maxCursorY)
{
ascent(let iX in 0 .. maxCursorX)
{
TMenuItem(iX, iY);
}
}
//<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;}
//eQ<65>Rn0<7F>eW[
let userName = "";
let objName = CreateTextObject(160, 96, 28, "");
task TNameCursor()
{
let objCursor = CreateTextObject(0, 96, 28, "_");
while(menuMode == MENU_NAME_ENTRY)
{
let nameLength = length(userName);
ObjRender_SetX(objCursor, 160 + nameLength * 17);
Obj_SetVisible(objCursor, nameLength < 8);
yield;
}
Obj_Delete(objCursor);
}
TNameCursor;
//<00>0<EFBFBD>0<EFBFBD>Qt
let frameKeyHold = 0;//<00>0<EFBFBD>0<EFBFBD>bW0c0q0j0W0<57>0<EFBFBD>0<EFBFBD>0<EFBFBD>0pe
while(menuMode == MENU_NAME_ENTRY)
{
if(GetVirtualKeyState(VK_OK) == KEY_PULL)
{
//zl<7A>[
let nameLength = length(userName);
if(cursorX == maxCursorX-1 && cursorY == maxCursorY-1)
{
//B}<7D>N<EFBFBD>0<EFBFBD>0
if(nameLength == 0)
{
userName = "No Name";
}
else
{
SaveReplay(replayIndex, userName);
SetScriptResult(RESULT_END);
CloseScript(GetOwnScriptID());
return;
}
}
else if(nameLength < 8)
{
userName = userName ~ strTextIn[cursorY][cursorX];
}
}
if(GetVirtualKeyState(VK_CANCEL) == KEY_PULL)
{
//<00>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
let nameLength = length(userName);
if(nameLength > 0)
{
userName = userName[0..nameLength-1];
}
}
ObjText_SetText(objName, userName);
//<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 % 10 == 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 % 10 == 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 % 10 == 0)))
{
cursorX--;
}
}
else if(GetVirtualKeyState(VK_RIGHT) == KEY_PUSH || GetVirtualKeyState(VK_RIGHT) == KEY_HOLD)
{
frameKeyHold++;
if(GetVirtualKeyState(VK_RIGHT) == KEY_PUSH ||
frameKeyHold == 20 ||
(frameKeyHold > 20 && (frameKeyHold % 10 == 0)))
{
cursorX++;
}
}
else
{
frameKeyHold = 0;
}
if(cursorX < 0)
{
cursorX = maxCursorX-1;
}
else if(cursorX >= maxCursorX)
{
cursorX = 0;
}
if(cursorY < 0)
{
cursorY = maxCursorY-1;
}
else if(cursorY >= maxCursorY)
{
cursorY = 0;
}
yield;
}
}