Line data Source code
1 : /* Copyright (C) 2021 Wildfire Games.
2 : * This file is part of 0 A.D.
3 : *
4 : * 0 A.D. is free software: you can redistribute it and/or modify
5 : * it under the terms of the GNU General Public License as published by
6 : * the Free Software Foundation, either version 2 of the License, or
7 : * (at your option) any later version.
8 : *
9 : * 0 A.D. is distributed in the hope that it will be useful,
10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 : * GNU General Public License for more details.
13 : *
14 : * You should have received a copy of the GNU General Public License
15 : * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 : */
17 :
18 : #include "precompiled.h"
19 :
20 : #include "JSInterface_GUIProxy_impl.h"
21 :
22 : #include "gui/ObjectBases/IGUIObject.h"
23 : #include "gui/ObjectTypes/CButton.h"
24 : #include "gui/ObjectTypes/CList.h"
25 : #include "gui/ObjectTypes/CMiniMap.h"
26 : #include "gui/ObjectTypes/CText.h"
27 :
28 : // Called for every specialization - adds the common interface.
29 : template<>
30 30 : void JSI_GUIProxy<IGUIObject>::CreateFunctions(const ScriptRequest& rq, GUIProxyProps* cache)
31 : {
32 30 : CreateFunction<&IGUIObject::GetName>(rq, cache, "toString");
33 30 : CreateFunction<&IGUIObject::GetName>(rq, cache, "toSource");
34 30 : CreateFunction<&IGUIObject::SetFocus>(rq, cache, "focus");
35 30 : CreateFunction<&IGUIObject::ReleaseFocus>(rq, cache, "blur");
36 30 : CreateFunction<&IGUIObject::GetComputedSize>(rq, cache, "getComputedSize");
37 30 : }
38 4 : DECLARE_GUIPROXY(IGUIObject);
39 :
40 : // Implement derived types below.
41 :
42 : // CButton
43 6 : template<> void JSI_GUIProxy<CButton>::CreateFunctions(const ScriptRequest& rq, GUIProxyProps* cache)
44 : {
45 6 : CreateFunction<&CButton::GetTextSize>(rq, cache, "getTextSize");
46 6 : }
47 0 : DECLARE_GUIPROXY(CButton);
48 :
49 : // CText
50 6 : template<> void JSI_GUIProxy<CText>::CreateFunctions(const ScriptRequest& rq, GUIProxyProps* cache)
51 : {
52 6 : CreateFunction<&CText::GetTextSize>(rq, cache, "getTextSize");
53 6 : }
54 0 : DECLARE_GUIPROXY(CText);
55 :
56 : // CList
57 6 : template<> void JSI_GUIProxy<CList>::CreateFunctions(const ScriptRequest& rq, GUIProxyProps* cache)
58 : {
59 6 : CreateFunction<static_cast<void(CList::*)(const CGUIString&)>(&CList::AddItem)>(rq, cache, "addItem");
60 6 : }
61 0 : DECLARE_GUIPROXY(CList);
62 :
63 : // CMiniMap
64 6 : template<> void JSI_GUIProxy<CMiniMap>::CreateFunctions(const ScriptRequest& rq, GUIProxyProps* cache)
65 : {
66 6 : CreateFunction<&CMiniMap::Flare>(rq, cache, "flare");
67 6 : }
68 0 : DECLARE_GUIPROXY(CMiniMap);
|