Skip to content
Snippets Groups Projects
Commit 86a5c58b authored by dg's avatar dg
Browse files

Escort quest rewards provide a tooltip

git-svn-id: http://svn.net-core.org/repos/t-engine4@1472 51575b47-30f0-44d4-a5cc-537603b46e54
parent 82c8a941
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,7 @@ function _M:init(chat, id)
self:generateList()
self.c_list = VariableList.new{width=self.iw - 10, list=self.list, fct=function(item) self:use(item) end}
self.c_list = VariableList.new{width=self.iw - 10, list=self.list, fct=function(item) self:use(item) end, select=function(item) self:select(item) end}
self:loadUI{
{left=0, top=0, ui=self.c_desc},
......@@ -57,12 +57,19 @@ function _M:init(chat, id)
}
end
function _M:select(item)
local a = self.chat:get(self.cur_id).answers[item.answer]
if not a then return end
if a.on_select then
a.on_select(self.npc, self.player, self)
end
end
function _M:use(item, a)
a = a or self.chat:get(self.cur_id).answers[item.answer]
if not a then return end
self.changed = true
print("[CHAT] selected", a[1], a.action, a.jump)
if a.action then
local id = a.action(self.npc, self.player, self)
......
......@@ -22,9 +22,10 @@ require "engine.Dialog"
module(..., package.seeall, class.inherit(engine.Dialog))
function _M:init(title, url, on_finish)
function _M:init(title, url, on_chunk, on_finish)
self.url = url
self.received = 0
self.on_chunk = on_chunk
self.on_finish = on_finish
local font = core.display.newFont("/data/font/Vera.ttf", 12)
......@@ -37,12 +38,15 @@ end
function _M:drawDialog(s)
if self.th then
local t = self.linda:receive(0, "final")
local len = self.linda:receive(0, "received")
while len do
len = self.linda:receive(0, "received")
if len then self.received = len end
local ck = self.linda:receive(0, "received")
while ck do
if ck then
self.received = ck.size
self.on_chunk(ck.chunk)
end
ck = self.linda:receive(0, "received")
end
local t = self.linda:receive(0, "final")
local v, err = self.th:join(0)
if err then error(err) end
......@@ -52,7 +56,7 @@ function _M:drawDialog(s)
self.linda = nil
self.th = nil
game:unregisterDialog(self)
self:on_finish(t)
self:on_finish()
end
end
......@@ -67,17 +71,16 @@ function _M:startDownload()
local http = require "socket.http"
local ltn12 = require "ltn12"
local t = {}
local size = 0
http.request{url = src, sink = function(chunk, err)
if err then error(err) end
if chunk then
size = size + #chunk
l:send(0, "received", size)
table.insert(t, chunk)
l:send(0, "received", {size=size, chunk=chunk})
end
return 1
end}
l:send("final", t)
l:send("final", true)
end
self.th = lanes.gen("*", list_handler)(self.url)
......
......@@ -28,6 +28,7 @@ function _M:init(t)
self.list = assert(t.list, "no list list")
self.w = assert(t.width, "no list width")
self.fct = t.fct
self.select = t.select
self.display_prop = t.display_prop or "name"
Base.init(self, t)
......@@ -85,6 +86,7 @@ function _M:generate()
self.mouse:registerZone(0, self.h, self.w, fh, function(button, x, y, xrel, yrel, bx, by, event)
self.sel = i
self:onSelect()
if button == "left" and event == "button" then self:onUse() end
end)
......@@ -94,8 +96,8 @@ function _M:generate()
-- Add UI controls
self.key:addBinds{
ACCEPT = function() self:onUse() end,
MOVE_UP = function() self.sel = util.boundWrap(self.sel - 1, 1, self.max) end,
MOVE_DOWN = function() self.sel = util.boundWrap(self.sel + 1, 1, self.max) end,
MOVE_UP = function() self.sel = util.boundWrap(self.sel - 1, 1, self.max) self:onSelect() end,
MOVE_DOWN = function() self.sel = util.boundWrap(self.sel + 1, 1, self.max) self:onSelect() end,
}
end
......@@ -106,6 +108,13 @@ function _M:onUse()
else self.fct(item, self.sel) end
end
function _M:onSelect()
local item = self.list[self.sel]
if not item then return end
if rawget(self, "select") then self.select(item, self.sel) end
end
function _M:display(x, y)
for i = 1, self.max do
local item = self.list[i]
......
......@@ -18,7 +18,7 @@
-- darkgod@te4.org
-- Engine Version
engine.version = {0,9,14,"te4",5}
engine.version = {0,9,13,"te4",5}
engine.require_c_core = engine.version[5]
engine.version_id = ("%s-%d_%d.%d.%d"):format(engine.version[4], engine.require_c_core, engine.version[1], engine.version[2], engine.version[3])
......
......@@ -152,14 +152,16 @@ function _M:updateAll()
d:startDownload()
elseif next.mod then
local mod = next.mod
local d = DownloadDialog.new("Downloading game: "..next.name, mod.download, function(di, data)
fs.mkdir("/tmp-dl/modules")
local fname = ("/tmp-dl/modules/%s.team"):format(mod.short_name, mod.version[1], mod.version[2], mod.version[3])
files[#files+1] = fname
local f = fs.open(fname, "w")
for i, v in ipairs(data) do f:write(v) end
f:close()
fs.mkdir("/tmp-dl/modules")
local fname = ("/tmp-dl/modules/%s-%d.%d.%d.team"):format(mod.short_name, mod.version[1], mod.version[2], mod.version[3])
files[#files+1] = fname
-- local f = fs.open(fname, "w")
local d = DownloadDialog.new("Downloading: "..next.name, mod.download, function(chunk)
-- f:write(chunk)
end, function(di, data)
-- f:close()
do_next()
end)
game:registerDialog(d)
......
......@@ -24,7 +24,7 @@ author = { "DarkGod", "darkgod@te4.org" }
homepage = "http://te4.org/"
is_boot = true
version = {1,0,0}
engine = {0,9,14,"te4"}
engine = {0,9,13,"te4"}
description = [[
Bootmenu!
]]
......
......@@ -136,7 +136,15 @@ local function generate_rewards()
player.changed = true
player:hasQuest(npc.quest_id).reward_message = ("improved %s by +%d"):format(npc.stats_def[i].name, reward.stats[i])
end
answers[#answers+1] = {("[Improve %s by +%d]"):format(npc.stats_def[i].name, reward.stats[i]), jump="done", action=doit}
answers[#answers+1] = {("[Improve %s by +%d]"):format(npc.stats_def[i].name, reward.stats[i]),
jump="done",
action=doit,
on_select=function(npc, player)
game.tooltip_x, game.tooltip_y = 1, 1
local TooltipsData = require("mod.class.interface.TooltipsData")
game.tooltip:displayAtMap(nil, nil, game.w, game.h, TooltipsData["TOOLTIP_"..npc.stats_def[i].short_name:upper()])
end,
}
end end
end
if reward.talents then
......@@ -149,7 +157,15 @@ local function generate_rewards()
if t.hide then player.__show_special_talents[tid] = true end
player:hasQuest(npc.quest_id).reward_message = ("%s talent %s (+%d level(s))"):format(game.player:knowTalent(tid) and "improved" or "learnt", t.name, level)
end
answers[#answers+1] = {("[%s talent %s (+%d level(s))]"):format(game.player:knowTalent(tid) and "Improve" or "Learn", t.name, level), jump="done", action=doit}
answers[#answers+1] = {
("[%s talent %s (+%d level(s))]"):format(game.player:knowTalent(tid) and "Improve" or "Learn", t.name, level),
jump="done",
action=doit,
on_select=function(npc, player)
game.tooltip_x, game.tooltip_y = 1, 1
game.tooltip:displayAtMap(nil, nil, game.w, game.h, "#GOLD#"..t.name.."#LAST#\n"..player:getTalentFullDescription(t, 1))
end,
}
end
end
end
......@@ -162,7 +178,14 @@ local function generate_rewards()
player:setTalentTypeMastery(tt, mastery)
player:hasQuest(npc.quest_id).reward_message = ("gained talent category %s (at mastery %0.2f)"):format(cat:capitalize().." / "..tt_def.name:capitalize(), mastery)
end
answers[#answers+1] = {("[Allow training of talent category %s (at mastery %0.2f)]"):format(cat:capitalize().." / "..tt_def.name:capitalize(), mastery), jump="done", action=doit}
answers[#answers+1] = {("[Allow training of talent category %s (at mastery %0.2f)]"):format(cat:capitalize().." / "..tt_def.name:capitalize(), mastery),
jump="done",
action=doit,
on_select=function(npc, player)
game.tooltip_x, game.tooltip_y = 1, 1
game.tooltip:displayAtMap(nil, nil, game.w, game.h, "#GOLD#"..(cat:capitalize().." / "..tt_def.name:capitalize()).."#LAST#\n"..tt_def.description)
end,
}
end end
end
return answers
......
......@@ -22,8 +22,8 @@ long_name = "Tales of Middle Earth: The Fourth Age"
short_name = "tome"
author = { "DarkGod", "darkgod@te4.org" }
homepage = "http://tome.te4.org/"
version = {3,9,14}
engine = {0,9,14,"te4"}
version = {3,9,13}
engine = {0,9,13,"te4"}
description = [[
Morgoth is banned to the Void. Sauron has been vanquished, the #ff0000#One Ring#ffffff# destroyed.
The nations of Men, Dwarves, Elves and Hobbits are freed from the tyranny of the Rings.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment