@@ -11,10 +11,13 @@ bool RecorderLayer::init() {
1111 addChild (m_pLayer);
1212
1313 auto bg = cocos2d::extension::CCScale9Sprite::create (" GJ_square01.png" , { 0 .0f , 0 .0f , 80 .0f , 80 .0f });
14- bg->setContentSize ({250 , 200 });
14+ const CCSize window_size (400 , 250 );
15+ bg->setContentSize (window_size);
1516 bg->setPosition (win_size / 2 );
1617 m_pLayer->addChild (bg);
1718
19+ const CCPoint top_left = win_size / 2 .f - ccp (window_size.width / 2 .f , -window_size.height / 2 .f );
20+
1821 m_pButtonMenu = CCMenu::create ();
1922 m_pButtonMenu->setPosition ({0 , 0 });
2023 auto menu = m_pButtonMenu; // sorry m_pButtonMenu is too much to type
@@ -29,58 +32,95 @@ bool RecorderLayer::init() {
2932 auto & rs = ReplaySystem::get_instance ();
3033
3134 auto toggler = gd::CCMenuItemToggler::create (check_off_sprite, check_on_sprite, this , menu_selector (RecorderLayer::on_toggle_recorder));
32- toggler->setPosition (center - ccp (98 . 0f , -70 . 0f ));
35+ toggler->setPosition (top_left + ccp (30 . f , -30 . f ));
3336 toggler->toggle (rs.recorder .m_recording );
3437 auto label = CCLabelBMFont::create (" Record" , " bigFont.fnt" );
35- label->setPosition (center - ccp (73 .f , -70 .f ));
38+ label->setPosition (top_left + ccp (55 .f , -30 .f ));
39+ label->setScale (0 .7f );
3640 label->setAnchorPoint ({0 , 0 .5f });
3741 menu->addChild (toggler);
3842 layer->addChild (label);
3943
4044 toggler = gd::CCMenuItemToggler::create (check_off_sprite, check_on_sprite, this , menu_selector (RecorderLayer::on_toggle_until_end));
41- toggler->setPosition (center - ccp (98 . 0f , -35 . 0f ));
45+ toggler->setPosition (top_left + ccp (30 . f , -65 . f ));
4246 toggler->toggle (rs.recorder .m_until_end );
4347 label = CCLabelBMFont::create (" Record until the end" , " bigFont.fnt" );
44- label->limitLabelWidth ( 180 . f , 1 . f , 0 . 1f );
45- label->setPosition (center - ccp (73 .f , -35 .f ));
48+ label->setScale ( 0 . 7f );
49+ label->setPosition (top_left + ccp (55 .f , -65 .f ));
4650 label->setAnchorPoint ({0 , 0 .5f });
4751 menu->addChild (toggler);
4852 layer->addChild (label);
4953
50- auto input = NumberInputNode::create ({ 70 .f , 30 .f } );
54+ auto input = NumberInputNode::create (CCSize ( 70 .f , 30 .f ) );
5155 input->set_value (rs.recorder .m_width );
52- input->setPosition (center - ccp (79 , 0 ));
56+ input->setPosition (top_left + ccp (49 . f , - 104 . f ));
5357 input->input_node ->setMaxLabelScale (0 .73f );
54- input->callback = [](auto input) {
55- ReplaySystem::get_instance () .recorder .m_width = input->get_value ();
58+ input->callback = [&rs ](auto input) {
59+ rs .recorder .m_width = input->get_value ();
5660 };
5761 layer->addChild (input);
5862
59- input = NumberInputNode::create ({70 .f , 30 .f });
63+ layer->addChild (NodeFactory<CCLabelBMFont>::start (" x" , " bigFont.fnt" )
64+ .setPosition (top_left + ccp (93 .5f , -104 .f ))
65+ .setScale (0 .5f ));
66+
67+ input = NumberInputNode::create (CCSize (70 .f , 30 .f ));
6068 input->set_value (rs.recorder .m_height );
61- input->setPosition (center - ccp (4 , 0 ));
69+ input->setPosition (top_left + ccp (137 . f , - 104 . f ));
6270 input->input_node ->setMaxLabelScale (0 .73f );
6371 input->callback = [&rs](auto input) {
6472 rs.recorder .m_height = input->get_value ();
6573 };
6674 layer->addChild (input);
6775
68- input = NumberInputNode::create ({50 .f , 30 .f });
76+ layer->addChild (NodeFactory<CCLabelBMFont>::start (" @" , " bigFont.fnt" )
77+ .setPosition (top_left + ccp (185 .5f , -104 .f ))
78+ .setScale (0 .5f ));
79+
80+ input = NumberInputNode::create (CCSize (50 .f , 30 .f ));
6981 input->set_value (rs.recorder .m_fps );
70- input->setPosition (center + ccp (76 , 0 ));
82+ input->setPosition (top_left + ccp (225 . f , - 104 . f ));
7183 input->input_node ->setMaxLabelScale (0 .73f );
7284 input->callback = [&rs](auto input) {
7385 rs.recorder .m_fps = input->get_value ();
7486 };
7587 layer->addChild (input);
7688
77- auto btn = gd::CCMenuItemSpriteExtra::create (
78- CCSprite::createWithSpriteFrameName (" gj_folderBtn_001.png" ),
79- this ,
80- menu_selector (RecorderLayer::on_pick_path)
81- );
82- btn->setPosition (center - ccp (98 .f , 63 .f ));
83- menu->addChild (btn);
89+ const std::string broad_filter = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.,;-_=+@!\" :0123456789$[](){}" ;
90+
91+ auto text_input = TextInputNode::create (CCSize (60 .f , 30 .f ), 1 .f , " chatFont.fnt" );
92+ text_input->setPosition (top_left + ccp (291 .5f , -177 .f ));
93+ text_input->input_node ->setAllowedChars (broad_filter);
94+ text_input->set_value (rs.recorder .m_bitrate );
95+ text_input->callback = [&rs](auto input) {
96+ rs.recorder .m_bitrate = input->get_value ();
97+ };
98+ layer->addChild (text_input);
99+
100+ text_input = TextInputNode::create (CCSize (60 .f , 30 .f ), 1 .f , " chatFont.fnt" );
101+ text_input->setPosition (top_left + ccp (359 .5f , -177 .f ));
102+ text_input->input_node ->m_sCaption = " Default" ;
103+ text_input->input_node ->setAllowedChars (broad_filter);
104+ text_input->input_node ->setLabelPlaceholderColor ({200 , 200 , 200 });
105+ text_input->set_value (rs.recorder .m_codec );
106+ text_input->callback = [&rs](auto input) {
107+ rs.recorder .m_codec = input->get_value ();
108+ };
109+ layer->addChild (text_input);
110+
111+ text_input = TextInputNode::create (CCSize (128 .f , 30 .f ), 1 .f , " chatFont.fnt" );
112+ text_input->setPosition (top_left + ccp (324 .5f , -217 .f ));
113+ text_input->input_node ->m_sCaption = " Extra options" ;
114+ text_input->input_node ->setAllowedChars (broad_filter);
115+ text_input->set_value (rs.recorder .m_extra_args );
116+ text_input->callback = [&rs](auto input) {
117+ rs.recorder .m_extra_args = input->get_value ();
118+ };
119+ text_input->input_node ->setLabelPlaceholderColor ({200 , 200 , 200 });
120+ layer->addChild (text_input);
121+
122+ layer->addChild (NodeFactory<CCLabelBMFont>::start (" Bitrate" , " bigFont.fnt" ).setPosition (top_left + ccp (291 .5f , -152 .f )).setScale (0 .4f ));
123+ layer->addChild (NodeFactory<CCLabelBMFont>::start (" Codec" , " bigFont.fnt" ).setPosition (top_left + ccp (359 .5f , -152 .f )).setScale (0 .4f ));
84124
85125 registerWithTouchDispatcher ();
86126 CCDirector::sharedDirector ()->getTouchDispatcher ()->incrementForcePrio (2 );
@@ -92,7 +132,8 @@ bool RecorderLayer::init() {
92132 );
93133
94134 m_pButtonMenu->addChild (close_btn);
95- close_btn->setPosition (50 .f , win_size.height - 50 .f );
135+ close_btn->setPosition (18 .f , win_size.height - 18 .f );
136+ close_btn->getNormalImage ()->setScale (.75f );
96137
97138 setKeypadEnabled (true );
98139 setTouchEnabled (true );
@@ -111,25 +152,26 @@ void RecorderLayer::on_close(CCObject*) {
111152
112153void RecorderLayer::on_toggle_recorder (CCObject* obj) {
113154 auto & rs = ReplaySystem::get_instance ();
114- if (static_cast <gd::CCMenuItemToggler*>(obj)->isOn ()) {
155+ auto toggler = static_cast <gd::CCMenuItemToggler*>(obj);
156+ if (toggler->isOn ()) {
115157 rs.recorder .stop ();
116158 } else {
117- // TODO: warn the user? idk theyre kinda dumb
118- if (!rs.is_playing ())
119- rs.toggle_playing ();
120- rs.recorder .start ();
159+ nfdchar_t * path = nullptr ;
160+ if (NFD_SaveDialog (" mp4" , nullptr , &path) == NFD_OKAY) {
161+ // TODO: warn the user? idk theyre kinda dumb
162+ if (!rs.is_playing ())
163+ rs.toggle_playing ();
164+ std::string p = std::string (path) + " .mp4" ;
165+ std::cout << " saving it to " << p << std::endl;
166+ rs.recorder .start (p);
167+ free (path);
168+ } else {
169+ // toggle it on so then gd does !on and then turns it off then boom success
170+ toggler->toggle (true );
171+ }
121172 }
122173}
123174
124175void RecorderLayer::on_toggle_until_end (CCObject* obj) {
125176 ReplaySystem::get_instance ().recorder .m_until_end = !static_cast <gd::CCMenuItemToggler*>(obj)->isOn ();
126- }
127-
128- void RecorderLayer::on_pick_path (CCObject*) {
129- nfdchar_t * path = nullptr ;
130- if (NFD_SaveDialog (" mp4" , nullptr , &path) == NFD_OKAY) {
131- ReplaySystem::get_instance ().recorder .m_output_path = std::string (path) + " .mp4" ;
132- std::cout << " set path to " << ReplaySystem::get_instance ().recorder .m_output_path << std::endl;
133- free (path);
134- }
135177}
0 commit comments