add box features

This commit is contained in:
Redo
2025-02-26 17:36:12 -07:00
parent cd5b46cc3b
commit dd049be341
21 changed files with 1510 additions and 339 deletions

116
scripts/client/controls.cs Normal file
View File

@ -0,0 +1,116 @@
// Registers hotkeys used to control the new duplicator.
// -------------------------------------------------------------------
//Register rebind-able controls
function ndRegisterKeybinds()
{
if($ND::KeybindsRegistered)
return;
$RemapDivision[$RemapCount] = "New Duplicator";
$RemapName[$RemapCount] = "Copy Selection (Ctrl C)";
$RemapCmd[$RemapCount] = "ndInputCopy";
$RemapCount++;
$RemapName[$RemapCount] = "Paste Selection (Ctrl V)";
$RemapCmd[$RemapCount] = "ndInputPaste";
$RemapCount++;
$RemapName[$RemapCount] = "Cut Selection (Ctrl X)";
$RemapCmd[$RemapCount] = "ndInputCut";
$RemapCount++;
$RemapName[$RemapCount] = "Multiselect (Ctrl, Hold to use)";
$RemapCmd[$RemapCount] = "ndInputMultiSelect";
$RemapCount++;
$RemapName[$RemapCount] = "Send /NewDuplicator";
$RemapCmd[$RemapCount] = "ndInputNewDuplicator";
$RemapCount++;
$RemapName[$RemapCount] = "Send /FillWrench";
$RemapCmd[$RemapCount] = "ndInputFillWrench";
$RemapCount++;
$RemapName[$RemapCount] = "Send /ForcePlant";
$RemapCmd[$RemapCount] = "ndInputForcePlant";
$RemapCount++;
$RemapName[$RemapCount] = "Send /ToggleForcePlant";
$RemapCmd[$RemapCount] = "ndInputToggleForcePlant";
$RemapCount++;
$RemapName[$RemapCount] = "Send /MirrorX";
$RemapCmd[$RemapCount] = "ndInputMirrorX";
$RemapCount++;
$RemapName[$RemapCount] = "Send /MirrorY";
$RemapCmd[$RemapCount] = "ndInputMirrorY";
$RemapCount++;
$RemapName[$RemapCount] = "Send /MirrorZ";
$RemapCmd[$RemapCount] = "ndInputMirrorZ";
$RemapCount++;
$RemapName[$RemapCount] = "Send /SuperCut (Shift-Ctrl X)";
$RemapCmd[$RemapCount] = "ndInputSuperCut";
$RemapCount++;
$RemapName[$RemapCount] = "Send /FillBricks (Shift-Ctrl V)";
$RemapCmd[$RemapCount] = "ndInputFillBricks";
$RemapCount++;
$ND::KeybindsRegistered = true;
}
//Enable the copy, paste, cut keybinds
function clientCmdNdEnableKeybinds(%bool)
{
if(%bool && !$ND::KeybindsEnabled)
{
%map = new ActionMap(ND_KeyMap);
if(MoveMap.getBinding("ndInputCopy") $= "")
%map.bind("keyboard", isWindows() ? "ctrl c" : "cmd c", "ndInputCopy");
if(MoveMap.getBinding("ndInputPaste") $= "")
%map.bind("keyboard", isWindows() ? "ctrl v" : "cmd v", "ndInputPaste");
if(MoveMap.getBinding("ndInputCut") $= "")
%map.bind("keyboard", isWindows() ? "ctrl x" : "cmd x", "ndInputCut");
if(MoveMap.getBinding("ndInputMultiSelect") $= "")
%map.bind("keyboard", isWindows() ? "lcontrol" : "cmd", "ndInputMultiSelect");
if(MoveMap.getBinding("ndInputSuperCut") $= "")
%map.bind("keyboard", isWindows() ? "shift-ctrl x" : "shift-cmd x", "ndInputSuperCut");
if(MoveMap.getBinding("ndInputFillBricks") $= "")
%map.bind("keyboard", isWindows() ? "shift-ctrl v" : "shift-cmd v", "ndInputFillBricks");
%map.push();
$ND::KeybindsEnabled = true;
}
else if(!%bool && $ND::KeybindsEnabled)
{
ND_KeyMap.pop();
ND_KeyMap.delete();
$ND::KeybindsEnabled = false;
}
}
//Input handlers
function ndInputNewDuplicator (%bool) {if(!%bool)return; commandToServer('newDuplicator' );}
function ndInputCopy (%bool) {if(!%bool)return; commandToServer('ndCopy' );}
function ndInputPaste (%bool) {if(!%bool)return; commandToServer('ndPaste' );}
function ndInputCut (%bool) {if(!%bool)return; commandToServer('ndCut' );}
function ndInputFillWrench (%bool) {if(!%bool)return; commandToServer('fillWrench' );}
function ndInputForcePlant (%bool) {if(!%bool)return; commandToServer('forcePlant' );}
function ndInputToggleForcePlant(%bool) {if(!%bool)return; commandToServer('toggleForcePlant');}
function ndInputMirrorX (%bool) {if(!%bool)return; commandToServer('mirrorX' );}
function ndInputMirrorY (%bool) {if(!%bool)return; commandToServer('mirrorY' );}
function ndInputMirrorZ (%bool) {if(!%bool)return; commandToServer('mirrorZ' );}
function ndInputSuperCut (%bool) {if(!%bool)return; commandToServer('superCut' );}
function ndInputFillBricks (%bool) {if(!%bool)return; commandToServer('fillBricks' );}
function ndInputMultiSelect(%bool) {commandToServer('ndMultiSelect', %bool);}

View File

@ -0,0 +1,507 @@
// Modified wrench dialog window with toggle-able settings.
// -------------------------------------------------------------------
new GuiControl(ND_WrenchDlg)
{
profile = "GuiDefaultProfile";
position = "0 0";
extent = "1024 768";
new GuiWindowCtrl(ND_Wrench_Window)
{
profile = "BlockWindowProfile";
horizSizing = "center";
vertSizing = "center";
position = "363 197";
extent = "297 373";
text = "New Duplicator | Fill Wrench";
resizeWidth = "0";
resizeHeight = "0";
canMove = "1";
canClose = "1";
canMinimize = "0";
canMaximize = "0";
minSize = "50 50";
closeCommand = "canvas.popDialog(ND_WrenchDlg);";
new GuiTextCtrl()
{
profile = "GuiTextProfile";
position = "13 33";
extent = "57 18";
text = "Brick Name:";
};
new GuiTextEditCtrl(ND_Wrench_Name)
{
profile = "GuiTextEditProfile";
position = "76 33";
extent = "162 18";
maxLength = "32";
};
new GuiTextCtrl()
{
profile = "GuiTextProfile";
position = "13 63";
extent = "26 18";
text = "Light:";
};
new GuiPopUpMenuCtrl(ND_Wrench_Lights)
{
profile = "BlockButtonProfile";
position = "76 60";
extent = "162 22";
maxPopupHeight = "200";
};
new GuiTextCtrl()
{
profile = "GuiTextProfile";
position = "13 93";
extent = "35 18";
text = "Emitter:";
};
new GuiPopUpMenuCtrl(ND_Wrench_Emitters)
{
profile = "BlockButtonProfile";
position = "76 90";
extent = "162 22";
maxPopupHeight = "200";
};
new GuiTextCtrl()
{
profile = "GuiTextProfile";
position = "13 113";
extent = "51 18";
text = "Emitter Dir:";
};
new GuiRadioCtrl(ND_Wrench_EmitterDir0)
{
profile = "GuiRadioProfile";
position = "78 110";
extent = "27 22";
text = "U";
groupNum = "1";
buttonType = "RadioButton";
};
new GuiRadioCtrl(ND_Wrench_EmitterDir1)
{
profile = "GuiRadioProfile";
position = "104 110";
extent = "27 22";
text = "D";
groupNum = "1";
buttonType = "RadioButton";
};
new GuiRadioCtrl(ND_Wrench_EmitterDir2)
{
profile = "GuiRadioProfile";
position = "130 110";
extent = "27 22";
text = "N";
groupNum = "1";
buttonType = "RadioButton";
};
new GuiRadioCtrl(ND_Wrench_EmitterDir3)
{
profile = "GuiRadioProfile";
position = "156 110";
extent = "27 22";
text = "E";
groupNum = "1";
buttonType = "RadioButton";
};
new GuiRadioCtrl(ND_Wrench_EmitterDir4)
{
profile = "GuiRadioProfile";
position = "182 110";
extent = "27 22";
text = "S";
groupNum = "1";
buttonType = "RadioButton";
};
new GuiRadioCtrl(ND_Wrench_EmitterDir5)
{
profile = "GuiRadioProfile";
position = "208 110";
extent = "27 22";
text = "W";
groupNum = "1";
buttonType = "RadioButton";
};
new GuiTextCtrl()
{
profile = "GuiTextProfile";
position = "13 153";
extent = "22 18";
text = "Item:";
};
new GuiPopUpMenuCtrl(ND_Wrench_Items)
{
profile = "BlockButtonProfile";
position = "76 150";
extent = "162 22";
maxPopupHeight = "200";
};
new GuiTextCtrl()
{
profile = "GuiTextProfile";
position = "13 173";
extent = "43 18";
text = "Item Pos:";
};
new GuiRadioCtrl(ND_Wrench_ItemPos1)
{
profile = "GuiRadioProfile";
position = "104 170";
extent = "27 22";
text = "D";
groupNum = "2";
buttonType = "RadioButton";
};
new GuiRadioCtrl(ND_Wrench_ItemPos0)
{
profile = "GuiRadioProfile";
position = "78 170";
extent = "27 22";
text = "U";
groupNum = "2";
buttonType = "RadioButton";
};
new GuiRadioCtrl(ND_Wrench_ItemPos2)
{
profile = "GuiRadioProfile";
position = "130 170";
extent = "27 22";
text = "N";
groupNum = "2";
buttonType = "RadioButton";
};
new GuiRadioCtrl(ND_Wrench_ItemPos3)
{
profile = "GuiRadioProfile";
position = "156 170";
extent = "27 22";
text = "E";
groupNum = "2";
buttonType = "RadioButton";
};
new GuiRadioCtrl(ND_Wrench_ItemPos4)
{
profile = "GuiRadioProfile";
position = "182 170";
extent = "27 22";
text = "S";
groupNum = "2";
buttonType = "RadioButton";
};
new GuiRadioCtrl(ND_Wrench_ItemPos5)
{
profile = "GuiRadioProfile";
position = "208 170";
extent = "27 22";
text = "W";
groupNum = "2";
buttonType = "RadioButton";
};
new GuiTextCtrl()
{
profile = "GuiTextProfile";
position = "13 193";
extent = "38 18";
text = "Item Dir:";
};
new GuiRadioCtrl(ND_Wrench_ItemDir5)
{
profile = "GuiRadioProfile";
position = "208 190";
extent = "27 22";
text = "W";
groupNum = "3";
buttonType = "RadioButton";
};
new GuiRadioCtrl(ND_Wrench_ItemDir2)
{
profile = "GuiRadioProfile";
position = "130 190";
extent = "27 22";
text = "N";
groupNum = "3";
buttonType = "RadioButton";
};
new GuiRadioCtrl(ND_Wrench_ItemDir3)
{
profile = "GuiRadioProfile";
position = "156 190";
extent = "27 22";
text = "E";
groupNum = "3";
buttonType = "RadioButton";
};
new GuiRadioCtrl(ND_Wrench_ItemDir4)
{
profile = "GuiRadioProfile";
position = "182 190";
extent = "27 22";
text = "S";
groupNum = "3";
buttonType = "RadioButton";
};
new GuiTextCtrl()
{
profile = "GuiTextProfile";
position = "13 213";
extent = "97 18";
text = "Item Respawn Time:";
};
new GuiTextEditCtrl(ND_Wrench_ItemTime)
{
profile = "GuiTextEditProfile";
position = "117 213";
extent = "121 18";
};
new GuiCheckBoxCtrl(ND_Wrench_RayCasting)
{
profile = "GuiCheckBoxProfile";
position = "14 240";
extent = "78 22";
text = "Ray Casting";
buttonType = "ToggleButton";
};
new GuiCheckBoxCtrl(ND_Wrench_Collision)
{
profile = "GuiCheckBoxProfile";
position = "14 260";
extent = "74 22";
text = "Collision";
buttonType = "ToggleButton";
};
new GuiCheckBoxCtrl(ND_Wrench_Rendering)
{
profile = "GuiCheckBoxProfile";
position = "14 280";
extent = "74 22";
text = "Rendering";
buttonType = "ToggleButton";
};
new GuiCheckBoxCtrl(ND_Wrench_ToggleName)
{
profile = "GuiCheckBoxProfile";
position = "244 32";
extent = "42 22";
command = "ND_Wrench_BlockName.setVisible(!$ThisControl.getValue());";
text = "Apply";
buttonType = "ToggleButton";
};
new GuiCheckBoxCtrl(ND_Wrench_ToggleLights)
{
profile = "GuiCheckBoxProfile";
position = "244 60";
extent = "42 22";
command = "ND_Wrench_BlockLights.setVisible(!$ThisControl.getValue());";
text = "Apply";
buttonType = "ToggleButton";
};
new GuiCheckBoxCtrl(ND_Wrench_ToggleEmitters)
{
profile = "GuiCheckBoxProfile";
position = "244 90";
extent = "42 22";
command = "ND_Wrench_BlockEmitters.setVisible(!$ThisControl.getValue());";
text = "Apply";
buttonType = "ToggleButton";
};
new GuiCheckBoxCtrl(ND_Wrench_ToggleEmitterDir)
{
profile = "GuiCheckBoxProfile";
position = "244 110";
extent = "42 22";
command = "ND_Wrench_BlockEmitterDir.setVisible(!$ThisControl.getValue());";
text = "Apply";
buttonType = "ToggleButton";
};
new GuiCheckBoxCtrl(ND_Wrench_ToggleItems)
{
profile = "GuiCheckBoxProfile";
position = "244 150";
extent = "42 22";
command = "ND_Wrench_BlockItems.setVisible(!$ThisControl.getValue());";
text = "Apply";
buttonType = "ToggleButton";
};
new GuiCheckBoxCtrl(ND_Wrench_ToggleItemPos)
{
profile = "GuiCheckBoxProfile";
position = "244 170";
extent = "42 22";
command = "ND_Wrench_BlockItemPos.setVisible(!$ThisControl.getValue());";
text = "Apply";
buttonType = "ToggleButton";
};
new GuiCheckBoxCtrl(ND_Wrench_ToggleItemDir)
{
profile = "GuiCheckBoxProfile";
position = "244 190";
extent = "42 22";
command = "ND_Wrench_BlockItemDir.setVisible(!$ThisControl.getValue());";
text = "Apply";
buttonType = "ToggleButton";
};
new GuiCheckBoxCtrl(ND_Wrench_ToggleItemTime)
{
profile = "GuiCheckBoxProfile";
position = "244 210";
extent = "42 22";
command = "ND_Wrench_BlockItemTime.setVisible(!$ThisControl.getValue());";
text = "Apply";
buttonType = "ToggleButton";
};
new GuiCheckBoxCtrl(ND_Wrench_ToggleRayCasting)
{
profile = "GuiCheckBoxProfile";
position = "244 240";
extent = "42 22";
command = "ND_Wrench_BlockRaycasting.setVisible(!$ThisControl.getValue());";
text = "Apply";
buttonType = "ToggleButton";
};
new GuiCheckBoxCtrl(ND_Wrench_ToggleCollision)
{
profile = "GuiCheckBoxProfile";
position = "244 260";
extent = "42 22";
command = "ND_Wrench_BlockCollision.setVisible(!$ThisControl.getValue());";
text = "Apply";
buttonType = "ToggleButton";
};
new GuiCheckBoxCtrl(ND_Wrench_ToggleRendering)
{
profile = "GuiCheckBoxProfile";
position = "244 280";
extent = "42 22";
command = "ND_Wrench_BlockRendering.setVisible(!$ThisControl.getValue());";
text = "Apply";
buttonType = "ToggleButton";
};
new GuiSwatchCtrl(ND_Wrench_BlockName)
{
profile = "GuiDefaultProfile";
position = "11 32";
extent = "233 24";
color = "200 200 200 200";
};
new GuiSwatchCtrl(ND_Wrench_BlockLights)
{
profile = "GuiDefaultProfile";
position = "11 60";
extent = "233 24";
color = "200 200 200 200";
};
new GuiSwatchCtrl(ND_Wrench_BlockEmitters)
{
profile = "GuiDefaultProfile";
position = "11 89";
extent = "233 24";
color = "200 200 200 200";
};
new GuiSwatchCtrl(ND_Wrench_BlockEmitterDir)
{
profile = "GuiDefaultProfile";
position = "11 114";
extent = "233 24";
color = "200 200 200 200";
};
new GuiSwatchCtrl(ND_Wrench_BlockItems)
{
profile = "GuiDefaultProfile";
position = "11 149";
extent = "233 24";
color = "200 200 200 200";
};
new GuiSwatchCtrl(ND_Wrench_BlockItemPos)
{
profile = "GuiDefaultProfile";
position = "11 173";
extent = "233 20";
color = "200 200 200 200";
};
new GuiSwatchCtrl(ND_Wrench_BlockItemDir)
{
profile = "GuiDefaultProfile";
position = "11 191";
extent = "233 20";
color = "200 200 200 200";
};
new GuiSwatchCtrl(ND_Wrench_BlockItemTime)
{
profile = "GuiDefaultProfile";
position = "11 212";
extent = "233 20";
color = "200 200 200 200";
};
new GuiSwatchCtrl(ND_Wrench_BlockRaycasting)
{
profile = "GuiDefaultProfile";
position = "11 242";
extent = "233 20";
color = "200 200 200 200";
};
new GuiSwatchCtrl(ND_Wrench_BlockCollision)
{
profile = "GuiDefaultProfile";
position = "11 262";
extent = "233 20";
color = "200 200 200 200";
};
new GuiSwatchCtrl(ND_Wrench_BlockRendering)
{
profile = "GuiDefaultProfile";
position = "11 282";
extent = "233 20";
color = "200 200 200 200";
};
new GuiBitmapButtonCtrl(ND_Wrench_Cancel)
{
profile = "BlockButtonProfile";
position = "16 317";
extent = "91 38";
command = "canvas.popDialog(ND_WrenchDlg);";
accelerator = "escape";
text = "<< Cancel";
buttonType = "PushButton";
bitmap = "base/client/ui/button2";
mColor = "255 255 255 255";
};
new GuiBitmapButtonCtrl(ND_Wrench_Send)
{
profile = "BlockButtonProfile";
position = "119 317";
extent = "160 38";
command = "ndSendFillWrenchData();";
text = "Apply Selected to All >>";
buttonType = "PushButton";
bitmap = "base/client/ui/button1";
mColor = "255 255 255 255";
};
};
};

View File

@ -0,0 +1,33 @@
// Responds to the handshake request sent by the server.
// -------------------------------------------------------------------
//Assume server doesn't have the new duplicator
$ND::ServerVersion = "0.0.0";
$ND::ServerHasND = false;
//Receive handshake from server
function clientCmdNdHandshake(%serverVersion)
{
$ND::ServerVersion = %serverVersion;
$ND::ServerHasND = true;
// Prevent servers from pestering us about version mismatches by pretending to have the same version as them.
// The version is basically not used for anything else, so need to send our actual version.
//commandToServer('ndHandshake', $ND::Version);
commandToServer('ndHandshake', %serverVersion);
}
package NewDuplicator_Client
{
//Reset server version on leaving server
function disconnectedCleanup(%bool)
{
$ND::ServerVersion = "0.0.0";
$ND::ServerHasND = false;
//Disable the keybinds
clientCmdNdEnableKeybinds(false);
parent::disconnectedCleanup(%bool);
}
};

164
scripts/client/wrench.cs Normal file
View File

@ -0,0 +1,164 @@
// Prepares the fillWrench gui and handles submitting the settings.
// -------------------------------------------------------------------
package NewDuplicator_Client
{
function clientCmdWrench_LoadMenus()
{
parent::clientCmdWrench_LoadMenus();
$ND::WrenchReloadRequired = true;
}
};
//Open the wrench gui for fill wrench mode
function clientCmdNdOpenWrenchGui()
{
if($ND::WrenchReloadRequired)
{
//Reload the drop down lists
ND_Wrench_Lights.clear();
ND_Wrench_Emitters.clear();
ND_Wrench_Items.clear();
ND_Wrench_Lights.add(" NONE", 0);
ND_Wrench_Emitters.add(" NONE", 0);
ND_Wrench_Items.add(" NONE", 0);
//Add all datablocks to list
%cnt = getDatablockGroupSize();
for(%i = 0; %i < %cnt; %i++)
{
%data = getDatablock(%i);
%uiName = %data.uiName;
//Skip non-selectable datablocks
if(%uiName $= "")
continue;
//Put datablock in correct list
switch$(%data.getClassName())
{
case "FxLightData":
ND_Wrench_Lights.add(%uiName, %data);
case "ParticleEmitterData":
ND_Wrench_Emitters.add(%uiName, %data);
case "ItemData":
ND_Wrench_Items.add(%uiName, %data);
}
}
//Sort lists
ND_Wrench_Lights.sort();
ND_Wrench_Emitters.sort();
ND_Wrench_Items.sort();
//Select NONE
ND_Wrench_Lights.setSelected(0);
ND_Wrench_Emitters.setSelected(0);
ND_Wrench_Items.setSelected(0);
$ND::WrenchReloadRequired = false;
}
//Open gui
Canvas.pushDialog(ND_WrenchDlg);
}
//Send the settings to the server
function ndSendFillWrenchData()
{
//Close gui
Canvas.popDialog(ND_WrenchDlg);
//Pack all enabled settings in string
%str = "";
if(ND_Wrench_ToggleName.getValue())
%str = %str TAB "N" SPC trim(ND_Wrench_Name.getValue());
if(ND_Wrench_ToggleLights.getValue())
%str = %str TAB "LDB" SPC ND_Wrench_Lights.getSelected();
if(ND_Wrench_ToggleEmitters.getValue())
%str = %str TAB "EDB" SPC ND_Wrench_Emitters.getSelected();
if(ND_Wrench_ToggleEmitterDir.getValue())
{
%dir = -1;
for(%i = 0; %i < 6; %i++)
{
%obj = "ND_Wrench_EmitterDir" @ %i;
if(%obj.getValue())
{
%dir = %i;
break;
}
}
if(%dir >= 0)
%str = %str TAB "EDIR" SPC %dir;
}
if(ND_Wrench_ToggleItems.getValue())
%str = %str TAB "IDB" SPC ND_Wrench_Items.getSelected();
if(ND_Wrench_ToggleItemPos.getValue())
{
%pos = -1;
for(%i = 0; %i < 6; %i++)
{
%obj = "ND_Wrench_ItemPos" @ %i;
if(%obj.getValue())
{
%pos = %i;
break;
}
}
if(%pos >= 0)
%str = %str TAB "IPOS" SPC %pos;
}
if(ND_Wrench_ToggleItemDir.getValue())
{
%dir = -1;
for(%i = 2; %i < 6; %i++)
{
%obj = "ND_Wrench_ItemDir" @ %i;
if(%obj.getValue())
{
%dir = %i;
break;
}
}
if(%dir >= 2)
%str = %str TAB "IDIR" SPC %dir;
}
if(ND_Wrench_ToggleItemTime.getValue())
%str = %str TAB "IRT" SPC trim(ND_Wrench_ItemTime.getValue()) * 1;
if(ND_Wrench_ToggleRayCasting.getValue())
%str = %str TAB "RC" SPC ND_Wrench_RayCasting.getValue();
if(ND_Wrench_ToggleCollision.getValue())
%str = %str TAB "C" SPC ND_Wrench_Collision.getValue();
if(ND_Wrench_ToggleRendering.getValue())
%str = %str TAB "R" SPC ND_Wrench_Rendering.getValue();
//Send string
if(strLen(%str))
commandToServer('ndStartFillWrench', trim(%str));
}