Skip to content
Snippets Groups Projects
Commit 60c474ef authored by dg's avatar dg
Browse files

Password will not be displayed onscreen anymore

TE4 main menu will display a "news of the day"


git-svn-id: http://svn.net-core.org/repos/t-engine4@1027 51575b47-30f0-44d4-a5cc-537603b46e54
parent c93f1962
No related branches found
No related tags found
No related merge requests found
......@@ -106,7 +106,6 @@ function _M:select(i, offset)
end
if self.selected > #self.list then self.selected = 1 end
if self.selected < 1 then self.selected = #self.list end
print(self.list,self.selected)
if old ~= self.selected and self.list[self.selected].onSelect then self.list[self.selected].onSelect() end
self.changed = true
end
......
......@@ -217,6 +217,14 @@ function _M:rpc(data)
end
end
function _M:getNews()
print("[ONLINE PROFILE] get news")
local data = self:rpc{action="GetNews"}
if not data then print("[ONLINE PROFILE] no news") return end
print("[ONLINE PROFILE] news ", data[1] and data[1].title)
return data
end
function _M:tryAuth()
print("[ONLINE PROFILE] auth")
local data = self:rpc{action="TryAuth", login=self.login, pass=self.pass}
......@@ -250,6 +258,7 @@ end
function _M:setConfigs(module, name, val)
if not self.auth then return end
if name == "online" then return end
if type(val) ~= "string" then val = serialize(val) end
......
......@@ -28,8 +28,8 @@ module(..., package.seeall, class.inherit(
tiles = engine.Tiles.new(16, 16)
function _M:init(dialogdef, owner, font, mask, fct)
--name, title, min, max, x, y, w, height
function _M:init(dialogdef, owner, font, mask, fct)
--name, title, min, max, x, y, w, height
self.type = "TextBox"
self.name = dialogdef.name
self.title = dialogdef.title
......@@ -37,23 +37,24 @@ function _M:init(dialogdef, owner, font, mask, fct)
self.max = dialogdef.max or 25
self.h = dialogdef.h or 30
self.font = font
self.w = dialogdef.w or 200
self.w = dialogdef.w or 200
self.x = dialogdef.x
self.y = dialogdef.y
self.private = dialogdef.private
self.text = ""
self.owner = owner
self.btn = {
self.owner = owner
self.btn = {
h = dialogdef.h,
mouse_over= function(button)
if self.owner.state ~= self.name then self.focused=true self.owner:focusControl(self.name) end
mouse_over= function(button)
if self.owner.state ~= self.name then self.focused=true self.owner:focusControl(self.name) end
if button == "right" then
self.text=""
self.text=""
self.ownwer.changed=true
end
end
}
self.owner.mouse:registerZone(self.owner.display_x + self.x, self.owner.display_y + self.y + self.h, self.w, self.h, self.btn.mouse_over)
self:startCursor()
self.owner.mouse:registerZone(self.owner.display_x + self.x, self.owner.display_y + self.y + self.h, self.w, self.h, self.btn.mouse_over)
self:startCursor()
end
function _M:delete()
......@@ -62,11 +63,11 @@ function _M:delete()
if self.cursorPosition < self.maximumCurosrPosition - 1 then temptext = temptext..self.text:sub(self.cursorPosition + 2, self.text:len()) end
self.text = temptext
self.maximumCurosrPosition = self.maximumCurosrPosition - 1
end
end
function _M:backSpace()
if (self.cursorPosition==0) then return end
local temptext = self.text:sub(1, self.cursorPosition - 1)
local temptext = self.text:sub(1, self.cursorPosition - 1)
if self.cursorPosition < self.maximumCurosrPosition then temptext = temptext..self.text:sub(self.cursorPosition + 1, self.text:len()) end
self.text = temptext
self.maximumCurosrPosition = self.maximumCurosrPosition - 1
......@@ -80,9 +81,7 @@ function _M:textInput(c)
self.text = self.text:sub(1,self.cursorPosition) .. c
if temp then self.text=self.text..temp end
self.owner.changed = true
print("[Cursor] before ", c, self.cursorPosition, self.maximumCurosrPosition)
self:moveRight(1, true)
print("[Cursor] after ", c, self.cursorPosition, self.maximumCurosrPosition)
self:moveRight(1, true)
end
end
......@@ -91,8 +90,8 @@ function _M:unFocus()
end
function _M:drawControl(s)
function _M:drawControl(s)
local r, g, b
local w = self.w
local h = self.h
......@@ -102,8 +101,8 @@ function _M:drawControl(s)
if self.owner.state==self.name then
title = title.."*"
end
r, g, b = s:drawColorStringBlended(self.font, title, self.x, self.y + ((h - th) / 2), r, g, b)
r, g, b = s:drawColorStringBlended(self.font, title, self.x, self.y + ((h - th) / 2), r, g, b)
s:merge(tiles:get(nil, 0,0,0, 0,0,0, "border_7"..(sel and "_sel" or "")..".png"), self.x + tw, self.y)
s:merge(tiles:get(nil, 0,0,0, 0,0,0, "border_9"..(sel and "_sel" or "")..".png"), w + self.x - 8, self.y)
s:merge(tiles:get(nil, 0,0,0, 0,0,0, "border_1"..(sel and "_sel" or "")..".png"), self.x + tw, self.y + h - 8)
......@@ -119,10 +118,11 @@ function _M:drawControl(s)
local text = self.text
if text=="" then text=self.mask or "" end
if self.private then text = text:gsub('.', '*') end
local sw, sh = self.font:size(text)
local baseX = self.x + tw + 10
s:drawColorStringBlended(self.font, text, baseX, self.y + h - sh - 8)
self:drawCursor(s, baseX, text)
end
......@@ -25,12 +25,12 @@ module(..., package.seeall, class.make)
tiles = engine.Tiles.new(16, 16)
function _M:init(fontname, fontsize, color, bgcolor)
function _M:init(fontname, fontsize, color, bgcolor, max)
self.color = color or {255,255,255}
self.bgcolor = bgcolor or {0,0,0}
self.font = core.display.newFont(fontname or "/data/font/Vera.ttf", fontsize or 12)
self.font_h = self.font:lineSkip()
self.max = max or 400
self.max = max or 300
self.changed = true
self.old_tmx, self.old_tmy = -1,-1
self.old_turn = -1
......@@ -38,7 +38,7 @@ end
--- Set the tooltip text
function _M:set(str, ...)
self.text = str:format(...):splitLines(300, self.font)
self.text = str:format(...):splitLines(self.max, self.font)
self.w, self.h = 0, 0
for i, l in ipairs(self.text) do
local w, h = self.font:size(l)
......@@ -100,6 +100,12 @@ function _M:display()
self.texture = self.surface:glTexture()
end
function _M:toScreen(x, y)
if self.surface then
self.surface:toScreenWithTexture(self.texture, x, y)
end
end
--- Displays the tooltip at the given map coordinates
-- @param tmx the map coordinate to get tooltip from
-- @param tmy the map coordinate to get tooltip from
......
......@@ -24,6 +24,7 @@ require "engine.interface.GameMusic"
local Module = require "engine.Module"
local Savefile = require "engine.Savefile"
local Dialog = require "engine.Dialog"
local Tooltip = require "engine.Tooltip"
local ButtonList = require "engine.ButtonList"
local DownloadDialog = require "engine.dialogs.DownloadDialog"
......@@ -34,6 +35,8 @@ function _M:init()
self.profile_font = core.display.newFont("/data/font/VeraIt.ttf", 14)
engine.Game.init(self, engine.KeyBind.new())
self.tooltip = Tooltip.new(nil, 14, nil, colors.DARK_GREY, 400)
self.background = core.display.loadImage("/data/gfx/mainmenu/background.png")
self.refuse_threads = true
end
......@@ -80,6 +83,11 @@ function _M:display()
self.s_log:toScreen(self.w - w, self.h - h)
end
if self.step.do_tooltip then
self.tooltip:display()
self.tooltip:toScreen(5, 5)
end
engine.Game.display(self)
end
......@@ -209,7 +217,21 @@ function _M:selectStepMain()
core.game.exit_engine()
end,
},
}, self.w * 0.3, self.h * 0.2, self.w * 0.4, self.h * 0.3)
}, 400, self.h * 0.2, self.w * 0.4, self.h * 0.3)
if not self.news then
self.news = profile:getNews()
if not self.news or not self.news[1] then
self.nesw = {
title = 'Welcome to T-Engine and the Tales of Middle-earth',
text = [[From this interface you can create new characters for the game modules you want to play.
T-Engine comes by default with the "Tales of Middle-earth" module, you can also install more by selecting "Install a game module" or by going to http://te4.org/
]]
}
end
self.tooltip:set("%s\n---\n%s", self.news[1].title, self.news[1].text)
end
self.step.do_tooltip = true
if not self.firstrunchecked then
-- Check first time run for online profile
......
......@@ -89,7 +89,7 @@ function _M:init(dialogdef, profile_help_text)
local basey = #self.lines * self.font:lineSkip() + 25
self:addControl(TextBox.new({name="login",title="Login:",min=2, max=25, x=30, y=basey + 5, w=350, h=30}, self, self.font, "login name"))
self:addControl(TextBox.new({name="pass",title ="Password:",min=2, max=25, x=30, y=basey + 45, w=350, h=30}, self, self.font, "password"))
self:addControl(TextBox.new({name="pass",title ="Password:",min=2, max=25, x=30, y=basey + 45, w=350, h=30, private=true}, self, self.font, "password"))
if not self.justlogin then
self:addControl(TextBox.new({name="email",title="Email Address:",min=2, max=25, x=30, y=basey + 85, w=350, h=30}, self, self.font, "email address"))
self:addControl(TextBox.new({name="name",title="Name:",min=2, max=25, x=30, y=basey + 125, w=350, h=30}, self, self.font, "name"))
......
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