示例#1
0
CLoadPlayersWidget::CLoadPlayersWidget( QWidget* parent)
    : QWidget(parent)
{
    for(int i = 0; i < 4; i++)
        labels[i].setText(QString("Player %1 :").arg(i+1));
    labels[Cyan].setStyleSheet("QLabel {color : darkcyan}");
    labels[Magenta].setStyleSheet("QLabel {color : darkmagenta}");
    labels[Yellow].setStyleSheet("QLabel {color : orange}");
    labels[Red].setStyleSheet(" QLabel {color : red}");
    QGridLayout *lOut = new QGridLayout(this);
    this->setLayout(lOut);
    for(int i = 0; i < 4; i++)
    {
        lOut->addWidget(&labels[i],(i+1)*2-1,1);
        cBoxes[i].setChecked(false);
        buttons[i].setDisabled(true);
        buttons[i].setText("Browse");
        lOut->addWidget(&cBoxes[i],(i+1)*2-1,0);
        lOut->addWidget(&buttons[i],(i+1)*2-1,2);
        compileButt[i] = new QPushButton("Compile !");
        compileButt[i]->setDisabled(true);
        lOut->addWidget(compileButt[i],(i+1)*2-1,3);
        activeLabels[i] = new QLabel("Disabled");
        lOut->addWidget(activeLabels[i],(i+1)*2,1);
    }

    for(int i = 0; i < 4; i++)
        connect(&cBoxes[i],SIGNAL(clicked(bool)),&buttons[i],SLOT(setEnabled(bool)));
    connect(&buttons[0], SIGNAL(clicked()), this, SLOT(load1()));
    connect(&buttons[1], SIGNAL(clicked()), this, SLOT(load2()));
    connect(&buttons[2], SIGNAL(clicked()), this, SLOT(load3()));
    connect(&buttons[3], SIGNAL(clicked()), this, SLOT(load4()));
}
示例#2
0
void shootf(int n, float v[], float f[])
{
	void derivs(float x, float y[], float dydx[]);
	void load1(float x1, float v1[], float y[]);
	void load2(float x2, float v2[], float y[]);
	void odeint(float ystart[], int nvar, float x1, float x2,
		float eps, float h1, float hmin, int *nok, int *nbad,
		void (*derivs)(float, float [], float []),
		void (*rkqs)(float [], float [], int, float *, float, float,
		float [], float *, float *, void (*)(float, float [], float [])));
	void rkqs(float y[], float dydx[], int n, float *x,
		float htry, float eps, float yscal[], float *hdid, float *hnext,
		void (*derivs)(float, float [], float []));
	void score(float xf, float y[], float f[]);
	int i,nbad,nok;
	float h1,hmin=0.0,*f1,*f2,*y;

	f1=vector(1,nvar);
	f2=vector(1,nvar);
	y=vector(1,nvar);
	kmax=0;
	h1=(x2-x1)/100.0;
	load1(x1,v,y);
	odeint(y,nvar,x1,xf,EPS,h1,hmin,&nok,&nbad,derivs,rkqs);
	score(xf,y,f1);
	load2(x2,&v[nn2],y);
	odeint(y,nvar,x2,xf,EPS,h1,hmin,&nok,&nbad,derivs,rkqs);
	score(xf,y,f2);
	for (i=1;i<=n;i++) f[i]=f1[i]-f2[i];
	free_vector(y,1,nvar);
	free_vector(f2,1,nvar);
	free_vector(f1,1,nvar);
}
示例#3
0
bool OpenALPlayer::load(std::vector<char> *data) {
	unsigned char *fdata = (unsigned char *) &(*data)[0];
	if (memcmp("RIFF", fdata, 4) == 0) {
		return load1(data);
	} else if (memcmp("Ogg", fdata, 3) == 0) {
		return load2(data);
	} else {
		return false;
	}
}
示例#4
0
void project1()
{
    codeFile = fopen("input.txt", "r");
    output = fopen("cleaninput.txt", "w");
    initArrays();
    load1();
    printCleanInput();
    cleanArrayList();
    findToken();
    //errorCheck();
    printLexemeTable();
    printTest();
}
示例#5
0
void es::MainGame::LoadData() {
  std::ostringstream out1, out2;
  const auto rand1 = eg::random()(1, 7);
  auto rand2 = eg::random()(1, 7);
  if (rand1 == rand2) { rand2 = (rand1 + 1) % 7 + 1; }
  out1 << "res/save" << rand1 << ".txt";
  out2 << "res/save" << rand2 << ".txt";

  std::ifstream load1(out1.str().c_str());
  if (load1) { loading(load1, false); }

  std::ifstream load2(out2.str().c_str());
  if (load2) { loading(load2, true); }
}
示例#6
0
int main(int argc, char * argv[]) {
    int a = 1, b = 2, z1 = 3, z2 = 4, z3 = 5;
    void *handle0, *handle1;
    char *error;

    if (argc == 3) {
        a = atoi(argv[1]);
        b = atoi(argv[2]);
    }

    DynamicLoader load0("./closure_callee0");
    DynamicLoader load1("./closure_callee1");
    DynamicLoader load2("./closure_callee2");
    DynamicLoader load3("./closure_callee3");

    std::function<int (int)> init_0 = load0.load<int (int)>("callee_init");
    std::function<int (int, int&, int*)> init_1 = load1.load<int (int, int&, int*)>("callee_init");
    std::function<int (int, int&, int*)> init_3 = load3.load<int (int, int&, int*)>("create_callee");
    std::function<int (void)> del_3 = load3.load<int (void)>("destroy_callee");
    std::function<int (int, int)> callee_0 = load0.load<int (int, int)>("callee");
    std::function<int (int, int)> callee_1 = load1.load<int (int, int)>("callee");
    std::function<int (int, int)> callee_3 = load3.load<int (int, int)>("lam");

    typedef std::function<int (int, int)> T_lam;

    std::function<int (T_lam, int, int)> callee_2 = load2.load<int (T_lam, int, int)>("callee");

    init_0(z1); 
    init_1(z1, z2, &z3);
    printf("<%s:%d> : z1 = %d, z2 = %d, z3 = %d\n", __FUNCTION__, __LINE__, z1, z2, z3);
    init_3(z1, z2, &z3);
    printf("<%s:%d> : z1 = %d, z2 = %d, z3 = %d\n", __FUNCTION__, __LINE__, z1, z2, z3);
    
    callee_0(a, b);
    callee_1(a, b);
    // callee_3(a, b);

    callee_2(callee_0, a, b);
    callee_2(callee_1, a, b);
    printf("<%s:%d> : z1 = %d, z2 = %d, z3 = %d\n", __FUNCTION__, __LINE__, z1, z2, z3);
    callee_2(callee_3, a, b);
    printf("<%s:%d> : z1 = %d, z2 = %d, z3 = %d\n", __FUNCTION__, __LINE__, z1, z2, z3);
    del_3();
    load0.close();
    load1.close();
    load2.close();
    load3.close();
    return 0;
}
示例#7
0
void NR::shootf(Vec_I_DP &v, Vec_O_DP &f)
{
	const DP EPS=1.0e-14;
	int i,nbad,nok;
	DP h1,hmin=0.0;

	int nvar=v.size();
	Vec_DP f1(nvar),f2(nvar),y(nvar);
	Vec_DP v2(&v[n2],nvar-n2);
	kmax=0;
	h1=(x2-x1)/100.0;
	load1(x1,v,y);
	odeint(y,x1,xf,EPS,h1,hmin,nok,nbad,derivs,rkqs);
	score(xf,y,f1);
	load2(x2,v2,y);
	odeint(y,x2,xf,EPS,h1,hmin,nok,nbad,derivs,rkqs);
	score(xf,y,f2);
	for (i=0;i<nvar;i++) f[i]=f1[i]-f2[i];
}
示例#8
0
int load_table(const gcstring& table)
	{
	const size_t bufsize = 8000;
	char buf[bufsize];
	IstreamFile fin((table + ".su").str(), "rb");
	if (!fin)
		except("can't open " << table << ".su");
	fin.getline(buf, bufsize);
	if (!has_prefix(buf, "Suneido dump 1"))
		except("invalid file");

	char* buf2 = buf + table.size() + 1;
	fin.getline(buf2, bufsize);
	verify(0 == memcmp(buf2, "======", 6));
	memcpy(buf, "create ", 7);
	memcpy(buf + 7, table.ptr(), table.size());
	Loading loading;
	int n = load1(fin, buf);
	verify(!alerts);
	return n;
	}
示例#9
0
void load(const gcstring& table)
	{
	thedb_create = true;

	if (table != "")							// load a single table
		{
		load_table(table);
		}
	else										// load entire database
		{
		const size_t bufsize = 8000;
		char buf[bufsize];
		IstreamFile fin("database.su", "rb");
		if (! fin)
			except("can't open database.su");
		fin.getline(buf, bufsize);
		if (! has_prefix(buf, "Suneido dump 1"))
			except("invalid file");

		if (_access("suneido.db", 0) == 0)
			{
			remove("suneido.bak");
			verify(0 == rename("suneido.db", "suneido.bak"));
			}

		Loading loading;
		while (fin.getline(buf, bufsize))
			{
			if (has_prefix(buf, "======"))
				{
				memcpy(buf, "create", 6);
				load1(fin, buf);
				}
			else
				except("bad file format");
			}
		verify(!alerts);
		}
	}
示例#10
0
void MadsAnimation::update() {
	if (_field12) {
		int spriteListIndex = _spriteListIndexes[_spriteListIndex];
		int newIndex = -1;
		
		for (uint idx = _oldFrameEntry; idx < _frameEntries.size(); ++idx) {
			if (_frameEntries[idx].frameNumber > _currentFrame)
				break;
			if (_frameEntries[idx].spriteSlot.spriteListIndex == spriteListIndex)
				newIndex = _frameEntries[idx].spriteSlot.frameNumber;
		}

		if (newIndex >= 0)
			load1(newIndex);
	}

	// Check for scroll change
	bool screenChanged = false;

	// Handle any scrolling of the screen surface
	if (hasScroll() && (_madsVm->_currentTimer >= _nextScrollTimer)) {
		_view->_bgSurface->scrollX(_scrollX);
		_view->_bgSurface->scrollY(_scrollY);

		_nextScrollTimer = _madsVm->_currentTimer + _scrollTicks;
		screenChanged = true;
	}

	// If it's not time for the next frame, then exit
	if (_madsVm->_currentTimer < _nextFrameTimer) {
		if (screenChanged)
			_view->_spriteSlots.fullRefresh();
		return;
	}

	// Loop checks for any prior animation sprite slots to be expired
	for (int slotIndex = 0; slotIndex < _view->_spriteSlots.startIndex; ++slotIndex) {
		if (_view->_spriteSlots[slotIndex].seqIndex >= 0x80) {
			// Flag the frame as animation sprite slot
			_view->_spriteSlots[slotIndex].spriteType = EXPIRED_SPRITE;
		}
	}

	// Validate the current frame
	if (_currentFrame >= (int)_miscEntries.size()) {
		// Is the animation allowed to be repeated?
		if (_resetFlag) {
			_currentFrame = 0;
			_oldFrameEntry = 0;
		} else {
			_freeFlag = true;
			return;
		}
	}

	// Handle starting any sound for this frame
	AnimMiscEntry &misc = _miscEntries[_currentFrame];
	if (misc.soundNum)
		_vm->_sound->playSound(misc.soundNum);

	// Handle any offset adjustment for sprites as of this frame
	if (_view->_posAdjust.x != misc.posAdjust.x) {
		_view->_posAdjust.x = misc.posAdjust.x;
		screenChanged = true;
	}
	if (_view->_posAdjust.y != misc.posAdjust.y) {
		_view->_posAdjust.y = misc.posAdjust.y;
		screenChanged = true;
	}


	if (screenChanged) {
		// Signal the entire screen needs refreshing
		_view->_spriteSlots.fullRefresh();
	}

	int spriteSlotsMax = _view->_spriteSlots.startIndex;

	// Main frame animation loop - frames get animated by being placed, as necessary, into the
	// main sprite slot array
	while ((uint)_oldFrameEntry < _frameEntries.size()) {
		if (_frameEntries[_oldFrameEntry].frameNumber > _currentFrame)
			break;
		else if (_frameEntries[_oldFrameEntry].frameNumber == _currentFrame) {
			// Found the correct frame 
			int spriteSlotIndex = 0;
			int index = 0;

			for (;;) {
				if ((spriteSlotIndex == 0) && (index < spriteSlotsMax)) {
					int seqIndex = _frameEntries[_oldFrameEntry].seqIndex - _view->_spriteSlots[index].seqIndex;
					if (seqIndex == 0x80) {
						if (_view->_spriteSlots[index] == _frameEntries[_oldFrameEntry].spriteSlot) {
							_view->_spriteSlots[index].spriteType = SPRITE_ZERO;
							spriteSlotIndex = -1;
						}
					}
					++index;
					continue;
				} 
				
				if (spriteSlotIndex == 0) {
					int slotIndex = _view->_spriteSlots.getIndex();
					MadsSpriteSlot &slot = _view->_spriteSlots[slotIndex];
					slot.copy(_frameEntries[_oldFrameEntry].spriteSlot);
					slot.seqIndex = _frameEntries[_oldFrameEntry].seqIndex + 0x80;
					
					SpriteAsset &spriteSet = _view->_spriteSlots.getSprite(
						_view->_spriteSlots[slotIndex].spriteListIndex);
					slot.spriteType = spriteSet.isBackground() ? BACKGROUND_SPRITE : FOREGROUND_SPRITE;
				}
				break;
			}
		}
		
		++_oldFrameEntry;
	}

	// Handle the display of any messages
	for (uint idx = 0; idx < _messages.size(); ++idx) {
		if (_messages[idx].kernelMsgIndex >= 0) {
			// Handle currently active message
			if ((_currentFrame < _messages[idx].startFrame) || (_currentFrame > _messages[idx].endFrame)) {
				_view->_kernelMessages.remove(_messages[idx].kernelMsgIndex);
				_messages[idx].kernelMsgIndex = -1;
				--_messageCtr;
			}
		} else if ((_currentFrame >= _messages[idx].startFrame) && (_currentFrame <= _messages[idx].endFrame)) {
			// Start displaying the message
			AnimMessage &me = _messages[idx];

			// The color index to use is dependant on how many messages are currently on-screen
			uint8 colIndex;
			switch (_messageCtr) {
			case 1:
				colIndex = 252;
				break;
			case 2:
				colIndex = 16;
				break;
			default:
				colIndex = 250;
				break;
			}

			_vm->_palette->setEntry(colIndex, me.rgb1.r, me.rgb1.g, me.rgb1.b);
			_vm->_palette->setEntry(colIndex + 1, me.rgb2.r, me.rgb2.g, me.rgb2.b);

			// Add a kernel message to display the given text
			me.kernelMsgIndex = _view->_kernelMessages.add(me.pos, colIndex * 0x101 + 0x100, 0, 0, INDEFINITE_TIMEOUT, me.msg);
			assert(me.kernelMsgIndex >= 0);

			// Play the associated sound, if it exists
			if (me.soundId > 0)
				_vm->_sound->playDSRSound(me.soundId - 1, 255, false);
			++_messageCtr;
		}
	}

	// Move to the next frame
	_currentFrame++;
	if (_currentFrame >= (int)_miscEntries.size()) {
		// Animation is complete
		if (_abortTimers != 0) {
			_view->_abortTimers = _abortTimers;
			_view->_abortTimersMode = _abortMode;

			if (_abortMode != ABORTMODE_1) {
				// Copy the noun list
				if (_madsVm->_scene)
					_madsVm->scene()->_action._action = _actionNouns;
			}
		}
	}

	int frameNum = MIN(_currentFrame, (int)_miscEntries.size() - 1);
	_nextFrameTimer = _madsVm->_currentTimer + _miscEntries[frameNum].numTicks;
}