From 8966c16ad298f94be1f4542afa6b081a1d286eda Mon Sep 17 00:00:00 2001 From: Kahrl Date: Fri, 23 Aug 2013 12:24:11 +0200 Subject: Add formspec table --- src/guiTable.h | 269 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 269 insertions(+) create mode 100644 src/guiTable.h (limited to 'src/guiTable.h') diff --git a/src/guiTable.h b/src/guiTable.h new file mode 100644 index 000000000..4d5b39166 --- /dev/null +++ b/src/guiTable.h @@ -0,0 +1,269 @@ +/* +Minetest +Copyright (C) 2013 celeron55, Perttu Ahola + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + + +#ifndef GUITABLE_HEADER +#define GUITABLE_HEADER + +#include +#include +#include +#include +#include + +#include "irrlichttypes_extrabloated.h" + +class ISimpleTextureSource; + +/* + A table GUI element for GUIFormSpecMenu. + + Sends a EGET_TABLE_CHANGED event to the parent when + an item is selected or double-clicked. + Call checkEvent() to get info. + + Credits: The interface and implementation of this class are (very) + loosely based on the Irrlicht classes CGUITable and CGUIListBox. + CGUITable and CGUIListBox are licensed under the Irrlicht license; + they are Copyright (C) 2002-2012 Nikolaus Gebhardt +*/ +class GUITable : public gui::IGUIElement +{ +public: + /* + Stores dynamic data that should be preserved + when updating a formspec + */ + struct DynamicData + { + s32 selected; + s32 scrollpos; + s32 keynav_time; + core::stringw keynav_buffer; + std::set opened_trees; + + DynamicData() + { + selected = 0; + scrollpos = 0; + keynav_time = 0; + } + }; + + /* + An option of the form = + */ + struct Option + { + std::string name; + std::string value; + + Option(const std::string &name_, const std::string &value_) + { + name = name_; + value = value_; + } + }; + + /* + A list of options that concern the entire table + */ + typedef std::vector