ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

gui_options.cpp

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "common/gui_options.h"
00024 
00025 #include "common/config-manager.h"
00026 #include "common/str.h"
00027 
00028 namespace Common {
00029 
00030 const struct GameOpt {
00031     const char *option;
00032     // Each description must be a unique identifier not containing a substring
00033     // of any other description
00034     const char *desc;
00035 } g_gameOptions[] = {
00036     { GUIO_NOSUBTITLES,  "sndNoSubs" },
00037     { GUIO_NOMUSIC,      "sndNoMusic" },
00038     { GUIO_NOSPEECH,     "sndNoSpeech" },
00039     { GUIO_NOSFX,        "sndNoSFX" },
00040     { GUIO_NOMIDI,       "sndNoMIDI" },
00041     { GUIO_LINKSPEECHTOSFX, "sndLinkSpeechToSfx" },
00042     { GUIO_LINKMUSICTOSFX,  "sndLinkMusicToSfx" },
00043     { GUIO_NOSPEECHVOLUME,  "sndNoSpchVolume" },
00044 
00045     { GUIO_NOLAUNCHLOAD, "launchNoLoad" },
00046 
00047     { GUIO_MIDIPCSPK,    "midiPCSpk" },
00048     { GUIO_MIDICMS,      "midiCMS" },
00049     { GUIO_MIDIPCJR,     "midiPCJr" },
00050     { GUIO_MIDIADLIB,    "midiAdLib" },
00051     { GUIO_MIDIC64,      "midiC64" },
00052     { GUIO_MIDIAMIGA,    "midiAmiga" },
00053     { GUIO_MIDIAPPLEIIGS,"midiAppleIIgs" },
00054     { GUIO_MIDITOWNS,    "midiTowns" },
00055     { GUIO_MIDIPC98,     "midiPC98" },
00056     { GUIO_MIDIMT32,     "midiMt32" },
00057     { GUIO_MIDIGM,       "midiGM" },
00058 
00059     { GUIO_NOASPECT,     "noAspect" },
00060 
00061     { GUIO_RENDERHERCGREEN, "hercGreen" },
00062     { GUIO_RENDERHERCAMBER, "hercAmber" },
00063     { GUIO_RENDERCGA,       "cga" },
00064     { GUIO_RENDEREGA,       "ega" },
00065     { GUIO_RENDERVGA,       "vga" },
00066     { GUIO_RENDERAMIGA,     "amiga" },
00067     { GUIO_RENDERFMTOWNS,   "fmtowns" },
00068     { GUIO_RENDERPC9821,    "pc9821" },
00069     { GUIO_RENDERPC9801,    "pc9801" },
00070     { GUIO_RENDERAPPLE2GS,  "2gs" },
00071     { GUIO_RENDERATARIST,   "atari" },
00072     { GUIO_RENDERMACINTOSH, "macintosh" },
00073 
00074     { GUIO_GAMEOPTIONS1, "gameOption1" },
00075     { GUIO_GAMEOPTIONS2, "gameOption2" },
00076     { GUIO_GAMEOPTIONS3, "gameOption3" },
00077     { GUIO_GAMEOPTIONS4, "gameOption4" },
00078     { GUIO_GAMEOPTIONS5, "gameOption5" },
00079     { GUIO_GAMEOPTIONS6, "gameOption6" },
00080     { GUIO_GAMEOPTIONS7, "gameOption7" },
00081     { GUIO_GAMEOPTIONS8, "gameOption8" },
00082     { GUIO_GAMEOPTIONS9, "gameOption9" },
00083     // Option strings must not contain substrings of any other options, so
00084     // "gameOption10" would be invalid here because it contains "gameOption1"
00085     { GUIO_GAMEOPTIONS10, "gameOptionA" },
00086     { GUIO_GAMEOPTIONS11, "gameOptionB" },
00087     { GUIO_GAMEOPTIONS12, "gameOptionC" },
00088     { GUIO_GAMEOPTIONS13, "gameOptionD" },
00089     { GUIO_GAMEOPTIONS14, "gameOptionE" },
00090     { GUIO_GAMEOPTIONS15, "gameOptionF" },
00091 
00092     { GUIO_NONE, nullptr }
00093 };
00094 
00095 bool checkGameGUIOption(const String &option, const String &str) {
00096     for (int i = 0; g_gameOptions[i].desc; i++) {
00097         if (option.contains(g_gameOptions[i].option)) {
00098             if (str.contains(g_gameOptions[i].desc))
00099                 return true;
00100             else
00101                 return false;
00102         }
00103     }
00104     return false;
00105 }
00106 
00107 String parseGameGUIOptions(const String &str) {
00108     String res;
00109 
00110     for (int i = 0; g_gameOptions[i].desc; i++)
00111         if (str.contains(g_gameOptions[i].desc))
00112             res += g_gameOptions[i].option;
00113 
00114     return res;
00115 }
00116 
00117 const String getGameGUIOptionsDescription(const String &options) {
00118     String res;
00119 
00120     for (int i = 0; g_gameOptions[i].desc; i++)
00121         if (options.contains(g_gameOptions[i].option[0]))
00122             res += String(g_gameOptions[i].desc) + " ";
00123 
00124     res.trim();
00125 
00126     return res;
00127 }
00128 
00129 void updateGameGUIOptions(const String &options, const String &langOption) {
00130     const String newOptionString = getGameGUIOptionsDescription(options) + " " + langOption;
00131 
00132     if ((!options.empty() && !ConfMan.hasKey("guioptions")) ||
00133         (ConfMan.hasKey("guioptions") && ConfMan.get("guioptions") != newOptionString)) {
00134         ConfMan.set("guioptions", newOptionString);
00135         ConfMan.flushToDisk();
00136     }
00137 }
00138 
00139 
00140 } // End of namespace Common


Generated on Sat May 25 2019 05:00:46 for ResidualVM by doxygen 1.7.1
curved edge   curved edge