Commit 66b54082d1dbdc7d27b7fff2224ceb16b3127dbe

Authored by dg
1 parent 2de446ed

Added an option to the graphics mode selection to use a custom tileset by enteri…

…ng a folder name and a few parameters


git-svn-id: http://svn.net-core.org/repos/t-engine4@3848 51575b47-30f0-44d4-a5cc-537603b46e54
... ... @@ -360,7 +360,7 @@ end
360 360 function _M:setupDisplayMode(reboot, mode)
361 361 if not mode or mode == "init" then
362 362 local gfx = config.settings.tome.gfx
363   - self:saveSettings("tome.gfx", ('tome.gfx = {tiles=%q, size=%q}\n'):format(gfx.tiles, gfx.size))
  363 + self:saveSettings("tome.gfx", ('tome.gfx = {tiles=%q, size=%q, tiles_custom_dir=%q, tiles_custom_moddable=%s, tiles_custom_adv=%s}\n'):format(gfx.tiles, gfx.size, gfx.tiles_custom_dir or "", gfx.tiles_custom_moddable and "true" or "false", gfx.tiles_custom_adv and "true" or "false"))
364 364
365 365 if reboot then
366 366 self.change_res_dialog = true
... ... @@ -375,9 +375,9 @@ function _M:setupDisplayMode(reboot, mode)
375 375 local gfx = config.settings.tome.gfx
376 376
377 377 -- Select tiles
378   - Tiles.prefix = "/data/gfx/"
379   - if gfx.tiles ~= "mushroom" then
380   - Tiles.prefix = "/data/gfx/"..gfx.tiles.."/"
  378 + Tiles.prefix = "/data/gfx/"..gfx.tiles.."/"
  379 + if config.settings.tome.gfx.tiles == "customtiles" then
  380 + Tiles.prefix = "/data/gfx/"..config.settings.tome.gfx.tiles_custom_dir.."/"
381 381 end
382 382 print("[DISPLAY MODE] Tileset: "..gfx.tiles)
383 383 print("[DISPLAY MODE] Size: "..gfx.size)
... ... @@ -411,8 +411,9 @@ function _M:setupDisplayMode(reboot, mode)
411 411 elseif gfx.tiles == "oldrpg" then
412 412 Map.tiles.nicer_tiles = true
413 413 Map.tiles.no_moddable_tiles = true
414   - elseif gfx.tiles == "mushroom" then
415   - Map.tiles.no_moddable_tiles = true
  414 + elseif gfx.tiles == "customtiles" then
  415 + Map.tiles.no_moddable_tiles = not config.settings.tome.gfx.tiles_custom_moddable
  416 + Map.tiles.nicer_tiles = config.settings.tome.gfx.tiles_custom_adv
416 417 end
417 418
418 419 if self.level then
... ...
... ... @@ -36,7 +36,7 @@ newTalent = function(t)
36 36 end
37 37 t.tactical = tacts
38 38 end
39   -
  39 +--[[
40 40 if t.image then
41 41 if type(t.image) == "boolean" then
42 42 local name = t.name:gsub(" ", ""):lower()
... ... @@ -48,7 +48,7 @@ newTalent = function(t)
48 48 end
49 49 t.image_texture = t.image:glTexture()
50 50 end
51   -
  51 +]]
52 52 return oldNewTalent(t)
53 53 end
54 54
... ...
... ... @@ -20,6 +20,10 @@
20 20 require "engine.class"
21 21 local Dialog = require "engine.ui.Dialog"
22 22 local List = require "engine.ui.List"
  23 +local Button = require "engine.ui.Button"
  24 +local Checkbox = require "engine.ui.Checkbox"
  25 +local Textzone = require "engine.ui.Textzone"
  26 +local Textbox = require "engine.ui.Textbox"
23 27 local GetQuantity = require "engine.dialogs.GetQuantity"
24 28 local Map = require "engine.Map"
25 29
... ... @@ -60,7 +64,37 @@ function _M:init()
60 64 end
61 65
62 66 function _M:doCustomTiles()
63   - local d = Dialog.new("Custom Tileset")
  67 + local d = Dialog.new("Custom Tileset", 100, 100)
  68 +
  69 + local help = Textzone.new{width=500, auto_height=true, text=[[You can configure the game to use a custom tileset.
  70 +You must place all files of your tileset in a subfolder of the modules's data/gfx/ folder, just like the existing tilesets.
  71 +Each tile must be correctly named according to the existing tilesets.]]}
  72 + local dir = Textbox.new{title="Folder: ", text="", chars=30, max_len=50, fct=function() end}
  73 + local moddable_tiles = Checkbox.new{title="Use moddable tiles (equipment showing on player)", default=false, fct=function() end }
  74 + local adv_tiles = Checkbox.new{title="Use advanced tiles (transitions, wide tiles, ...)", default=false, fct=function() end }
  75 + local ok = Button.new{text="Use custom tileset", fct=function()
  76 + config.settings.tome.gfx.tiles = "customtiles"
  77 + config.settings.tome.gfx.tiles_custom_dir = dir.text
  78 + config.settings.tome.gfx.tiles_custom_moddable = moddable_tiles.checked
  79 + config.settings.tome.gfx.tiles_custom_adv = adv_tiles.checked
  80 + self.changed = true
  81 + self:use{change_sel = "main"}
  82 + game:unregisterDialog(d)
  83 + end}
  84 + local cancel = Button.new{text="Cancel", fct=function() game:unregisterDialog(d) end}
  85 +
  86 + d:loadUI{
  87 + {left=0, top=0, ui=help},
  88 + {left=0, top=help.h, ui=dir},
  89 + {left=0, top=help.h+dir.h, ui=moddable_tiles},
  90 + {left=0, top=help.h+dir.h+moddable_tiles.h, ui=adv_tiles},
  91 + {left=0, bottom=0, ui=ok},
  92 + {right=0, bottom=0, ui=cancel},
  93 + }
  94 + d:setFocus(dir)
  95 + d:setupUI(true, true)
  96 +
  97 + game:registerDialog(d)
64 98 end
65 99
66 100 function _M:use(item)
... ...