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

Autosave on zone switch

git-svn-id: http://svn.net-core.org/repos/t-engine4@1629 51575b47-30f0-44d4-a5cc-537603b46e54
parent daf9da62
No related branches found
No related tags found
No related merge requests found
Showing
with 165 additions and 65 deletions
......@@ -47,7 +47,6 @@ end
-- @param object the object to save
-- @param class a class name, if different from the default one
function _M:push(savename, type, object, class)
print("<<<<", savename, type, object, class, "::", game.onSavefilePush) FIX ME
if game.onSavefilePush then game:onSavefilePush(savename, type, object, class) end
class = class or self.saveclass
......
-- TE4 - T-Engine 4
-- Copyright (C) 2009, 2010 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
-- Defines AIs that can use talents, either smartly or "dumbly"
newAI("angband", function(self)
if self:runAI(self.ai_state.ai_target or "target_simple") then
-- One in "talent_in" chance of using a talent
if (not self.ai_state.no_talents or self.ai_state.no_talents == 0) and rng.chance(self.ai_state.talent_in or 6) and self:reactionToward(self.ai_target.actor) < 0 then
self:runAI("dumb_talented")
end
if not self.energy.used then
self:runAI(self.ai_state.ai_move or "move_simple")
end
return true
end
end)
......@@ -33,6 +33,8 @@ local Actor = require "mod.class.Actor"
local Player = require "mod.class.Player"
local NPC = require "mod.class.NPC"
local PlayerDisplay = require "mod.class.PlayerDisplay"
local HotkeysDisplay = require "engine.HotkeysDisplay"
local ActorsSeenDisplay = require "engine.ActorsSeenDisplay"
local LogDisplay = require "engine.LogDisplay"
......@@ -57,12 +59,15 @@ end
function _M:run()
self.flash = LogFlasher.new(0, 0, self.w, 20, nil, nil, nil, {255,255,255}, {0,0,0})
self.logdisplay = LogDisplay.new(0, self.h * 0.8, self.w * 0.5, self.h * 0.2, nil, nil, nil, {255,255,255}, {30,30,30})
self.hotkeys_display = HotkeysDisplay.new(nil, self.w * 0.5, self.h * 0.8, self.w * 0.5, self.h * 0.2, {30,30,0})
self.npcs_display = ActorsSeenDisplay.new(nil, self.w * 0.5, self.h * 0.8, self.w * 0.5, self.h * 0.2, {30,30,0})
self.logdisplay = LogDisplay.new(0, self.h * 0.8, self.w * 0.5, self.h * 0.2, nil, nil, nil, {255,255,255}, "/data/gfx/ui/message-log.png")
self.player_display = PlayerDisplay.new(0, 220, 200, self.h * 0.8 - 220, {30,30,0})
self.hotkeys_display = HotkeysDisplay.new(nil, self.w * 0.5, self.h * 0.8, self.w * 0.5, self.h * 0.2, "/data/gfx/ui/talents-list.png")
self.npcs_display = ActorsSeenDisplay.new(nil, self.w * 0.5, self.h * 0.8, self.w * 0.5, self.h * 0.2, "/data/gfx/ui/talents-list.png")
self.tooltip = Tooltip.new(nil, nil, {255,255,255}, {30,30,30})
self.flyers = FlyingText.new()
self:setFlyingText(self.flyers)
self.minimap_bg, self.minimap_bg_w, self.minimap_bg_h = core.display.loadImage("/data/gfx/ui/minimap.png"):glTexture()
self:createSeparators()
self.log = function(style, ...) if type(style) == "number" then self.logdisplay(...) self.flash(style, ...) else self.logdisplay(style, ...) self.flash(self.flash.NEUTRAL, style, ...) end end
self.logSeen = function(e, style, ...) if e and self.level.map.seens(e.x, e.y) then self.log(style, ...) end end
......@@ -116,6 +121,12 @@ function _M:loaded()
self.key = engine.KeyBind.new()
end
function _M:createSeparators()
self.bottom_separator, self.bottom_separator_w, self.bottom_separator_h = self:createVisualSeparator("horizontal", self.w)
self.split_separator, self.split_separator_w, self.split_separator_h = self:createVisualSeparator("vertical", math.floor(self.h * 0.2))
self.player_separator, self.player_separator_w, self.player_separator_h = self:createVisualSeparator("vertical", math.floor(self.h * 0.8) - 20)
end
function _M:setupDisplayMode()
print("[DISPLAY MODE] 32x32 ASCII/background")
Map:setViewPort(200, 20, self.w - 200, math.floor(self.h * 0.80) - 20, 16, 16, "/data/font/FSEX300.ttf", 16, true, false)
......@@ -215,13 +226,15 @@ function _M:display()
-- Display the targetting system if active
self.target:display()
-- And the minimap
self.level.map:minimapDisplay(self.w - 200, 20, util.bound(self.player.x - 25, 0, self.level.map.w - 50), util.bound(self.player.y - 25, 0, self.level.map.h - 50), 50, 50, 0.6)
-- Minimap display
self.minimap_bg:toScreenFull(0, 20, 200, 200, self.minimap_bg_w, self.minimap_bg_h)
self.level.map:minimapDisplay(0, 20, util.bound(self.player.x - 25, 0, self.level.map.w - 50), util.bound(self.player.y - 25, 0, self.level.map.h - 50), 50, 50, 1)
end
-- We display the player's interface
self.flash:toScreen()
self.logdisplay:toScreen()
self.player_display:toScreen()
if self.show_npc_list then
self.npcs_display:toScreen()
else
......@@ -229,6 +242,13 @@ function _M:display()
end
if self.player then self.player.changed = false end
-- Separators
self.bottom_separator:toScreenFull(0, 20 - 3, self.w, 6, self.bottom_separator_w, self.bottom_separator_h)
self.bottom_separator:toScreenFull(0, self.h * 0.8 - 3, self.w, 6, self.bottom_separator_w, self.bottom_separator_h)
self.split_separator:toScreenFull(self.w * 0.5 - 3 - 15, self.h * 0.8, 6, self.h * 0.2, self.split_separator_w, self.split_separator_h)
self.split_separator:toScreenFull(self.w * 0.5 - 3, self.h * 0.8, 6, self.h * 0.2, self.split_separator_w, self.split_separator_h)
self.player_separator:toScreenFull(200 - 3, 20, 6, self.h * 0.8 - 20, self.player_separator_w, self.player_separator_h)
-- Tooltip is displayed over all else
self:targetDisplayTooltip()
......@@ -392,6 +412,10 @@ function _M:setupMouse(reset)
if button == "wheelup" then self.logdisplay:scrollUp(1) end
if button == "wheeldown" then self.logdisplay:scrollUp(-1) end
end, {button=true})
-- Tooltip over the player pane
self.mouse:registerZone(self.player_display.display_x, self.player_display.display_y, self.player_display.w, self.player_display.h, function(button, mx, my, xrel, yrel, bx, by, event)
self.player_display.mouse:delegate(button, mx, my, xrel, yrel, bx, by, event)
end)
-- Use hotkeys with mouse
self.mouse:registerZone(self.hotkeys_display.display_x, self.hotkeys_display.display_y, self.w, self.h, function(button, mx, my, xrel, yrel, bx, by, event)
self.hotkeys_display:onMouse(button, mx, my, event == "button", function(text) self.tooltip:displayAtMap(nil, nil, self.w, self.h, tostring(text)) end)
......@@ -415,3 +439,32 @@ function _M:saveGame()
savefile_pipe:push(self.save_name, "game", self)
self.log("Saving game...")
end
--------------------------------------------------------------
-- UI stuff
--------------------------------------------------------------
--- Create a visual separator
local _sep_left = core.display.loadImage("/data/gfx/ui/separator-left.png") _sep_left:alpha()
local _sep_right = core.display.loadImage("/data/gfx/ui/separator-right.png") _sep_right:alpha()
local _sep_horiz = core.display.loadImage("/data/gfx/ui/separator-hori.png") _sep_horiz:alpha()
local _sep_top = core.display.loadImage("/data/gfx/ui/separator-top.png") _sep_top:alpha()
local _sep_bottom = core.display.loadImage("/data/gfx/ui/separator-bottom.png") _sep_bottom:alpha()
local _sep_vert = core.display.loadImage("/data/gfx/ui/separator-vert.png") _sep_vert:alpha()
function _M:createVisualSeparator(dir, size)
if dir == "horizontal" then
local sep = core.display.newSurface(size, 6)
sep:erase(0, 0, 0)
sep:merge(_sep_left, 0, 0)
for i = 7, size - 7, 9 do sep:merge(_sep_horiz, i, 0) end
sep:merge(_sep_right, size - 6, 0)
return sep:glTexture()
else
local sep = core.display.newSurface(6, size)
sep:erase(0, 0, 0)
sep:merge(_sep_top, 0, 0)
for i = 7, size - 7, 9 do sep:merge(_sep_vert, 0, i) end
sep:merge(_sep_bottom, 0, size - 6)
return sep:glTexture()
end
end
......@@ -87,81 +87,23 @@ function _M:display()
h = h + self.font_h
if game.level and game.level.turn_counter then
s:drawColorStringBlended(self.font, ("Turns remaining: %d"):format(game.level.turn_counter / 10), x, h, 255, 0, 0) h = h + self.font_h
h = h + self.font_h
end
if player:getAir() < player.max_air then
self:mouseTooltip(self.TOOLTIP_AIR, s:drawColorStringBlended(self.font, ("Air level: %d/%d"):format(player:getAir(), player.max_air), x, h, 255, 0, 0)) h = h + self.font_h
h = h + self.font_h
end
if player:attr("encumbered") then
self:mouseTooltip(self.TOOLTIP_ENCUMBERED, s:drawColorStringBlended(self.font, "Encumbered!", x, h, 255, 0, 0)) h = h + self.font_h
h = h + self.font_h
end
self:mouseTooltip(self.TOOLTIP_STRDEXCON, s:drawColorStringBlended(self.font, ("Str/Dex/Con: #00ff00#%3d/%3d/%3d"):format(player:getStr(), player:getDex(), player:getCon()), x, h, 255, 255, 255)) h = h + self.font_h
self:mouseTooltip(self.TOOLTIP_MAGWILCUN, s:drawColorStringBlended(self.font, ("Mag/Wil/Cun: #00ff00#%3d/%3d/%3d"):format(player:getMag(), player:getWil(), player:getCun()), x, h, 255, 255, 255)) h = h + self.font_h
self:mouseTooltip(self.TOOLTIP_INTWISCHA, s:drawColorStringBlended(self.font, ("Int/Wis/Cha: #00ff00#%3d/%3d/%3d"):format(player:getInt(), player:getWis(), player:getCha()), x, h, 255, 255, 255)) h = h + self.font_h
h = h + self.font_h
s:erase(colors.VERY_DARK_RED.r, colors.VERY_DARK_RED.g, colors.VERY_DARK_RED.b, 255, self.bars_x, h, self.bars_w, self.font_h)
s:erase(colors.DARK_RED.r, colors.DARK_RED.g, colors.DARK_RED.b, 255, self.bars_x, h, self.bars_w * player.life / player.max_life, self.font_h)
self:mouseTooltip(self.TOOLTIP_LIFE, s:drawColorStringBlended(self.font, ("#c00000#Life: #ffffff#%d/%d"):format(player.life, player.max_life), x, h, 255, 255, 255)) h = h + self.font_h
if player.alchemy_golem and not player.alchemy_golem.dead then
s:erase(colors.VERY_DARK_RED.r, colors.VERY_DARK_RED.g, colors.VERY_DARK_RED.b, 255, self.bars_x, h, self.bars_w, self.font_h)
s:erase(colors.DARK_RED.r, colors.DARK_RED.g, colors.DARK_RED.b, 255, self.bars_x, h, self.bars_w * player.alchemy_golem.life / player.alchemy_golem.max_life, self.font_h)
self:mouseTooltip(self.TOOLTIP_LIFE, s:drawColorStringBlended(self.font, ("#c00000#Golem: #ffffff#%d/%d"):format(player.alchemy_golem.life, player.alchemy_golem.max_life), x, h, 255, 255, 255)) h = h + self.font_h
end
if player:knowTalent(player.T_STAMINA_POOL) then
s:erase(0xff / 6, 0xcc / 6, 0x80 / 6, 255, self.bars_x, h, self.bars_w, self.font_h)
s:erase(0xff / 3, 0xcc / 3, 0x80 / 3, 255, self.bars_x, h, self.bars_w * player:getStamina() / player.max_stamina, self.font_h)
self:mouseTooltip(self.TOOLTIP_STAMINA, s:drawColorStringBlended(self.font, ("#ffcc80#Stamina: #ffffff#%d/%d"):format(player:getStamina(), player.max_stamina), x, h, 255, 255, 255)) h = h + self.font_h
end
if player:knowTalent(player.T_MANA_POOL) then
s:erase(0x7f / 5, 0xff / 5, 0xd4 / 5, 255, self.bars_x, h, self.bars_w, self.font_h)
s:erase(0x7f / 2, 0xff / 2, 0xd4 / 2, 255, self.bars_x, h, self.bars_w * player:getMana() / player.max_mana, self.font_h)
self:mouseTooltip(self.TOOLTIP_MANA, s:drawColorStringBlended(self.font, ("#7fffd4#Mana: #ffffff#%d/%d"):format(player:getMana(), player.max_mana), x, h, 255, 255, 255)) h = h + self.font_h
end
if player:knowTalent(player.T_EQUILIBRIUM_POOL) then
s:erase(0x00 / 5, 0xff / 5, 0x74 / 5, 255, self.bars_x, h, self.bars_w, self.font_h)
s:erase(0x00 / 2, 0xff / 2, 0x74 / 2, 255, self.bars_x, h, self.bars_w * math.min(1, math.log(1 + player:getEquilibrium() / 100)), self.font_h)
self:mouseTooltip(self.TOOLTIP_EQUILIBRIUM, s:drawColorStringBlended(self.font, ("#00ff74#Equi: #ffffff#%d"):format(player:getEquilibrium()), x, h, 255, 255, 255)) h = h + self.font_h
end
if player:knowTalent(player.T_POSITIVE_POOL) then
s:erase(colors.GOLD.r / 5, colors.GOLD.g / 5, colors.GOLD.b / 5, 255, self.bars_x, h, self.bars_w, self.font_h)
s:erase(colors.GOLD.r / 2, colors.GOLD.g / 2, colors.GOLD.b / 2, 255, self.bars_x, h, self.bars_w * player:getPositive() / player.max_positive, self.font_h)
self:mouseTooltip(self.TOOLTIP_POSITIVE, s:drawColorStringBlended(self.font, ("#7fffd4#Positive:#ffffff#%d/%d"):format(player:getPositive(), player.max_positive), x, h, 255, 255, 255)) h = h + self.font_h
end
if player:knowTalent(player.T_NEGATIVE_POOL) then
s:erase(colors.GREY.r / 5, colors.GREY.g / 5, colors.GREY.b / 5, 255, self.bars_x, h, self.bars_w, self.font_h)
s:erase(colors.GREY.r / 2, colors.GREY.g / 2, colors.GREY.b / 2, 255, self.bars_x, h, self.bars_w * player:getNegative() / player.max_negative, self.font_h)
self:mouseTooltip(self.TOOLTIP_NEGATIVE, s:drawColorStringBlended(self.font, ("#7fffd4#Negative:#ffffff#%d/%d"):format(player:getNegative(), player.max_negative), x, h, 255, 255, 255)) h = h + self.font_h
end
if player:knowTalent(player.T_VIM_POOL) then
s:erase(0x90 / 6, 0x40 / 6, 0x10 / 6, 255, self.bars_x, h, self.bars_w, self.font_h)
s:erase(0x90 / 3, 0x40 / 3, 0x10 / 3, 255, self.bars_x, h, self.bars_w * player:getVim() / player.max_vim, self.font_h)
self:mouseTooltip(self.TOOLTIP_VIM, s:drawColorStringBlended(self.font, ("#904010#Vim: #ffffff#%d/%d"):format(player:getVim(), player.max_vim), x, h, 255, 255, 255)) h = h + self.font_h
end
if player:knowTalent(player.T_HATE_POOL) then
s:erase(colors.GREY.r / 5, colors.GREY.g / 5, colors.GREY.b / 5, 255, self.bars_x, h, self.bars_w, self.font_h)
s:erase(colors.GREY.r / 2, colors.GREY.g / 2, colors.GREY.b / 2, 255, self.bars_x, h, self.bars_w * player:getHate() / 10, self.font_h)
self:mouseTooltip(self.TOOLTIP_HATE, s:drawColorStringBlended(self.font, ("#F53CBE#Hate: #ffffff#%.1f/%d"):format(player:getHate(), 10), x, h, 255, 255, 255)) h = h + self.font_h
end
if savefile_pipe.saving then h = h + self.font_h s:drawColorStringBlended(self.font, "#YELLOW#Saving...", x, h, 255, 255, 255) h = h + self.font_h end
h = h + self.font_h
for tid, act in pairs(player.sustain_talents) do
if act then
local t = player:getTalentFromId(tid)
local desc = "#GOLD##{bold}#"..t.name.."#{normal}##WHITE#\n"..tostring(player:getTalentFullDescription(t))
self:mouseTooltip(desc, s:drawColorStringBlended(self.font, ("#LIGHT_GREEN#%s"):format(t.name), x, h, 255, 255, 255)) h = h + self.font_h
end
end
for eff_id, p in pairs(player.tmp) do
local e = player.tempeffect_def[eff_id]
local desc = e.long_desc(player, p)
......
-- ToME - Tales of Middle-Earth
-- Copyright (C) 2009, 2010 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
require "engine.class"
module(..., package.seeall, class.make)
-------------------------------------------------------------
-- Ressources
-------------------------------------------------------------
TOOLTIP_GOLD = [[#GOLD#Gold#LAST#
Money!
With gold you can buy items in the various stores in town.
You can gain money by looting it from your foes, by selling items and by doing some quests.
]]
TOOLTIP_LIFE = [[#GOLD#Life#LAST#
This is your life force, when you take damage this is reduced more and more.
If it reaches below zero you die.
Death is usualy permanent so beware!
It is increased by Constitution.]]
TOOLTIP_MANA = [[#GOLD#Mana#LAST#
Mana represents your reserve of magical energies. Each spell cast consumes mana and each sustained spell reduces your maximum mana.
It is increased by Willpower.]]
TOOLTIP_LEVEL = [[#GOLD#Level and experience#LAST#
Each time you kill a creature that is over your own level - 5 you gain some experience.
When you reach enough experience you advance to the next level. There is a maximum of 50 levels you can gain.
Each time you level you gain stat and talent points to use to improve your character.
]]
-------------------------------------------------------------
-- Stats
-------------------------------------------------------------
TOOLTIP_STR = [[#GOLD#Strength#LAST#
Strength defines your character's ability to apply physical force. It increases your melee damage, damage done with heavy weapons, your chance to resist physical effects, and carrying capacity.
]]
TOOLTIP_DEX = [[#GOLD#Dexterity#LAST#
Dexterity defines your character's ability to be agile and alert. It increases your chance to hit, your ability to avoid attacks, and your damage with light weapons.
]]
TOOLTIP_CON = [[#GOLD#Constitution#LAST#
Constitution defines your character's ability to withstand and resist damage. It increases your maximum life and physical resistance.
]]
TOOLTIP_INT = [[#GOLD#Intelligence#LAST#
Intelligence defines how well you can handle complex spells and magical devices.
]]
TOOLTIP_WIS = [[#GOLD#Wisdom#LAST#
Wisdom defines your character's mental resistance.
]]
TOOLTIP_CHA = [[#GOLD#Charisma#LAST#
Charisma defines your character's good looks.
]]
TOOLTIP_STRDEXCON = "#AQUAMARINE#Physical stats#LAST#\n---\n"..TOOLTIP_STR.."\n---\n"..TOOLTIP_DEX.."\n---\n"..TOOLTIP_CON
TOOLTIP_INTWISCHA = "#AQUAMARINE#Mental stats#LAST#\n---\n"..TOOLTIP_INT.."\n---\n"..TOOLTIP_WIS.."\n---\n"..TOOLTIP_CHA
game/modules/angband/data/gfx/ui/actors-icon.png

274 B

game/modules/angband/data/gfx/ui/charsheet-icon.png

292 B

game/modules/angband/data/gfx/ui/inventory-icon.png

307 B

game/modules/angband/data/gfx/ui/main-menu-icon.png

268 B

game/modules/angband/data/gfx/ui/message-log.png

9.77 KiB

game/modules/angband/data/gfx/ui/minimap.png

20.4 KiB

game/modules/angband/data/gfx/ui/player-display-top.png

416 B

game/modules/angband/data/gfx/ui/player-display.png

2.89 KiB

game/modules/angband/data/gfx/ui/separator-bottom.png

221 B

game/modules/angband/data/gfx/ui/separator-hori.png

200 B

game/modules/angband/data/gfx/ui/separator-left.png

246 B

game/modules/angband/data/gfx/ui/separator-right.png

235 B

game/modules/angband/data/gfx/ui/separator-top.png

254 B

game/modules/angband/data/gfx/ui/separator-vert.png

220 B

game/modules/angband/data/gfx/ui/talents-icon.png

276 B

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