ScarletBlackMarket/KevinSystem/kevin_system/Legacy (1280x720)/Kevin_ReplaySave.txt

454 lines
11 KiB
Plaintext
Raw Normal View History

//リプレイ保存スクリプト
int STGWIDTH = GetStgFrameWidth();
int STGHEIGHT = GetStgFrameHeight();
@Initialize
{
SetAutoDeleteObject(true);
LoadReplayList();
TBackgroundNew(0, 0);
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, float size, let text)
{
let obj = ObjText_Create();
ObjText_SetText(obj, text);
ObjText_SetFontSize(obj, size);
ObjText_SetFontType(obj, "Unispace");
ObjText_SetFontBold(obj, true);
//ObjText_SetHorizontalAlignment(obj, ALIGNMENT_CENTER);
ObjText_SetMaxWidth(obj, STGWIDTH);
ObjText_SetFontColorTop(obj, 155, 45, 175);
ObjText_SetFontColorBottom(obj, 200, 80, 255);
ObjText_SetFontBorderType(obj, BORDER_FULL);
ObjText_SetFontBorderColor(obj, 255, 255, 255);
ObjText_SetFontBorderWidth(obj, 1.75);
Obj_SetRenderPriorityI(obj, 10);
ObjRender_SetX(obj, mx);
ObjRender_SetY(obj, my);
return obj;
}
// renderX and renderY will be TOP-LEFT COORDS
task TBackgroundNew(renderX, renderY){
// Render semi-transparent primitive background
task TRenderPrim(selection){
// Thank you for the PrimMaker Ferase :omegaflooshed:
ObjRender_SetPosition(selection, renderX+640, renderY+360, 0); // Since the render priority of the r.target is under 20
// Set up vert 0
ObjPrim_SetVertexPosition(selection,0,-640,-360,0);
ObjPrim_SetVertexColor(selection,0,0xA487FF);
ObjPrim_SetVertexUVT(selection, 0, 0, 0);
// Set up vert 1
ObjPrim_SetVertexPosition(selection,1,640,-360,0);
ObjPrim_SetVertexColor(selection,1,0xA487FF);
ObjPrim_SetVertexUVT(selection, 1, 1280, 0);
// Set up vert 2
ObjPrim_SetVertexPosition(selection,2,640,360,0);
ObjPrim_SetVertexColor(selection,2,0xA487FF);
ObjPrim_SetVertexUVT(selection, 2, 1280, 720);
// Set up vert 3
ObjPrim_SetVertexPosition(selection,3,640,360,0);
ObjPrim_SetVertexColor(selection,3,0xF187FF);
ObjPrim_SetVertexUVT(selection, 3, 1280, 720);
// Set up vert 4
ObjPrim_SetVertexPosition(selection,4,-640,360,0);
ObjPrim_SetVertexColor(selection,4,0xF187FF);
ObjPrim_SetVertexUVT(selection, 4, 0, 720);
// Set up vert 5
ObjPrim_SetVertexPosition(selection,5,-640,-360,0);
ObjPrim_SetVertexColor(selection,5,0xF187FF);
ObjPrim_SetVertexUVT(selection, 5, 0, 0);
for(int i = 0; i <= 5; i++){
ObjPrim_SetVertexAlpha(selection, i, 100);
}
}
// Render... the render target???
let objBG = ObjPrim_Create(OBJ_PRIMITIVE_2D);
ObjPrim_SetPrimitiveType(objBG, PRIMITIVE_TRIANGLELIST);
ObjPrim_SetVertexCount(objBG, 6);
let target = "target";
CreateRenderTargetEx(target, STGWIDTH, STGHEIGHT);
ObjPrim_SetTexture(objBG, target);
//SetInvalidRenderPriorityA1(20, 80);
RenderToTextureA1(target, 0, 100, true);
//RenderToTextureB1(target, objBG, true);
Obj_SetRenderPriorityI(objBG, 0);
TRenderPrim(objBG);
}
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(341, 90 + 30 * itemY, 25, "");
let objSelect = CreateTextObject(341, 90 + 30 * itemY, 25, "");
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);
}
//キー状態がリセットされるまで待機
while(GetVirtualKeyState(VK_OK) != KEY_FREE){yield;}
//キー処理
let frameKeyHold = 0;//キー押しっぱなしフレーム数
while(menuMode == MENU_INDEX_SELECTION)
{
//決定
if(GetVirtualKeyState(VK_OK) == KEY_PULL)
{
menuMode = MENU_NAME_ENTRY;
let index = page * countItemPerPage + cursorY + 1;
TNameEntry(index);
break;
}
//カーソル移動
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","!","?","'","\"","$"],
["(",")","{","}","[","]","<",">","&","#","|","~","^"," "," ","終"]
];
let strTextView =
[
["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","!","?","'","\"","$"],
["(",")","{","}","&osb;","&csb;","<",">","&","#","|","~","^"," "," ","»"]
];
let cursorX = 0;
let cursorY = 0;
let maxCursorX = length(strTextIn[0]);
let maxCursorY = length(strTextIn);
task TMenuItem(let itemX, let itemY)
{
let objText = CreateTextObject(341 + GetStgFrameWidth()/5.4 + itemX * 24, 255 + itemY * 24, 22, strTextView[itemY][itemX]);
let objSelect = CreateTextObject(341 + GetStgFrameWidth()/5.4 + itemX * 24, 255 + itemY * 24, 22, strTextView[itemY][itemX]);
ObjRender_SetBlendType(objSelect, BLEND_ADD_ARGB);
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);
}
}
//キー状態がリセットされるまで待機
while(GetVirtualKeyState(VK_OK) != KEY_FREE){yield;}
//入力済み文字
let userName = "";
let objName = CreateTextObject(341+GetStgFrameWidth()/4, 125, 28, "");
task TNameCursor()
{
let objCursor = CreateTextObject(341+GetStgFrameWidth()/4, 125, 28, "_");
while(menuMode == MENU_NAME_ENTRY)
{
let nameLength = length(userName);
ObjRender_SetX(objCursor, 341+GetStgFrameWidth()/4 + nameLength * 17);
Obj_SetVisible(objCursor, nameLength < 8);
yield;
}
Obj_Delete(objCursor);
}
TNameCursor;
//キー処理
let frameKeyHold = 0;//キー押しっぱなしフレーム数
while(menuMode == MENU_NAME_ENTRY)
{
if(GetVirtualKeyState(VK_OK) == KEY_PULL)
{
//決定
let nameLength = length(userName);
if(cursorX == maxCursorX-1 && cursorY == maxCursorY-1)
{
//終了キー
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)
{
//キャンセル
let nameLength = length(userName);
if(nameLength > 0)
{
userName = userName[0..nameLength-1];
}
else{menuMode = MENU_INDEX_SELECTION; TReplayIndexSelection(); break;}
}
ObjText_SetText(objName, userName);
//カーソル移動
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;
}
}