//--------------------------------------------------------------
void ofxMtlMapping2DPolygon::setAsIdle()
{
    disable();
    disableVertices();
}
Example #2
0
void InspectorWorkerAgent::clearFrontend()
{
    m_state->setBoolean(WorkerAgentState::autoconnectToWorkers, false);
    disable(0);
    m_inspectorFrontend = 0;
}
/*-----------------------------------------------------------*/
void vHTTPTask( void * pvParameters )
{
short i, sLen;
unsigned char ucState;

	( void ) pvParameters;

    /* Create the semaphore used to communicate between this task and the
    WIZnet ISR. */
    vSemaphoreCreateBinary( xTCPSemaphore );

	/* Make sure everything is setup before we start. */
	prvNetifInit();
	prvHTTPInit();

	for( ;; )
	{
		/* Wait until the ISR tells us there is something to do. */
    	xSemaphoreTake( xTCPSemaphore, portMAX_DELAY );

		/* Check each socket. */
		for( i = 0; i < httpSOCKET_NUM; i++ )
		{
			ucState = select( i, SEL_CONTROL );

			switch (ucState)
			{
				case SOCK_ESTABLISHED :  /* new connection established. */

					if( ( sLen = select( i, SEL_RECV ) ) > 0 )
					{
						if( sLen > httpSOCKET_BUFFER_SIZE )
						{
							sLen = httpSOCKET_BUFFER_SIZE;
						}

						disable();

						sLen = recv( i, ucSocketBuffer, sLen );

						if( ucConnection[ i ] == 1 )
						{
							/* This is our first time processing a HTTP
							 request on this connection. */
							prvTransmitHTTP( i );
							ucConnection[i] = 0;
						}
						enable();
					}
					break;

				case SOCK_CLOSE_WAIT :

					close(i);
					break;

				case SOCK_CLOSED :

					ucConnection[i] = 1;
					socket( i, SOCK_STREAM, 80, 0x00 );
					NBlisten( i ); /* reinitialize socket. */
					break;
			}
		}
	}
}
Example #4
0
void PageRuntimeAgent::clearFrontend()
{
    m_frontend = 0;
    String errorString;
    disable(&errorString);
}
Example #5
0
thread test_recursion(bool verbose)
{
    tid_typ atid, btid, ctid, dtid, i, j;
    bool passed = TRUE;
    uchar testArray[4 * 2 * TIMES];
    uchar expectedResults[4 * 2 * TIMES];
    char str[50];
    int index = 0;
    int btid_remaining, dtid_remaining;

    /* reset the number of calls to `t5` */
    calls = 0;

    /* disable interrupts to prevent a preemption from launching a 
     * lower-priority thread before the higher-priority ones are created */
    disable();

    ready(atid = create((void *)t5, INITSTK, 31, "RECURSION-A",
                        3, TIMES, testArray, &index), 0);
    ready(btid = create((void *)t5, INITSTK, 32, "RECURSION-B",
                        3, TIMES, testArray, &index), 0);
    ready(ctid = create((void *)t5, INITSTK, 34, "RECURSION-C",
                        3, TIMES, testArray, &index), 0);
    ready(dtid = create((void *)t5, INITSTK, 32, "RECURSION-D",
                        3, TIMES, testArray, &index), 0);

    /* Run the tests by yielding the processor */
    yield();

    /* Generate expected results and compare */

    for (i = 0, j = TIMES; i < 2 * TIMES; i += 2, j--)
    {
        expectedResults[i] = ctid;
        expectedResults[i + 1] = j;
    }

    /* Since threads may be rescheduled before they can disable interrupts, the
     * exact order than threads B and D, which have equal priority, execute in
     * is unpredictable.  To avoid spurious test failures, we accept them
     * executing in any order.  */
    btid_remaining = TIMES;
    dtid_remaining = TIMES;
    for (i = TIMES * 2; i < 6 * TIMES; i += 2)
    {
        if (testArray[i] == btid && btid_remaining > 0) {
            expectedResults[i] = btid;
            expectedResults[i + 1] = btid_remaining;
            btid_remaining--;
        } else {
            expectedResults[i] = dtid;
            expectedResults[i + 1] = dtid_remaining;
            dtid_remaining--;
        }
    }


    for (i = 6 * TIMES, j = TIMES; i < 8 * TIMES; i += 2, j--)
    {
        expectedResults[i] = atid;
        expectedResults[i + 1] = j;
    }

    for (i = 0; i < 8 * TIMES; i++)
    {
        if (expectedResults[i] != testArray[i])
        {
            passed = FALSE;
            sprintf(str, "Expected testArray[%d] == %d, not %d\n",
                    i, expectedResults[i], testArray[i]);
            testFail(verbose, str);
        }
    }

    /* t5 should be called (4 threads * NTIMES) = 20 times */
    testPrint(verbose, "Checking number of recursive calls");
    failif(calls != 20, "called `t5` excessivly");

    if (TRUE == passed)
    {
        testPass(TRUE, "");
    }
    else
    {
        testFail(TRUE, "");
    }

    return OK;
}
Example #6
0
void InspectorHeapAgent::willDestroyFrontendAndBackend(DisconnectReason)
{
    ErrorString ignored;
    stopTracking(ignored);
    disable(ignored);
}
Example #7
0
syscall	kill(
	  pid32		pid		/* ID of process to kill	*/
	)
{
	intmask	mask;			/* Saved interrupt mask		*/
	int32	i;			/* Index into descriptors	*/
	struct	procent *prptr = &proctab[currpid];		/* Ptr to process' table entry	*/\
	struct memblkentry *prevmemblkptr = prptr->prmemblklist;
	struct memblkentry *memblkptr =  prevmemblkptr->next;

	//kprintf("in here homie bad zone\n");

	mask = disable();
	if (isbadpid(pid) || (pid == NULLPROC)
	    || ((prptr = &proctab[pid])->prstate) == PR_FREE) {
		restore(mask);
		return SYSERR;
	}
	
	while(memblkptr != NULL){
		prevmemblkptr = memblkptr;
		memblkptr = memblkptr->next;
	}

	//kprintf("prptr->prmemblklist->size before :%d\n",prptr->prmemblklist->size);
	prevmemblkptr->size = 0;
	prptr->prmemblklist->size = prevmemblkptr->size;
	prevmemblkptr->next = NULL;
	//kprintf("prptr->prmemblklist->size after :%d\n",prptr->prmemblklist->size);
	

	if (--prcount <= 1) {		/* Last user process completes	*/
		xdone();
	}

	send(prptr->prparent, pid);
	for (i=0; i<3; i++) {
		close(prptr->prdesc[i]);
	}
	freestk(prptr->prstkbase, prptr->prstklen);

	switch (prptr->prstate) {
	case PR_CURR:
		prptr->prstate = PR_FREE;	/* Suicide */
		resched();

	case PR_SLEEP:
	case PR_RECTIM:
		unsleep(pid);
		prptr->prstate = PR_FREE;
		break;

	case PR_WAIT:
		semtab[prptr->prsem].scount++;
		/* Fall through */

	case PR_READY:
		getitem(pid);		/* Remove from queue */
		/* Fall through */

	default:
		prptr->prstate = PR_FREE;
	}

	kprintf("prptr->prmemblklist->size %d\n",prevmemblkptr->size);
	restore(mask);
	return OK;
}
Example #8
0
void IOEventSource::setWorkLoop(IOWorkLoop *inWorkLoop)
{
    if ( !inWorkLoop )
        disable();
    workLoop = inWorkLoop;
}
Example #9
0
Frame::Frame() : EventListener(2)
{
	rootWidget = new RootWidget();
	disable();
}
Example #10
0
/* style 2: baud=... parity=... data=... stop=... retry=... */
int serial(int snum, char * what)
{
  unsigned int xbaud, baud, xparity, data, stop, xretry;
  char parity, retry;

#ifdef DMODE
  static long int baudlist[] = { 110, 150, 300, 600,
    1200, 2400, 4800, 9600,   19200, 38400L, 57600L, 115200L
  }; /* baudlist */
#endif

  if ( (what == NULL) || (!strncmp(what, "/STA", 4)) ) {
    int i;
    static char * serbits[] = {
      "delta-CTS", "delta-DSR", "RI-trail", "delta-CD",
      "CTS", "DSR", "RI", "CD",
      /* modem: cleartosend, datasetready, ringindicator, carrierdetect */
      "data-received", "overrun", "parity-error", "frame-error",
      "break-received", "xmit-hold-empty", "xmit-shift-empty", "timeout"
    }; /* serbits */
    printf("*** SERIAL PORT %d STATUS ***\r\n", snum+1);

    r.x.ax = 0x0300; /* read status */
    r.x.dx = snum;
    int86(0x14, &r, &r);
    printf("Port status: [ ");
    for (i=15; i>=0; i--) {
      if ( (r.x.ax & (1<<i)) != 0)
        printf("%s ", serbits[i]);
    }
    printf("]\r\n");

#ifndef DMODE2 /* Tell about BAUDHARD=1 only if /STA... given, unless DMODE2 */
    if ( (what != NULL) && (!strncmp(what, "/STA", 4)) ) {
#else
    {
#endif
      printf("Use MODE COM%d BAUDHARD=1 to read *configuration* from UART.\r\n",
        snum+1);
    }

    return 0;
  }

  if (strchr(what,'=') != NULL) {
    baud   = grabarg(what, "BAUD=");
    xbaud   = grabarg(what, "BAUDHARD="); /* new 4/2004 */
    xparity = grabarg(what, "PARITY=");
    data   = grabarg(what, "DATA=");
    stop   = grabarg(what, "STOP=");
    xretry  = grabarg(what, "RETRY=");
  } else {
    what = skipspace(what);
    if ( (what[0]!=',') && (!isdigit(what[0])) ) {
      printf("Syntax error in 'MODE COMn ...', please check 'MODE /?'.\r\n");
      return 1;
    }
    baud   = posarg(what, 0);
    xbaud = 0;
    xparity = posarg(what, 1);
    data   = posarg(what, 2);
    stop   = posarg(what, 3);
    xretry  = posarg(what, 4);
  }

  if ( (baud==0) && (xparity==0) && (data==0) && (stop==0) && (xretry==0)
    && (xbaud==0) ) {
    printf("Syntax error in 'MODE COMn ...', please check 'MODE /?'.\r\n");
    return 1;
  }

  if ( (data>8) || ((data<5) && (data!=0)) ) {
    printf("Data bits must be 5, 6, 7 or 8.\r\n");
    return 1; /* failed */
  }

  if ( (stop>2) || (stop<0) ) {
    printf("Stop bits must be 1 or 2.\r\n");
    printf("(2 stopbits treated as 1.5 if 5 or 6 data bits).\r\n");
    return 1; /* failed */
  }

  retry = (char)xretry;
  xretry = xlatretry(retry);
  if (xretry<0) return 1; /* error */
  if ((xretry==2) || (xretry==3)) /* if busy: 0 busy  1 error  2 ready */
                                  /*          3 keep trying 4 no retry */
    printf("Not yet supported RETRY value - ignored.\r\n");
    /* Reason: We do not hook int 14h at all (yet) ;-) ! */

  parity = (char)xparity;
  switch (parity) {
    case 'N':
      xparity = 0; /* none */
      break;
    case 'O':
      xparity = 1; /* odd */
      break;
    case 'E':
      xparity = 2; /* even (3 for old style API) */
      break;
    case 'S':
      xparity = 3; /* space? (new style API only) */
      break;
    case 'M':
      xparity = 4; /* mark? (new style API only) */
      break;
    case 0:
      xparity = 0; /* default parity setting: no parity */
      parity = '-';
      break;
    default:
      printf("Parity must be N, O, E, S or M (none, odd, even, space, mark).\r\n");
      return 1; /* failed */
  } /* switch */

  if (stop==0)
    stop = (baud==110) ? 2 : 1; /* default number of stop bits */

  if ((baud % 10) == 0) baud /= 10; /* strip at most 2 trailing zeroes */
  if ((baud % 10) == 0) baud /= 10; /* strip at most 2 trailing zeroes */

  switch (baud) {
    case 11:  /*   110 (caveat: 11 could also abbreviate 115200 (*)) */
      baud = 0;
      break;
    case 15:  /*   150 */
      baud = 1;
      break;
    case 3:   /*   300 (caveat: 3 could also abbreviate 38400 (*)) */
      baud = 2;
      break;
    case 6:   /*   600 (*) */
      baud = 3;
      break;
    case 12:  /*  1200 */
      baud = 4;
      break;
    case 0: /* default baud value is 2400 in most DOS versions */
    case 24:  /*  2400 */
      baud = 5;
      break;
    case 48:  /*  4800 */
      baud = 6;
      break;
    case 96:  /*  9600 */
      baud = 7;
      break;
    /* 14400 ??? */
    case 19:  /* 19200 */
    case 192:
      baud = 8; /* from here on we have to use the new API */
      break;
    /* 28800 ??? */
    case 38:  /* 38400 (supported?) */
    case 384:
      baud = 9;
      break;
    case 57:  /* 57600 (supported?) */
    case 576:
      baud = 10;
      break;
    case 115: /* 115200 (supported?) */
    case 1152:
    case 0xc200: /* 115200 & 0xffff */
      baud = 11;
      break;
    default:
      printf("BIOS-Unsupported baud rate, sorry.\r\n");
      printf("Please use BAUDHARD=value, with value=baud rate / 100\r\n");
      printf("e.g. BAUDHARD=1152 for 115200 baud, to program baud rate\r\n");
      printf("directly into UART hardware. BAUDHARD=1 reads UART config!\r\n");
      return 1;
  } /* switch */
  if ((baud > 8) && (baud < 12)) {
    printf("If your BIOS fails to set this baud rate properly, try\r\n");
    printf("using BAUDHARD=%d instead to program UART hardware directly.\r\n",
      (baud>9) ? ((baud==11) ? 1152 : 576) : 384);
  }

  /* (*) MS MODE only allows full values or 2 or 3 digit abbreviations, */
  /*  while we also allow "omit trailing zeroes" style 1 digit abbrev.! */

  if (data==0)
    data = 8; /* default number of data bits */

  r.x.dx = snum; /* port number */
  if ( (baud > 7) || (xparity > 2) ) { /* need new API? */
    r.x.ax = 0x0401; /* extended setup, no break */
    r.h.bh = xparity;
    r.h.bl = stop-1; /* 0 means 1, 1 means 2 (1.5 if 5 data bits) stop bits */
    r.h.ch = data-5; /* 0..3 means 5..8 data bits */
    r.h.cl = baud;   /* baud rate selector, values 0..8 same for all BIOSes */
    if (xbaud!=1)   /* do not SET before READING config! */
      int86(0x14, &r, &r);
    if (r.x.ax == 0x1954) { /* we got "FOSSIL init successful" */
                            /* which means that BX / CX had no effect */
      printf("FOSSIL driver detected, MODE could not configure port!\r\n");
      printf("You can use MODE with FOSSIL for max 9600 baud / normal parity only.\r\n");
    }
    if (r.x.ax == 0xaa55) {
      printf("MBBIOS detected, please use only 110-9600 baud and set\r\n");
      printf("the MBBIOS high speed option to translate to 9600-330400 baud.\r\n");
      r.x.ax = 0x1954;
    }
  } else {
    if (xparity==2)
      xparity=3; /* translate to old style value */
    r.h.ah = 0; /* initialize port */
    r.h.al = (baud<<5) | (xparity<<3) | ((stop-1)<<1) | (data-5);
    if (xbaud!=1)   /* do not SET before READING config! */
      int86(0x14, &r, &r);
  }
  /* returns status in AX */

  if (xbaud) {
    unsigned int sport = peek(0x40, snum+snum);
    unsigned int scratch;

    if (!sport) {
      printf("This serial port has no UART, sorry.\r\n");
      return 1;
    }

    disable();
    scratch = inportb(sport+7);
    outportb(sport+7, 0xea);
    printf("UART is ");
    if (inportb(sport+7) != 0xea) {
      if (xbaud!=1) {
        printf("8250, reading defaults!");
        xbaud = 1;
      } else
        printf("8250.");
    } else {
      outportb(sport+7, scratch);
      printf("16450 or newer."); /* or 8250A */
    }
    enable();

    printf(" %s:\r\n",
      (xbaud==1) ? "Reading parameters" : "Programming baud rate");
    if (xbaud>1152) { /* limit for 1.8432 MHz clock */
      printf("Maximum baud rate is 115200 (BAUDHARD=1152).\r\n");
      xbaud = 1;
    }

    if (xbaud==1) { /* parameter reading */

      /* line control: DLAB break PPP stop WW */
      /* PPP = 1x1 for sticky ~x parity, ??0 for no parity, 0x1 for */
      /* 0 odd / 1 even parity. stop 0 for 1 stop bit, 1 for 1.5 (WW=0) / 2 */
      /* WW 0..3 for 5..8 data bits */
      scratch = inportb(sport+3);
      if (scratch & 0x40) printf(" break,");
      if (scratch & 0x08) {
        printf(" %s parity,", (scratch & 0x20) ?
            ( (scratch & 0x10) ? "sticky low" : "sticky high" ) :
            ( (scratch & 0x10) ? "even" : "odd" ) );
      } else
        printf(" no parity,");
      printf(" %s, %d bit,", ( (scratch & 0x04) ?
          ( (scratch & 0x03) ? "2 stop bits" : "1.5 stop bits" ) :
          "1 stop bit" ),
        5 + (scratch & 0x03) );

      disable();
      outportb(sport+3, inportb(sport+3) | 0x80); /* divisor access */
#ifdef DIVISOR_WORD
      scratch = inport(sport);	/* divisor word */
#else
      scratch = inportb(sport+1); /* high byte */
      scratch <<= 8;
      scratch |= inportb(sport); /* low byte */ /* better read LO before HI? */
#endif
      outportb(sport+3, inportb(sport+3) & 0x7f);
      enable();

      if (scratch) {
        printf(" %ld baud,", 115200UL / scratch);
        xbaud = 1152 / scratch;
      } else {
        printf(" infinite baud rate!?,");
        xbaud = 9999;
      }
      scratch = inportb(sport+4);
      printf(" RTS %s, DTR %s.\r\n",
        ( (scratch & 2) ? "on" : "auto" ),
        ( (scratch & 1) ? "on" : "auto" ) );
      /* Modem control: ? ? (out0) loopback out2=irqenable out1=0 RTS DTR */
      /* (RTS / DTR set means "forced on" instead of "use for handshake") */

    } else {

      /* registers: +0/+1 divisor latch low/high if DLAB=1, +7 scratch...   */
      /* +3 line control +4 modem control +5 line status +6 modem status... */
      scratch = 1152 / xbaud; /* convert into divisor */
      printf(" %ld %s(divisor ", 115200UL / scratch,
        ((115200UL / scratch) != (100UL * xbaud)) ? "(had to round up) " : "" );

      disable();
      outportb(sport+3, inportb(sport+3) | 0x80); /* divisor access */
#ifdef DIVISOR_WORD
      outport(sport, scratch);	/* divisor word */
#else
      outportb(sport, scratch & 0xff); /* low byte */
      outportb(sport+1, scratch >> 8); /* high byte */
#endif
      outportb(sport+3, inportb(sport+3) & 0x7f);
      enable();

      printf("%d).\r\n", scratch);

#if SET_RTS_DTR
      /* to force RTS / DTR to on: */
      outportb(sport+4, inportb(sport+4) | 3);
      printf("Forcing RTS/DTR on.\r\n");
      /* should be done by drivers, e.g. raising on mouse init */
#endif

    } /* baud rate writing */

  } /* direct UART programming: BAUDHARD argument given */

#ifdef DMODE
  printf("MODE COM%d (x)baud=%ld parity=%c data=%d stop=%d (ignored: retry=%c)\r\n",
    snum+1, (xbaud) ? ((long int)xbaud * 100UL) : baudlist[baud],
    parity, data, stop, retry ? retry : '-');
#endif

  /* TODO: send RETRY setting to TSR part */

  return (r.x.ax==0x1954) ? 1 : 0;
} /* serial */
Example #11
0
void Chap9_SetAddress(void)
{

	UCHAR   j;

	{
		RaiseIRQL();
		disable();
		if(!ControlData.Abort)
		{
			if(bUSBCheck_Device_State.State_bits.DEVICE_DEFAULT_STATE)
			{
				if((ControlData.DeviceRequest.wValue & DEVICE_ADDRESS_MASK) != 0 )
				{
					bUSBCheck_Device_State.State_bits.DEVICE_DEFAULT_STATE = 0;
					Hal4D13_SetAddressEnable((UCHAR)(ControlData.DeviceRequest.wValue &
											DEVICE_ADDRESS_MASK), 1);
					bUSBCheck_Device_State.State_bits.DEVICE_ADDRESS_STATE = 1;
					Chap9_SingleTransmitEP0(0, 0);
					printf("addressed");

				}

				else
					bUSBCheck_Device_State.State_bits.DEVICE_DEFAULT_STATE = 1;
			}

			else if(bUSBCheck_Device_State.State_bits.DEVICE_ADDRESS_STATE)
			{
				if((ControlData.DeviceRequest.wValue & DEVICE_ADDRESS_MASK) == 0 )
				{
					Hal4D13_SetAddressEnable((UCHAR)(ControlData.DeviceRequest.wValue &
											DEVICE_ADDRESS_MASK), 1);
					bUSBCheck_Device_State.State_bits.DEVICE_DEFAULT_STATE = 1;
					bUSBCheck_Device_State.State_bits.DEVICE_ADDRESS_STATE = 0;
					Chap9_SingleTransmitEP0(0, 0);

				}

				else
				{
					bUSBCheck_Device_State.State_bits.DEVICE_DEFAULT_STATE = 0;
					Hal4D13_SetAddressEnable((UCHAR)(ControlData.DeviceRequest.wValue &
											DEVICE_ADDRESS_MASK), 1);
					bUSBCheck_Device_State.State_bits.DEVICE_ADDRESS_STATE = 1;
					Chap9_SingleTransmitEP0(0, 0);

				}

			}

			else
			{

				bUSBCheck_Device_State.State_bits.DEVICE_CONFIGURATION_STATE = 0;
				bUSBCheck_Device_State.State_bits.DEVICE_ADDRESS_STATE = 0;
				bUSBCheck_Device_State.State_bits.DEVICE_DEFAULT_STATE = 1;
				j = DEV_BEHAVIOUR_NOT_SPECIFIED;
				Chap9_SingleTransmitEP0(&j, 0);
			}

		}
		LowerIRQL();
		enable();

	}
    //printf("Addr %x\n",Hal4D13_GetAddress());
}
void InspectorDatabaseAgent::willDestroyFrontendAndBackend(Inspector::DisconnectReason)
{
    ErrorString unused;
    disable(unused);
}
Example #13
0
/// DOT_SLIDER class down here
void UI_DOT_SLIDER::create(UI_WINDOW *wnd, int _x, int _y, char *bm, int id, int end_buttons, int _num_pos)
{
	char	filename[MAX_PATH_LEN];
	int	bx, by, bw, hotspot;

	has_end_buttons = end_buttons;

	if ( has_end_buttons ) {
		bx = _x + 24;
		by = _y + 1;
		bw = 190;
		hotspot = id + 1;
	} else {
		bx = _x;
		by = _y;
		bw = 80;
		hotspot = id;
	}

	num_pos = _num_pos;

	sprintf(filename, "%s%0.2d", bm, hotspot);
	first_frame = bm_load_animation(filename, &total_frames);
	if (first_frame < 0) {
		Error(LOCATION, "Could not load %s.ani\n", filename);
		disable();
		hide();
		return;
	}

	base_create(wnd, UI_KIND_DOT_SLIDER, bx, by, bw, 20);
	pos = 0;

	// A DOT_SLIDER has up to 3 child buttons..

	by = _y;

	// First button is the region with the dots
	button.create( wnd, "", bx, by, bw, 20, 0, 1 );
	button.set_parent(this);
	button.link_hotspot(hotspot);
	button.hide();

	if ( has_end_buttons ) {
		// Second button is the up (increase) button
		sprintf(filename, "%s%0.2d", bm, id + 2);
		up_button.create( wnd, "", _x + 216, _y, 22, 24, 1, 1 );
		up_button.set_parent(this);
		up_button.set_highlight_action(common_play_highlight_sound);
		up_button.set_bmaps(filename);
		up_button.link_hotspot(id + 2);

		// Third button is the down (decrease) button
		sprintf(filename, "%s%0.2d", bm, id);
		down_button.create( wnd, "", _x, _y, 22, 24, 1, 1 );
		down_button.set_parent(this);
		down_button.set_highlight_action(common_play_highlight_sound);
		down_button.set_bmaps(filename);
		down_button.link_hotspot(id);
	}
}
Example #14
0
/*------------------------------------------------------------------------
 * kill  --  kill a process and remove it from the system
 *------------------------------------------------------------------------
 */
SYSCALL kill(int pid)
{
	STATWORD ps;    
	struct	pentry	*pptr;		/* points to proc. table for pid*/
	int	dev, i;

	disable(ps);
	if (isbadpid(pid) || (pptr= &proctab[pid])->pstate==PRFREE) {
		restore(ps);
		return(SYSERR);
	}
	if (--numproc == 0)
		xdone();

	dev = pptr->pdevs[0];
	if (! isbaddev(dev) )
		close(dev);
	dev = pptr->pdevs[1];
	if (! isbaddev(dev) )
		close(dev);
	dev = pptr->ppagedev;
	if (! isbaddev(dev) )
		close(dev);
	
	send(pptr->pnxtkin, pid);

	freestk(pptr->pbase, pptr->pstklen);
	switch (pptr->pstate) {

	case PRCURR:	for(i = 0; i < NLOCKS; i ++)
			{
				while(lockholdtab[pid][i] > 0)
					release(pid, locks[i].locknum);
			}
			pptr->pstate = PRFREE;	/* suicide */
			resched();

	case PRWAIT:	semaph[pptr->psem].semcnt++;
		
	case PRLWAIT:	
	case PRREADY:	for(i = 0; i < NLOCKS; i ++)
			{
				while(lockholdtab[pid][i] > 0)
					release(pid, locks[i].locknum);
			}
			dequeue(pid);
			pptr->pstate = PRFREE;
			break;

	case PRSLEEP:
	case PRTRECV:	unsleep(pid);
						/* fall through	*/
	default:	pptr->pstate = PRFREE;
			for(i = 0; i < NLOCKS; i ++)
			{
				while(lockholdtab[pid][i] > 0)
					release(pid, locks[i].locknum);
			}
	}
	restore(ps);
	return(OK);
}
Example #15
0
bool OculusVRDevice::enable()
{
   // Start off with disabling the device if it is already enabled
   disable();

   Con::printf("Oculus VR Device Init:");

   OVR::System::Init(OVR::Log::ConfigureDefaultLog(OVR::LogMask_All));
   if(OVR::System::IsInitialized())
   {
      mEnabled = true;

      // Create the OVR device manager
      mDeviceManager = OVR::DeviceManager::Create();
      if(!mDeviceManager)
      {
         if(smSimulateHMD)
         {
            Con::printf("   Could not create a HMD device manager.  Simulating a HMD.");
            Con::printf("   ");

            createSimulatedHMD();
            createSimulatedSensor();
            setActive(true);
            return true;
         }
         else
         {
            Con::printf("   Could not create a HMD device manager.");
            Con::printf("   ");

            mEnabled = false;
            OVR::System::Destroy();
            return false;
         }
      }

      // Provide a message listener
      // NOTE: Commented out as non-functional in 0.1.2
      //mListener = new DeviceListener(this);
      //mDeviceManager->SetMessageHandler(mListener);

      // Enumerate HMDs and pick the first one
      OVR::HMDDevice* hmd = mDeviceManager->EnumerateDevices<OVR::HMDDevice>().CreateDevice();
      if(hmd)
      {
         // Add the HMD to our list
         addHMDDevice(hmd);

         // Detect and add any sensor on the HMD
         OVR::SensorDevice* sensor = hmd->GetSensor();
         if(sensor)
         {
            addSensorDevice(sensor);
         }
         else
         {
            Con::printf("   No sensor device on HMD.");
         }

         setActive(true);
      }
      else
      {
         if(smSimulateHMD)
         {
            Con::printf("   Could not enumerate a HMD device.  Simulating a HMD.");
            createSimulatedHMD();
            createSimulatedSensor();
            setActive(true);
         }
         else
         {
            Con::printf("   Could not enumerate a HMD device.");
         }
      }

   }

   Con::printf("   ");

   return false;
}
Example #16
0
	void FrameBufferObject::attach(unsigned int slot, unsigned int texture) {
		enable();
		glFramebufferTexture(GL_FRAMEBUFFER, slot, texture, 0);
		disable();
	}
HardwareTimer::~HardwareTimer() {
    disable();
    if (__user_fptr != NULL) //double check
        delete __user_fptr;    
}
void InspectorIndexedDBAgent::clearFrontend()
{
    m_frontendProvider->clearFrontend();
    m_frontendProvider.clear();
    disable(0);
}
/*Codigo fuente de nuestra interrupcion del timer*/
void interrupt myTimer(...)
{
	disable();              //Apaga las dem?s interrupciones
	(*prev)();              //Llama al antiguo c?digo de interrupcion
	//Espera una tecla y verifica si es la tecla Enter
	if(kbhit()  && getch() == 0xD)
	{
		//Devuelve la interrupci?n original
		setvect(8,prev);
		exit(0);
        }
        if (quantumProcess > 0)
        {
                //Si el proceso aun  tiene quantum lo disminuye.
                quantumProcess--;
        }
        else
        {
                //Salva el SP del proceso que se quedo sin quantum
				asm mov  stackPointer, SP
				pcb[indexProcess].stcPtr = stackPointer;
				if (pcb[indexProcess].status == 1)
				{
					pcb[indexProcess].status = 2;
				}
				//copia el valor que posee el quantum del proceso actual
				int q = pcb[indexProcess].quantum;
				if (q > 20)
				{ 
					//Si el quantum del proceso es mayor a 20 reinicia el quantum en su valor original
					q = quantum;
				}
				else
				{
					/*Si el quantum del proceso actual no es mayor a 20 le aumenta uno para que a la siguiente ejecución
					tenga un tick de reloj más*/
					q++;
				}
				//Asigna el nuevo quantum al proceso.
				pcb[indexProcess].quantum = q;
				//Cambio de proceso.
				indexAux = indexProcess;
				indexProcess++;
				indexProcess = indexProcess % 2;
				if (pcb[indexProcess].status != 2)
				{
					indexProcess++;
					indexProcess = indexProcess % 2;
				}
				//Guarda el quantum del nuevo proceso.
				quantumProcess = pcb[indexProcess].quantum;

				//revisa que no se repita el proceso que se acaba de quedar sin quantum
				if (indexAux != indexProcess)
				{
					//Le indica que el nuevo proceso va estar en estado ejecutado.
					pcb[indexProcess].status = 1;
					stackPointer = pcb[indexProcess].stcPtr;
					//Mueve el SP a donde esta el contexto del nuevo proceso que va ejecutar
					asm mov sp,stackPointer
				}
        }
Example #20
0
void InspectorLayerTreeAgent::clearFrontend()
{
    m_frontend = 0;
    disable(0);
}
void InspectorDOMStorageAgent::clearFrontend()
{
    m_frontend = 0;
    disable(0);
}
Example #22
0
File: rui.c Project: Maxsl/r-source
int winaddmenuitem(const char * item, const char * menu,
		   const char * action, char *errmsg)
{
    int i, im;
    menuitem m;
    char mitem[1002], *p;

    /* if (nitems > 499) {
	strcpy(errmsg, G_("too many menu items have been created"));
	return 2;
	} */
    if (strlen(item) + strlen(menu) > 1000) {
	strcpy(errmsg, G_("menu + item is limited to 1000 bytes"));
	return 5;
    }

    for (im = 0; im < nmenus; im++) {
	if (strcmp(menu, usermenunames[im]) == 0) break;
    }
    if (im == nmenus) {
	strcpy(errmsg, G_("menu does not exist"));
	return 3;
    }

    strcpy(mitem, menu); strcat(mitem, "/"); strcat(mitem, item);

    for (i = 0; i < nitems; i++) {
	if (strcmp(mitem, umitems[i]->name) == 0) break;
    }
    if (i < nitems) { /* existing item */
	if (strcmp(action, "enable") == 0) {
	    enable(umitems[i]->m);
	} else if (strcmp(action, "disable") == 0) {
	    disable(umitems[i]->m);
	} else {
	    p = umitems[i]->action;
	    p = realloc(p, strlen(action) + 1);
	    if(!p) {
		strcpy(errmsg, G_("failed to allocate char storage"));
		return 4;
	    }
	    strcpy(p, action);
	}
    } else {
	addto(usermenus[im]);
	m  = newmenuitem(item, 0, menuuser);
	if (m) {
	    if(alloc_items <= nitems) {
		if(alloc_items <= 0) {
		    alloc_items = 100;
		    umitems = (Uitem *) malloc(sizeof(Uitem) * alloc_items);
		} else {
		    alloc_items += 100;
		    umitems = (Uitem *) realloc(umitems,
						sizeof(Uitem) * alloc_items);
		}
	    }
	    umitems[nitems] = (Uitem) malloc(sizeof(uitem));
	    umitems[nitems]->m = m;
	    umitems[nitems]->name = p = (char *) malloc(strlen(mitem) + 1);
	    if(!p) {
		strcpy(errmsg, G_("failed to allocate char storage"));
		return 4;
	    }
	    strcpy(p, mitem);
	    if(!p) {
		strcpy(errmsg, G_("failed to allocate char storage"));
		return 4;
	    }
	    umitems[nitems]->action = p = (char *) malloc(strlen(action) + 1);
	    strcpy(p, action);
	    m->max = nitems;
	    nitems++;
	} else {
	    strcpy(errmsg, G_("failed to allocate menuitem"));
	    return 1;
	}
    }
    show(RConsole);
    return 0;
}
Example #23
0
void fast_kbflush_dos(void)
{
      disable();
      HEAD = TAIL;
      enable();
}
Example #24
0
File: rui.c Project: Maxsl/r-source
static void menuact(control m)
{
    if (consolegetlazy(RConsole)) check(mlazy); else uncheck(mlazy);

    /* display needs pager set */
    if (R_is_running) enable(mdisplay); else disable(mdisplay);

    if (ConsoleAcceptCmd) {
	enable(msource);
	enable(mload);
	enable(msave);
	enable(mls);
	enable(mrm);
	enable(msearch);

    } else {
	disable(msource);
	disable(mload);
	disable(msave);
	disable(mls);
	disable(mrm);
	disable(msearch);
    }

    if (consolecancopy(RConsole)) {
	enable(mcopy);
	enable(mcopypaste);
    } else {
	disable(mcopy);
	disable(mcopypaste);
    }

    if (consolecanpaste(RConsole)) {
	enable(mpaste);
	enable(mpastecmds);
    }
    else {
	disable(mpaste);
	disable(mpastecmds);
    }

    helpmenuact(hmenu);
    pkgmenuact(pmenu);

    draw(RMenuBar);
}
Example #25
0
void InspectorConsoleAgent::clearFrontend()
{
    m_frontend = 0;
    String errorString;
    disable(&errorString);
}
Example #26
0
File: rui.c Project: Maxsl/r-source
int RguiCommonHelp(menu m, HelpMenuItems hmenu)
{
    addto(m);

    MCHECK(hmenu->mFAQ = newmenuitem(G_("FAQ on R"), 0, menuFAQ));
    if (!check_doc_file("doc\\manual\\R-FAQ.html")) disable(hmenu->mFAQ);
    MCHECK(hmenu->mrwFAQ = newmenuitem(G_("FAQ on R for &Windows"), 0, menurwFAQ));
    if (!check_doc_file("doc\\html\\rw-FAQ.html")) disable(hmenu->mrwFAQ);


    if (!lmanintro && !lmanref && !lmandata && !lmanlang && !lmanext
       && !lmanint && !lmanadmin && !lmanSweave) {
	MCHECK(hmenu->mman0 = newmenuitem(G_("Manuals (in PDF)"), 0, NULL));
	disable(hmenu->mman0);
    } else {
	MCHECK(hmenu->mman = newsubmenu(m, G_("Manuals (in PDF)")));
	MCHECK(hmenu->mmanintro = newmenuitem("An &Introduction to R", 0,
				       menumainman));
	if (!lmanintro) disable(hmenu->mmanintro);
	MCHECK(hmenu->mmanref = newmenuitem("R &Reference", 0,
				     menumainref));
	if (!lmanref) disable(hmenu->mmanref);
	MCHECK(hmenu->mmandata = newmenuitem("R Data Import/Export", 0,
				      menumaindata));
	if (!lmandata) disable(hmenu->mmandata);
	MCHECK(hmenu->mmanlang = newmenuitem("R Language Definition", 0,
				      menumainlang));
	if (!lmanlang) disable(hmenu->mmanlang);
	MCHECK(hmenu->mmanext = newmenuitem("Writing R Extensions", 0,
				     menumainext));
	if (!lmanext) disable(hmenu->mmanext);
	MCHECK(hmenu->mmanint = newmenuitem("R Internals", 0,
				     menumainint));
	if (!lmanint) disable(hmenu->mmanint);
	MCHECK(hmenu->mmanadmin = newmenuitem("R Installation and Administration", 0,
				       menumainadmin));
	if (!lmanadmin) disable(hmenu->mmanadmin);
	MCHECK(hmenu->mmanSweave = newmenuitem("Sweave User", 0,
				       menumainSweave));
	if (!lmanSweave) disable(hmenu->mmanSweave);
    }


    addto(m);
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(hmenu->mhelp = newmenuitem(G_("R functions (text)..."), 0,
				      menuhelp));
    MCHECK(hmenu->mhelpstart = newmenuitem(G_("Html help"), 0, menuhelpstart));
    if (!check_doc_file("doc\\html\\index.html")) disable(hmenu->mhelpstart);
    MCHECK(hmenu->mhelpsearch = newmenuitem(G_("Search help..."), 0,
					    menuhelpsearch));
    MCHECK(hmenu->msearchRsite = newmenuitem("search.r-project.org ...", 0,
					     menusearchRsite));
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(hmenu->mapropos = newmenuitem(G_("Apropos..."), 0, menuapropos));
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(newmenuitem(G_("R Project home page"), 0, menuRhome));
    MCHECK(hmenu->mCRAN = newmenuitem(G_("CRAN home page"), 0, menuCRAN));
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(newmenuitem(G_("About"), 0, menuabout));
    return 0;
}
Example #27
0
PD_UI_DissBattle::PD_UI_DissBattle(BulletWorld* _bulletWorld, Player * _player, Font * _font, Shader * _textShader, Shader * _shader) :
	VerticalLinearLayout(_bulletWorld),
	iteration(0),
	enabled(true),
	canInterject(true),
	basePlayerInsultSpeedMultiplier(1.f),
	playerInsultSpeedMultiplier(basePlayerInsultSpeedMultiplier),
	basePlayerQuestionTimerLength(1.f),
	playerQuestionTimerLength(basePlayerQuestionTimerLength),
	playerQuestionTimer(0),
	basePlayerAnswerTimerLength(1.25f),
	playerAnswerTimerLength(basePlayerAnswerTimerLength),
	playerAnswerTimer(0),
	playerResult(false),
	playerResultEffective(false),
	playerResultTimerLength(1.5f),
	playerResultTimer(0.f),
	enemyCursor(new Sprite(_shader)),
	prevHighlightedPunctuation(nullptr),
	highlightedPunctuation(nullptr),
	punctuationHighlight(new Sprite(_shader)),
	highlightedWordStart(nullptr),
	highlightedWordEnd(nullptr),
	wordHighlight(new Sprite(_shader)),
	complimentBubble(new Sprite(_shader)),
	complimentBubbleTimerBaseLength(1.f),
	complimentBubbleTimerLength(1.f),
	complimentBubbleTimer(0.f),
	complimentBubbleScale(1.f),
	interjectBubble(new Sprite(_shader)),
	interjected(false),
	interjectBubbleTimerBaseLength(1.f),
	interjectBubbleTimerLength(1.f),
	interjectBubbleTimer(0.f),
	shader(_shader),
	baseCursorDelayLength(0.05f),
	baseCursorPunctDelayLength(0.15f),
	cursorDelayLength(0.f),
	cursorDelayDuration(0.f),
	baseGlyphWidth(_font->getGlyphAdvance('m').x),
	glyphIdx(0),
	confidence(50.f),
	isGameOver(false),
	gameOverLength(1.f),
	gameOverDuration(0.f),
	win(false),
	isComplete(false),
	offensiveCorrect(0),
	offensiveWrong(0),
	defensiveCorrect(0),
	defensiveWrong(0),
	punctuationCnt(-1),
	interjectTimer(0),
	damage(10.f),
	playerComboMultiplier(1.f),
	enemyComboMultiplier(1.f),
	keyboard(&Keyboard::getInstance()),
	enemy(nullptr),
	modeOffensive(true),
	player(_player),
	playerAttackMultiplier(1.f),
	enemyAttackMultiplier(1.f),
	insightMultiplier(1.f),
	insightAlpha(1.f),
	sassInsultMultiplier(1.f),
	sassInterjectMultiplier(1.f),
	playerComboIncrement(0),
	enemyComboIncrement(0),
	optionOneShader(new ComponentShaderText(true)),
	optionTwoShader(new ComponentShaderText(true))
{
	verticalAlignment = kTOP;
	horizontalAlignment = kCENTER;
	background->setVisible(false);

	float borderSize = sweet::getWindowHeight() * 0.1f / 2.f;

	healthContainer = new VerticalLinearLayout(_bulletWorld);
	addChild(healthContainer);
	healthContainer->setRationalWidth(1.f, this);
	healthContainer->setRationalHeight(0.15f, this);
	healthContainer->horizontalAlignment = kCENTER;
	healthContainer->verticalAlignment = kMIDDLE;
	//healthContainer->setBackgroundColour(0, 1.f, 0.541f);

	displayContainer = new NodeUI(_bulletWorld);
	addChild(displayContainer);
	displayContainer ->setRationalWidth(1.f, this);
	displayContainer ->setRationalHeight(0.85f, this);
	displayContainer ->background->setVisible(false);

	gameContainer = new NodeUI(_bulletWorld);
	displayContainer->addChild(gameContainer);
	gameContainer->setRationalWidth(1.f, displayContainer);
	gameContainer->setRationalHeight(1.f, displayContainer);
	gameContainer->background->setVisible(false);
	//gameContainer->setBackgroundColour(0, 0.714f, 0.929f);

	// Enemy Cursor
	enemyCursor->mesh->pushTexture2D(PD_ResourceManager::scenario->getTexture("DISS-BATTLE-CURSOR")->texture);
	enemyCursor->mesh->setScaleMode(GL_NEAREST);
	enemyCursor->childTransform->scale(20.f);
	childTransform->addChild(enemyCursor);

	// move the cusrosr's mesh up so that the origin is aligned with the top
	for (unsigned long int i = 0; i < enemyCursor->mesh->vertices.size(); ++i){
		enemyCursor->mesh->vertices.at(i).y -= 0.5f;
	}

	// Punctuation Highlight
	punctuationHighlight->mesh->pushTexture2D(PD_ResourceManager::scenario->getTexture("DISS-BATTLE-HIGHLIGHT")->texture);
	punctuationHighlight->mesh->setScaleMode(GL_NEAREST);
	// move the highlight's mesh up so that the origin is aligned with the bottom
	for (unsigned long int i = 0; i < punctuationHighlight->mesh->vertices.size(); ++i){
		punctuationHighlight->mesh->vertices.at(i).x += 0.5f;
		punctuationHighlight->mesh->vertices.at(i).y += 0.5f;
	}
	punctuationHighlight->setVisible(false);

	// Word Highlight
	// move the highlights's mesh up so that the origin is aligned with the bottom and set the colour
	for (unsigned long int i = 0; i < wordHighlight->mesh->vertices.size(); ++i){
		wordHighlight->mesh->vertices.at(i).x += 0.5f;
		wordHighlight->mesh->vertices.at(i).y += 0.5f;

		wordHighlight->mesh->vertices.at(i).red = 0.820f;
		wordHighlight->mesh->vertices.at(i).green = 0.722f;
		wordHighlight->mesh->vertices.at(i).blue = 0.851f;
	}
	wordHighlight->setVisible(false);

	livesContainer = new HorizontalLinearLayout(_bulletWorld);
	healthContainer->addChild(livesContainer);
	//livesContainer->setBackgroundColour(0.5f, 1.f, 0.5f);
	livesContainer->setRationalWidth(1.f, healthContainer);
	livesContainer->setRationalHeight(0.5f, healthContainer);
	livesContainer->horizontalAlignment = kLEFT;
	livesContainer->verticalAlignment = kTOP;

	// healthbar
	confidenceSlider = new SliderControlled(_bulletWorld, &confidence, 0, 100.f);
	healthContainer->addChild(confidenceSlider);
	//confidenceSlider->setBackgroundColour(1.f, 0, 0);
	//confidenceSlider->fill->setBackgroundColour(0, 1.f, 0);
	confidenceSlider->setRationalWidth(0.7f, healthContainer);
	confidenceSlider->setRationalHeight(0.5f, healthContainer);

	//confidenceSlider->thumb->background->meshTransform->scale(2);
	confidenceSlider->thumb->setBackgroundColour(1,1,1,1);
	confidenceSlider->thumb->background->mesh->pushTexture2D(PD_ResourceManager::scenario->getTexture("DISS-BATTLE-SLIDER-THUMB-HAPPY")->texture);
	confidenceSlider->thumb->background->mesh->setScaleMode(GL_NEAREST);

	confidenceSlider->setBackgroundColour(1,1,1,1);
	confidenceSlider->background->mesh->pushTexture2D(PD_ResourceManager::scenario->getTexture("DISS-BATTLE-SLIDER-TRACK")->texture);
	confidenceSlider->background->mesh->setScaleMode(GL_NEAREST);

	confidenceSlider->fill->setBackgroundColour(1,1,1,1);
	confidenceSlider->fill->background->mesh->pushTexture2D(PD_ResourceManager::scenario->getTexture("DISS-BATTLE-SLIDER-FILL")->texture);
	confidenceSlider->fill->background->mesh->setScaleMode(GL_NEAREST);

	enemyBubble = new NodeUI(_bulletWorld);
	gameContainer->addChild(enemyBubble);
	enemyBubble->setRationalWidth(1.f, gameContainer);
	enemyBubble->setRationalHeight(1.f, gameContainer);
	enemyBubble->setMarginTop(0.4f);
	enemyBubble->setMarginBottom(0.3f);
	enemyBubble->background->setVisible(false);
	enemyBubble->setBackgroundColour(0.5, 0.5, 0.5, 1.f);
	enemyBubble->setMarginRight(0.05f);
	enemyBubble->setMarginLeft(0.55f);

	NodeUI_NineSliced * enemyBubbleBubble = new NodeUI_NineSliced(_bulletWorld, PD_ResourceManager::scenario->getNineSlicedTexture("NPC-BUBBLE"));
	enemyBubble->addChild(enemyBubbleBubble);
	enemyBubbleBubble->setBorder(borderSize);
	enemyBubbleBubble->setRationalWidth(1.f, enemyBubble);
	enemyBubbleBubble->setRationalHeight(1.f, enemyBubble);
	enemyBubbleBubble->setMarginLeft(0.15f);
	enemyBubbleBubble->setPadding(0.05f);
	enemyBubbleBubble->setScaleMode(GL_NEAREST);
	//enemyBubbleBubble->setBackgroundColour(0.f, 1.f, 0.f, 0.5f);

	NodeUI * enemyBubbleTextContainer = new NodeUI(_bulletWorld);
	enemyBubbleBubble->addChild(enemyBubbleTextContainer);
	enemyBubbleTextContainer->setRationalWidth(1.f, enemyBubbleTextContainer->nodeUIParent);
	enemyBubbleTextContainer->setRationalHeight(1.f, enemyBubbleTextContainer->nodeUIParent);
	enemyBubbleTextContainer->setBackgroundColour(1.f,0, 0, 0.5);
	enemyBubbleTextContainer->background->setVisible(false);
	enemyBubbleTextContainer->setPadding(0.05f);

	enemyBubbleTextContainer->uiElements->addChild(wordHighlight);
	enemyBubbleTextContainer->uiElements->addChild(punctuationHighlight);

	enemyBubbleText = new TextArea(world, _font, _textShader);
	enemyBubbleText->setRenderMode(kTEXTURE);
	enemyBubbleTextContainer->addChild(enemyBubbleText);
	enemyBubbleText->setWrapMode(kWORD);
	enemyBubbleText->setRationalWidth(1.f, enemyBubbleTextContainer);
	enemyBubbleText->setRationalHeight(1.f, enemyBubbleTextContainer);
	enemyBubbleText->horizontalAlignment = kCENTER;
	enemyBubbleText->verticalAlignment = kMIDDLE;
	enemyBubbleText->background->setVisible(false);
	enemyBubbleText->setBackgroundColour(1, 1, 1, 0.5);

	NodeUI * enemyBubbleTail = new NodeUI(_bulletWorld);
	enemyBubble->addChild(enemyBubbleTail);
	enemyBubbleTail->background->mesh->pushTexture2D(PD_ResourceManager::scenario->getTexture("DISS-BATTLE-DEFENSE-BUBBLE-TAIL")->texture);
	enemyBubbleTail->setRationalWidth(1.f, enemyBubble);
	enemyBubbleTail->setRationalHeight(1.f, enemyBubble);
	enemyBubbleTail->setMarginRight(0.835f);
	enemyBubbleTail->setMarginTop(0.3f);
	enemyBubbleTail->setMarginBottom(0.3f);
	//enemyBubbleTail->setBackgroundColour(1.f, 0, 0, 0.5f);
	enemyBubbleTail->background->mesh->setScaleMode(GL_NEAREST);

	playerBubble = new NodeUI(_bulletWorld);
	gameContainer->addChild(playerBubble);
	playerBubble->setRationalWidth(1.f, gameContainer);
	playerBubble->setRationalHeight(1.f, gameContainer);
	playerBubble->setMarginTop(0.5f);
	playerBubble->setMarginBottom(0.05f);
	playerBubble->background->setVisible(false);
	playerBubble->setBackgroundColour(1, 0, 0, 0.5f);
	playerBubble->setMarginRight(0.05f);
	playerBubble->setMarginLeft(0.4f);

	playerTimerSlider = new SliderControlled(_bulletWorld, &playerAnswerTimer, 0, playerAnswerTimerLength, true, true);
	playerBubble->addChild(playerTimerSlider);
	playerTimerSlider->boxSizing = kCONTENT_BOX;
	playerTimerSlider->setRationalWidth(0.7f, playerBubble);
	playerTimerSlider->setRationalHeight(0.1f, playerBubble);
	playerTimerSlider->setBackgroundColour(1,1,1,1);
	playerTimerSlider->background->mesh->pushTexture2D(PD_ResourceManager::scenario->getTexture("SLIDER-TRACK")->texture);
	playerTimerSlider->background->mesh->setScaleMode(GL_NEAREST);
	playerTimerSlider->fill->setBackgroundColour(1,1,1,1);
	playerTimerSlider->fill->background->mesh->pushTexture2D(PD_ResourceManager::scenario->getTexture("DISS-BATTLE-SLIDER-FILL")->texture);
	playerTimerSlider->fill->background->mesh->setScaleMode(GL_NEAREST);
	playerTimerSlider->thumb->setVisible(false);
	playerTimerSlider->setMarginLeft(0.3f);
	playerTimerSlider->setMarginBottom(1.f);

	// The fancy nine sliced bubble
	NodeUI_NineSliced * playerBubbleBubble = new NodeUI_NineSliced(_bulletWorld, PD_ResourceManager::scenario->getNineSlicedTexture("PLAYER-BUBBLE"));
	playerBubble->addChild(playerBubbleBubble);
	playerBubbleBubble->setBorder(borderSize);
	playerBubbleBubble->setRationalWidth(1.f, playerBubble);
	playerBubbleBubble->setRationalHeight(1.f, playerBubble);
	playerBubbleBubble->setMarginLeft(0.3f);
	playerBubbleBubble->setMarginBottom(0.3f);
	//playerBubbleBubble->setBackgroundColour(0, 0.1f, 0, 0.5f);
	playerBubbleBubble->setScaleMode(GL_NEAREST);

	// The side by side text and button layout
	playerBubbleLayout = new HorizontalLinearLayout(_bulletWorld);
	playerBubbleBubble->addChild(playerBubbleLayout);
	playerBubbleLayout->verticalAlignment = kMIDDLE;
	playerBubbleLayout->horizontalAlignment = kCENTER;
	playerBubbleLayout->setRationalWidth(1.f, playerBubbleBubble);
	playerBubbleLayout->setRationalHeight(1.f, playerBubbleBubble);
	playerBubbleLayout->setPadding(0.05f);
	playerBubbleLayout->background->setVisible(false);
	playerBubbleLayout->setBackgroundColour(1, 1, 1, 0.5f);

	playerBubbleText = new TextArea(world, _font, _textShader);
	playerBubbleText->setRenderMode(kTEXTURE);
	playerBubbleText->setWrapMode(kWORD);
	playerBubbleLayout->addChild(playerBubbleText);
	playerBubbleText->setRationalWidth(PLAYER_TEXT_WIDTH, playerBubbleLayout);
	playerBubbleText->setRationalHeight(1.0f, playerBubbleLayout);
	playerBubbleText->horizontalAlignment = kCENTER;
	playerBubbleText->verticalAlignment = kMIDDLE;
	playerBubbleText->background->setVisible(false);
	playerBubbleText->setBackgroundColour(1.f, 0, 0, 0.5f);

	playerBubbleOptions = new HorizontalLinearLayout(_bulletWorld);
	playerBubbleLayout->addChild(playerBubbleOptions);

	playerBubbleOptions->setRationalWidth(0.5f, playerBubbleLayout);
	playerBubbleOptions->setRationalHeight(1.f, playerBubbleLayout);
	playerBubbleOptions->setBackgroundColour(0, 1.f, 0, 0.5f);
	playerBubbleOptions->background->setVisible(false);
	playerBubbleOptions->horizontalAlignment = kCENTER;
	playerBubbleOptions->verticalAlignment = kMIDDLE;

	Texture * arrowsTex = PD_ResourceManager::scenario->getTexture("DISS-TUTORIAL-ARROWS")->texture;
	NodeUI * playerArrows = new NodeUI(_bulletWorld);
	playerBubbleOptions->addChild(playerArrows);
	playerArrows->background->mesh->pushTexture2D(arrowsTex);
	playerArrows->setRationalWidth(0.2f, playerBubbleOptions);
	playerArrows->setSquareHeight((float)arrowsTex->height/arrowsTex->width);
	playerArrows->background->mesh->setScaleMode(GL_NEAREST);

	VerticalLinearLayout * buttonLayout = new VerticalLinearLayout(_bulletWorld);
	playerBubbleOptions->addChild(buttonLayout);
	buttonLayout->setRationalWidth(0.8f, playerBubbleOptions);
	buttonLayout->setRationalHeight(0.75f, playerBubbleOptions);
	buttonLayout->verticalAlignment = kMIDDLE;
	buttonLayout->setPaddingLeft(0.05f);

	pBubbleBtn1 = new PD_InsultButton(_bulletWorld, _font, optionOneShader);
	buttonLayout->addChild(pBubbleBtn1);
	pBubbleBtn1->setRationalWidth(1.f, buttonLayout);
	pBubbleBtn1->setRationalHeight(0.5f, buttonLayout);
	pBubbleBtn1->setPadding(0.f, 0.1f);
	pBubbleBtn1->setMarginBottom(0.1f);
	pBubbleBtn1->setMouseEnabled(false);

	pBubbleBtn2 = new PD_InsultButton(_bulletWorld, _font, optionTwoShader);
	buttonLayout->addChild(pBubbleBtn2);
	pBubbleBtn2->setRationalWidth(1.f, buttonLayout);
	pBubbleBtn2->setRationalHeight(0.5f, buttonLayout);
	pBubbleBtn2->setPadding(0.f, 0.1f);
	pBubbleBtn2->setMarginTop(0.1f);
	pBubbleBtn2->setMouseEnabled(false);

	NodeUI * playerBubbleTail = new NodeUI(_bulletWorld);
	playerBubble->addChild(playerBubbleTail);
	playerBubbleTail->background->mesh->pushTexture2D(PD_ResourceManager::scenario->getTexture("DISS-BATTLE-OFFENSE-BUBBLE-TAIL")->texture);
	playerBubbleTail->setRationalWidth(1.f, playerBubble);
	playerBubbleTail->setRationalHeight(1.f, playerBubble);
	playerBubbleTail->setMarginRight(0.69f);
	playerBubbleTail->setMarginTop(0.3f);
	playerBubbleTail->setMarginBottom(0.03f);
	playerBubbleTail->background->mesh->setScaleMode(GL_NEAREST);

	gameOverContainer = new VerticalLinearLayout(_bulletWorld);
	displayContainer->addChild(gameOverContainer);
	gameOverContainer->horizontalAlignment = kCENTER;
	gameOverContainer->verticalAlignment = kMIDDLE;
	gameOverContainer->setRationalHeight(1.f, displayContainer);
	gameOverContainer->setRationalWidth(1.f, displayContainer);
	gameOverContainer->setPadding(0.f, 0.1f);
	gameOverContainer->setVisible(false);

	gameOverImage = new NodeUI(_bulletWorld);
	gameOverContainer->addChild(gameOverImage);
	gameOverImage->setRationalHeight(0.5f, gameOverContainer);
	gameOverImage->setSquareWidth(1.f);
	gameOverImage->background->mesh->setScaleMode(GL_NEAREST);

	complimentBubble->mesh->pushTexture2D(PD_ResourceManager::scenario->getTexture("DISS-BATTLE-COMPLIMENT1")->texture);
	complimentBubble->mesh->setScaleMode(GL_NEAREST);
	complimentBubble->childTransform->scale(sweet::getWindowHeight() * 0.5, sweet::getWindowHeight() * 0.5, 0);
	complimentBubble->meshTransform->scale(0, 0, 0);
	complimentBubble->childTransform->translate(sweet::getWindowWidth() * 0.2, 0, 0);
	complimentBubble->setVisible(false);

	// move the interject bubble's mesh up so that the origin is aligned with the bottom
	for (unsigned long int i = 0; i < complimentBubble->mesh->vertices.size(); ++i){
		complimentBubble->mesh->vertices.at(i).x += 0.5f;
		complimentBubble->mesh->vertices.at(i).y += 0.5f;
	}
	childTransform->addChild(complimentBubble);

	interjectBubble->mesh->pushTexture2D(PD_ResourceManager::scenario->getTexture("DISS-BATTLE-INTERJECT")->texture);
	interjectBubble->mesh->setScaleMode(GL_NEAREST);
	interjectBubble->childTransform->scale(sweet::getWindowHeight() * 0.6, sweet::getWindowHeight() * 0.6, 0);
	interjectBubble->meshTransform->scale(0, 0, 0);
	interjectBubble->childTransform->translate(sweet::getWindowWidth() * 0.6, 0, 0);
	interjectBubble->setVisible(false);

	// move the interject bubble's mesh up so that the origin is aligned with the bottom
	for (unsigned long int i = 0; i < interjectBubble->mesh->vertices.size(); ++i){
		interjectBubble->mesh->vertices.at(i).x += 0.5f;
		interjectBubble->mesh->vertices.at(i).y += 0.5f;
	}
	childTransform->addChild(interjectBubble);

	tutorialSpacebar = new HorizontalLinearLayout(_bulletWorld);
	gameContainer->addChild(tutorialSpacebar);
	tutorialSpacebar->setRationalWidth(1.f, gameContainer);
	tutorialSpacebar->setRationalHeight(0.4f, gameContainer);
	tutorialSpacebar->verticalAlignment = kMIDDLE;
	tutorialSpacebar->horizontalAlignment = kCENTER;
	tutorialSpacebar->setMarginLeft(0.6f);
	tutorialSpacebar->setVisible(false);

	tutorialSpacebarImage = new NodeUI(_bulletWorld);
	tutorialSpacebar->addChild(tutorialSpacebarImage);
	tutorialSpacebarImage->setRationalHeight(1.f, tutorialSpacebar);
	tutorialSpacebarImage->setSquareWidth(1.f);
	tutorialSpacebarImage->background->mesh->pushTexture2D(PD_ResourceManager::scenario->getTexture("DISS-TUTORIAL-SPACEBAR")->texture);
	tutorialSpacebarImage->background->mesh->setScaleMode(GL_NEAREST);

	// disable and hide by default
	disable();

	eventManager->addEventListener("wordspoken", [this](sweet::Event * _event){
		// Stuff!!!
	});

	// Init sound vectors
	for(unsigned long int i = 1; i < 11; ++i) {
		missInterjectSounds.push_back(PD_ResourceManager::scenario->getAudio("slap" + std::to_string(i))->sound);
	}

	for(unsigned long int i = 1; i < NUM_SUCCEED_INSULT; ++i) {
		succeedInsultSounds.push_back(PD_ResourceManager::scenario->getAudio(SUCCEED_INSULT + std::to_string(i))->sound);
	}
	
	PD_ResourceManager::scenario->getAudio(TIMER)->sound->setGain(3);

	optionOneShader->incrementReferenceCount();
	optionTwoShader->incrementReferenceCount();
	optionOneShader->name = "PD_UI_DissBattle text shader (option one)";
	optionTwoShader->name = "PD_UI_DissBattle text shader (option two)";


	eventManager->addEventListener("fightStarted", [this](sweet::Event * _event){
		if(modeOffensive){
			playerBubbleText->invalidateLayout();
		}else{
			enemyBubbleText->invalidateLayout();
		}
	});
}
Example #28
0
void OculusVRDevice::cleanUp()
{
   disable();
}
void InspectorProfilerAgent::disable(ErrorString*)
{
    m_state->setBoolean(ProfilerAgentState::profilerEnabled, false);
    disable();
}
Example #30
0
Driver::~Driver()
{
    disable();
}