Exemplo n.º 1
0
BaseSingleton::~BaseSingleton()
{
  SDL_LockMutex(mutex);
  singletons.remove(this);
  SDL_UnlockMutex(mutex);

  MSG_DBG_RTTI("singleton", "Removed singleton %p", this);
}
Exemplo n.º 2
0
BaseSingleton::BaseSingleton()
{
  // Usually the game loading makes the first calls to this constructor serial.
  if (!mutex) mutex = SDL_CreateMutex();

  SDL_LockMutex(mutex);
  singletons.push_back(this);
  SDL_UnlockMutex(mutex);

  MSG_DBG_RTTI("singleton", "Added singleton %p", this);
}
Exemplo n.º 3
0
void WidgetList::SetFocusOnNextWidget()
{
  // No widget => exit
  if (widget_list.size() == 0) {
    selected_widget = NULL;
    return;
  }

  MSG_DBG_RTTI("widgetlist", "before %s:%p",
               typeid(selected_widget).name(), selected_widget);

  Widget* w = GetNextWidget(selected_widget, true);
  SetFocusOn(w, true);
}
Exemplo n.º 4
0
Widget* WidgetList::GetFirstWidget() const
{
  Widget *first = NULL;

  MSG_DEBUG("widgetlist", "%p::GetFirstWidget()", this);

  for (cwit it = widget_list.begin(); it != widget_list.end(); it++) {
    if ((*it)->IsWidgetBrowser()) {
      MSG_DBG_RTTI("widgetlist", "%s:%p is a widget browser!\n",
                   typeid(*it).name(), (*it));

      first = (*it)->GetFirstWidget();
      if (first != NULL)
        return first;
    } else {
      MSG_DBG_RTTI("widgetlist", "%s:%p is NOT a widget browser!\n",
                   typeid(*it).name(), (*it));

      return (*it);
    }
  }

  return NULL;
}
Exemplo n.º 5
0
Widget* WidgetList::GetNextWidget(const Widget *w, bool loop) const
{
  Widget *r = NULL;

  ASSERT(!w || !w->IsWidgetBrowser());

  MSG_DBG_RTTI("widgetlist", "%p::GetNextWidget(%s:%p)",
               this, typeid(w).name(), w);

  if (widget_list.size() == 0) {
    return NULL;
  }

  if (w == NULL) {
    r = GetFirstWidget();
    MSG_DBG_RTTI("widgetlist", "%p::GetNextWidget(%s:%p) ==> %s%p",
                 this, typeid(w).name(), w, typeid(r).name(), r);
    return r;
  }

  std::list<Widget*>::const_iterator it;
  for (it = widget_list.begin(); it != widget_list.end(); it++) {

    MSG_DBG_RTTI("widgetlist", "iterate on %s:%p", typeid(*it).name(), (*it));

    if (w == (*it)) {
      MSG_DBG_RTTI("widgetlist", "we have found %s:%p", typeid(*it).name(), (*it));

      it++;
      if (it != widget_list.end())
        r = (*it);
      else if (loop)
        r = GetFirstWidget();
      else
        r = (Widget*)w;
      break;
    }

    if ((*it)->IsWidgetBrowser()) {
      MSG_DBG_RTTI("widgetlist", "%s:%p is a widget browser!\n",
                   typeid(*it).name(), (*it));

      r = (*it)->GetNextWidget(w, false);

      if (r && r == w && it != widget_list.end()) {
        MSG_DBG_RTTI("widgetlist", "r == w %s:%p", typeid(r).name(), (r));
        it++;
        if (it != widget_list.end()) {
          r = (*it);
          MSG_DBG_RTTI("widgetlist", "r ==>  %s:%p", typeid(r).name(), (r));
          if (r->IsWidgetBrowser()) {
            r = r->GetFirstWidget();
          }
        } else if (loop) {
          r = GetFirstWidget();
        }
      }
      if (r)
        break;
    } else {
      MSG_DBG_RTTI("widgetlist", "%s:%p is NOT a widget browser!\n",
                   typeid(*it).name(), (*it));
    }
  }

  ASSERT(!r || !r->IsWidgetBrowser());

  MSG_DBG_RTTI("widgetlist", "%p::GetNextWidget(%s:%p) ==> %s%p",
               this, typeid(w).name(), w, typeid(r).name(), r);

  return r;
}