ff_u_nui_ribbon
Show the area name in a ribbon on area enter.
The ribbon is displayed for 5 seconds at the top of the screen.
The window is built with ff_i_nuibuilder.
Variables
ENABLE__FF_U_NUI_RIBBON: (string) (opt-in) Set to "Y" on module to enable the unit.
Submitted by Enonwow on 2025-09-05 00:55.
https://neverwintervault.org/project/nwnee/other/gui/ribbon-system
Source code
// @code
#include "ff_i_core"
#include "ff_i_nuibuilder"
const string ENABLE__FF_U_NUI_RIBBON = "ENABLE__FF_U_NUI_RIBBON";
const string RIBBON_WINDOW_ID = "__RIBBON_WINDOW_ID";
const int RIBBON_ORIGINAL_WIDTH = 846;
const int RIBBON_ORIGINAL_HEIGHT = 250;
float RIBBON_WIDTH = RIBBON_ORIGINAL_WIDTH / 2.0;
float RIBBON_HEIGHT = RIBBON_ORIGINAL_HEIGHT / 2.0;
// -----------------------------------------------------------------------------
//! @brief Show a ribbon with sText to oPC for 5 seconds.
//! @param oPC The PC.
//! @param sText Text to display.
void CreateRibbonWindow(object oPC, string sText)
{
if (!GetIsPC(oPC))
return;
int nToken = NuiFindWindow(oPC, RIBBON_WINDOW_ID);
if (nToken > 0)
return;
int nDeviceWidth = GetPlayerDeviceProperty(oPC, PLAYER_DEVICE_PROPERTY_GUI_WIDTH);
float fWindowX = (nDeviceWidth - RIBBON_WIDTH) / 2.0;
float fWindowY = 0.0;
int nTextLength = GetStringLength(sText);
int nTextX = nTextLength * 7;
float fTextWidth = nTextLength * 8.0;
NUI_InitializeWindow(NuiRect(fWindowX, fWindowY, RIBBON_WIDTH + 15.0, RIBBON_HEIGHT + 15.0));
NUI_SetWindowTitlebarHidden();
NUI_SetWindowTransparent(JsonBool(TRUE));
NUI_SetWindowBorder(JsonBool(FALSE));
NUI_StartColumn();
NUI_StartElement(NuiSpacer());
NUI_StartDrawList(JsonBool(FALSE));
NUI_AddDrawListItem(NuiDrawListImage(
JsonBool(TRUE),
JsonString("ribbon"),
NuiRect(0.0, 0.0, RIBBON_WIDTH, RIBBON_HEIGHT),
JsonInt(NUI_ASPECT_STRETCH),
JsonInt(NUI_HALIGN_LEFT),
JsonInt(NUI_VALIGN_TOP),
NUI_DRAW_LIST_ITEM_ORDER_BEFORE,
NUI_DRAW_LIST_ITEM_RENDER_ALWAYS));
NUI_AddDrawListItem(NuiDrawListText(
JsonBool(TRUE),
NuiColor(255, 255, 255),
NuiRect((RIBBON_WIDTH - nTextX) / 2, RIBBON_HEIGHT / 1.5, fTextWidth, 15.0),
JsonString(sText),
NUI_DRAW_LIST_ITEM_ORDER_AFTER,
NUI_DRAW_LIST_ITEM_RENDER_ALWAYS));
NUI_End();
NUI_End();
NUI_End();
nToken = NuiCreate(oPC, NUI_FinalizeWindow(), RIBBON_WINDOW_ID);
if (nToken)
DelayCommand(5.0, NuiDestroy(oPC, nToken));
}
// -----------------------------------------------------------------------------
void main()
{
string sEvent = NWNX_Events_GetCurrentEvent();
if (sEvent == ON_REGISTER)
{
if (!GetModuleFlag(ENABLE__FF_U_NUI_RIBBON, FALSE))
return;
SubscribeToEvent(ON_DEFAULT_AREA_ENTER, __FILE__);
}
else
CreateRibbonWindow(GetEnteringObject(), GetName(OBJECT_SELF));
}