Velocizzato caricamento spostando il test di presenza dei programmi
git-svn-id: svn://10.65.10.50/trunk@5041 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
137a06e857
commit
2bed551e1c
61
ba/ba0.cpp
61
ba/ba0.cpp
@ -386,7 +386,7 @@ public:
|
||||
bool enabled() const;
|
||||
bool disabled() const { return !enabled(); }
|
||||
|
||||
COLOR color() const { return _enabled ? _color : DISABLED_COLOR; }
|
||||
COLOR color() const { return enabled() ? _color : DISABLED_COLOR; }
|
||||
|
||||
bool is_submenu() const { return _type == '[' && _action.not_empty(); }
|
||||
bool is_program() const { return _type != '[' && _action.not_empty(); }
|
||||
@ -507,20 +507,6 @@ void TMenuitem::create(const char* t)
|
||||
if (_action.empty())
|
||||
_enabled = FALSE;
|
||||
}
|
||||
|
||||
if (enabled() && is_program())
|
||||
{
|
||||
const int endname = _action.find(' ');
|
||||
TFilename name(endname > 0 ? _action.left(endname) : _action);
|
||||
const char* ext[] = { "exe", "pif", "com", "bat", NULL };
|
||||
for (int e = 0; ext[e]; e++)
|
||||
{
|
||||
name.ext(ext[e]);
|
||||
if (fexist(name))
|
||||
break;
|
||||
}
|
||||
_enabled = ext[e] != NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool TMenuitem::enabled() const
|
||||
@ -533,6 +519,21 @@ bool TMenuitem::enabled() const
|
||||
TSubmenu* mnu = menu().find(_action);
|
||||
yes = mnu && mnu->enabled();
|
||||
}
|
||||
else
|
||||
{
|
||||
const int endname = _action.find(' ');
|
||||
TFilename name(endname > 0 ? _action.left(endname) : _action);
|
||||
const char* ext[] = { "exe", "pif", "com", "bat", NULL };
|
||||
for (int e = 0; ext[e]; e++)
|
||||
{
|
||||
name.ext(ext[e]);
|
||||
if (fexist(name))
|
||||
break;
|
||||
}
|
||||
yes = ext[e] != NULL;
|
||||
if (!yes)
|
||||
((TMenuitem*)this)->_enabled = FALSE;
|
||||
}
|
||||
}
|
||||
return yes;
|
||||
}
|
||||
@ -635,7 +636,7 @@ bool TMenuitem::perform() const
|
||||
}
|
||||
|
||||
TSubmenu::TSubmenu(TMenu* menu, const char* name)
|
||||
: _menu(menu), _name(name), _enabled(TRUE), _firm(FALSE)
|
||||
: _menu(menu), _name(name), _enabled(TRUE), _firm(FALSE), _items(12)
|
||||
{
|
||||
}
|
||||
|
||||
@ -695,19 +696,31 @@ void TSubmenu::read(TScanner& scanner)
|
||||
|
||||
int TSubmenu::find_string(const char* str) const
|
||||
{
|
||||
TString caption;
|
||||
bool found = FALSE;
|
||||
|
||||
TString caption(32);
|
||||
|
||||
caption = _caption; caption.upper();
|
||||
if (caption.find(str) >= 0)
|
||||
found = TRUE;
|
||||
|
||||
for (int i = 0; i < items(); i++)
|
||||
{
|
||||
const TMenuitem& mi = item(i);
|
||||
if (mi.enabled() && mi.is_program())
|
||||
{
|
||||
caption = item(i).caption();
|
||||
caption.upper();
|
||||
if (caption.find(str) >= 0)
|
||||
{
|
||||
if (!found)
|
||||
{
|
||||
caption = item(i).caption();
|
||||
caption.upper();
|
||||
found = caption.find(str) >= 0;
|
||||
}
|
||||
if (found)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool TSubmenu::perform(int i)
|
||||
@ -720,7 +733,7 @@ bool TSubmenu::perform(int i)
|
||||
|
||||
bool TMenu::read(const char* name, TString& root)
|
||||
{
|
||||
TString str;
|
||||
TString80 str;
|
||||
bool first = TRUE;
|
||||
|
||||
TScanner scanner(name);
|
||||
@ -754,7 +767,7 @@ bool TMenu::read(const char* name, TString& root)
|
||||
|
||||
bool TMenu::read(const char* name)
|
||||
{
|
||||
TString root;
|
||||
TString80 root;
|
||||
bool ok = read(name, root);
|
||||
if (ok && _current == NULL)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user