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

Particle density setting added to the video options

git-svn-id: http://svn.net-core.org/repos/t-engine4@1424 51575b47-30f0-44d4-a5cc-537603b46e54
parent f2991857
No related branches found
No related tags found
No related merge requests found
......@@ -70,5 +70,5 @@ function _M:loaded()
gl = self.__particles_gl[gl]
self.update = fct
self.ps = core.particles.newEmitter(max or 1000, no_stop, def, gl)
self.ps = core.particles.newEmitter(max or 1000, no_stop, config.settings.particles_density or 100, def, gl)
end
......@@ -76,7 +76,7 @@ function _M:interact(who)
local d; d = ShowStore.new("Store: "..self.name, store, inven, nil, nil, function(what, o, item)
if what == "buy" then
if o:getNumber() > 1 then
local q = GetQuantity.new(nil, nil, o:getNumber(), function(qty) self:doBuy(who, o, item, qty, d) end)
local q = GetQuantity.new(nil, nil, o:getNumber(), o:getNumber(), function(qty) self:doBuy(who, o, item, qty, d) end)
game:registerDialog(q)
else
self:doBuy(who, o, item, 1, d)
......@@ -84,7 +84,7 @@ function _M:interact(who)
else
if o:getNumber() > 1 then
local q
q = GetQuantity.new(nil, nil, o:getNumber(), function(qty) print("plop", qty) self:doSell(who, o, item, qty, d) end)
q = GetQuantity.new(nil, nil, o:getNumber(), o:getNumber(), function(qty) print("plop", qty) self:doSell(who, o, item, qty, d) end)
game:registerDialog(q)
else
self:doSell(who, o, item, 1, d)
......
......@@ -25,12 +25,12 @@ local Numberbox = require "engine.ui.Numberbox"
module(..., package.seeall, class.inherit(Dialog))
function _M:init(title, prompt, default, action)
function _M:init(title, prompt, default, max, action)
self.action = action
Dialog.init(self, title or "Quantity", 320, 110)
local c_box = Numberbox.new{title=prompt and (prompt..": ") or "", number=default or 0, chars=10, fct=function(text) self:okclick() end}
local c_box = Numberbox.new{title=prompt and (prompt..": ") or "", number=default or 0, max=max, chars=10, fct=function(text) self:okclick() end}
self.c_box = c_box
local ok = require("engine.ui.Button").new{text="Accept", fct=function() self:okclick() end}
local cancel = require("engine.ui.Button").new{text="Cancel", fct=function() self:cancelclick() end}
......
......@@ -22,6 +22,7 @@ local Dialog = require "engine.ui.Dialog"
local TreeList = require "engine.ui.TreeList"
local Textzone = require "engine.ui.Textzone"
local Separator = require "engine.ui.Separator"
local GetQuantity = require "engine.dialogs.GetQuantity"
module(..., package.seeall, class.inherit(Dialog))
......@@ -62,7 +63,7 @@ function _M:generateList()
local i = 0
local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text="Display resolution."}
list[#list+1] = { zone=zone, name="Resolution", status=function(item)
list[#list+1] = { zone=zone, name="#GOLD##{bold}#Resolution#WHITE##{normal}#", status=function(item)
return config.settings.window.size
end, fct=function(item)
local menu = require("engine.dialogs.DisplayResolution").new(function() self.c_list:drawItem(item) end)
......@@ -70,16 +71,18 @@ function _M:generateList()
end,}
local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text="Controls the particle effects density.\nThis option allows to change the density of the many particle effects in the game.\nIf the game is slow when displaying spell effects try to lower this setting.#WHITE#"}
list[#list+1] = { zone=zone, name="Particle effects density", status=function(item)
return tostring(config.settings.particles_density and "enabled" or "disabled")
list[#list+1] = { zone=zone, name="#GOLD##{bold}#Particle effects density#WHITE##{normal}#", status=function(item)
return tostring(config.settings.particles_density)
end, fct=function(item)
game:saveSettings("particles_density", ("particles_density = %s\n"):format(tostring(config.settings.particles_density)))
self.c_list:drawItem(item)
game:registerDialog(GetQuantity.new("Enter density", "From 0 to 100", config.settings.particles_density, 100, function(qty)
game:saveSettings("particles_density", ("particles_density = %d\n"):format(qty))
config.settings.particles_density = qty
self.c_list:drawItem(item)
end))
end,}
local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text="Activates antialiased texts.\nTexts will look nicer but it can be slower on some computers.\n\n#LIGHT_RED#You must restart the game for it to take effect.#WHITE#"}
list[#list+1] = { zone=zone, name="Antialiased texts", status=function(item)
list[#list+1] = { zone=zone, name="#GOLD##{bold}#Antialiased texts#WHITE##{normal}#", status=function(item)
return tostring(core.display.getTextBlended() and "enabled" or "disabled")
end, fct=function(item)
local state = not core.display.getTextBlended()
......@@ -89,7 +92,7 @@ function _M:generateList()
end,}
local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text="Activates framebuffers.\nThis option allows for some special graphical effects.\nIf you encounter weird graphical glitches try to disable it.\n\n#LIGHT_RED#You must restart the game for it to take effect.#WHITE#"}
list[#list+1] = { zone=zone, name="Framebuffers", status=function(item)
list[#list+1] = { zone=zone, name="#GOLD##{bold}#Framebuffers#WHITE##{normal}#", status=function(item)
return tostring(config.settings.fbo_active and "enabled" or "disabled")
end, fct=function(item)
config.settings.fbo_active = not config.settings.fbo_active
......@@ -98,7 +101,7 @@ function _M:generateList()
end,}
local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text="Activates OpenGL Shaders.\nThis option allows for some special graphical effects.\nIf you encounter weird graphical glitches try to disable it.\n\n#LIGHT_RED#You must restart the game for it to take effect.#WHITE#"}
list[#list+1] = { zone=zone, name="OpenGL Shaders", status=function(item)
list[#list+1] = { zone=zone, name="#GOLD##{bold}#OpenGL Shaders#WHITE##{normal}#", status=function(item)
return tostring(config.settings.shaders_active and "enabled" or "disabled")
end, fct=function(item)
config.settings.shaders_active = not config.settings.shaders_active
......
......@@ -53,6 +53,7 @@ music.volume = 60
aa_text = true
fbo_active = true
shaders_active = true
particles_density = 100
]]
for i, file in ipairs(fs.list("/settings/")) do
if file:find(".cfg$") then
......
......@@ -66,13 +66,17 @@ static int particles_new(lua_State *L)
{
int nb = luaL_checknumber(L, 1);
bool no_stop = lua_toboolean(L, 2);
GLuint *t = (GLuint*)auxiliar_checkclass(L, "gl{texture}", 4);
int density = luaL_checknumber(L, 3);
GLuint *t = (GLuint*)auxiliar_checkclass(L, "gl{texture}", 5);
int t_ref = luaL_ref(L, LUA_REGISTRYINDEX);
int p_ref = luaL_ref(L, LUA_REGISTRYINDEX);
particles_type *ps = (particles_type*)lua_newuserdata(L, sizeof(particles_type));
auxiliar_setclass(L, "core{particles}", -1);
ps->density = density;
nb = (nb * ps->density) / 100;
if (!nb) nb = 1;
ps->nb = nb;
ps->texture = *t;
ps->texture_ref = t_ref;
......@@ -152,6 +156,9 @@ static int particles_emit(lua_State *L)
particles_type *ps = (particles_type*)auxiliar_checkclass(L, "core{particles}", 1);
int nb = luaL_checknumber(L, 2);
nb = (nb * ps->density) / 100;
if (!nb) nb = 1;
int i;
for (i = 0; i < ps->nb; i++)
{
......
......@@ -39,6 +39,7 @@ typedef struct {
int nb;
int texture_ref;
int generator_ref;
int density;
bool no_stop;
int base;
......
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