Exemplo n.º 1
0
// enter shell state
void EnterShellState()
{
	// set up drawlists
	InitDrawlists();

	// create default font
	CreateDefaultFont();

	// clear the screen
	glClear(
		GL_COLOR_BUFFER_BIT
#ifdef ENABLE_DEPTH_TEST
		| GL_DEPTH_BUFFER_BIT
#endif
		);

	// show back buffer
	Platform::Present();

	// reset simulation timer
	sim_rate = float(SIMULATION_RATE);
	sim_step = 1.0f / sim_rate;
	sim_turn = 0;
	sim_fraction = 1.0f;

	// input binding
	InitInput(INPUT_CONFIG.c_str());

	// level configuration
	InitLevel("shell.xml");

	// create options overlay
	shellmenu.mActive = NULL;
	shellmenu.Push(&shellmenumainpage);
	Overlay *options = new Overlay(0xef286ca5 /* "options" */);
	Database::overlay.Put(0xef286ca5 /* "options" */, options);
	options->SetAction(Overlay::Action(RenderShellOptions));
	options->Show();

	// start audio
	Sound::Resume();

	// play the startup sound (HACK)
	PlaySoundCue(0x94326baa /* "startup" */);

	// set to runtime mode
	runtime = true;
}
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPWSTR    lpCmdLine,
                     _In_ int       nCmdShow){
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

	hFont = CreateDefaultFont(-14, loadfontname("tech\\font").c_str());
	religion = new std::vector<std::string>(50);
	pattern = new std::vector<std::string>(20);
	weapon = new std::vector<std::string>(20);
	legacy = new std::vector<std::string>(50);
	interfacev = new std::vector<std::string>(10);
	database = new std::vector<hero>();

    LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
    LoadStringW(hInstance, IDC_TESROLEGENERATOR, szWindowClass, MAX_LOADSTRING);
    MyRegisterClass(hInstance);
    if (!InitInstance (hInstance, nCmdShow)) { return FALSE; }
    HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_TESROLEGENERATOR));
    MSG msg;
    while (GetMessage(&msg, nullptr, 0, 0))  { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } }
    return (int) msg.wParam;
}
Exemplo n.º 3
0
Arquivo: file.c Projeto: thequux/pcb
/* ---------------------------------------------------------------------------
 * load PCB
 * parse the file with enabled 'PCB mode' (see parser)
 * if successful, update some other stuff
 */
int
LoadPCB (char *Filename)
{
  PCBTypePtr newPCB = CreateNewPCB (false);
  PCBTypePtr oldPCB;
  bool units_mm;
#ifdef DEBUG
  double elapsed;
  clock_t start, end;

  start = clock ();
#endif

  oldPCB = PCB;
  PCB = newPCB;

  /* new data isn't added to the undo list */
  if (!ParsePCB (PCB, Filename))
    {
      RemovePCB (oldPCB);

      CreateNewPCBPost (PCB, 0);
      ResetStackAndVisibility ();

      /* update cursor location */
      Crosshair.X = MAX (0, MIN (PCB->CursorX, (LocationType) PCB->MaxWidth));
      Crosshair.Y =
	MAX (0, MIN (PCB->CursorY, (LocationType) PCB->MaxHeight));

      Xorig = Crosshair.X - TO_PCB (Output.Width / 2);
      Yorig = Crosshair.Y - TO_PCB (Output.Height / 2);

      /* update cursor confinement and output area (scrollbars) */
      ChangePCBSize (PCB->MaxWidth, PCB->MaxHeight);

      /* create default font if necessary */
      if (!PCB->Font.Valid)
	{
	  Message (_
		   ("File '%s' has no font information, using default font\n"),
		   Filename);
	  CreateDefaultFont ();
	}

      /* clear 'changed flag' */
      SetChangedFlag (false);
      PCB->Filename = strdup (Filename);
      /* just in case a bad file saved file is loaded */

      units_mm = (PCB->Grid != (int) PCB->Grid) ? true : false;

      Settings.grid_units_mm = units_mm;

      sort_netlist ();

      set_some_route_style ();

      hid_action ("PCBChanged");

#ifdef DEBUG
      end = clock ();
      elapsed = ((double) (end - start)) / CLOCKS_PER_SEC;
      gui->log ("Loading file %s took %f seconds of CPU time\n",
		Filename, elapsed);
#endif

      return (0);
    }
  PCB = oldPCB;
  hid_action ("PCBChanged");

  /* release unused memory */
  RemovePCB (newPCB);
  return (1);
}
Exemplo n.º 4
0
/*!
 * \brief Creates a new PCB.
 */
PCBType *
CreateNewPCB (void)
{
  PCBType *ptr;
  int i;

  /* allocate memory, switch all layers on and copy resources */
  ptr = (PCBType *)calloc (1, sizeof (PCBType));
  ptr->Data = CreateNewBuffer ();
  ptr->Data->pcb = (PCBType *) ptr;
  ptr->Data->polyClip = 1;

  ptr->ThermStyle = 4;
  ptr->IsleArea = 2.e8;
  ptr->SilkActive = false;
  ptr->RatDraw = false;
  SET_FLAG (NAMEONPCBFLAG, ptr);
  if (Settings.ShowNumber)
    SET_FLAG (SHOWNUMBERFLAG, ptr);
  if (Settings.AllDirectionLines)
    SET_FLAG (ALLDIRECTIONFLAG, ptr);
  ptr->Clipping = 1;		/* this is the most useful starting point for now */
  if (Settings.RubberBandMode)
    SET_FLAG (RUBBERBANDFLAG, ptr);
  if (Settings.SwapStartDirection)
    SET_FLAG (SWAPSTARTDIRFLAG, ptr);
  if (Settings.UniqueNames)
    SET_FLAG (UNIQUENAMEFLAG, ptr);
  if (Settings.SnapPin)
    SET_FLAG (SNAPPINFLAG, ptr);
  if (Settings.ClearLine)
    SET_FLAG (CLEARNEWFLAG, ptr);
  if (Settings.FullPoly)
    SET_FLAG (NEWFULLPOLYFLAG, ptr);
  if (Settings.OrthogonalMoves)
    SET_FLAG (ORTHOMOVEFLAG, ptr);
  if (Settings.liveRouting)
    SET_FLAG (LIVEROUTEFLAG, ptr);
  if (Settings.ShowDRC)
    SET_FLAG (SHOWDRCFLAG, ptr);
  if (Settings.AutoDRC)
    SET_FLAG (AUTODRCFLAG, ptr);
  ptr->Grid = Settings.Grid;
  ptr->LayerGroups = Settings.LayerGroups;
  STYLE_LOOP (ptr);
  {
    *style = Settings.RouteStyle[n];
    style->index = n;
  }
  END_LOOP;
  ptr->MaxWidth = Settings.MaxWidth;
  ptr->MaxHeight = Settings.MaxHeight;
  ptr->ID = ID++;
  ptr->ThermScale = 0.5;

  ptr->Bloat = Settings.Bloat;
  ptr->Shrink = Settings.Shrink;
  ptr->minWid = Settings.minWid;
  ptr->minSlk = Settings.minSlk;
  ptr->minDrill = Settings.minDrill;
  ptr->minRing = Settings.minRing;

  for (i = 0; i < MAX_LAYER; i++)
    ptr->Data->Layer[i].Name = strdup (Settings.DefaultLayerName[i]);

	CreateDefaultFont (ptr);

  return (ptr);
}
Exemplo n.º 5
0
LRESULT CInformationPanel::OnMessage(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
	switch (uMsg) {
	case WM_CREATE:
		{
			InitializeUI();

			if (!m_Font.IsCreated())
				CreateDefaultFont(&m_Font);
			m_BackBrush.Create(m_Theme.Style.Back.Fill.GetSolidColor());
			m_ProgramInfoBackBrush.Create(m_Theme.ProgramInfoStyle.Back.Fill.GetSolidColor());
			CalcFontHeight();

			m_HotButton=-1;

			CProgramInfoItem *pProgramInfoItem=
				static_cast<CProgramInfoItem*>(GetItem(ITEM_PROGRAMINFO));
			CreateProgramInfoEdit();
			if (pProgramInfoItem->IsVisible())
				::ShowWindow(m_hwndProgramInfo,SW_SHOW);
		}
		return 0;

	HANDLE_MSG(hwnd,WM_COMMAND,OnCommand);

	case WM_SIZE:
		if (IsItemVisible(ITEM_PROGRAMINFO)) {
			RECT rc;

			GetItemRect(ITEM_PROGRAMINFO,&rc);
			TVTest::Theme::SubtractBorderRect(m_Theme.ProgramInfoStyle.Back.Border,&rc);
			::MoveWindow(m_hwndProgramInfo,rc.left,rc.top,
						 rc.right-rc.left,rc.bottom-rc.top,TRUE);
		}
		return 0;

	case WM_PAINT:
		{
			PAINTSTRUCT ps;

			::BeginPaint(hwnd,&ps);
			Draw(ps.hdc,ps.rcPaint);
			::EndPaint(hwnd,&ps);
		}
		return 0;

	case WM_CTLCOLORSTATIC:
		{
			HDC hdc=reinterpret_cast<HDC>(wParam);

			::SetTextColor(hdc,m_Theme.ProgramInfoStyle.Fore.Fill.GetSolidColor());
			::SetBkColor(hdc,m_Theme.ProgramInfoStyle.Back.Fill.GetSolidColor());
			return reinterpret_cast<LRESULT>(m_ProgramInfoBackBrush.GetHandle());
		}

	case WM_LBUTTONDOWN:
		{
			int Button=ButtonHitTest(GET_X_LPARAM(lParam),GET_Y_LPARAM(lParam));

			if (Button>=0) {
				SetHotButton(Button);
				::SetCapture(hwnd);
			}
		}
		return 0;

	case WM_LBUTTONUP:
		if (::GetCapture()==hwnd) {
			if (m_HotButton>=0) {
				SetHotButton(ButtonHitTest(GET_X_LPARAM(lParam),GET_Y_LPARAM(lParam)));

				switch (m_HotButton) {
				case BUTTON_PROGRAMINFOPREV:
					::SendMessage(hwnd,WM_COMMAND,CM_PROGRAMINFOPREV,0);
					break;
				case BUTTON_PROGRAMINFONEXT:
					::SendMessage(hwnd,WM_COMMAND,CM_PROGRAMINFONEXT,0);
					break;
				}
			}

			::ReleaseCapture();
		}
		return 0;

	case WM_RBUTTONUP:
		{
			HMENU hmenu;
			POINT pt;

			hmenu=::LoadMenu(m_hinst,MAKEINTRESOURCE(IDM_INFORMATIONPANEL));
			for (int i=0;i<NUM_ITEMS;i++)
				CheckMenuItem(hmenu,CM_INFORMATIONPANEL_ITEM_FIRST+i,
							  MF_BYCOMMAND | (IsItemVisible(i)?MFS_CHECKED:MFS_UNCHECKED));
			pt.x=GET_X_LPARAM(lParam);
			pt.y=GET_Y_LPARAM(lParam);
			::ClientToScreen(hwnd,&pt);
			::TrackPopupMenu(::GetSubMenu(hmenu,0),TPM_RIGHTBUTTON,pt.x,pt.y,0,hwnd,NULL);
			::DestroyMenu(hmenu);
		}
		return TRUE;

	case WM_MOUSEMOVE:
		{
			SetHotButton(ButtonHitTest(GET_X_LPARAM(lParam),GET_Y_LPARAM(lParam)));

			if (::GetCapture()==NULL) {
				TRACKMOUSEEVENT tme;
				tme.cbSize=sizeof(TRACKMOUSEEVENT);
				tme.dwFlags=TME_LEAVE;
				tme.hwndTrack=hwnd;
				::TrackMouseEvent(&tme);
			}
		}
		return 0;

	case WM_MOUSELEAVE:
	case WM_CAPTURECHANGED:
		if (m_HotButton>=0)
			SetHotButton(-1);
		return 0;

	case WM_SETCURSOR:
		if ((HWND)wParam==hwnd) {
			if (LOWORD(lParam)==HTCLIENT && m_HotButton>=0) {
				::SetCursor(GetActionCursor());
				return TRUE;
			}
		} else if ((HWND)wParam==m_hwndProgramInfo
				&& LOWORD(lParam)==HTCLIENT
				&& m_fUseRichEdit
				&& m_fProgramInfoCursorOverLink) {
			::SetCursor(GetLinkCursor());
			return TRUE;
		}
		break;

	case WM_NOTIFY:
		switch (reinterpret_cast<LPNMHDR>(lParam)->code) {
		case EN_MSGFILTER:
			{
				MSGFILTER *pMsgFilter=reinterpret_cast<MSGFILTER*>(lParam);

				switch (pMsgFilter->msg) {
				case WM_RBUTTONUP:
					TVTest::EventInfoUtil::EventInfoContextMenu(hwnd,m_hwndProgramInfo);
					break;

				case WM_LBUTTONDOWN:
					m_ProgramInfoClickPos.x=GET_X_LPARAM(pMsgFilter->lParam);
					m_ProgramInfoClickPos.y=GET_Y_LPARAM(pMsgFilter->lParam);
					break;

				case WM_MOUSEMOVE:
					m_ProgramInfoClickPos.x=-1;
					m_ProgramInfoClickPos.y=-1;
					{
						POINT pt={GET_X_LPARAM(pMsgFilter->lParam),GET_Y_LPARAM(pMsgFilter->lParam)};

						if (CRichEditUtil::LinkHitTest(m_hwndProgramInfo,pt,m_ProgramInfoLinkList)>=0) {
							m_fProgramInfoCursorOverLink=true;
							::SetCursor(GetLinkCursor());
						} else {
							m_fProgramInfoCursorOverLink=false;
						}
					}
					break;

				case WM_LBUTTONUP:
					{
						POINT pt={GET_X_LPARAM(pMsgFilter->lParam),GET_Y_LPARAM(pMsgFilter->lParam)};

						if (m_ProgramInfoClickPos.x==pt.x && m_ProgramInfoClickPos.y==pt.y)
							CRichEditUtil::HandleLinkClick(m_hwndProgramInfo,pt,m_ProgramInfoLinkList);
					}
					break;
				}
			}
			return 0;

#if 0
		case EN_LINK:
			{
				ENLINK *penl=reinterpret_cast<ENLINK*>(lParam);

				if (penl->msg==WM_LBUTTONUP)
					CRichEditUtil::HandleLinkClick(penl);
			}
			return 0;
#endif
		}
		break;

	case WM_DISPLAYCHANGE:
		m_Offscreen.Destroy();
		return 0;

	case WM_DESTROY:
		m_BackBrush.Destroy();
		m_ProgramInfoBackBrush.Destroy();
		m_Offscreen.Destroy();
		m_hwndProgramInfo=NULL;
		return 0;
	}

	return ::DefWindowProc(hwnd,uMsg,wParam,lParam);
}