added manually edited non-preset audio volume values to select list
authorHolger Schemel <info@artsoft.org>
Mon, 2 Mar 2015 22:33:57 +0000 (23:33 +0100)
committerHolger Schemel <info@artsoft.org>
Mon, 2 Mar 2015 22:33:57 +0000 (23:33 +0100)
ChangeLog
src/screens.c

index d0f69ab6c0a62f241548b9d3ec8edec6d1d5472a..ee347ccbd58ae1f90e9711f077ae7b89e892b7c2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,8 @@
        * added classic level sets to git repository
        * added element description files to git repository
        * changed mouse cursor on title screens not being always invisible
+       * added manually edited non-preset audio volume values to select list
+         (if sound, loops or music volume was manually edited in "setup.conf")
 
 2015-02-27
        * fixed using "background.TOOLBOX", which was simply ignored before
index d7a2b63e6883d10a6607eea3584561b16f866365..fe5f60a04a29df808fc535fc34f73f77fd6191d3 100644 (file)
@@ -4352,6 +4352,7 @@ static void execSetupSound()
 {
   if (volumes_simple == NULL)
   {
+    boolean current_volume_simple_found = FALSE;
     int i;
 
     for (i = 0; volumes_list[i].value != -1; i++)
@@ -4373,6 +4374,31 @@ static void execSetupSound()
       setString(&ti->infotext, "Sound Volume");
 
       pushTreeInfo(&volumes_simple, ti);
+
+      if (value == setup.volume_simple)
+        current_volume_simple_found = TRUE;
+    }
+
+    if (!current_volume_simple_found)
+    {
+      // add entry for non-preset volume value
+
+      TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
+      char identifier[32], name[32];
+      int value = setup.volume_simple;
+
+      ti->node_top = &volumes_simple;
+      ti->sort_priority = value;
+
+      sprintf(identifier, "%d", value);
+      sprintf(name, "%d %% (Current)", value);
+
+      setString(&ti->identifier, identifier);
+      setString(&ti->name, name);
+      setString(&ti->name_sorting, name);
+      setString(&ti->infotext, "Sound Volume");
+
+      pushTreeInfo(&volumes_simple, ti);
     }
 
     /* sort volume values to start with lowest volume value */
@@ -4394,6 +4420,7 @@ static void execSetupSound()
 
   if (volumes_loops == NULL)
   {
+    boolean current_volume_loops_found = FALSE;
     int i;
 
     for (i = 0; volumes_list[i].value != -1; i++)
@@ -4415,6 +4442,31 @@ static void execSetupSound()
       setString(&ti->infotext, "Loops Volume");
 
       pushTreeInfo(&volumes_loops, ti);
+
+      if (value == setup.volume_loops)
+        current_volume_loops_found = TRUE;
+    }
+
+    if (!current_volume_loops_found)
+    {
+      // add entry for non-preset volume value
+
+      TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
+      char identifier[32], name[32];
+      int value = setup.volume_loops;
+
+      ti->node_top = &volumes_loops;
+      ti->sort_priority = value;
+
+      sprintf(identifier, "%d", value);
+      sprintf(name, "%d %% (Current)", value);
+
+      setString(&ti->identifier, identifier);
+      setString(&ti->name, name);
+      setString(&ti->name_sorting, name);
+      setString(&ti->infotext, "Loops Volume");
+
+      pushTreeInfo(&volumes_loops, ti);
     }
 
     /* sort volume values to start with lowest volume value */
@@ -4436,6 +4488,7 @@ static void execSetupSound()
 
   if (volumes_music == NULL)
   {
+    boolean current_volume_music_found = FALSE;
     int i;
 
     for (i = 0; volumes_list[i].value != -1; i++)
@@ -4457,6 +4510,31 @@ static void execSetupSound()
       setString(&ti->infotext, "Music Volume");
 
       pushTreeInfo(&volumes_music, ti);
+
+      if (value == setup.volume_music)
+        current_volume_music_found = TRUE;
+    }
+
+    if (!current_volume_music_found)
+    {
+      // add entry for non-preset volume value
+
+      TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
+      char identifier[32], name[32];
+      int value = setup.volume_music;
+
+      ti->node_top = &volumes_music;
+      ti->sort_priority = value;
+
+      sprintf(identifier, "%d", value);
+      sprintf(name, "%d %% (Current)", value);
+
+      setString(&ti->identifier, identifier);
+      setString(&ti->name, name);
+      setString(&ti->name_sorting, name);
+      setString(&ti->infotext, "Music Volume");
+
+      pushTreeInfo(&volumes_music, ti);
     }
 
     /* sort volume values to start with lowest volume value */