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

Method applyCommands

source/rendering/StarTextPainter.cpp:341–372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339}
340
341void TextPainter::applyCommands(StringView unsplitCommands) {
342 unsplitCommands.forEachSplitView(",", [&](StringView command, size_t, size_t) {
343 try {
344 if (command == "reset") {
345 m_renderSettings = m_savedRenderSettings;
346 m_fontTextureGroup.switchFont(m_renderSettings.font);
347 } else if (command == "set") {
348 m_savedRenderSettings = m_renderSettings;
349 } else if (command.beginsWith("shadow")) {
350 if (command.utf8Size() == 6)
351 m_renderSettings.shadow = Color::Black.toRgba();
352 else if (command.utf8()[6] == '=')
353 m_renderSettings.shadow = Color(command.substr(7)).toRgba();
354 } else if (command == "noshadow") {
355 m_renderSettings.shadow = Color::Clear.toRgba();
356 } else if (command.beginsWith("font=")) {
357 setFont(m_renderSettings.font = command.substr(5));
358 } else if (command.beginsWith("directives=")) {
359 setProcessingDirectives(command.substr(11));
360 } else if (command.beginsWith("backdirectives=")) {
361 setProcessingDirectives(command.substr(15), true);
362 } else {
363 // expects both #... sequences and plain old color names.
364 Color c = Color(command);
365 c.setAlphaF(c.alphaF() * ((float)m_savedRenderSettings.color[3]) / 255);
366 m_renderSettings.color = c.toRgba();
367 }
368 } catch (JsonException&) {
369 } catch (ColorException&) {
370 }
371 });
372}
373
374void TextPainter::modifyDirectives(Directives& directives) {
375 if (directives) {

Callers

nothing calls this directly

Calls 9

ColorClass · 0.85
forEachSplitViewMethod · 0.80
switchFontMethod · 0.80
toRgbaMethod · 0.80
setAlphaFMethod · 0.80
alphaFMethod · 0.80
beginsWithMethod · 0.45
utf8SizeMethod · 0.45
substrMethod · 0.45

Tested by

no test coverage detected