Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void __stdcall InstallHudComponents(HUDMenu * menu)
- {
- BSTArrayFunctor<HUDObject*> alloc(&menu->hudComponents);
- GFxValue hudComponent;
- GFxValue args[2];
- args[0].SetString("hudExtension");
- args[1].SetNumber(-1);
- menu->view->Invoke("_root.createEmptyMovieClip", &hudComponent, args, 2);
- args[0].SetString("hud_extension.swf");
- hudComponent.Invoke("loadMovie", NULL, &args[0], 1);
- HUDEnemyHealthbars * healthBars = new HUDEnemyHealthbars(menu->view);
- healthBars->object = hudComponent;
- alloc.Push((HUDObject*&)healthBars);
- }
- void HUDEnemyHealthbars::Update()
- {
- for(UInt32 i = 0; i < (*g_thePlayer)->hostileHandles.count; i++) {
- UInt32 handle = 0;
- (*g_thePlayer)->hostileHandles.GetNthItem(i, handle);
- EnemyHealthbar dummy;
- dummy.handle = handle;
- std::pair<EnemySet::iterator,bool> ret = components.insert(dummy);
- if(ret.second == false) {
- // AttachMovie, new handle added
- GFxValue meterComponent;
- GFxValue arg;
- arg.SetNumber(handle);
- view->Invoke("_root.hudExtension.loadMeter", &meterComponent, &arg, 1);
- (*ret.first).object = meterComponent;
- }
- }
- EnemySet::iterator it = components.begin();
- while(it != components.end())
- {
- UInt32 handle = (*it).handle;
- TESObjectREFR * refr = NULL;
- LookupREFRByHandle(&handle, &refr);
- if(!refr) { // Handle lookup failed, delete it
- components.erase(it++);
- continue;
- }
- if(refr) {
- Actor * actor = DYNAMIC_CAST(refr, TESObjectREFR, Actor);
- if(actor) {
- if(actor->actorValueOwner.GetCurrent(24) < 0.0) { // Actor died
- components.erase(it++);
- continue;
- }
- NiPoint3 markerPos;
- refr->GetMarkerPosition(&markerPos);
- 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;
- y_out = rect.top + (rect.bottom - rect.top) * y_out;
- x_out = rect.bottom + (rect.right - rect.left) * x_out;
- if(it->object.IsDisplayObject()) {
- GFxValue::DisplayInfo dInfo;
- it->object.GetDisplayInfo(&dInfo);
- dInfo.x = x_out;
- dInfo.y = y_out;
- it->object.SetDisplayInfo(&dInfo);
- }
- }
- }
- it++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement