Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: 4-seasons colors schemes - Please try your hand!  (Read 6141 times)

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
4-seasons colors schemes - Please try your hand!
« on: November 13, 2016, 06:43:19 pm »


<<< DOWNLOAD >>> - V1.0
To enable the script, add "season-palette start" to your dfhack.init
Album with Screenshots

Installation:
Download, unpack. Copy the 5 color schemes into the DwarfFortress/raw folder. Copy the script into the DwarfFortress/hack/scripts folder. Add "season-palette start" without the "" to the dfhack.init. Gen a new world.

A dfhack script and 12 color schemes to change the colors of DF depending on the season: Spring, Summer, Autumn and Winter.

Milo christiansen was so kind to write a custom dfhack script that allows the changing of colors on the fly.

Season-palette.lua:
Code: [Select]
-- Swap color palettes with the changes of the seasons.
--
-- Based on my script for the Rubble addon "Libs/Colors/Swap Palette", modified at
-- Meph's request to support automatic seasonal switching.

--[[
Copyright 2016 Milo Christiansen

This software is provided 'as-is', without any express or implied warranty. In
no event will the authors be held liable for any damages arising from the use of
this software.

Permission is granted to anyone to use this software for any purpose, including
commercial applications, and to alter it and redistribute it freely, subject to
the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim
that you wrote the original software. If you use this software in a product, an
acknowledgment in the product documentation would be appreciated but is not
required.

2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.
]]

--@ module = true
--@ enable = true

local mapingsA = {
["BLACK"] = 0,
["BLUE"] = 1,
["GREEN"] = 2,
["CYAN"] = 3,
["RED"] = 4,
["MAGENTA"] = 5,
["BROWN"] = 6,
["LGRAY"] = 7,
["DGRAY"] = 8,
["LBLUE"] = 9,
["LGREEN"] = 10,
["LCYAN"] = 11,
["LRED"] = 12,
["LMAGENTA"] = 13,
["YELLOW"] = 14,
["WHITE"] = 15,
}

local mapingsB = {
["R"] = 0,
["G"] = 1,
["B"] = 2,
}

local function trimPrefix(pre, str)
if (string.find(str, pre, 1, true)) ~= 1 then return str end
return string.sub(str, #pre + 1)
end

function LoadPalette(path)
-- Strip off the DF path (if it is included) so the log message is shorter.
print("Attempting to load color palette file: \""..trimPrefix(dfhack.getDFPath(), path).."\"")

local file, err = io.open(path, "rb")
if file == nil then
-- Use a less verbose error message to keep the console cleaner.
--print("  Load failed: "..err)
print("  Could not open file.")
return false
end

local contents = file:read("*a")
file:close()

-- Keep track of the old colors so we can revert to them if we have trouble parsing the new color file.
local revcolors = {}
for a = 0, 15, 1 do
revcolors[a] = {}
for b = 0, 2, 1 do
revcolors[a][b] = df.global.enabler.ccolor[a][b]
end
end

-- If only I could use the Rubble raw parser here... Oh well, I suppose regular expressions will do almost as well.
for a, b, v in string.gmatch(contents, "%[([A-Z]+)_([RGB]):([0-9]+)%]") do
local ka, kb, v = mapingsA[a], mapingsB[b], tonumber(v)
if ka == nil or kb == nil or v == nil then
-- Parse error, revert changes.
for x = 0, 15, 1 do
for y = 0, 2, 1 do
df.global.enabler.ccolor[x][y] = revcolors[x][y]
end
end
print("  Color file parse error (all changes reverted).")
return false
end

if v == 0 then
df.global.enabler.ccolor[ka][kb] = 0
else
v = v / 255
if v > 1 then
print("  Warning: The "..b.." component for color "..a.." is out of range! Adjusting value.")
v = 1
end
df.global.enabler.ccolor[ka][kb] = v
end
end
return true
end

if moduleMode then return end

function usage()
print [==[
Swap color palettes when the seasons change.

For this script to work you need to add *at least* one color palette file to
your save raw directory.

Palette file names:
    "colors.txt": The world "default" (worldgen and replacement) palette.
    "colors_spring.txt": The palette displayed during spring.
    "colors_summer.txt": The palette displayed during summer.
    "colors_autumn.txt": The palette displayed during autumn.
    "colors_winter.txt": The palette displayed during winter.

If you do not provide a world default palette, palette switching will be
disabled for the current world. The seasonal palettes are optional, the default
palette is not! The default palette will be used to replace any missing
seasonal palettes and during worldgen.

When the world is unloaded or this script is disabled, the system default color
palette ("/data/init/colors.txt") will be loaded. The system default palette
will always be used in the main menu, but your custom palettes should be used
everywhere else.

Usage:
    season-palette start|enable
    enable season-palette
        Begin swapping seasonal color palettes.
   
    season-palette stop|disable
    disable season-palette
        Stop swapping seasonal color palettes and load the default color
        palette.
   
    If loaded as a module this script will export a single Lua function:
   
    LoadPalette(path)
        Load a color palette from the text file at "path". This file must be in
        the same format as "/data/init/colors.txt". If there is an error any
        changes will be reverted and this function will return false (returns
        true normally).
]==]
end

args = {...}
if dfhack_flags and dfhack_flags.enable then
    table.insert(args, dfhack_flags.enable_state and 'enable' or 'disable')
end

enabled = false
if #args >= 1 then
if args[1] == 'start' or args[1] == 'enable' then
enabled = true
elseif args[1] == 'stop' or args[1] == 'disable' then
enabled = false
else
usage()
return
end
else
usage()
return
end

local seasons = {
[-1] = '', -- worldgen
[0] = '_spring',
[1] = '_summer',
[2] = '_autumn',
[3] = '_winter',
}
lastSeason = lastSeason or nil

local function seasonSwapLoop()
if not enabled then
LoadPalette(dfhack.getDFPath().."/data/init/colors.txt")
return
end

if lastSeason == nil or lastSeason ~= df.global.cur_season then
lastSeason = df.global.cur_season

-- Try to load the seasonal palette, if that fails fall back on the world default palette.
if not LoadPalette(dfhack.getSavePath().."/raw/colors"..seasons[lastSeason]..".txt") then
if seasons[lastSeason] == "" or not LoadPalette(dfhack.getSavePath().."/raw/colors.txt") then
print("The current world do not provide a valid default palette, disabling palette swapping for this world.")
return
end
end
end

dfhack.timeout(50, 'ticks', seasonSwapLoop)
end

dfhack.onStateChange.SeasonPalette = function(event)
if event == SC_WORLD_LOADED and enabled then
seasonSwapLoop()
end
if event == SC_WORLD_UNLOADED and enabled then
LoadPalette(dfhack.getDFPath().."/data/init/colors.txt")
-- Ticker is auto-canceled by DFHack.
end
end

if dfhack.isWorldLoaded() then
dfhack.onStateChange.SeasonPalette(SC_WORLD_LOADED)
end

I added color schemes to be used with it: Meph Colors, Gemset Colors (original by DragondePlatino), JollyBastion Colors (original by JollyBastion)
Spoiler: Meph colors default: (click to show/hide)
Spoiler: Meph colors spring (click to show/hide)
Spoiler: Meph colors summer (click to show/hide)
Spoiler: Meph colors autumn (click to show/hide)
Spoiler: Meph colors winter (click to show/hide)

Spoiler: Color scheme legend (click to show/hide)

I would be very happy if more artists would try their hand at creating seasonal color schemes; Raeborga, Vherid, DragondePlatino... you all seem to have a knack for this. :)
« Last Edit: November 13, 2016, 08:03:43 pm by Meph »
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

ANickel

  • Bay Watcher
    • View Profile
Re: 4-seasons colors schemes - Please try your hand!
« Reply #1 on: November 13, 2016, 06:59:39 pm »

Got the first download!  I'll try it out.
PS: I can't try it out until I get an explanation of how to install it.  Whoops.
« Last Edit: November 13, 2016, 07:33:03 pm by ANickel »
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: 4-seasons colors schemes - Please try your hand!
« Reply #2 on: November 13, 2016, 08:03:15 pm »

Ups...

download, unpack. Copy the 5 color schemes into the DwarfFortress/raw folder. Copy the script into the DwarfFortress/hack/scripts folder. Add "season-palette start" without the "" to the dfhack.init. Gen a new world.

The installation is explained inside the script itself, didnt remember to mention it.

Quote
For this script to work you need to add *at least* one color palette file to
your save raw directory.

Palette file names:
    "colors.txt": The world "default" (worldgen and replacement) palette.
    "colors_spring.txt": The palette displayed during spring.
    "colors_summer.txt": The palette displayed during summer.
    "colors_autumn.txt": The palette displayed during autumn.
    "colors_winter.txt": The palette displayed during winter.

If you do not provide a world default palette, palette switching will be
disabled for the current world. The seasonal palettes are optional, the default
palette is not! The default palette will be used to replace any missing
seasonal palettes and during worldgen.

When the world is unloaded or this script is disabled, the system default color
palette ("/data/init/colors.txt") will be loaded. The system default palette
will always be used in the main menu, but your custom palettes should be used
everywhere else.
« Last Edit: November 13, 2016, 08:05:57 pm by Meph »
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

DragonDePlatino

  • Bay Watcher
  • [HABIT:COLLECT_WEALTH]
    • View Profile
Re: 4-seasons colors schemes - Please try your hand!
« Reply #3 on: November 14, 2016, 12:14:36 am »

Sweet! You finally got this working in DF. I've been itching to sink my teeth into a feature like this. Here's my take on the default palette. What makes it default, you ask? I stuck to 6-bit colors which is what the default color scheme uses AFAIK. This means everything has a retro flavor, but it's difficult to make subtle changes to colors like black and gray.

Spoiler: Preview (click to show/hide)
Spoiler: Spring (click to show/hide)
Spoiler: Summer (click to show/hide)
Spoiler: Fall (click to show/hide)
Spoiler: Winter (click to show/hide)

For Spring, I took the edge off all the colors and pushed the cool colors towards sea-green. Green and pink are the dominant colors. For Summer, everything is more or less the default palette with a few improvements. I wanted to make everything warm, but I kept producting very fall-like palettes. For Fall, I warmed up the palette and lowered the saturation a bit. The purple-colored magenta gives off some very Halloween-like vibes. Winter is my favorite palette. I drained the color from everything and added an icy tint to the grays. The result feels a lot like the Commodore 64 palette.

If anyone would like to suggest some changes, shoot away. I understand the gray changes were a little drastic so I'm willing to tone those down if they're a problem.

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: 4-seasons colors schemes - Please try your hand!
« Reply #4 on: November 14, 2016, 06:35:08 am »

That was quick!

And not me, but Milo Christiansen got it working. ;)

One thing I really like are the borders/frame changing colors. A visual reminder for what season it is.

It might be worth trying to restrict it a bit to surface-colors. For example grey/dark-grey are not really used there, mostly for rocks/metals. Same for white/black, thats the text colors, would be strange to see the UI change due to seasons.

But green/light-green, blue/light-blue and brown/yellow, those are grass, water and wood...

Could you be so kind and upload your default scheme as a color palette, with 16 boxes of colors, like in the legend I posted? I think I made a mistake somewhere in mine, with brown/yellow, but without one by a different author I cant figure out if I mixed something up.
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

DragonDePlatino

  • Bay Watcher
  • [HABIT:COLLECT_WEALTH]
    • View Profile
Re: 4-seasons colors schemes - Please try your hand!
« Reply #5 on: November 14, 2016, 02:45:38 pm »

Gotcha. I went back and changed the grays to normal. I also added a bit more contrast between seasons so they should stand out more. I've tested out the palette on a dozen different screenshots so they should look OK in most situations.

The color schemes are in the upper-left corner of the previews. Alternatively, if your image editor supports indexed palettes, you can download the preview and view those in the palette editor. The order is default-spring-summer-fall-winter.

Spoiler: Preview (click to show/hide)
Spoiler: Spring (click to show/hide)
Spoiler: Summer (click to show/hide)
Spoiler: Fall (click to show/hide)
Spoiler: Winter (click to show/hide)

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: 4-seasons colors schemes - Please try your hand!
« Reply #6 on: November 14, 2016, 03:46:03 pm »

Thank you again.

Might I include them in the Meph Tileset, as an optional setting? Full credit given of course. I think Peridexis also wanted to add this feature to the Starter Pack. :)

I'll make some screenshots with my tileset, see how it looks with a graphical set, instead of ascii.
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

DragonDePlatino

  • Bay Watcher
  • [HABIT:COLLECT_WEALTH]
    • View Profile
Re: 4-seasons colors schemes - Please try your hand!
« Reply #7 on: November 14, 2016, 05:05:27 pm »

Feel free to do whatever you'd like with this scheme. I doubt it will work very well with realistic tilesets, though. I had entirely ASCII and ASCII-like tilesets in mind when I made this.
« Last Edit: November 14, 2016, 05:11:19 pm by DragonDePlatino »
Logged

raeborga

  • Bay Watcher
  • [STRANGE_MOODS]
    • View Profile
Re: 4-seasons colors schemes - Please try your hand!
« Reply #8 on: November 15, 2016, 06:42:36 pm »

I haven't had time to sit down and play for a while...  :(

Buddy of mine does this kind of stuff for a living and suggests not changing all the colors, but focusing on changing important bits and keeping a common thread throughout all 4 palettes.

Notes:
+ I say change green because of the association with plants, and the fact that plants changing color is one of the primary indications of the seasons.
+ Could also add a bit of color to the greys. Grey is a bit boring by itself so this would be an easy target.
+ There is a serious lack of actual blue in nature, but it wouldn't be too horrible to have a more vibrant color for summer and spring, and a more muted color for fall and winter, to give the impression things are getting more gloomy.
+ Red and magenta are prime candidates for not changing.

Subtlety is important. Don't want people to hate certain seasons.
Logged