summaryrefslogtreecommitdiff
path: root/setupmenu.c
blob: c1447eced8c1d8d8ed30ae7e81289c73ec15fe16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
 * sndctl  -  a plugin for the Video Disk Recorder
 *        file: setupmenu.c
 * description: the OSD menu page for this plugin
 *
 *      author: Thomas Hildebrandt <toxym@web.de>
 *
 * inspired by and reengineered from 'avolctl'
 * thanks to Martin Prochnow <nordlichtl@martins-kabuff.de>
 */

#include "defaults.h"
#include "setupmenu.h"
#include "menuitems.h"
#include "sndctl.h"
#include "setup.h"

/*********************************************************
 * member functions for class cSetupMenuSndctl
 *********************************************************/

/*
 * constructors
 */
cSetupMenuSndctl::cSetupMenuSndctl( cPluginSndctl *Plugin ){
  // save plugin
  plugin = Plugin;

  // get current values
  menuname = strdup( plugin->GetSetup()->Get( SNDCTL_SETUP_MENUNAME ).c_str());
  hideMainMenuEntry = plugin->GetSetup()->GetBool( SNDCTL_SETUP_HIDEMAINMENUENTRY ) ? 1 : 0;
  initVolume = plugin->GetSetup()->GetInt( SNDCTL_SETUP_INIT_VOLUME );
  defSoundSet = plugin->GetSetup()->Get( SNDCTL_SETUP_DEFAULT_SSET );
  ddAutoSwitch = plugin->GetSetup()->GetBool( SNDCTL_SETUP_DD_AUTO_SWITCH ) ? 1 : 0;
  ddAutoSoundSet = plugin->GetSetup()->Get( SNDCTL_SETUP_DD_AUTO_SSET );
  soundflash = plugin->GetSetup()->GetBool( SNDCTL_SETUP_SOUNDFLASH ) ? 1 : 0;
  muteOnEnd = plugin->GetSetup()->GetBool( SNDCTL_SETUP_MUTE_ON_END ) ? 1 : 0;

  // add content
  Set();
}

/*
 * makes setup menu entries
 */
void cSetupMenuSndctl::Set( void ){
  // main menu entry
  Add( new cMenuEditBoolItem( tr( SNDCTL_TXT_0002 ), &hideMainMenuEntry ));

  // main menu name
  Add( new cMenuEditStrItem( tr( SNDCTL_TXT_0007 ), menuname, 40, tr(FileNameChars)));

  // default soundset
  Add( new cSoundSetChooserItem( plugin->GetSoundManager(), &defSoundSet, SNDCTL_TXT_0003 ));

  // initial volume
  Add( new cMenuEditIntItem( tr( SNDCTL_TXT_0014 ), &initVolume, -1, 100 ));

  // DD auto switch
  Add( new cMenuEditBoolItem( tr( SNDCTL_TXT_0012 ), &ddAutoSwitch ));

  // DD auto sound set
  Add( new cSoundSetChooserItem( plugin->GetSoundManager(), &ddAutoSoundSet, SNDCTL_TXT_0013 ));

  // sound flash
  Add( new cMenuEditBoolItem( tr( SNDCTL_TXT_0015 ), &soundflash ));

  // sound flash
  Add( new cMenuEditBoolItem( tr( SNDCTL_TXT_0016 ), &muteOnEnd ));
}

/*
 * stores changed values
 */
void cSetupMenuSndctl::Store( void ){
  char vol[3];

  // main menu entry
  plugin->GetSetup()->Set( SNDCTL_SETUP_HIDEMAINMENUENTRY, string( hideMainMenuEntry ? "yes" : "no" ));

  // main menu name
  plugin->GetSetup()->Set( SNDCTL_SETUP_MENUNAME, string( menuname ));

  // default sound set
  plugin->GetSetup()->Set( SNDCTL_SETUP_DEFAULT_SSET, defSoundSet );

  // initial volume
  sprintf( vol, "%d", initVolume );
  plugin->GetSetup()->Set( SNDCTL_SETUP_INIT_VOLUME, string( vol ));

  // DD auto switch
  plugin->GetSetup()->Set( SNDCTL_SETUP_DD_AUTO_SWITCH, string( ddAutoSwitch ? "yes" : "no" ));

  // DD auto switch sound set
  plugin->GetSetup()->Set( SNDCTL_SETUP_DD_AUTO_SSET, ddAutoSoundSet );

  // sound flash
  plugin->GetSetup()->Set( SNDCTL_SETUP_SOUNDFLASH, string( soundflash ? "yes" : "no" ));

  // mute on end
  plugin->GetSetup()->Set( SNDCTL_SETUP_MUTE_ON_END, string( muteOnEnd ? "yes" : "no" ));

  // do a global store now
  plugin->GetSetup()->Store( plugin );
}