Revision: 2488
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2488&view=rev
Author: ulteq
Date: 2012-04-30 02:21:21 +0000 (Mon, 30 Apr 2012)
Log Message:
-----------
-Cleanup
Modified Paths:
--------------
trunk/source/main/gameplay/CacheSystem.h
trunk/source/main/gui/SelectorWindow.cpp
Modified: trunk/source/main/gameplay/CacheSystem.h
===================================================================
--- trunk/source/main/gameplay/CacheSystem.h 2012-04-29 15:24:49 UTC (rev
2487)
+++ trunk/source/main/gameplay/CacheSystem.h 2012-04-30 02:21:21 UTC (rev
2488)
@@ -224,7 +224,7 @@
static bool resourceExistsInAllGroups(Ogre::String filename);
// see:
https://code.google.com/p/rigsofrods-streams/source/browse/trunk/0.39/win32-skeleton/config/categories.cfg
- enum CategoryID {CID_MAX=9000, CID_Unsorted=9990, CID_All, CID_Fresh,
CID_Hidden};
+ enum CategoryID {CID_Max=9000, CID_Unsorted=9990, CID_All=9991,
CID_Fresh=9992, CID_Hidden=9993, CID_SearchResults=9994};
protected:
CacheSystem();
~CacheSystem();
Modified: trunk/source/main/gui/SelectorWindow.cpp
===================================================================
--- trunk/source/main/gui/SelectorWindow.cpp 2012-04-29 15:24:49 UTC (rev
2487)
+++ trunk/source/main/gui/SelectorWindow.cpp 2012-04-30 02:21:21 UTC (rev
2488)
@@ -332,7 +332,7 @@
continue;
// remove invalid category ID's
- if(it->categoryid >= CacheSystem::CID_MAX)
+ if(it->categoryid >= CacheSystem::CID_Max)
it->categoryid = -1;
// category unsorted
@@ -359,19 +359,18 @@
}
for(std::map<int, Category_Entry>::iterator itc = cats->begin();
itc!=cats->end(); itc++)
{
- int usage = mCategoryUsage[itc->second.number];
- if(usage == 0) continue;
-
- current_category++;
-
- UTFString title = _L(itc->second.title.c_str());
- if(title.empty())
- title = _L("unknown");
- UTFString txt = U("[") + TOUTFSTRING(current_category) + U("/")
+ TOUTFSTRING(tally_categories) + U("] (") + TOUTFSTRING(usage) + U(") ") +
title;
-
- mTypeComboBox->addItem(convertToMyGUIString(txt),
itc->second.number);
+ int num_elements = mCategoryUsage[itc->second.number];
+ if(num_elements > 0)
+ {
+ UTFString title = _L("unknown");
+ if(!itc->second.title.empty())
+ {
+ title = _L(itc->second.title.c_str());
+ }
+ UTFString txt = U("[") +
TOUTFSTRING(++current_category) + U("/") + TOUTFSTRING(tally_categories) + U("]
(") + TOUTFSTRING(num_elements) + U(") ") + title;
+ mTypeComboBox->addItem(convertToMyGUIString(txt),
itc->second.number);
+ }
}
- if(mTypeComboBox->getItemCount() != 0)
mTypeComboBox->setIndexSelected(0);
if(tally_categories > 0)
{
try
@@ -490,31 +489,19 @@
String search_cmd = mSearchLineEdit->getCaption();
StringUtil::toLowerCase(search_cmd);
- int ts = getTimeStamp();
+ int counter = 0;
+ int ts = getTimeStamp();
+
mModelList->removeAllItems();
- std::vector<Cache_Entry>::iterator it;
- int counter=0, counter2=0;
- // re-test too see how much matches
- for(it = mEntries.begin(); it != mEntries.end(); it++)
+
+ for(std::vector<Cache_Entry>::iterator it = mEntries.begin(); it !=
mEntries.end(); it++)
{
- if(it->categoryid == categoryID || (categoryID == 9991) ||
(categoryID == 9992 && (ts - it->addtimestamp < 86400)))
- counter++;
-
- // search results
- if(categoryID == 9994 && searchCompare(search_cmd, &(*it)))
+ if(it->categoryid == categoryID || categoryID ==
CacheSystem::CID_All
+
|| categoryID == CacheSystem::CID_Fresh && (ts - it->addtimestamp < 86400)
+
|| categoryID == CacheSystem::CID_SearchResults && searchCompare(search_cmd,
&(*it)))
{
counter++;
- }
- }
-
- for(it = mEntries.begin(); it != mEntries.end(); it++)
- {
- if(it->categoryid == categoryID || (categoryID == 9991) ||
(categoryID == 9992 && (ts - it->addtimestamp < 86400)) )
- {
- counter2++;
- //printf("adding item %d\n", counter2);
- String txt = TOSTRING(counter2)+". " + it->dname;
-
+ String txt = TOSTRING(counter)+". " + it->dname;
try
{
mModelList->addItem(txt, it->number);
@@ -522,22 +509,10 @@
{
mModelList->addItem("ENCODING ERROR",
it->number);
}
- } else if(categoryID == 9994 && searchCompare(search_cmd,
&(*it)))
- {
- counter2++;
- //printf("adding item %d\n", counter2);
- String txt = TOSTRING(counter2)+". " + it->dname;
- try
- {
- mModelList->addItem(txt, it->number);
- } catch(...)
- {
- mModelList->addItem("ENCODING ERROR",
it->number);
- }
}
-
}
- if(counter2 > 0)
+
+ if(counter > 0)
{
try
{
@@ -879,7 +854,7 @@
void SelectorWindow::eventSearchTextChange(MyGUI::EditBox *_sender)
{
if(!mMainWidget->getVisible()) return;
- onCategorySelected(9994);
+ onCategorySelected(CacheSystem::CID_SearchResults);
mTypeComboBox->setCaption(_L("Search Results"));
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel