Ejemplo n.º 1
0
// Renders a box with a hole in the middle.
void Geometry::RenderBox(const Core::Vector2f& origin, const Core::Vector2f& dimensions, const Core::Vector2f& hole_origin, const Core::Vector2f& hole_dimensions, const Core::Colourb& colour)
{
	// Top box.
	float top_y_dimensions = hole_origin.y - origin.y;
	if (top_y_dimensions > 0)
	{
		RenderBox(origin, Core::Vector2f(dimensions.x, top_y_dimensions), colour);
	}

	// Bottom box.
	float bottom_y_dimensions = (origin.y + dimensions.y) - (hole_origin.y + hole_dimensions.y);
	if (bottom_y_dimensions > 0)
	{
		RenderBox(Core::Vector2f(origin.x, hole_origin.y + hole_dimensions.y), Core::Vector2f(dimensions.x, bottom_y_dimensions), colour);
	}

	// Left box.
	float left_x_dimensions = hole_origin.x - origin.x;
	if (left_x_dimensions > 0)
	{
		RenderBox(Core::Vector2f(origin.x, hole_origin.y), Core::Vector2f(left_x_dimensions, hole_dimensions.y), colour);
	}

	// Right box.
	float right_x_dimensions = (origin.x + dimensions.x) - (hole_origin.x + hole_dimensions.x);
	if (right_x_dimensions > 0)
	{
		RenderBox(Core::Vector2f(hole_origin.x + hole_dimensions.x, hole_origin.y), Core::Vector2f(right_x_dimensions, hole_dimensions.y), colour);
	}
}
Ejemplo n.º 2
0
void	RenderHLine( int sx, int sy, int ex, char dot, char width, char spacing, int farbe )
{
	if (dot == 0)  RenderBox(sx,(int)(sy-(width/2)),ex, (int)(sy+(width/2)), FILL, farbe);
	if (dot == 1)
	{
		while (sx <= ex)
		{
			RenderBox(sx,(int)(sy-(width/2)),sx+width, (int)(sy+(width/2)), FILL, farbe);
			sx=sx+width+(spacing*width);
		}
	}
}
Ejemplo n.º 3
0
void	RenderVLine( int sx, int sy, int ey, char dot, char width, char spacing, int farbe )
{
	if (dot == 0)  RenderBox((int)(sx-(width/2)),sy,(int)(sx+(width/2)),ey , FILL, farbe);
	if (dot == 1)
	{
		while (sy <= ey)
		{
			RenderBox((int)(sx-(width/2)),sy,(int)(sx+(width/2)),sy+width , FILL, farbe);
			sy=sy+width+(spacing*width);
		}
	}
}
Ejemplo n.º 4
0
//************************************************************************************************
// 	cMenuItem::Draw()
//************************************************************************************************
void cMenuItem::Draw(int ItemLeft , int ItemTop, int ItemWidth)
{
    if (ItemLeft > -1)
	m_ItemLeft = ItemLeft;
    if (ItemTop > -1)
	m_ItemTop = ItemTop;
    if (ItemWidth > -1)
	m_ItemWidth = ItemWidth;
	
    if (m_Selected)
    {
	RenderBox(m_ItemLeft, 
		  m_ItemTop, 
		  m_ItemLeft + m_ItemWidth, 
		  m_ItemTop  + ITEM_HEIGHT, 
		  FILL, 
		  SKIN3);
    
	RenderString(m_pText, 
		     m_ItemLeft + ITEM_TEXT_LEFT, 
		     m_ItemTop  + ITEM_TEXT_TOP, 
		     m_ItemLeft + m_ItemWidth - ITEM_TEXT_RIGHT, 
		     LEFT, 
		     WHITE, 
		     SKIN3);
    }
    else
    {
	if (ItemLeft == -1)
	{
	    RenderBox(m_ItemLeft, 
		      m_ItemTop, 
		      m_ItemLeft + m_ItemWidth, 
		      m_ItemTop  + ITEM_HEIGHT, 
		      FILL, 
		      SKIN2);
	}	  
	
	RenderString(m_pText, 
	             m_ItemLeft + ITEM_TEXT_LEFT, 
		     m_ItemTop  + ITEM_TEXT_TOP, 
		     m_ItemLeft + m_ItemWidth - ITEM_TEXT_RIGHT, 
		     LEFT, 
		     WHITE, 
		     SKIN2);
    }
}
Ejemplo n.º 5
0
void DrawBox(NxShape* box, const NxVec3& color)
{
	NxMat34 pose = box->getGlobalPose();

	glPushMatrix();
	SetupGLMatrix(pose.t, pose.M);
	NxVec3 boxDim = box->isBox()->getDimensions();
	glScalef(boxDim.x, boxDim.y, boxDim.z);
	RenderBox(2.0);
	glPopMatrix();
}
Ejemplo n.º 6
0
  /**
   * Renders the AbstractAirspace on the canvas
   * @param as AbstractAirspace to render
   */
  void
  Render(const AbstractAirspace& as)
  {
    int type = as.get_type();
    if (type <= 0)
      return;

    // No intersections for this airspace
    if (m_intersections.empty())
      return;

    // Select pens and brushes
#ifdef ENABLE_SDL
    Color color =
      Graphics::GetAirspaceColour(settings.colours[type]);
#ifdef ENABLE_OPENGL
    color = color.with_alpha(48);
#endif
    Brush brush(color);
#else
    const Brush &brush = Graphics::GetAirspaceBrushByClass(type, settings);
    canvas.set_text_color(light_color(Graphics::GetAirspaceColourByClass(type, settings)));
#endif

    PixelRect rcd;
    // Calculate top and bottom coordinate
    rcd.top = chart.screenY(as.get_top_altitude(state));
    if (as.is_base_terrain())
      rcd.bottom = chart.screenY(fixed_zero);
    else
      rcd.bottom = chart.screenY(as.get_base_altitude(state));

    // Iterate through the intersections
    for (AirspaceIntersectionVector::const_iterator it = m_intersections.begin();
         it != m_intersections.end(); ++it) {
      const GeoPoint p_start = it->first;
      const GeoPoint p_end = it->second;
      const fixed distance_start = start.distance(p_start);
      const fixed distance_end = start.distance(p_end);

      // Determine left and right coordinate
      rcd.left = chart.screenX(distance_start);
      rcd.right = chart.screenX(distance_end);

      // only one edge found, next edge must be beyond screen
      if ((rcd.left == rcd.right) && (p_start == p_end)) {
        rcd.right = chart.screenX(chart.getXmax());
      }

      // Draw the airspace
      RenderBox(rcd, brush, settings.black_outline, type);
    }
  }
void TerrainTilesPanel::OnRender(ion::render::Renderer& renderer, const ion::Matrix4& cameraInverseMtx, const ion::Matrix4& projectionMtx, float& z, float zOffset)
{
	//Render canvas
	RenderCanvas(renderer, cameraInverseMtx, projectionMtx, z);

	z += zOffset;

	//Render selected TerrainTile
	if(m_selectedTerrainTile != InvalidTerrainTileId)
	{
		if(TerrainTile* terrainTile = m_project.GetTerrainTileset().GetTerrainTile(m_selectedTerrainTile))
		{
			ion::Vector2 size(1, 1);
			const ion::Colour& colour = m_renderResources.GetColour(RenderResources::eColourSelected);
			RenderBox(m_selectedTerrainTilePos, size, colour, renderer, cameraInverseMtx, projectionMtx, z);
		}
	}

	z += zOffset;

	//Render mouse hover TerrainTile
	if(m_hoverTerrainTile != InvalidTerrainTileId && m_hoverTerrainTile != m_selectedTerrainTile)
	{
		if(TerrainTile* terrainTile = m_project.GetTerrainTileset().GetTerrainTile(m_hoverTerrainTile))
		{
			ion::Vector2 size(1, 1);
			const ion::Colour& colour = m_renderResources.GetColour(RenderResources::eColourHighlight);
			RenderBox(m_hoverTerrainTilePos, size, colour, renderer, cameraInverseMtx, projectionMtx, z);
		}
	}

	z += zOffset;

	//Render grid
	if(m_project.GetShowGrid())
	{
		RenderGrid(renderer, cameraInverseMtx, projectionMtx, z);
	}
}
Ejemplo n.º 8
0
  /**
   * Renders the AbstractAirspace on the canvas
   * @param as AbstractAirspace to render
   */
  void
  Render(const AbstractAirspace& as)
  {
    int type = as.GetType();
    if (type <= 0)
      return;

    // No intersections for this airspace
    if (m_intersections.empty())
      return;

    // Select pens and brushes
#ifndef USE_GDI
    Color color = airspace_look.colors[settings.colours[type]];
#ifdef ENABLE_OPENGL
    color = color.WithAlpha(48);
#endif
    Brush brush(color);
#else
    const Brush &brush = airspace_look.brushes[settings.brushes[type]];
    canvas.SetTextColor(LightColor(airspace_look.colors[settings.colours[type]]));
#endif

    PixelRect rcd;
    // Calculate top and bottom coordinate
    rcd.top = chart.screenY(as.GetTopAltitude(state));
    if (as.IsBaseTerrain())
      rcd.bottom = chart.screenY(fixed_zero);
    else
      rcd.bottom = chart.screenY(as.GetBaseAltitude(state));

    // Iterate through the intersections
    for (auto it = m_intersections.begin(); it != m_intersections.end(); ++it) {
      const GeoPoint p_start = it->first;
      const GeoPoint p_end = it->second;
      const fixed distance_start = start.Distance(p_start);
      const fixed distance_end = start.Distance(p_end);

      // Determine left and right coordinate
      rcd.left = chart.screenX(distance_start);
      rcd.right = chart.screenX(distance_end);

      // only one edge found, next edge must be beyond screen
      if ((rcd.left == rcd.right) && (p_start == p_end)) {
        rcd.right = chart.screenX(chart.getXmax());
      }

      // Draw the airspace
      RenderBox(rcd, brush, settings.black_outline, type);
    }
  }
Ejemplo n.º 9
0
static void ShowInfo(int index)
{
	int loop, tind;
	char tstr[512];
	int ixw=160, iyw=300, dy, my, offs=10, soffs=3;

	dy=iyw/12;
	my=2*dy;
	
	startx = sx + (((ex-sx) - ixw)/2);
	starty = sy + (((ey-sy) - iyw)/2);

	tind=index;
	
	//frame layout
	RenderBox(0, 0, ixw, iyw, radius, CMC);
//	RenderBox(0, 0, ixw, iyw, GRID, CMCS, radius);

	// titlebar
	RenderBox(2, 2, ixw-2, dy+2*soffs, radius, CMH);

	//selectbar
	RenderBox(2, offs+soffs+(index+1)*dy, ixw, offs+soffs+(index+2)*dy, radius, CMCS);

	RenderString("Rezap-Zeit", 0, dy, ixw, CENTER, MED, CMHT);

	for(loop = 0; loop < 10; ++loop)
	{
		sprintf(tstr,"%1d =",(loop<9)?(loop+1):0);
		RenderString(tstr, 10, offs+my, 40, CENTER, MED, (loop == tind)?CMCST:CMCT);
		sprintf(tstr,"%2d   min",wtime[loop]);
		RenderString(tstr, 40, offs+my, ixw-60, RIGHT, MED, (loop == tind)?CMCST:CMCT);
		my += dy;
	}

	//copy backbuffer to framebuffer
	memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres);
}
Ejemplo n.º 10
0
//************************************************************************************************
// 	Draw()
//************************************************************************************************
void cMenu::Draw()
{
    IMPORT_FRAMEBUFFER_VARS;
    
    int MaxMenuHeight = p_ysize - MENU_TOP_MARGIN - MENU_BOTTOM_MARGIN;
    int MenuHeight = MENU_HEADER_HEIGHT;
    m_VisibleItemEnd = m_VisibleItemBegin;
    for (unsigned int i = 0; (MenuHeight + (*m_VisibleItemEnd)->GetItemHeight() <= MaxMenuHeight) && (i < m_ItemList.size()); i++)
    {
	MenuHeight += ITEM_HEIGHT;
	m_VisibleItemEnd++;
    }
    
    if ((m_VisibleItemBegin != m_ItemList.begin()) || (m_VisibleItemEnd != m_ItemList.end()))
	MenuHeight = MENU_HEADER_HEIGHT + m_ItemList.size() * ITEM_HEIGHT;
    
    int MenuTop  = (p_ysize - MenuHeight)  / 2; 
    int MenuLeft = (p_xsize  - m_ItemWidth) / 2;
    
    
    RenderBox(MenuLeft, MenuTop, MenuLeft+m_ItemWidth, MenuTop+MENU_HEADER_HEIGHT, FILL, SKIN1);
    RenderBox(MenuLeft, MenuTop+MENU_HEADER_HEIGHT, MenuLeft+m_ItemWidth, MenuTop+MenuHeight, FILL, SKIN2);
    RenderString(m_pName, MenuLeft+ITEM_TEXT_LEFT, MenuTop, m_ItemWidth-ITEM_TEXT_LEFT-ITEM_TEXT_RIGHT, 
		 LEFT, YELLOW, SKIN1);
	
    TItemList::iterator it;	 
    int Top = MenuTop + MENU_HEADER_HEIGHT;
    for (it = m_VisibleItemBegin; it != m_VisibleItemEnd; it++)
    {
	(*it)->Draw(MenuLeft, Top, m_ItemWidth);
	Top += (*it)->GetItemHeight();
	
	if (it == m_SelectedItem)
	    (*it)->SetSelected(true);
    }
}
Ejemplo n.º 11
0
//************************************************************************************************
// 	cMenuSeparatorItem::Draw()
//************************************************************************************************
void cMenuSeparatorItem::Draw(int ItemLeft , int ItemTop, int ItemWidth)
{
    if (ItemLeft > -1)
	m_ItemLeft = ItemLeft;
    if (ItemTop > -1)
	m_ItemTop = ItemTop;
    if (ItemWidth > -1)
	m_ItemWidth = ItemWidth;
	
    RenderBox(m_ItemLeft + 3, 
	      m_ItemTop + m_ItemHeight / 2 - 1, 
	      m_ItemLeft + m_ItemWidth - 3, 
	      m_ItemTop + m_ItemHeight / 2 + 1, 
	      FILL, 
	      SKIN3);
}
Ejemplo n.º 12
0
//************************************************************************************************
// 	DrawMsgBox()
//************************************************************************************************
void cMenu::DrawMsgBox(char* header, char* question, bool okBtn, bool homeBtn, bool drawAll)
{
   IMPORT_FRAMEBUFFER_VARS;
   if (drawAll)
   {
      STORE_PALETTE(&colormap);
      RenderBox(0, 0, p_xsize, p_ysize, FILL, TRANSP);
   }
   
   int Width = 530;
   int Height = 142;
   int Left = p_xsize / 2 - Width / 2;
   int Top = p_ysize / 2 - Height / 2;

   if (drawAll)
   {
      RenderBox(Left, Top, Left+Width, Top+Height, FILL, SKIN3);
      RenderBox(Left, Top+42, Left+Width, Top+Height, FILL, SKIN3);
      RenderBox(Left+2, Top+2, Left+Width-2, Top+42-1, FILL, SKIN1);
      RenderBox(Left+2, Top+42+1, Left+Width-2, Top+Height-2, FILL, SKIN2);
      
      
      RenderString(header, Left+2, Top+6, Width-2, CENTER, YELLOW, SKIN1);
   }
   RenderString(question, Left+2, Top+42+6, Width-2, CENTER, WHITE, SKIN2);
   
   if (drawAll)
   {
      if (okBtn)
      {
         RenderBox(Left+70, Top+Height-42, Left+70+70, Top+Height-12, FILL, SKIN3);
         RenderString("OK", Left+70, Top+Height-42, 70, CENTER, WHITE, SKIN3);
      }
      
      if (homeBtn)
      {
         RenderBox(Left+Width-70-70, Top+Height-42, Left+Width-70, Top+Height-12, FILL, SKIN3);
         RenderString("HOME", Left+Width-70-70, Top+Height-42, 70, CENTER, WHITE, SKIN3);
      }
   }
}
int main (int argc, char **argv)
{
	int i,j,found=0,m,mask=1,kmode=1,pmode=0, lc=-1, changed=0, todo=1, help=1, help_changed=0, move=0;
	unsigned char actchan[20]=""/*,channel[128]=""*/;
	FILE *fh,*fh2;
	char *cpt1,*cpt2;
	gpixel mp, mc[MAX_MASK], tp;
	int tsx=430, tsy=120, tdy=24, tsz=28, txw=500, tcol=TURQUOISE;
	int xp[MAX_MASK][8],yp[MAX_MASK][8],xw[MAX_MASK][8],yw[MAX_MASK][8],valid[MAX_MASK],cmc[MAX_MASK],xxp,xxw,yyp,yyw,nmsk=0,amsk=0;
	double xs=1.0, ys=1.0;
	time_t t1,t2;

		for(j=0; j<MAX_MASK; j++)
		{
			valid[j]=0;
			cmc[j]=BLACK;
			make_color(BLACK, &mc[j]);
			for(i=0; i<8; i++)
			{
				xp[j][i]=(1280-40)/2;
				xw[j][i]=40;
				yp[j][i]=(720-20)/2;
				yw[j][i]=20;
			}	
		}
		system("pzapit -var > /tmp/logomaskset.stat");
		if((fh=fopen("/tmp/logomaskset.stat","r"))!=NULL)
		{
			if(fgets(tstr,500,fh))
			{
				TrimString(tstr);
				if(strlen(tstr))
				{
					if(sscanf(tstr+strlen(tstr)-1,"%d",&pmode)!=1)
					{
						pmode=0;
					}
				}
			}
			fclose(fh);
		}
	
		system("touch /tmp/.logomask_kill");

		fb = open(FB_DEVICE, O_RDWR);

		if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1)
		{
			printf("logomask <FBIOGET_FSCREENINFO failed>\n");
			return -1;
		}
		if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1)
		{
			printf("logomask <FBIOGET_VSCREENINFO failed>\n");
			return -1;
		}
		
		if(!(lfb = (unsigned char*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0)))
		{
			printf("logomask <mapping of Framebuffer failed>\n");
			return -1;
		}

	//init fontlibrary

		if((error = FT_Init_FreeType(&library)))
		{
			printf("logomask <FT_Init_FreeType failed with Errorcode 0x%.2X>", error);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_Manager_New(library, 1, 2, 0, &MyFaceRequester, NULL, &manager)))
		{
			printf("logomask <FTC_Manager_New failed with Errorcode 0x%.2X>\n", error);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_SBitCache_New(manager, &cache)))
		{
			printf("logomask <FTC_SBitCache_New failed with Errorcode 0x%.2X>\n", error);
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_Manager_LookupFace(manager, FONT, &face)))
		{
			printf("logomask <FTC_Manager_Lookup_Face failed with Errorcode 0x%.2X>\n", error);
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		use_kerning = FT_HAS_KERNING(face);

		desc.face_id = FONT;
		desc.flags = FT_LOAD_MONOCHROME;


		InitRC();

	//init backbuffer

		if(!(lbb = malloc(fix_screeninfo.line_length*var_screeninfo.yres)))
		{
			printf("logomask <allocating of Backbuffer failed>\n");
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		memset(lbb, 0, fix_screeninfo.line_length*var_screeninfo.yres);

		system("pzapit -gi > /tmp/logomask.chan");
		if((fh=fopen("/tmp/logomask.chan","r"))!=NULL)
		{
			if(fgets(tstr, BUFSIZE, fh))
			{
				TrimString(tstr);
				if((cpt1=strchr(tstr,' '))!=NULL)
					*cpt1=0;
			}
			fclose(fh);
			if(strlen(tstr))
			{
				strcpy(actchan,tstr);
			}

			if((fh=fopen(CFG_FILE,"r"))!=NULL)
			{
				found=0;
				while(fgets(tstr, BUFSIZE, fh) && !found)
				{
					TrimString(tstr);
					if(strlen(tstr))
					{
						if(strstr(tstr,actchan)!=NULL)
						{
							mask=1;
							nmsk=0;
							cpt2=strstr(tstr,",MC");
							if((cpt1=strchr(tstr,','))!=NULL)
							{
								while(cpt1)
								{
									valid[nmsk]=0;
									if(cpt2 && sscanf(cpt2+1,"MC%8X",&mp.lpixel)==1)
									{
										cpt2=strchr(cpt2+1,',');
									}
									else
									{
										make_color(BLACK, &mp);
									}
									for(i=0; i<8 && cpt1; i++)
									{
										cpt1++;
										if(sscanf(cpt1,"%d,%d,%d,%d",&xxp,&xxw,&yyp,&yyw)==4)
										{
											xp[nmsk][i]=xxp;
											xw[nmsk][i]=xxw;
											yp[nmsk][i]=yyp;
											yw[nmsk][i]=yyw;
											mc[nmsk].lpixel=mp.lpixel;
											found=1;
											valid[nmsk]=1;
										}
										for(j=0; j<4 && cpt1; j++)
										{
											cpt1=strchr(cpt1+1,',');
										}
									}
									if(valid[nmsk])
									{
										nmsk++;
									}
								}
							}
						}
					}
				}
				fclose(fh);
			}
		}

		if(!nmsk)
		{
			nmsk=1;
			valid[0]=1;
		}
		mask=nmsk;
		for(m=0; m<MAX_MASK; m++)
		{
			if(valid[m])
			{
				xxp=xp[m][pmode];
				xxw=xw[m][pmode];				
				yyp=yp[m][pmode];
				yyw=yw[m][pmode];
				tp.lpixel=mc[m].lpixel;
				RenderBox(xxp, yyp, xxp+xxw, yyp+yyw, FILL, &tp);
				if(m==amsk)
					RenderBox(xxp, yyp, xxp+xxw, yyp+yyw, GRID, make_color(LBLUE,&tp));
				for(i=0;i<=yyw;i++)
				{
					j=(yyp+i)*fix_screeninfo.line_length+(xxp<<2);
					if((j+(xxw<<2))<fix_screeninfo.line_length*var_screeninfo.yres)
					{
						memcpy(lfb+j, lbb+j, xxw<<2);
					}
				}
			}
		}
		time(&t1);
		while((rc!=KEY_EXIT) && (rc!=KEY_OK))
		{
			rc=GetRCCode();
			if((rc!=-1) && (rc!=KEY_EXIT) && (rc!=KEY_OK))
			{
				time(&t1);
				move=0;
				xxp=xp[amsk][pmode];
				xxw=xw[amsk][pmode];
				yyp=yp[amsk][pmode];
				yyw=yw[amsk][pmode];
				lpix.lpixel=mc[amsk].lpixel;
				switch(rc)
				{
					case KEY_LEFT:
					if(lc==KEY_LEFT)
					{
						xs+=0.3;
					}
					else
					{
						xs=1.0;
					}
					if(kmode)
					{
						if(xxp>0)
						{
							changed=1;
							xxp-=xs;
						}
					}
					else
					{
						if(xxw>6)
						{
							changed=1;
							xxw-=xs;
						}
					}
					move=1;
					break;
				
					case KEY_RIGHT:
					if((xxp+xxw)<(fix_screeninfo.line_length-1))
					{
						changed=1;
						if(lc==KEY_RIGHT)
						{
							xs+=0.3;
						}
						else
						{
							xs=1.0;
						}
						if(kmode)
						{
							xxp+=xs;
						}
						else
						{
							xxw+=xs;
						}
					}
					move=1;
					break;
				
					case KEY_UP:
					if(lc==KEY_UP)
					{
						ys+=0.2;
					}
					else
					{
						ys=1.0;
					}
					if(kmode)
					{
						if(yyp>0)
						{
							changed=1;
							yyp-=ys;
						}
					}
					else
					{
						if(yyw>6)
						{
							changed=1;
							yyw-=ys;
						}
					}
					move=1;
					break;
				
					case KEY_DOWN:
					if((yyp+yyw)<(var_screeninfo.yres-1))
					{
						changed=1;
						if(lc==KEY_DOWN)
						{
							ys+=0.2;
						}
						else
						{
							ys=1.0;
						}
						if(kmode)
						{
							yyp+=ys;
						}
						else
						{
							yyw+=ys;
						}
					}
					move=1;
					break;
				
					case KEY_RED:
						changed=1;
						RenderBox(xxp, yyp, xxp+xxw, yyp+yyw, FILL, make_color(TRANSP,&tp));
						for(i=0;i<=yyw;i++)
						{
							j=(yyp+i)*fix_screeninfo.line_length+(xxp<<2);
							if(((j+(xxw<<2)))<fix_screeninfo.line_length*var_screeninfo.yres)
							{
								memcpy(lfb+j, lbb+j, xxw<<2);
							}
						}
						valid[amsk]=0;
						nmsk--;
						kmode=1;
						if(nmsk)
						{
							todo=2;
							amsk=-1;
							for(m=0; m<MAX_MASK && amsk<0; m++)
							{
								if(valid[m])
								{
									amsk=m;
									xxp=xp[amsk][pmode];
									xxw=xw[amsk][pmode];
									yyp=yp[amsk][pmode];
									yyw=yw[amsk][pmode];
									lpix.lpixel=mc[amsk].lpixel;
								}
							}	
						}
						else
						{
							todo=mask=0;
						}
					break;
				
					case KEY_GREEN:
						if(nmsk<MAX_MASK)
						{
							todo=2;
							changed=1;
							kmode=1;
							amsk=-1;
							for(m=0; amsk<0 && m<MAX_MASK; m++)
							{
								if(!valid[m])
								{
									amsk=m;
									valid[amsk]=1;
									nmsk++;
									cmc[amsk]=BLACK;
									make_color(BLACK, &mc[amsk]);
									for(i=0; i<8; i++)
									{
										xp[amsk][i]=(1280-40)/2;
										xw[amsk][i]=40;
										yp[amsk][i]=(720-20)/2;
										yw[amsk][i]=20;
									}
									xxp=xp[amsk][pmode];
									xxw=xw[amsk][pmode];
									yyp=yp[amsk][pmode];
									yyw=yw[amsk][pmode];
									lpix.lpixel=mc[amsk].lpixel;
								}
							}
						}	
					break;
					
					case KEY_PAGEUP:
						if(nmsk>1)
						{
							m=amsk+1;
							if(m>=MAX_MASK)
							{
								m=0;
							}
							while(!valid[m])
							{
								if(++m>=MAX_MASK)
								{
									m=0;
								}
							}
							RenderBox(xxp, yyp, xxp+xxw, yyp+yyw, FILL, &lpix);
							amsk=m;
							xxp=xp[amsk][pmode];
							xxw=xw[amsk][pmode];
							yyp=yp[amsk][pmode];
							yyw=yw[amsk][pmode];
							lpix.lpixel=mc[amsk].lpixel;
						}
					break;
				
					case KEY_PAGEDOWN:
						if(nmsk>1)
						{
							m=amsk-1;
							if(m<0)
							{
								m=MAX_MASK-1;
							}
							while(!valid[m])
							{
								if(--m<0)
								{
									m=MAX_MASK;
								}
							}
							RenderBox(xxp, yyp, xxp+xxw, yyp+yyw, FILL, &lpix);
							amsk=m;
							xxp=xp[amsk][pmode];
							xxw=xw[amsk][pmode];
							yyp=yp[amsk][pmode];
							yyw=yw[amsk][pmode];
							lpix.lpixel=mc[amsk].lpixel;
						}
					break;

					case KEY_YELLOW:
						kmode=0;
					break;
				
					case KEY_BLUE:
						kmode=1;
					break;
					
					case KEY_1:
						if(nmsk)
						{
							if(mc[amsk].cpixel.rd < 0xF0)
								mc[amsk].cpixel.rd+=0x10;
							else
								mc[amsk].cpixel.rd=0xFF;
							changed=1;
						}
					break;

					case KEY_4:
						if(nmsk)
						{
							mc[amsk].cpixel.rd=0x80;
							changed=1;
						}
					break;

					case KEY_7:
						if(nmsk)
						{
							if(mc[amsk].cpixel.rd > 0x0F)
								mc[amsk].cpixel.rd-=0x10;
							else
								mc[amsk].cpixel.rd=0x00;
							changed=1;
						}
					break;

					case KEY_2:
						if(nmsk)
						{
							if(mc[amsk].cpixel.gn < 0xF0)
								mc[amsk].cpixel.gn+=0x10;
							else
								mc[amsk].cpixel.gn=0xFF;
							changed=1;
						}
					break;

					case KEY_5:
						if(nmsk)
						{
							mc[amsk].cpixel.gn=0x80;
							changed=1;
						}
					break;

					case KEY_8:
						if(nmsk)
						{
							if(mc[amsk].cpixel.gn > 0x0F)
								mc[amsk].cpixel.gn-=0x10;
							else
								mc[amsk].cpixel.gn=0x00;
							changed=1;
						}
					break;

					case KEY_3:
						if(nmsk)
						{
							if(mc[amsk].cpixel.bl < 0xF0)
								mc[amsk].cpixel.bl+=0x10;
							else
								mc[amsk].cpixel.bl=0xFF;
							changed=1;
						}
					break;

					case KEY_6:
						if(nmsk)
						{
							mc[amsk].cpixel.bl=0x80;
							changed=1;
						}
					break;

					case KEY_9:
						if(nmsk)
						{
							if(mc[amsk].cpixel.bl > 0x0F)
								mc[amsk].cpixel.bl-=0x10;
							else
								mc[amsk].cpixel.bl=0x00;
							changed=1;
						}
					break;

					case KEY_VOLUMEDOWN:
						if(nmsk)
						{
							if(mc[amsk].cpixel.tr < 0xF8)
								mc[amsk].cpixel.tr+=0x08;
							else
								mc[amsk].cpixel.tr=0xFF;
							changed=1;
						}
					break;

					case KEY_VOLUMEUP:
						if(nmsk)
						{
							if(mc[amsk].cpixel.tr > 0x08)
								mc[amsk].cpixel.tr-=0x08;
							else
								mc[amsk].cpixel.tr=0x00;
							changed=1;
						}
					break;

					case KEY_MUTE:
						if(nmsk)
						{
							if(++cmc[amsk]>LTURQUOISE)
								cmc[amsk]=BLACK;
							make_color(cmc[amsk], &mc[amsk]);
							changed=1;
						}
					break;

					case KEY_HELP:
						help_changed=1;
					break;
				}
				lc=rc;
				lpix.lpixel=mc[amsk].lpixel;
				if(mask || todo==2)
				{
					RenderBox(xp[amsk][pmode], yp[amsk][pmode], xp[amsk][pmode]+xw[amsk][pmode], yp[amsk][pmode]+yw[amsk][pmode], FILL, make_color(TRANSP, &tp));
					for(i=0;i<=yw[amsk][pmode];i++)
					{
						j=(yp[amsk][pmode]+i)*fix_screeninfo.line_length+(xp[amsk][pmode]<<2);
						if((j+(xw[amsk][pmode]<<2))<fix_screeninfo.line_length*var_screeninfo.yres)
						{
							memcpy(lfb+j, lbb+j, (xw[amsk][pmode]+1)<<2);
						}
					}
					xp[amsk][pmode]=xxp;
					xw[amsk][pmode]=xxw;
					yp[amsk][pmode]=yyp;
					yw[amsk][pmode]=yyw;
					for(m=0; mask && m<MAX_MASK; m++)
					{
						if(valid[m])
						{
							xxp=xp[m][pmode];
							xxw=xw[m][pmode];
							yyp=yp[m][pmode];
							yyw=yw[m][pmode];
							tp.lpixel=mc[m].lpixel;
							RenderBox(xxp, yyp, xxp+xxw, yyp+yyw, FILL, ((m==amsk) && move)?make_color(TRANSP, &tp):&tp);
							if(m==amsk)
								RenderBox(xxp, yyp, xxp+xxw, yyp+yyw, GRID, make_color((kmode)?LBLUE:LYELLOW,&tp));
							for(i=0;i<=yyw;i++)
							{
								j=(yyp+i)*fix_screeninfo.line_length+(xxp<<2);
								if((j+(xxw<<2))<fix_screeninfo.line_length*var_screeninfo.yres)
								{
									memcpy(lfb+j, lbb+j, (xxw+1)<<2);
								}
							}
						}
					}
				}
			}
			time(&t2);
			if((t2-t1)>1)
			{
				xs=1.0;
				ys=1.0;
				tsy=120;
				if(move)
				{
					RenderBox(xp[amsk][pmode], yp[amsk][pmode], xp[amsk][pmode]+xw[amsk][pmode], yp[amsk][pmode]+yw[amsk][pmode], FILL, &mc[amsk]);
					RenderBox(xp[amsk][pmode], yp[amsk][pmode], xp[amsk][pmode]+xw[amsk][pmode], yp[amsk][pmode]+yw[amsk][pmode], GRID, make_color((kmode)?LBLUE:LYELLOW,&tp));
				}
				move=0;
				if(help_changed)
				{
					help^=1;
				}
				if(help)
				{
					RenderBox(tsx,tsy,tsx+txw,tsy+21*tdy,FILL,make_color(TRANSP, &tp));
					if(nmsk)
						RenderBox(xp[amsk][pmode], yp[amsk][pmode], xp[amsk][pmode]+xw[amsk][pmode], yp[amsk][pmode]+yw[amsk][pmode], GRID, make_color((kmode)?LBLUE:LYELLOW, &tp));
					RenderString("Maskensteuerung", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
					RenderString("Blau  :  Umschalten auf Positionseinstellung", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
					RenderString("Gelb  :  Umschalten auf Größeneinstellung", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
					RenderString("Grün  :  Maske hinzufügen", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
					RenderString("Rot    :  Maske löschen", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
					RenderString("PgUp :  nächste Maske auswählen", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
					RenderString("PgDn :  vorherige Maske auswählen", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
					RenderString("Maskenfarbe", tsx, tsy+=(2*tdy), txw, LEFT, tsz, tcol);
					RenderString("Mute  :  Maskenfarbe aus Vorgabe auswählen", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
					RenderString("1,4,7   :  Farbton Rot erhöhen, auf Mitte setzen, verringern", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
					RenderString("2,5,8  :  Farbton Grün erhöhen, auf Mitte setzen, verringern", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
					RenderString("3,6,9  :  Farbton Blau erhöhen, auf Mitte setzen, verringern", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
					RenderString("Vol +  :  Transparenz erhöhen", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
					RenderString("Vol -  :  Transparenz verringern", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
					RenderString("Allgemein", tsx, tsy+=(2*tdy), txw, LEFT, tsz, tcol);
					RenderString("?        :  Hilfetext ein/ausschalten", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
					RenderString("Exit    :  Abbrechen", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
					RenderString("OK     :  Speichern und Beenden", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
				}
				else
				{
					if(help_changed)
					{
						RenderBox(tsx, tsy, tsx+txw, tsy+21*tdy, FILL, make_color(TRANSP, &tp));
						if(nmsk)
							RenderBox(xp[amsk][pmode], yp[amsk][pmode], xp[amsk][pmode]+xw[amsk][pmode], yp[amsk][pmode]+yw[amsk][pmode], GRID, make_color((kmode)?LBLUE:LYELLOW, &tp));
					}
				}
				help_changed=0;
				memcpy(lfb, lbb, fix_screeninfo.line_length*var_screeninfo.yres);
			}
		}
		if(rc==KEY_EXIT)
		{
			changed=0;
			todo=0;
		}
		if(rc==KEY_OK && changed)
		{
			if((fh2=fopen("/tmp/logomask.conf","w"))!=NULL)
			{
				fh=fopen(CFG_FILE,"r");
				while(fh && fgets(tstr, BUFSIZE, fh))
				{
					TrimString(tstr);
					if(strlen(tstr))
					{
						if(strstr(tstr,actchan)==NULL)
						{
							fprintf(fh2,"%s\n",tstr);
						}
					}
				}
				if(fh)
				{
					fclose(fh);
				}
				if(todo)
				{
					fprintf(fh2,"%s",actchan);
					for(j=0; j<MAX_MASK; j++)
					{
						if(valid[j])
						{
							for(i=0; i<8; i++)
							{
								fprintf(fh2,",%d,%d,%d,%d",xp[j][i],xw[j][i],yp[j][i],yw[j][i]);
							}
						}
					}
					for(j=0; j<MAX_MASK; j++)
					{
						if(valid[j])
						{
							fprintf(fh2,",MC%08X",mc[j].lpixel);
						}
					}
					fprintf(fh2,",\n");
				}
				fclose(fh2);
				remove(CFG_FILE);
				system("mv /tmp/logomask.conf /var/tuxbox/config/logomask.conf");
			}
		}		
		free(lbb);
		munmap(lfb, fix_screeninfo.smem_len);

		close(fb);
		CloseRC();
		remove("/tmp/.logomask_kill");
		remove("/tmp/logomaskset.*");
		system("logomask &");
		return 0;
}
int main (int argc, char **argv)
{
	int i,j,m,cmc=BLACK,transp=TRANSP,found,loop=1,mask=0,test=0,pmode=0,lmode=0,mchanged=1,cchanged=2,mwait;
	unsigned char lastchan[20]="", actchan[20]=""/*,channel[128]=""*/;
	int xp[MAX_MASK][8],yp[MAX_MASK][8],xw[MAX_MASK][8],yw[MAX_MASK][8],valid[MAX_MASK],xxp,xxw,yyp,yyw,nmsk=0;
	FILE *fh;
	char *cpt1,*cpt2,mc[MAX_MASK];
	
		if(argc==2 && strstr(argv[1],"test")!=NULL)
		{
			test=1;
		}
		printf("logomask Version %s\n",CL_VERSION);
		if((mwait=Read_Neutrino_Cfg("timing.infobar"))<0)
			mwait=6;
		
		mwait-=1;	

		fb = open(FB_DEVICE, O_RDWR);

		if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1)
		{
			printf("logomask <FBIOGET_FSCREENINFO failed>\n");
			return -1;
		}
		if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1)
		{
			printf("logomask <FBIOGET_VSCREENINFO failed>\n");
			return -1;
		}
		
		if(!(lfb = (unsigned char*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0)))
		{
			printf("logomask <mapping of Framebuffer failed>\n");
			return -1;
		}

	//init backbuffer

		if(!(lbb = malloc(var_screeninfo.xres*var_screeninfo.yres)))
		{
			printf("logomask <allocating of Backbuffer failed>\n");
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		memset(lbb, 0, var_screeninfo.xres*var_screeninfo.yres);
//		memset(mc, BLACK, sizeof(mc));
		startx = sx;
		starty = sy;


	// if problem with config file return from plugin

		while(loop)
		{
			sleep(1);
			system("saa -w > /tmp/logomaskset.stat");
			if((fh=fopen("/tmp/logomaskset.stat","r"))!=NULL)
			{
				if(fgets(tstr,500,fh))
				{
					TrimString(tstr);
					if(strlen(tstr))
					{
						lmode=pmode;
						if(sscanf(tstr+strlen(tstr)-1,"%d",&i)!=1)
						{
							pmode=0;
						}
						else
						{
							mchanged=(pmode!=i);
							pmode=i;
						}
					}
				}
				fclose(fh);
			}
			system("wget -q -Y off -O /tmp/logomask.chan http://localhost/control/zapto");
			if((fh=fopen("/tmp/logomask.chan","r"))!=NULL)
			{
				if(fgets(tstr, 4095, fh))
				{
					TrimString(tstr);
				}
				fclose(fh);
				if(strlen(tstr))
				{
					strcpy(actchan,tstr);
					cchanged=(cchanged==2)?3:((strcmp(actchan,lastchan)?1:0));
					if(mchanged || cchanged)
					{
						found=0;
						if(cchanged)
						{
							if(cchanged==1)
							{
								sleep(mwait);
							}
							cchanged=1;
						}
						if(mask)
						{
							for(m=0; m<nmsk; m++)
							{
								if(valid[m])
								{
									xxp=xp[m][lmode];
									xxw=xw[m][lmode];				
									yyp=yp[m][lmode];
									yyw=yw[m][lmode];
									cmc=mc[m];
									RenderBox(xxp, yyp, xxp+xxw, yyp+yyw, FILL, transp);
									for(i=0;i<=yyw;i++)
									{
										j=(yyp+i)*var_screeninfo.xres+xxp;
										if((j+xxw)<var_screeninfo.xres*var_screeninfo.yres)
										{
											memcpy(lfb+j, lbb+j, xxw);
										}
									}
								}
							}
						}
						mask=0;
						
					if((fh=fopen(CFG_FILE,"r"))!=NULL)
					{
						strcpy(lastchan,actchan);
						found=0;
						while(fgets(tstr, 4095, fh) && !found)
						{
							TrimString(tstr);
							if(strlen(tstr))
							{
								if(strstr(tstr,actchan)!=NULL)
								{
									mask=1;
									nmsk=0;
									cpt2=strstr(tstr,",MC");
									if((cpt1=strchr(tstr,','))!=NULL)
									{
										while(cpt1)
										{
											valid[nmsk]=0;
											if(cpt2 && sscanf(cpt2+1,"MC%d",&m)==1)
											{
												cmc=m;
												cpt2=strchr(cpt2+1,',');
											}
											else
											{
												cmc=BLACK;
											}
											for(i=0; i<8 && cpt1; i++)
											{
												cpt1++;
												if(sscanf(cpt1,"%d,%d,%d,%d",&xxp,&xxw,&yyp,&yyw)==4)
												{
													xp[nmsk][i]=xxp;
													xw[nmsk][i]=xxw;
													yp[nmsk][i]=yyp;
													yw[nmsk][i]=yyw;
													mc[nmsk]=cmc;
													found=1;
													valid[nmsk]=1;
												}
												for(j=0; j<4 && cpt1; j++)
												{
													cpt1=strchr(cpt1+1,',');
												}
											}
											if(valid[nmsk])
											{
												nmsk++;
											}
										}
									}
								}
							}
						}
						fclose(fh);
					}
				}
			}
			if(mask)
			{
				for(m=0; m<nmsk; m++)
				{
					if(valid[m])
					{
						xxp=xp[m][pmode];
						xxw=xw[m][pmode];				
						yyp=yp[m][pmode];
						yyw=yw[m][pmode];
						cmc=mc[m];
						RenderBox(xxp, yyp, xxp+xxw, yyp+yyw, (test)?GRID:FILL, cmc);
						for(i=0;i<=yyw;i++)
						{
							j=(yyp+i)*var_screeninfo.xres+xxp;
							if((j+xxw)<var_screeninfo.xres*var_screeninfo.yres)
							{
								memcpy(lfb+j, lbb+j, xxw);
							}
						}
					}
				}
			}
			if(++loop>5)
			{
				if(access("/tmp/.logomask_kill",0)!=-1)
				{
					loop=0;
				}
			}	
		}
	}

	for(m=0; m<nmsk; m++)
	{
		if(valid[m])
		{
			xxp=xp[m][pmode];
			xxw=xw[m][pmode];				
			yyp=yp[m][pmode];
			yyw=yw[m][pmode];
			cmc=mc[m];
			RenderBox(xxp, yyp, xxp+xxw, yyp+yyw, FILL, transp);
			for(i=0;i<=yyw;i++)
			{
				j=(yyp+i)*var_screeninfo.xres+xxp;
				if((j+xxw)<var_screeninfo.xres*var_screeninfo.yres)
				{
					memcpy(lfb+j, lbb+j, xxw);
				}
			}
		}
	}

	free(lbb);
	munmap(lfb, fix_screeninfo.smem_len);
	close(fb);
	remove("/tmp/.logomask_kill");
	remove("/tmp/logomask.*");
	return 0;
}
Ejemplo n.º 15
0
void CIATestMainWindow::OnDraw(IGenericRender *piRender)
{
	if(!m_FrameManager.m_piFrameManager)
	{
		return;
	}

	m_FrameManager.m_piFrameManager->ProcessFrame();
	double dTimeFraction=m_FrameManager.m_piFrameManager->GetTimeFraction();
	double dRealTimeFraction=m_FrameManager.m_piFrameManager->GetRealTimeFraction();

	if(m_bPauseOnNextFrame)
	{
		m_FrameManager.m_piFrameManager->SetPauseOnNextFrame(true);
		m_bPauseOnNextFrame=false;
	}

	ProcessInput(dTimeFraction,dRealTimeFraction);

	if(m_FrameManager.m_piFrameManager->GetTimeFraction()>0)
	{
		ProcessPhysics(dTimeFraction);
		ProcessIA(dTimeFraction);
	}

	double dAspectRatio=m_rRealRect.h/m_rRealRect.w;
	double dNearPlane=0,dFarPlane=0;
	double dViewAngle=m_Camera.m_piCamera->GetViewAngle();
	CVector vAngles,vPosition;

	m_Camera.m_piCamera->SetAspectRatio(dAspectRatio);
	m_Camera.m_piCamera->GetClippingPlanes(dNearPlane,dFarPlane);
	vAngles=m_Camera.m_piCamera->GetAngles();
	vPosition=m_Camera.m_piCamera->GetPosition();


	piRender->SetPerspectiveProjection(dViewAngle,dNearPlane,100000);
	piRender->SetCamera(vPosition,vAngles.c[YAW],vAngles.c[PITCH],vAngles.c[ROLL]);

	glGetDoublev(GL_MODELVIEW_MATRIX,(double*)m_pdModelMatrix);
	glGetDoublev(GL_PROJECTION_MATRIX,(double*)m_pdProjectionMatrix);
	glGetIntegerv(GL_VIEWPORT,m_pnViewport);

	RenderBox(CVector(0,0,-dBaseThickness),CVector(dBaseSize,dBaseSize,0),CVector(0.3,0.3,0.3));
	RenderAxises();

	char A[200];
	sprintf(A,"Fps: %.02f",m_FrameManager.m_piFrameManager->GetCurrentFps());
	m_piSTFps->SetText(A);

	sprintf(A,"Time: %.02f",((double)m_FrameManager.m_piFrameManager->GetCurrentTime())/1000.0);
	if(m_FrameManager.m_piFrameManager->IsPaused())
	{
		strcat(A," (Paused)");
	}
	m_piSTTime->SetText(A);

	CVector entityPos=m_pSelectedEntity?m_pSelectedEntity->GetPosition():CVector(0,0,0);
	sprintf(A,"Pos: %.02f , %.02f , %.02f",entityPos.c[0],entityPos.c[1],entityPos.c[2]);
	m_piSTEntityPos->SetText(A);

	CVector entityVel=m_pSelectedEntity?m_pSelectedEntity->GetVelocity():CVector(0,0,0);
	sprintf(A,"Vel: %.02f , %.02f , %.02f - %.02f/%.02f ",entityVel.c[0],entityVel.c[1],entityVel.c[2],(double)entityVel,m_pSelectedEntity?m_pSelectedEntity->GetMaxVelocity():0);
	m_piSTEntityVel->SetText(A);

	map<string,CIAEntityBase *>::iterator i;
	for(i=m_mEntities.begin();i!=m_mEntities.end();i++)
	{
		i->second->Render();
	}
}
static void ShowInfo(MENU *m, int knew )
{
	int icon_w=0, icon_h=0, xsize=0, ysize=0;
	int loop, dloop, ldy, stlen;
	double scrollbar_len, scrollbar_ofs, scrollbar_cor;
	int index=m->act_entry,tind=m->act_entry;
	int sbw=(m->num_entrys>MAX_FUNCS)?scale2res(15):0; // scrollbar width
	int sbo=OFFSET_MIN; // inner scrollbar offset
	char tstr[BUFSIZE]={0}, *tptr;
	char dstr[BUFSIZE]={0}, *lcptr,*lcstr;
	int dy, my, moffs, mh, toffs, soffs=OFFSET_SMALL/*4*/, oldx=startx, oldy=starty, sbar=0, nosel;
	PLISTENTRY pl;

	moffs=iyw/(MAX_FUNCS+1)+OFFSET_SMALL;
	mh=iyw-moffs;
	dy=mh/(MAX_FUNCS+1);
	toffs=dy/2;
	my=moffs+toffs+dy;

	startx = sx + (((ex-sx) - ixw)/2);
	starty = sy + (((ey-sy) - iyw)/2);

	tind=index;

	//frame layout
	RenderBox(OFFSET_SMALL/*6*/, OFFSET_SMALL, ixw+OFFSET_SMALL, iyw+OFFSET_SMALL, radius, COL_SHADOW_PLUS_0);
	RenderBox(0, 0, ixw, iyw, radius, CMC);

	// titlebar
	RenderBox(0, 0, ixw, moffs, radius, CMH);

	for(loop=MAX_FUNCS*(index/MAX_FUNCS); loop<MAX_FUNCS*(index/MAX_FUNCS+1) && loop<m->num_entrys && !sbar; loop++)
	{
		pl=m->list[loop];
		sbar |= ((pl->type!=TYP_COMMENT) && (pl->type!=TYP_INACTIVE));
	}
	--loop;
	if(loop>index)
	{
		m->act_entry=index=loop;
	}

	if(sbw)
	{
		//sliderframe
		RenderBox(ixw-sbw, moffs, ixw, iyw, radius, COL_MENUCONTENT_PLUS_1);
		//slider
		scrollbar_len = (double)mh / (double)((m->num_entrys/MAX_FUNCS+1)*MAX_FUNCS);
		scrollbar_ofs = scrollbar_len*(double)((index/MAX_FUNCS)*MAX_FUNCS);
		scrollbar_cor = scrollbar_len*(double)MAX_FUNCS;
		RenderBox(ixw-sbw + sbo, moffs + scrollbar_ofs + sbo, ixw - sbo, moffs + scrollbar_ofs + scrollbar_cor - sbo, radius, COL_MENUCONTENT_PLUS_3);
	}
	int iw,ih;
	int offset, hoffs = (m->headermed[m->act_header]==1)?0:scale2res(48);
	int ioffs = xoffs+8; // + half standard icon
	if(m->icon[m->act_header])
	{
		png_getsize(m->icon[m->act_header], &icon_w, &icon_h);
		// limit icon size
		if(icon_w > 150 || icon_h > 36) {
			icon_w = xsize = 150;
			icon_h = ysize = 36;
		}
		if (icon_w > 32) {
			offset = ioffs-16;
		}
		else
			offset = ioffs-icon_w/2;
		paintIcon(m->icon[m->act_header], offset, (moffs-icon_h)/2+1, xsize, ysize, &iw, &ih);
	}

	// Title text
	if (icon_w > 32) {
		hoffs  = offset+iw+8;
	}
	lcstr=strdup(m->headertxt[m->act_header]);
	clean_string(m->headertxt[m->act_header],lcstr);
	RenderString(lcstr, hoffs, moffs-(moffs-FSIZE_BIG)/2+2, ixw-sbw-hoffs, (m->headermed[m->act_header]==1)?CENTER:LEFT, FSIZE_BIG, CMHT);
	free(lcstr);

	index /= MAX_FUNCS;
	dloop=0;
	ldy=dy;
	//Show table of commands
	for(loop = index*MAX_FUNCS; (loop < (index+1)*MAX_FUNCS) && (loop < m->num_entrys); ++loop)
	{
		int clh=2; // comment line height
		dy=ldy;
		pl=m->list[loop];
		strcpy(dstr,pl->entry);
		if((tptr=strxchr(dstr,','))!=NULL)
		{
			if(pl->type != TYP_COMMENT)
			{
				*tptr=0;
			}
		}
		lcptr=tptr=dstr;
		while(*tptr)
		{
			if(*tptr==0x27)
			{
				memmove(tptr,tptr+1,strlen(tptr));
			}
			++tptr;
		}

		if(m->num_active && sbar && (loop==m->act_entry))
		{
			RenderBox(0, my+soffs-dy, ixw-sbw, my+soffs, radius, CMCS);
		}
		nosel=(pl->type==TYP_COMMENT) || (pl->type==TYP_INACTIVE);
		if(!(pl->type==TYP_COMMENT && pl->underline==2))
		{
			int font_type = MED;
			int font_size = FSIZE_MED;
			int coffs=0; // comment offset
			if (pl->type==TYP_COMMENT)
			{
				font_type = SMALL;
				font_size = FSIZE_SMALL;
				if (pl->underline==1)
				{
					coffs=clh;
				}
			}
			RenderString(dstr, scale2res(48), my+soffs-(dy-font_size)/2-coffs+2, ixw-sbw-scale2res(65), LEFT, font_type, (((loop%MAX_FUNCS) == (tind%MAX_FUNCS)) && (sbar) && (!nosel))?CMCST:(nosel)?CMCIT:CMCT);
		}
		if(pl->type==TYP_MENU)
		{
			RenderString(">", scale2res(30), my+soffs-(dy-FSIZE_MED)/2+OFFSET_MIN, scale2res(65), LEFT, MED, (((loop%MAX_FUNCS) == (tind%MAX_FUNCS)) && (sbar) && (!nosel))?CMCST:CMCT);
		}
		if(pl->underline)
		{
			int cloffs=0,ccenter=0;
			if(pl->type==TYP_COMMENT)
			{
				if(strlen(dstr)==0)
				{
					cloffs=dy/2;
					if(pl->underline==2)
					{
						dy/=2; // FIXME: these substraction causes space at bottom of painted box
						cloffs+=dy/2;
					}
				}
				else
				{
					if(pl->underline==2)
					{
						cloffs=dy/2;
						ccenter=1;
					}
				}
			}
			else
			{
				if(pl->underline==2)
				{
					dy+=dy/2; // FIXME: these addition causes text outside painted box
					cloffs=-dy/4;
				}
			}
			RenderBox(xoffs, my+soffs-cloffs-clh, ixw-xoffs-sbw, my+soffs-cloffs, 0, COL_MENUCONTENT_PLUS_3);
			if(ccenter)
			{
				stlen=GetStringLen(xoffs, dstr, MED);
				RenderBox(xoffs+(ixw-xoffs-sbw)/2-stlen/2, my+soffs-ldy, xoffs+(ixw-xoffs-sbw)/2+stlen/2+3*OFFSET_SMALL, my+soffs, FILL, CMC);
				RenderString(dstr, xoffs, my+soffs-(dy-FSIZE_MED)/2, ixw-sbw, CENTER, MED, CMCIT);
			}
		}
		if((pl->type!=TYP_COMMENT) && ((pl->type!=TYP_INACTIVE) || (pl->showalways==2)))
		{
			icon_w = icon_h = 0;
			png_getsize(ICON_BUTTON_RED, &icon_w, &icon_h);
			direct[dloop++]=(pl->type!=TYP_INACTIVE)?loop:-1;
			switch(dloop)
			{
				case 1: paintIcon(ICON_BUTTON_RED,    ioffs-icon_w/2, my+soffs-(dy+icon_h)/2, 0, 0, &iw, &ih); break;
				case 2: paintIcon(ICON_BUTTON_GREEN,  ioffs-icon_w/2, my+soffs-(dy+icon_h)/2, 0, 0, &iw, &ih); break;
				case 3: paintIcon(ICON_BUTTON_YELLOW, ioffs-icon_w/2, my+soffs-(dy+icon_h)/2, 0, 0, &iw, &ih); break;
				case 4: paintIcon(ICON_BUTTON_BLUE,   ioffs-icon_w/2, my+soffs-(dy+icon_h)/2, 0, 0, &iw, &ih); break;
				default:
					if(dloop<15)
					{
						sprintf(tstr,"%1d",(dloop-4)%10);
						RenderString(tstr, xoffs, my+soffs-(dy-FSIZE_SMALL)/2+2, 3*OFFSET_SMALL, CENTER, SMALL, ((loop%MAX_FUNCS) == (tind%MAX_FUNCS))?CMCST:((pl->type==TYP_INACTIVE)?CMCIT:CMCT));
					}
				break;
			}
		}
		my += dy;
	}
	dy=ldy;
	for(; dloop<MAX_FUNCS; dloop++)
	{
		direct[dloop]=-1;
	}

	//copy backbuffer to framebuffer
#ifdef MARTII
	blit();
#else
	memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t));
#endif

	if(m->num_active && knew)
		{
			if(m->list[m->act_entry]->entry)
			{
				sprintf(trstr,"%s%s",(m->list[m->act_entry]->type<=TYP_MENUSOFF)?"> ":"",m->list[m->act_entry]->entry);
				if((lcptr=strxchr(trstr,','))!=NULL)
				{
					*lcptr=0;
				}
			}
			else
			{
				sprintf(trstr,"Kein Eintrag");
			}

			if(vfd)
			{
				lcstr=strdup(trstr);
				clean_string(trstr,lcstr);
				sprintf(tstr,"%s -t\"%s\"",VFD,lcstr);
				system(tstr);
				free(lcstr);
			}
		}

	startx=oldx;
	starty=oldy;
}
Ejemplo n.º 17
0
void RenderNoteAnchor (FloatNote * psNote, NotesPersist * psNotesData) {
	// Render the note to the screen
	float fFade;
	GLuint uTexture;
	GLfloat afVertices[6];
	Vector3 vsBoxTopLeft;
	Vector3 vsBoxBottomRight;

	if (psNote->szText->len > 0) {
		// Draw a transparent rectangle on the screen
		fFade = (1.0f - ((psNote->vsAnchor.fZ - psNotesData->fFocusFar + NOTE_FOCUSSHIFT) * NOTE_FOCUSFADE));
		if (psNote == psNotesData->psSelectedNote) {
			fFade = (1.0f / NOTE_BACKFADEMAX);
		}
		if ((fFade > 0.0f) && (fFade < 50.0f)) {
			if ((fFade > 1.0f) && (psNote != psNotesData->psSelectedNote)) {
				fFade = 1.0f;
			}
			glColor4f (1.0, 1.0, 1.0, fFade * NOTE_BACKFADEMAX);

			// Set the z position of the note
		  glDepthRange (psNote->vsAnchor.fZ, psNote->vsAnchor.fZ);

			// Render the floating note
			uTexture = GetTexture (TEXNAME_NOTES, NULL, psNotesData->psTexData);
			glBindTexture (GL_TEXTURE_2D, uTexture);
			glEnable (GL_TEXTURE_2D);
		  glEnableClientState (GL_TEXTURE_COORD_ARRAY);

			vsBoxTopLeft.fX = psNote->vsAnchor.fX + psNote->fMarginExternal + NOTE_XSHIFT;
			vsBoxTopLeft.fY = psNote->vsAnchor.fY + psNote->fMarginExternal + NOTE_YSHIFT;
			vsBoxTopLeft.fZ = psNote->vsAnchor.fZ;
			vsBoxBottomRight.fX = psNote->vsAnchor.fX + psNote->vsSize.fX - psNote->fMarginExternal + NOTE_XSHIFT;
			vsBoxBottomRight.fY = psNote->vsAnchor.fY + psNote->vsSize.fY - psNote->fMarginExternal + NOTE_YSHIFT;
			vsBoxBottomRight.fZ = psNote->vsAnchor.fZ;
			RenderBox (& vsBoxTopLeft, & vsBoxBottomRight, NOTE_BORDERWIDTH, uTexture);

			afVertices[0]  = psNote->vsAnchor.fX;
			afVertices[1]  = psNote->vsAnchor.fY;
			afVertices[2]  = NOTE_LAYER_ZPOS;
			afVertices[3]  = psNote->vsAnchor.fX + psNote->fMarginExternal + NOTE_XSHIFT;
			afVertices[4]  = psNote->vsAnchor.fY + psNote->fMarginExternal + NOTE_YSHIFT;
			afVertices[5]  = NOTE_LAYER_ZPOS;

			glDisable (GL_TEXTURE_2D);
		  glDisableClientState (GL_TEXTURE_COORD_ARRAY);
			glColor4f (0.5, 0.5, 1.0, fFade * NOTE_BACKFADEMAX);
			glVertexPointer (3, GL_FLOAT, 0, afVertices);
			glDrawArrays (GL_LINE_STRIP, 0, 2);

			if (psNotesData->boInverted) {
				glColor4f (0.0, 0.0, 0.0, fFade * NOTE_TEXTFADEMAX);
			}
			else {
				glColor4f (1.0, 1.0, 1.0, fFade * NOTE_TEXTFADEMAX);
			}
		  glDepthRange (0.0, 1.0);

			RenderBitmapString (psNote->vsAnchor.fX + psNote->fMarginInternal + psNote->fMarginExternal + NOTE_XSHIFT, psNote->vsAnchor.fY + psNote->vsSize.fY - psNote->fMarginExternal - psNote->fMarginInternal + NOTE_YSHIFT - NOTETEXT_LINEHEIGHT + 2.0f, psNote->vsAnchor.fZ, NOTETEXT_FONT, psNote->szText->str);
		}
	}
}
Ejemplo n.º 18
0
void RenderBox( float _fWidth, float _fHeight, float _fDepth )
{
    TSRVector3 Extents( _fWidth, _fHeight, _fDepth );
    RenderBox( Extents );
}
Ejemplo n.º 19
0
int show_txt(int buttonly)
{
    FILE *tfh;
    int i,bx,by,x1,y1,rv=-1,run=1,line=0,action=1,cut,itmp,btns=buttons,lbtns=(buttons>bpline)?bpline:buttons,blines=1+((btns-1)/lbtns);


    if(hide)
    {
        memcpy(lfb, hbb, var_screeninfo.xres*var_screeninfo.yres);
        return 0;
    }
    yo=(header)?80:35;
    if(!buttonly)
    {
        memcpy(lbb, ibb, var_screeninfo.xres*var_screeninfo.yres);
    }
    if((tfh=fopen(TMP_FILE,"r"))!=NULL)
    {
        fclose(tfh);
        if(!buttonly)
        {
            if(type!=1)
            {
                btns=0;
                myo=0;
            }

            RenderString("X", 310, 270, 20, LEFT, BIG, TRANSP);
            pxw=GetStringLen(sx,title)+10;
            if(type==1)
            {
                RenderString("X", 310, 270, 20, LEFT, MED, TRANSP);
                myo=blines*(butty+buttdy);
                for(i=0; i<btns; i++)
                {
                    itmp=GetStringLen(sx,butmsg[i])+10;
                    if(itmp>buttx)
                    {
                        buttx=itmp;
                    }
                }
            }
            buttsize=buttx;

            RenderString("X", 310, 270, 20, LEFT, size, TRANSP);
            if(fh_txt_getsize(TMP_FILE, &x1, &y1, &cut))
            {
                printf("msgbox <invalid Text-Format>\n");
                return -1;
            }
            x1+=10;

            dy=0.8*(double)size;
            if(pxw<x1)
            {
                pxw=x1;
            }
            if(pxw<(lbtns*buttx+lbtns*buttdx))
            {
                pxw=(lbtns*buttx+lbtns*buttdx);
            }
            if(pxw>((ex-sx)-2*buttdx))
            {
                pxw=ex-sx-2*buttdx;
            }
            psx=((ex-sx)/2-pxw/2);
            pyw=y1*dy/*-myo*/;
            if(pyw>((ey-sy)-yo-myo))
            {
                pyw=((ey-sy)-yo-myo);
            }
            psy=/*sy+*/((ey-sy)/2-(pyw+myo-yo)/2);
            if(btns)
            {
                buttxstart=psx+pxw/2-(((double)lbtns*(double)buttsize+(((lbtns>2)&&(lbtns&1))?((double)buttdx):0.0))/2.0);
//				buttystart=psy+pyw/2-(((double)blines*(double)butty+(((blines>2)&&(blines&1))?((double)buttdy):0.0))/2.0);
                buttystart=psy+y1*dy;
            }
        }

        while(run)
        {
            //frame layout
            if(action)
            {
                if(!buttonly)
                {
                    RenderBox(psx-20, psy-yo, psx+pxw+20, psy+pyw+myo, radius, CMH);
                    RenderBox(psx-20+2, psy-yo+2, psx+pxw+20-2, psy+pyw+myo-2, radius, CMC);
                    if(header)
                    {
                        RenderBox(psx-18, psy-yo+2, psx+pxw+18, psy-yo+44, radius, CMH);
                        RenderString(title, psx, psy-yo+36, pxw, CENTER, BIG, CMHT);
                    }
                }
                if(buttonly || !(rv=fh_txt_load(TMP_FILE, psx, pxw, psy, dy, size, line, &cut)))
                {
                    if(type==1)
                    {
                        for(i=0; i<btns; i++)
                        {
                            bx=i%lbtns;
                            by=i/lbtns;
                            RenderBox(buttxstart+bx*(buttsize+buttdx/2), buttystart+by*(butty+buttdy/2), buttxstart+(bx+1)*buttsize+bx*(buttdx/2), buttystart+by*(butty+buttdy/2)+butty, radius, YELLOW);
                            RenderBox(buttxstart+bx*(buttsize+buttdx/2)+2, buttystart+by*(butty+buttdy/2)+2, buttxstart+(bx+1)*buttsize+bx*(buttdx/2)-2, buttystart+by*(butty+buttdy/2)+butty-2, radius, ((by*bpline+bx)==(selection-1))?CMCS:CMC);
                            RenderString(butmsg[i], buttxstart+bx*(buttsize+buttdx/2), buttystart+by*(butty+buttdy/2)+butty-7, buttsize, CENTER, MED, (i==(selection-1))?CMCST:CMCIT);
                        }

//						RenderBox((ex-sx)/2-buttx/2, psy+pyw+myo/2-butty/2, (ex-sx)/2+buttx/2, psy+pyw+myo/2+butty/2, FILL, CMCS);
//						RenderBox((ex-sx)/2-buttx/2, psy+pyw+myo/2-butty/2, (ex-sx)/2+buttx/2, psy+pyw+myo/2+butty/2, GRID, YELLOW);
//						RenderString("OK", (ex-sx)/2-buttx/2, psy+pyw+myo/2+butty/2-7, buttx, CENTER, MED, CMCST);
                    }
                    memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres);
                }
            }
            run=0;
        }
    }
    return (rv)?-1:0;
}
Ejemplo n.º 20
0
int fh_txt_trans(const char *name, int xs, int xw, int ys, int dy, int cs, int line, int *cut, int *x, int *y, int plot)
{
char tstr[BUFSIZE],rstr[BUFSIZE],*tptr;
int loop=1, j, slen, cnt=0;
FILE *fh;
int just, color=CMCT;

	if(!(fh=fopen(name,"rb")))	return(FH_ERROR_FILE);

//	first=(line==0);
	*x=0;
	*y=0;
	while((loop>0) && (fgets(tstr, sizeof(tstr), fh)))
	{
		j=0;
		just=LEFT;
		color=CMCT;
		
		tptr=tstr+strlen(tstr);
		while((tptr>=tstr) && (*tptr<=32))
		{
			*tptr=0;
			--tptr;
		}
		tptr=tstr;
		while(*tptr)
		{
			rstr[j++]=*tptr;
			cnt++;

			if(*tptr == '~')
			{
				switch (*(tptr+1))
				{
					case 'l': just=LEFT; break;
					case 'r': just=RIGHT; break;
					case 'c': just=CENTER; break;
					case 's': // vert. line
						RenderBox(xs, ys-cs/3, xs+xw, ys-cs/3+1, FILL, COL_MENUCONTENT_PLUS_3);
						RenderBox(xs, ys-cs/3+1, xs+xw, ys-cs/3+2, FILL, COL_MENUCONTENT_PLUS_1);
						break;
				}
			}
			tptr++;
		}
		if((loop>0) && (ys<(ey-dy)))
		{
			rstr[j]=0;
			if(plot)
			{
				if(loop>=line)
				{
					RenderString(rstr, xs, ys, xw, just, cs, color);
/*					if(strlen(rstr))
					{
						first=0;
					}
*/					ys+=dy;
				}
			}
			else
			{
				if(strlen(rstr))
				{
					slen=GetStringLen(xs,rstr)+10;
					if(slen>*x)
					{
						*x=slen;
					}
				}
				*y=*y+1;
			}
		}
	}
	if(plot)
	{
		*cut=(ys>=(ey-dy));
	}
	fclose(fh);
	return(FH_ERROR_OK);
}
Ejemplo n.º 21
0
Archivo: clock.c Proyecto: UkCvs/ukcvs
int main (int argc, char **argv)
{
	unsigned int margin_left_F, digit_width, margin_top_t, font_size, margin_top_box, margin_top_d, digits, secs_width, adj_height;
	int i = 0;
	int j = 0;
	int w = 0;
	int ms = 0;
	int mw = 0;
	int loop = 1;
	unsigned int newmail = 0;
	unsigned int mailgfx = 0;
	int xdir = 1, ydir = 1;
	double xstep = 1, ystep = 1; 
	double csx, cex, csy, cey;
	time_t atim;
	struct tm *ltim;
	char *aptr,*rptr;
	char dstr[2] = {0,0};
	FILE *tfh;

		printf("Clock / SSaver Version %s\n",CL_VERSION);

		for (i = 1; i < argc; i++)
		{
			if (!strncmp(argv[i], "-ss", 3))
			{
				ssaver = 1;
				continue;
			}
		}

		if (ssaver)
		{
			time(&atim);
			srand((unsigned int)atim);
			ReadConf(SCFG_FILE);
		}
		else
		{
			ReadConf(CCFG_FILE);
		}

		for (i = 1; i < argc; i++)
		{
			aptr=argv[i];
			if((rptr=strchr(aptr,'='))!=NULL)
			{
				rptr++;
				if (!ssaver)
				{
					if(strstr(aptr,"X=")!=NULL)
					{
						if(sscanf(rptr,"%d",&j)==1)
						{
							xpos=j;
						}
					}	
					if(strstr(aptr,"Y=")!=NULL)
					{
						if(sscanf(rptr,"%d",&j)==1)
						{
							ypos=j;
						}
					}
					if(strstr(aptr,"MAIL=")!=NULL)
					{
						if(sscanf(rptr,"%d",&j)==1)
						{
							mail=j;
						}
					}
				}
				if(strstr(aptr,"DATE=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						show_date=j;
					}
				}
				if(strstr(aptr,"BIG=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						big=(j)?1:0;
					}
				}
				if(strstr(aptr,"SEC=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						show_sec=j;
					}
				}
				if(strstr(aptr,"BLINK=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						blink=j;
					}
				}
				if(strstr(aptr,"SLOW=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						if(!j)
						{
							j=1;
						}
						slow=j;
					}
				}
				if(strstr(aptr,"FCOL=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						fcol=j;
					}
				}
				if(strstr(aptr,"BCOL=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						bcol=j;
					}
				}
			}
		}
		if((sx=Read_Neutrino_Cfg("screen_StartX"))<0)
			sx=80;
		
		if((ex=Read_Neutrino_Cfg("screen_EndX"))<0)
			ex=620;

		if((sy=Read_Neutrino_Cfg("screen_StartY"))<0)
			sy=80;

		if((ey=Read_Neutrino_Cfg("screen_EndY"))<0)
			ey=505;
		
		fb = open(FB_DEVICE, O_RDWR);

		if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1)
		{
			printf("Clock / SSaver <FBIOGET_FSCREENINFO failed>\n");
			return -1;
		}
		if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1)
		{
			printf("Clock / SSaver <FBIOGET_VSCREENINFO failed>\n");
			return -1;
		}
		if(!(lfb = (unsigned char*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0)))
		{
			printf("Clock / SSaver <mapping of Framebuffer failed>\n");
			return -1;
		}

	//init fontlibrary

		if((error = FT_Init_FreeType(&library)))
		{
			printf("Clock / SSaver <FT_Init_FreeType failed with Errorcode 0x%.2X>", error);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_Manager_New(library, 1, 2, 0, &MyFaceRequester, NULL, &manager)))
		{
			printf("Clock / SSaver <FTC_Manager_New failed with Errorcode 0x%.2X>\n", error);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_SBitCache_New(manager, &cache)))
		{
			printf("Clock / SSaver <FTC_SBitCache_New failed with Errorcode 0x%.2X>\n", error);
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_Manager_Lookup_Face(manager, FONT, &face)))
		{
			printf("Clock / SSaver <FTC_Manager_Lookup_Face failed with Errorcode 0x%.2X>\n", error);
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		use_kerning = FT_HAS_KERNING(face);

#ifdef FT_NEW_CACHE_API
		desc.face_id = FONT;
#else
		desc.font.face_id = FONT;
#endif
#if FREETYPE_MAJOR  == 2 && FREETYPE_MINOR == 0
		desc.image_type = ftc_image_mono;
#else
		desc.flags = FT_LOAD_MONOCHROME;
#endif

		//init backbuffer

		if(!(lbb = malloc(var_screeninfo.xres*var_screeninfo.yres)))
		{
			printf("Clock / SSaver <allocating of Backbuffer failed>\n");
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if (!slow)
			slow=1;

		if (slow>10)
			slow=10;

		if (fcol > MAXCOL && !(ssaver == 1 && fcol == 99))
			fcol = 2;
		if (bcol > 3 && !(bcol == 10))
			bcol = 1;

		if (ssaver)
		{
			memset(lbb, col[bcol], var_screeninfo.xres*var_screeninfo.yres);
			memset(lfb, col[bcol], var_screeninfo.xres*var_screeninfo.yres);
		}
		else
			memset(lbb, 0, var_screeninfo.xres*var_screeninfo.yres);

		if (big)			//grosse Schrift (time/date)
		{
			margin_left_F = 3;			// 3
			digit_width = 14;			// 14
			margin_top_t = 26;			// 26
			font_size = BIG;			// 40
			margin_top_box = 30;		// 30
			margin_top_d = 60;			// 60
		}
		else
		{
			margin_left_F = 7;			//7  Abstand links
			digit_width = 12;			//12 Ziffernblockbreite
			margin_top_t = 19;			//19 Abstand "TimeString"-Unterkante von oben
			font_size = MED;			//30 Schriftgroesse
			margin_top_box = 20;		//20 Abstand Renderbox von oben
			margin_top_d = 40;			//40 Abstand "DateString" von oben
		}
		digits = 0;
		secs_width = 0;
		startx = sx;
		starty = sy;
		mw = (big) ? 42 : 36;			//mailwidth
		adj_height = 1 * (!big && !show_date); //max steprange == 3, so we need always a top/bottom margin of >=3

		if (!show_sec && !show_date)
		{
			digits = 3;				//3 Platzhalter ':ss'
			secs_width = digits * digit_width;
		}

		if (ssaver)
		{
			xpos = rand() %480 + 10;
			ypos = rand() %460 + 10;	
			xdir *= (rand() &1) == 0 ? -1 : 1;
			ydir *= (rand() &1) == 0 ? -1 : 1;
			xstep/=(double)slow;
			ystep/=(double)slow;
			if (fcol == 99)
			{
				cCol = 1;
				Change_Col(&fcol, &bcol);
			}
			InitRC();
		}

	while (loop)
	{
		if (ssaver)
			usleep(15000L);
		else
		{
			usleep(150000L);
			newmail = 0;
			if(mail && ExistFile(MAIL_FILE))
			{
				if((tfh = fopen(MAIL_FILE,"r")) != NULL)
				{
					if(fgets(tstr, 511, tfh))
					{
						if(sscanf(tstr, "%d", &i))
						{
							newmail = i;
						}
					}
					fclose(tfh);
				}
			}
		}

		time(&atim);
		ltim=localtime(&atim);
		if (show_sec)
		{
			sprintf(tstr,"%02d:%02d:%02d", ltim->tm_hour, ltim->tm_min, ltim->tm_sec);
		}
		else
		{
			if (blink)
				sprintf(tstr,"   %02d%c%02d", ltim->tm_hour, (ltim->tm_sec & 1)? ' ' : ':', ltim->tm_min);
			else
				sprintf(tstr,"   %02d:%02d", ltim->tm_hour, ltim->tm_min);
		}

		if (!ssaver)
		{
			if (((int)xpos >= mw) || (!show_sec))
			{
				ms = (int)xpos + ((show_sec) ? 0 : mw) - mw;	//mail left
			}
			else
			{
				ms = (int)xpos + 100 + 20 * big;		//mail right
			}
			//paint Backgroundcolor to clear digit
			RenderBox(xpos+secs_width, ypos, xpos+secs_width+100+20*big, ypos+margin_top_box + adj_height, FILL, col[bcol]);
		}

		if (ssaver)
		{
			xpos += xstep * (double)xdir;
			ypos += ystep * (double)ydir;

			csx = xpos + secs_width;
			csy = ypos;
			cex = xpos + secs_width + 100 + 20 * big;
			cey = ypos + margin_top_t + 2 * (1 + big) + (margin_top_box * show_date) + adj_height;

			if ((int)csx < 0 || (sx + (int)cex) > ex)
			{
				if (cCol)
					Change_Col(&fcol, &bcol);
				xdir *= -1;
				xpos += xstep * (double)xdir;
				csx = xpos + secs_width;
				cex = xpos + secs_width + 100 + 20 * big;
				xstep = rand() &3;
				if (!xstep)
				{
					xstep = 1;
				}
				xstep /= (double)slow;
			}
			if ((int)csy < 0 || (sy + (int)cey) > ey)
			{
				if (cCol)
					Change_Col(&fcol, &bcol);
				ydir *= -1;
				ypos += ystep * (double)ydir;
				csy = ypos;
				cey = ypos + margin_top_t + 2 * (1 + big) + (margin_top_box * show_date) + adj_height;	
				ystep = rand() &3;
				if (!ystep)
				{
					ystep = 1;
				}
				ystep /= (double)slow;
			}
			RenderBox(csx, csy, cex, cey, FILL, col[bcol]);
		}

		for (i = digits; i < strlen(tstr); i++)
		{
			*dstr = tstr[i];
			RenderString(dstr, xpos - margin_left_F + (i * digit_width), ypos + margin_top_t, 30, CENTER, font_size, col[fcol]);
		}

		if (show_date)
		{
			sprintf(tstr, "%02d.%02d.%02d", ltim->tm_mday, ltim->tm_mon + 1, ltim->tm_year - 100);
			if (!ssaver)
			{
			//Backgroundbox color Date
			RenderBox(xpos, ypos + margin_top_box, xpos + 100 + 20 * big, ypos + margin_top_d, FILL, col[bcol]);
			}
			for(i = 0; i < strlen(tstr); i++)
			{
				*dstr = tstr[i];
				RenderString(dstr, xpos - margin_left_F + (i * digit_width), ypos + margin_top_d - 2 - (2 * big), 30, CENTER, font_size, col[fcol]);
			}
		}

		if (ssaver)
		{
			w = 100 + 20 * big + ((show_sec) ? 0 : - secs_width);
			for (i = 0; i <= ((show_date) ? 20 : 10) * (2 + big) + adj_height; i++)
			{
				j = (starty + (int)ypos + i) * var_screeninfo.xres + (int)xpos + ((show_sec) ? 0 : secs_width) + startx;
				if ((j + w) < var_screeninfo.xres * var_screeninfo.yres)
				{
					memcpy(lfb+j, lbb+j, w);
				}
			}
		}
		else
		{
			if (newmail > 0)
			{
				mailgfx = 1;

				//Background mail, left site from clock
				RenderBox(ms, ypos, ms+mw, ypos+margin_top_box + adj_height, FILL, col[bcol]); //bcol

				if(!(ltim->tm_sec & 1))
				{
					RenderBox (ms+8, ypos+5+(1+big), ms+mw-8, ypos+margin_top_box+adj_height-2-(3*big), GRID,	col[fcol]);
					DrawLine  (ms+8, ypos+5+(1+big), ms+mw-8, ypos+margin_top_box+adj_height-2-(3*big),			col[fcol]);
					DrawLine  (ms+8, ypos+margin_top_box+adj_height-2-(3*big), ms+mw-8, ypos+5+(1+big),			col[fcol]);
					DrawLine  (ms+(9+1*big), ypos+4+(1+big), ms+(mw/2), ypos+1,                  				col[fcol]);
					DrawLine  (ms+(9+1*big), ypos+5+(1+big), ms+(mw/2), ypos+2,                  				col[fcol]);
					DrawLine  (ms+(mw/2), ypos+1, ms+mw-(9+1*big), ypos+4+(1+big),               				col[fcol]);
					DrawLine  (ms+(mw/2), ypos+2, ms+mw-(9+1*big), ypos+5+(1+big),               				col[fcol]);
				}
				else
				{
					sprintf(tstr,"%d",newmail);
					RenderString(tstr, ms, ypos+margin_top_t, mw, CENTER, font_size, col[fcol]);
				}
			}
			else
			{
				if (mailgfx > 0)
					RenderBox(ms, ypos, ms+mw, ypos + margin_top_box + adj_height, FILL, (!show_date || show_sec) ? TRANSP : col[bcol]);
				else
					ms=(int)xpos;
			}

			w = 100 + 20 * big + ((mailgfx) ? ((show_sec) ? mw : 0) : - secs_width);
			for (i=0; i <= ((show_date) ? 20 : 10) * (2 + big) + adj_height; i++)
			{
				j = (starty + (int)ypos + i) * var_screeninfo.xres + ( ((ms < (int)xpos) ? ms : (int)xpos) + ((show_sec) ? 0 : ((mailgfx) ? 0 : secs_width)) ) + startx;			
				if ((j + w) < var_screeninfo.xres * var_screeninfo.yres)
				{
					memcpy(lfb+j, lbb+j, w);
				}
			}
			if (newmail == 0 && mailgfx > 0)
				mailgfx = 0;
		}

		if (++loop > 10)
		{
			if ( (ssaver && (RCKeyPressed() || ExistFile("/tmp/.ssaver_kill")))
				|| (!ssaver && ExistFile("/tmp/.clock_kill")) )
				loop = 0;
		}
	}


/****************************
 * close down Clock / SSaver
 ****************************/
	if (ssaver)
	{
		memset(lfb, 0, var_screeninfo.xres*var_screeninfo.yres);
		remove("/tmp/.ssaver_kill");
		CloseRC();
	}
	else
	{
		memset(lbb, 0, var_screeninfo.xres*var_screeninfo.yres);
		remove("/tmp/.clock_kill");
		for (i=0; i <= ((show_date) ? 20 : 10) * (2 + big) + adj_height; i++)
		{
			j=(starty+(int)ypos+i)*var_screeninfo.xres+((ms<(int)xpos)?ms:(int)xpos)+((show_sec)?0:((mailgfx)?0:secs_width))+startx;
			if((j+100+20*big+((mail)?mw:0))<var_screeninfo.xres*var_screeninfo.yres)
			{
				memcpy(lfb+j, lbb+j, w);
			}
		}
	}

	FTC_Manager_Done(manager);
	FT_Done_FreeType(library);

	free(lbb);
	munmap(lfb, fix_screeninfo.smem_len);

	close(fb);

	return 0;
}
Ejemplo n.º 22
0
//************************************************************************************************
// 	ClearOSD()
//************************************************************************************************
void cMenu::ClearOSD()
{
   IMPORT_FRAMEBUFFER_VARS;
   RenderBox(0, 0, p_xsize, p_ysize, FILL, TRANSP);
   STORE_PALETTE(NULL);
}
Ejemplo n.º 23
0
char *inputd(char *form, char *title, char *defstr, int keys, int frame, int mask, int bhelp, int cols, int tmo, int debounce)
{
int exs,eys,wxs,wxw,wys,wyw,i,j,xp,yp;
char trnd[2]={0,0},tch;
int act_key=-1, last_key=-1, b_key=-1, run=1, ipos=0;
time_t t1,t2,tm1;
char knum[12][2]={"1","2","3","4","5","6","7","8","9"," ","0"};
char kalp[12][5]={"+-*/","abcä","def","ghi","jkl","mnoö","pqrs","tuvü","wxyz","","_,.;"};

	epos=-1;
	cpos=0;
	kpos=0;
	first=1;
	time(&tm1);
	if(cols>25)
	{
		cols=25;
	}
	if(cols<1)
	{
		cols=1;
	}
	format=form;
	estr=strdup(form);
	cnt=strlen(form);
	
	RenderString("X", 310, 250, 20, LEFT, BIG, CMC);
	i=GetStringLen(title)+10;
	j=((cnt>cols)?cols:cnt)*exsz;
	if(j>i)
	{
		i=j;
	}
	if(keys)
	{
		j=3*bxsz;
		if(j>i)
		{
			i=j;
		}
	}
	wxw=i+2*xbrd;

	i=(((cnt-1)/cols)+1)*eysz;
	if(keys)
	{
		i+=4*bysz;
	}
	wyw=((keys)?4:2)*ybrd+i;

	wxs=((ex-sx)-wxw)/2;
	wys=(((ey-sy)-wyw)+hsz)/2;
	exs=wxs+(wxw-((cnt>cols)?cols:cnt)*exsz)/2;
	eys=wys+ybrd;

	*estr=0;
	*rstr=0;
		
	j=0;
	for(i=0; i<strlen(format); i++)
	{
		tch=format[i];
		if(IsInput(tch))
		{
			if(epos==-1)
			{
				epos=i;
			}
			if(defstr && j<strlen(defstr))
			{
				estr[i]=defstr[j++];
			}
			else
			{
				estr[i]=' ';
			}
		}
		else
		{
			estr[i]=format[i];
		}
	}
	estr[i]=0;

	RenderBox(wxs-2, wys-hsz-2, wxs+wxw+2, wys+wyw+2, radius, CMH);
	RenderBox(wxs, wys-hsz, wxs+wxw, wys+wyw, radius, CMC);
	RenderBox(wxs, wys-hsz, wxs+wxw, wys, radius, CMH);
	RenderString(title, wxs, wys-15, wxw, CENTER, BIG, CMHT);
	if(keys)
	{
		int bxs=wxs+(wxw-(3*bxsz))/2;
		int bys=((wys+wyw)-2*ybrd)-4*bysz;
		
		for(i=0; i<11; i++)
		{
			if(i!=9)
			{
				RenderBox(bxs+(i%3)*bxsz, bys+(i/3)*bysz, bxs+((i%3)+1)*bxsz, bys+((i/3)+1)*bysz, radius, COL_MENUCONTENT_PLUS_4);
				RenderBox(bxs+(i%3)*bxsz+2, bys+(i/3)*bysz+2, bxs+((i%3)+1)*bxsz-2, bys+((i/3)+1)*bysz-2, radius, CMC);
				RenderString(knum[i], bxs+(i%3)*bxsz, bys+(i/3)*bysz+bysz/2, bxsz, CENTER, MED, CMCIT);
				RenderString(kalp[i], bxs+(i%3)*bxsz, bys+(i/3)*bysz+bysz-8, bxsz, CENTER, SMALL, CMCIT);
				
			}
		}	
		RenderCircle(bxs,wys+wyw-ybrd-8,'R');
		RenderString("Groß/Klein",bxs+15,wys+wyw-ybrd+5,3*bxsz,LEFT,SMALL,CMCIT);
		RenderCircle(bxs+3*bxsz-GetStringLen("löschen")-15,wys+wyw-ybrd-8,'Y');
		RenderString("löschen",bxs,wys+wyw-ybrd+5,3*bxsz,RIGHT,SMALL,CMCIT);
	}
	
	while(run)
	{
		for(i=0; i<cnt; i++)
		{
			xp=i%cols;
			yp=i/cols;
			if(frame && IsInput(format[i]))
			{
				RenderBox(exs+xp*exsz, eys+5+yp*eysz, exs+(xp+1)*exsz, eys+(yp+1)*eysz, radius, COL_MENUCONTENT_PLUS_4);
			}
			RenderBox(exs+xp*exsz+1, eys+5+yp*eysz+1, exs+(xp+1)*exsz-1, eys+(yp+1)*eysz-1, radius, (epos==i)?CMCS:CMC);
			*trnd=(mask && format[i]==NUM && IsNum(estr[i]))?'*':estr[i];
			RenderString(trnd, exs+xp*exsz+2, eys+yp*eysz+tys, exsz-2, CENTER, MED, (epos==i)?CMCST:(IsInput(format[i]))?CMCT:CMCIT);
		}
		memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres);

		time(&t1);
		i=-1;
		while(i==-1)
		{
			i=GetRCCode();
			if(i!=-1)
			{
				tmo=0;
				if(i==b_key)
				{
					usleep(debounce*1000);
					while((i=GetRCCode())!=-1);
				}
				b_key=i;
			}
			time(&t2);
			if(tmo)
			{
				if((t2-tm1)>=tmo)
				{
					i=RC_HOME;
				}
			}
			if((((format[epos]!=NUM) && (format[epos]!=HEX)) || ((format[epos]==HEX)&&(strlen(hcod[cpos])>1))) && ((t2-t1)>ndelay) && last_key>=0)
			{
				act_key=i=-2;
				b_key=-3;
				NextPos();
			}
		}
		act_key=i;
		
		switch(act_key)
		{
			case RC_0:
				SetCode(0);
			break;
			
			case RC_1:
				SetCode(1);
			break;
			
			case RC_2:
				SetCode(2);
			break;
			
			case RC_3:
				SetCode(3);
			break;
			
			case RC_4:
				SetCode(4);
			break;
			
			case RC_5:
				SetCode(5);
			break;
			
			case RC_6:
				SetCode(6);
			break;
			
			case RC_7:
				SetCode(7);
			break;
			
			case RC_8:
				SetCode(8);
			break;
			
			case RC_9:
				SetCode(9);
			break;
			
			case RC_RIGHT:
				NextPos();
				act_key=-2;
			break;
			
			case RC_LEFT:
				PrevPos();
				act_key=-2;
			break;
			
			case RC_PLUS:
				ipos=epos;
				while(IsInput(format[ipos+1]) && ((ipos+1)<cnt))
				{
					++ipos;
				}
				while(ipos>epos)
				{
					estr[ipos]=estr[ipos-1];
					--ipos;
				}
				estr[epos]=' ';
				act_key=-1;
			break;

			case RC_MINUS:
				ipos=epos+1;
				while(IsInput(format[ipos]) && (ipos<cnt))
				{
					estr[ipos-1]=estr[ipos];
					++ipos;
				}
				estr[ipos-1]=' ';
				act_key=-1;
			break;

			case RC_OK:
				run=0;
			break;
			
			case RC_MUTE:	
				memset(lfb, TRANSP, 720*576);
				usleep(500000L);
				while(GetRCCode()!=-1)
				{
					usleep(100000L);
				}
				while(GetRCCode()!=RC_MUTE)
				{
					usleep(500000L);
				}
				while((act_key=GetRCCode())!=-1)
				{
					usleep(100000L);
				}
			break;

			case RC_UP:
				if(epos>=cols)
				{
					epos-=cols;
					if(!IsInput(format[epos]))
					{
						NextPos();
					}
				}
				else
				{
					epos=cnt-1;
					if(!IsInput(format[epos]))
					{
						PrevPos();
					}
				}
				act_key=-2;
			break;
			
			case RC_DOWN:
				if(epos<=(cnt-cols))
				{
					epos+=cols;
					if(!IsInput(format[epos]))
					{
						NextPos();
					}
				}
				else
				{
					epos=0;
					if(!IsInput(format[epos]))
					{
						NextPos();
					}
				}
				act_key=-2;
			break;
			
			case RC_HOME:
				free(estr);
				estr=NULL;
				*rstr=0;
				run=0;
			break;
			
			case RC_RED:
				if(IsAlpha(estr[epos]))
				{
					estr[epos]^=0x20;
				}
				act_key=-2;
			break;
			
			case RC_YELLOW:
				epos=-1;
				for(i=0; i<strlen(format); i++)
				{
					if(IsInput(format[i]))
					{
						if(epos==-1)
						{
							epos=i;
						}
						estr[i]=' ';
					}
				}
				act_key=-2;
			break;
			
			case RC_HELP:
				if(bhelp)
				{
					sprintf(estr,"?");
					run=0;
				}
			break;
			
			default:
				act_key=-2;
			break;
		}
		last_key=act_key;
	}
	
	if(estr)
	{
		j=0;
		for(i=0; i<strlen(format); i++)
		{
			if(IsInput(format[i]))
			{
				rstr[j++]=estr[i];
			}
		}
		rstr[j]=0;
		free(estr);
	}	
	ReTransform_Msg(rstr);
	return tstr;
}
Ejemplo n.º 24
0
int show_txt(int buttonly)
{
	FILE *tfh;
	char const *fname=NULL;
	int yo=scale2res(80), buttx=scale2res(80), butty=scale2res(30), buttdx=scale2res(20), buttdy=scale2res(10);
	int icon_w=0, icon_h=0, xsize=0, ysize=0;
	int i,bx,by,x1,y1,rv=-1,run=1,line=0,action=1,cut,itmp,btns=buttons,lbtns=(buttons>bpline)?bpline:buttons,blines=1+((btns-1)/lbtns);

	if(hide)
	{
#if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE
		memcpy(lbb, hbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t));
		blit();
#else
		memcpy(lfb, hbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t));
#endif
		return 0;
	}
	if (strcmp(icon, "none")==0 || strcmp(icon, "0")==0)
		fname = "";
	else if (strcmp(icon, "error")==0 || strcmp(icon, "1")==0)
		fname = ICON_ERROR;
	else if (strcmp(icon, "info")==0 || strcmp(icon, "2")==0)
		fname = ICON_INFO;
	else	
		fname = icon;
	png_getsize(fname, &icon_w, &icon_h);

	// limit icon size
	if(icon_w > 100 || icon_h > 60) {
		icon_w = xsize = 100;
		icon_h = ysize = 60;
	}

	int h_head = max(FSIZE_MED+(size/2), icon_h);
	yo=((header)?h_head:0);

	int moffs=yo-h_head/3-(size/2);
	if(!buttonly)
	{
		memcpy(lbb, ibb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t));
	}
	if((tfh=fopen(TMP_FILE,"r"))!=NULL)
	{
		fclose(tfh);
		int fsizebut = scale2res(26);

		if(!buttonly)
		{
			if(type!=1)
			{
				btns=0;
				myo=0;
			}	
		
			pxw=GetStringLen(sx,title,FSIZE_BIG)+OFFSET_MED;
			if(type==1)
			{
				myo=blines*(butty+buttdy);
				for(i=0; i<btns; i++)
				{
					itmp=GetStringLen(sx,butmsg[i],fsizebut)+OFFSET_MED;
					if(itmp>buttx)
					{
						buttx=itmp;
					}
				}
			}
			buttsize=buttx;
			
			if(fh_txt_getsize(TMP_FILE, &x1, &y1, size, &cut))
			{
				printf(__plugin__ " <invalid Text-Format>\n");
				return -1;
			}
			x1+=OFFSET_MED;

			dy=size;
			if(pxw<x1)
			{
				pxw=x1;
			}
			if(pxw<(lbtns*buttx+lbtns*buttdx))
			{
				pxw=(lbtns*buttx+lbtns*buttdx);
			}
			if(pxw>((ex-sx)-2*buttdx))
			{
				pxw=ex-sx-2*buttdx;
			}
			psx=((ex-sx)/2-pxw/2);
			pyw=y1*dy/*-myo*/;
			if(pyw>((ey-sy)-yo-myo))
			{
				pyw=((ey-sy)-yo-myo);
			}
			psy=((ey-sy)/2-(pyw+myo-yo)/2);
			if(btns)
			{
				buttxstart=psx+pxw/2-(((double)lbtns*(double)buttsize+(((lbtns>2)&&(lbtns&1))?((double)buttdx):0.0))/2.0);
				buttystart=psy+y1*dy+2*OFFSET_MED;
			}
		}

		while(run)
		{
			//frame layout
			if(action)
			{
				if(!buttonly)
				{
					int iw, ih, pxoffs = 0;
					int slen = GetStringLen(sx, title, FSIZE_BIG)+2*OFFSET_MED;
					if (icon_w > 0 && (psx+pxw-2*OFFSET_MED-slen <= psx-OFFSET_MED+icon_w+OFFSET_MED))
						pxoffs = (icon_w)/2;
					RenderBox(psx-2*OFFSET_MED-pxoffs+OFFSET_SMALL, psy-yo-h_head/3-OFFSET_SMALL, psx+pxw+pxoffs+2*OFFSET_MED+OFFSET_SMALL, psy+pyw+myo+(h_head/3)+OFFSET_MED+OFFSET_SMALL, radius, COL_SHADOW_PLUS_0);
					RenderBox(psx-2*OFFSET_MED-pxoffs, psy-yo-h_head/3-OFFSET_MED, psx+pxw+pxoffs+2*OFFSET_MED, psy+pyw+myo+(h_head/3)+OFFSET_MED, radius, CMC);
					if(header)
					{
						int pyoffs=(icon_h < h_head)?1:0;
						RenderBox(psx-2*OFFSET_MED-pxoffs, psy-yo-h_head/3-OFFSET_MED, psx+pxw+pxoffs+2*OFFSET_MED, psy-yo+(h_head*2)/3-OFFSET_MED, radius, CMH);
						paintIcon(fname,  psx-OFFSET_MED-pxoffs, psy-yo-h_head/3+h_head/2-icon_h/2+pyoffs-OFFSET_MED, xsize, ysize, &iw, &ih);
						RenderString(title, psx+pxoffs, psy-moffs-OFFSET_MED, pxw, CENTER, FSIZE_BIG, CMHT);
					}
				}
				if(buttonly || !(rv=fh_txt_load(TMP_FILE, psx, pxw, psy+size, dy, size, line, &cut)))
				{
					if(type==1)
					{
						for(i=0; i<btns; i++)
						{
							bx=i%lbtns;
							by=i/lbtns;
							RenderBox(buttxstart+bx*(buttsize+buttdx/2)+OFFSET_SMALL/2, buttystart+by*(butty+buttdy/2)+OFFSET_SMALL/2, buttxstart+(bx+1)*buttsize+bx*(buttdx/2)+OFFSET_SMALL/2, buttystart+by*(butty+buttdy/2)+butty+OFFSET_SMALL/2, radius_small, COL_SHADOW_PLUS_0);
							RenderBox(buttxstart+bx*(buttsize+buttdx/2), buttystart+by*(butty+buttdy/2), buttxstart+(bx+1)*buttsize+bx*(buttdx/2), buttystart+by*(butty+buttdy/2)+butty, radius_small, CMCS/*YELLOW*/);
							RenderBox(buttxstart+bx*(buttsize+buttdx/2)+1, buttystart+by*(butty+buttdy/2)+1, buttxstart+(bx+1)*buttsize+bx*(buttdx/2)-1, buttystart+by*(butty+buttdy/2)+butty-1, radius_small, ((by*bpline+bx)==(selection-1))?CMCS:CMC);
							RenderString(butmsg[i], buttxstart+bx*(buttsize+buttdx/2), buttystart+by*(butty+buttdy/2)+butty, buttsize, CENTER, fsizebut, (i==(selection-1))?CMCST:CMCIT);
						}
					}
#if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE
					blit();
#else
					memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t));
#endif
				}
			}
			run=0;
		}
	}
	return (rv)?-1:0;	
}
Ejemplo n.º 25
0
Archivo: clock.c Proyecto: TitanNit/tdt
int main (int argc, char **argv)
{
	int tv,index,i,j,k,w,cmct=CMCT,cmc=CMC,trnspi=TRANSP,trnsp=0,found,loop=1,x0,x1,x2,x3,x4,x5,x6,x7,ms,mw,newmail=0;
	time_t atim;
	struct tm *ltim;
	char *aptr,*rptr;
	char dstr[2]={0,0};
	FILE *tfh;

		printf("Clock Version %s\n",CL_VERSION);
		
		ReadConf();
	
		for(i=1; i<argc; i++)
		{
			aptr=argv[i];
			if((rptr=strchr(aptr,'='))!=NULL)
			{
				rptr++;
				if(strstr(aptr,"X=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						xpos=j;
					}
				}
				if(strstr(aptr,"Y=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						ypos=j;
					}
				}
				if(strstr(aptr,"DATE=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						sdat=j;
					}
				}
				if(strstr(aptr,"BIG=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						big=j;
					}
				}
				if(strstr(aptr,"SEC=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						secs=j;
					}
				}
				if(strstr(aptr,"FCOL=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						fcol=j;
					}
				}
				if(strstr(aptr,"BCOL=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						bcol=j;
					}
				}
				if(strstr(aptr,"MAIL=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						mail=j;
					}
				}
			}
		}
		if((sx=Read_Neutrino_Cfg("screen_StartX"))<0)
			sx=80;
		
		if((ex=Read_Neutrino_Cfg("screen_EndX"))<0)
			ex=620;

		if((sy=Read_Neutrino_Cfg("screen_StartY"))<0)
			sy=80;

		if((ey=Read_Neutrino_Cfg("screen_EndY"))<0)
			ey=505;
			
		for(index=CMCST; index<=CMH; index++)
		{
			sprintf(tstr,"menu_%s_alpha",menucoltxt[index-1]);
			if((tv=Read_Neutrino_Cfg(tstr))>=0)
				tr[index-1]=(tv<<8);

			sprintf(tstr,"menu_%s_blue",menucoltxt[index-1]);
			if((tv=Read_Neutrino_Cfg(tstr))>=0)
				bl[index-1]=(tv+(tv<<8));

			sprintf(tstr,"menu_%s_green",menucoltxt[index-1]);
			if((tv=Read_Neutrino_Cfg(tstr))>=0)
				gn[index-1]=(tv+(tv<<8));

			sprintf(tstr,"menu_%s_red",menucoltxt[index-1]);
			if((tv=Read_Neutrino_Cfg(tstr))>=0)
				rd[index-1]=(tv+(tv<<8));
		}
		
		fb = open(FB_DEVICE, O_RDWR);

		if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1)
		{
			printf("Clock <FBIOGET_FSCREENINFO failed>\n");
			return -1;
		}
		if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1)
		{
			printf("Clock <FBIOGET_VSCREENINFO failed>\n");
			return -1;
		}
		
		if(ioctl(fb, FBIOGETCMAP, &colormap) == -1)
		{
			printf("Clock <FBIOGETCMAP failed>\n");
			return -1;
		}

		if(!(lfb = (unsigned char*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0)))
		{
			printf("Clock <mapping of Framebuffer failed>\n");
			return -1;
		}

	//init fontlibrary

		if((error = FT_Init_FreeType(&library)))
		{
			printf("Clock <FT_Init_FreeType failed with Errorcode 0x%.2X>", error);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_Manager_New(library, 1, 2, 0, &MyFaceRequester, NULL, &manager)))
		{
			printf("Clock <FTC_Manager_New failed with Errorcode 0x%.2X>\n", error);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_SBitCache_New(manager, &cache)))
		{
			printf("Clock <FTC_SBitCache_New failed with Errorcode 0x%.2X>\n", error);
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_Manager_Lookup_Face(manager, FONT, &face)))
		{
			printf("Clock <FTC_Manager_Lookup_Face failed with Errorcode 0x%.2X>\n", error);
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		use_kerning = FT_HAS_KERNING(face);

#ifdef FT_NEW_CACHE_API
		desc.face_id = FONT;
#else
		desc.font.face_id = FONT;
#endif
#if FREETYPE_MAJOR  == 2 && FREETYPE_MINOR == 0
		desc.image_type = ftc_image_mono;
#else
		desc.flags = FT_LOAD_MONOCHROME;
#endif

	//init backbuffer

		if(!(lbb = malloc(var_screeninfo.xres*var_screeninfo.yres)))
		{
			printf("Clock <allocating of Backbuffer failed>\n");
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		memset(lbb, 0, var_screeninfo.xres*var_screeninfo.yres);

		startx = sx;
		starty = sy;
		mw=(big)?40:30;

	while(loop)
	{
		usleep(150000L);
		newmail=0;
		if(mail && ExistFile(MAIL_FILE))
		{
			if((tfh=fopen(MAIL_FILE,"r"))!=NULL)
			{
				if(fgets(tstr,511,tfh))
				{
					if(sscanf(tstr,"%d",&i))
					{
						newmail=i;
					}
				}
				fclose(tfh);
			}
		}
		ioctl(fb, FBIOGETCMAP, &colormap);
		found=0;
		trnsp=0;
		for(i=colormap.start;i<colormap.len && found!=7;i++)
		{
			if(!colormap.red[i] && !colormap.green[i] && !colormap.blue[i] && !colormap.transp[i])
			{
				cmc=i;
				found|=1;
			}
			if(colormap.red[i]>=0xF000 && colormap.green[i]>=0xF000  && colormap.blue[i]>=0xF000 && !colormap.transp[i])
			{
				cmct=i;
				found|=2;
			}
			if(colormap.transp[i]>trnsp)
			{
				trnspi=i;
				trnsp=colormap.transp[i];
				found|=4;
			}
		}	

		if(big)
		{
			x0=3;
			x1=14;
			x2=26;
			x3=BIG;
			x4=30;
			x5=60;
		}
		else
		{
			x0=7;
			x1=12;
			x2=18;
			x3=MED;
			x4=18;
			x5=40;
		}
		x6=0;
		x7=0;
		time(&atim);
		ltim=localtime(&atim);
		if(secs)
		{
			sprintf(tstr,"%02d:%02d:%02d",ltim->tm_hour,ltim->tm_min,ltim->tm_sec);
		}
		else
		{
			sprintf(tstr,"   %02d%c%02d",ltim->tm_hour,(ltim->tm_sec & 1)?':':' ',ltim->tm_min);
			if(!sdat)
			{
				x6=3;
				x7=36+4*big;
			}
		}
		if((xpos>=mw)||(!secs))
		{
			ms=xpos+((secs)?0:36+4*big)-mw;
		}
		else
		{
			ms=xpos+100+20*big;
		}
		k=((ms>xpos)&&mail)?mw:0;
		RenderBox(xpos+x7, ypos, xpos+x7+100+20*big, ypos+x2+2*(1+big), FILL, (bcol==0)?trnspi:((bcol==1)?cmc:cmct));
		for(i=x6; i<strlen(tstr); i++)
		{
			*dstr=tstr[i];
			RenderString(dstr, xpos-x0+(i*x1), ypos+x2, 30, CENTER, x3, (fcol==0)?trnspi:((fcol==2)?cmct:cmc));
		}

		if(sdat)
		{
			sprintf(tstr,"%02d.%02d.%02d",ltim->tm_mday,ltim->tm_mon+1,ltim->tm_year-100);
			RenderBox(xpos, ypos+x4, xpos+100+20*big, ypos+x5, FILL, (bcol==0)?trnspi:((bcol==1)?cmc:cmct));
			for(i=0; i<strlen(tstr); i++)
			{
				*dstr=tstr[i];
				RenderString(dstr, xpos-x0+(i*x1), ypos+x5-2-2*big, 30, CENTER, x3, (fcol==0)?trnspi:((fcol==2)?cmct:cmc));
			}
		}
		if(mail)
		{
			if(newmail)
			{
				RenderBox(ms, ypos, ms+mw, ypos+x2+2*(1+big), FILL, (bcol==0)?trnspi:((bcol==1)?cmc:cmct));
				if(!(ltim->tm_sec & 1))
				{
					RenderBox(ms+5, ypos+5+(1+big), ms+mw-5, ypos+x2+(1+big)-2, GRID, (fcol==0)?trnspi:((fcol==1)?cmc:cmct));
					DrawLine(ms+5, ypos+5+(1+big), ms+mw-5, ypos+x2+(1+big)-2, (fcol==0)?trnspi:((fcol==1)?cmc:cmct));
					DrawLine(ms+5, ypos+x2+(1+big)-2, ms+mw-5, ypos+5+(1+big), (fcol==0)?trnspi:((fcol==1)?cmc:cmct));
					DrawLine(ms+5, ypos+5+(1+big), ms+((mw-2)/2), ypos+2, (fcol==0)?trnspi:((fcol==1)?cmc:cmct));
					DrawLine(ms+6, ypos+6+(1+big), ms+((mw-2)/2)+1, ypos+3, (fcol==0)?trnspi:((fcol==1)?cmc:cmct));
					DrawLine(ms+((mw-2)/2), ypos+2, ms+mw-5, ypos+5+(1+big), (fcol==0)?trnspi:((fcol==1)?cmc:cmct));
					DrawLine(ms+((mw-2)/2)+1, ypos+3, ms+mw-6, ypos+6+(1+big), (fcol==0)?trnspi:((fcol==1)?cmc:cmct));
				}
				else
				{
					sprintf(tstr,"%d",newmail);
					RenderString(tstr, ms, ypos+x2, mw, CENTER, x3, (fcol==0)?trnspi:((fcol==2)?cmct:cmc));
				}
			}
			else
			{
				if(!sdat || secs)
				{
					RenderBox(ms+((ms>(xpos+100))?1:0), ypos, ms+mw-((k)?0:1), ypos+x2+2*(1+big), FILL, trnspi);
				}
			}
		}
		else
		{
			ms=xpos;
		}
		
		w=100+20*big+((mail)?5*big+((secs)?mw:0):0)+k-((k&&!sdat)?mw:0);
		for(i=0;i<=((sdat)?40:20)*(1+big);i++)
		{
			j=(starty+ypos+i)*var_screeninfo.xres+((ms<xpos)?ms:xpos)+startx;
			if((j+w)<var_screeninfo.xres*var_screeninfo.yres)
			{
				memcpy(lfb+j, lbb+j, w);
			}
		}
		if(++loop>5)
		{
			if(ExistFile("/tmp/.clock_kill"))
			{
				loop=0;
			}
		}	
	}	

	cmct=0;
	cmc=0;
	for(i=colormap.start;i<colormap.len;i++)
	{
		if(colormap.transp[i]>cmct)
		{
			cmc=i;
			cmct=colormap.transp[i];
		}
	}
	memset(lbb, cmc, var_screeninfo.xres*var_screeninfo.yres);
	for(i=0;i<=((sdat)?40:20)*(1+big);i++)
	{
		j=(starty+ypos+i)*var_screeninfo.xres+((ms<xpos)?ms:xpos)+startx;
		if((j+100+20*big+((mail)?mw:0))<var_screeninfo.xres*var_screeninfo.yres)
		{
			memcpy(lfb+j, lbb+j, w);
		}
	}
	FTC_Manager_Done(manager);
	FT_Done_FreeType(library);

	free(lbb);
	munmap(lfb, fix_screeninfo.smem_len);

	close(fb);
	remove("/tmp/.clock_kill");
	return 0;
}
Ejemplo n.º 26
0
//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
void GLSkyPortal::DrawContents()
{
	bool drawBoth = false;
	int CM_Index;
	PalEntry FadeColor(0,0,0,0);

	if (gl_fixedcolormap) 
	{
		CM_Index=gl_fixedcolormap<CM_LIMIT? gl_fixedcolormap:CM_DEFAULT;
	}
	else 
	{
		CM_Index=CM_DEFAULT;
		FadeColor=origin->fadecolor;
	}

	gl_EnableFog(false);
	gl.Disable(GL_ALPHA_TEST);
	gl.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	gl.PushMatrix();
	gl_SetupView(0, 0, 0, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1), true);

	if (origin->texture[0] && origin->texture[0]->bSkybox)
	{
		if (fixedcolormap)
		{						
			float rr,gg,bb;

			gl_GetLightColor(255, 0, NULL, &rr, &gg, &bb);
			R=rr;
			G=gg;
			B=bb;
		}
		else R=G=B=1.f;

		RenderBox(origin->skytexno1, origin->texture[0], origin->x_offset[0], CM_Index);
		gl.Enable(GL_ALPHA_TEST);
	}
	else
	{
		if (origin->texture[0]==origin->texture[1] && origin->doublesky) origin->doublesky=false;	

		gl.Translatef(0.f, -1000.f, 0.f);

		if (origin->texture[0])
		{
			gl_SetTextureMode(TM_OPAQUE);
			RenderDome(origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->y_offset, CM_Index);
			gl_SetTextureMode(TM_MODULATE);
		}
		
		gl.Enable(GL_ALPHA_TEST);
		gl.AlphaFunc(GL_GEQUAL,0.05f);
		
		if (origin->doublesky && origin->texture[1])
		{
			secondlayer=true;
			RenderDome(0, origin->texture[1], origin->x_offset[1], origin->y_offset, CM_Index);
			secondlayer=false;
		}

		if (skyfog>0 && (FadeColor.r ||FadeColor.g || FadeColor.b))
		{
			gl_EnableTexture(false);
			foglayer=true;
			gl.Color4f(FadeColor.r/255.0f,FadeColor.g/255.0f,FadeColor.b/255.0f,skyfog/255.0f);
			RenderDome(0, NULL, 0, 0, CM_DEFAULT);
			gl_EnableTexture(true);
			foglayer=false;
		}
	}
	gl.PopMatrix();
}
Ejemplo n.º 27
0
//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
void GLSkyPortal::DrawContents()
{
	bool drawBoth = false;
	int CM_Index;
	PalEntry FadeColor(0,0,0,0);

	// We have no use for Doom lighting special handling here, so disable it for this function.
	int oldlightmode = glset.lightmode;
	if (glset.lightmode == 8) glset.lightmode = 2;


	if (gl_fixedcolormap) 
	{
		CM_Index=gl_fixedcolormap<CM_FIRSTSPECIALCOLORMAP + SpecialColormaps.Size()? gl_fixedcolormap:CM_DEFAULT;
	}
	else 
	{
		CM_Index=CM_DEFAULT;
		FadeColor=origin->fadecolor;
	}

	gl_RenderState.EnableFog(false);
	gl_RenderState.EnableAlphaTest(false);
	gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	GLRenderer->SetupView(0, 0, 0, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));

	if (origin->texture[0] && origin->texture[0]->tex->gl_info.bSkybox)
	{
		if (gl_fixedcolormap != CM_DEFAULT)
		{						
			float rr,gg,bb;

			gl_GetLightColor(255, 0, NULL, &rr, &gg, &bb);
			R=rr;
			G=gg;
			B=bb;
		}
		else R=G=B=1.f;

		RenderBox(origin->skytexno1, origin->texture[0], origin->x_offset[0], CM_Index, origin->sky2);
		gl_RenderState.EnableAlphaTest(true);
	}
	else
	{
		if (origin->texture[0]==origin->texture[1] && origin->doublesky) origin->doublesky=false;	

		if (origin->texture[0])
		{
			gl_RenderState.SetTextureMode(TM_OPAQUE);
			RenderDome(origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->y_offset, origin->mirrored, CM_Index);
			gl_RenderState.SetTextureMode(TM_MODULATE);
		}
		
		gl_RenderState.EnableAlphaTest(true);
		gl_RenderState.AlphaFunc(GL_GEQUAL,0.05f);
		
		if (origin->doublesky && origin->texture[1])
		{
			secondlayer=true;
			RenderDome(FNullTextureID(), origin->texture[1], origin->x_offset[1], origin->y_offset, false, CM_Index);
			secondlayer=false;
		}

		if (skyfog>0 && (FadeColor.r ||FadeColor.g || FadeColor.b))
		{
			gl_RenderState.EnableTexture(false);
			foglayer=true;
			glColor4f(FadeColor.r/255.0f,FadeColor.g/255.0f,FadeColor.b/255.0f,skyfog/255.0f);
			RenderDome(FNullTextureID(), NULL, 0, 0, false, CM_DEFAULT);
			gl_RenderState.EnableTexture(true);
			foglayer=false;
		}
	}
	glPopMatrix();
	glset.lightmode = oldlightmode;
}
Ejemplo n.º 28
0
//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
void GLSkyPortal::DrawContents()
{
	bool drawBoth = false;

	// We have no use for Doom lighting special handling here, so disable it for this function.
	int oldlightmode = glset.lightmode;
	if (glset.lightmode == 8)
	{
		glset.lightmode = 2;
		gl_RenderState.SetSoftLightLevel(-1);
	}


	gl_RenderState.ResetColor();
	gl_RenderState.EnableFog(false);
	gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
	gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	bool oldClamp = gl_RenderState.SetDepthClamp(true);

	gl_MatrixStack.Push(gl_RenderState.mViewMatrix);
	GLRenderer->SetupView(0, 0, 0, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));

	if (origin->texture[0] && origin->texture[0]->tex->gl_info.bSkybox)
	{
		RenderBox(origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->sky2);
	}
	else
	{
		gl_RenderState.SetVertexBuffer(GLRenderer->mSkyVBO);
		if (origin->texture[0]==origin->texture[1] && origin->doublesky) origin->doublesky=false;	

		if (origin->texture[0])
		{
			gl_RenderState.SetTextureMode(TM_OPAQUE);
			RenderDome(origin->texture[0], origin->x_offset[0], origin->y_offset, origin->mirrored, FSkyVertexBuffer::SKYMODE_MAINLAYER);
			gl_RenderState.SetTextureMode(TM_MODULATE);
		}
		
		gl_RenderState.AlphaFunc(GL_GEQUAL, 0.05f);
		
		if (origin->doublesky && origin->texture[1])
		{
			RenderDome(origin->texture[1], origin->x_offset[1], origin->y_offset, false, FSkyVertexBuffer::SKYMODE_SECONDLAYER);
		}

		if (skyfog>0 && gl_fixedcolormap == CM_DEFAULT && (origin->fadecolor & 0xffffff) != 0)
		{
			PalEntry FadeColor = origin->fadecolor;
			FadeColor.a = clamp<int>(skyfog, 0, 255);

			gl_RenderState.EnableTexture(false);
			gl_RenderState.SetObjectColor(FadeColor);
			gl_RenderState.Apply();
			glDrawArrays(GL_TRIANGLES, 0, 12);
			gl_RenderState.EnableTexture(true);
			gl_RenderState.SetObjectColor(0xffffffff);
		}
		gl_RenderState.SetVertexBuffer(GLRenderer->mVBO);
	}
	gl_MatrixStack.Pop(gl_RenderState.mViewMatrix);
	gl_RenderState.ApplyMatrices();
	glset.lightmode = oldlightmode;
	gl_RenderState.SetDepthClamp(oldClamp);
}
Ejemplo n.º 29
0
int main (int argc, char **argv)
{
	int tv,index,i,j,cmct=CMCT,cmc=CMC,trnspi=TRANSP,trnsp=0,found,loop=1,first=1,x0,x1,x2,x3,x4,x5,x6,x7;
	int xdir=1, ydir=1;
	double xstep=1, ystep=1; 
	double csx, cex, csy, cey;
	time_t atim;
	struct tm *ltim;
	char *aptr,*rptr;
	char dstr[2]={0,0};

		printf("SSaver Version %s\n",CL_VERSION);
		
		ReadConf();
	
		for(i=1; i<argc; i++)
		{
			aptr=argv[i];
			if((rptr=strchr(aptr,'='))!=NULL)
			{
				rptr++;
				if(strstr(aptr,"DATE=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						sdat=j;
					}
				}
				if(strstr(aptr,"BIG=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						big=(j)?1:0;
					}
				}
				if(strstr(aptr,"SEC=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						secs=j;
					}
				}
				if(strstr(aptr,"SLOW=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						if(!j)
						{
							j=1;
						}
						slow=j;
					}
				}
				if(strstr(aptr,"FCOL=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						fcol=j;
					}
				}
				if(strstr(aptr,"BCOL=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						bcol=j;
					}
				}
			}
		}
		if((sx=Read_Neutrino_Cfg("screen_StartX"))<0)
			sx=80;
		
		if((ex=Read_Neutrino_Cfg("screen_EndX"))<0)
			ex=620;

		if((sy=Read_Neutrino_Cfg("screen_StartY"))<0)
			sy=80;

		if((ey=Read_Neutrino_Cfg("screen_EndY"))<0)
			ey=505;
		
		if(!slow)
		{
			slow=1;
		}	
		if(slow>10)
		{
			slow=10;
		}
		
		xpos=ex/2;
		ypos=ey/2;	
		for(index=CMCST; index<=CMH; index++)
		{
			sprintf(tstr,"menu_%s_alpha",menucoltxt[index-1]);
			if((tv=Read_Neutrino_Cfg(tstr))>=0)
				tr[index-1]=(tv<<8);

			sprintf(tstr,"menu_%s_blue",menucoltxt[index-1]);
			if((tv=Read_Neutrino_Cfg(tstr))>=0)
				bl[index-1]=(tv+(tv<<8));

			sprintf(tstr,"menu_%s_green",menucoltxt[index-1]);
			if((tv=Read_Neutrino_Cfg(tstr))>=0)
				gn[index-1]=(tv+(tv<<8));

			sprintf(tstr,"menu_%s_red",menucoltxt[index-1]);
			if((tv=Read_Neutrino_Cfg(tstr))>=0)
				rd[index-1]=(tv+(tv<<8));
		}
		
		fb = open(FB_DEVICE, O_RDWR);

		if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1)
		{
			printf("Clock <FBIOGET_FSCREENINFO failed>\n");
			return -1;
		}
		if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1)
		{
			printf("Clock <FBIOGET_VSCREENINFO failed>\n");
			return -1;
		}
		
		if(ioctl(fb, FBIOGETCMAP, &colormap) == -1)
		{
			printf("Clock <FBIOGETCMAP failed>\n");
			return -1;
		}

		if(!(lfb = (unsigned char*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0)))
		{
			printf("Clock <mapping of Framebuffer failed>\n");
			return -1;
		}

	//init fontlibrary

		if((error = FT_Init_FreeType(&library)))
		{
			printf("Clock <FT_Init_FreeType failed with Errorcode 0x%.2X>", error);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_Manager_New(library, 1, 2, 0, &MyFaceRequester, NULL, &manager)))
		{
			printf("Clock <FTC_Manager_New failed with Errorcode 0x%.2X>\n", error);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_SBitCache_New(manager, &cache)))
		{
			printf("Clock <FTC_SBitCache_New failed with Errorcode 0x%.2X>\n", error);
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_Manager_Lookup_Face(manager, FONT, &face)))
		{
			printf("Clock <FTC_Manager_Lookup_Face failed with Errorcode 0x%.2X>\n", error);
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		use_kerning = FT_HAS_KERNING(face);

#ifdef FT_NEW_CACHE_API
		desc.face_id = FONT;
		desc.flags = FT_LOAD_MONOCHROME;
#else
		desc.font.face_id = FONT;
		desc.image_type = ftc_image_mono;
#endif
		if(!(lbb = malloc(var_screeninfo.xres*var_screeninfo.yres)))
		{
			printf("Clock <allocating of Backbuffer failed>\n");
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		memset(lbb, 0, var_screeninfo.xres*var_screeninfo.yres);

		startx = sx;
		starty = sy;
		xstep/=(double)slow;
		ystep/=(double)slow;
		
		InitRC();

	while(loop)
	{
		usleep(15000L);
		ioctl(fb, FBIOGETCMAP, &colormap);
		found=0;
		trnsp=0;
		for(i=colormap.start;i<colormap.len && found!=7;i++)
		{
			if(!colormap.red[i] && !colormap.green[i] && !colormap.blue[i] && !colormap.transp[i])
			{
				cmc=i;
				found|=1;
			}
			if(colormap.red[i]>=0xF000 && colormap.green[i]>=0xF000  && colormap.blue[i]>=0xF000 && !colormap.transp[i])
			{
				cmct=i;
				found|=2;
			}
			if(colormap.transp[i]>trnsp)
			{
				trnspi=i;
				trnsp=colormap.transp[i];
				found|=4;
			}
		}
		if(first)
		{
			first=0;
			memset(lbb, (bcol==0)?trnspi:((bcol==1)?cmc:cmct), var_screeninfo.xres*var_screeninfo.yres);
			memset(lfb, (bcol==0)?trnspi:((bcol==1)?cmc:cmct), var_screeninfo.xres*var_screeninfo.yres);
		}
		if(big)
		{
			x0=3;
			x1=14;
			x2=26;
			x3=BIG;
			x4=30;
			x5=60;
		}
		else
		{
			x0=7;
			x1=12;
			x2=18;
			x3=MED;
			x4=18;
			x5=40;
		}
		x6=0;
		x7=0;
		time(&atim);
		ltim=localtime(&atim);
		if(secs)
		{
			sprintf(tstr,"%02d:%02d:%02d",ltim->tm_hour,ltim->tm_min,ltim->tm_sec);
		}
		else
		{
			sprintf(tstr,"   %02d%c%02d",ltim->tm_hour,(ltim->tm_sec & 1)?':':' ',ltim->tm_min);
			if(!sdat)
			{
				x6=3;
				x7=36+4*big;
			}
		}

		xpos+=xstep*(double)xdir;
		ypos+=ystep*(double)ydir;

		csx=xpos+x7;
		csy=ypos;
		cex=xpos+x7+100+20*big;
		cey=ypos+x2+2*(1+big)+sdat*x4;
		if(csx<0 || (sx+cex)>=ex)
		{
			xdir*=-1;
			xpos+=xstep*(double)xdir;
			csx=xpos+x7;
			cex=xpos+x7+100+20*big;
			xstep=rand()&3;
			if(!xstep)
			{
				xstep=1;
			}
			xstep/=(double)slow;
		}
		if(csy<0 || (sy+cey)>=ey)
		{
			ydir*=-1;
			ypos+=ystep*(double)ydir;
			csy=ypos;
			cey=ypos+x2+2*(1+big)+sdat*x4;
			ystep=rand()&3;
			if(!ystep || (ystep==3 && ydir==1))
			{
				ystep=1;
			}
			ystep/=(double)slow;
		}

		for(i=x6; i<strlen(tstr); i++)
		{
			*dstr=tstr[i];
			RenderString(dstr, xpos-x0+(i*x1), ypos+x2, 30, CENTER, x3, (fcol==0)?trnspi:((fcol==2)?cmct:cmc));
		}

		if(sdat)
		{
			sprintf(tstr,"%02d.%02d.%02d",ltim->tm_mday,ltim->tm_mon+1,ltim->tm_year-100);
			for(i=0; i<strlen(tstr); i++)
			{
				*dstr=tstr[i];
				RenderString(dstr, xpos-x0+(i*x1), ypos+x5-2-2*big, 30, CENTER, x3, (fcol==0)?trnspi:((fcol==2)?cmct:cmc));
			}
		}

		for(i=0;i<=((sdat)?40:20)*(1+big);i++)
		{
			j=(starty+ypos+i)*var_screeninfo.xres+xpos+startx;
			if((j+100+20*big)<var_screeninfo.xres*var_screeninfo.yres)
			{
				memcpy(lfb+j, lbb+j, 100+20*big);
			}
		}
		
		RenderBox(csx, csy, cex, cey, FILL, (bcol==0)?trnspi:((bcol==1)?cmc:cmct));

		if(++loop>10)
		{
			if(RCKeyPressed()||ExistFile("/tmp/.ssaver_kill"))
			{
				loop=0;
			}
		}	
	}	

	cmct=0;
	cmc=0;
	for(i=colormap.start;i<colormap.len;i++)
	{
		if(colormap.transp[i]>cmct)
		{
			cmc=i;
			cmct=colormap.transp[i];
		}
	}
	memset(lfb, cmc, var_screeninfo.xres*var_screeninfo.yres);
	FTC_Manager_Done(manager);
	FT_Done_FreeType(library);

	free(lbb);
	munmap(lfb, fix_screeninfo.smem_len);

	close(fb);
	CloseRC();
	remove("/tmp/.ssaver_kill");
	return 0;
}
Ejemplo n.º 30
0
inline void
AirspaceIntersectionVisitorSlice::Render(const AbstractAirspace &as) const
{
  AirspaceClass type = as.GetType();

  // No intersections for this airspace
  if (intersections.empty())
    return;

  PixelRect rcd;
  // Calculate top and bottom coordinate
  rcd.top = chart.ScreenY(as.GetTopAltitude(state));
  if (as.IsBaseTerrain())
    rcd.bottom = chart.ScreenY(fixed(0));
  else
    rcd.bottom = chart.ScreenY(as.GetBaseAltitude(state));

  int min_x = 1024, max_x = 0;

  // Iterate through the intersections
  for (const auto &i : intersections) {
    const GeoPoint &p_start = i.first;
    const GeoPoint &p_end = i.second;

    rcd.left = chart.ScreenX(start.Distance(p_start));

    // only one edge found, next edge must be beyond screen
    if (p_start == p_end)
      rcd.right = chart.ScreenX(chart.GetXMax());
    else
      rcd.right = chart.ScreenX(start.Distance(p_end));

    if (rcd.left < min_x)
      min_x = rcd.left;

    if (rcd.right > max_x)
      max_x = rcd.right;

    // Draw the airspace
    RenderBox(rcd, type);
  }

  min_x += Layout::GetTextPadding();
  max_x -= Layout::GetTextPadding();

  /* draw the airspace name */
  const TCHAR *name = as.GetName();
  if (name != nullptr && !StringIsEmpty(name) && min_x < max_x) {
    canvas.SetBackgroundTransparent();
    canvas.SetTextColor(COLOR_BLACK);

    const unsigned max_width = max_x - min_x;

    const PixelSize name_size = canvas.CalcTextSize(name);
    const int x = unsigned(name_size.cx) >= max_width
      ? min_x
      : (min_x + max_x - name_size.cx) / 2;
    const int y = (rcd.top + rcd.bottom - name_size.cy) / 2;

    canvas.DrawClippedText(x, y, max_x - x, name);
  }
}