Пример #1
0
/** Mouse Button Up */
void TextArea::OnMouseUp(unsigned short x, unsigned short y, unsigned short /*Button*/,
	unsigned short /*Mod*/)
{
	if (( x <= Width ) && ( y <= ( Height - 5 ) ) && ( seltext != -1 )) {
		Value = (unsigned int) seltext;
		Changed = true;
		if (strnicmp( lines[seltext], "[s=", 3 ) == 0) {
			if (minrow > seltext)
				return;
			int idx;
			sscanf( lines[seltext], "[s=%d,", &idx );
			GameControl* gc = core->GetGameControl();
			if (gc && (gc->GetDialogueFlags()&DF_IN_DIALOG) ) {
				if (idx==-1) {
					//this kills this object, don't use any more data!
					gc->EndDialog();
					return;
				}
				gc->DialogChoose( idx );
				return;
			}
		}
	}

	if (VarName[0] != 0) {
		core->GetDictionary()->SetAt( VarName, Value );
	}
	RunEventHandler( TextAreaOnChange );
}
bool GlobalTimer::Update()
{
	Map *map;
	Game *game;
	GameControl* gc;
	unsigned long thisTime;
	unsigned long advance;

	gc = core->GetGameControl();
	if (gc)
		gc->UpdateScrolling();

	UpdateAnimations();

	thisTime = GetTickCount();

	if (!startTime) {
		startTime = thisTime;
		return false;
	}

	advance = thisTime - startTime;
	if ( advance < interval) {
		return false;
	}
	ieDword count = advance/interval;
	DoStep(count);
	DoFadeStep(count);
	if (!gc) {
		goto end;
	}
	game = core->GetGame();
	if (!game) {
		goto end;
	}
	map = game->GetCurrentArea();
	if (!map) {
		goto end;
	}
	//do spell effects expire in dialogs?
	//if yes, then we should remove this condition
	if (!(gc->GetDialogueFlags()&DF_IN_DIALOG) ) {
		map->UpdateFog();
		map->UpdateEffects();
		if (thisTime) {
			//this measures in-world time (affected by effects, actions, etc)
			game->AdvanceTime(1);
		}
	}
	//this measures time spent in the game (including pauses)
	if (thisTime) {
		game->RealTime++;
	}
end:
	startTime = thisTime;
	return true;
}
Пример #3
0
/** Key Press Event */
void TextArea::OnKeyPress(unsigned char Key, unsigned short /*Mod*/)
{
	if (Flags & IE_GUI_TEXTAREA_EDITABLE) {
		if (Key >= 0x20) {
			Owner->Invalidate();
			Changed = true;
			int len = GetRowLength(CurLine);
			//printf("len: %d Before: %s\n",len, lines[CurLine]);
			lines[CurLine] = (char *) realloc( lines[CurLine], len + 2 );
			for (int i = len; i > CurPos; i--) {
				lines[CurLine][i] = lines[CurLine][i - 1];
			}
			lines[CurLine][CurPos] = Key;
			lines[CurLine][len + 1] = 0;
			CurPos++;
			//printf("pos: %d After: %s\n",CurPos, lines[CurLine]);
			CalcRowCount();
			RunEventHandler( TextAreaOnChange );
		}
		return;
	}

	//Selectable=false for dialogs, rather unintuitive, but fact
	if ((Flags & IE_GUI_TEXTAREA_SELECTABLE) || ( Key < '1' ) || ( Key > '9' ))
		return;
	GameControl *gc = core->GetGameControl();
	if (gc && (gc->GetDialogueFlags()&DF_IN_DIALOG) ) {
		Changed = true;
		seltext=minrow-1;
		if ((unsigned int) seltext>=lines.size()) {
			return;
		}
		for(int i=0;i<Key-'0';i++) {
			do {
				seltext++;
				if ((unsigned int) seltext>=lines.size()) {
					return;
				}
			}
			while (strnicmp( lines[seltext], "[s=", 3 ) != 0 );
		}
		int idx=-1;
		sscanf( lines[seltext], "[s=%d,", &idx);
		if (idx==-1) {
			//this kills this object, don't use any more data!
			gc->EndDialog();
			return;
		}
		gc->DialogChoose( idx );
	}
}
int CanSave()
{
	//some of these restrictions might not be needed
	Store * store = core->GetCurrentStore();
	if (store) {
		return 1; //can't save while store is open
	}
	GameControl *gc = core->GetGameControl();
	if (!gc) {
		return -1; //no gamecontrol!!!
	}
	if (gc->GetDialogueFlags()&DF_IN_DIALOG) {
		return 2; //can't save while in dialog?
	}
	//TODO: can't save while in combat
	//TODO: can't save while (party) actors are in helpless states
	//TODO: can't save while AOE spells are in effect
	//TODO: can't save while IF_NOINT is set on an actor
	return 0;
}
Пример #5
0
static int CanSave()
{
	//some of these restrictions might not be needed
	Store * store = core->GetCurrentStore();
	if (store) {
		displaymsg->DisplayConstantString(STR_CANTSAVESTORE, DMC_BG2XPGREEN);
		return 1; //can't save while store is open
	}
	GameControl *gc = core->GetGameControl();
	if (!gc) {
		displaymsg->DisplayConstantString(STR_CANTSAVE, DMC_BG2XPGREEN);
		return -1; //no gamecontrol!!!
	}
	if (gc->GetDialogueFlags()&DF_IN_DIALOG) {
		displaymsg->DisplayConstantString(STR_CANTSAVEDIALOG, DMC_BG2XPGREEN);
		return 2; //can't save while in dialog
	}

	//TODO: can't save while in combat
	Game *game = core->GetGame();
	if (!game) {
		displaymsg->DisplayConstantString(STR_CANTSAVE, DMC_BG2XPGREEN);
		return -1;
	}
	if (game->CombatCounter) {
		displaymsg->DisplayConstantString(STR_CANTSAVECOMBAT, DMC_BG2XPGREEN);
		return 3;
	}

	Map *map = game->GetCurrentArea();
	if (!map) {		
		displaymsg->DisplayConstantString(STR_CANTSAVE, DMC_BG2XPGREEN);
		return -1;
	}

	if (map->AreaFlags&AF_SAVE) {
		//cannot save in area
		displaymsg->DisplayConstantString(STR_CANTSAVEMONS, DMC_BG2XPGREEN);
		return 4;
	}

	int i = game->GetPartySize(true);
	while(i--) {
		Actor *actor = game->GetPC(i, true);
		//TODO: can't save while (party) actors are in helpless states
		if (actor->GetStat(IE_STATE_ID) & STATE_NOSAVE) {
			//some actor is in nosave state
			displaymsg->DisplayConstantString(STR_CANTSAVENOCTRL, DMC_BG2XPGREEN);
			return 5;
		}
		if (actor->GetCurrentArea()!=map) {
			//scattered
			displaymsg->DisplayConstantString(STR_CANTSAVE, DMC_BG2XPGREEN);
			return 6;
		}
	}

	//TODO: can't save while AOE spells are in effect -> CANTSAVE
	//TODO: can't save while IF_NOINT is set on any actor -> CANTSAVEDIALOG2 (dialog about to start)
	//TODO: can't save  during a rest, chapter information or movie -> CANTSAVEMOVIE
	//TODO: can't save while enemies are visible? AnyPCSeesEnemy -> CANTSAVEMONS

	return 0;
}
Пример #6
0
static int CanSave()
{
	//some of these restrictions might not be needed
	Store * store = core->GetCurrentStore();
	if (store) {
		displaymsg->DisplayConstantString(STR_CANTSAVESTORE, DMC_BG2XPGREEN);
		return 1; //can't save while store is open
	}
	GameControl *gc = core->GetGameControl();
	if (!gc) {
		displaymsg->DisplayConstantString(STR_CANTSAVE, DMC_BG2XPGREEN);
		return -1; //no gamecontrol!!!
	}
	if (gc->GetDialogueFlags()&DF_IN_DIALOG) {
		displaymsg->DisplayConstantString(STR_CANTSAVEDIALOG, DMC_BG2XPGREEN);
		return 2; //can't save while in dialog
	}

	Game *game = core->GetGame();
	if (!game) {
		displaymsg->DisplayConstantString(STR_CANTSAVE, DMC_BG2XPGREEN);
		return -1;
	}
	if (game->CombatCounter) {
		displaymsg->DisplayConstantString(STR_CANTSAVECOMBAT, DMC_BG2XPGREEN);
		return 3;
	}

	Map *map = game->GetCurrentArea();
	if (!map) {		
		displaymsg->DisplayConstantString(STR_CANTSAVE, DMC_BG2XPGREEN);
		return -1;
	}

	if (map->AreaFlags&AF_NOSAVE) {
		//cannot save in area
		displaymsg->DisplayConstantString(STR_CANTSAVEMONS, DMC_BG2XPGREEN);
		return 4;
	}

	int i = game->GetPartySize(true);
	while(i--) {
		Actor *actor = game->GetPC(i, true);
		// can't save while (party) actors are in helpless or dead states
		// STATE_NOSAVE tracks actors not to be stored in GAM, not game saveability
		if (actor->GetStat(IE_STATE_ID) & (STATE_NOSAVE|STATE_MINDLESS)) {
			//some actor is in nosave state
			displaymsg->DisplayConstantString(STR_CANTSAVENOCTRL, DMC_BG2XPGREEN);
			return 5;
		}
		if (actor->GetCurrentArea()!=map) {
			//scattered
			displaymsg->DisplayConstantString(STR_CANTSAVE, DMC_BG2XPGREEN);
			return 6;
		}

		if (map->AnyEnemyNearPoint(actor->Pos)) {
			displaymsg->DisplayConstantString( STR_CANTSAVEMONS, DMC_BG2XPGREEN );
			return 7;
		}

	}

	Point pc1 =  game->GetPC(0, true)->Pos;
	Actor **nearActors = map->GetAllActorsInRadius(pc1, GA_NO_DEAD|GA_NO_UNSCHEDULED, 15*10);
	i = 0;
	while (nearActors[i]) {
		Actor *actor = nearActors[i];
		if (actor->GetInternalFlag() & IF_NOINT) {
			// dialog about to start or similar
			displaymsg->DisplayConstantString(STR_CANTSAVEDIALOG2, DMC_BG2XPGREEN);
			return 8;
		}
		i++;
	}
	free(nearActors);

	//TODO: can't save while AOE spells are in effect -> CANTSAVE
	//TODO: can't save  during a rest, chapter information or movie -> CANTSAVEMOVIE

	return 0;
}