Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paint Shop - Randomize colors #6069

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions data/lang/ui-core/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2011,6 +2011,10 @@
"description": "For the checkbox in settings window",
"message": "Quit confirmation"
},
"RANDOM_COLORS": {
"description": "Paint shop. Randomize colors",
"message": "Random Colors"
},
"RANDOM_FACE": {
"description": "Generate random face",
"message": "Random"
Expand Down
50 changes: 39 additions & 11 deletions data/pigui/modules/station-view/06-shipRepairs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ local ui = require 'pigui'
local StationView = require 'pigui.views.station-view'
local ShipDef = require "ShipDef"
local Game = require "Game"
local Engine = require 'Engine'
local Rand = require "Rand"
local PiGuiFace = require 'pigui.libs.face'
local Format = require "Format"
Expand Down Expand Up @@ -298,15 +299,6 @@ local function drawPaintshop()
secChanged, previewColors[2] = ui.colorEdit((l.COLOR.." 2"), previewColors[2], { "NoAlpha" })
triChanged, previewColors[3] = ui.colorEdit((l.COLOR.." 3"), previewColors[3], { "NoAlpha" })

local colorChanged = (priChanged or secChanged or triChanged)
if colorChanged then
changesMade = true
end

if colorChanged then
changeColor()
end

ui.withFont(pionillium.body, function()

if ui.button("<", Vector2(20, 36)) then
Expand All @@ -320,11 +312,47 @@ local function drawPaintshop()
end

ui.sameLine()

if ui.button(l.RESET_PREVIEW, Vector2(200, 36)) then
if ui.button(l.RESET_PREVIEW, Vector2(columnWidth/4, 36)) then
resetPreview()
end

ui.sameLine()
if ui.button(l.RANDOM_COLORS, Vector2(columnWidth/4, 36)) then

local function randomColor()
return Color(Engine.rand:Integer(0,255), Engine.rand:Integer(0,255), Engine.rand:Integer(0,255))
end

previewColors[1] = randomColor()
previewColors[2] = randomColor()
previewColors[3] = randomColor()

-- preview colors may be the same
if Engine.rand:Integer(0,2) < 1 then
local color = Engine.rand:Integer(1,4)
if color == 1 then
previewColors[2] = previewColors[1]
elseif color == 2 then
previewColors[3] = previewColors[1]
elseif color == 3 then
previewColors[3] = previewColors[2]
else -- All colors the same
previewColors[2] = previewColors[1]
previewColors[3] = previewColors[1]
end
end
priChanged = true -- All colors changed but we only need to hint one
end

local colorChanged = (priChanged or secChanged or triChanged)
if colorChanged then
changesMade = true
end

if colorChanged then
changeColor()
end

ui.dummy(verticalDummy)

ui.withStyleColors({Text = priceColor }, function()
Expand Down