/*
 * MultiPlayer
 * Copyright (C) 1992 Bryan Ford
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * I (the author of MultiPlayer) can be contacted on the Internet at
 * "bryan.ford@m.cc.utah.edu".  See "Player.doc" for other addresses.
 *
 * $Id: infowin.c,v 4.3 92/07/19 18:08:17 BAF Exp $
 *
 * $Log:	infowin.c,v $
 * Revision 4.3  92/07/19  18:08:17  BAF
 * Adjustment for putting localdata back into RemindNodes
 * 
 * Revision 4.2  92/06/21  11:13:11  BAF
 * Migrated regargs to stdargs
 *
 * Revision 4.1  92/06/06  19:56:29  BAF
 * Major_code_cleanup
 *
 * Revision 3.1  92/05/25  07:53:34  BAF
 * GNU-ized.
 *
 *
 */


// System includes
#include <exec/types.h>
#include <exec/execbase.h>
#include <intuition/intuition.h>
#include <proto/exec.h>
#include <proto/intuition.h>

#include "bry/macros.h"
#include "bry/remind.h"
#include "bry/misc.h"
#include "bry/guido.h"

#include "player.h"

extern GuidoSpec infowindowspec;
extern short infowinleft, infowintop;

extern struct MPWin mpwin;

struct Gadget *infowinlvgad;

static long check(long sigmask);
void infowinattach(void);
static struct MPWin mpwin = {infowindowspec,&infowinleft,infowinattach,
  {0},{{0},check},{0}};

static long
check(long sigmask)
{
  if((sigmask & mpwin.sigmask) && GCheckPanel(mpwin.win,standardcallback,0L))
    setfinmpwin(&mpwin);
  return(0);
}

void
infowindetach(void)
{
  if(mpwin.win)
    GDetachListView(mpwin.win,infowinlvgad);
}

static long
doattach(void)
{
  if(mpwin.win)
    {
    extern struct MinList *infolist;
    struct MinList *l;
    static struct MinList ml;

      if(!(l = infolist))
        NewList(l = &ml);
      GAttachListView(mpwin.win,infowinlvgad,l,0,0);
    }
  return(0);
}

void
infowinattach(void)
{
  static remind_decl(node,doattach,0);

  if(mpwin.win)
    remind_add(&dolist,&node);
}

char *
infowinopenclose(void)
{
  if(mpwin.win)
    {
      setfinmpwin(&mpwin);
      return(0L);
    }
  return(openmpwin(&mpwin));
}

void
gui_infowinopenclose(void)
{
  showerr(infowinopenclose());
}
