MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / imageHandler

Method imageHandler

source/windowing/StarWidgetParsing.cpp:201–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199}
200
201WidgetConstructResult WidgetParser::imageHandler(String const& name, Json const& config) {
202 auto image = make_shared<ImageWidget>();
203 common(image, config);
204
205 if (config.contains("file"))
206 image->setImage(config.getString("file"));
207
208 if (config.contains("drawables"))
209 image->setDrawables(config.getArray("drawables").transformed([](Json const& d) { return Drawable(d); } ));
210
211 if (config.contains("scale"))
212 image->setScale(config.getFloat("scale"));
213
214 if (config.contains("rotation"))
215 image->setRotation(config.getFloat("rotation"));
216
217 if (config.contains("centered"))
218 image->setCentered(config.getBool("centered"));
219
220 if (config.contains("trim"))
221 image->setTrim(config.getBool("trim"));
222 else
223 image->setTrim(image->centered()); // once upon a time in a magical kingdom, these settings were linked
224
225 if (config.contains("offset"))
226 image->setOffset(jsonToVec2I(config.get("offset")));
227
228 if (config.contains("maxSize"))
229 image->setMaxSize(jsonToVec2I(config.get("maxSize")));
230
231 if (config.contains("minSize"))
232 image->setMinSize(jsonToVec2I(config.get("minSize")));
233
234 return WidgetConstructResult(image, name, config.getFloat("zlevel", 0));
235}
236
237WidgetConstructResult WidgetParser::imageStretchHandler(String const& name, Json const& config) {
238 ImageStretchSet stretchSet = parseImageStretchSet(config.get("stretchSet"));

Callers

nothing calls this directly

Calls 15

DrawableClass · 0.85
jsonToVec2IFunction · 0.85
setImageMethod · 0.80
getStringMethod · 0.80
setDrawablesMethod · 0.80
getArrayMethod · 0.80
getFloatMethod · 0.80
setCenteredMethod · 0.80
getBoolMethod · 0.80
setTrimMethod · 0.80
centeredMethod · 0.80

Tested by

no test coverage detected