Skip to content

Commit

Permalink
more debug.
Browse files Browse the repository at this point in the history
  • Loading branch information
nagolove committed Jun 20, 2021
1 parent 382bee6 commit 61dfab6
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 10 deletions.
6 changes: 6 additions & 0 deletions colorconstants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 th






local colors = {

["black"] = { 136 / 255, 55 / 255, 41 / 255 },
["white"] = { 136 / 255, 55 / 255, 41 / 255 },


["brown"] = { 136 / 255, 55 / 255, 41 / 255 },
["green"] = { 72 / 255, 180 / 255, 66 / 255 },
["blue"] = { 27 / 255, 30 / 255, 249 / 255 },
Expand Down
6 changes: 6 additions & 0 deletions colorconstants.tl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@
--["purple"] = {128 / 255, 7 / 255, 128 / 255}, } as ConstantsTable, constans_mt as metatable<ConstantsTable>)
--end

-- TODO Расширить палитру парами дополненных цветов
local colors: {string:{number}} = {
-- отладочные цвета
["black"] = {136 / 255, 55 / 255, 41 / 255},
["white"] = {136 / 255, 55 / 255, 41 / 255},

-- основные цвета
["brown"] = {136 / 255, 55 / 255, 41 / 255},
["green"] = {72 / 255, 180 / 255, 66 / 255},
["blue"] = {27 / 255, 30 / 255, 249 / 255},
Expand Down
1 change: 1 addition & 0 deletions layout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ function splitvByNum(tbl, piecesNum)
return _tl_table_unpack(subTbls)
end

-- что делает эта функция?
function shrink(tbl, value)
assertHelper(tbl)
assert(type(value) == "number", string.format("number expected, but %s is", type(value)))
Expand Down
38 changes: 33 additions & 5 deletions nback.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ local yield = coroutine.yield









Expand Down Expand Up @@ -1143,6 +1146,7 @@ function Nback:check(signalType)
end

function Nback:resize(neww, newh)
colprint('Nback:resize()')
print(string.format("resized to %d * %d", neww, newh))
self:buildLayout()

Expand All @@ -1152,6 +1156,13 @@ function Nback:resize(neww, newh)
self.cellWidth = math.ceil(self.layout.center.h / self.dim)

self.bhupur_h = self.cellWidth * self.dim

print(inspect(self.layout))

print('Nback:resize() x0, y0',
self.layout.center.x + (self.layout.center.w - self.layout.center.h) / 2,
self.layout.center.y)

self.x0, self.y0 = self.layout.center.x + (self.layout.center.w - self.layout.center.h) / 2, self.layout.center.y
self.processor = require("coroprocessor").new()

Expand Down Expand Up @@ -1206,20 +1217,35 @@ end

function Nback:drawActiveSignal()
print('Nback:drawActiveSignal()')

local pos = self.signals.pos[self.currentSig]

print("self.signals", inspect(self.signals))
print("self.signals.pos", inspect(self.signals.pos[self.currentSig]))
print('pos', inspect(pos))

local x, y = pos.x, pos.y

print('self.current_sig', inspect(self.currentSig))
print('self.signals.color', inspect(self.signals.color))
print('colorConstants.colors', inspect(colorConstants.colors))
print('hmm', inspect(self.signals.color[self.currentSig]))
if (not x) or (not y) then
x, y = 1, 1
colprint('No right position, using default (1, 1)')
end

print('x, y', x, y)









local sig_color = colorConstants.colors[self.signals.color[self.currentSig]]
print('sig_color', sig_color)
if not sig_color then
colprint('Not right color, using default.')
sig_color = colorConstants.colors['black']
end

if self.figureAlpha then
sig_color[4] = self.figureAlpha
Expand All @@ -1228,6 +1254,7 @@ function Nback:drawActiveSignal()
end

local curtype = self.signals.form[self.currentSig]
print(x, y, inspect(curtype), inspect(sig_color))
self.signalView:draw(x, y, curtype, sig_color)
end

Expand All @@ -1236,6 +1263,7 @@ function Nback:drawField()
g.setColor(self.fieldColor)
local oldwidth = g.getLineWidth()
g.setLineWidth(2)
print('self.x0, self.y0', self.x0, self.y0)
for i = 0, self.dim do

g.line(self.x0, self.y0 + i * self.cellWidth,
Expand Down
30 changes: 29 additions & 1 deletion nback.tl
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,11 @@ global type Nback = record
shaderTimeEnabled: boolean
figureAlpha: number
bhupur_h: number

-- координаты левого верхнего угла экрана(в пикселях?)
x0: number
y0: number

processor: CoroProcessor
statisticRender: StatisticRender
volume: number
Expand Down Expand Up @@ -1143,6 +1146,7 @@ function Nback:check(signalType: Signals.EqKeys)
end

function Nback:resize(neww: integer, newh: integer)
colprint('Nback:resize()')
print(string.format("resized to %d * %d", neww, newh))
self:buildLayout()

Expand All @@ -1152,6 +1156,13 @@ function Nback:resize(neww: integer, newh: integer)
self.cellWidth = math.ceil(self.layout.center.h / self.dim)

self.bhupur_h = self.cellWidth * self.dim

print(inspect(self.layout))

print('Nback:resize() x0, y0',
self.layout.center.x + (self.layout.center.w - self.layout.center.h) / 2,
self.layout.center.y)

self.x0, self.y0 = self.layout.center.x + (self.layout.center.w - self.layout.center.h) / 2, self.layout.center.y
self.processor = require "coroprocessor".new()

Expand Down Expand Up @@ -1206,20 +1217,35 @@ end

function Nback:drawActiveSignal()
print('Nback:drawActiveSignal()')

local pos = self.signals.pos[self.currentSig]

print("self.signals", inspect(self.signals))
print("self.signals.pos", inspect(self.signals.pos[self.currentSig]))
print('pos', inspect(pos))

local x, y = pos.x, pos.y

if (not x) or (not y) then
x, y = 1, 1
colprint('No right position, using default (1, 1)')
end

print('x, y', x, y)

--[[
print('self.current_sig', inspect(self.currentSig))
print('self.signals.color', inspect(self.signals.color))
print('colorConstants.colors', inspect(colorConstants.colors))
print('hmm', inspect(self.signals.color[self.currentSig]))
print('sig_color', sig_color)
--]]

local sig_color = colorConstants.colors[self.signals.color[self.currentSig]]
print('sig_color', sig_color)
if not sig_color then
colprint('Not right color, using default.')
sig_color = colorConstants.colors['black']
end

if self.figureAlpha then
sig_color[4] = self.figureAlpha
Expand All @@ -1228,6 +1254,7 @@ function Nback:drawActiveSignal()
end
--print("sig_color[4]", sig_color[4])
local curtype: string = self.signals.form[self.currentSig]
print(x, y, inspect(curtype), inspect(sig_color))
self.signalView:draw(x, y, curtype, sig_color)
end

Expand All @@ -1236,6 +1263,7 @@ function Nback:drawField()
g.setColor(self.fieldColor)
local oldwidth = g.getLineWidth()
g.setLineWidth(2)
print('self.x0, self.y0', self.x0, self.y0)
for i = 0, self.dim do
-- horizontal
g.line(self.x0, self.y0 + i * self.cellWidth,
Expand Down
4 changes: 2 additions & 2 deletions signal_quad_field.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ local inspect = require("inspect")






local SignalView_mt = {
Expand Down Expand Up @@ -109,6 +108,7 @@ end


function SignalView:setCorner(x, y)
print('SignalView:setCorner()', x, y)
self.x0, self.y0 = x, y
end

Expand All @@ -128,7 +128,7 @@ end


function SignalView:draw(xd, yd, type_, color)
print('SignalView:draw()', xd, yd, type_, color)




Expand Down
4 changes: 2 additions & 2 deletions signal_quad_field.tl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ global type SignalView = record
resize: function(SignalView, number, number)
resize: function(SignalView, width: number)
rhombus: function(SignalView, x: number, y: number, w: number, h: number)
setCorner: function(SignalView, number, number)
setCorner: function(SignalView, x: number, y: number)
trdown: function(SignalView, x: number, y: number, w: number, h: number)
trup: function(SignalView, x: number, y: number, w: number, h: number)
Expand Down Expand Up @@ -109,6 +108,7 @@ end
-- установить координаты левого верхнего угла, от которого идет отсчет ячеек.
-- обязательно вызывать перед рисовкой.
function SignalView:setCorner(x: number, y: number)
print('SignalView:setCorner()', x, y)
self.x0, self.y0 = x, y
end

Expand All @@ -128,7 +128,7 @@ end
-- треугольник вверх, пересечение треугольников, ромб)
-- color - текущий цвет
function SignalView:draw(xd: number, yd: number, type_: string, color: {number})
print('SignalView:draw()', xd, yd, type_, color)
--print('SignalView:draw()', xd, yd, inspect(type_), inspect(color))

--local currentHex = self.hexfield:get(xd, yd)

Expand Down

0 comments on commit 61dfab6

Please sign in to comment.