Ignore:
Timestamp:
Mar 15, 2008, 12:55:44 AM (11 years ago)
Author:
Sam Hocevar
Message:
  • Rename the "eh" variable to "wm" because it's a window manager, not an event handler.
  • No longer pass the window manager to functions, there's only one.

Inspired by Win32 Abuse changelog for January 28, 2001:

  • Starting work on singleton code; will get rid of all

references to an arbitrary window_manager* because
there's only going to be one, and it's not ever
going to change.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/netcfg.cpp

    r88 r106  
    5353void net_configuration::cfg_error(char const *msg)
    5454{
    55   jwindow *j=eh->new_window(-1,0,-1,-1,new info_field(WINDOW_FRAME_LEFT,WINDOW_FRAME_TOP,0,msg,
     55  jwindow *j=wm->new_window(-1,0,-1,-1,new info_field(WINDOW_FRAME_LEFT,WINDOW_FRAME_TOP,0,msg,
    5656      new button(WINDOW_FRAME_LEFT,WINDOW_FRAME_TOP+30,CFG_ERR_OK,symbol_str("ok_button"),NULL)),symbol_str("input_error"));
    5757  event ev;
    5858  do
    5959  {
    60     eh->flush_screen();
    61     do { eh->get_event(ev); } while (ev.type==EV_MOUSE_MOVE && eh->event_waiting());
     60    wm->flush_screen();
     61    do { wm->get_event(ev); } while (ev.type==EV_MOUSE_MOVE && wm->event_waiting());
    6262  } while (ev.type!=EV_MESSAGE || ev.message.id!=CFG_ERR_OK || ev.type==EV_CLOSE_WINDOW || (ev.type==EV_KEY && ev.key==JK_ESC));
    63   eh->close_window(j);
    64   eh->flush_screen();
     63  wm->close_window(j);
     64  wm->flush_screen();
    6565}
    6666
     
    171171  int x=WINDOW_FRAME_LEFT,y=WINDOW_FRAME_TOP;
    172172 
    173   jwindow *sv=eh->new_window(50,80,-1,-1,new button(WINDOW_FRAME_LEFT,WINDOW_FRAME_TOP,NET_SERVER,symbol_str("server"),
    174                                      new button(WINDOW_FRAME_LEFT,WINDOW_FRAME_TOP+eh->font()->height()*2,NET_CLIENT,symbol_str("client"),
    175                                      new button(WINDOW_FRAME_LEFT,WINDOW_FRAME_TOP+eh->font()->height()*4,NET_SINGLE,symbol_str("single_play"),
    176                                      new button(WINDOW_FRAME_LEFT,WINDOW_FRAME_TOP+eh->font()->height()*6,NET_CANCEL,symbol_str("cancel_net"),
     173  jwindow *sv=wm->new_window(50,80,-1,-1,new button(WINDOW_FRAME_LEFT,WINDOW_FRAME_TOP,NET_SERVER,symbol_str("server"),
     174                                     new button(WINDOW_FRAME_LEFT,WINDOW_FRAME_TOP+wm->font()->height()*2,NET_CLIENT,symbol_str("client"),
     175                                     new button(WINDOW_FRAME_LEFT,WINDOW_FRAME_TOP+wm->font()->height()*4,NET_SINGLE,symbol_str("single_play"),
     176                                     new button(WINDOW_FRAME_LEFT,WINDOW_FRAME_TOP+wm->font()->height()*6,NET_CANCEL,symbol_str("cancel_net"),
    177177                                                NULL)))),symbol_str("Networking"));
    178178
     
    181181  do
    182182  {
    183     eh->flush_screen();
    184     do { eh->get_event(ev); } while (ev.type==EV_MOUSE_MOVE && eh->event_waiting());
     183    wm->flush_screen();
     184    do { wm->get_event(ev); } while (ev.type==EV_MOUSE_MOVE && wm->event_waiting());
    185185    if (ev.type==EV_MESSAGE)
    186186    {
     
    193193  } while (!done);
    194194
    195   eh->close_window(sv);
    196   eh->flush_screen();
     195  wm->close_window(sv);
     196  wm->flush_screen();
    197197           
    198198  if (state==RESTART_SINGLE)
     
    228228    i->y=y;
    229229    int x1,y1,x2,y2;
    230     i->area(x1,y1,x2,y2,eh);
     230    i->area(x1,y1,x2,y2);
    231231    y=y2+2;
    232232  }
    233233
    234234
    235   jwindow *nw=eh->new_window(0,0,-1,-1,ilist,symbol_str("Networking"));
     235  jwindow *nw=wm->new_window(0,0,-1,-1,ilist,symbol_str("Networking"));
    236236
    237237  done=0;
    238238  do
    239239  {
    240     eh->flush_screen();
    241     do { eh->get_event(ev); } while (ev.type==EV_MOUSE_MOVE && eh->event_waiting());
     240    wm->flush_screen();
     241    do { wm->get_event(ev); } while (ev.type==EV_MOUSE_MOVE && wm->event_waiting());
    242242    if (ev.type==EV_MESSAGE && ev.message.id==NET_OK && confirm_inputs(nw,state==RESTART_SERVER))
    243243      done=1;
     
    248248
    249249  } while (!done);
    250   eh->close_window(nw);
    251   eh->flush_screen();
     250  wm->close_window(nw);
     251  wm->flush_screen();
    252252
    253253  return ev.message.id==NET_OK;
     
    265265  int x=(xres+1)/2-ns_w/2,y=(yres+1)/2-ns_h/2;
    266266  ns->put_image(screen,x,y);
    267   JCFont *fnt=eh->font();
     267  JCFont *fnt=wm->font();
    268268
    269269  uint8_t *remap=white_light+30*256;
     
    276276    fy=y+ns_h/2-fnt->height();
    277277
    278   fnt->put_string(screen,fx+1,fy+1,message,eh->black());
    279   fnt->put_string(screen,fx,fy,message,eh->bright_color());
     278  fnt->put_string(screen,fx+1,fy+1,message,wm->black());
     279  fnt->put_string(screen,fx,fy,message,wm->bright_color());
    280280
    281281 
     
    288288    button *sb=new button(bx,by,NET_SERVER,ok,NULL);
    289289
    290     input_manager inm(screen,eh,sb);
     290    input_manager inm(screen,sb);
    291291    inm.allow_no_selections();
    292292    inm.clear_current();
     
    296296    do
    297297    {
    298       eh->flush_screen();
    299       do  { eh->get_event(ev); } while (ev.type==EV_MOUSE_MOVE && eh->event_waiting());
    300       inm.handle_event(ev,NULL,eh);
     298      wm->flush_screen();
     299      do  { wm->get_event(ev); } while (ev.type==EV_MOUSE_MOVE && wm->event_waiting());
     300      inm.handle_event(ev,NULL);
    301301      if ((ev.type==EV_KEY && (ev.key==JK_ESC || ev.key==JK_ENTER)) ||
    302302          ev.type==EV_MESSAGE) done=1;
     
    305305
    306306  screen_backup->put_image(screen,0,0);
    307   eh->flush_screen();
     307  wm->flush_screen();
    308308  delete screen_backup;
    309309}
     
    313313{
    314314  int X1,Y1,X2,Y2;
    315   i->area(X1,Y1,X2,Y2,eh);
     315  i->area(X1,Y1,X2,Y2);
    316316  i->x=(x1+x2)/2-(X2-X1)/2;
    317317
    318318  if (place_below)
    319319  {
    320     place_below->area(X1,Y1,X2,Y2,eh);
     320    place_below->area(X1,Y1,X2,Y2);
    321321    i->y=Y2+2;
    322322  }
     
    330330  int x=(xres+1)/2-ns_w/2,y=(yres+1)/2-ns_h/2;
    331331  ns->put_image(screen,x,y);
    332   JCFont *fnt=eh->font();
     332  JCFont *fnt=wm->font();
    333333  image *ok_image=cash.img(cash.reg("art/frame.spe","dev_ok",SPEC_IMAGE,1))->copy(),
    334334    *cancel_image=cash.img(cash.reg("art/frame.spe","cancel",SPEC_IMAGE,1))->copy();
     
    356356
    357357
    358     b->arrange_left_right(eh);
     358    b->arrange_left_right();
    359359    center_ifield(b,x,x+ns_w,list);
    360     b->arrange_left_right(eh);
     360    b->arrange_left_right();
    361361    list=b;
    362362
     
    372372    b->add_button(new button(0,0,MAX_3,"3",NULL));
    373373    b->add_button(new button(0,0,MAX_2,"2",NULL));
    374     b->arrange_left_right(eh);
     374    b->arrange_left_right();
    375375    center_ifield(b,x,x+ns_w,list);
    376     b->arrange_left_right(eh);   
     376    b->arrange_left_right();   
    377377    list=b;
    378378
     
    386386    b->add_button(q);
    387387
    388     b->arrange_left_right(eh);
     388    b->arrange_left_right();
    389389    center_ifield(b,x,x+ns_w,list);
    390     b->arrange_left_right(eh);   
     390    b->arrange_left_right();   
    391391    list=b;
    392392
     
    408408
    409409  {
    410     input_manager inm(screen,eh,list);
     410    input_manager inm(screen,list);
    411411    inm.allow_no_selections();
    412412    inm.clear_current();
     
    416416    do
    417417    {
    418       eh->flush_screen();
    419       do { eh->get_event(ev); } while (ev.type==EV_MOUSE_MOVE && eh->event_waiting());
    420       inm.handle_event(ev,NULL,eh);
     418      wm->flush_screen();
     419      do { wm->get_event(ev); } while (ev.type==EV_MOUSE_MOVE && wm->event_waiting());
     420      inm.handle_event(ev,NULL);
    421421      if (ev.type==EV_MESSAGE)
    422422      {
     
    450450  ns->put_image(screen,x,y);
    451451  char const *nw_s = symbol_str("Networking");
    452   JCFont *fnt=eh->font();
    453 
    454 
    455   eh->font()->put_string(screen,x+ns_w/2-strlen(nw_s)*fnt->width()/2,y+21/2-fnt->height()/2,
    456       nw_s,eh->medium_color());
     452  JCFont *fnt=wm->font();
     453
     454
     455  wm->font()->put_string(screen,x+ns_w/2-strlen(nw_s)*fnt->width()/2,y+21/2-fnt->height()/2,
     456      nw_s,wm->medium_color());
    457457  {
    458458
     
    463463      sb=new button(x+40,y+ns_h-9-fnt->height(),NET_SINGLE,symbol_str("single_play"),sb);
    464464
    465     input_manager inm(screen,eh,sb);
     465    input_manager inm(screen,sb);
    466466
    467467    inm.allow_no_selections();
     
    479479    do
    480480    {
    481       if (eh->event_waiting())
     481      if (wm->event_waiting())
    482482      {
    483         do  { eh->get_event(ev); } while (ev.type==EV_MOUSE_MOVE && eh->event_waiting());
    484         inm.handle_event(ev,NULL,eh);
     483        do  { wm->get_event(ev); } while (ev.type==EV_MOUSE_MOVE && wm->event_waiting());
     484        inm.handle_event(ev,NULL);
    485485        if (ev.type==EV_MESSAGE)
    486486        {
     
    509509        }
    510510
    511       eh->flush_screen();
     511      wm->flush_screen();
    512512      char name[256];
    513513
Note: See TracChangeset for help on using the changeset viewer.