Files
Tool_NewDuplicator/classes/server/duplimode/boxselecthistory.cs

89 lines
2.6 KiB
C#

function ndBoxPlaySound(%sel, %sound) {
if(%sel.selectedCorner)
%soundPoint = %sel.point2;
else
%soundPoint = %sel.point1;
serverPlay3d(BrickMoveSound, %soundPoint);
}
function gameConnection::ndCreateSelectionBox(%client) {
%name = %client.name;
if(getSubStr(%name, strLen(%name - 1), 1) $= "s")
%shapeName = %name @ "' Selection Box";
else
%shapeName = %name @ "'s Selection Box";
%client.ndSelectionBox = ND_SelectionBox(%shapeName);
}
function gameConnection::ndPushBoxHistory(%client) {
//talk("push");
if(!isObject(%client.ndSelectionBox)) return;
%box = %client.ndSelectionBox.point1 SPC %client.ndSelectionBox.point2;
if(%client.ndBoxHistoryCount>0 &&
%box $= %client.ndBoxHistory[%client.ndBoxHistoryCount-1])
return;
%client.ndBoxHistory[%client.ndBoxHistoryCount+0] = %box;
%client.ndBoxHistoryCount++;
%client.ndBoxHistoryPos = 1; // recall prior to this one
}
function gameConnection::ndBoxChanged(%client) {
//talk("changed");
%client.ndBoxHistoryPos = 0; // recall starting with this initial selection
%client.ndSaveBoxOnRecall = true;
}
function gameConnection::ndBoxCleared(%client) {
//talk("cleared");
if(%client.ndSaveBoxOnRecall) {
%client.ndPushBoxHistory();
%client.ndSaveBoxOnRecall = false;
}
%client.ndBoxHistoryPos = 0;
}
function gameConnection::ndRecallBoxHistory(%client, %offset) {
//talk("recall " @ %offset);
if(%offset<1 || %offset>%client.ndBoxHistoryCount) return;
%idx = %client.ndBoxHistoryCount - %offset;
%box = %client.ndBoxHistory[%idx];
%p1 = getWords(%box,0,2);
%p2 = getWords(%box,3,5);
if(!isObject(%client.ndSelectionBox))
%client.ndCreateSelectionBox();
%client.ndSelectionBox.setSize(%p1,%p2);
%client.ndUpdateBottomPrint();
ndBoxPlaySound(%client.ndSelectionBox, BrickMoveSound);
}
function ndPlayerHoldingNewdup(%player) {
return isObject(%player) &&
isObject(%player.getMountedImage(0)) &&
getSubStr(%player.getMountedImage(0).getName(),0,8) $= "ND_Image";
}
function gameConnection::ndPrevBox(%client) {
if(!ndPlayerHoldingNewdup(%client.player)) return;
if(%client.ndModeIndex != $NDM::BoxSelect) return;
if(%client.ndBoxHistoryPos < %client.ndBoxHistoryCount)
%client.ndBoxHistoryPos++;
if(%client.ndSaveBoxOnRecall) {
%client.ndPushBoxHistory();
%client.ndBoxHistoryPos++;
%client.ndSaveBoxOnRecall = false;
}
%client.ndRecallBoxHistory(%client.ndBoxHistoryPos);
}
function gameConnection::ndNextBox(%client) {
if(!ndPlayerHoldingNewdup(%client.player)) return;
if(%client.ndModeIndex != $NDM::BoxSelect) return;
if(%client.ndBoxHistoryPos > 1)
%client.ndBoxHistoryPos--;
else
%client.ndBoxHistoryPos = 1;
%client.ndRecallBoxHistory(%client.ndBoxHistoryPos);
}