MCPcopy Create free account
hub / github.com/GlobedGD/globed2 / init

Method init

src/modules/scripting-ui/ui/ScriptLogPanelPopup.cpp:17–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15static const CCSize GRAPH_SIZE {400.f, 240.f};
16
17bool ScriptLogPanelPopup::init() {
18 if (!BasePopup::init(460.f, 300.f)) return false;
19
20 m_editor = Build(CodeEditor::create({400.f, 240.f}))
21 .pos(this->fromCenter(0.f, 10.f))
22 .parent(m_mainLayer);
23
24 m_drawNode = Build(CCDrawNode::create())
25 .anchorPoint(0.5f, 0.5f)
26 .pos(this->fromCenter(5.f, 20.f))
27 .contentSize(GRAPH_SIZE)
28 .parent(m_mainLayer);
29 m_drawNode->m_bUseArea = false;
30
31 m_graphLabelsNode = Build<CCNode>::create()
32 .anchorPoint(0.5f, 0.5f)
33 .pos(this->fromCenter(5.f, 20.f))
34 .contentSize(GRAPH_SIZE)
35 .parent(m_mainLayer);
36
37 m_graphBottomLabels = Build<CCNode>::create()
38 .anchorPoint(0.5f, 0.5f)
39 .pos(this->fromCenter(5.f, 15.f))
40 .contentSize(GRAPH_SIZE)
41 .parent(m_mainLayer);
42
43 m_listener = NetworkManagerImpl::get().listen<msg::ScriptLogsMessage>([this](const auto& msg) {
44 if (m_autoRefresh) {
45 this->refresh();
46 }
47 }, 1000); // be after the gjbgl listener
48
49 auto toggler = Build(CCMenuItemExt::createTogglerWithStandardSprites(0.8f, [this](auto toggler) {
50 bool on = !toggler->isOn();
51 m_autoRefresh = on;
52 }))
53 .parent(m_buttonMenu)
54 .pos(this->fromBottomLeft(21.f, 21.f))
55 .collect();
56 toggler->toggle(m_autoRefresh);
57
58 Build<CCLabelBMFont>::create("Auto refresh", "bigFont.fnt")
59 .scale(0.4f)
60 .parent(m_mainLayer)
61 .pos(this->fromBottomLeft(42.f, 21.f))
62 .anchorPoint(0.f, 0.5f);
63
64 // toggler for switching to graph
65
66 auto swToggler = Build(CCMenuItemExt::createTogglerWithStandardSprites(0.8f, [this](auto toggler) {
67 bool on = !toggler->isOn();
68 this->toggleGraphShown(on);
69 }))
70 .parent(m_buttonMenu)
71 .pos(this->fromBottomRight(76.f, 21.f))
72 .collect();
73
74 Build<CCLabelBMFont>::create("Memory", "bigFont.fnt")

Callers 1

createMethod · 0.45

Calls 4

refreshMethod · 0.95
toggleGraphShownMethod · 0.95
initFunction · 0.50
getFunction · 0.50

Tested by

no test coverage detected