summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-06-22 00:26:54 +0200
committerTreeki <treeki@gmail.com>2011-06-22 00:26:54 +0200
commit6ba9c03047a4101c65a4225da7d72b428876421f (patch)
tree11c6fc47bde00435e12af65ae1f8b6b481d76c2a /src
parent3e67e3a91ac797791fabdf4ec730ef8d1a8f6990 (diff)
downloadkamek-6ba9c03047a4101c65a4225da7d72b428876421f.tar.gz
kamek-6ba9c03047a4101c65a4225da7d72b428876421f.zip
a bunch of work on the HUD+animations. why didn't I commit this earlier
Diffstat (limited to 'src')
-rw-r--r--src/wm_hud.cpp72
-rw-r--r--src/wm_path_manager.cpp7
-rw-r--r--src/worldmap.h8
3 files changed, 78 insertions, 9 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);
+ }
}
+
+
diff --git a/src/wm_path_manager.cpp b/src/wm_path_manager.cpp
index f892aca..9883cac 100644
--- a/src/wm_path_manager.cpp
+++ b/src/wm_path_manager.cpp
@@ -134,7 +134,7 @@ void dWMPathManager_c::moveThroughPath() {
//save->current_world = newPage; ?
save->current_path_node = pathData.getPointID(currentPoint);
- dWMHud_c::instance->updateText();
+ dWMHud_c::instance->showPointBar();
} else {
moveToSegment(nextSegment);
}
@@ -158,6 +158,8 @@ void dWMPathManager_c::startMovementTo(WMDirection direction) {
reverseThroughPath = false;
moveToSegment(0);
}
+
+ dWMHud_c::instance->hidePointBar();
}
void dWMPathManager_c::moveToSegment(int id) {
@@ -248,8 +250,9 @@ void dWMPathManager_c::setInitialPathVisibility() {
void dWMPathManager_c::computeEvents() {
+ // TODO: Change this! Testing code!!
for (int i = 0; i < EVENT_COUNT; i++)
- events[i] = false;
+ events[i] = true;
SaveBlock *save = GetSaveFile()->GetBlock(-1);
diff --git a/src/worldmap.h b/src/worldmap.h
index 304b08d..b05432b 100644
--- a/src/worldmap.h
+++ b/src/worldmap.h
@@ -67,8 +67,16 @@ class dWMHud_c : public dBase_c {
void updateText();
+ void showPointBar();
+ void hidePointBar();
+
+ void setPointName();
+
static dWMHud_c *build();
static dWMHud_c *instance;
+
+ private:
+ bool isPointBarShown;
};