diff options
Diffstat (limited to 'src/wm_hud.cpp')
-rw-r--r-- | src/wm_hud.cpp | 72 |
1 files changed, 65 insertions, 7 deletions
diff --git a/src/wm_hud.cpp b/src/wm_hud.cpp index aa8a8b4..4335c6a 100644 --- a/src/wm_hud.cpp +++ b/src/wm_hud.cpp @@ -21,14 +21,23 @@ dWMHud_c::dWMHud_c() { } +// TODO: Need to define these in a better way, somehow +#define ANIM_BUTTON_1 0 +#define ANIM_BUTTON_2 1 +#define ANIM_BOTTOM_SHOW 2 +#define ANIM_BOTTOM_HIDE 3 +#define ANIM_TOP_SHOW 4 +#define ANIM_TOP_HIDE 5 + int dWMHud_c::onCreate() { if (!layoutLoaded) { bool gotFile = layout.loadArc("maphud.arc", false); if (!gotFile) return false; - static const char *brlanNames[3] = {"maphud_hitbutton.brlan", "maphud_in.brlan", "maphud_out.brlan"}; - static const char *groupNames[4] = {"B01_Button", "B02_Button", "A00_Window", "A00_Window"}; + //static const char *brlanNames[3] = {"maphud_hitbutton.brlan", "maphud_in.brlan", "maphud_out.brlan"}; + static const char *brlanNames[5] = {"maphud_hitbutton.brlan", "bottom_in.brlan", "bottom_out.brlan", "top_in.brlan", "top_out.brlan"}; + static const char *groupNames[6] = {"B01_Button", "B02_Button", "A00_Window", "A00_Window", "A01_Window", "A01_Window"}; bool output = layout.build("maphud.brlyt"); @@ -42,12 +51,12 @@ int dWMHud_c::onCreate() { layout.layout.rootPane->scale.y = 0.7711f; } - layout.loadAnimations(brlanNames, 3); - layout.loadGroups(groupNames, (int[4]){0, 0, 1, 2}, 4); + layout.loadAnimations(brlanNames, 5); + layout.loadGroups(groupNames, (int[6]){0, 0, 1, 2, 3, 4}, 6); layout.disableAllAnimations(); - layout.enableNonLoopAnim(2); + layout.enableNonLoopAnim(ANIM_BOTTOM_SHOW); - updateText(); + showPointBar(); layoutLoaded = true; } @@ -77,7 +86,13 @@ int dWMHud_c::onDraw() { void dWMHud_c::updateText() { + setPointName(); +} + + +void dWMHud_c::setPointName() { wchar_t newPointName[120]; + int length; // figure this out... WMPathPoint *point = dWMPathManager_c::instance->currentPoint; @@ -93,12 +108,55 @@ void dWMHud_c::updateText() { for (int i = 0; i < 120 && i < entry->nameLength; i++) { newPointName[i] = levelName[i]; } + length = entry->nameLength; newPointName[entry->nameLength] = 0; } else { newPointName[0] = 0; + length = 0; + } + + nw4r::lyt::TextBox *box = layout.findTextBoxByName("T_levelname_01"); + + nw4r::ut::TextWriter tw; + tw.font = box->font; + tw.SetFontSize(box->fontSizeX, box->fontSizeY); + tw.somethingRelatedToLineHeight = box->lineSpace; + tw.charSpace = box->charSpace; + if (box->tagProc != 0) + tw.tagProcessorMaybe = box->tagProc; + + float width = tw.CalcStringWidth(newPointName, length); + SpammyReport("Text width: %f\n", width); + + layout.findWindowByName("W_levelname")->size.x = width + 22; + layout.findPictureByName("P_topleftboxbg")->size.x = width; + layout.findPictureByName("P_topthinboxbg")->size.x = 597 - width; + + box->SetString(newPointName); +} + + +void dWMHud_c::showPointBar() { + WMPathPoint *point = dWMPathManager_c::instance->currentPoint; + + if (point->type == WMPathPoint::LEVEL_TYPE) { + isPointBarShown = true; + + updateText(); + + layout.enableNonLoopAnim(ANIM_TOP_SHOW); } +} + + +void dWMHud_c::hidePointBar() { + if (isPointBarShown) { + isPointBarShown = false; - layout.findTextBoxByName("T_levelname_01")->SetString(newPointName); + layout.enableNonLoopAnim(ANIM_TOP_HIDE); + } } + + |