Skip to content
Snippets Groups Projects
Commit db96e7ec authored by DarkGod's avatar DarkGod
Browse files

test

parent 7685cc7b
No related branches found
Tags tome-beta26b
No related merge requests found
......@@ -19,6 +19,7 @@
require "engine.class"
local Map = require "engine.Map"
local Shader = require "engine.Shader"
--- handles targetting
module(..., package.seeall, class.make)
......@@ -37,19 +38,19 @@ function _M:init(map, source_actor)
local pot_width = math.pow(2, math.ceil(math.log(map.tile_w-0.1) / math.log(2.0)))
local pot_height = math.pow(2, math.ceil(math.log(map.tile_h-0.1) / math.log(2.0)))
self.sr = core.display.newSurface(pot_width, pot_height)
self.sr:erase(255, 0, 0, 90)
self.sr:erase(255, 0, 0, 150)
self.sr = self.sr:glTexture()
self.sb = core.display.newSurface(pot_width, pot_height)
self.sb:erase(0, 0, 255, 90)
self.sb:erase(0, 0, 255, 150)
self.sb = self.sb:glTexture()
self.sg = core.display.newSurface(pot_width, pot_height)
self.sg:erase(0, 255, 0, 90)
self.sg:erase(0, 255, 0, 150)
self.sg = self.sg:glTexture()
self.sy = core.display.newSurface(pot_width, pot_height)
self.sy:erase(255, 255, 0, 90)
self.sy:erase(255, 255, 0, 150)
self.sy = self.sy:glTexture()
self.syg = core.display.newSurface(pot_width, pot_height)
self.syg:erase(153, 204, 50, 90)
self.syg:erase(153, 204, 50, 150)
self.syg = self.syg:glTexture()
self.source_actor = source_actor
......@@ -62,6 +63,14 @@ function _M:init(map, source_actor)
-- setmetatable(self.target, {__mode='v'})
end
function _M:enableFBORenderer(shader)
self.fbo = core.display.newFBO(Map.viewport.width, Map.viewport.height)
if not self.fbo then return end
if shader then
self.fbo_shader = Shader.new(shader)
end
end
function _M:displayArrow(sx, sy, tx, ty, full)
local x, y = (tx*2.5 + sx) / 3.5, (ty*2.5 + sy) / 3.5
......@@ -77,7 +86,27 @@ function _M:displayArrow(sx, sy, tx, ty, full)
core.display.glMatrix(false)
end
function _M:display(dispx, dispy)
function _M:display(dispx, dispy, prevfbo)
local ox, oy = self.display_x, self.display_y
local sx, sy = game.level.map._map:getScroll()
sx = sx + game.level.map.display_x
sy = sy + game.level.map.display_y
self.display_x, self.display_y = dispx or sx or self.display_x, dispy or sy or self.display_y
if not self.fbo then
self:realDisplay(self.display_x, self.display_y)
else
self.fbo:use(true, 0, 0, 0, 0)
self:realDisplay(0, 0)
self.fbo:use(false, prevfbo)
self.fbo:toScreen(self.display_x, self.display_y, Map.viewport.width, Map.viewport.height, nil, 1, 1, 1, 1, true)
self.fbo:toScreen(self.display_x, self.display_y, Map.viewport.width, Map.viewport.height, self.fbo_shader.shad, 1, 1, 1, 1, true)
end
self.display_x, self.display_y = ox, oy
end
function _M:realDisplay(dispx, dispy)
-- Make sure we have a source
if not self.target_type.source_actor then
self.target_type.source_actor = self.source_actor
......@@ -92,13 +121,8 @@ function _M:display(dispx, dispy)
self.target_type.start_x = self.target_type.start_x or self.target_type.x or self.target_type.source_actor and self.target_type.source_actor.x or self.x
self.target_type.start_y = self.target_type.start_y or self.target_type.y or self.target_type.source_actor and self.target_type.source_actor.y or self.y
local ox, oy = self.display_x, self.display_y
local sx, sy = game.level.map._map:getScroll()
sx = sx + game.level.map.display_x
sy = sy + game.level.map.display_y
self.display_x, self.display_y = dispx or sx or self.display_x, dispy or sy or self.display_y
-- self.cursor:toScreen(self.display_x + (self.target.x - game.level.map.mx) * self.tile_w * Map.zoom, self.display_y + (self.target.y - game.level.map.my) * self.tile_h * Map.zoom, self.tile_w * Map.zoom, self.tile_h * Map.zoom)
-- self.cursor:toScreen(dispx + (self.target.x - game.level.map.mx) * self.tile_w * Map.zoom, dispy + (self.target.y - game.level.map.my) * self.tile_h * Map.zoom, self.tile_w * Map.zoom, self.tile_h * Map.zoom)
-- Do not display if not requested
if not self.active then return end
......@@ -107,16 +131,16 @@ function _M:display(dispx, dispy)
if util.isHex() then
display_highlight = function(texture, tx, ty)
texture:toScreenHighlightHex(
self.display_x + (tx - game.level.map.mx) * self.tile_w * Map.zoom,
self.display_y + (ty - game.level.map.my + util.hexOffset(tx)) * self.tile_h * Map.zoom,
dispx + (tx - game.level.map.mx) * self.tile_w * Map.zoom,
dispy + (ty - game.level.map.my + util.hexOffset(tx)) * self.tile_h * Map.zoom,
self.tile_w * Map.zoom,
self.tile_h * Map.zoom)
end
else
display_highlight = function(texture, tx, ty)
texture:toScreen(
self.display_x + (tx - game.level.map.mx) * self.tile_w * Map.zoom,
self.display_y + (ty - game.level.map.my) * self.tile_h * Map.zoom,
dispx + (tx - game.level.map.mx) * self.tile_w * Map.zoom,
dispy + (ty - game.level.map.my) * self.tile_h * Map.zoom,
self.tile_w * Map.zoom,
self.tile_h * Map.zoom)
end
......@@ -206,7 +230,7 @@ function _M:display(dispx, dispy)
end
if not self.target_type.immediate_keys or firstx then
self.cursor:toScreen(self.display_x + (self.target.x - game.level.map.mx) * self.tile_w * Map.zoom, self.display_y + (self.target.y - game.level.map.my + util.hexOffset(self.target.x)) * self.tile_h * Map.zoom, self.tile_w * Map.zoom, self.tile_h * Map.zoom)
self.cursor:toScreen(dispx + (self.target.x - game.level.map.mx) * self.tile_w * Map.zoom, dispy + (self.target.y - game.level.map.my + util.hexOffset(self.target.x)) * self.tile_h * Map.zoom, self.tile_w * Map.zoom, self.tile_h * Map.zoom)
end
if self.target_type.ball and self.target_type.ball > 0 then
......@@ -281,8 +305,6 @@ function _M:display(dispx, dispy)
self:displayArrow(self.target_type.start_x, self.target_type.start_y, spot[1], spot[2], firstx == spot[1] and firsty == spot[2])
end
end
self.display_x, self.display_y = ox, oy
end
-- @return t The target table used by ActorProject, Projectile, GameTargeting, etc.
......
......@@ -134,6 +134,7 @@ function _M:runReal()
if not self.player then self:newGame() end
engine.interface.GameTargeting.init(self)
if self.target then self.target:enableFBORenderer("invis_edge") end
self.uiset.hotkeys_display.actor = self.player
self.uiset.npcs_display.actor = self.player
......@@ -1358,13 +1359,13 @@ function _M:displayMap(nb_keyframes)
_2DNoise:bind(1, false)
self.fbo2:toScreen(map.display_x, map.display_y, map.viewport.width, map.viewport.height, self.fbo_shader.shad)
if self.target then self.target:display() end
if self.target then self.target:display(nil, nil, self.full_fbo) end
-- Basic display; no FBOs
else
if self.level.data.background then self.level.data.background(self.level, map.display_x, map.display_y, nb_keyframes) end
map:display(nil, nil, nb_keyframes, config.settings.tome.smooth_fov)
if self.target then self.target:display() end
if self.target then self.target:display(nil, nil, self.full_fbo) end
if self.level.data.foreground then self.level.data.foreground(self.level, map.display_x, map.display_y, nb_keyframes) end
if self.level.data.weather_particle then self.state:displayWeather(self.level, self.level.data.weather_particle, nb_keyframes) end
if self.level.data.weather_shader then self.state:displayWeatherShader(self.level, self.level.data.weather_shader, map.display_x, map.display_y, nb_keyframes) end
......
......@@ -23,4 +23,5 @@ return {
args = {
},
clone = false,
permanent = true,
}
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