/
AutomatismMetadata.cpp
168 lines (159 loc) · 6.6 KB
/
AutomatismMetadata.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
* GDevelop Core
* Copyright 2008-2014 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
*/
#include "AutomatismMetadata.h"
#include "GDCore/Events/InstructionMetadata.h"
#include "GDCore/Events/ExpressionMetadata.h"
#include "GDCore/PlatformDefinition/Automatism.h"
#include "GDCore/PlatformDefinition/AutomatismsSharedData.h"
#include <iostream>
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
#include "GDCore/IDE/SkinHelper.h"
#include <wx/file.h>
#include <wx/bitmap.h>
#endif
namespace gd
{
AutomatismMetadata::AutomatismMetadata(const std::string & extensionNamespace_,
const std::string & name_,
const std::string & fullname_,
const std::string & defaultName_,
const std::string & description_,
const std::string & group_,
const std::string & icon24x24,
const std::string & className_,
boost::shared_ptr<gd::Automatism> instance_,
boost::shared_ptr<gd::AutomatismsSharedData> sharedDatasInstance_) :
extensionNamespace(extensionNamespace_),
instance(instance_),
sharedDatasInstance(sharedDatasInstance_)
{
#if defined(GD_IDE_ONLY)
SetFullName(std::string(fullname_));
SetDescription(std::string(description_));
SetDefaultName(std::string(defaultName_));
SetGroup(group_);
className = className_;
iconFilename = icon24x24;
#if !defined(GD_NO_WX_GUI)
if ( gd::SkinHelper::IconExists(iconFilename, 24) )
SetBitmapIcon(gd::SkinHelper::GetIcon(iconFilename, 24));
else if ( wxFile::Exists(iconFilename) )
SetBitmapIcon(wxBitmap(iconFilename, wxBITMAP_TYPE_ANY));
else {
std::cout << "Warning: The icon file for automatism \"" << name_
<< " was not found in the current skin icons"
<< " and the specified name is not an existing filename.";
SetBitmapIcon(wxBitmap(24,24));
}
#endif
#endif
if ( instance ) instance->SetTypeName(name_);
if ( sharedDatasInstance ) sharedDatasInstance->SetTypeName(name_);
}
gd::InstructionMetadata & AutomatismMetadata::AddCondition(const std::string & name,
const std::string & fullname,
const std::string & description,
const std::string & sentence,
const std::string & group,
const std::string & icon,
const std::string & smallicon)
{
#if defined(GD_IDE_ONLY)
std::string nameWithNamespace = extensionNamespace.empty() ? name : extensionNamespace+name;
conditionsInfos[nameWithNamespace] = InstructionMetadata(extensionNamespace, nameWithNamespace, fullname, description, sentence, group, icon, smallicon);
return conditionsInfos[nameWithNamespace];
#endif
}
gd::InstructionMetadata & AutomatismMetadata::AddAction(const std::string & name,
const std::string & fullname,
const std::string & description,
const std::string & sentence,
const std::string & group,
const std::string & icon,
const std::string & smallicon)
{
#if defined(GD_IDE_ONLY)
std::string nameWithNamespace = extensionNamespace.empty() ? name : extensionNamespace+name;
actionsInfos[nameWithNamespace] = InstructionMetadata(extensionNamespace, nameWithNamespace, fullname, description, sentence, group, icon, smallicon);
return actionsInfos[nameWithNamespace];
#endif
}
gd::ExpressionMetadata & AutomatismMetadata::AddExpression(const std::string & name,
const std::string & fullname,
const std::string & description,
const std::string & group,
const std::string & smallicon)
{
#if defined(GD_IDE_ONLY)
//Be careful, automatisms expression do not have namespace ( not necessary as we refer to the auomatism name in the expression )
expressionsInfos[name] = ExpressionMetadata(extensionNamespace, name, fullname, description, group, smallicon);
return expressionsInfos[name];
#endif
}
gd::ExpressionMetadata & AutomatismMetadata::AddStrExpression(const std::string & name,
const std::string & fullname,
const std::string & description,
const std::string & group,
const std::string & smallicon)
{
#if defined(GD_IDE_ONLY)
//Be careful, automatisms expression do not have namespace ( not necessary as we refer to the auomatism name in the expression )
strExpressionsInfos[name] = ExpressionMetadata(extensionNamespace, name, fullname, description, group, smallicon);
return strExpressionsInfos[name];
#endif
}
AutomatismMetadata & AutomatismMetadata::SetFullName(const std::string & fullname_)
{
#if defined(GD_IDE_ONLY)
fullname = fullname_;
#endif
return *this;
}
AutomatismMetadata & AutomatismMetadata::SetDefaultName(const std::string & defaultName_)
{
#if defined(GD_IDE_ONLY)
defaultName = defaultName_;
#endif
return *this;
}
AutomatismMetadata & AutomatismMetadata::SetDescription(const std::string & description_)
{
#if defined(GD_IDE_ONLY)
description = description_;
#endif
return *this;
}
AutomatismMetadata & AutomatismMetadata::SetGroup(const std::string & group_)
{
#if defined(GD_IDE_ONLY)
group = group_;
#endif
return *this;
}
AutomatismMetadata & AutomatismMetadata::SetBitmapIcon(const wxBitmap & bitmap_)
{
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
icon = bitmap_;
#endif
return *this;
}
AutomatismMetadata & AutomatismMetadata::SetIncludeFile(const std::string & includeFile)
{
#if defined(GD_IDE_ONLY)
includeFiles.clear();
includeFiles.push_back(includeFile);
#endif
return *this;
}
AutomatismMetadata & AutomatismMetadata::AddIncludeFile(const std::string & includeFile)
{
#if defined(GD_IDE_ONLY)
if ( std::find(includeFiles.begin(), includeFiles.end(), includeFile) == includeFiles.end())
includeFiles.push_back(includeFile);
#endif
return *this;
}
}