ConfigClient.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. /*
  2. ==============================================================================
  3. This is an automatically generated GUI class created by the Introjucer!
  4. Be careful when adding custom code to these files, as only the code within
  5. the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
  6. and re-saved.
  7. Created with Introjucer version: 3.1.0
  8. ------------------------------------------------------------------------------
  9. The Introjucer is part of the JUCE library - "Jules' Utility Class Extensions"
  10. Copyright 2004-13 by Raw Material Software Ltd.
  11. ==============================================================================
  12. */
  13. //[Headers] You can add your own extra header files here...
  14. #include "Constants.h"
  15. //[/Headers]
  16. #include "ConfigClient.h"
  17. //[MiscUserDefs] You can add your own user definitions and misc code here...
  18. //[/MiscUserDefs]
  19. //==============================================================================
  20. ConfigClient::ConfigClient (ValueTree config_store)
  21. : configStore(config_store)
  22. {
  23. addAndMakeVisible (saveAudioLabel = new Label ("saveAudioLabel",
  24. TRANS("save audio")));
  25. saveAudioLabel->setFont (Font (15.00f, Font::plain));
  26. saveAudioLabel->setJustificationType (Justification::centredTop);
  27. saveAudioLabel->setEditable (false, false, false);
  28. saveAudioLabel->setColour (Label::textColourId, Colours::white);
  29. saveAudioLabel->setColour (TextEditor::textColourId, Colours::black);
  30. saveAudioLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
  31. addAndMakeVisible (saveAudioComboBox = new ComboBox ("saveAudioComboBox"));
  32. saveAudioComboBox->setExplicitFocusOrder (1);
  33. saveAudioComboBox->setEditableText (false);
  34. saveAudioComboBox->setJustificationType (Justification::centredLeft);
  35. saveAudioComboBox->setTextWhenNothingSelected (String::empty);
  36. saveAudioComboBox->setTextWhenNoChoicesAvailable (TRANS("(no choices)"));
  37. saveAudioComboBox->addItem (TRANS("delete asap"), 1);
  38. saveAudioComboBox->addItem (TRANS("dont save"), 2);
  39. saveAudioComboBox->addItem (TRANS("save ogg"), 3);
  40. saveAudioComboBox->addItem (TRANS("save ogg and wav"), 4);
  41. saveAudioComboBox->addListener (this);
  42. addAndMakeVisible (oggMixdownButton = new ToggleButton ("oggMixdownButton"));
  43. oggMixdownButton->setExplicitFocusOrder (2);
  44. oggMixdownButton->setButtonText (TRANS("ogg mixdown"));
  45. oggMixdownButton->addListener (this);
  46. oggMixdownButton->setColour (ToggleButton::textColourId, Colours::white);
  47. addAndMakeVisible (wavMixdownButton = new ToggleButton ("wavMixdownButton"));
  48. wavMixdownButton->setExplicitFocusOrder (3);
  49. wavMixdownButton->setButtonText (TRANS("wav mixdown"));
  50. wavMixdownButton->addListener (this);
  51. wavMixdownButton->setColour (ToggleButton::textColourId, Colours::white);
  52. addAndMakeVisible (debugLevelLabel = new Label ("debugLevelLabel",
  53. TRANS("debug level")));
  54. debugLevelLabel->setFont (Font (15.00f, Font::plain));
  55. debugLevelLabel->setJustificationType (Justification::centredTop);
  56. debugLevelLabel->setEditable (false, false, false);
  57. debugLevelLabel->setColour (Label::textColourId, Colours::white);
  58. debugLevelLabel->setColour (TextEditor::textColourId, Colours::black);
  59. debugLevelLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
  60. addAndMakeVisible (debugLevelComboBox = new ComboBox ("debugLevelComboBox"));
  61. debugLevelComboBox->setExplicitFocusOrder (4);
  62. debugLevelComboBox->setEditableText (false);
  63. debugLevelComboBox->setJustificationType (Justification::centredLeft);
  64. debugLevelComboBox->setTextWhenNothingSelected (String::empty);
  65. debugLevelComboBox->setTextWhenNoChoicesAvailable (TRANS("(no choices)"));
  66. debugLevelComboBox->addItem (TRANS("silent"), 1);
  67. debugLevelComboBox->addItem (TRANS("audio"), 2);
  68. debugLevelComboBox->addItem (TRANS("audio and network"), 3);
  69. debugLevelComboBox->addItem (TRANS("linjam trace"), 4);
  70. debugLevelComboBox->addListener (this);
  71. addAndMakeVisible (saveLogButton = new ToggleButton ("saveLogButton"));
  72. saveLogButton->setExplicitFocusOrder (5);
  73. saveLogButton->setButtonText (TRANS("save log"));
  74. saveLogButton->addListener (this);
  75. saveLogButton->setColour (ToggleButton::textColourId, Colours::white);
  76. addAndMakeVisible (hideBotsButton = new ToggleButton ("hideBotsButton"));
  77. hideBotsButton->setExplicitFocusOrder (6);
  78. hideBotsButton->setButtonText (TRANS("hide bots"));
  79. hideBotsButton->addListener (this);
  80. hideBotsButton->setToggleState (true, dontSendNotification);
  81. hideBotsButton->setColour (ToggleButton::textColourId, Colours::white);
  82. //[UserPreSize]
  83. //[/UserPreSize]
  84. setSize (614, 434);
  85. //[Constructor] You can add your own custom stuff here..
  86. int save_audio_mode = int( this->configStore[CONFIG::SAVE_AUDIO_MODE_ID]) ;
  87. int mixdown_mode = int( this->configStore[CONFIG::MIXDOWN_MODE_ID]) ;
  88. int debug_level = int( this->configStore[CONFIG::DEBUG_LEVEL_ID]) ;
  89. bool should_save_log = bool(this->configStore[CONFIG::SHOULD_SAVE_LOG_KEY]) ;
  90. bool should_hide_bots = bool(this->configStore[CONFIG::SHOULD_HIDE_BOTS_KEY]) ;
  91. bool should_mixdown_ogg = !!(mixdown_mode & (int)NJClient::SAVE_MIXDOWN_OGG) ;
  92. bool should_mixdown_wav = !!(mixdown_mode & (int)NJClient::SAVE_MIXDOWN_WAV) ;
  93. saveAudioComboBox ->setSelectedId(save_audio_mode + CONFIG::SAVE_AUDIO_ENUM_OFFSET) ;
  94. debugLevelComboBox->setSelectedItemIndex(debug_level) ;
  95. oggMixdownButton ->setToggleState(should_mixdown_ogg , juce::dontSendNotification) ;
  96. wavMixdownButton ->setToggleState(should_mixdown_wav , juce::dontSendNotification) ;
  97. saveLogButton ->setToggleState(should_save_log , juce::dontSendNotification) ;
  98. hideBotsButton ->setToggleState(should_hide_bots , juce::dontSendNotification) ;
  99. //[/Constructor]
  100. }
  101. ConfigClient::~ConfigClient()
  102. {
  103. //[Destructor_pre]. You can add your own custom destruction code here..
  104. //[/Destructor_pre]
  105. saveAudioLabel = nullptr;
  106. saveAudioComboBox = nullptr;
  107. oggMixdownButton = nullptr;
  108. wavMixdownButton = nullptr;
  109. debugLevelLabel = nullptr;
  110. debugLevelComboBox = nullptr;
  111. saveLogButton = nullptr;
  112. hideBotsButton = nullptr;
  113. //[Destructor]. You can add your own custom destruction code here..
  114. //[/Destructor]
  115. }
  116. //==============================================================================
  117. void ConfigClient::paint (Graphics& g)
  118. {
  119. //[UserPrePaint] Add your own custom painting code here..
  120. //[/UserPrePaint]
  121. g.setColour (Colour (0xff202000));
  122. g.fillRoundedRectangle (0.0f, 0.0f, static_cast<float> (getWidth() - 0), static_cast<float> (getHeight() - 0), 10.000f);
  123. //[UserPaint] Add your own custom painting code here..
  124. //[/UserPaint]
  125. }
  126. void ConfigClient::resized()
  127. {
  128. saveAudioLabel->setBounds (20, 18, 152, 16);
  129. saveAudioComboBox->setBounds (20, 38, 152, 16);
  130. oggMixdownButton->setBounds (20, 58, 74, 16);
  131. wavMixdownButton->setBounds (98, 58, 74, 16);
  132. debugLevelLabel->setBounds (20, 86, 152, 16);
  133. debugLevelComboBox->setBounds (20, 106, 152, 16);
  134. saveLogButton->setBounds (20, 130, 74, 16);
  135. hideBotsButton->setBounds (98, 130, 74, 16);
  136. //[UserResized] Add your own custom resize handling here..
  137. //[/UserResized]
  138. }
  139. void ConfigClient::comboBoxChanged (ComboBox* comboBoxThatHasChanged)
  140. {
  141. //[UsercomboBoxChanged_Pre]
  142. Identifier config_key ;
  143. var value ;
  144. //[/UsercomboBoxChanged_Pre]
  145. if (comboBoxThatHasChanged == saveAudioComboBox)
  146. {
  147. //[UserComboBoxCode_saveAudioComboBox] -- add your combo box handling code here..
  148. config_key = CONFIG::SAVE_AUDIO_MODE_ID ;
  149. value = var(saveAudioComboBox->getSelectedId() - CONFIG::SAVE_AUDIO_ENUM_OFFSET) ;
  150. //[/UserComboBoxCode_saveAudioComboBox]
  151. }
  152. else if (comboBoxThatHasChanged == debugLevelComboBox)
  153. {
  154. //[UserComboBoxCode_debugLevelComboBox] -- add your combo box handling code here..
  155. config_key = CONFIG::DEBUG_LEVEL_ID ;
  156. value = var(debugLevelComboBox->getSelectedItemIndex()) ;
  157. //[/UserComboBoxCode_debugLevelComboBox]
  158. }
  159. //[UsercomboBoxChanged_Post]
  160. setConfig(config_key , value) ;
  161. //[/UsercomboBoxChanged_Post]
  162. }
  163. void ConfigClient::buttonClicked (Button* buttonThatWasClicked)
  164. {
  165. //[UserbuttonClicked_Pre]
  166. int mixdown_mode = (int)NJClient::SAVE_MIXDOWN_NONE ;
  167. if (oggMixdownButton->getToggleState()) mixdown_mode |= (int)NJClient::SAVE_MIXDOWN_OGG ;
  168. if (wavMixdownButton->getToggleState()) mixdown_mode |= (int)NJClient::SAVE_MIXDOWN_WAV ;
  169. Identifier config_key ;
  170. var value ;
  171. var mixdown_value = var(mixdown_mode) ;
  172. var toggle_value = var(buttonThatWasClicked->getToggleState()) ;
  173. //[/UserbuttonClicked_Pre]
  174. if (buttonThatWasClicked == oggMixdownButton)
  175. {
  176. //[UserButtonCode_oggMixdownButton] -- add your button handler code here..
  177. config_key = CONFIG::MIXDOWN_MODE_ID ;
  178. value = mixdown_value ;
  179. //[/UserButtonCode_oggMixdownButton]
  180. }
  181. else if (buttonThatWasClicked == wavMixdownButton)
  182. {
  183. //[UserButtonCode_wavMixdownButton] -- add your button handler code here..
  184. config_key = CONFIG::MIXDOWN_MODE_ID ;
  185. value = mixdown_value ;
  186. //[/UserButtonCode_wavMixdownButton]
  187. }
  188. else if (buttonThatWasClicked == saveLogButton)
  189. {
  190. //[UserButtonCode_saveLogButton] -- add your button handler code here..
  191. config_key = CONFIG::SHOULD_SAVE_LOG_KEY ;
  192. value = toggle_value ;
  193. //[/UserButtonCode_saveLogButton]
  194. }
  195. else if (buttonThatWasClicked == hideBotsButton)
  196. {
  197. //[UserButtonCode_hideBotsButton] -- add your button handler code here..
  198. config_key = CONFIG::SHOULD_HIDE_BOTS_KEY ;
  199. value = toggle_value ;
  200. //[/UserButtonCode_hideBotsButton]
  201. }
  202. //[UserbuttonClicked_Post]
  203. setConfig(config_key , value) ;
  204. //[/UserbuttonClicked_Post]
  205. }
  206. //[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
  207. void ConfigClient::setConfig(Identifier a_key , var a_value)
  208. {
  209. this->configStore.setProperty(a_key , a_value , nullptr) ;
  210. }
  211. //[/MiscUserCode]
  212. //==============================================================================
  213. #if 0
  214. /* -- Introjucer information section --
  215. This is where the Introjucer stores the metadata that describe this GUI layout, so
  216. make changes in here at your peril!
  217. BEGIN_JUCER_METADATA
  218. <JUCER_COMPONENT documentType="Component" className="ConfigClient" componentName=""
  219. parentClasses="public Component" constructorParams="ValueTree config_store"
  220. variableInitialisers="configStore(config_store)" snapPixels="8"
  221. snapActive="1" snapShown="1" overlayOpacity="0.330" fixedSize="1"
  222. initialWidth="614" initialHeight="434">
  223. <BACKGROUND backgroundColour="0">
  224. <ROUNDRECT pos="0 0 0M 0M" cornerSize="10" fill="solid: ff202000" hasStroke="0"/>
  225. </BACKGROUND>
  226. <LABEL name="saveAudioLabel" id="28e9c840504ea936" memberName="saveAudioLabel"
  227. virtualName="" explicitFocusOrder="0" pos="20 18 152 16" textCol="ffffffff"
  228. edTextCol="ff000000" edBkgCol="0" labelText="save audio" editableSingleClick="0"
  229. editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
  230. fontsize="15" bold="0" italic="0" justification="12"/>
  231. <COMBOBOX name="saveAudioComboBox" id="195d38c0dfa0b780" memberName="saveAudioComboBox"
  232. virtualName="" explicitFocusOrder="1" pos="20 38 152 16" editable="0"
  233. layout="33" items="delete asap&#10;dont save&#10;save ogg&#10;save ogg and wav"
  234. textWhenNonSelected="" textWhenNoItems="(no choices)"/>
  235. <TOGGLEBUTTON name="oggMixdownButton" id="ccb740c03ababc9f" memberName="oggMixdownButton"
  236. virtualName="" explicitFocusOrder="2" pos="20 58 74 16" txtcol="ffffffff"
  237. buttonText="ogg mixdown" connectedEdges="0" needsCallback="1"
  238. radioGroupId="0" state="0"/>
  239. <TOGGLEBUTTON name="wavMixdownButton" id="2bfc206fbb162f7f" memberName="wavMixdownButton"
  240. virtualName="" explicitFocusOrder="3" pos="98 58 74 16" txtcol="ffffffff"
  241. buttonText="wav mixdown" connectedEdges="0" needsCallback="1"
  242. radioGroupId="0" state="0"/>
  243. <LABEL name="debugLevelLabel" id="a67b459c94aba72e" memberName="debugLevelLabel"
  244. virtualName="" explicitFocusOrder="0" pos="20 86 152 16" textCol="ffffffff"
  245. edTextCol="ff000000" edBkgCol="0" labelText="debug level" editableSingleClick="0"
  246. editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
  247. fontsize="15" bold="0" italic="0" justification="12"/>
  248. <COMBOBOX name="debugLevelComboBox" id="3b81e2ff4dec7469" memberName="debugLevelComboBox"
  249. virtualName="" explicitFocusOrder="4" pos="20 106 152 16" editable="0"
  250. layout="33" items="silent&#10;audio&#10;audio and network&#10;linjam trace"
  251. textWhenNonSelected="" textWhenNoItems="(no choices)"/>
  252. <TOGGLEBUTTON name="saveLogButton" id="a9eb5bfc0df5b172" memberName="saveLogButton"
  253. virtualName="" explicitFocusOrder="5" pos="20 130 74 16" txtcol="ffffffff"
  254. buttonText="save log" connectedEdges="0" needsCallback="1" radioGroupId="0"
  255. state="0"/>
  256. <TOGGLEBUTTON name="hideBotsButton" id="f7a06fb783648919" memberName="hideBotsButton"
  257. virtualName="" explicitFocusOrder="6" pos="98 130 74 16" txtcol="ffffffff"
  258. buttonText="hide bots" connectedEdges="0" needsCallback="1" radioGroupId="0"
  259. state="1"/>
  260. </JUCER_COMPONENT>
  261. END_JUCER_METADATA
  262. */
  263. #endif
  264. //[EndFile] You can add extra defines here...
  265. //[/EndFile]