00001 /*************************************************************************** 00002 * Copyright (C) 2008 by Sverre Rabbelier * 00003 * sverre@rabbelier.nl * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 3 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 #pragma once 00021 00022 #include "Types.h" 00023 #include "SavableTypes.h" 00024 00025 #include "OLCEditor.h" 00026 #include "CommandInfoObject.h" 00027 #include "CommandTable.h" 00028 00029 class EditorDetail : public OLCEditor 00030 { 00031 public: 00032 typedef CommandInfoObject<EditorDetail> DetailCommand; 00034 EditorDetail(UBSocket* sock); 00035 EditorDetail(UBSocket* sock, mud::DetailPtr detail); 00036 EditorDetail(UBSocket* sock, mud::AreaPtr parentArea); 00037 EditorDetail(UBSocket* sock, mud::RoomPtr parentRoom); 00038 EditorDetail(UBSocket* sock, mud::ChunkPtr parentChunk); 00039 ~EditorDetail(void); 00040 00041 void OnFocus(); 00042 00043 std::string name() { return "Detail"; }; 00044 std::string prompt() { return "Detail> "; }; 00045 00046 std::string lookup(const std::string& action); 00047 void dispatch(const std::string& action, const std::string& argument); 00048 00049 SavablePtr getEditing(); 00050 TableImplPtr getTable(); 00051 KeysPtr addNew(); 00052 std::vector<std::string> getList(); 00053 std::vector<std::string> getCommands(); 00054 void setEditing(KeysPtr keys); 00055 00056 void editKey(const std::string& argument); 00057 void editDescription(const std::string& argument); 00058 void showDetail(const std::string& argument); 00059 void saveDetail(const std::string& argument); 00060 void clearParents(const std::string& argument); 00061 void setParent(const std::string& argument); 00062 00063 private: 00064 enum E_TARGET 00065 { 00066 M_NONE, 00067 M_DESCRIPTION, 00068 }; 00069 00070 CommandTable<EditorDetail> m_commands; 00071 mud::DetailPtr m_detail; 00072 mud::AreaPtr m_parentArea; 00073 mud::RoomPtr m_parentRoom; 00074 mud::ChunkPtr m_parentChunk; 00075 00076 std::string m_value; 00077 EditorDetail::E_TARGET m_target; 00078 00079 EditorDetail(const EditorDetail& rhs); 00080 EditorDetail operator=(const EditorDetail& rhs); 00081 };