Skip to content

Commit

Permalink
Make the colors configurable for colorblind people
Browse files Browse the repository at this point in the history
  • Loading branch information
Quezler committed Dec 17, 2024
1 parent 23cb767 commit adb731c
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 32 deletions.
5 changes: 5 additions & 0 deletions mods_2.0/014_notice-me-senpai/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---------------------------------------------------------------------------------------------------
Version: 1.0.9
Date: 2024. 12. 17
Info:
- Make the colors configurable for colorblind people
---------------------------------------------------------------------------------------------------
Version: 1.0.8
Date: 2024. 11. 18
Info:
Expand Down
19 changes: 16 additions & 3 deletions mods_2.0/014_notice-me-senpai/control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ local function playerdata_create(player_index)
redraw = false,

alt_mode = player.game_view_settings.show_entity_info,

colormap = {
green = settings.get_player_settings(player.index)["notice-me-senpai--green" ].value,
yellow = settings.get_player_settings(player.index)["notice-me-senpai--yellow"].value,
red = settings.get_player_settings(player.index)["notice-me-senpai--red" ].value,
}
}
end

Expand Down Expand Up @@ -149,13 +155,20 @@ local function position_key(position)
return string.format("[%g, %g]", position.x, position.y)
end

-- kept as fallback for pre 1.0.9
local colors = {
green = {0.0, 0.9, 0.0, 1},
yellow = {0.9, 0.9, 0.0, 1},
red = {0.9, 0.0, 0.0, 1},
}

local function get_color_for_tile_key(playerdata, tile_key)
if playerdata.green_positions[tile_key] then
return {0, 0.9, 0, 1} -- green
return playerdata.colormap["green"] or colors["green"]
elseif playerdata.yellow_positions[tile_key] then
return {0.9, 0.9, 0, 1} -- yellow
return playerdata.colormap["yellow"] or colors["yellow"]
else
return {0.9, 0, 0, 1} -- red
return playerdata.colormap["red"] or colors["red"]
end
end

Expand Down
2 changes: 1 addition & 1 deletion mods_2.0/014_notice-me-senpai/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "Notice me senpai",
"description": "Highlights resources with no drill on them yet when holding a miner.",

"version": "1.0.8",
"version": "1.0.9",
"author": "Quezler",
"factorio_version": "2.0",

Expand Down
4 changes: 4 additions & 0 deletions mods_2.0/014_notice-me-senpai/locale/en/strings.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[mod-setting-name]
notice-me-senpai--green=Green
notice-me-senpai--yellow=Yellow
notice-me-senpai--red=Red
22 changes: 22 additions & 0 deletions mods_2.0/014_notice-me-senpai/settings.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
local mod_prefix = "notice-me-senpai--"

data:extend({
{
type = "color-setting",
name = mod_prefix .. "green",
setting_type = "runtime-per-user",
default_value = {0.0, 0.9, 0.0, 1},
},
{
type = "color-setting",
name = mod_prefix .. "yellow",
setting_type = "runtime-per-user",
default_value = {0.9, 0.9, 0.0, 1},
},
{
type = "color-setting",
name = mod_prefix .. "red",
setting_type = "runtime-per-user",
default_value = {0.9, 0.0, 0.0, 1},
},
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---------------------------------------------------------------------------------------------------
Version: 1.0.3
Date: 2024. 12. 17
Info:
- Make the colors configurable for colorblind people
---------------------------------------------------------------------------------------------------
Version: 1.0.2
Date: 2024. 11. 15
Info:
Expand Down
59 changes: 32 additions & 27 deletions mods_2.0/028_agricultural-tower-placement-helper/control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ script.on_event(defines.events.on_player_cursor_stack_changed, function(event)
tile_render_objects = {},

alt_mode = player.game_view_settings.show_entity_info,

colormap = {
green = settings.get_player_settings(player.index)["agricultural-tower-placement-helper--green" ].value,
yellow = settings.get_player_settings(player.index)["agricultural-tower-placement-helper--yellow"].value,
red = settings.get_player_settings(player.index)["agricultural-tower-placement-helper--red" ].value,
}
}

Handler.tick_player(event)
Expand Down Expand Up @@ -122,8 +128,7 @@ script.on_event(defines.events.on_player_toggled_alt_mode, function(event)
end
end)

--

-- kept as fallback for pre 1.0.3
local colors = {
green = {0.0, 0.9, 0.0, 1},
yellow = {0.9, 0.9, 0.0, 1},
Expand All @@ -133,36 +138,36 @@ local colors = {
-- todo: generate from prototypes.
local tile_name_to_color = {
-- currently plantable for yumako
["natural-yumako-soil" ] = colors.green,
["artificial-yumako-soil"] = colors.green,
["overgrowth-yumako-soil"] = colors.green,
["natural-yumako-soil" ] = "green",
["artificial-yumako-soil"] = "green",
["overgrowth-yumako-soil"] = "green",

-- currently plantable for jellynut
["natural-jellynut-soil" ] = colors.green,
["artificial-jellynut-soil"] = colors.green,
["overgrowth-jellynut-soil"] = colors.green,
["natural-jellynut-soil" ] = "green",
["artificial-jellynut-soil"] = "green",
["overgrowth-jellynut-soil"] = "green",

-- future plantable for yumako
["wetland-light-green-slime"] = colors.red,
["wetland-green-slime" ] = colors.red,
["wetland-yumako" ] = colors.yellow, -- artificial soil
["lowland-olive-blubber" ] = colors.red,
["lowland-olive-blubber-2" ] = colors.red,
["lowland-olive-blubber-3" ] = colors.red,
["lowland-brown-blubber" ] = colors.red,
["lowland-pale-green" ] = colors.red,
["wetland-light-green-slime"] = "red",
["wetland-green-slime" ] = "red",
["wetland-yumako" ] = "yellow", -- artificial soil
["lowland-olive-blubber" ] = "red",
["lowland-olive-blubber-2" ] = "red",
["lowland-olive-blubber-3" ] = "red",
["lowland-brown-blubber" ] = "red",
["lowland-pale-green" ] = "red",

-- future plantable for jellynut
["wetland-pink-tentacle"] = colors.red,
["wetland-red-tentacle" ] = colors.red,
["wetland-jellynut" ] = colors.yellow, -- artificial soil
["lowland-red-vein" ] = colors.red,
["lowland-red-vein-2" ] = colors.red,
["lowland-red-vein-3" ] = colors.red,
["lowland-red-vein-4" ] = colors.red,
["lowland-red-vein-dead"] = colors.red,
["lowland-red-infection"] = colors.red,
["lowland-cream-red" ] = colors.red,
["wetland-pink-tentacle"] = "red",
["wetland-red-tentacle" ] = "red",
["wetland-jellynut" ] = "yellow", -- artificial soil
["lowland-red-vein" ] = "red",
["lowland-red-vein-2" ] = "red",
["lowland-red-vein-3" ] = "red",
["lowland-red-vein-4" ] = "red",
["lowland-red-vein-dead"] = "red",
["lowland-red-infection"] = "red",
["lowland-cream-red" ] = "red",
}

local tile_names = {}
Expand Down Expand Up @@ -217,7 +222,7 @@ function Handler.tick_player(event)
target = {tile.position.x + 0.5, tile.position.y + 0.5},
radius = playerdata.alt_mode and 0.2 or 0.1,

color = color,
color = playerdata.colormap[color] or colors[color],
filled = true,

players = {playerdata.player_index},
Expand Down
2 changes: 1 addition & 1 deletion mods_2.0/028_agricultural-tower-placement-helper/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "Agricultural tower placement helper",
"description": "Shows you the difference between tiles that require artificial soil vs (yet to unlock) overgrowth soil.",

"version": "1.0.2",
"version": "1.0.3",
"author": "Quezler",
"factorio_version": "2.0",

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[mod-setting-name]
agricultural-tower-placement-helper--green=Green
agricultural-tower-placement-helper--yellow=Yellow
agricultural-tower-placement-helper--red=Red
22 changes: 22 additions & 0 deletions mods_2.0/028_agricultural-tower-placement-helper/settings.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
local mod_prefix = "agricultural-tower-placement-helper--"

data:extend({
{
type = "color-setting",
name = mod_prefix .. "green",
setting_type = "runtime-per-user",
default_value = {0.0, 0.9, 0.0, 1},
},
{
type = "color-setting",
name = mod_prefix .. "yellow",
setting_type = "runtime-per-user",
default_value = {0.9, 0.9, 0.0, 1},
},
{
type = "color-setting",
name = mod_prefix .. "red",
setting_type = "runtime-per-user",
default_value = {0.9, 0.0, 0.0, 1},
},
})

0 comments on commit adb731c

Please sign in to comment.