add new zone box visuals,
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
//bls 4
|
||||
|
||||
// This file should not exist. Fix later...
|
||||
// -------------------------------------------------------------------
|
||||
@ -61,6 +60,8 @@ function NDM_BoxSelect::onStartMode(%this, %client, %lastMode)
|
||||
//Switch away from this mode
|
||||
function NDM_BoxSelect::onChangeMode(%this, %client, %nextMode)
|
||||
{
|
||||
%client.ndBoxCleared();
|
||||
|
||||
if(%nextMode == $NDM::StackSelect)
|
||||
{
|
||||
//Clear selection
|
||||
@ -107,6 +108,8 @@ function NDM_BoxSelect::onChangeMode(%this, %client, %nextMode)
|
||||
//Kill this mode
|
||||
function NDM_BoxSelect::onKillMode(%this, %client)
|
||||
{
|
||||
%client.ndBoxCleared();
|
||||
|
||||
//Destroy selection
|
||||
if(isObject(%client.ndSelection))
|
||||
%client.ndSelection.delete();
|
||||
@ -164,6 +167,7 @@ function NDM_BoxSelect::onSelectObject(%this, %client, %obj, %pos, %normal)
|
||||
else
|
||||
{
|
||||
%client.ndSelectionBox.zoneBrick = "";
|
||||
%client.ndSelectionBox.setNormalColors();
|
||||
%box = %obj.getWorldBox();
|
||||
%p1 = getWords(%box, 0, 2);
|
||||
%p2 = getWords(%box, 3, 5);
|
||||
@ -186,6 +190,7 @@ function NDM_BoxSelect::onSelectObject(%this, %client, %obj, %pos, %normal)
|
||||
} else if (isObject(%obj.physicalZone)) {
|
||||
%box = ndGetBoxFromZone(%obj);
|
||||
%client.ndSelectionBox.zoneBrick = %obj;
|
||||
%client.ndSelectionBox.setZoneColors();
|
||||
} else {
|
||||
%box = ndGetPlateBoxFromRayCast(%pos, %normal);
|
||||
}
|
||||
@ -208,7 +213,7 @@ function ndRound(%v, %step) {
|
||||
return mFloor(%v/%step + 0.5)*%step;
|
||||
}
|
||||
|
||||
function ndCorrectBox(%box) {
|
||||
function ndSnapBoxToGrid(%box) {
|
||||
%xl = ndRound(getWord(%box, 0), 0.5);
|
||||
%yl = ndRound(getWord(%box, 1), 0.5);
|
||||
%zl = ndRound(getWord(%box, 2), 0.2);
|
||||
@ -226,19 +231,16 @@ function ndGetBoxFromRom(%b) {
|
||||
%bh = getWords(%box, 3, 5);
|
||||
%bl = vectorAdd(%bl, "0 0 " SPC (%db.brickSizeZ * 0.2));
|
||||
%bh = vectorAdd(%bh, "0 0 " SPC (%db.logicRomZ * 0.2));
|
||||
return ndCorrectBox(%bl SPC %bh);
|
||||
return ndSnapBoxToGrid(%bl SPC %bh);
|
||||
}
|
||||
|
||||
function ndGetBoxFromZone(%b) {
|
||||
%z = %b.physicalZone;
|
||||
%pos = %z.position;
|
||||
%scale = %z.getScale();
|
||||
%sx = getWord(%scale, 0);
|
||||
%sy = getWord(%scale, 1);
|
||||
%sz = getWord(%scale, 2);
|
||||
%bl = vectorAdd(%pos, 0 SPC -%sy SPC 0);
|
||||
%bh = vectorAdd(%pos, %sx SPC 0 SPC %sz);
|
||||
return ndCorrectBox(%bl SPC %bh);
|
||||
%bl = vectorAdd(%pos, 0 SPC -%getWord(%scale,1) SPC 0);
|
||||
%bh = vectorAdd(%pos, getWord(%scale,0) SPC 0 SPC getWord(%scale,2));
|
||||
return ndSnapBoxToGrid(%bl SPC %bh);
|
||||
}
|
||||
|
||||
|
||||
@ -366,12 +368,18 @@ function ndApplyZoneEvent(%brick, %p1a, %p2a, %client) {
|
||||
if(%brick.eventOutput[%i] $= "setZoneBox") {
|
||||
%brick.eventOutputParameter[%i, 1] = %p1;
|
||||
%brick.eventOutputParameter[%i, 2] = %p2;
|
||||
|
||||
// update event
|
||||
%brick.setZoneBox(%p1,%p2, %brick.eventOutputParameter[%i,3], 0);
|
||||
if(isFunction("fxDtsBrick", "triggerPropertyOnLoad"))
|
||||
%brick.triggerPropertyOnLoad();
|
||||
|
||||
// inform client
|
||||
messageClient(%client, 'MsgError', "");
|
||||
commandToClient(%client, 'centerPrint',
|
||||
"<font:Verdana:20>\c6Applied selection box to zone event \c3" @ %i
|
||||
@ "\c6 on brick, and re-created zone.", 5);
|
||||
%brick.setZoneBox(%p1, %p2,
|
||||
%brick.eventOutputParameter[%i,3], 0);
|
||||
@ "\c6 on brick,<br>\c6re-created zone, and triggered propertyOnLoad events.", 5);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -16,24 +16,29 @@ function gameConnection::ndCreateSelectionBox(%client) {
|
||||
%client.ndSelectionBox = ND_SelectionBox(%shapeName);
|
||||
}
|
||||
|
||||
function gameConnection::ndPushBoxHistory(%client) {
|
||||
//talk("push");
|
||||
if(!isObject(%client.ndSelectionBox)) return;
|
||||
%box = %client.ndSelectionBox.point1 SPC %client.ndSelectionBox.point2;
|
||||
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 &&
|
||||
%box $= %client.ndBoxHistory[%client.ndBoxHistoryCount-1])
|
||||
%entry $= %client.ndBoxHistory[%client.ndBoxHistoryCount-1])
|
||||
return;
|
||||
%client.ndBoxHistory[%client.ndBoxHistoryCount+0] = %box;
|
||||
%client.ndBoxHistory[%client.ndBoxHistoryCount+0] = %entry;
|
||||
%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;
|
||||
@ -41,18 +46,26 @@ function gameConnection::ndBoxCleared(%client) {
|
||||
%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];
|
||||
%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);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
//bls 4
|
||||
|
||||
// This file should not exist. Fix later...
|
||||
// -------------------------------------------------------------------
|
||||
@ -273,6 +272,8 @@ function NDM_PlantCopy::conditionalPlant(%this, %client, %force, %ownership)
|
||||
return;
|
||||
}
|
||||
|
||||
%client.ndPushBoxHistory(%client.ndSelection.getGhostWorldBox());
|
||||
|
||||
%client.ndLastPlantTime = $Sim::Time;
|
||||
|
||||
%pos = %client.ndSelection.ghostPosition;
|
||||
|
@ -1,4 +1,3 @@
|
||||
//bls 4
|
||||
|
||||
// This file should not exist. Fix later...
|
||||
// -------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user