]> git.lizzy.rs Git - minetest.git/blob - src/dummygamedef.h
Add keybind to swap items between hands
[minetest.git] / src / dummygamedef.h
1 /*
2 Minetest
3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4 Copyright (C) 2022 TurkeyMcMac, Jude Melton-Houghton <jwmhjwmh@gmail.com>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #pragma once
22
23 #include "gamedef.h"
24 #include "itemdef.h"
25 #include "nodedef.h"
26 #include "craftdef.h"
27 #include "content/mods.h"
28 #include "database/database-dummy.h"
29
30 class DummyGameDef : public IGameDef {
31 public:
32         DummyGameDef():
33                 m_itemdef(createItemDefManager()),
34                 m_nodedef(createNodeDefManager()),
35                 m_craftdef(createCraftDefManager()),
36                 m_mod_storage_database(new Database_Dummy())
37         {
38         }
39
40         ~DummyGameDef()
41         {
42                 delete m_mod_storage_database;
43                 delete m_craftdef;
44                 delete m_nodedef;
45                 delete m_itemdef;
46         }
47
48         IItemDefManager *getItemDefManager() override { return m_itemdef; }
49         const NodeDefManager *getNodeDefManager() override { return m_nodedef; }
50         NodeDefManager* getWritableNodeDefManager() { return m_nodedef; }
51         ICraftDefManager *getCraftDefManager() override { return m_craftdef; }
52
53         u16 allocateUnknownNodeId(const std::string &name) override
54         {
55                 return m_nodedef->allocateDummy(name);
56         }
57
58         const std::vector<ModSpec> &getMods() const override
59         {
60                 static std::vector<ModSpec> emptymodspec;
61                 return emptymodspec;
62         }
63         const ModSpec* getModSpec(const std::string &modname) const override { return nullptr; }
64         ModStorageDatabase *getModStorageDatabase() override { return m_mod_storage_database; }
65
66         bool joinModChannel(const std::string &channel) override { return false; }
67         bool leaveModChannel(const std::string &channel) override { return false; }
68         bool sendModChannelMessage(const std::string &channel, const std::string &message) override
69         {
70                 return false;
71         }
72         ModChannel *getModChannel(const std::string &channel) override { return nullptr; }
73
74 protected:
75         IItemDefManager *m_itemdef = nullptr;
76         NodeDefManager *m_nodedef = nullptr;
77         ICraftDefManager *m_craftdef = nullptr;
78         ModStorageDatabase *m_mod_storage_database = nullptr;
79 };