diff options
Diffstat (limited to '')
-rw-r--r-- | src/koopatlas/hud.cpp | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp new file mode 100644 index 0000000..c5b2c6e --- /dev/null +++ b/src/koopatlas/hud.cpp @@ -0,0 +1,168 @@ +#include "koopatlas/hud.h" + +dWMHud_c *dWMHud_c::instance = 0; + +dWMHud_c *dWMHud_c::build() { + OSReport("Creating WM_Hud\n"); + + void *buffer = AllocFromGameHeap1(sizeof(dWMHud_c)); + dWMHud_c *c = new(buffer) dWMHud_c; + + OSReport("Created WM_Hud @ %p\n", c); + + instance = c; + return c; +} + + + +dWMHud_c::dWMHud_c() { + layoutLoaded = false; +} + + +// 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 *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"); + + if (!IsWideScreen()) { + layout.clippingEnabled = true; + layout.clipX = 0; + layout.clipY = 52; + layout.clipWidth = 640; + layout.clipHeight = 352; + layout.layout.rootPane->scale.x = 0.7711f; + layout.layout.rootPane->scale.y = 0.7711f; + } + + layout.loadAnimations(brlanNames, 5); + layout.loadGroups(groupNames, (int[6]){0, 0, 1, 2, 3, 4}, 6); + layout.disableAllAnimations(); + layout.enableNonLoopAnim(ANIM_BOTTOM_SHOW); + + showPointBar(); + + layoutLoaded = true; + } + + return true; +} + + +int dWMHud_c::onDelete() { + return layout.free(); +} + + +int dWMHud_c::onExecute() { + layout.execAnimations(); + layout.update(); + + return true; +} + + +int dWMHud_c::onDraw() { + layout.scheduleForDrawing(); + + return true; +} + + +void dWMHud_c::updateText() { + setPointName(); +} + + +void dWMHud_c::setPointName() { + wchar_t newPointName[120]; + int length; + + // figure this out... + /*WMPathPoint *point = dWMPathManager_c::instance->currentPoint; + + if (point->type == WMPathPoint::LEVEL_TYPE) { + LevelInfo *li = &dScNewerWorldMap_c::instance->levelInfo; + LevelInfo::Entry *entry = li->search(point->params[0] - 1, point->params[1] - 1); + + char *levelName = li->getNameForLevel(entry); + + // copy it + // I need to make this into a function. + 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; + }*/ + + const char *str = "This needs to be done\0"; + length = 21; + for (int i = 0; i < length; i++) + newPointName[i] = str[i]; + newPointName[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 (true) {//point->type == WMPathPoint::LEVEL_TYPE) { + isPointBarShown = true; + + updateText(); + + layout.enableNonLoopAnim(ANIM_TOP_SHOW); + } +} + + +void dWMHud_c::hidePointBar() { + if (isPointBarShown) { + isPointBarShown = false; + + layout.enableNonLoopAnim(ANIM_TOP_HIDE); + } +} + + + |