diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a0be8be..c31df6c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,30 @@ +# Version 0.15.0.1521 - 2018-07-27 (LÖVE 11.0) + +## Additions +- Added functionality for saving log files to a folder in the safe directory when the game crashes. + +## Fixes +- Fixed sprites not showing for connectable world objects in the map editor. +- Fixed camera panning not working on the map editor's map testing screen. +- Fixed crash caused by weapon stacks in the inventory screen. + +## Removals +- Removed automatic camera tracking of moving characters (will be re-implemented in future versions). +- Removed automatic camera movement when selecting a different character (will be re-implemented in future versions). +- Removed hardcoded strings from help screen. + +## Other Changes +- Changed targeted LÖVE version to 11.0 "Mysterious Mysteries". +- Changed the way audio sources are loaded, stored and played. +- Changed speed and transparency of pulsating overlays (movement paths, hit cones, ...). +- Changed explosion damage to fixed instead of random values. +- Changed how default texture pack is loaded. + - The default texture pack is always copied to the mods folder at the start of the game. + - The default texture pack is loaded directly from the mods folder. + + + + # Version 0.14.0.1489 - 2018-01-26 ## Additions diff --git a/README.md b/README.md index c8b99bf6..6a1dd39e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # On The Roadside -[![Version](https://img.shields.io/badge/Version-0.14.0.1489-blue.svg)](https://github.com/rm-code/on-the-roadside/releases/latest) -[![LOVE](https://img.shields.io/badge/L%C3%96VE-0.10.2-EA316E.svg)](http://love2d.org/) +[![Version](https://img.shields.io/badge/Version-0.15.0.1521-blue.svg)](https://github.com/rm-code/on-the-roadside/releases/latest) +[![LOVE](https://img.shields.io/badge/L%C3%96VE-11.0-EA316E.svg)](http://love2d.org/) [![Build Status](https://travis-ci.com/rm-code/On-The-Roadside.svg?token=q3rLXeyGTBN9VB2zsWMr&branch=develop)](https://travis-ci.com/rm-code/On-The-Roadside) _On the Roadside_ is a turn-based strategy game in which you take control of a squad of mercenaries fighting for survival in a world shaped by unknown forces. It currently is in the very _early stages_ of development. @@ -22,3 +22,7 @@ _On the Roadside_ is a turn-based strategy game in which you take control of a s ### Please note This game is still in early stages of development by a one-man team ([@rm-code](https://twitter.com/rm_code)). I'm developing this game on my own in my free time and while I'm determined to make it as good and complete as possible there is no guarantee that it will ever be completed. That's why currently I am using the "pay what you want option" - If you decide that my work is worth your hard earned cash, you are a lovely person and I like you <3 + +### Generating the Documentation + +OTR uses LuaDoc to generate a documentation. By default the documentation will be generated in a `../docs` folder. diff --git a/conf.lua b/conf.lua index 9afc7968..797345da 100644 --- a/conf.lua +++ b/conf.lua @@ -4,7 +4,7 @@ local PROJECT_IDENTITY = "rmcode_otr" local PROJECT_VERSION = require( 'version' ) -local LOVE_VERSION = "0.10.2" +local LOVE_VERSION = "11.0" --- -- Initialise löve's config file. diff --git a/lib/TGFParser.lua b/lib/TGFParser.lua index 8d38f79e..4a8e52af 100644 --- a/lib/TGFParser.lua +++ b/lib/TGFParser.lua @@ -32,9 +32,7 @@ local TGFParser = { -- Line iterator -- ------------------------------------------------ --- TODO love.filesystem.lines is currently bugged on Mac OS 10.13 --- therefore we have to use a quick workaround --- local lines = love and love.filesystem.lines or io.lines; +local lines = love and love.filesystem.lines or io.lines; -- ------------------------------------------------ -- Local Functions @@ -53,26 +51,11 @@ local function loadFile( path ) local target = nodes; -- Change the target table once the '#' separator is reached. - -- TODO love.filesystem.lines is currently bugged on Mac OS 10.13 - -- therefore we have to use a quick workaround - - if love then - local str = love.filesystem.read(path) - for line in str:gmatch("[^\r\n]+") do - if line == '#' then - target = edges; - else - target[#target + 1] = line; - end - end - else - -- Change the target table once the '#' separator is reached. - for line in io.lines( path ) do - if line == '#' then - target = edges; - else - target[#target + 1] = line; - end + for line in lines( path ) do + if line == '#' then + target = edges; + else + target[#target + 1] = line; end end diff --git a/main.lua b/main.lua index 87354f84..03f6457b 100644 --- a/main.lua +++ b/main.lua @@ -19,13 +19,41 @@ local DEBUG_GRID_FLAG = '-g' local DEBUG_FULLSCREEN_FLAG = '-f' local DEBUG_WINDOWED_FLAG = '-w' +local SCREENS = { + bootloading = require( 'src.ui.screens.BootLoadingScreen' ), + mainmenu = require( 'src.ui.screens.MainMenu' ), + ingamemenu = require( 'src.ui.screens.IngameCombatMenu' ), + options = require( 'src.ui.screens.OptionsScreen' ), + changelog = require( 'src.ui.screens.ChangelogScreen' ), + combat = require( 'src.ui.screens.CombatScreen' ), + inventory = require( 'src.ui.screens.InventoryScreen' ), + help = require( 'src.ui.screens.HelpScreen' ), + gamescreen = require( 'src.ui.screens.GameScreen' ), + gameover = require( 'src.ui.screens.GameOverScreen' ), + loadgame = require( 'src.ui.screens.SavegameScreen' ), + confirm = require( 'src.ui.screens.ConfirmationModal' ), + information = require( 'src.ui.screens.InformationModal' ), + inputdialog = require( 'src.ui.screens.InputDialog' ), + maptest = require( 'src.ui.screens.MapTest' ), + mapeditor = require( 'src.ui.screens.MapEditor' ), + mapeditormenu = require( 'src.ui.screens.MapEditorMenu' ), + prefabeditor = require( 'src.ui.screens.PrefabEditor' ), + prefabeditormenu = require( 'src.ui.screens.PrefabEditorMenu' ), + editorloading = require( 'src.ui.mapeditor.EditorLoadingScreen' ), + keybindingeditor = require( 'src.ui.screens.KeybindingScreen' ), + keybindingmodal = require( 'src.ui.screens.KeybindingModal' ), + playerInfo = require( 'src.ui.screens.PlayerInfo' ), +} + -- ------------------------------------------------ --- Callbacks +-- Local Functions -- ------------------------------------------------ -function love.load( args ) - Log.init() - +--- +-- Iterates over any provided command line arguments and activates the proper +-- mechanics. +-- +local function handleCommandLineArguments( args ) for _, arg in pairs( args ) do if arg == DEBUG_OUTPUT_FLAG then Log.setDebugActive( true ) @@ -37,7 +65,12 @@ function love.load( args ) love.window.setFullscreen( false ) end end +end +--- +-- Prints some information about the game and the player's system. +-- +local function printGameInfo() local info = {} info[#info + 1] = "===================" info[#info + 1] = string.format( "Title: '%s'", getTitle() ) @@ -56,43 +89,35 @@ function love.load( args ) for _, line in ipairs( info ) do Log.print( line ) end +end + +-- ------------------------------------------------ +-- Callbacks +-- ------------------------------------------------ + +function love.load( args ) + Log.init() + + handleCommandLineArguments( args ) - local screens = { - bootloading = require( 'src.ui.screens.BootLoadingScreen' ), - mainmenu = require( 'src.ui.screens.MainMenu' ), - ingamemenu = require( 'src.ui.screens.IngameCombatMenu' ), - options = require( 'src.ui.screens.OptionsScreen' ), - changelog = require( 'src.ui.screens.ChangelogScreen' ), - combat = require( 'src.ui.screens.CombatScreen' ), - inventory = require( 'src.ui.screens.InventoryScreen' ), - help = require( 'src.ui.screens.HelpScreen' ), - gamescreen = require( 'src.ui.screens.GameScreen' ), - gameover = require( 'src.ui.screens.GameOverScreen' ), - loadgame = require( 'src.ui.screens.SavegameScreen' ), - confirm = require( 'src.ui.screens.ConfirmationModal' ), - information = require( 'src.ui.screens.InformationModal' ), - inputdialog = require( 'src.ui.screens.InputDialog' ), - maptest = require( 'src.ui.screens.MapTest' ), - mapeditor = require( 'src.ui.screens.MapEditor' ), - mapeditormenu = require( 'src.ui.screens.MapEditorMenu' ), - prefabeditor = require( 'src.ui.screens.PrefabEditor' ), - prefabeditormenu = require( 'src.ui.screens.PrefabEditorMenu' ), - editorloading = require( 'src.ui.mapeditor.EditorLoadingScreen' ), - keybindingeditor = require( 'src.ui.screens.KeybindingScreen' ), - keybindingmodal = require( 'src.ui.screens.KeybindingModal' ), - playerInfo = require( 'src.ui.screens.PlayerInfo' ), - } - - ScreenManager.init( screens, 'bootloading' ) + printGameInfo() + + ScreenManager.init( SCREENS, 'bootloading' ) letterbox = Letterbox() + + -- Create the actual debug grid, if the debug grid flag was set via command + -- line arguments. + if debugGrid then + debugGrid = DebugGrid() + end end function love.draw() ScreenManager.draw() if debugGrid then - DebugGrid.draw() + debugGrid:draw() end letterbox.draw() @@ -202,6 +227,9 @@ function love.errhand( msg ) p = string.gsub(p, "\t", "") p = string.gsub(p, "%[string \"(.-)\"%]", "%1") + -- Save a copy of the log to the crash dump folder. + Log.saveCrashDump() + local function draw() local pos = love.window.toPixels(70) love.graphics.clear(love.graphics.getBackgroundColor()) diff --git a/res/data/items/weapons/Melee.lua b/res/data/items/weapons/Melee.lua index abde3328..e272650a 100644 --- a/res/data/items/weapons/Melee.lua +++ b/res/data/items/weapons/Melee.lua @@ -14,7 +14,7 @@ return { subType = "Melee", damage = 5, reloadable = false, - sound = 'MELEE', + sound = 'sound_melee', mode = { { name = "Slash", @@ -47,7 +47,7 @@ return { subType = "Melee", damage = 4, reloadable = false, - sound = 'MELEE', + sound = 'sound_melee', mode = { { name = "Single", @@ -73,7 +73,7 @@ return { subType = "Melee", damage = 2, reloadable = false, - sound = 'MELEE', + sound = 'sound_melee', mode = { { name = "Bite", diff --git a/res/data/items/weapons/Ranged.lua b/res/data/items/weapons/Ranged.lua index 11985436..05a0ce34 100644 --- a/res/data/items/weapons/Ranged.lua +++ b/res/data/items/weapons/Ranged.lua @@ -12,7 +12,7 @@ return { 'humanoid' }, subType = "Ranged", - sound = 'ASSAULT_RIFLE', + sound = 'sound_assault_rifle', damage = 3, reloadable = true, mode = { @@ -47,7 +47,7 @@ return { 'humanoid' }, subType = "Ranged", - sound = 'ROCKET_LAUNCHER', + sound = 'sound_rocket_launcher', damage = 8, reloadable = true, mode = { @@ -75,7 +75,7 @@ return { 'humanoid' }, subType = "Ranged", - sound = 'SHOTGUN', + sound = 'sound_shotgun', damage = 2, reloadable = true, mode = { diff --git a/res/data/items/weapons/Thrown.lua b/res/data/items/weapons/Thrown.lua index a592349d..983d90d8 100644 --- a/res/data/items/weapons/Thrown.lua +++ b/res/data/items/weapons/Thrown.lua @@ -14,7 +14,7 @@ return { subType = "Thrown", damage = 5, reloadable = false, - sound = 'MELEE', + sound = 'sound_thrown', mode = { { name = "Throw", @@ -44,7 +44,7 @@ return { subType = "Thrown", damage = 3, reloadable = false, - sound = 'MELEE', + sound = 'sound_thrown', mode = { { name = "Throw", diff --git a/res/sounds/info.lua b/res/sounds/info.lua new file mode 100644 index 00000000..7bb27d0f --- /dev/null +++ b/res/sounds/info.lua @@ -0,0 +1,14 @@ +return { + name = 'default', + sounds = { + ['sound_door'] = { file = 'door.wav', type = 'static' }, + ['sound_select'] = { file = 'select.wav', type = 'static' }, + ['sound_assault_rifle'] = { file = 'ar.wav', type = 'static' }, + ['sound_shotgun'] = { file = 'ar.wav', type = 'static' }, + ['sound_climb'] = { file = 'climb.wav', type = 'static' }, + ['sound_explode'] = { file = 'explosion.wav', type = 'static' }, + ['sound_rocket_launcher'] = { file = 'rocket.wav', type = 'static' }, + ['sound_melee'] = { file = 'melee.wav', type = 'static' }, + ['sound_thrown'] = { file = 'melee.wav', type = 'static' }, + } +} diff --git a/res/texturepacks/default/README.txt b/res/texturepacks/default/README.txt new file mode 100644 index 00000000..1a807c4e --- /dev/null +++ b/res/texturepacks/default/README.txt @@ -0,0 +1,7 @@ +======================== +!! WARNING !! +======================== + +The default texture pack will be overwritten automatically. + +If you want to create your own texture pack you should copy and rename the default pack. diff --git a/res/texturepacks/default/colors.lua b/res/texturepacks/default/colors.lua index c6f53e81..3ff39409 100644 --- a/res/texturepacks/default/colors.lua +++ b/res/texturepacks/default/colors.lua @@ -3,38 +3,45 @@ local COLORS = {} -- DawnBringer's 32 Col Palette V1.0 -- @see http://pixeljoint.com/forum/forum_posts.asp?TID=16247 -COLORS.DB00 = { 0, 0, 0 } -COLORS.DB01 = { 34, 32, 52 } -COLORS.DB02 = { 69, 40, 60 } -COLORS.DB03 = { 102, 57, 49 } -COLORS.DB04 = { 143, 86, 59 } -COLORS.DB05 = { 223, 113, 38 } -COLORS.DB06 = { 217, 160, 102 } -COLORS.DB07 = { 238, 195, 154 } -COLORS.DB08 = { 251, 242, 54 } -COLORS.DB09 = { 153, 229, 80 } -COLORS.DB10 = { 106, 190, 48 } -COLORS.DB11 = { 55, 148, 110 } -COLORS.DB12 = { 75, 105, 47 } -COLORS.DB13 = { 82, 75, 36 } -COLORS.DB14 = { 50, 60, 57 } -COLORS.DB15 = { 63, 63, 116 } -COLORS.DB16 = { 48, 96, 130 } -COLORS.DB17 = { 91, 110, 225 } -COLORS.DB18 = { 99, 155, 255 } -COLORS.DB19 = { 95, 205, 228 } -COLORS.DB20 = { 203, 219, 252 } -COLORS.DB21 = { 255, 255, 255 } -COLORS.DB22 = { 155, 173, 183 } -COLORS.DB23 = { 132, 126, 135 } -COLORS.DB24 = { 105, 106, 106 } -COLORS.DB25 = { 89, 86, 82 } -COLORS.DB26 = { 118, 66, 138 } -COLORS.DB27 = { 172, 50, 50 } -COLORS.DB28 = { 217, 87, 99 } -COLORS.DB29 = { 215, 123, 186 } -COLORS.DB30 = { 143, 151, 74 } -COLORS.DB31 = { 138, 111, 48 } +COLORS.DB00 = { 0.000000, 0.000000, 0.000000 } +COLORS.DB01 = { 0.133333, 0.125490, 0.203922 } +COLORS.DB02 = { 0.270588, 0.156863, 0.235294 } +COLORS.DB03 = { 0.400000, 0.223529, 0.192157 } +COLORS.DB04 = { 0.560784, 0.337255, 0.231373 } +COLORS.DB05 = { 0.874510, 0.443137, 0.149020 } +COLORS.DB06 = { 0.850980, 0.627451, 0.400000 } +COLORS.DB07 = { 0.933333, 0.764706, 0.603922 } + +COLORS.DB08 = { 0.984314, 0.949020, 0.211765 } +COLORS.DB09 = { 0.600000, 0.898039, 0.313725 } +COLORS.DB10 = { 0.415686, 0.745098, 0.188235 } +COLORS.DB11 = { 0.215686, 0.580392, 0.431373 } +COLORS.DB12 = { 0.294118, 0.411765, 0.184314 } +COLORS.DB13 = { 0.321569, 0.294118, 0.141176 } +COLORS.DB14 = { 0.196078, 0.235294, 0.223529 } +COLORS.DB15 = { 0.247059, 0.247059, 0.454902 } + +COLORS.DB16 = { 0.188235, 0.376471, 0.509804 } +COLORS.DB17 = { 0.356863, 0.431373, 0.882353 } +COLORS.DB18 = { 0.388235, 0.607843, 1.000000 } +COLORS.DB19 = { 0.372549, 0.803922, 0.894118 } +COLORS.DB20 = { 0.796078, 0.858824, 0.988235 } +COLORS.DB21 = { 1.000000, 1.000000, 1.000000 } +COLORS.DB22 = { 0.607843, 0.678431, 0.717647 } +COLORS.DB23 = { 0.517647, 0.494118, 0.529412 } + +COLORS.DB24 = { 0.411765, 0.415686, 0.415686 } +COLORS.DB25 = { 0.349020, 0.337255, 0.321569 } +COLORS.DB26 = { 0.462745, 0.258824, 0.541176 } +COLORS.DB27 = { 0.674510, 0.196078, 0.196078 } +COLORS.DB28 = { 0.850980, 0.341176, 0.388235 } +COLORS.DB29 = { 0.843137, 0.482353, 0.729412 } +COLORS.DB30 = { 0.560784, 0.592157, 0.290196 } +COLORS.DB31 = { 0.541176, 0.435294, 0.188235 } + +COLORS.RESET = { 1.0, 1.0, 1.0, 1.0 } +COLORS.BACKGROUND = { 0.0, 0.0, 0.0, 1.0 } +COLORS.DEBUG_GRID = { 0.2, 0.2, 0.2, 0.3 } return { -- ============================== @@ -216,9 +223,11 @@ return { ['parcel_xl'] = COLORS.DB02, ['ingame_editor_grid_lines'] = COLORS.DB14, - -- ============================== - -- SYSTEM - -- ============================== - ['sys_background'] = { 0, 0, 0, 255 }, - ['sys_reset'] = { 255, 255, 255, 255 } -- Should not be changed! + -- ============================================================ + -- SYSTEM - These values shouldn't be changed! + -- ============================================================ + + ['sys_background'] = COLORS.BACKGROUND, + ['sys_debug_grid'] = COLORS.DEBUG_GRID, + ['sys_reset'] = COLORS.RESET } diff --git a/src/SaveHandler.lua b/src/SaveHandler.lua index a485360b..ec2dd30c 100644 --- a/src/SaveHandler.lua +++ b/src/SaveHandler.lua @@ -44,7 +44,7 @@ function SaveHandler.save( t, name ) Log.print( 'Created savegame: ' .. name, 'SaveHandler' ) -- Create the saves folder it doesn't exist already. - if not love.filesystem.exists( SAVE_FOLDER ) then + if not love.filesystem.getInfo( SAVE_FOLDER ) then love.filesystem.createDirectory( SAVE_FOLDER ) end diff --git a/src/Settings.lua b/src/Settings.lua index 2528eb98..b88edd96 100644 --- a/src/Settings.lua +++ b/src/Settings.lua @@ -52,6 +52,8 @@ local DEFAULT_SETTINGS = { } } +local WARNING_TEXT = 'Replacing outdated settings file (v%d) with current default settings (v%d)!' + -- ------------------------------------------------ -- Private Variables -- ------------------------------------------------ @@ -82,18 +84,29 @@ function Settings.save() end --- --- Loads the settings from the file. +-- Tries to load a settings file. If the file doesn't exist already, it will be +-- created. If the loaded settings file has an outdated version, it will be +-- replaced with the current default settings. -- function Settings.load() -- Create settings file if it doesn't exist yet. - if not love.filesystem.isFile( FILE_NAME ) then - create() - elseif Compressor.load( FILE_NAME ).version ~= DEFAULT_SETTINGS.version then - Log.warn( 'Detected outdated settings file => Replacing with default settings!', 'Settings' ) + if not love.filesystem.getInfo( FILE_NAME, 'file' ) then create() end + -- Load current settings. settings = Compressor.load( FILE_NAME ) + + -- Replace settings if we find an outdated version. + if settings.version ~= DEFAULT_SETTINGS.version then + Log.warn( string.format( WARNING_TEXT, settings.version, DEFAULT_SETTINGS.version ), 'Settings' ) + + -- Create and load the new settings file. + create() + settings = Compressor.load( FILE_NAME ) + end + + Log.info( string.format( 'Loaded game settings (v%d)', settings.version ), 'Settings' ) end --- diff --git a/src/SoundManager.lua b/src/SoundManager.lua index a30054e9..1bdf9919 100644 --- a/src/SoundManager.lua +++ b/src/SoundManager.lua @@ -1,55 +1,76 @@ -local Log = require( 'src.util.Log' ); -local Messenger = require( 'src.Messenger' ); +--- +-- @module SoundManager +-- + +-- ------------------------------------------------ +-- Required Modules +-- ------------------------------------------------ + +local Log = require( 'src.util.Log' ) + +-- ------------------------------------------------ +-- Module +-- ------------------------------------------------ + +local SoundManager = {} + +-- ------------------------------------------------ +-- Constants +-- ------------------------------------------------ + +local SOUNDFILES_FOLDER = 'res/sounds/' +local INFO_FILE_NAME = 'info' -local SoundManager = {}; +-- ------------------------------------------------ +-- Private Variables +-- ------------------------------------------------ -local SOUNDS = {} +local sounds = {} + +-- ------------------------------------------------ +-- Private Functions +-- ------------------------------------------------ --- --- Stops a source if it is currently playing. --- @param source (Source) The source to stop. --- @return (Source) The stopped source. +-- Loads sound files from the provided path. +-- @tparam string path The path to check for sounds. -- -local function stopBeforePlaying( source ) - if source:isPlaying() then - source:stop(); +local function load( path ) + local info = require( path .. INFO_FILE_NAME ) + if not info then + return false end - return source; -end -function SoundManager.loadResources() - SOUNDS.DOOR = love.audio.newSource( 'res/sounds/door.wav' ); - SOUNDS.SELECT = love.audio.newSource( 'res/sounds/select.wav' ); - SOUNDS.ASSAULT_RIFLE = love.audio.newSource( 'res/sounds/ar.wav' ); - SOUNDS.SHOTGUN = love.audio.newSource( 'res/sounds/ar.wav' ); - SOUNDS.CLIMB = love.audio.newSource( 'res/sounds/climb.wav' ); - SOUNDS.EXPLODE = love.audio.newSource( 'res/sounds/explosion.wav' ); - SOUNDS.ROCKET_LAUNCHER = love.audio.newSource( 'res/sounds/rocket.wav' ); - SOUNDS.MELEE = love.audio.newSource( 'res/sounds/melee.wav' ); + local count = 0 + for id, source in pairs( info.sounds ) do + local filepath = SOUNDFILES_FOLDER .. source.file + if love.filesystem.getInfo( filepath, 'file' ) then + sounds[id] = love.audio.newSource( filepath, source.type ) + + count = count + 1 + Log.print( string.format( ' %3d. %s', count, id ), 'SoundManager' ) + else + Log.warn( string.format( 'Source file "%s" for id "%s" couldn\'t be found', source.file, id ), 'SoundManager' ) + end + end end -Messenger.observe( 'ACTION_DOOR', function() - love.audio.play( SOUNDS.DOOR ); -end) +-- ------------------------------------------------ +-- Public Functions +-- ------------------------------------------------ -Messenger.observe( 'SOUND_CLIMB', function() - love.audio.play( SOUNDS.CLIMB ); -end) +function SoundManager.load() + Log.print( "Loading Sounds:", 'SoundManager' ) + load( SOUNDFILES_FOLDER ) +end -Messenger.observe( 'SOUND_ATTACK', function( weapon ) - if not SOUNDS[weapon:getSound()] then - Log.warn( string.format( 'Sound file for %s doesn\'t exist', weapon:getID() )); - return; +function SoundManager.play( id ) + if not sounds[id] then + Log.warn( string.format( 'A sound with the id "%s" couldn\'t be found', id ), 'SoundManager' ) + return end - love.audio.play( stopBeforePlaying( SOUNDS[weapon:getSound()] )); -end) - -Messenger.observe( 'SWITCH_CHARACTERS', function() - love.audio.play( SOUNDS.SELECT ); -end) -Messenger.observe( 'EXPLOSION', function() - love.audio.play( SOUNDS.EXPLODE ); -end) + sounds[id]:play() +end -return SoundManager; +return SoundManager diff --git a/src/characters/Faction.lua b/src/characters/Faction.lua index a691e25e..b220a21d 100644 --- a/src/characters/Faction.lua +++ b/src/characters/Faction.lua @@ -9,7 +9,6 @@ local Class = require( 'lib.Middleclass' ) local Log = require( 'src.util.Log' ) local Node = require( 'src.util.Node' ) -local Messenger = require( 'src.Messenger' ) local CharacterFactory = require( 'src.characters.CharacterFactory' ) local Character = require( 'src.characters.Character' ) @@ -160,7 +159,6 @@ function Faction:selectCharacter( character ) self.active = node self.active:getObject():activate() - Messenger.publish( 'SWITCH_CHARACTERS', self.active:getObject() ) break end node = node:getNext() @@ -254,7 +252,6 @@ function Faction:nextCharacter() if not character:isDead() then previousCharacter:deactivate() character:activate() - Messenger.publish( 'SWITCH_CHARACTERS', character ) return character end end @@ -272,7 +269,6 @@ function Faction:prevCharacter() if not character:isDead() then previousCharacter:activate() character:deactivate() - Messenger.publish( 'SWITCH_CHARACTERS', character ) return character end end diff --git a/src/characters/Factions.lua b/src/characters/Factions.lua index db829a50..6b2e494e 100644 --- a/src/characters/Factions.lua +++ b/src/characters/Factions.lua @@ -8,7 +8,6 @@ local Class = require( 'lib.Middleclass' ) local Node = require( 'src.util.Node' ) -local Messenger = require( 'src.Messenger' ) local Log = require( 'src.util.Log' ) -- ------------------------------------------------ @@ -82,7 +81,6 @@ function Factions:nextFaction() if current:isDead() then return self:getFaction():nextCharacter() end - Messenger.publish( 'SWITCH_CHARACTERS', current ) return current end diff --git a/src/characters/actions/ClimbOver.lua b/src/characters/actions/ClimbOver.lua index 065b04a7..545a9ae3 100644 --- a/src/characters/actions/ClimbOver.lua +++ b/src/characters/actions/ClimbOver.lua @@ -10,7 +10,7 @@ -- ------------------------------------------------ local Action = require( 'src.characters.actions.Action' ) -local Messenger = require( 'src.Messenger' ) +local SoundManager = require( 'src.SoundManager' ) -- ------------------------------------------------ -- Module @@ -35,7 +35,7 @@ function ClimbOver:perform() self.target:setCharacter( self.character ) self.character:setTile( self.target ) - Messenger.publish( 'SOUND_CLIMB' ) + SoundManager.play( 'sound_climb' ) return true end diff --git a/src/characters/actions/Close.lua b/src/characters/actions/Close.lua index d3605480..9634bfbf 100644 --- a/src/characters/actions/Close.lua +++ b/src/characters/actions/Close.lua @@ -8,7 +8,7 @@ -- ------------------------------------------------ local Action = require( 'src.characters.actions.Action' ) -local Messenger = require( 'src.Messenger' ) +local SoundManager = require( 'src.SoundManager' ) -- ------------------------------------------------ -- Module @@ -30,7 +30,7 @@ function Close:perform() assert( targetObject:isPassable(), 'Target tile needs to be passable!' ) assert( self.target:isAdjacent( self.character:getTile() ), 'Character has to be adjacent to the target tile!' ) - Messenger.publish( 'ACTION_DOOR' ) + SoundManager.play( 'sound_door' ) -- Update the WorldObject. targetObject:setPassable( false ) diff --git a/src/characters/actions/MeleeAttack.lua b/src/characters/actions/MeleeAttack.lua index c300f17a..730f0789 100644 --- a/src/characters/actions/MeleeAttack.lua +++ b/src/characters/actions/MeleeAttack.lua @@ -7,7 +7,7 @@ -- ------------------------------------------------ local Action = require( 'src.characters.actions.Action' ) -local Messenger = require( 'src.Messenger' ) +local SoundManager = require( 'src.SoundManager' ) -- ------------------------------------------------ -- Module @@ -31,7 +31,7 @@ function MeleeAttack:perform() local weapon = self.character:getWeapon() self.target:hit( weapon:getDamage(), weapon:getDamageType() ) - Messenger.publish( 'SOUND_ATTACK', weapon ) + SoundManager.play( weapon:getSound() ) return true end diff --git a/src/characters/actions/Open.lua b/src/characters/actions/Open.lua index 27a77ee4..fef7662c 100644 --- a/src/characters/actions/Open.lua +++ b/src/characters/actions/Open.lua @@ -8,7 +8,7 @@ -- ------------------------------------------------ local Action = require( 'src.characters.actions.Action' ) -local Messenger = require( 'src.Messenger' ) +local SoundManager = require( 'src.SoundManager' ) -- ------------------------------------------------ -- Module @@ -30,7 +30,7 @@ function Open:perform() assert( not targetObject:isPassable(), 'Target tile needs to be impassable!' ) assert( self.target:isAdjacent( self.character:getTile() ), 'Character has to be adjacent to the target tile!' ) - Messenger.publish( 'ACTION_DOOR' ) + SoundManager.play( 'sound_door' ) -- Update the WorldObject. targetObject:setPassable( true ) diff --git a/src/characters/actions/Walk.lua b/src/characters/actions/Walk.lua index f4ab45f1..f1a10806 100644 --- a/src/characters/actions/Walk.lua +++ b/src/characters/actions/Walk.lua @@ -8,7 +8,6 @@ -- ------------------------------------------------ local Action = require( 'src.characters.actions.Action' ) -local Messenger = require( 'src.Messenger' ) -- ------------------------------------------------ -- Module @@ -31,8 +30,6 @@ function Walk:perform() assert( not self.target:isOccupied(), 'Target tile must not be occupied by another character!' ) assert( self.target:isAdjacent( current ), 'Character has to be adjacent to the target tile!' ) - Messenger.publish( 'CHARACTER_MOVED', self.character ) - -- Remove the character from the old tile, add it to the new one and -- give it a reference to the new tile. current:removeCharacter() diff --git a/src/inventory/ItemStack.lua b/src/inventory/ItemStack.lua index 87c22ecd..2f8c5e06 100644 --- a/src/inventory/ItemStack.lua +++ b/src/inventory/ItemStack.lua @@ -99,6 +99,10 @@ function ItemStack:getItemType() return self.items[#self.items]:getItemType() end +function ItemStack:getSubType() + return self.items[#self.items]:getSubType() +end + function ItemStack:getDescriptionID() return self.items[#self.items]:getDescriptionID() end diff --git a/src/items/weapons/ExplosionManager.lua b/src/items/weapons/ExplosionManager.lua index 50b271d5..067b07b8 100644 --- a/src/items/weapons/ExplosionManager.lua +++ b/src/items/weapons/ExplosionManager.lua @@ -1,5 +1,6 @@ local Bresenham = require( 'lib.Bresenham' ); local Messenger = require( 'src.Messenger' ); +local SoundManager = require( 'src.SoundManager' ) local Util = require( 'src.util.Util' ); -- ------------------------------------------------ @@ -128,11 +129,11 @@ function ExplosionManager.update( dt ) if explosionLayout and timer <= 0 then -- Notify anyone who cares. Messenger.publish( 'EXPLOSION', explosionLayout[explosionIndex] ); - -- Damage the hit tiles. The damage is the base damage minus a random - -- value in the range of [1, 10% of damage] multiplied by the distance - -- to the source of the explosion. + SoundManager.play( 'sound_explode') + + -- Damage the hit tiles. for tile, damage in pairs( explosionLayout[explosionIndex] ) do - tile:hit( damage - love.math.random( damage * 0.1 ) * explosionIndex, DAMAGE_TYPES.EXPLOSIVE ); + tile:hit( damage, DAMAGE_TYPES.EXPLOSIVE ) end -- Advance the step index. explosionIndex = explosionIndex + 1; diff --git a/src/items/weapons/ProjectileQueue.lua b/src/items/weapons/ProjectileQueue.lua index a5759b78..0d26861f 100644 --- a/src/items/weapons/ProjectileQueue.lua +++ b/src/items/weapons/ProjectileQueue.lua @@ -10,7 +10,7 @@ local Class = require( 'lib.Middleclass' ) local Projectile = require( 'src.items.weapons.Projectile' ) local ProjectilePath = require( 'src.items.weapons.ProjectilePath' ) local Queue = require( 'src.util.Queue' ) -local Messenger = require( 'src.Messenger' ) +local SoundManager = require( 'src.SoundManager' ) -- ------------------------------------------------ -- Module @@ -48,7 +48,7 @@ local function spawnProjectile( queue, character, weapon, shots, projectiles, tx local projectile = Projectile( character, path, weapon:getDamage(), round:getDamageType(), round:getEffects() ) -- Play sound and remove the round from the magazine. - Messenger.publish( 'SOUND_ATTACK', weapon ) + SoundManager.play( weapon:getSound() ) weapon:getMagazine():removeRound() -- Spawn projectiles for the spread shot. diff --git a/src/items/weapons/ThrownProjectileQueue.lua b/src/items/weapons/ThrownProjectileQueue.lua index 8a8406cf..9fa4cf65 100644 --- a/src/items/weapons/ThrownProjectileQueue.lua +++ b/src/items/weapons/ThrownProjectileQueue.lua @@ -9,7 +9,7 @@ local Class = require( 'lib.Middleclass' ) local Projectile = require( 'src.items.weapons.Projectile' ) local ProjectilePath = require( 'src.items.weapons.ProjectilePath' ) -local Messenger = require( 'src.Messenger' ) +local SoundManager = require( 'src.SoundManager' ) -- ------------------------------------------------ -- Module @@ -55,7 +55,7 @@ function ThrownProjectileQueue:initialize( character, tx, ty, th ) self.projectiles[self.index] = projectile -- Play sound. - Messenger.publish( 'SOUND_ATTACK', self.weapon ) + SoundManager.play( self.weapon:getSound() ) end --- diff --git a/src/turnbased/states/PlanningState.lua b/src/turnbased/states/PlanningState.lua index 74e16c61..36042b6c 100644 --- a/src/turnbased/states/PlanningState.lua +++ b/src/turnbased/states/PlanningState.lua @@ -14,7 +14,9 @@ local StandUp = require( 'src.characters.actions.StandUp' ) local Crouch = require( 'src.characters.actions.Crouch' ) local LieDown = require( 'src.characters.actions.LieDown' ) local OpenInventory = require( 'src.characters.actions.OpenInventory' ) + local AttackInput = require( 'src.turnbased.helpers.AttackInput' ) +local MovementInput = require( 'src.turnbased.helpers.MovementInput' ) local InteractionInput = require( 'src.turnbased.helpers.InteractionInput' ) -- ------------------------------------------------ @@ -116,9 +118,9 @@ function PlanningState:initialize( stateManager ) self.stateManager = stateManager local inputStates = { - attack = require( 'src.turnbased.helpers.AttackInput' ), - movement = require( 'src.turnbased.helpers.MovementInput' ), - interaction = require( 'src.turnbased.helpers.InteractionInput' ) + attack = AttackInput, + movement = MovementInput, + interaction = InteractionInput } self.inputStateHandler = StateManager( inputStates ) diff --git a/src/ui/elements/inventory/UIItemStats.lua b/src/ui/elements/inventory/UIItemStats.lua index 4003f996..314794cb 100644 --- a/src/ui/elements/inventory/UIItemStats.lua +++ b/src/ui/elements/inventory/UIItemStats.lua @@ -10,6 +10,7 @@ local UIElement = require( 'src.ui.elements.UIElement' ) local TexturePacks = require( 'src.ui.texturepacks.TexturePacks' ) local Translator = require( 'src.util.Translator' ) local UIScrollArea = require( 'src.ui.elements.UIScrollArea' ) +local ItemStack = require( 'src.inventory.ItemStack' ) -- ------------------------------------------------ -- Module @@ -166,6 +167,10 @@ function UIItemStats:draw() end function UIItemStats:setItem( item ) + if item:isInstanceOf( ItemStack ) then + item = item:getItem() + end + self.stats = assembleText( self, item ) addDescriptionArea( self, item ) end diff --git a/src/ui/mapeditor/EditorLoadingScreen.lua b/src/ui/mapeditor/EditorLoadingScreen.lua index cb0ea3c8..b44c6c2c 100644 --- a/src/ui/mapeditor/EditorLoadingScreen.lua +++ b/src/ui/mapeditor/EditorLoadingScreen.lua @@ -69,7 +69,7 @@ local function generateOutlines( x, y ) end local function isValidFile( path ) - if not love.filesystem.isFile( path ) then + if not love.filesystem.getInfo( path, 'file' ) then return end diff --git a/src/ui/mapeditor/LayoutBrush.lua b/src/ui/mapeditor/LayoutBrush.lua index 9f15908f..5afcb8b5 100644 --- a/src/ui/mapeditor/LayoutBrush.lua +++ b/src/ui/mapeditor/LayoutBrush.lua @@ -25,13 +25,14 @@ function LayoutBrush:initialize( template ) self.x, self.y = 0, 0 end +-- TODO replace hardcoded colors function LayoutBrush:draw() local tw, th = TexturePacks.getTileDimensions() if self.mode == 'draw' then - love.graphics.setColor( 255, 0, 255, 100 ) + love.graphics.setColor( 1.0, 0, 1.0, 0.4 ) love.graphics.rectangle( 'line', self.x * tw, self.y * th, self.template.PARCEL_WIDTH * tw, self.template.PARCEL_HEIGHT * th ) else - love.graphics.setColor( 200, 0, 0, 100 ) + love.graphics.setColor( 0.8, 0, 0, 0.4 ) love.graphics.rectangle( 'fill', self.x * tw, self.y * th, tw, th ) end TexturePacks.resetColor() diff --git a/src/ui/mapeditor/LayoutCanvas.lua b/src/ui/mapeditor/LayoutCanvas.lua index 98e28c19..e44ae9f7 100644 --- a/src/ui/mapeditor/LayoutCanvas.lua +++ b/src/ui/mapeditor/LayoutCanvas.lua @@ -63,7 +63,8 @@ function LayoutCanvas:draw() local tw, th = TexturePacks.getTileDimensions() -- Draws a translucent grid. - love.graphics.setColor( 100, 100, 100, 100 ) + TexturePacks.setColor( 'sys_debug_grid' ) + for x = 1, self.grid.mapwidth do for y = 1, self.grid.mapheight do love.graphics.rectangle( 'line', x * tw, y * th, tw, th ) @@ -88,7 +89,7 @@ function LayoutCanvas:draw() end end - love.graphics.setColor( 255, 255, 255, 255 ) + TexturePacks.resetColor() end --- diff --git a/src/ui/overlays/DebugGrid.lua b/src/ui/overlays/DebugGrid.lua index 4f0341dd..cd679c3e 100644 --- a/src/ui/overlays/DebugGrid.lua +++ b/src/ui/overlays/DebugGrid.lua @@ -8,13 +8,14 @@ -- Required Modules -- ------------------------------------------------ +local Class = require( 'lib.Middleclass' ) local TexturePacks = require( 'src.ui.texturepacks.TexturePacks' ) -- ------------------------------------------------ -- Module -- ------------------------------------------------ -local DebugGrid = {} +local DebugGrid = Class( 'DebugGrid' ) -- ------------------------------------------------ -- Private Functions @@ -28,28 +29,34 @@ end -- Public Functions -- ------------------------------------------------ -function DebugGrid.draw() - local sw, sh = love.graphics.getDimensions() +function DebugGrid:initialize() + self.canvas = love.graphics.newCanvas( love.graphics.getDimensions() ) + self.canvas:renderTo( function() + local sw, sh = love.graphics.getDimensions() - local tileWidth, tileHeight = TexturePacks.getTileDimensions() - local glyphWidth, glyphHeight = TexturePacks.getGlyphDimensions() + local tileWidth, tileHeight = TexturePacks.getTileDimensions() + local glyphWidth, glyphHeight = TexturePacks.getGlyphDimensions() - for x = 0, sw - 1 do - for y = 0, sh - 1 do - if mod( x, tileWidth ) == 0 and mod( y, tileHeight ) == 0 then - love.graphics.setColor( 100, 100, 100, 80 ) - love.graphics.rectangle( 'line', x, y, tileWidth, tileHeight ) - end + for x = 0, sw - 1 do + for y = 0, sh - 1 do + if mod( x, tileWidth ) == 0 and mod( y, tileHeight ) == 0 then + TexturePacks.setColor( 'sys_debug_grid' ) + love.graphics.rectangle( 'line', x, y, tileWidth, tileHeight ) + end - if mod( x, glyphWidth ) == 0 and mod( y, glyphHeight ) == 0 then - love.graphics.setColor( 100, 100, 100, 60 ) - love.graphics.rectangle( 'line', x, y, glyphWidth, glyphHeight ) + if mod( x, glyphWidth ) == 0 and mod( y, glyphHeight ) == 0 then + TexturePacks.setColor( 'sys_debug_grid' ) + love.graphics.rectangle( 'line', x, y, glyphWidth, glyphHeight ) + end end end - end - love.graphics.setColor( 255, 255, 255, 255 ) + TexturePacks.resetColor() + end) end +function DebugGrid:draw() + love.graphics.draw( self.canvas, 0, 0 ) +end return DebugGrid diff --git a/src/ui/overlays/OverlayPainter.lua b/src/ui/overlays/OverlayPainter.lua index e05c02ca..51647e2c 100644 --- a/src/ui/overlays/OverlayPainter.lua +++ b/src/ui/overlays/OverlayPainter.lua @@ -88,7 +88,7 @@ function OverlayPainter:initialize( game, camera ) self.camera = camera self.particleLayer = ParticleLayer() - self.pulser = Pulser( 4, 80, 80 ) + self.pulser = Pulser( 2, 0.2, 0.6 ) self.coneOverlay = ConeOverlay( self.game, self.pulser, self.camera ) self.pathOverlay = PathOverlay( self.game, self.pulser ) diff --git a/src/ui/overlays/ParticleLayer.lua b/src/ui/overlays/ParticleLayer.lua index 1308188a..d15118cd 100644 --- a/src/ui/overlays/ParticleLayer.lua +++ b/src/ui/overlays/ParticleLayer.lua @@ -43,24 +43,24 @@ function ParticleLayer:initialize() local tile = projectile:getTile() if tile then if projectile:getEffects():hasCustomSprite() then - addParticleEffect( self.grid, self.particles, tile:getX(), tile:getY(), 255, 255, 255, 255, 1500, projectile:getEffects():getCustomSprite() ) + addParticleEffect( self.grid, self.particles, tile:getX(), tile:getY(), 1.0, 1.0, 1.0, 1.0, 2.5, projectile:getEffects():getCustomSprite() ) elseif projectile:getEffects():isExplosive() then - local col = love.math.random( 150, 255 ) - addParticleEffect( self.grid, self.particles, tile:getX(), tile:getY(), col, col, col, love.math.random( 100, 255 ), 500 ) + local col = love.math.random( 0.59, 1.0 ) + addParticleEffect( self.grid, self.particles, tile:getX(), tile:getY(), col, col, col, love.math.random( 0.59, 1.0 ), 1.0 ) else - addParticleEffect( self.grid, self.particles, tile:getX(), tile:getY(), 223, 113, 38, 200, 500 ) + addParticleEffect( self.grid, self.particles, tile:getX(), tile:getY(), 0.87450, 0.44313, 0.14901, 0.78, 0.5 ) end end end) Messenger.observe( 'EXPLOSION', function( ... ) local generation = ... - for tile, life in pairs( generation ) do - local r = 255 - local g = love.math.random( 100, 200 ) + for tile, _ in pairs( generation ) do + local r = 0.9 + local g = love.math.random( 0.39, 0.58 ) local b = 0 - local a = love.math.random( 200, 255 ) - local fade = 500 / math.min( 3, love.math.random( life )) + local a = love.math.random( 0.78, 0.9 ) + local fade = math.max( 0.95, love.math.random( 2.5 )) addParticleEffect( self.grid, self.particles, tile:getX(), tile:getY(), r, g, b, a, fade ) end end) diff --git a/src/ui/screens/BootLoadingScreen.lua b/src/ui/screens/BootLoadingScreen.lua index 26ea45fe..1de478f4 100644 --- a/src/ui/screens/BootLoadingScreen.lua +++ b/src/ui/screens/BootLoadingScreen.lua @@ -37,13 +37,13 @@ function BootLoadingScreen:initialize() local startTime = love.timer.getTime() TexturePacks.load() + SoundManager.load() ItemFactory.loadTemplates() TileFactory.loadTemplates() BodyFactory.loadTemplates() WorldObjectFactory.loadTemplates() BehaviorTreeFactory.loadTemplates() - SoundManager.loadResources() CharacterFactory.init() diff --git a/src/ui/screens/CombatScreen.lua b/src/ui/screens/CombatScreen.lua index 10a3dff7..4b4f5321 100644 --- a/src/ui/screens/CombatScreen.lua +++ b/src/ui/screens/CombatScreen.lua @@ -9,7 +9,6 @@ local MapPainter = require( 'src.ui.MapPainter' ) local Camera = require( 'src.ui.Camera' ) local UserInterface = require( 'src.ui.UserInterface' ) local OverlayPainter = require( 'src.ui.overlays.OverlayPainter' ) -local Messenger = require( 'src.Messenger' ) local TexturePacks = require( 'src.ui.texturepacks.TexturePacks' ) local Settings = require( 'src.Settings' ) @@ -36,21 +35,6 @@ function CombatScreen:initialize( playerFaction, savegame ) self.userInterface = UserInterface( self.combatState, self.camera ) self.overlayPainter = OverlayPainter( self.combatState, self.camera ) - - self.observations = {} - self.observations[#self.observations + 1] = Messenger.observe( 'SWITCH_CHARACTERS', function( character ) - if not self.combatState:getFactions():getPlayerFaction():canSee( character:getTile() ) then - return - end - self.camera:setTargetPosition( character:getTile():getX() * tw, character:getTile():getY() * th ) - end) - - self.observations[#self.observations + 1] = Messenger.observe( 'CHARACTER_MOVED', function( character ) - if not self.combatState:getFactions():getPlayerFaction():canSee( character:getTile() ) then - return - end - self.camera:setTargetPosition( character:getTile():getX() * tw, character:getTile():getY() * th ) - end) end function CombatScreen:draw() @@ -106,9 +90,6 @@ function CombatScreen:mousefocus( f ) end function CombatScreen:close() - for i = 1, #self.observations do - Messenger.remove( self.observations[i] ) - end self.combatState:close() end diff --git a/src/ui/screens/HelpScreen.lua b/src/ui/screens/HelpScreen.lua index 6560ec03..16fc6540 100644 --- a/src/ui/screens/HelpScreen.lua +++ b/src/ui/screens/HelpScreen.lua @@ -26,38 +26,38 @@ local HELP_TEXT = { color = 'ui_help_section', children = { 'NOTE: Characters can also be selected by right-clicking on them!', - { 'prev_character', 'Select previous character' }, - { 'next_character', 'Select next character' }, - { 'end_turn', 'End turn' }, - { 'open_inventory_screen', 'Open inventory' }, - { 'open_health_screen', 'Open health panel' } + { 'prev_character' }, + { 'next_character' }, + { 'end_turn' }, + { 'open_inventory_screen' }, + { 'open_health_screen' } } }, { text = 'WEAPONS', color = 'ui_help_section', children = { - { 'next_weapon_mode', 'Select previous firing mode' }, - { 'prev_weapon_mode', 'Select next firing mode' }, - { 'action_reload_weapon', 'Reload current weapon' } + { 'next_weapon_mode' }, + { 'prev_weapon_mode' }, + { 'action_reload_weapon' } } }, { text = 'STANCES', color = 'ui_help_section', children = { - { 'action_stand', 'Change stance to Stand' }, - { 'action_crouch', 'Change stance to Crouch' }, - { 'action_prone', 'Change stance to Prone' } + { 'action_stand' }, + { 'action_crouch' }, + { 'action_prone' } } }, { text = 'INPUT', color = 'ui_help_section', children = { - { 'attack_mode', 'Switch to Attack Mode' }, - { 'movement_mode', 'Switch to Movement Mode' }, - { 'interaction_mode', 'Switch to Interaction Mode (e.g. to open barrels or doors)' } + { 'attack_mode' }, + { 'movement_mode' }, + { 'interaction_mode' } } } } @@ -85,7 +85,7 @@ local function assembleText() offset = offset + 1 if type( HELP_TEXT[i].children[j] ) == 'table' then text:addf( Settings.getKeybinding( HELP_TEXT[i].children[j][1] ), (UI_GRID_WIDTH-2) * tw, 'left', 4*tw, offset * th ) - text:addf( HELP_TEXT[i].children[j][2], (UI_GRID_WIDTH-2) * tw, 'left', 10*tw, offset * th ) + text:addf( Translator.getText( HELP_TEXT[i].children[j][1] ), (UI_GRID_WIDTH-2) * tw, 'left', 10*tw, offset * th ) else text:addf( HELP_TEXT[i].children[j], (UI_GRID_WIDTH-2) * tw, 'left', 4*tw, offset * th ) end diff --git a/src/ui/screens/MapTest.lua b/src/ui/screens/MapTest.lua index 7656e9cc..e7629967 100644 --- a/src/ui/screens/MapTest.lua +++ b/src/ui/screens/MapTest.lua @@ -14,6 +14,7 @@ local PrefabLoader = require( 'src.map.procedural.PrefabLoader' ) local ProceduralMapGenerator = require( 'src.map.procedural.ProceduralMapGenerator' ) local TexturePacks = require( 'src.ui.texturepacks.TexturePacks' ) local Map = require( 'src.map.Map' ) +local Settings = require( 'src.Settings' ) -- ------------------------------------------------ -- Module @@ -71,6 +72,12 @@ function MapTest:keypressed( _, scancode ) if scancode == 'escape' then ScreenManager.pop() end + + self.camera:input( Settings.mapInput( scancode ), true ) +end + +function MapTest:keyreleased( _, scancode ) + self.camera:input( Settings.mapInput( scancode ), false ) end return MapTest diff --git a/src/ui/screens/PrefabEditor.lua b/src/ui/screens/PrefabEditor.lua index 6be05c45..3434bec0 100644 --- a/src/ui/screens/PrefabEditor.lua +++ b/src/ui/screens/PrefabEditor.lua @@ -70,6 +70,8 @@ local function createWorldObjectSelector( objectTemplates, tool ) local tmp = UIButton( lx, ly, 0, counter, SELECTOR_WIDTH, 1, callback, Translator.getText( id ), 'left' ) if template.openable then tmp:setIcon( id, 'closed' ) + elseif template.connections then + tmp:setIcon( id, 'default' ) else tmp:setIcon( id ) end diff --git a/src/ui/screens/SavegameScreen.lua b/src/ui/screens/SavegameScreen.lua index 996a2f57..e8e57814 100644 --- a/src/ui/screens/SavegameScreen.lua +++ b/src/ui/screens/SavegameScreen.lua @@ -91,7 +91,7 @@ local function createSaveGameEntry( lx, ly, index, item, folder ) -- the version of the game at which they were created and their creation date. local str = string.format( '%2d. %s', index, item ) str = Util.rightPadString( str, 36, ' ') - str = str .. string.format( ' %s %s', version, os.date( '%Y-%m-%d %X', love.filesystem.getLastModified( folder ))) + str = str .. string.format( ' %s %s', version, os.date( '%Y-%m-%d %X', love.filesystem.getInfo( folder ).modtime )) local function callback() if version == getVersion() then @@ -115,13 +115,13 @@ local function loadFiles( savedir ) local saveDirectories = {} for _, item in pairs( love.filesystem.getDirectoryItems( savedir )) do - if love.filesystem.isDirectory( savedir .. '/' .. item ) then + if love.filesystem.getInfo( savedir .. '/' .. item, 'directory' ) then saveDirectories[#saveDirectories + 1] = item end end table.sort( saveDirectories, function( a, b ) - return love.filesystem.getLastModified( savedir .. '/' .. a ) > love.filesystem.getLastModified( savedir .. '/' .. b ) + return love.filesystem.getInfo( savedir .. '/' .. a ).modtime > love.filesystem.getInfo( savedir .. '/' .. b ).modtime end) return saveDirectories diff --git a/src/ui/texturepacks/TexturePacks.lua b/src/ui/texturepacks/TexturePacks.lua index 924ec6d0..b91e9904 100644 --- a/src/ui/texturepacks/TexturePacks.lua +++ b/src/ui/texturepacks/TexturePacks.lua @@ -30,6 +30,7 @@ local DEFAULT = { NAME = 'default', INFO = 'info.lua', COLORS = 'colors.lua', + WARNING = 'README.txt', SPRITES = 'sprites.lua', IMAGEFONT = 'imagefont.png', SPRITESHEET = 'spritesheet.png', @@ -112,7 +113,7 @@ local function loadPacks( sourceFolder ) local count = 0 for _, item in ipairs( love.filesystem.getDirectoryItems( sourceFolder )) do local path = sourceFolder .. item .. '/' - if love.filesystem.isDirectory( path ) then + if love.filesystem.getInfo( path, 'directory' ) then local success, tpack = load( path ) if success then @@ -127,7 +128,7 @@ local function loadPacks( sourceFolder ) end count = count + 1 - Log.print( string.format( ' %3d. %s', count, name ), 'TexturePacks' ) + Log.info( string.format( ' %3d. %s', count, name ), 'TexturePacks' ) else Log.warn( string.format( 'A texture pack with the id "%s" already exists. The duplicate will be ignored.', name ), 'TexturePacks' ) end @@ -151,10 +152,7 @@ end -- Copies the default texture pack to the mods folder in the user's save directory. -- local function copyDefaultTexturePack() - -- Abort if the texture pack exists already. - if love.filesystem.isDirectory( MOD_TEXTURE_PACK_FOLDER .. DEFAULT.NAME ) then - return - end + Log.info( "Copying default texture pack to mod folder", 'TexturePacks' ) love.filesystem.createDirectory( MOD_TEXTURE_PACK_FOLDER .. DEFAULT.NAME ) @@ -164,6 +162,7 @@ local function copyDefaultTexturePack() copyFile( source, target, DEFAULT.INFO ) copyFile( source, target, DEFAULT.COLORS ) copyFile( source, target, DEFAULT.SPRITES ) + copyFile( source, target, DEFAULT.WARNING ) copyFile( source, target, DEFAULT.IMAGEFONT ) copyFile( source, target, DEFAULT.SPRITESHEET ) end @@ -173,19 +172,15 @@ end -- ------------------------------------------------ function TexturePacks.load() - Log.print( "Load Default Texture Packs:", 'TexturePacks' ) - loadPacks( TEXTURE_PACK_FOLDER ) - -- Creates the mods folder if it doesn't exist. - if not love.filesystem.exists( MOD_TEXTURE_PACK_FOLDER ) then + if not love.filesystem.getInfo( MOD_TEXTURE_PACK_FOLDER ) then love.filesystem.createDirectory( MOD_TEXTURE_PACK_FOLDER ) end - Log.print( "Load External Texture Packs:", 'TexturePacks' ) - loadPacks( MOD_TEXTURE_PACK_FOLDER ) - - Log.debug( "Copying default texture pack to mod folder!" ) copyDefaultTexturePack() + + Log.info( "Load Texture Packs:", 'TexturePacks' ) + loadPacks( MOD_TEXTURE_PACK_FOLDER ) end -- ------------------------------------------------ diff --git a/src/util/Compressor.lua b/src/util/Compressor.lua index 88325bbb..5c2dbc3f 100644 --- a/src/util/Compressor.lua +++ b/src/util/Compressor.lua @@ -20,7 +20,7 @@ local Compressor = {} function Compressor.save( t, path ) local rawstring = Serialize( t ) - local compressedData = love.math.compress( rawstring ) + local compressedData = love.data.compress( 'data', 'lz4', rawstring ) assert( love.filesystem.write( path, compressedData )) end @@ -30,7 +30,7 @@ function Compressor.load( path ) assert( compressedData, errorMessage ) -- Decompress and return the loaded lua file. - local rawstring = love.math.decompress( compressedData, 'lz4' ) + local rawstring = love.data.decompress( 'string', 'lz4', compressedData ) -- Print a warning if it can't be loaded and return false. local result, error = load( rawstring ) diff --git a/src/util/Log.lua b/src/util/Log.lua index c6825a61..f06dbd24 100644 --- a/src/util/Log.lua +++ b/src/util/Log.lua @@ -19,6 +19,10 @@ local Log = {} local FILE_NAME = 'latest.log' +local CRASH_FOLDER = 'crash_dumps/' +local CRASH_FILE_NAME = '%s%s_crash.log' + +local INFO_PREFIX = '[INFO]' local DEBUG_PREFIX = '[DEBUG]' local WARNING_PREFIX = '[WARNING]' local ERROR_PREFIX = '[ERROR]' @@ -97,6 +101,16 @@ function Log.print( str, caller ) appendlineBreak() end +--- +-- Logs a informational message. +-- @tparam string str The message to log. +-- @tparam string caller The module which sent the message. +-- +function Log.info( str, caller ) + write( str, caller, INFO_PREFIX ) + appendlineBreak() +end + --- -- Logs a warning message. -- @tparam string str The message to log. @@ -146,4 +160,12 @@ function Log.getDebugActive() return active end +--- +-- Saves a copy of the latest.log to the crash dump folder and timestamps it. +-- +function Log.saveCrashDump() + love.filesystem.createDirectory( CRASH_FOLDER ) + assert( love.filesystem.write( string.format( CRASH_FILE_NAME, CRASH_FOLDER, os.time() ), love.filesystem.read( FILE_NAME ))) +end + return Log diff --git a/src/util/Translator.lua b/src/util/Translator.lua index 01df67e6..de27f9d6 100644 --- a/src/util/Translator.lua +++ b/src/util/Translator.lua @@ -65,7 +65,7 @@ local function load( dir ) local subdirectories = love.filesystem.getDirectoryItems( dir ) for i, subdir in ipairs( subdirectories ) do local path = dir .. subdir .. '/' - if love.filesystem.isDirectory( path ) then + if love.filesystem.getInfo( path, 'directory' ) then local files = love.filesystem.getDirectoryItems( path ) -- Loads all the other text files for this locale. diff --git a/version.lua b/version.lua index 02fcce9a..a41a836c 100644 --- a/version.lua +++ b/version.lua @@ -1,8 +1,8 @@ local version = { major = 0, - minor = 14, + minor = 15, patch = 0, - build = 1489, + build = 1521, } return string.format( "%d.%d.%d.%d", version.major, version.minor, version.patch, version.build );