From eb80bad7c3012f4ed674eb498fb7d5aee121befc Mon Sep 17 00:00:00 2001 From: Mircea Kitsune Date: Sat, 29 Oct 2011 22:51:44 +0300 Subject: [PATCH] And now for something a little different: No longer use a string for the clipboard, but a client-side cvar. This offers many new possibilities... such as multiple clipboards, object presets and shortcuts, exporting objects and posting them online (forum, twitter, etc), and using the clipboard between servers. eg: Say you see an object you can copy, and wanna put it on your server. Just copy it from the Sandbox menu, disconnect, connect to your server, and paste. Your object will be there :) --- defaultXonotic.cfg | 1 + qcsrc/menu/xonotic/dialog_sandboxtools.c | 2 +- qcsrc/server/mutators/sandbox.qc | 7 ++++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index b3a5f54de0..a155221fe9 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -557,6 +557,7 @@ set g_sandbox_object_scale_min 0.1 "minimum scale that objects can be set to" set g_sandbox_object_scale_max 2 "maximum scale that objects can be set to" set g_sandbox_object_material_velocity_min 100 "velocity objects must have while colliding for material effects to be applied" set g_sandbox_object_material_velocity_factor 0.002 "velocity range which decides the intensity of material effects" +set cl_sandbox_clipboard "" seta menu_sandbox_spawn_model "" seta menu_sandbox_attach_bone "" diff --git a/qcsrc/menu/xonotic/dialog_sandboxtools.c b/qcsrc/menu/xonotic/dialog_sandboxtools.c index ed2d719497..f9f22942a7 100644 --- a/qcsrc/menu/xonotic/dialog_sandboxtools.c +++ b/qcsrc/menu/xonotic/dialog_sandboxtools.c @@ -24,7 +24,7 @@ void XonoticSandboxToolsDialog_fill(entity me) me.TD(me, 1, 0.5, makeXonoticCommandButton(_("Spawn"), '0 0 0', "sandbox object_spawn \"$menu_sandbox_spawn_model\"", 0)); me.TD(me, 1, 0.5, makeXonoticCommandButton(_("Remove *"), '0 0 0', "sandbox object_remove", 0)); me.TDempty(me, 0.1); - me.TD(me, 1, 0.5, makeXonoticCommandButton(_("Copy *"), '0 0 0', "sandbox object_duplicate copy", 0)); + me.TD(me, 1, 0.5, makeXonoticCommandButton(_("Copy *"), '0 0 0', "sandbox object_duplicate copy cl_sandbox_clipboard", 0)); me.TD(me, 1, 0.5, makeXonoticCommandButton(_("Paste"), '0 0 0', "sandbox object_duplicate paste", 0)); me.TR(me); me.TD(me, 1, 0.25, e = makeXonoticTextLabel(0, _("Bone:"))); diff --git a/qcsrc/server/mutators/sandbox.qc b/qcsrc/server/mutators/sandbox.qc index 9af2e65a51..e49fbd2188 100644 --- a/qcsrc/server/mutators/sandbox.qc +++ b/qcsrc/server/mutators/sandbox.qc @@ -374,6 +374,7 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand) { entity e; float i; + string s; // ---------------- COMMAND: HELP ---------------- case "help": @@ -450,9 +451,9 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand) e = sandbox_ObjectEdit_Get(autocvar_g_sandbox_editor_free); // can we copy objects we can't edit? if(e != world) { - if(self.object_clipboard) - strunzone(self.object_clipboard); - self.object_clipboard = strzone(sandbox_ObjectPort_Save(e, FALSE)); + s = sandbox_ObjectPort_Save(e, FALSE); + s = strreplace("\"", "\\\"", s); + stuffcmd(self, strcat("set ", argv(3), " \"", s, "\"")); print_to(self, "^2SANDBOX - INFO: ^7Object copied to clipboard"); return TRUE; -- 2.39.2