CMenuForwarder: clean up multiple code parts

This commit is contained in:
2017-06-18 00:04:40 +02:00
parent 284dba8c25
commit 7b3ce6f330
2 changed files with 45 additions and 35 deletions

View File

@@ -2127,48 +2127,52 @@ int CMenuOptionStringChooser::paint( bool selected )
} }
//------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------
CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, CMenuForwarder::CMenuForwarder( const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey,
neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic)
: CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic)
{ {
option_string_ptr = &Option; init("", Text, Option, NULL, Target, ActionKey);
name = Text;
nameString = "";
jumpTarget = Target;
actionKey = ActionKey ? ActionKey : "";
} }
CMenuForwarder::CMenuForwarder(const std::string& Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, CMenuForwarder::CMenuForwarder( const std::string& Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey,
neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic)
: CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic)
{
init(Text, NONEXISTANT_LOCALE, Option, NULL, Target, ActionKey);
}
CMenuForwarder::CMenuForwarder( const neutrino_locale_t Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey,
neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic)
: CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic)
{
init("", Text, "", Option, Target, ActionKey);
}
CMenuForwarder::CMenuForwarder( const std::string& Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey,
neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic)
: CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic)
{
init(Text, NONEXISTANT_LOCALE, "", Option, Target, ActionKey);
}
void CMenuForwarder::init( const std::string &Text,
const neutrino_locale_t Name,
const std::string &sOption,
const char * const cOption,
CMenuTarget* Target,
const char * const ActionKey)
{ {
option_string_ptr = &Option;
name = NONEXISTANT_LOCALE;
nameString = Text; nameString = Text;
jumpTarget = Target; name = Name;
actionKey = ActionKey ? ActionKey : "";
}
CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, if (sOption.empty())
neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) {
: CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) option_string = cOption ? cOption : "";
{ option_string_ptr = &option_string;
option_string = Option ? Option : ""; }
option_string_ptr = &option_string; else
name = Text; option_string_ptr = &sOption;
nameString = "";
jumpTarget = Target;
actionKey = ActionKey ? ActionKey : "";
}
CMenuForwarder::CMenuForwarder(const std::string& Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey,
neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic)
: CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic)
{
option_string = Option ? Option : "";
option_string_ptr = &option_string;
name = NONEXISTANT_LOCALE;
nameString = Text;
jumpTarget = Target; jumpTarget = Target;
actionKey = ActionKey ? ActionKey : ""; actionKey = ActionKey ? ActionKey : "";
} }

View File

@@ -231,6 +231,12 @@ class CMenuSeparator : public CMenuItem
class CMenuForwarder : public CMenuItem class CMenuForwarder : public CMenuItem
{ {
std::string actionKey; std::string actionKey;
void init( const std::string &OptionName,
const neutrino_locale_t Name,
const std::string &sOption,
const char * const cOption,
CMenuTarget* Target,
const char * const ActionKey);
protected: protected:
std::string option_string; std::string option_string;