コード例 #1
0
void FxPlayerTiny::SetVisible(GFxValue* mc, bool visible)
{
	if (mc->IsDisplayObject())
	{
		GFxValue::DisplayInfo info;
		info.SetVisible(visible);
		mc->SetDisplayInfo(info);
	}
}
コード例 #2
0
// this involves positioning of the hud elements so i'm assuming magicka and stamina
// will need separate positions below the health bar.
void ObjectWidget::UpdateComponent(GFxMovieView * view, float * depth)
{
	TESForm * form = LookupFormByID(formId);
	if(form) {
		TESObjectREFR * reference = DYNAMIC_CAST(form, TESForm, TESObjectREFR);
		if(reference) {
			NiPoint3 markerPos;
			reference->GetMarkerPosition(&markerPos);
			markerPos.z += 25;

			float x_out = 0.0;
			float y_out = 0.0;
			float z_out = 0.0;

			GRectF rect = view->GetVisibleFrameRect();

			WorldPtToScreenPt3_Internal(g_worldToCamMatrix, g_viewPort, &markerPos, &x_out, &y_out, &z_out, 1e-5);

			// Move component, update component stats
			y_out = 1.0 - y_out; // Flip y for Flash coordinate system
			y_out = rect.top + (rect.bottom - rect.top) * y_out;
			x_out = rect.left + (rect.right - rect.left) * x_out;

			*depth = z_out;

			bool isVisible = false;
			bool isFriendly = false;
			QueryState(reference, &isVisible, &isFriendly);

			if ((g_hudExtension->hudFlags & HUDExtension::kFlags_HideName) == HUDExtension::kFlags_HideName || (flags & ObjectWidget::kFlag_HideName) == ObjectWidget::kFlag_HideName) {
				params[kProperty_Name].SetString("");
				UpdateText();
			} else {
				const char * text = CALL_MEMBER_FN(reference, GetReferenceName)();
				if (params[kProperty_Name].GetString() != text) {
					params[kProperty_Name].SetString(text);
					UpdateText();
				}
			}

			if ((flags & ObjectWidget::kFlag_UseHostility) == ObjectWidget::kFlag_UseHostility) {
				bool nowFriendly = IsFriendly();
				if (nowFriendly && !isFriendly) { // Turned hostile
					flags &= ~ObjectWidget::kFlag_Friendly;
					UpdateFlags();
					UpdateColors();
				}
				else if (!nowFriendly && isFriendly) { // Turned friendly
					flags |= ObjectWidget::kFlag_Friendly;
					UpdateFlags();
					UpdateColors();
				}
			}

			double scale = min(((100 - z_out * 100) * 10), 50);//(1.0 - z_out) * 100;//min(((100 - z_out * 100) * 10), 50);
			if(object.IsDisplayObject()) {
				GFxValue::DisplayInfo dInfo;
				dInfo.SetPosition(x_out, y_out);
				dInfo.SetScale(scale, scale);
				dInfo.SetVisible(isVisible);
				object.SetDisplayInfo(&dInfo);

				if((flags & kFlag_UpdatePercent) == kFlag_UpdatePercent)
					UpdateValues();
			}
		}
	}
}
コード例 #3
0
void ObjectWidget::UpdateProperty(UInt32 type)
{
	switch(type)
	{
	// I'm not sure if you need each data type needs their own separate set of flags or not.
	// I'm assuming the show in combat/hide on death/Line of Sight checks are important but I don't know how
	// I'd apply it to magicka and stamina as well.
	case kPropertyType_Flags:
		{
			// Update visibility if necessary
			if((flags & kFlag_ShowInCombat) == kFlag_ShowInCombat || 
				(flags & kFlag_HideOutOfCombat) == kFlag_HideOutOfCombat || 
				(flags & kFlag_HideOnDeath) == kFlag_HideOnDeath) {
				TESForm * form = LookupFormByID(formId);
				if(form) {
					TESObjectREFR * reference = DYNAMIC_CAST(form, TESForm, TESObjectREFR);
					if(reference) {
						bool isVisible = false;
						bool isFriendly = false;
						QueryState(reference, &isVisible, &isFriendly);
						if(object.IsDisplayObject()) {
							GFxValue::DisplayInfo dInfo;
							dInfo.SetVisible(isVisible);
							object.SetDisplayInfo(&dInfo);
						}
					}
				}
			}
		}
		break;
	// Case fall through so it will keep going through the cases
	// until the break; statement is reached.
	case kPropertyType_HealthCurrentValue:
	case kPropertyType_HealthMaximumValue:
	case kPropertyType_MagickaCurrentValue:
	case kPropertyType_MagickaMaximumValue:
	case kPropertyType_StaminaCurrentValue:
	case kPropertyType_StaminaMaximumValue:
		UpdateValues();
		break;
	// Health Cases
	case kPropertyType_HealthPrimaryColor:
	case kPropertyType_HealthSecondaryColor:
	case kPropertyType_HealthFlashColor:
	case kPropertyType_HealthPrimaryFriendlyColor:
	case kPropertyType_HealthSecondaryFriendlyColor:
	case kPropertyType_HealthFlashFriendlyColor:
	// Magicka Cases
	case kPropertyType_MagickaPrimaryColor:
	case kPropertyType_MagickaSecondaryColor:
	case kPropertyType_MagickaFlashColor:
	case kPropertyType_MagickaPrimaryFriendlyColor:
	case kPropertyType_MagickaSecondaryFriendlyColor:
	case kPropertyType_MagickaFlashFriendlyColor:
	// Stamina Cases
	case kPropertyType_StaminaPrimaryColor:
	case kPropertyType_StaminaSecondaryColor:
	case kPropertyType_StaminaFlashColor:
	case kPropertyType_StaminaPrimaryFriendlyColor:
	case kPropertyType_StaminaSecondaryFriendlyColor:
	case kPropertyType_StaminaFlashFriendlyColor:
		UpdateColors();
		break;
	case kPropertyType_HealthFillMode:
	case kPropertyType_MagickaFillMode:
	case kPropertyType_StaminaFillMode:
		UpdateFillMode();
		break;
	case kPropertyType_StartFlash:
		UpdateFlash();
		break;
	case kPropertyType_Name:
		UpdateText();
		break;
	}
}