diff --git a/config.js b/config.js index f2490d5..e180be4 100644 --- a/config.js +++ b/config.js @@ -11,8 +11,7 @@ function tabulate(html) { } -function template(id, data) { - var tmpl = $("#" + id).html(); +function template(tmpl, data) { var brag = tmpl.replace(/\$([_A-Za-z.]+)/g, function (str, p1) { var dict = data; $.each(p1.split("."), function (i,v) { diff --git a/main.html b/main.html index f7849fa..a42d01b 100644 --- a/main.html +++ b/main.html @@ -71,7 +71,9 @@ Experience +
+
@@ -126,6 +128,7 @@ Encumbrance
+
@@ -142,6 +145,7 @@
+
@@ -154,6 +158,7 @@
+
@@ -163,13 +168,14 @@
Executing a Greater Wolog
+

-Cheats: +Cheat @@ -177,10 +183,10 @@ Cheats: $Traits.Name the $Traits.Race [$hostname] $motto -Level $Traits.Level $Traits.Class (exp. $ExpBar.position/$ExpBar.max) +Level $Traits.Level $Traits.Class (exp. $ExpBar.position / $ExpBar.max) -Plot stage: $Plots.last ($PlotBar.Hint) -Quest: $Quests.last ($QuestBar.Hint) +Plot stage: $Plots.last ($PlotBar.hint) +Quest: $Quests.last ($QuestBar.hint) Stats: STR $Stats.STR @@ -194,7 +200,7 @@ Equipment: $Equips.___ Spell Book: $Spells.___ -Inventory ($EncumBar.Hint): +Inventory ($EncumBar.hint): $Inventory.___ -- $date -- Progress Quest 6.3.web - http://progressquest.com/ diff --git a/main.js b/main.js index f4e4d0c..09f873f 100644 --- a/main.js +++ b/main.js @@ -1,10 +1,10 @@ // Copyright (c)2002-2010 Eric Fredricksen all rights reserved -// TODO: All these Hints // TODO: Test use of seed as DNA // TODO: Layout newguy and main better // TODO: fix Prologue plot bar // TODO: limit number of Acts +// TODO: get first quest // revs: // 6: pq 6.3/web @@ -103,7 +103,7 @@ function Plural(s) { return Copy(s,1,Length(s)-1) + 'ies'; else if (Ends(s,'us')) return Copy(s,1,Length(s)-2) + 'i'; - else if (Ends(s,'ch') || Ends(s,'x') || Ends(s,'s')) + else if (Ends(s,'ch') || Ends(s,'x') || Ends(s,'s') || Ends(s, 'sh')) return s + 'es'; else if (Ends(s,'f')) return Copy(s,1,Length(s)-1) + 'ves'; @@ -398,10 +398,8 @@ function Put(list, key, value) { EncumBar.reposition(EncumBar.Position); } - if (list === Inventory) { + if (list === Inventory) EncumBar.reposition(Sum(Inventory) - GetI(Inventory,'Gold')); - EncumBar.Hint = IntToStr(EncumBar.Position) + '/' + IntToStr(EncumBar.Max) + ' cubits'; - } } function LevelUpTime(level) { // seconds @@ -413,6 +411,7 @@ function LevelUpTime(level) { // seconds function ProgressBar(id) { this.id = id; this.bar = $("#"+ id + " > .bar"); + this.hint = ''; this.reset = function (newmax) { this.Max = newmax; @@ -420,8 +419,16 @@ function ProgressBar(id) { }; this.reposition = function (newpos) { - this.Position = newpos; + this.Position = Min(newpos, this.Max); this.bar.css("width", 100 * this.Position / this.Max + "%"); + + // Recompute hint + var label = $("#" + this.id).find(".hint"); + this.percent = (100 * this.Position).div(this.Max); + this.remaining = Math.floor(this.Max - this.Position); + this.time = RoughTime(this.Max - this.Position); + this.hint = template(label.attr("template"), this); + label.text(this.hint); }; this.increment = function (inc) { @@ -433,7 +440,9 @@ function ProgressBar(id) { }; this.save = function (game) { - game[id] = {position: this.Position, max: this.Max}; + game[id] = {position: this.Position, + max: this.Max, + hint: this.hint}; }; this.load = function (game) { @@ -784,7 +793,6 @@ function toArabic(s) { function CompleteAct() { Plots.rows().find("input:checkbox").attr("checked", "true"); PlotBar.reset(60 * 60 * (1 + 5 * Plots.length())); // 1 hr + 5/act - PlotBar.Hint = 'Cutscene omitted'; Plots.Add('Act ' + toRoman(Plots.length())); WinItem(); @@ -801,7 +809,7 @@ function Log(line) { } function CharSheet() { - return template("sheet", game); + return template($("#sheet").html(), game); // TODO: make this a separate page } @@ -902,7 +910,6 @@ function Timer1Timer() { else ExpBar.increment(TaskBar.Max / 1000); } - ExpBar.Hint = Math.floor(ExpBar.Max-ExpBar.Position) + ' XP needed for next level'; // advance quest if (gain) { @@ -911,7 +918,6 @@ function Timer1Timer() { CompleteQuest(); } else if (Quests.length() > 0) { QuestBar.increment(TaskBar.Max / 1000); - QuestBar.Hint = IntToStr(100 * QuestBar.Position.div(QuestBar.Max)) + '% complete'; } } } @@ -922,8 +928,6 @@ function Timer1Timer() { InterplotCinematic(); else PlotBar.increment(TaskBar.Max / 1000); - - PlotBar.Hint = RoughTime(PlotBar.Max-PlotBar.Position) + ' remaining'; } Dequeue(); diff --git a/pq.css b/pq.css index e8790bb..24035c0 100644 --- a/pq.css +++ b/pq.css @@ -123,6 +123,20 @@ div.progress-container > div.bar { width: 50%; } +div.hint { + z-index: 20; + position: absolute; + margin-top: 1px; + visibility: hidden; + width: 250px; + text-align: center; + color: #060; +} + +div.progress-container:hover div.hint { + visibility: visible; +} + #titlebar { background-color: blue; @@ -159,8 +173,8 @@ body { margin-top: 1em; } -#taskbar { - width: 99%; +#TaskBar, #TaskBar .hint { + width: 800px; } div.scroll { diff --git a/roster.js b/roster.js index d59b4e0..e943d5e 100644 --- a/roster.js +++ b/roster.js @@ -54,7 +54,7 @@ $(document).ready(function () { }); function brag(sheet) { - var brag = $(template("badge", sheet)); + var brag = template($("#badge").html(), sheet)); if (sheet.motto) brag.find(".bs").text('"' + sheet.motto + '"'); return brag;