ConfigClient.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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.1
  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 "LinJam.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 client_store)
  21. : clientStore(client_store)
  22. {
  23. //[Constructor_pre] You can add your own custom stuff here..
  24. //[/Constructor_pre]
  25. addAndMakeVisible (saveAudioLabel = new Label ("saveAudioLabel",
  26. TRANS("save audio")));
  27. saveAudioLabel->setFont (Font (15.00f, Font::plain));
  28. saveAudioLabel->setJustificationType (Justification::centredTop);
  29. saveAudioLabel->setEditable (false, false, false);
  30. saveAudioLabel->setColour (Label::textColourId, Colours::white);
  31. saveAudioLabel->setColour (TextEditor::textColourId, Colours::black);
  32. saveAudioLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
  33. addAndMakeVisible (saveAudioComboBox = new ComboBox ("saveAudioComboBox"));
  34. saveAudioComboBox->setExplicitFocusOrder (1);
  35. saveAudioComboBox->setEditableText (false);
  36. saveAudioComboBox->setJustificationType (Justification::centredLeft);
  37. saveAudioComboBox->setTextWhenNothingSelected (String());
  38. saveAudioComboBox->setTextWhenNoChoicesAvailable (TRANS("(no choices)"));
  39. saveAudioComboBox->addListener (this);
  40. addAndMakeVisible (oggMixdownButton = new ToggleButton ("oggMixdownButton"));
  41. oggMixdownButton->setExplicitFocusOrder (2);
  42. oggMixdownButton->setButtonText (TRANS("ogg mixdown"));
  43. oggMixdownButton->addListener (this);
  44. oggMixdownButton->setColour (ToggleButton::textColourId, Colours::white);
  45. addAndMakeVisible (wavMixdownButton = new ToggleButton ("wavMixdownButton"));
  46. wavMixdownButton->setExplicitFocusOrder (3);
  47. wavMixdownButton->setButtonText (TRANS("wav mixdown"));
  48. wavMixdownButton->addListener (this);
  49. wavMixdownButton->setColour (ToggleButton::textColourId, Colours::white);
  50. addAndMakeVisible (debugLevelLabel = new Label ("debugLevelLabel",
  51. TRANS("debug level")));
  52. debugLevelLabel->setFont (Font (15.00f, Font::plain));
  53. debugLevelLabel->setJustificationType (Justification::centredTop);
  54. debugLevelLabel->setEditable (false, false, false);
  55. debugLevelLabel->setColour (Label::textColourId, Colours::white);
  56. debugLevelLabel->setColour (TextEditor::textColourId, Colours::black);
  57. debugLevelLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
  58. addAndMakeVisible (debugLevelComboBox = new ComboBox ("debugLevelComboBox"));
  59. debugLevelComboBox->setExplicitFocusOrder (4);
  60. debugLevelComboBox->setEditableText (false);
  61. debugLevelComboBox->setJustificationType (Justification::centredLeft);
  62. debugLevelComboBox->setTextWhenNothingSelected (String());
  63. debugLevelComboBox->setTextWhenNoChoicesAvailable (TRANS("(no choices)"));
  64. debugLevelComboBox->addListener (this);
  65. addAndMakeVisible (saveLogButton = new ToggleButton ("saveLogButton"));
  66. saveLogButton->setExplicitFocusOrder (5);
  67. saveLogButton->setButtonText (TRANS("save log"));
  68. saveLogButton->addListener (this);
  69. saveLogButton->setColour (ToggleButton::textColourId, Colours::white);
  70. addAndMakeVisible (hideBotsButton = new ToggleButton ("hideBotsButton"));
  71. hideBotsButton->setExplicitFocusOrder (6);
  72. hideBotsButton->setButtonText (TRANS("hide bots"));
  73. hideBotsButton->addListener (this);
  74. hideBotsButton->setToggleState (true, dontSendNotification);
  75. hideBotsButton->setColour (ToggleButton::textColourId, Colours::white);
  76. addAndMakeVisible (cleanButton = new TextButton ("cleanButton"));
  77. cleanButton->setExplicitFocusOrder (7);
  78. cleanButton->setButtonText (TRANS("clean session dir"));
  79. cleanButton->addListener (this);
  80. //[UserPreSize]
  81. //[/UserPreSize]
  82. setSize (614, 434);
  83. //[Constructor] You can add your own custom stuff here..
  84. int save_audio_mode = int( this->clientStore[CONFIG::SAVE_AUDIO_MODE_ID ]) ;
  85. int mixdown_mode = int( this->clientStore[CONFIG::MIXDOWN_MODE_ID ]) ;
  86. int debug_level = int( this->clientStore[CONFIG::DEBUG_LEVEL_ID ]) ;
  87. bool should_save_log = bool(this->clientStore[CONFIG::SHOULD_SAVE_LOG_KEY ]) ;
  88. bool should_hide_bots = bool(this->clientStore[CONFIG::SHOULD_HIDE_BOTS_KEY]) ;
  89. bool should_mixdown_ogg = !!(mixdown_mode & (int)NJClient::MIXDOWN_OGG) ;
  90. bool should_mixdown_wav = !!(mixdown_mode & (int)NJClient::MIXDOWN_WAV) ;
  91. this->saveAudioComboBox ->addItemList(GUI::SAVE_MODES , 1) ;
  92. this->debugLevelComboBox->addItemList(GUI::DEBUG_LEVELS , 1) ;
  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. cleanButton = nullptr;
  114. //[Destructor]. You can add your own custom destruction code here..
  115. //[/Destructor]
  116. }
  117. //==============================================================================
  118. void ConfigClient::paint (Graphics& g)
  119. {
  120. //[UserPrePaint] Add your own custom painting code here..
  121. //[/UserPrePaint]
  122. g.setColour (Colour (0xff202000));
  123. g.fillRoundedRectangle (0.0f, 0.0f, static_cast<float> (getWidth() - 0), static_cast<float> (getHeight() - 0), 10.000f);
  124. //[UserPaint] Add your own custom painting code here..
  125. //[/UserPaint]
  126. }
  127. void ConfigClient::resized()
  128. {
  129. //[UserPreResize] Add your own custom resize code here..
  130. //[/UserPreResize]
  131. saveAudioLabel->setBounds (20, 18, 152, 16);
  132. saveAudioComboBox->setBounds (20, 38, 152, 16);
  133. oggMixdownButton->setBounds (20, 58, 74, 16);
  134. wavMixdownButton->setBounds (98, 58, 74, 16);
  135. debugLevelLabel->setBounds (20, 86, 152, 16);
  136. debugLevelComboBox->setBounds (20, 106, 152, 16);
  137. saveLogButton->setBounds (20, 130, 74, 16);
  138. hideBotsButton->setBounds (98, 130, 74, 16);
  139. cleanButton->setBounds (20, 164, 150, 24);
  140. //[UserResized] Add your own custom resize handling here..
  141. //[/UserResized]
  142. }
  143. void ConfigClient::comboBoxChanged (ComboBox* comboBoxThatHasChanged)
  144. {
  145. //[UsercomboBoxChanged_Pre]
  146. Identifier config_key ;
  147. var value ;
  148. //[/UsercomboBoxChanged_Pre]
  149. if (comboBoxThatHasChanged == saveAudioComboBox)
  150. {
  151. //[UserComboBoxCode_saveAudioComboBox] -- add your combo box handling code here..
  152. config_key = CONFIG::SAVE_AUDIO_MODE_ID ;
  153. value = var(saveAudioComboBox->getSelectedId() - CONFIG::SAVE_AUDIO_ENUM_OFFSET) ;
  154. //[/UserComboBoxCode_saveAudioComboBox]
  155. }
  156. else if (comboBoxThatHasChanged == debugLevelComboBox)
  157. {
  158. //[UserComboBoxCode_debugLevelComboBox] -- add your combo box handling code here..
  159. config_key = CONFIG::DEBUG_LEVEL_ID ;
  160. value = var(debugLevelComboBox->getSelectedItemIndex()) ;
  161. //[/UserComboBoxCode_debugLevelComboBox]
  162. }
  163. //[UsercomboBoxChanged_Post]
  164. setConfig(config_key , value) ;
  165. //[/UsercomboBoxChanged_Post]
  166. }
  167. void ConfigClient::buttonClicked (Button* buttonThatWasClicked)
  168. {
  169. //[UserbuttonClicked_Pre]
  170. int mixdown_mode = (int)NJClient::MIXDOWN_NONE ;
  171. if (oggMixdownButton->getToggleState()) mixdown_mode |= (int)NJClient::MIXDOWN_OGG ;
  172. if (wavMixdownButton->getToggleState()) mixdown_mode |= (int)NJClient::MIXDOWN_WAV ;
  173. Identifier config_key ;
  174. var value ;
  175. var mixdown_value = var(mixdown_mode) ;
  176. var toggle_value = var(buttonThatWasClicked->getToggleState()) ;
  177. //[/UserbuttonClicked_Pre]
  178. if (buttonThatWasClicked == oggMixdownButton)
  179. {
  180. //[UserButtonCode_oggMixdownButton] -- add your button handler code here..
  181. config_key = CONFIG::MIXDOWN_MODE_ID ;
  182. value = mixdown_value ;
  183. //[/UserButtonCode_oggMixdownButton]
  184. }
  185. else if (buttonThatWasClicked == wavMixdownButton)
  186. {
  187. //[UserButtonCode_wavMixdownButton] -- add your button handler code here..
  188. config_key = CONFIG::MIXDOWN_MODE_ID ;
  189. value = mixdown_value ;
  190. //[/UserButtonCode_wavMixdownButton]
  191. }
  192. else if (buttonThatWasClicked == saveLogButton)
  193. {
  194. //[UserButtonCode_saveLogButton] -- add your button handler code here..
  195. config_key = CONFIG::SHOULD_SAVE_LOG_KEY ;
  196. value = toggle_value ;
  197. //[/UserButtonCode_saveLogButton]
  198. }
  199. else if (buttonThatWasClicked == hideBotsButton)
  200. {
  201. //[UserButtonCode_hideBotsButton] -- add your button handler code here..
  202. config_key = CONFIG::SHOULD_HIDE_BOTS_KEY ;
  203. value = toggle_value ;
  204. //[/UserButtonCode_hideBotsButton]
  205. }
  206. else if (buttonThatWasClicked == cleanButton)
  207. {
  208. //[UserButtonCode_cleanButton] -- add your button handler code here..
  209. LinJam::CleanSessionDir() ;
  210. //[/UserButtonCode_cleanButton]
  211. }
  212. //[UserbuttonClicked_Post]
  213. setConfig(config_key , value) ;
  214. //[/UserbuttonClicked_Post]
  215. }
  216. //[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
  217. void ConfigClient::setConfig(Identifier a_key , var a_value)
  218. {
  219. this->clientStore.setProperty(a_key , a_value , nullptr) ;
  220. }
  221. //[/MiscUserCode]
  222. //==============================================================================
  223. #if 0
  224. /* -- Introjucer information section --
  225. This is where the Introjucer stores the metadata that describe this GUI layout, so
  226. make changes in here at your peril!
  227. BEGIN_JUCER_METADATA
  228. <JUCER_COMPONENT documentType="Component" className="ConfigClient" componentName=""
  229. parentClasses="public Component" constructorParams="ValueTree client_store"
  230. variableInitialisers="clientStore(client_store)" snapPixels="8"
  231. snapActive="1" snapShown="1" overlayOpacity="0.330" fixedSize="1"
  232. initialWidth="614" initialHeight="434">
  233. <BACKGROUND backgroundColour="0">
  234. <ROUNDRECT pos="0 0 0M 0M" cornerSize="10" fill="solid: ff202000" hasStroke="0"/>
  235. </BACKGROUND>
  236. <LABEL name="saveAudioLabel" id="28e9c840504ea936" memberName="saveAudioLabel"
  237. virtualName="" explicitFocusOrder="0" pos="20 18 152 16" textCol="ffffffff"
  238. edTextCol="ff000000" edBkgCol="0" labelText="save audio" editableSingleClick="0"
  239. editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
  240. fontsize="15" bold="0" italic="0" justification="12"/>
  241. <COMBOBOX name="saveAudioComboBox" id="195d38c0dfa0b780" memberName="saveAudioComboBox"
  242. virtualName="" explicitFocusOrder="1" pos="20 38 152 16" editable="0"
  243. layout="33" items="" textWhenNonSelected="" textWhenNoItems="(no choices)"/>
  244. <TOGGLEBUTTON name="oggMixdownButton" id="ccb740c03ababc9f" memberName="oggMixdownButton"
  245. virtualName="" explicitFocusOrder="2" pos="20 58 74 16" txtcol="ffffffff"
  246. buttonText="ogg mixdown" connectedEdges="0" needsCallback="1"
  247. radioGroupId="0" state="0"/>
  248. <TOGGLEBUTTON name="wavMixdownButton" id="2bfc206fbb162f7f" memberName="wavMixdownButton"
  249. virtualName="" explicitFocusOrder="3" pos="98 58 74 16" txtcol="ffffffff"
  250. buttonText="wav mixdown" connectedEdges="0" needsCallback="1"
  251. radioGroupId="0" state="0"/>
  252. <LABEL name="debugLevelLabel" id="a67b459c94aba72e" memberName="debugLevelLabel"
  253. virtualName="" explicitFocusOrder="0" pos="20 86 152 16" textCol="ffffffff"
  254. edTextCol="ff000000" edBkgCol="0" labelText="debug level" editableSingleClick="0"
  255. editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
  256. fontsize="15" bold="0" italic="0" justification="12"/>
  257. <COMBOBOX name="debugLevelComboBox" id="3b81e2ff4dec7469" memberName="debugLevelComboBox"
  258. virtualName="" explicitFocusOrder="4" pos="20 106 152 16" editable="0"
  259. layout="33" items="" textWhenNonSelected="" textWhenNoItems="(no choices)"/>
  260. <TOGGLEBUTTON name="saveLogButton" id="a9eb5bfc0df5b172" memberName="saveLogButton"
  261. virtualName="" explicitFocusOrder="5" pos="20 130 74 16" txtcol="ffffffff"
  262. buttonText="save log" connectedEdges="0" needsCallback="1" radioGroupId="0"
  263. state="0"/>
  264. <TOGGLEBUTTON name="hideBotsButton" id="f7a06fb783648919" memberName="hideBotsButton"
  265. virtualName="" explicitFocusOrder="6" pos="98 130 74 16" txtcol="ffffffff"
  266. buttonText="hide bots" connectedEdges="0" needsCallback="1" radioGroupId="0"
  267. state="1"/>
  268. <TEXTBUTTON name="cleanButton" id="6134f446448d4d2b" memberName="cleanButton"
  269. virtualName="" explicitFocusOrder="7" pos="20 164 150 24" buttonText="clean session dir"
  270. connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  271. </JUCER_COMPONENT>
  272. END_JUCER_METADATA
  273. */
  274. #endif
  275. //[EndFile] You can add extra defines here...
  276. //[/EndFile]