102 lines
2.9 KiB
C#
102 lines
2.9 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, %optBox) {
|
|
if(%optBox $= "") {
|
|
if(!isObject(%client.ndSelectionBox)) return;
|
|
%box = %client.ndSelectionBox.point1 SPC %client.ndSelectionBox.point2;
|
|
%zone = %client.ndSelectionBox.zoneBrick;
|
|
} else {
|
|
%box = %optBox;
|
|
%zone = "";
|
|
}
|
|
%entry = %box TAB %zone;
|
|
|
|
if(%client.ndBoxHistoryCount>0 &&
|
|
%entry $= %client.ndBoxHistory[%client.ndBoxHistoryCount-1])
|
|
return;
|
|
%client.ndBoxHistory[%client.ndBoxHistoryCount+0] = %entry;
|
|
%client.ndBoxHistoryCount++;
|
|
%client.ndBoxHistoryPos = 1; // recall prior to this one
|
|
}
|
|
function gameConnection::ndBoxChanged(%client) {
|
|
%client.ndBoxHistoryPos = 0; // recall starting with this initial selection
|
|
%client.ndSaveBoxOnRecall = true;
|
|
}
|
|
function gameConnection::ndBoxCleared(%client) {
|
|
if(%client.ndSaveBoxOnRecall) {
|
|
%client.ndPushBoxHistory();
|
|
%client.ndSaveBoxOnRecall = false;
|
|
}
|
|
%client.ndBoxHistoryPos = 0;
|
|
}
|
|
function gameConnection::ndRecallBoxHistory(%client, %offset) {
|
|
if(%offset<1 || %offset>%client.ndBoxHistoryCount) return;
|
|
|
|
%idx = %client.ndBoxHistoryCount - %offset;
|
|
%entry = %client.ndBoxHistory[%idx];
|
|
%box = getField(%entry, 0);
|
|
%zone = getField(%entry, 1);
|
|
|
|
%p1 = getWords(%box,0,2);
|
|
%p2 = getWords(%box,3,5);
|
|
|
|
if(!isObject(%client.ndSelectionBox))
|
|
%client.ndCreateSelectionBox();
|
|
%client.ndSelectionBox.zoneBrick = %zone;
|
|
if(isObject(%zone))
|
|
%client.ndSelectionBox.setZoneColors();
|
|
else
|
|
%client.ndSelectionBox.setNormalColors();
|
|
%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);
|
|
}
|