From 7fc7594c2f33f89fed08e375fc8f240dfa3ceca5 Mon Sep 17 00:00:00 2001 From: Mircea Kitsune Date: Fri, 28 Oct 2011 00:22:14 +0300 Subject: [PATCH] Merge duplicate_object_copy and duplicate_object_paste into a single duplicate_object command, with copy and paste as arguments --- qcsrc/menu/xonotic/dialog_sandboxtools.c | 14 +---- qcsrc/server/mutators/sandbox.qc | 71 ++++++++++++------------ 2 files changed, 37 insertions(+), 48 deletions(-) diff --git a/qcsrc/menu/xonotic/dialog_sandboxtools.c b/qcsrc/menu/xonotic/dialog_sandboxtools.c index 320eaa800..3e6563cc4 100644 --- a/qcsrc/menu/xonotic/dialog_sandboxtools.c +++ b/qcsrc/menu/xonotic/dialog_sandboxtools.c @@ -24,8 +24,8 @@ void XonoticSandboxToolsDialog_fill(entity me) me.TD(me, 1, 0.5, makeXonoticCommandButton(_("Spawn"), '0 0 0', "sandbox spawn_object $menu_sandbox_spawn_model", 0)); me.TD(me, 1, 0.5, makeXonoticCommandButton(_("Remove *"), '0 0 0', "sandbox remove_object", 0)); me.TDempty(me, 0.1); - me.TD(me, 1, 0.5, makeXonoticCommandButton(_("Copy *"), '0 0 0', "sandbox duplicate_object_copy", 0)); - me.TD(me, 1, 0.5, makeXonoticCommandButton(_("Paste"), '0 0 0', "sandbox duplicate_object_paste", 0)); + me.TD(me, 1, 0.5, makeXonoticCommandButton(_("Copy *"), '0 0 0', "sandbox duplicate_object copy", 0)); + me.TD(me, 1, 0.5, makeXonoticCommandButton(_("Paste"), '0 0 0', "sandbox duplicate_object paste", 0)); me.TR(me); me.TD(me, 1, 0.25, e = makeXonoticTextLabel(0, _("Bone:"))); me.TD(me, 1, 1.5, box = makeXonoticInputBox(1, "menu_sandbox_attach_bone")); @@ -58,20 +58,10 @@ void XonoticSandboxToolsDialog_fill(entity me) me.TD(me, 1, 2, e = makeXonoticTextLabel(0, _("Physical object properties for *:"))); me.TR(me); me.TD(me, 1, 0.5, makeXonoticCommandButton(_("Set material:"), '0 0 0', "sandbox edit_object material $menu_sandbox_edit_material", 0)); - - /*me.TD(me, 1, 1.5, e = makeXonoticTextSlider("menu_sandbox_edit_material")); - e.addValue(e, _("none"), "0"); - e.addValue(e, _("metal"), "1"); - e.addValue(e, _("stone"), "2"); - e.addValue(e, _("wood"), "3"); - e.addValue(e, _("flesh"), "4"); - e.configureXonoticTextSliderValues(e);*/ - me.TD(me, 1, 1.5, box = makeXonoticInputBox(1, "menu_sandbox_edit_material")); box.forbiddenCharacters = "\r\n\\\"$"; // don't care, isn't getting saved box.maxLength = -127; // negative means encoded length in bytes box.saveImmediately = 1; - me.TD(me, 1, 0.5, makeXonoticCommandButton(_("Set physics:"), '0 0 0', "sandbox edit_object physics $menu_sandbox_edit_physics", 0)); me.TD(me, 1, 0.5, e = makeXonoticRadioButton(1, "menu_sandbox_edit_physics", "0", _("Static"))); me.TD(me, 1, 0.5, e = makeXonoticRadioButton(1, "menu_sandbox_edit_physics", "1", _("Movable"))); diff --git a/qcsrc/server/mutators/sandbox.qc b/qcsrc/server/mutators/sandbox.qc index 4e65f4eaf..82599aae3 100644 --- a/qcsrc/server/mutators/sandbox.qc +++ b/qcsrc/server/mutators/sandbox.qc @@ -204,8 +204,7 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand) print_to(self, "^7\"^2spawn_item ^3item^7\" spawns the specified item in front of the player. Only weapons are currently supported"); print_to(self, "^7\"^2spawn_object ^3models/foo/bar.md3^7\" spawns a new object in front of the player, and gives it the specified model"); print_to(self, "^7\"^2remove_object^7\" removes the object the player is looking at. Players can only remove their own objects"); - print_to(self, "^7\"^2duplicate_object_copy^7\" copies the object the player is looking at. Players can only copy their own objects"); - print_to(self, "^7\"^2duplicate_object_paste^7\" pastes the copied object in front of the player"); + print_to(self, "^7\"^2duplicate_object ^3value^7\" duplicates the object. 'copy' copies the object, 'paste' puts it in front of the player"); print_to(self, "^7\"^2claim_object^7\" sets the player as the owner of the object, if he has the right to edit it"); print_to(self, "^7\"^2attach_object ^3property value^7\" attaches one object to another. Players can only attach their own objects"); print_to(self, "^7Attachment properties for ^2attach_object^7:"); @@ -295,46 +294,46 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand) print_to(self, "WARNING: Object could not be removed. Make sure you are facing an object that belongs to you (default)"); return TRUE; - // ---------------- COMMAND: DUPLICATE OBJECT COPY ---------------- - case "duplicate_object_copy": - // copies customizable properties of the selected object to the clipboard - - e = sandbox_EditObject_Get(); // you can only copy objects you can edit, so this works - if(e != world) + // ---------------- COMMAND: DUPLICATE OBJECT ---------------- + case "duplicate_object": + switch(argv(2)) { - if(self.object_clipboard) - strunzone(self.object_clipboard); - self.object_clipboard = strzone(sandbox_Storage_Save(e)); + case "copy": + // copies customizable properties of the selected object to the clipboard + e = sandbox_EditObject_Get(); // you can only copy objects you can edit, so this works + if(e != world) + { + if(self.object_clipboard) + strunzone(self.object_clipboard); + self.object_clipboard = strzone(sandbox_Storage_Save(e)); - print_to(self, "Object copied to clipboard"); - return TRUE; - } + print_to(self, "Object copied to clipboard"); + return TRUE; + } + print_to(self, "WARNING: Object could not be copied. Make sure you are facing an object that belongs to you (default)"); + return TRUE; - print_to(self, "WARNING: Object could not be copied. Make sure you are facing an object that belongs to you (default)"); - return TRUE; + case "paste": + // spawns a new object using the properties in the player's clipboard + if(!self.object_clipboard) // no object in clipboard + { + print_to(self, "WARNING: No object in clipboard. You must copy an object before you can paste it"); + return TRUE; + } + if(object_count >= autocvar_g_sandbox_editor_maxobjects) + { + print_to(self, strcat("WARNING: Cannot spawn any more objects. Up to ^3", ftos(autocvar_g_sandbox_editor_maxobjects), " ^7objects may exist at a time")); + return TRUE; + } - // ---------------- COMMAND: DUPLICATE OBJECT PASTE ---------------- - case "duplicate_object_paste": - // spawns a new object using the properties in the player's clipboard + e = sandbox_SpawnObject(); + sandbox_Storage_Load(e, self.object_clipboard); - if(!self.object_clipboard) // no object in clipboard - { - print_to(self, "WARNING: No object in clipboard. You must copy an object before you can paste it"); - return TRUE; - } - if(object_count >= autocvar_g_sandbox_editor_maxobjects) - { - print_to(self, strcat("WARNING: Cannot spawn any more objects. Up to ^3", ftos(autocvar_g_sandbox_editor_maxobjects), " ^7objects may exist at a time")); - return TRUE; + print_to(self, "Object pasted successfully"); + if(autocvar_g_sandbox_info) + print(strcat(self.netname, " pasted an object at origin ", vtos(e.origin), "\n")); + return TRUE; } - - e = sandbox_SpawnObject(); - sandbox_Storage_Load(e, self.object_clipboard); - - print_to(self, "Object pasted successfully"); - if(autocvar_g_sandbox_info) - print(strcat(self.netname, " pasted an object at origin ", vtos(e.origin), "\n")); - return TRUE; // ---------------- COMMAND: CLAIM OBJECT ---------------- -- 2.39.2