示例#1
0
//=====================================================================================
//  Window for WIND
//=====================================================================================
CFuiWind::CFuiWind(Tag idn, const char *filename)
:CFuiWindow(idn,filename,0,0,0)
{ char erm[128];
  sprintf(erm,"Incorrect TEMPLATE file: %",filename);
  //---Locate components ------------------------------------
  layW = (CFuiList*)  GetComponent('layr');
  if (0 == layW) gtfo(erm);
  errW = (CFuiLabel*) GetComponent('eror');
  if (0 == layW) gtfo(erm);
  popW = (CFuiPopupMenu*) GetComponent('popm');
  if (0 == popW) gtfo(erm);
  skyW = (CFuiTextField*) GetComponent('ceil');
  if (0 == skyW) gtfo(erm);
  //-- Init menu -------------------------------------------
  popW->CreatePage(&cMEN,coverMENU);
  layer = globals->wtm->GetCloudLayer();
  popW->SetButtonText((char*)cMEN.aText[layer]);
  //-- Init cloud ceil -------------------------------------
  ceil = globals->wtm->GetCloudCeil();
  ChangeCeil(0);
  //-- Init list box ---------------------------------------
  U_INT type = LIST_HAS_TITLE + LIST_NOHSCROLL;
  windBOX.SetParameters(this,'layr',type);
  windBOX.Display();
  Select();
}
示例#2
0
//=====================================================================================
//=====================================================================================
//  Weather overview
//=====================================================================================
CFuiWeatherView::CFuiWeatherView(Tag idn, const char *filename)
:CFuiWindow(idn,filename,0,0,0)
{ char *erm = "Invalid template %s";
  //---Get window components -------------------------------
  datW  = (CFuiLabel*)GetComponent('date');
  if (0 == datW)  gtfo(erm,filename);
  timW  = (CFuiLabel*)GetComponent('time');
  if (0 == datW)  gtfo(erm,filename);
  utcW  = (CFuiLabel*)GetComponent('utc_');
  if (0 == utcW)  gtfo(erm,filename);
  disW  = (CFuiLabel*)GetComponent('dist');
  if (0 == disW)  gtfo(erm,filename);
  locW  = (CFuiLabel*)GetComponent('loca');
  if (0 == locW)  gtfo(erm,filename);
  winW  = (CFuiLabel*)GetComponent('wind');
  if (0 == winW)  gtfo(erm,filename);
  altW  = (CFuiLabel*)GetComponent('alti');
  if (0 == altW)  gtfo(erm,filename);
  tmpW  = (CFuiLabel*)GetComponent('temp');
  if (0 == tmpW)  gtfo(erm,filename);
  barW  = (CFuiLabel*)GetComponent('baro');
  if (0 == barW)  gtfo(erm,filename);
  cldW  = (CFuiLabel*)GetComponent('clod');
  if (0 == cldW)  gtfo(erm,filename);
  //---------------------------------------------------------
  Apt   = 0;
  Req.SetWindow(this);
}
示例#3
0
//--------------------------------------------------------------------------
//  Create a new area
//  1)  A rectangular area is located staring from the row and column of the region
//  2)  Two new candidate areas are pushed down to the stack:  One from
//      the horizontal end and one from the top row, provide the slots are not
//      already done.
//  
//--------------------------------------------------------------------------
void  CImport::OpenArea(CRectArea *zon)
{ char row  = zon->row;
  char col  = zon->col;
  zon->lgx  = 1;
  zon->lgz  = 1;
  zon->iden = ridx;
  zon->end  = 0;
  int No    = (row << TC_BY32) + col;
  zon->type = Spot[No].GetType();
  zon->elv  = Spot[No].GetValue();
  GetBaseRow(zon);
  GetLastRow(zon);
  AreaDone(zon);
  //---Add right and top area ----------------
  if (zon->OpenToX())
  { CRectArea *rzn = Stack + widx;
    rzn->col  = zon->col + zon->lgx;
    rzn->row  = zon->row;
    if (FreeSpot(rzn)) widx++;
    if (widx == AREA_STAK) gtfo ("too much areas");
  }
  if (zon->OpenToZ())
  { CRectArea *tzn = Stack + widx;
    tzn->col  = zon->col;
    tzn->row  = zon->row + zon->lgz;
    if (FreeSpot(tzn)) widx++;
    if (widx == AREA_STAK) gtfo ("too much areas");
  }
}
示例#4
0
//---------------------------------------------------------------------
//  Read the knob position
//---------------------------------------------------------------------
void  C_Knob::ReadPOSN(SStream *str)
{ if (0 == mgg) gtfo("Knob: need mother gauge");
  char txt[128];
  ReadString(txt,128,str);
  int px,py;
  int wx,hy;
  int nf = sscanf(txt,"%d , %d , %d , %d",&px,&py,&wx,&hy);
  if (4 != nf) gtfo("Invalide <posn>");
  x1  = short(px);
  y1  = short(py);
  wd  = short(wx);
  ht  = short(hy);
  InitQuad();
  return;
}
示例#5
0
//-----------------------------------------------------------------
//	Read Parameters 
//-----------------------------------------------------------------
int CgQUAD::Read(SStream *stream, Tag tag)
{ if (0 == mgg)	gtfo("<rdim> needs mother gauge");
	float pm;
	char txt[128];
	switch(tag)	{
	case 'bmap':
		ReadStrip(stream,txdf);
		return TAG_READ;
	case 'rdim':
		ReadString(txt,128,stream);
		DecodeRDIM(txt);
		return TAG_READ;
	//--- rigth skew ------------
	case 'rskw':
		ReadFloat(&pm,stream);
		quad[0].VT_Y += pm;
		quad[3].VT_Y += pm;
		return TAG_READ;
			//--- left skew ------------
	case 'lskw':
		ReadFloat(&pm,stream);
		quad[1].VT_Y += pm;
		quad[2].VT_Y += pm;
		return TAG_READ;

	}
  WARNINGLOG("Unknown Tag %s",TagToString(tag));
	return TAG_IGNORED;
}
示例#6
0
//-----------------------------------------------------------------
//  Copy elevations
//-----------------------------------------------------------------
void CElvSpot::CopyTo(int *dst,int nbv)
{ int  mvt = Dim * Dim;
  int *src = elev;
  if (nbv != mvt) gtfo("Area error");
  for(int k=0; k<nbv; k++) *dst++ = *src++;
  return;
}
示例#7
0
//----------------------------------------------------------------------
//  Decode rotation center
//----------------------------------------------------------------------
void CNeedle::ReadROTC(SStream *str)
{ char txt[128];
  float  x,y;
  ReadString(txt,128,str);
  if (2 != sscanf(txt," %f , %f \t",&x,&y))  gtfo("Invalid <rotc> tag");
  rotn.SetCenter(x,y);
  return;
}
示例#8
0
//=========================================================================================
//  AIRCRAFT SELECTION WINDOW
//  Display a list of available aircraftt with icon and make according to the popup filter
//  NOTE:  Due to the flag ok in the VehicleSelect.win, the button id is renamed okok
//=========================================================================================
CFuiSetAir::CFuiSetAir(Tag idn, const char *filename)
:CFuiWindow(idn,filename,0,0,0)
{ fSlot.FixeIt();
  airBOX.SetParameters(this,'crft',0,64);
  selPOP = (CFuiPopupMenu*)GetComponent('type');
  if (0 == selPOP)  gtfo("Wrong file VehicleSelect.win");
  selBTN = (CFuiButton*)   GetComponent('okok');
  if (0 == selBTN)  gtfo("Wrong file VehicleSelect.win");
  //---Create associated mask (change size when adding new type) ---------------
  mask[0]       = 0x00FF;
  mask[1]       = 0x01;
  mask[2]       = 0x02;
  mask[3]       = 0x04;
  mask[4]       = 0x08;
  mask[5]       = 0x10;
  EditSelPopup();
}
示例#9
0
//----------------------------------------------------------------
//  Init quad to the requested dimension
//----------------------------------------------------------------
void VStrip::ReadPOSN(SStream *str)
{ if (0 == mgg) gtfo("VStrip need mother gauge");
  vtab  = new TC_VTAB[4];
	vOfs  = mgg->FixRoom(4);								// OK
  mgg->DecodePOSN(str,vtab,1);
  quad  = vtab;
  return;
}
示例#10
0
文件: i3.c 项目: ifbyair/input
int main(int ac, char *av[]){
    static struct termios origt,newt;
    volatile char c;

    printf("Welcome to the menu system\n");

    if( tcgetattr(STDIN_FILENO,&origt) < 0 )
        gtfo("tcgetattr failed!\n");

    newt = origt;

    newt.c_lflag &= ~(ICANON);

    if( tcsetattr(STDIN_FILENO, TCSANOW, &newt) < 0 ){
        tcsetattr(STDIN_FILENO, TCSANOW, &origt);
        gtfo("tcsetattr failed!\n");
    }

    menu *m1 = newMenu("Ultimate control",3);
    m1->items[0] = *newItem("Item 1", &item1);
    m1->items[1] = *newItem("Item 2", &item2);
    m1->items[2] = *newItem("Item 3", &item3);

// Do some useful shit
    while(1){
        c = getchar();
        if( c == 'q' )
            break;
        switch(c){
            case 'j':
                menu_down(m1);
                break;
            case 'k':
                menu_up(m1);
                break;
            case 'e':  // execute
                menu_execute(m1);
                break;
        }
    }
// Done with useful shit
    
    tcsetattr(STDIN_FILENO, TCSANOW, &origt);
    printf("We're done, bye!\n");
}
示例#11
0
//-----------------------------------------------------------------
//	Decode dimension and build quad 
//-----------------------------------------------------------------
void CgQUAD::DecodeRDIM(char *txt)
{	float w,h;
	int nf = sscanf(txt," %f , %f ", &w, &h);
	if (2 != nf)	gtfo("Invalid <rdim> parameters");
	float sx  = mgg->GetXPos();
  float sy  = mgg->GetYPos();
	mgg->BuildQuad(quad,sx,sy,w,h);
	return;
}
示例#12
0
//----------------------------------------------------------------------
//  Decode rotation center and dimension
//  <cntr> -------
//  x,y,r
//----------------------------------------------------------------------
void CNeedle::ReadNCTR(SStream *str)
{ if (0 == mgg)  gtfo("<nctrj>: Mother Gauge needed");
  vtab  = new TC_VTAB[4];
	vOfs = mgg->FixRoom(4);
  mgg->DecodeNCTR(str,vtab,1);
  //---- set the needle quad --------------
  rotn.SetVTAB(vtab);
	rotn.SetVBO(vOfs);
  return;
}
示例#13
0
//----------------------------------------------------------------
//  Read a strip of vertical texture
//  By default, the quad is copied from the mother gauge
//----------------------------------------------------------------
void VStrip::ReadStrip(SStream *s)
{ CStreamObject::ReadStrip(s,txd);
  hiFrame = txd.nf - 1;
  if (quad)   return;
  //---- Allocate a quad and dupplicate the mother gauge --
  if (0 == mgg) gtfo("VStrip need mother gauge");
  quad  = mgg->GetVTAB();
  vOfs	= mgg->ofsVBO();										// OK    
  return;
}
示例#14
0
//----------------------------------------------------------------------
//  If the position is specified, the needle uses its own Quad
//  whatever the position is
//  NOTE:  The coordinates are relative to the top left corner of the Gauge
//----------------------------------------------------------------------
void  CNeedle::ReadPOSN(SStream *str)
{ if (0 == mgg)  gtfo("<posn>: Mother Gauge needed");
  //--- Allocate the needle quad --------------------------
  vtab = new TC_VTAB[4];
	vOfs = mgg->FixRoom(4);
  mgg->DecodePOSN(str,vtab,1);
  //---- Set the needle quad ------------------------
  rotn.SetVTAB(vtab);
	rotn.SetVBO(vOfs);
  return;
  }
示例#15
0
//----------------------------------------------------------------------
//  If the projection is specified, the needle uses its own Quad
//  whatever the position is
//  NOTE:  All coordinates are relative to the top left corner of the gauge
//----------------------------------------------------------------------
void CNeedle::ReadPROJ(SStream *str)
{ if (0 == mgg)  gtfo("<proj>: Mother Gauge needed");
  vtab = new TC_VTAB[4];
	vOfs = mgg->FixRoom(4);
  //--- Decode projector corners -----------
  mgg->DecodePROJ(str,vtab,1);
  //---- Set the needle quad ---------------
  rotn.SetVTAB(vtab);
	rotn.SetVBO(vOfs);
  return;
}
示例#16
0
//=======================================================================================
//  CFuiFuel window
//=======================================================================================
CFuiFuel::CFuiFuel(Tag idn, const char* filename)
:CFuiWindow(idn,filename,0,0,0)
{ char *erm = "incorrect VehicleFuel.WIN file";
  rul = (CFuiSlider*)GetComponent('tots');
  if (0 == rul) gtfo(erm);
  All = (CFuiLabel *)GetComponent('totl');
  if (0 == All) gtfo(erm);
  Sel = (CFuiLabel *)GetComponent('selt');
  if (0 == Sel) gtfo(erm);
  pop = (CFuiPopupMenu*)GetComponent('stuf');
  if (0 == pop) gtfo(erm);
  Tnk = (CFuiList*)  GetComponent('tank');
  if (0 == Tnk) gtfo(erm);
  Tot.SetName("ALL TANKS");
  sCel  = &Tot;
  cBOX  = 0;
	//---------------------------------------------------
	plan	= globals->pln;
	if (plan)	Init();
	else			Close();
}
示例#17
0
//--------------------------------------------------------------
//  Read list of actions
//---------------------------------------------------------------
void CGaugeAction::ReadActions(SStream *str)
{ char txt[128];
  int na = 0;
  ReadInt(&na,str);
  while (na--)
  { ReadString(txt,128,str);
    BASE_ACT *a = new BASE_ACT();
    vact.push_back(a);
    if (DecodeFrame  (txt,a))   continue;
    if (DecodeMessage(txt,a))   continue;
    gtfo("Bad Gauge action");
  }
  return;
}
示例#18
0
//-----------------------------------------------------------
//  Read texture position
//-----------------------------------------------------------
void C_Cover::ReadSize(SStream *str)
{ if (0 == mgg)  gtfo("Mother Gauge needed");
  int px = 0;
  int py = 0;
  int wd = 0;
  int ht = 0;
  ReadSIZE(str,&px,&py,&wd,&ht);
  px += mgg->GetXPos();
  py += mgg->GetYPos();
  //---- Build the needle quad ------------------------
  vtab  = new TC_VTAB[4];
	vOfs  = mgg->FixRoom(4);
  mgg->BuildQuad(vtab,px,py,wd,ht);
  quad  = vtab;
}
示例#19
0
//---------------------------------------------------------------------
//  Init quad from mother gauge
//---------------------------------------------------------------------
void C_Knob::InitQuad()
{ if (0 == mgg) gtfo("Knob: need mother gauge");
	if (vOfs)			return;
  //--- Compute rectangle ---------------------------
  x2  = x1 + wd;
  y2  = y1 + ht;
  //--- Init quad -----------------------------------
  int sx = mgg->GetXPos() + x1;       // x position in panel
  int sy = mgg->GetYPos() + y1;       // y position in panel
  mgg->BuildQuad(quad,sx,sy,wd,ht);    // Init knob quad
	vOfs	 = mgg->FixRoom(4);
  rotn.SetVTAB(quad);
  rotn.SetVBO(vOfs);
  return;
}
示例#20
0
//---------------------------------------------------------------------
//  Read the projector
//---------------------------------------------------------------------
void C_Knob::ReadPROJ(SStream *str)
{ if (0 == mgg) gtfo("Knob: need mother gauge");
  mgg->DecodePROJ(str,quad,1);
  //--- compute top left corner ------------------
  x1  = GetLefPos(quad);
  y1  = GetTopPos(quad);
  wd  = GetWIDTH(quad);
  ht  = GetHEIGHT(quad);
  x2  = x1 + wd;
  y2  = y1 + ht;
	vOfs	= mgg->FixRoom(4);
  rotn.SetVTAB(quad);
	rotn.SetVBO(vOfs);
  return;
}
示例#21
0
//---------------------------------------------------------------------
//  Read 
//---------------------------------------------------------------------
int CDigit::Read(SStream *str, Tag tag)
{ if (0 == mgg) gtfo("CDigit: Mother gauge needed");
  switch (tag)  {
    //--- Get position ------------------
    case 'posn':
      mgg->DecodeCADR(str,quad,1);
      return TAG_READ;
    //--- GetProjector ------------------
    case 'proj':
      mgg->DecodePROJ(str,quad,1);
      return TAG_READ;
    //--- Integer digit -----------------
    case 'idig':
      type  = 0;
      return TAG_READ;
    //--- Partial digit -----------------
    case 'pdig':
      type  = 1;
      return TAG_READ;
  }
  return TAG_IGNORED;
}
示例#22
0
//---------------------------------------------------------------------
//  Read all parameters
//---------------------------------------------------------------------
int CNeedleMark::Read(SStream *stream, Tag tag)
{ if (0 == mgg) gtfo("<CNeedleMark: need mother gauge");
  switch (tag)  {
    case 'bmap':
      nedl.SetGauge(mgg);
      nedl.ReadBMAP(stream);
      return TAG_READ;
    //--- rotation center --------------
    case 'rotc':
      nedl.ReadROTC(stream);
      return TAG_READ;
    //--- minimum value ----------------
    case 'dmin':
      ReadFloat(&dmin, stream);
      return TAG_READ;
    //--- maximum value ----------------
    case 'dmax':
      ReadFloat(&dmax, stream);
      return TAG_READ;
    //--- Clamp values -----------------
    case 'clmp':
      ReadFloat(&dmin,stream);
      ReadFloat(&dmax,stream);
      return TAG_READ;
    //--- Current value ----------------
		case 'sang':
    case 'dval':
      ReadFloat(&dval,stream);
			SaveValue(dval);
      return TAG_READ;
    //--- Knob -------------------------
    case 'knob':
      ReadKNOB(stream);
      return TAG_READ;

  }
  WARNINGLOG("CNeedleMark: tag %s unknowned",TagToString(tag));
  return TAG_IGNORED;
}
示例#23
0
//======================================================================================
//  CFuiAxis to assign Joystick axes
//======================================================================================
CFuiAxis::CFuiAxis(Tag idn, const char *filename)
:CFuiWindow(idn,filename,0,0,0)
{ char err[128];
  sprintf(err,"Incorrect TEMPLATE file: %s",filename);
  all = 1;
  jsd = 0;
	jsp	= 0;
  jsm = globals->jsm;
  //---Locate components -----------------------------
  asgWIN    = (CFuiButton*)   GetComponent('defa');
  if (0 == asgWIN )  gtfo(err);
  labWIN    = (CFuiLabel*)    GetComponent('?lbl');
  if (0 == labWIN )  gtfo(err);
  vehPOP    = (CFuiPopupMenu*)GetComponent('type');
  if (0 == vehPOP )  gtfo(err);
  chkWIN    = (CFuiCheckbox*) GetComponent('alla');
  if (0 == chkWIN )  gtfo(err);
	//--- Group box axes ------------------------------
	gp1AXE		= (CFuiGroupBox*) GetComponent('axes');
  if (0 == gp1AXE)   gtfo(err);
	devAXE		= (CFuiLabel*)		gp1AXE->GetComponent('devn');
	if (0 == devAXE)	gtfo(err);
	labAXE		= (CFuiLabel*)		gp1AXE->GetComponent('axen');
	if (0 == labAXE)	gtfo(err);
	valAXE    = (CFuiSlider*)   gp1AXE->GetComponent('axev');
  if (0 == valAXE)   gtfo(err);
	valAXE->SetProperty(FUI_NO_MOUSE);
  invAXE = (CFuiCheckbox*)gp1AXE->GetComponent('chka');
  if (0 == invAXE)   gtfo(err);
	//--- Group box tune -------------------------------
	grpFOR		= (CFuiGroupBox*) GetComponent('tune');
  if (0 == grpFOR)   gtfo(err);
	minFOR    = (CFuiButton*)   GetComponent('opr-');
  if (0 == minFOR )  gtfo(err);
	plsFOR    = (CFuiButton*)   GetComponent('opr+');
  if (0 == plsFOR )  gtfo(err);
	//--- Neutral box ----------------------------------
	labNEU		= (CFuiLabel*)    GetComponent('labN');
	if (0 == labNEU )  gtfo(err);
	valNEU		= (CFuiSlider*)   GetComponent('neut');
	if (0 == valNEU )  gtfo(err);
	//--- Button control -------------------------------
	devPOP    = (CFuiPopupMenu*)GetComponent('devl');
  if (0 == devPOP )  gtfo(err);
	grpHAT		= (CFuiGroupBox*) GetComponent('hatg');
  if (0 == grpHAT)   gtfo(err);
	chkHAT    = (CFuiCheckbox*)grpHAT->GetComponent('useH');
	if (0 == chkHAT)   gtfo(err);
	//--------------------------------------------------
  axeBOX.SetParameters(this,'list',0,0);
	butBOX.SetParameters(this,'butL',0,0);
  //-----Init vehicle menu ---------------------------
	jsm->CreateDevList(devMENU,16);
	ShowNeutral();
  chkWIN->SetState(all);
  vehPOP->CreatePage(&vehMEN,vehMENU);
	devPOP->CreatePage(&devMEN,devMENU);
  SelectVehicle(0);
  FillAxes(0);
	AxeSelect(0);
	ButtonList(0);
	HatControl();
  //----Allow for Joystick detection ------------------
	if (jsm->IsBusy()) Close();
	else	{	jsm->StartDetectMoves(WhenAxeMove,windowId);
					jsm->StartDetectButton(WhenButtonClick,windowId);
				}
}
示例#24
0
//--------------------------------------------------------------
//  Init the window
//--------------------------------------------------------------
void CFuiVehOption::ReadFinished()
{ CFuiWindow::ReadFinished();
  if (0 == surface) gtfo("CFuiVehOption: no surface");
}
示例#25
0
//--------------------------------------------------------------
//  Adjust the texture rotation center
//  Texture wd and ht must be present
//---------------------------------------------------------------
void CRotNeedle::SetCenter(double dx, double dy)
{ if (0 == quad)      gtfo("<rotc> Gauge without dimension");
  rotc.x  = double(dx) / double(txd.wd);
  rotc.y  = double(1) - (double(dy) / double(txd.ht));
  return;
}