| 254 | } |
| 255 | |
| 256 | const std::string* Engine::GetValue( const std::string& property, Widget::PtrConst widget ) const { |
| 257 | // Look for property. |
| 258 | PropertyMap::const_iterator prop_iter( m_properties.find( property ) ); |
| 259 | |
| 260 | const std::string* value = 0; |
| 261 | int score = -1; |
| 262 | |
| 263 | if( prop_iter != m_properties.end() ) { |
| 264 | WidgetNameMap::const_iterator name_iter; |
| 265 | |
| 266 | if( widget ) { |
| 267 | // Find widget-specific properties, first. |
| 268 | name_iter = prop_iter->second.find( widget->GetName() ); |
| 269 | |
| 270 | if( name_iter != prop_iter->second.end() ) { |
| 271 | // Check against selectors. |
| 272 | for( const auto& selector_value : name_iter->second ) { |
| 273 | if( selector_value.first->Matches( widget ) ) { |
| 274 | // Found, check if it is better than current best. |
| 275 | auto new_score = selector_value.first->GetScore(); |
| 276 | |
| 277 | if( new_score > score ) { |
| 278 | value = &selector_value.second; |
| 279 | score = new_score; |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | // Look for general properties now. |
| 287 | name_iter = prop_iter->second.find( "*" ); |
| 288 | |
| 289 | if( name_iter != prop_iter->second.end() ) { |
| 290 | for( const auto& selector_value : name_iter->second ) { |
| 291 | if( selector_value.first->Matches( widget ) ) { |
| 292 | // Found, check if it is better than current best. |
| 293 | auto new_score = selector_value.first->GetScore(); |
| 294 | |
| 295 | if( new_score > score ) { |
| 296 | value = &selector_value.second; |
| 297 | score = new_score; |
| 298 | } |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | return value; |
| 305 | } |
| 306 | |
| 307 | ResourceManager& Engine::GetResourceManager() const { |
| 308 | return m_resource_manager; |