From 84eab812554d55f57f592d9af54c8c4b9b98a651 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 2 Oct 2011 16:10:43 +0000 Subject: Added a print() method to list individual templates through the list_template command. --- src/game/base/template.cc | 35 ++++++++++++++++++++++++++++++++++- src/game/base/template.h | 2 ++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/game/base/template.cc b/src/game/base/template.cc index 7ef4106..fd04402 100644 --- a/src/game/base/template.cc +++ b/src/game/base/template.cc @@ -17,7 +17,21 @@ core::InfoType *Template::template_infotype = 0; void func_list_template(const std::string &args) { - Template::list(); + std::stringstream argstr(args); + std::string label; + if (argstr >> label) { + aux::to_label(label); + Template *entitytemplate = Template::find(label); + if (entitytemplate) { + entitytemplate->print(); + + } else { + con_warn << "Unknown template '" << label << "'" << std::endl; + return; + } + } else { + Template::list(); + } } Template *Template::find(const std::string & label) @@ -29,6 +43,25 @@ Template *Template::find(const std::string & label) } } +void Template::print() const { + con_print << "Template '" << label() << "' info id " << id() << std::endl; + // show radius if set + if (radius()) + con_print << " radius " << radius() << std::endl; + + // set modelname + if (modelname().size()) + con_print << " model " << modelname() << std::endl; + + // set primary color + if (has_color()) + con_print << " primary color " << color() << std::endl; + + // set secondary color + if (has_color_second()) + con_print << " primary color " << color_second() << std::endl; +} + void Template::list() { core::Info::list(template_infotype); diff --git a/src/game/base/template.h b/src/game/base/template.h index 7934a7f..a89a092 100644 --- a/src/game/base/template.h +++ b/src/game/base/template.h @@ -44,6 +44,8 @@ public: return template_color_second; } + virtual void print() const; + /* --- actors ----------------------------------------------------- */ /** -- cgit v1.2.3